qt4runconfiguration.h 8.1 KB
Newer Older
hjk's avatar
hjk committed
1
/****************************************************************************
con's avatar
con committed
2
**
3
** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
hjk's avatar
hjk committed
4
** Contact: http://www.qt-project.org/legal
con's avatar
con committed
5
**
hjk's avatar
hjk committed
6
** This file is part of Qt Creator.
con's avatar
con committed
7
**
hjk's avatar
hjk committed
8 9 10 11 12 13 14
** Commercial License Usage
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
** a written agreement between you and Digia.  For licensing terms and
** conditions see http://qt.digia.com/licensing.  For further information
** use the contact form at http://qt.digia.com/contact-us.
15
**
16
** GNU Lesser General Public License Usage
hjk's avatar
hjk committed
17 18 19 20 21 22
** Alternatively, this file may be used under the terms of the GNU Lesser
** General Public License version 2.1 as published by the Free Software
** Foundation and appearing in the file LICENSE.LGPL included in the
** packaging of this file.  Please review the following information to
** ensure the GNU Lesser General Public License version 2.1 requirements
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
23
**
hjk's avatar
hjk committed
24 25
** In addition, as a special exception, Digia gives you certain additional
** rights.  These rights are described in the Digia Qt LGPL Exception
con's avatar
con committed
26 27
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
hjk's avatar
hjk committed
28
****************************************************************************/
hjk's avatar
hjk committed
29

con's avatar
con committed
30 31 32
#ifndef QT4RUNCONFIGURATION_H
#define QT4RUNCONFIGURATION_H

Tobias Hunger's avatar
Tobias Hunger committed
33 34
#include "qmakerunconfigurationfactory.h"

35
#include <projectexplorer/localapplicationrunconfiguration.h>
36 37 38

#include <utils/environment.h>

39 40 41
#include <QStringList>
#include <QLabel>
#include <QWidget>
42

hjk's avatar
hjk committed
43
QT_BEGIN_NAMESPACE
44
class QCheckBox;
45
class QLineEdit;
46
class QRadioButton;
47
class QComboBox;
hjk's avatar
hjk committed
48
QT_END_NAMESPACE
con's avatar
con committed
49

50 51 52 53 54 55 56 57 58
namespace Utils {
class PathChooser;
class DetailsWidget;
}

namespace ProjectExplorer {
    class EnvironmentWidget;
}

