diff --git a/src/plugins/projectexplorer/projectexplorer.pro b/src/plugins/projectexplorer/projectexplorer.pro index 4408de7dde5..013e2378d5b 100644 --- a/src/plugins/projectexplorer/projectexplorer.pro +++ b/src/plugins/projectexplorer/projectexplorer.pro @@ -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 \ diff --git a/src/plugins/projectexplorer/projectexplorer.qbs b/src/plugins/projectexplorer/projectexplorer.qbs index 1b328792c43..2b26ac49b64 100644 --- a/src/plugins/projectexplorer/projectexplorer.qbs +++ b/src/plugins/projectexplorer/projectexplorer.qbs @@ -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", diff --git a/src/plugins/projectexplorer/runconfiguration.h b/src/plugins/projectexplorer/runconfiguration.h index 4d54fd40771..2a57dbb7aee 100644 --- a/src/plugins/projectexplorer/runconfiguration.h +++ b/src/plugins/projectexplorer/runconfiguration.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; } diff --git a/src/plugins/projectexplorer/terminalaspect.cpp b/src/plugins/projectexplorer/terminalaspect.cpp new file mode 100644 index 00000000000..ddaa6a4dc15 --- /dev/null +++ b/src/plugins/projectexplorer/terminalaspect.cpp @@ -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 +#include + +#include +#include +#include +#include + +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 diff --git a/src/plugins/projectexplorer/terminalaspect.h b/src/plugins/projectexplorer/terminalaspect.h new file mode 100644 index 00000000000..d55de286bd6 --- /dev/null +++ b/src/plugins/projectexplorer/terminalaspect.h @@ -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 m_checkBox; // Owned by RunConfigWidget +}; + +} // namespace ProjectExplorer + +#endif // TERMINALASPECT_H