qt4runconfiguration.h 7.3 KB
Newer Older
1
/**************************************************************************
con's avatar
con committed
2
3
4
**
** This file is part of Qt Creator
**
5
** Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
con's avatar
con committed
6
**
7
** Contact: Nokia Corporation (qt-info@nokia.com)
con's avatar
con committed
8
**
9
** Commercial Usage
10
**
11
12
13
14
** Licensees holding valid Qt Commercial licenses may use this file in
** accordance with the Qt Commercial License Agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
** a written agreement between you and Nokia.
15
**
16
** GNU Lesser General Public License Usage
17
**
18
19
20
21
22
23
** 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.
24
**
25
** If you are unsure which license is appropriate for your use, please
hjk's avatar
hjk committed
26
** contact the sales department at http://qt.nokia.com/contact.
con's avatar
con committed
27
**
28
**************************************************************************/
hjk's avatar
hjk committed
29

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

33
#include <utils/pathchooser.h>
dt's avatar
dt committed
34
#include <utils/detailswidget.h>
con's avatar
con committed
35
#include <projectexplorer/applicationrunconfiguration.h>
36
37
#include <projectexplorer/environment.h>
#include <projectexplorer/environmenteditmodel.h>
con's avatar
con committed
38
#include <QtCore/QStringList>
39
#include <QtGui/QWidget>
dt's avatar
dt committed
40
#include <QtGui/QToolButton>
41

hjk's avatar
hjk committed
42
QT_BEGIN_NAMESPACE
43
class QWidget;
44
class QCheckBox;
45
46
class QLabel;
class QLineEdit;
47
class QRadioButton;
48
class QComboBox;
hjk's avatar
hjk committed
49
QT_END_NAMESPACE
con's avatar
con committed
50
51
52
53
54
55

namespace Qt4ProjectManager {

class Qt4Project;

namespace Internal {
56
class Qt4PriFileNode;
57
class Qt4ProFileNode;
58

59
class Qt4RunConfiguration : public ProjectExplorer::LocalApplicationRunConfiguration
con's avatar
con committed
60
61
{
    Q_OBJECT
62
    // to change the name and arguments and set the userenvironmentchanges
63
    friend class Qt4RunConfigurationWidget;
con's avatar
con committed
64
public:
65
    Qt4RunConfiguration(Qt4Project *pro, const QString &proFilePath);
con's avatar
con committed
66
67
    virtual ~Qt4RunConfiguration();

dt's avatar
dt committed
68
69
    Qt4Project *qt4Project() const;

con's avatar
con committed
70
    virtual QString type() const;
71
    virtual bool isEnabled(ProjectExplorer::BuildConfiguration *configuration) const;
con's avatar
con committed
72
73
74
75
76
77
78
79
80
    virtual QWidget *configurationWidget();
    virtual void save(ProjectExplorer::PersistentSettingsWriter &writer) const;
    virtual void restore(const ProjectExplorer::PersistentSettingsReader &reader);

    virtual QString executable() const;
    virtual RunMode runMode() const;
    virtual QString workingDirectory() const;
    virtual QStringList commandLineArguments() const;
    virtual ProjectExplorer::Environment environment() const;
81
    virtual QString dumperLibrary() const;
82
    virtual QStringList dumperLibraryLocations() const;
83
    virtual ProjectExplorer::ToolChain::ToolChainType toolChainType() const;
con's avatar
con committed
84

85
86
    bool isUsingDyldImageSuffix() const;
    void setUsingDyldImageSuffix(bool state);
con's avatar
con committed
87
88
    QString proFilePath() const;

89
90
91
92
93
94
95
96
97
    // TODO detectQtShadowBuild() ? how did this work ?

public slots:
    // This function is called if:
    // X the pro file changes
    // X the active buildconfiguration changes
    // X  the qmake parameters change
    // X  the build directory changes
    void invalidateCachedTargetInformation();
con's avatar
con committed
98

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

    // note those signals might not emited for every change
109
    void effectiveTargetInformationChanged();
110

con's avatar
con committed
111
private slots:
112
113
    void proFileUpdate(Qt4ProjectManager::Internal::Qt4ProFileNode *pro);
    void setArguments(const QString &argumentsString);
114
    void setWorkingDirectory(const QString &workingDirectory);
115
    void setUserName(const QString&);
116
    void setRunMode(RunMode runMode);
con's avatar
con committed
117
118

private:
119
120
121
    enum BaseEnvironmentBase { CleanEnvironmentBase = 0,
                               SystemEnvironmentBase = 1,
                               BuildEnvironmentBase  = 2 };
122
123
124
    void setBaseEnvironmentBase(BaseEnvironmentBase env);
    BaseEnvironmentBase baseEnvironmentBase() const;

125
126
127
128
    ProjectExplorer::Environment baseEnvironment() const;
    void setUserEnvironmentChanges(const QList<ProjectExplorer::EnvironmentItem> &diff);
    QList<ProjectExplorer::EnvironmentItem> userEnvironmentChanges() const;

129
    void updateTarget();
con's avatar
con committed
130
131
132
133
134
135
136
    QStringList m_commandLineArguments;
    QString m_proFilePath; // Full path to the Application Pro File

    // Cached startup sub project information
    QStringList m_targets;
    QString m_executable;
    QString m_workingDir;
137
    ProjectExplorer::LocalApplicationRunConfiguration::RunMode m_runMode;
con's avatar
con committed
138
    bool m_userSetName;
139
    bool m_cachedTargetInformationValid;
140
    bool m_isUsingDyldImageSuffix;
141
142
    bool m_userSetWokingDirectory;
    QString m_userWorkingDirectory;
143
    QList<ProjectExplorer::EnvironmentItem> m_userEnvironmentChanges;
144
    BaseEnvironmentBase m_baseEnvironmentBase;
145
146
147
148
149
150
151
};

class Qt4RunConfigurationWidget : public QWidget
{
    Q_OBJECT
public:
    Qt4RunConfigurationWidget(Qt4RunConfiguration *qt4runconfigration, QWidget *parent);
152
153
154
protected:
    void showEvent(QShowEvent *event);
    void hideEvent(QHideEvent *event);
155
private slots:
156
157
158
    void workDirectoryEdited();
    void workingDirectoryReseted();
    void argumentsEdited(const QString &arguments);
159
    void nameEdited(const QString &name);
160
    void userChangesEdited();
161
162

