WinRT: Introduce a custom UninstallAfterStopAspect

... to handle the remaning bool settings in the RunConfiguration.

Change-Id: Icf5c0994860793c69ebb182fb7a0e15b7245c4ad
Reviewed-by: David Schulz <david.schulz@qt.io>
This commit is contained in:
hjk
2018-04-16 11:14:25 +02:00
parent 32a219f5c1
commit 962e980baf
6 changed files with 39 additions and 151 deletions

View File

@@ -13,7 +13,6 @@ HEADERS += \
winrtqtversion.h \ winrtqtversion.h \
winrtqtversionfactory.h \ winrtqtversionfactory.h \
winrtrunconfiguration.h \ winrtrunconfiguration.h \
winrtrunconfigurationwidget.h \
winrtruncontrol.h \ winrtruncontrol.h \
winrtrunfactories.h \ winrtrunfactories.h \
winrtrunnerhelper.h winrtrunnerhelper.h
@@ -30,7 +29,6 @@ SOURCES += \
winrtqtversion.cpp \ winrtqtversion.cpp \
winrtqtversionfactory.cpp \ winrtqtversionfactory.cpp \
winrtrunconfiguration.cpp \ winrtrunconfiguration.cpp \
winrtrunconfigurationwidget.cpp \
winrtruncontrol.cpp \ winrtruncontrol.cpp \
winrtrunfactories.cpp \ winrtrunfactories.cpp \
winrtrunnerhelper.cpp winrtrunnerhelper.cpp

View File

