qt4runconfiguration.h 7.05 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>
con's avatar
con committed
34
#include <projectexplorer/applicationrunconfiguration.h>
35
36
#include <projectexplorer/environment.h>
#include <projectexplorer/environmenteditmodel.h>
con's avatar
con committed
37
#include <QtCore/QStringList>
38
39
#include <QtGui/QWidget>

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

namespace Qt4ProjectManager {

class Qt4Project;

namespace Internal {

55
class Qt4PriFileNode;
56

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

    virtual QString type() const;
67
    virtual bool isEnabled() const;
con's avatar
con committed
68
69
70
71
72
73
74
75
76
    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;
77
    virtual QString dumperLibrary() const;
78
    virtual QStringList dumperLibraryLocations() const;
79
    virtual ProjectExplorer::ToolChain::ToolChainType toolChainType() const;
con's avatar
con committed
80

81
82
    bool isUsingDyldImageSuffix() const;
    void setUsingDyldImageSuffix(bool state);
con's avatar
con committed
83
84
    QString proFilePath() const;

85
86
87
88
89
90
91
92
93
    // 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
94

95
96
97
signals:
    void nameChanged(const QString&);
    void commandLineArgumentsChanged(const QString&);
98
    void workingDirectoryChanged(const QString&);
99
    void runModeChanged(ProjectExplorer::ApplicationRunConfiguration::RunMode runMode);
100
    void usingDyldImageSuffixChanged(bool);
101
    void baseEnvironmentChanged();
102
    void userEnvironmentChangesChanged(const QList<ProjectExplorer::EnvironmentItem> &diff);
103
104

    // note those signals might not emited for every change
105
    void effectiveTargetInformationChanged();
106

con's avatar
con committed
107
108
private slots:
    void setCommandLineArguments(const QString &argumentsString);
109
    void setWorkingDirectory(const QString &workingDirectory);
con's avatar
con committed
110
    void nameEdited(const QString&);
111
    void setRunMode(RunMode runMode);
con's avatar
con committed
112
113

private:
114
115
116
    enum BaseEnvironmentBase { CleanEnvironmentBase = 0,
                               SystemEnvironmentBase = 1,
                               BuildEnvironmentBase  = 2 };
117
118
119
    void setBaseEnvironmentBase(BaseEnvironmentBase env);
    BaseEnvironmentBase baseEnvironmentBase() const;

120
121
122
123
    ProjectExplorer::Environment baseEnvironment() const;
    void setUserEnvironmentChanges(const QList<ProjectExplorer::EnvironmentItem> &diff);
    QList<ProjectExplorer::EnvironmentItem> userEnvironmentChanges() const;

124
    void updateTarget();
con's avatar
con committed
125
126
127
128
129
130
131
132
133
    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;
    ProjectExplorer::ApplicationRunConfiguration::RunMode m_runMode;
    bool m_userSetName;
134
    QWidget *m_configWidget;
135
    bool m_cachedTargetInformationValid;
136
    bool m_isUsingDyldImageSuffix;
137
138
    bool m_userSetWokingDirectory;
    QString m_userWorkingDirectory;
139
    QList<ProjectExplorer::EnvironmentItem> m_userEnvironmentChanges;
140
    BaseEnvironmentBase m_baseEnvironmentBase;
141
142
143
144
145
146
147
};

class Qt4RunConfigurationWidget : public QWidget
{
    Q_OBJECT
public:
    Qt4RunConfigurationWidget(Qt4RunConfiguration *qt4runconfigration, QWidget *parent);
148
149
150
protected:
    void showEvent(QShowEvent *event);
    void hideEvent(QHideEvent *event);
151
private slots:
152
153
    void setWorkingDirectory();
    void resetWorkingDirectory();
154
155
    void setCommandLineArguments(const QString &arguments);
    void nameEdited(const QString &name);
156
    void userChangesUpdated();
157
158

    void workingDirectoryChanged(const QString &workingDirectory);
159
160
    void commandLineArgumentsChanged(const QString &args);
    void nameChanged(const QString &name);
161
    void runModeChanged(ProjectExplorer::ApplicationRunConfiguration::RunMode runMode);
162
    void userEnvironmentChangesChanged(const QList<ProjectExplorer::EnvironmentItem> &userChanges);
163
    void baseEnvironmentChanged();
164

165
    void effectiveTargetInformationChanged();
166
    void termToggled(bool);
167
168
    void usingDyldImageSuffixToggled(bool);
    void usingDyldImageSuffixChanged(bool);
169
    void baseEnvironmentComboBoxChanged(int index);
170
171
172
173
private:
    Qt4RunConfiguration *m_qt4RunConfiguration;
    bool m_ignoreChange;
    QLabel *m_executableLabel;
174
    Core::Utils::PathChooser *m_workingDirectoryEdit;
175
176
    QLineEdit *m_nameLineEdit;
    QLineEdit *m_argumentsLineEdit;
177
    QCheckBox *m_useTerminalCheck;
178
    QCheckBox *m_usingDyldImageSuffix;
179

180
    QComboBox *m_baseEnvironmentComboBox;
181

182
    ProjectExplorer::EnvironmentWidget *m_environmentWidget;
183
    bool m_isShown;
con's avatar
con committed
184
185
186
187
188
189
190
191
};

class Qt4RunConfigurationFactory : public ProjectExplorer::IRunConfigurationFactory
{
    Q_OBJECT
public:
    Qt4RunConfigurationFactory();
    virtual ~Qt4RunConfigurationFactory();
con's avatar
con committed
192
    virtual bool canRestore(const QString &type) const;
con's avatar
con committed
193
    virtual QSharedPointer<ProjectExplorer::RunConfiguration> create(ProjectExplorer::Project *project, const QString &type);
con's avatar
con committed
194
195
    QStringList availableCreationTypes(ProjectExplorer::Project *pro) const;
    QString displayNameForType(const QString &type) const;
con's avatar
con committed
196
197
198
199
200
201
};

} // namespace Internal
} // namespace Qt4ProjectManager

#endif // QT4RUNCONFIGURATION_H