forked from qt-creator/qt-creator
ProjectExplorer: Introduce a "TerminalAspect"
To be used in RunConfigurations that have a 'Run in Terminal' option. Change-Id: Iea29a0d44e15e70c994e0e993a7e69133ae89fbf Reviewed-by: Tobias Hunger <tobias.hunger@theqtcompany.com>
This commit is contained in:
@@ -12,6 +12,7 @@ HEADERS += projectexplorer.h \
|
||||
configtaskhandler.h \
|
||||
environmentaspect.h \
|
||||
environmentaspectwidget.h \
|
||||
terminalaspect.h \
|
||||
gcctoolchain.h \
|
||||
importwidget.h \
|
||||
localapplicationrunconfiguration.h \
|
||||
@@ -162,6 +163,7 @@ SOURCES += projectexplorer.cpp \
|
||||
configtaskhandler.cpp \
|
||||
environmentaspect.cpp \
|
||||
environmentaspectwidget.cpp \
|
||||
terminalaspect.cpp \
|
||||
gcctoolchain.cpp \
|
||||
importwidget.cpp \
|
||||
localapplicationrunconfiguration.cpp \
|
||||
|
@@ -145,6 +145,7 @@ QtcPlugin {
|
||||
"taskhub.cpp", "taskhub.h",
|
||||
"taskmodel.cpp", "taskmodel.h",
|
||||
"taskwindow.cpp", "taskwindow.h",
|
||||
"terminalaspect.cpp", "terminalaspect.h",
|
||||
"toolchain.cpp", "toolchain.h",
|
||||
"toolchainconfigwidget.cpp", "toolchainconfigwidget.h",
|
||||
"toolchainmanager.cpp", "toolchainmanager.h",
|
||||
|
@@ -118,7 +118,8 @@ public:
|
||||
|
||||
virtual IRunConfigurationAspect *create(RunConfiguration *runConfig) const = 0;
|
||||
virtual IRunConfigurationAspect *clone(RunConfiguration *runConfig) const;
|
||||
virtual RunConfigWidget *createConfigurationWidget();
|
||||
virtual RunConfigWidget *createConfigurationWidget(); // Either this...
|
||||
virtual void addToMainConfigurationWidget(QWidget */*parent*/, QLayout */*layout*/) {} // ... or this.
|
||||
|
||||
void setId(Core::Id id) { m_id = id; }
|
||||
void setDisplayName(const QString &displayName) { m_displayName = displayName; }
|
||||
|
107
src/plugins/projectexplorer/terminalaspect.cpp
Normal file
107
src/plugins/projectexplorer/terminalaspect.cpp
Normal file
@@ -0,0 +1,107 @@
|
||||
/****************************************************************************
|
||||
**
|
||||
** Copyright (C) 2015 The Qt Company Ltd.
|
||||
** Contact: http://www.qt.io/licensing
|
||||
**
|
||||
** This file is part of Qt Creator.
|
||||
**
|
||||
** 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 The Qt Company. For licensing terms and
|
||||
** conditions see http://www.qt.io/terms-conditions. For further information
|
||||
** use the contact form at http://www.qt.io/contact-us.
|
||||
**
|
||||
** GNU Lesser General Public License Usage
|
||||
** Alternatively, this file may be used under the terms of the GNU Lesser
|
||||
** 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.
|
||||
**
|
||||
** In addition, as a special exception, The Qt Company gives you certain additional
|
||||
** rights. These rights are described in The Qt Company LGPL Exception
|
||||
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
#include "terminalaspect.h"
|
||||
|
||||
#include <projectexplorer/project.h>
|
||||
#include <projectexplorer/runconfiguration.h>
|
||||
|
||||
#include <QCheckBox>
|
||||
#include <QDebug>
|
||||
#include <QFormLayout>
|
||||
#include <QLabel>
|
||||
|
||||
const char USE_TERMINAL_KEY[] = "Qt4ProjectManager.Qt4RunConfiguration.UseTerminal";
|
||||
|
||||
namespace ProjectExplorer {
|
||||
|
||||
/*!
|
||||
\class ProjectExplorer::TerminalAspect
|
||||
*/
|
||||
|
||||
TerminalAspect::TerminalAspect(RunConfiguration *runConfig, bool useTerminal, bool isForced)
|
||||
: IRunConfigurationAspect(runConfig), m_useTerminal(useTerminal), m_isForced(isForced), m_checkBox(0)
|
||||
{
|
||||
setDisplayName(tr("Terminal"));
|
||||
setId("TerminalAspect");
|
||||
}
|
||||
|
||||
IRunConfigurationAspect *TerminalAspect::create(RunConfiguration *runConfig) const
|
||||
{
|
||||
return new TerminalAspect(runConfig, false, false);
|
||||
}
|
||||
|
||||
IRunConfigurationAspect *TerminalAspect::clone(RunConfiguration *runConfig) const
|
||||
{
|
||||
return new TerminalAspect(runConfig, m_useTerminal, m_isForced);
|
||||
}
|
||||
|
||||
void TerminalAspect::addToMainConfigurationWidget(QWidget *parent, QLayout *layout)
|
||||
{
|
||||
QTC_CHECK(!m_checkBox);
|
||||
m_checkBox = new QCheckBox(tr("Run in terminal"), parent);
|
||||
m_checkBox->setChecked(m_useTerminal);
|
||||
layout->addWidget(m_checkBox);
|
||||
connect(m_checkBox, &QAbstractButton::clicked, this, [this] {
|
||||
m_isForced = true;
|
||||
setUseTerminal(true);
|
||||
});
|
||||
}
|
||||
|
||||
void TerminalAspect::fromMap(const QVariantMap &map)
|
||||
{
|
||||
if (map.contains(QLatin1String(USE_TERMINAL_KEY))) {
|
||||
m_useTerminal = map.value(QLatin1String(USE_TERMINAL_KEY)).toBool();
|
||||
m_isForced = true;
|
||||
} else {
|
||||
m_isForced = false;
|
||||
}
|
||||
}
|
||||
|
||||
void TerminalAspect::toMap(QVariantMap &data) const
|
||||
{
|
||||
if (m_isForced)
|
||||
data.insert(QLatin1String(USE_TERMINAL_KEY), m_useTerminal);
|
||||
}
|
||||
|
||||
bool TerminalAspect::useTerminal() const
|
||||
{
|
||||
return m_useTerminal;
|
||||
}
|
||||
|
||||
void TerminalAspect::setUseTerminal(bool useTerminal)
|
||||
{
|
||||
if (m_useTerminal != useTerminal) {
|
||||
m_useTerminal = useTerminal;
|
||||
emit useTerminalChanged(useTerminal);
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace ProjectExplorer
|
71
src/plugins/projectexplorer/terminalaspect.h
Normal file
71
src/plugins/projectexplorer/terminalaspect.h
Normal file
@@ -0,0 +1,71 @@
|
||||
/****************************************************************************
|
||||
**
|
||||
** Copyright (C) 2015 The Qt Company Ltd.
|
||||
** Contact: http://www.qt.io/licensing
|
||||
**
|
||||
** This file is part of Qt Creator.
|
||||
**
|
||||
** 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 The Qt Company. For licensing terms and
|
||||
** conditions see http://www.qt.io/terms-conditions. For further information
|
||||
** use the contact form at http://www.qt.io/contact-us.
|
||||
**
|
||||
** GNU Lesser General Public License Usage
|
||||
** Alternatively, this file may be used under the terms of the GNU Lesser
|
||||
** 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.
|
||||
**
|
||||
** In addition, as a special exception, The Qt Company gives you certain additional
|
||||
** rights. These rights are described in The Qt Company LGPL Exception
|
||||
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
#ifndef TERMINALASPECT_H
|
||||
#define TERMINALASPECT_H
|
||||
|
||||
#include "runconfiguration.h"
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
class QCheckBox;
|
||||
QT_END_NAMESPACE
|
||||
|
||||
namespace ProjectExplorer {
|
||||
|
||||
class PROJECTEXPLORER_EXPORT TerminalAspect : public IRunConfigurationAspect
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit TerminalAspect(RunConfiguration *rc, bool useTerminal = false, bool isForced = false);
|
||||
|
||||
IRunConfigurationAspect *create(RunConfiguration *runConfig) const override;
|
||||
IRunConfigurationAspect *clone(RunConfiguration *runConfig) const override;
|
||||
|
||||
void addToMainConfigurationWidget(QWidget *parent, QLayout *layout) override;
|
||||
|
||||
bool useTerminal() const;
|
||||
void setUseTerminal(bool useTerminal);
|
||||
|
||||
signals:
|
||||
void useTerminalChanged(bool);
|
||||
|
||||
private:
|
||||
void fromMap(const QVariantMap &map) override;
|
||||
void toMap(QVariantMap &map) const override;
|
||||
|
||||
bool m_useTerminal;
|
||||
bool m_isForced;
|
||||
QPointer<QCheckBox> m_checkBox; // Owned by RunConfigWidget
|
||||
};
|
||||
|
||||
} // namespace ProjectExplorer
|
||||
|
||||
#endif // TERMINALASPECT_H
|
Reference in New Issue
Block a user