2019-06-04 14:22:35 +02:00
|
|
|
/****************************************************************************
|
|
|
|
|
**
|
|
|
|
|
** Copyright (C) 2019 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 "qdbmakedefaultappstep.h"
|
|
|
|
|
|
|
|
|
|
#include "qdbmakedefaultappservice.h"
|
|
|
|
|
|
|
|
|
|
#include <QRadioButton>
|
|
|
|
|
#include <QVBoxLayout>
|
|
|
|
|
|
|
|
|
|
namespace Qdb {
|
|
|
|
|
namespace Internal {
|
|
|
|
|
|
|
|
|
|
class QdbMakeDefaultAppStepPrivate
|
|
|
|
|
{
|
|
|
|
|
public:
|
|
|
|
|
QdbMakeDefaultAppService deployService;
|
|
|
|
|
bool makeDefault;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
class QdbConfigWidget : public ProjectExplorer::BuildStepConfigWidget
|
|
|
|
|
{
|
|
|
|
|
public:
|
|
|
|
|
QdbConfigWidget(QdbMakeDefaultAppStep *step)
|
|
|
|
|
: BuildStepConfigWidget(step)
|
|
|
|
|
{
|
|
|
|
|
QVBoxLayout * const mainLayout = new QVBoxLayout(this);
|
|
|
|
|
mainLayout->setMargin(0);
|
|
|
|
|
|
2019-06-11 08:42:23 +02:00
|
|
|
m_makeDefaultBtn.setText(
|
|
|
|
|
QdbMakeDefaultAppStep::tr("Set this application to start by default"));
|
|
|
|
|
m_resetDefaultBtn.setText(
|
|
|
|
|
QdbMakeDefaultAppStep::tr("Reset default application"));
|
2019-06-04 14:22:35 +02:00
|
|
|
|
|
|
|
|
if (step->makeDefault())
|
|
|
|
|
m_makeDefaultBtn.setChecked(true);
|
|
|
|
|
else
|
|
|
|
|
m_resetDefaultBtn.setChecked(true);
|
|
|
|
|
|
|
|
|
|
mainLayout->addWidget(&m_makeDefaultBtn);
|
|
|
|
|
mainLayout->addWidget(&m_resetDefaultBtn);
|
|
|
|
|
|
2019-06-11 08:42:23 +02:00
|
|
|
connect(&m_makeDefaultBtn, &QRadioButton::clicked, this, [step] {
|
|
|
|
|
step->setMakeDefault(true);
|
|
|
|
|
});
|
|
|
|
|
connect(&m_resetDefaultBtn, &QRadioButton::clicked, this, [step] {
|
|
|
|
|
step->setMakeDefault(false);
|
|
|
|
|
});
|
2019-06-04 14:22:35 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private:
|
|
|
|
|
QRadioButton m_makeDefaultBtn;
|
|
|
|
|
QRadioButton m_resetDefaultBtn;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
QdbMakeDefaultAppStep::QdbMakeDefaultAppStep(ProjectExplorer::BuildStepList *bsl)
|
|
|
|
|
: AbstractRemoteLinuxDeployStep(bsl, stepId())
|
|
|
|
|
{
|
|
|
|
|
d = new QdbMakeDefaultAppStepPrivate;
|
|
|
|
|
setDefaultDisplayName(stepDisplayName());
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
QdbMakeDefaultAppStep::~QdbMakeDefaultAppStep()
|
|
|
|
|
{
|
|
|
|
|
delete d;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Core::Id QdbMakeDefaultAppStep::stepId()
|
|
|
|
|
{
|
|
|
|
|
return "Qdb.MakeDefaultAppStep";
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
RemoteLinux::CheckResult QdbMakeDefaultAppStep::initInternal()
|
|
|
|
|
{
|
|
|
|
|
d->deployService.setMakeDefault(d->makeDefault);
|
|
|
|
|
return deployService()->isDeploymentPossible();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
RemoteLinux::AbstractRemoteLinuxDeployService *QdbMakeDefaultAppStep::deployService() const
|
|
|
|
|
{
|
|
|
|
|
return &d->deployService;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
ProjectExplorer::BuildStepConfigWidget *QdbMakeDefaultAppStep::createConfigWidget()
|
|
|
|
|
{
|
|
|
|
|
return new QdbConfigWidget(this);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
QString QdbMakeDefaultAppStep::stepDisplayName()
|
|
|
|
|
{
|
|
|
|
|
return QStringLiteral("Change default application");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void QdbMakeDefaultAppStep::setMakeDefault(bool makeDefault)
|
|
|
|
|
{
|
|
|
|
|
d->makeDefault = makeDefault;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool QdbMakeDefaultAppStep::makeDefault() const
|
|
|
|
|
{
|
|
|
|
|
return d->makeDefault;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static QString makeDefaultKey()
|
|
|
|
|
{
|
|
|
|
|
return QLatin1String("QdbMakeDefaultDeployStep.MakeDefault");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool QdbMakeDefaultAppStep::fromMap(const QVariantMap &map)
|
|
|
|
|
{
|
|
|
|
|
if (!AbstractRemoteLinuxDeployStep::fromMap(map))
|
|
|
|
|
return false;
|
|
|
|
|
d->makeDefault = map.value(makeDefaultKey()).toBool();
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
QVariantMap QdbMakeDefaultAppStep::toMap() const
|
|
|
|
|
{
|
|
|
|
|
QVariantMap map = AbstractRemoteLinuxDeployStep::toMap();
|
|
|
|
|
map.insert(makeDefaultKey(), d->makeDefault);
|
|
|
|
|
return map;
|
|
|
|
|
}
|
2019-06-11 08:42:23 +02:00
|
|
|
|
2019-06-04 14:22:35 +02:00
|
|
|
} // namespace Internal
|
|
|
|
|
} // namespace Qdb
|