    void workingDirectoryChanged(const QString &workingDirectory);
163
164
    void commandLineArgumentsChanged(const QString &args);
    void nameChanged(const QString &name);
165
    void runModeChanged(ProjectExplorer::LocalApplicationRunConfiguration::RunMode runMode);
166
    void userEnvironmentChangesChanged(const QList<ProjectExplorer::EnvironmentItem> &userChanges);
167
    void baseEnvironmentChanged();
168

169
    void effectiveTargetInformationChanged();
170
    void termToggled(bool);
171
172
    void usingDyldImageSuffixToggled(bool);
    void usingDyldImageSuffixChanged(bool);
173
    void baseEnvironmentSelected(int index);
dt's avatar
dt committed
174

175
private:
dt's avatar
dt committed
176
    void updateSummary();
177
178
179
    Qt4RunConfiguration *m_qt4RunConfiguration;
    bool m_ignoreChange;
    QLabel *m_executableLabel;
180
    Utils::PathChooser *m_workingDirectoryEdit;
181
182
    QLineEdit *m_nameLineEdit;
    QLineEdit *m_argumentsLineEdit;
183
    QCheckBox *m_useTerminalCheck;
184
    QCheckBox *m_usingDyldImageSuffix;
185

186
    QComboBox *m_baseEnvironmentComboBox;
dt's avatar
dt committed
187
    Utils::DetailsWidget *m_detailsContainer;
188

189
    ProjectExplorer::EnvironmentWidget *m_environmentWidget;
190
    bool m_isShown;
con's avatar
con committed
191
192
193
194
195
196
197
198
};

class Qt4RunConfigurationFactory : public ProjectExplorer::IRunConfigurationFactory
{
    Q_OBJECT
public:
    Qt4RunConfigurationFactory();
    virtual ~Qt4RunConfigurationFactory();
con's avatar
con committed
199
    virtual bool canRestore(const QString &type) const;
200
    virtual ProjectExplorer::RunConfiguration *create(ProjectExplorer::Project *project, const QString &type);
con's avatar
con committed
201
202
    QStringList availableCreationTypes(ProjectExplorer::Project *pro) const;
    QString displayNameForType(const QString &type) const;
con's avatar
con committed
203
204
205
206
207
208
};

} // namespace Internal
} // namespace Qt4ProjectManager

#endif // QT4RUNCONFIGURATION_H