@@ -36,8 +36,6 @@ QtcPlugin {
"winrtqtversionfactory.h", "winrtqtversionfactory.h",
"winrtrunconfiguration.cpp", "winrtrunconfiguration.cpp",
"winrtrunconfiguration.h", "winrtrunconfiguration.h",
"winrtrunconfigurationwidget.cpp",
"winrtrunconfigurationwidget.h",
"winrtruncontrol.cpp", "winrtruncontrol.cpp",
"winrtruncontrol.h", "winrtruncontrol.h",
"winrtrunfactories.cpp", "winrtrunfactories.cpp",

View File

@@ -24,7 +24,6 @@
****************************************************************************/ ****************************************************************************/
#include "winrtrunconfiguration.h" #include "winrtrunconfiguration.h"
#include "winrtrunconfigurationwidget.h"
#include "winrtconstants.h" #include "winrtconstants.h"
#include <coreplugin/icore.h> #include <coreplugin/icore.h>
@@ -34,39 +33,57 @@
#include <projectexplorer/runconfigurationaspects.h> #include <projectexplorer/runconfigurationaspects.h>
#include <projectexplorer/runnables.h> #include <projectexplorer/runnables.h>
#include <utils/detailswidget.h>
#include <qmakeprojectmanager/qmakeproject.h> #include <qmakeprojectmanager/qmakeproject.h>
#include <QFormLayout>
using namespace ProjectExplorer;
using namespace Utils;
namespace WinRt { namespace WinRt {
namespace Internal { namespace Internal {
static const char uninstallAfterStopIdC[] = "WinRtRunConfigurationUninstallAfterStopId"; class UninstallAfterStopAspect : public BaseBoolAspect
{
Q_OBJECT
public:
UninstallAfterStopAspect(RunConfiguration *rc)
: BaseBoolAspect(rc, "WinRtRunConfigurationUninstallAfterStopId")
{
setLabel(WinRtRunConfiguration::tr("Uninstall package after application stops"));
}
};
WinRtRunConfiguration::WinRtRunConfiguration(ProjectExplorer::Target *target)
WinRtRunConfiguration::WinRtRunConfiguration(Target *target)
: RunConfiguration(target, Constants::WINRT_RC_PREFIX) : RunConfiguration(target, Constants::WINRT_RC_PREFIX)
{ {
setDisplayName(tr("Run App Package")); setDisplayName(tr("Run App Package"));
addExtraAspect(new ProjectExplorer::ArgumentsAspect(this, "WinRtRunConfigurationArgumentsId")); addExtraAspect(new ArgumentsAspect(this, "WinRtRunConfigurationArgumentsId"));
addExtraAspect(new UninstallAfterStopAspect(this));
} }
QWidget *WinRtRunConfiguration::createConfigurationWidget() QWidget *WinRtRunConfiguration::createConfigurationWidget()
{ {
return new WinRtRunConfigurationWidget(this); auto widget = new QWidget;
auto fl = new QFormLayout(widget);
extraAspect<ArgumentsAspect>()->addToMainConfigurationWidget(widget, fl);
extraAspect<UninstallAfterStopAspect>()->addToMainConfigurationWidget(widget, fl);
auto wrapped = wrapWidget(widget);
auto detailsWidget = qobject_cast<DetailsWidget *>(wrapped);
QTC_ASSERT(detailsWidget, return wrapped);
detailsWidget->setState(DetailsWidget::Expanded);
detailsWidget->setSummaryText(tr("Launch App"));
return detailsWidget;
} }
QVariantMap WinRtRunConfiguration::toMap() const bool WinRtRunConfiguration::uninstallAfterStop() const
{ {
QVariantMap map = RunConfiguration::toMap(); return extraAspect<UninstallAfterStopAspect>()->value();
map.insert(QLatin1String(uninstallAfterStopIdC), m_uninstallAfterStop);
return map;
}
bool WinRtRunConfiguration::fromMap(const QVariantMap &map)
{
if (!RunConfiguration::fromMap(map))
return false;
setUninstallAfterStop(map.value(QLatin1String(uninstallAfterStopIdC)).toBool());
return true;
} }
QString WinRtRunConfiguration::proFilePath() const QString WinRtRunConfiguration::proFilePath() const
@@ -79,12 +96,6 @@ QString WinRtRunConfiguration::arguments() const
return extraAspect<ProjectExplorer::ArgumentsAspect>()->arguments(); return extraAspect<ProjectExplorer::ArgumentsAspect>()->arguments();
} }
void WinRtRunConfiguration::setUninstallAfterStop(bool b)
{
m_uninstallAfterStop = b;
emit uninstallAfterStopChanged(m_uninstallAfterStop);
}
ProjectExplorer::Runnable WinRtRunConfiguration::runnable() const ProjectExplorer::Runnable WinRtRunConfiguration::runnable() const
{ {
ProjectExplorer::StandardRunnable r; ProjectExplorer::StandardRunnable r;
@@ -126,3 +137,5 @@ QString WinRtRunConfiguration::executable() const
} // namespace Internal } // namespace Internal
} // namespace WinRt } // namespace WinRt
#include "winrtrunconfiguration.moc"

View File

@@ -25,7 +25,7 @@
#pragma once #pragma once
#include <projectexplorer/runconfiguration.h> #include <projectexplorer/runconfigurationaspects.h>
namespace WinRt { namespace WinRt {
namespace Internal { namespace Internal {
@@ -38,23 +38,14 @@ public:
explicit WinRtRunConfiguration(ProjectExplorer::Target *target); explicit WinRtRunConfiguration(ProjectExplorer::Target *target);
QWidget *createConfigurationWidget() override; QWidget *createConfigurationWidget() override;
QVariantMap toMap() const override;
bool fromMap(const QVariantMap &map) override;
QString proFilePath() const; QString proFilePath() const;
QString arguments() const; QString arguments() const;
bool uninstallAfterStop() const { return m_uninstallAfterStop; } bool uninstallAfterStop() const;
void setUninstallAfterStop(bool b);
ProjectExplorer::Runnable runnable() const override; ProjectExplorer::Runnable runnable() const override;
signals:
void argumentsChanged(QString);
void uninstallAfterStopChanged(bool);
private: private:
bool m_uninstallAfterStop = false;
QString executable() const; QString executable() const;
}; };

View File

@@ -1,63 +0,0 @@
/****************************************************************************
**
** Copyright (C) 2016 The Qt Company Ltd.
** Contact: https://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 https://www.qt.io/terms-conditions. For further
** information use the contact form at https://www.qt.io/contact-us.
**
** GNU General Public License Usage
** Alternatively, this file may be used under the terms of the GNU
** General Public License version 3 as published by the Free Software
** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
** included in the packaging of this file. Please review the following
** information to ensure the GNU General Public License requirements will
** be met: https://www.gnu.org/licenses/gpl-3.0.html.
**
****************************************************************************/
#include "winrtrunconfigurationwidget.h"
#include "winrtrunconfiguration.h"
#include <projectexplorer/runconfigurationaspects.h>
#include <QCheckBox>
#include <QFormLayout>
namespace WinRt {
namespace Internal {
WinRtRunConfigurationWidget::WinRtRunConfigurationWidget(WinRtRunConfiguration *rc)
: m_runConfiguration(rc)
{
setState(Expanded);
setSummaryText(tr("Launch App"));
auto widget = new QWidget(this);
widget->setContentsMargins(0, 0, 0, 0);
setWidget(widget);
auto verticalLayout = new QFormLayout(widget);
rc->extraAspect<ProjectExplorer::ArgumentsAspect>()
->addToMainConfigurationWidget(widget, verticalLayout);
auto uninstallAfterStop = new QCheckBox(widget);
verticalLayout->addWidget(uninstallAfterStop);
uninstallAfterStop->setText(tr("Uninstall package after application stops"));
connect(uninstallAfterStop, &QCheckBox::stateChanged, this, [this] (int checked) {
m_runConfiguration->setUninstallAfterStop(checked == Qt::Checked);
});
}
} // namespace Internal
} // namespace WinRt

View File

@@ -1,49 +0,0 @@
/****************************************************************************
**
** Copyright (C) 2016 The Qt Company Ltd.
** Contact: https://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 https://www.qt.io/terms-conditions. For further
** information use the contact form at https://www.qt.io/contact-us.
**
** GNU General Public License Usage
** Alternatively, this file may be used under the terms of the GNU
** General Public License version 3 as published by the Free Software
** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
** included in the packaging of this file. Please review the following
** information to ensure the GNU General Public License requirements will
** be met: https://www.gnu.org/licenses/gpl-3.0.html.
**
****************************************************************************/
#pragma once
#include <utils/detailswidget.h>
namespace WinRt {
namespace Internal {
class WinRtRunConfiguration;
class WinRtRunConfigurationWidget : public Utils::DetailsWidget
{
Q_OBJECT
public:
explicit WinRtRunConfigurationWidget(WinRtRunConfiguration *rc);
bool isValid() const;
private:
WinRtRunConfiguration *m_runConfiguration;
};
} // namespace Internal
} // namespace WinRt