desktopqmakerunconfiguration.h 7.37 KB
Newer Older
hjk's avatar
hjk committed
1
/****************************************************************************
con's avatar
con committed
2
**
3
** Copyright (C) 2014 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
** 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
Eike Ziller's avatar
Eike Ziller committed
13
14
** conditions see http://www.qt.io/licensing.  For further information
** use the contact form at http://www.qt.io/contact-us.
15
**
16
** GNU Lesser General Public License Usage
hjk's avatar
hjk committed
17
** Alternatively, this file may be used under the terms of the GNU Lesser
Eike Ziller's avatar
Eike Ziller committed
18
19
20
21
22
23
** General Public License version 2.1 or version 3 as published by the Free
** Software Foundation and appearing in the file LICENSE.LGPLv21 and
** LICENSE.LGPLv3 included in the packaging of this file.  Please review the
** following information to ensure the GNU Lesser General Public License
** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
24
**
hjk's avatar
hjk committed
25
26
** 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
27
28
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
hjk's avatar
hjk committed
29
****************************************************************************/
hjk's avatar
hjk committed
30

31
32
#ifndef DESKTOPQMAKERUNCONFIGURATION_H
#define DESKTOPQMAKERUNCONFIGURATION_H
con's avatar
con committed
33

34
#include <qmakeprojectmanager/qmakerunconfigurationfactory.h>
Tobias Hunger's avatar
Tobias Hunger committed
35

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


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
namespace Utils {
class PathChooser;
class DetailsWidget;
}