con's avatar
con committed
59
namespace Qt4ProjectManager {
60

con's avatar
con committed
61
class Qt4Project;
62
class Qt4ProFileNode;
Daniel Teske's avatar
Daniel Teske committed
63
class Qt4PriFileNode;
con's avatar
con committed
64 65

namespace Internal {
66
class Qt4RunConfigurationFactory;
67

68
class Qt4RunConfiguration : public ProjectExplorer::LocalApplicationRunConfiguration
con's avatar
con committed
69 70
{
    Q_OBJECT
71
    // to change the display name and arguments and set the userenvironmentchanges
72
    friend class Qt4RunConfigurationWidget;
73 74
    friend class Qt4RunConfigurationFactory;

con's avatar
con committed
75
public:
Tobias Hunger's avatar
Tobias Hunger committed
76
    Qt4RunConfiguration(ProjectExplorer::Target *parent, Core::Id id);
con's avatar
con committed
77 78
    virtual ~Qt4RunConfiguration();

79
    virtual bool isEnabled() const;
dt_'s avatar
dt_ committed
80
    virtual QString disabledReason() const;
81
    virtual QWidget *createConfigurationWidget();
con's avatar
con committed
82 83 84

    virtual QString executable() const;
    virtual RunMode runMode() const;
Tobias Hunger's avatar
Tobias Hunger committed
85
    bool forcedGuiMode() const;
con's avatar
con committed
86
    virtual QString workingDirectory() const;
87
    virtual QString commandLineArguments() const;
88
    virtual Utils::Environment environment() const;
89 90
    QString dumperLibrary() const;
    QStringList dumperLibraryLocations() const;
con's avatar
con committed
91

92 93
    bool isUsingDyldImageSuffix() const;
    void setUsingDyldImageSuffix(bool state);
94

con's avatar
con committed
95 96
    QString proFilePath() const;

97
    QVariantMap toMap() const;
98

con's avatar
con committed
99
    Utils::OutputFormatter *createOutputFormatter() const;
dt's avatar
dt committed
100

101
    void setRunMode(RunMode runMode);
102
signals:
103
    void commandLineArgumentsChanged(const QString&);
104
    void baseWorkingDirectoryChanged(const QString&);
105
    void runModeChanged(ProjectExplorer::LocalApplicationRunConfiguration::RunMode runMode);
106
    void usingDyldImageSuffixChanged(bool);
107
    void baseEnvironmentChanged();
108
    void userEnvironmentChangesChanged(const QList<Utils::EnvironmentItem> &diff);
109

Tobias Hunger's avatar
Tobias Hunger committed
110
    // Note: These signals might not get emitted for every change!
111
    void effectiveTargetInformationChanged();
112

con's avatar
con committed
113
private slots:
Tobias Hunger's avatar
Tobias Hunger committed
114
    void kitChanged();
115
    void proFileUpdated(Qt4ProjectManager::Qt4ProFileNode *pro, bool success, bool parseInProgress);
con's avatar
con committed
116

117
protected:
Tobias Hunger's avatar
Tobias Hunger committed
118
    Qt4RunConfiguration(ProjectExplorer::Target *parent, Qt4RunConfiguration *source);
119 120
    virtual bool fromMap(const QVariantMap &map);

con's avatar
con committed
121
private:
122
    void setBaseWorkingDirectory(const QString &workingDirectory);
123
    QString baseWorkingDirectory() const;
124
    void setCommandLineArguments(const QString &argumentsString);
125
    QString rawCommandLineArguments() const;
126 127 128
    enum BaseEnvironmentBase { CleanEnvironmentBase = 0,
                               SystemEnvironmentBase = 1,
                               BuildEnvironmentBase  = 2 };
129
    QString defaultDisplayName();
130 131 132
    void setBaseEnvironmentBase(BaseEnvironmentBase env);
    BaseEnvironmentBase baseEnvironmentBase() const;

133 134
    void ctor();

135
    Utils::Environment baseEnvironment() const;
136
    QString baseEnvironmentText() const;
137 138
    void setUserEnvironmentChanges(const QList<Utils::EnvironmentItem> &diff);
    QList<Utils::EnvironmentItem> userEnvironmentChanges() const;
139

140
    void updateTarget();
141
    QString m_commandLineArguments;
con's avatar
con committed
142 143 144
    QString m_proFilePath; // Full path to the Application Pro File

    // Cached startup sub project information
145
    ProjectExplorer::LocalApplicationRunConfiguration::RunMode m_runMode;
Tobias Hunger's avatar
Tobias Hunger committed
146
    bool m_forcedGuiMode;
con's avatar
con committed
147
    bool m_userSetName;
148
    bool m_isUsingDyldImageSuffix;
149
    QString m_userWorkingDirectory;
150
    QList<Utils::EnvironmentItem> m_userEnvironmentChanges;
151
    BaseEnvironmentBase m_baseEnvironmentBase;
152
    bool m_parseSuccess;
153
    bool m_parseInProgress;
154 155 156 157 158
};

class Qt4RunConfigurationWidget : public QWidget
{
    Q_OBJECT
159

160 161
public:
    Qt4RunConfigurationWidget(Qt4RunConfiguration *qt4runconfigration, QWidget *parent);
Tobias Hunger's avatar
Tobias Hunger committed
162 163
    ~Qt4RunConfigurationWidget();

164 165 166
protected:
    void showEvent(QShowEvent *event);
    void hideEvent(QHideEvent *event);
167

168
private slots:
169
    void runConfigurationEnabledChange();
170 171 172 173
    void workDirectoryEdited();
    void workingDirectoryReseted();
    void argumentsEdited(const QString &arguments);
    void userChangesEdited();
174 175

