qt4runconfiguration.h 7.36 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 display 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;

70
    virtual QString id() 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
signals:
100
    void displayNameChanged(const QString&);
101
    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
    ProjectExplorer::Environment baseEnvironment() const;
126
    QString baseEnvironmentText() const;
127
128
129
    void setUserEnvironmentChanges(const QList<ProjectExplorer::EnvironmentItem> &diff);
    QList<ProjectExplorer::EnvironmentItem> userEnvironmentChanges() const;

130
    void updateTarget();
con's avatar
con committed
131
132
133
134
135
136
137
    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;
138
    ProjectExplorer::LocalApplicationRunConfiguration::RunMode m_runMode;
con's avatar
con committed
139
    bool m_userSetName;
140
    bool m_cachedTargetInformationValid;
141
    bool m_isUsingDyldImageSuffix;
142
143
    bool m_userSetWokingDirectory;
    QString m_userWorkingDirectory;
144
    QList<ProjectExplorer::EnvironmentItem> m_userEnvironmentChanges;
145
    BaseEnvironmentBase m_baseEnvironmentBase;
146
147
148
149
150
151
152
};

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

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

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

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

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

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

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

} // namespace Internal
} // namespace Qt4ProjectManager

#endif // QT4RUNCONFIGURATION_H