55
namespace QmakeProjectManager {
56

57
58
59
class QmakeProject;
class QmakeProFileNode;
class QmakePriFileNode;
60
class TargetInformation;
con's avatar
con committed
61
62

namespace Internal {
63
class DesktopQmakeRunConfigurationFactory;
64

65
class DesktopQmakeRunConfiguration : public ProjectExplorer::LocalApplicationRunConfiguration
con's avatar
con committed
66
67
{
    Q_OBJECT
68
    // to change the display name and arguments and set the userenvironmentchanges
69
70
    friend class DesktopQmakeRunConfigurationWidget;
    friend class DesktopQmakeRunConfigurationFactory;
71

con's avatar
con committed
72
public:
73
74
    DesktopQmakeRunConfiguration(ProjectExplorer::Target *parent, Core::Id id);
    virtual ~DesktopQmakeRunConfiguration();
con's avatar
con committed
75

76
    virtual bool isEnabled() const;
dt_'s avatar
dt_ committed
77
    virtual QString disabledReason() const;
78
    virtual QWidget *createConfigurationWidget();
con's avatar
con committed
79
80

    virtual QString executable() const;
81
    virtual ProjectExplorer::ApplicationLauncher::Mode runMode() const;
Tobias Hunger's avatar
Tobias Hunger committed
82
    bool forcedGuiMode() const;
con's avatar
con committed
83
    virtual QString workingDirectory() const;
84
    virtual QString commandLineArguments() const;
con's avatar
con committed
85

86
87
    bool isUsingDyldImageSuffix() const;
    void setUsingDyldImageSuffix(bool state);
88

con's avatar
con committed
89
90
    QString proFilePath() const;

91
    QVariantMap toMap() const;
92

con's avatar
con committed
93
    Utils::OutputFormatter *createOutputFormatter() const;
dt's avatar
dt committed
94

95
    void setRunMode(ProjectExplorer::ApplicationLauncher::Mode runMode);
96
97
98

    void addToBaseEnvironment(Utils::Environment &env) const;

99
signals:
100
    void commandLineArgumentsChanged(const QString&);
101
    void baseWorkingDirectoryChanged(const QString&);
102
    void runModeChanged(ProjectExplorer::ApplicationLauncher::Mode runMode);
103
    void usingDyldImageSuffixChanged(bool);
104

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

con's avatar
con committed
108
private slots:
Tobias Hunger's avatar
Tobias Hunger committed
109
    void kitChanged();
110
    void proFileUpdated(QmakeProjectManager::QmakeProFileNode *pro, bool success, bool parseInProgress);
111
    void proFileEvaluated();
con's avatar
con committed
112

113
protected:
114
    DesktopQmakeRunConfiguration(ProjectExplorer::Target *parent, DesktopQmakeRunConfiguration *source);
115
116
    virtual bool fromMap(const QVariantMap &map);

con's avatar
con committed
117
private:
118
    QPair<QString, QString> extractWorkingDirAndExecutable(const QmakeProFileNode *node) const;
119
    void setBaseWorkingDirectory(const QString &workingDirectory);
120
    QString baseWorkingDirectory() const;
121
    void setCommandLineArguments(const QString &argumentsString);
122
    QString rawCommandLineArguments() const;
123
    QString defaultDisplayName();
124

125
126
    void ctor();

127
    void updateTarget();
128
    QString m_commandLineArguments;
con's avatar
con committed
129
130
131
    QString m_proFilePath; // Full path to the Application Pro File

    // Cached startup sub project information
132
    ProjectExplorer::ApplicationLauncher::Mode m_runMode;
Tobias Hunger's avatar
Tobias Hunger committed
133
    bool m_forcedGuiMode;
134
    bool m_isUsingDyldImageSuffix;
135
    QString m_userWorkingDirectory;
136
    bool m_parseSuccess;
137
    bool m_parseInProgress;
138
139
};

140
class DesktopQmakeRunConfigurationWidget : public QWidget
141
142
{
    Q_OBJECT
143

144
public:
145
146
    DesktopQmakeRunConfigurationWidget(DesktopQmakeRunConfiguration *qmakeRunConfiguration, QWidget *parent);
    ~DesktopQmakeRunConfigurationWidget();
Tobias Hunger's avatar
Tobias Hunger committed
147

148
149
150
protected:
    void showEvent(QShowEvent *event);
    void hideEvent(QHideEvent *event);
151

152
private slots:
153
    void runConfigurationEnabledChange();
154
155
156
    void workDirectoryEdited();
    void workingDirectoryReseted();
    void argumentsEdited(const QString &arguments);
157
    void environmentWasChanged();
158
159

    void workingDirectoryChanged(const QString &workingDirectory);
160
    void commandLineArgumentsChanged(const QString &args);
161
    void runModeChanged(ProjectExplorer::ApplicationLauncher::Mode runMode);
162

163
    void effectiveTargetInformationChanged();
164
    void termToggled(bool);
hjk's avatar
hjk committed
165
    void qvfbToggled(bool);
166
167
    void usingDyldImageSuffixToggled(bool);
    void usingDyldImageSuffixChanged(bool);
dt's avatar
dt committed
168

169
private:
170
    DesktopQmakeRunConfiguration *m_qmakeRunConfiguration;
171
    bool m_ignoreChange;
172
173
    QLabel *m_disabledIcon;
    QLabel *m_disabledReason;
174
    QLabel *m_executableLineLabel;
175
    Utils::PathChooser *m_workingDirectoryEdit;
176
    QLineEdit *m_argumentsLineEdit;
177
    QCheckBox *m_useTerminalCheck;
hjk's avatar
hjk committed
178
    QCheckBox *m_useQvfbCheck;
179
    QCheckBox *m_usingDyldImageSuffix;
180
    QLineEdit *m_qmlDebugPort;
dt's avatar
dt committed
181
    Utils::DetailsWidget *m_detailsContainer;
182
    bool m_isShown;
con's avatar
con committed
183
184
};

185
class DesktopQmakeRunConfigurationFactory : public QmakeRunConfigurationFactory
con's avatar
con committed
186
187
{
    Q_OBJECT
188

con's avatar
con committed
189
public:
190
191
    explicit DesktopQmakeRunConfigurationFactory(QObject *parent = 0);
    ~DesktopQmakeRunConfigurationFactory();
192

193
    bool canCreate(ProjectExplorer::Target *parent, Core::Id id) const;
Tobias Hunger's avatar
Tobias Hunger committed
194
195
196
    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);
197

198
    QList<Core::Id> availableCreationIds(ProjectExplorer::Target *parent, CreationMode mode) const;
199
    QString displayNameForId(Core::Id id) const;
Tobias Hunger's avatar
Tobias Hunger committed
200
201

    QList<ProjectExplorer::RunConfiguration *> runConfigurationsForNode(ProjectExplorer::Target *t,
202
                                                                        const ProjectExplorer::Node *n);
203
204

private:
205
206
    bool canHandle(ProjectExplorer::Target *t) const;

207
    ProjectExplorer::RunConfiguration *doCreate(ProjectExplorer::Target *parent, Core::Id id);
208
209
    ProjectExplorer::RunConfiguration *doRestore(ProjectExplorer::Target *parent,
                                                 const QVariantMap &map);
con's avatar
con committed
210
211
212
};

} // namespace Internal
213
} // namespace QmakeProjectManager
con's avatar
con committed
214

215
#endif // DESKTOPQMAKERUNCONFIGURATION_H