    void workingDirectoryChanged(const QString &workingDirectory);
176
    void commandLineArgumentsChanged(const QString &args);
177
    void runModeChanged(ProjectExplorer::LocalApplicationRunConfiguration::RunMode runMode);
178
    void userEnvironmentChangesChanged(const QList<Utils::EnvironmentItem> &userChanges);
179
    void baseEnvironmentChanged();
180

181
    void effectiveTargetInformationChanged();
182
    void termToggled(bool);
hjk's avatar
hjk committed
183
    void qvfbToggled(bool);
184 185
    void usingDyldImageSuffixToggled(bool);
    void usingDyldImageSuffixChanged(bool);
186
    void baseEnvironmentSelected(int index);
dt's avatar
dt committed
187

188 189 190
private:
    Qt4RunConfiguration *m_qt4RunConfiguration;
    bool m_ignoreChange;
191 192
    QLabel *m_disabledIcon;
    QLabel *m_disabledReason;
193
    QLineEdit *m_executableLineEdit;
194
    Utils::PathChooser *m_workingDirectoryEdit;
195
    QLineEdit *m_argumentsLineEdit;
196
    QCheckBox *m_useTerminalCheck;
hjk's avatar
hjk committed
197
    QCheckBox *m_useQvfbCheck;
198
    QCheckBox *m_usingDyldImageSuffix;
199
    QLineEdit *m_qmlDebugPort;
200

201
    QComboBox *m_baseEnvironmentComboBox;
dt's avatar
dt committed
202
    Utils::DetailsWidget *m_detailsContainer;
203
    ProjectExplorer::EnvironmentWidget *m_environmentWidget;
204
    bool m_isShown;
con's avatar
con committed
205 206
};

Tobias Hunger's avatar
Tobias Hunger committed
207
class Qt4RunConfigurationFactory : public QmakeRunConfigurationFactory
con's avatar
con committed
208 209
{
    Q_OBJECT
210

con's avatar
con committed
211
public:
212
    explicit Qt4RunConfigurationFactory(QObject *parent = 0);
Tobias Hunger's avatar
Tobias Hunger committed
213
    ~Qt4RunConfigurationFactory();
214

Tobias Hunger's avatar
Tobias Hunger committed
215 216 217 218
    bool canCreate(ProjectExplorer::Target *parent, const Core::Id id) const;
    bool canRestore(ProjectExplorer::Target *parent, const QVariantMap &map) const;
    bool canClone(ProjectExplorer::Target *parent, ProjectExplorer::RunConfiguration *source) const;
    ProjectExplorer::RunConfiguration *clone(ProjectExplorer::Target *parent, ProjectExplorer::RunConfiguration *source);
219

220 221
    QList<Core::Id> availableCreationIds(ProjectExplorer::Target *parent) const;
    QString displayNameForId(const Core::Id id) const;
Tobias Hunger's avatar
Tobias Hunger committed
222 223 224

    QList<ProjectExplorer::RunConfiguration *> runConfigurationsForNode(ProjectExplorer::Target *t,
                                                                        ProjectExplorer::Node *n);
225 226

private:
227 228
    bool canHandle(ProjectExplorer::Target *t) const;

229
    ProjectExplorer::RunConfiguration *doCreate(ProjectExplorer::Target *parent, const Core::Id id);
230 231
    ProjectExplorer::RunConfiguration *doRestore(ProjectExplorer::Target *parent,
                                                 const QVariantMap &map);
con's avatar
con committed
232 233 234 235 236 237
};

} // namespace Internal
} // namespace Qt4ProjectManager

#endif // QT4RUNCONFIGURATION_H