Android: Simplify deploy step widget setup

Remove the nested QGroupBox, inline code into only callers, etc.
Also use better display name for deploy step widget.

Change-Id: I579810c04dea032a98ba28db6de035048f801f75
Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
Reviewed-by: Leena Miettinen <riitta-leena.miettinen@qt.io>
This commit is contained in:
hjk
2019-01-25 14:33:57 +01:00
parent 346ddbaa08
commit fd5916ae23
7 changed files with 60 additions and 214 deletions

View File

@@ -35,7 +35,6 @@ HEADERS += \
androiddevicedialog.h \
androiddeployqtstep.h \
certificatesmodel.h \
androiddeployqtwidget.h \
androidpotentialkit.h \
androidsignaloperation.h \
javaeditor.h \
@@ -84,7 +83,6 @@ SOURCES += \
androiddevicedialog.cpp \
androiddeployqtstep.cpp \
certificatesmodel.cpp \
androiddeployqtwidget.cpp \
androidpotentialkit.cpp \
androidsignaloperation.cpp \
javaeditor.cpp \
@@ -109,7 +107,6 @@ FORMS += \
addnewavddialog.ui \
androidcreatekeystorecertificate.ui \
androiddevicedialog.ui \
androiddeployqtwidget.ui \
androidbuildapkwidget.ui \
adbcommandswidget.ui \
androidsdkmanagerwidget.ui

View File

@@ -44,9 +44,6 @@ Project {
"androiddevicedialog.cpp",
"androiddevicedialog.h",
"androiddevicedialog.ui",
"androiddeployqtwidget.cpp",
"androiddeployqtwidget.h",
"androiddeployqtwidget.ui",
"androiddevice.cpp",
"androiddevice.h",
"androiddevicefactory.cpp",

View File

@@ -25,7 +25,6 @@
****************************************************************************/
#include "androiddeployqtstep.h"
#include "androiddeployqtwidget.h"
#include "certificatesmodel.h"
#include "javaparser.h"
@@ -54,10 +53,14 @@
#include <utils/qtcprocess.h>
#include <utils/synchronousprocess.h>
#include <QCheckBox>
#include <QFileDialog>
#include <QGroupBox>
#include <QInputDialog>
#include <QMessageBox>
#include <QLoggingCategory>
#include <QMessageBox>
#include <QPushButton>
#include <QVBoxLayout>
using namespace ProjectExplorer;
using namespace Android;
@@ -86,6 +89,60 @@ AndroidDeployQtStepFactory::AndroidDeployQtStepFactory()
setDisplayName(AndroidDeployQtStep::tr("Deploy to Android device or emulator"));
}
// AndroidDeployQtWidget
class AndroidDeployQtWidget : public BuildStepConfigWidget
{
public:
AndroidDeployQtWidget(AndroidDeployQtStep *step)
: ProjectExplorer::BuildStepConfigWidget(step)
{
setDisplayName(QString("<b>%1</b>").arg(step->displayName()));
setSummaryText(displayName());
auto uninstallPreviousPackage = new QCheckBox(this);
uninstallPreviousPackage->setText(tr("Uninstall previous package"));
uninstallPreviousPackage->setChecked(step->uninstallPreviousPackage() > AndroidDeployQtStep::Keep);
uninstallPreviousPackage->setEnabled(step->uninstallPreviousPackage() != AndroidDeployQtStep::ForceUnintall);
auto resetDefaultDevices = new QPushButton(this);
resetDefaultDevices->setText(AndroidDeployQtStep::tr("Reset Default Devices"));
auto cleanLibsPushButton = new QPushButton(this);
cleanLibsPushButton->setText(AndroidDeployQtStep::tr("Clean Temporary Libraries Directory on Device"));
auto installMinistroButton = new QPushButton(this);
installMinistroButton->setText(AndroidDeployQtStep::tr("Install Ministro from APK"));
connect(installMinistroButton, &QAbstractButton::clicked, this, [this, step] {
QString packagePath =
QFileDialog::getOpenFileName(this,
AndroidDeployQtStep::tr("Qt Android Smart Installer"),
QDir::homePath(),
AndroidDeployQtStep::tr("Android package (*.apk)"));
if (!packagePath.isEmpty())
AndroidManager::installQASIPackage(step->target(), packagePath);
});
connect(cleanLibsPushButton, &QAbstractButton::clicked, this, [step] {
AndroidManager::cleanLibsOnDevice(step->target());
});
connect(resetDefaultDevices, &QAbstractButton::clicked, this, [step] {
AndroidConfigurations::clearDefaultDevices(step->project());
});
connect(uninstallPreviousPackage, &QAbstractButton::toggled,
step, &AndroidDeployQtStep::setUninstallPreviousPackage);
auto layout = new QVBoxLayout(this);
layout->addWidget(uninstallPreviousPackage);
layout->addWidget(resetDefaultDevices);
layout->addWidget(cleanLibsPushButton);
layout->addWidget(installMinistroButton);
}
};
// AndroidDeployQtStep
AndroidDeployQtStep::AndroidDeployQtStep(ProjectExplorer::BuildStepList *parent)

View File

@@ -36,10 +36,6 @@
namespace Utils { class QtcProcess; }
QT_BEGIN_NAMESPACE
class QAbstractItemModel;
QT_END_NAMESPACE
namespace Android {
namespace Internal {
@@ -52,7 +48,6 @@ public:
class AndroidDeployQtStep : public ProjectExplorer::BuildStep
{
Q_OBJECT
friend class AndroidDeployQtStepFactory;
enum DeployErrorCode
{

View File

@@ -1,83 +0,0 @@
/****************************************************************************
**
** Copyright (C) 2016 BogDan Vatra <bog_dan_ro@yahoo.com>
** 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 "androiddeployqtwidget.h"
#include "ui_androiddeployqtwidget.h"
#include "androiddeployqtstep.h"
#include "androidmanager.h"
#include <QFileDialog>
using namespace Android;
using namespace Internal;
AndroidDeployQtWidget::AndroidDeployQtWidget(AndroidDeployQtStep *step)
: ProjectExplorer::BuildStepConfigWidget(step),
m_ui(new Ui::AndroidDeployQtWidget),
m_step(step)
{
m_ui->setupUi(this);
setDisplayName(tr("<b>Deploy configurations</b>"));
setSummaryText(displayName());
m_ui->uninstallPreviousPackage->setChecked(m_step->uninstallPreviousPackage() > AndroidDeployQtStep::Keep);
m_ui->uninstallPreviousPackage->setEnabled(m_step->uninstallPreviousPackage() != AndroidDeployQtStep::ForceUnintall);
connect(m_ui->installMinistroButton, &QAbstractButton::clicked,
this, &AndroidDeployQtWidget::installMinistro);
connect(m_ui->cleanLibsPushButton, &QAbstractButton::clicked,
this, &AndroidDeployQtWidget::cleanLibsOnDevice);
connect(m_ui->resetDefaultDevices, &QAbstractButton::clicked,
this, &AndroidDeployQtWidget::resetDefaultDevices);
connect(m_ui->uninstallPreviousPackage, &QAbstractButton::toggled,
m_step, &AndroidDeployQtStep::setUninstallPreviousPackage);
}
AndroidDeployQtWidget::~AndroidDeployQtWidget()
{
delete m_ui;
}
void AndroidDeployQtWidget::installMinistro()
{
QString packagePath =
QFileDialog::getOpenFileName(this, tr("Qt Android Smart Installer"),
QDir::homePath(), tr("Android package (*.apk)"));
if (!packagePath.isEmpty())
AndroidManager::installQASIPackage(m_step->target(), packagePath);
}
void AndroidDeployQtWidget::cleanLibsOnDevice()
{
AndroidManager::cleanLibsOnDevice(m_step->target());
}
void AndroidDeployQtWidget::resetDefaultDevices()
{
AndroidConfigurations::clearDefaultDevices(m_step->project());
}

View File

@@ -1,59 +0,0 @@
/****************************************************************************
**
** Copyright (C) 2016 BogDan Vatra <bog_dan_ro@yahoo.com>
** 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 <projectexplorer/buildstep.h>
#include <QWidget>
QT_BEGIN_NAMESPACE
namespace Ui { class AndroidDeployQtWidget; }
QT_END_NAMESPACE
namespace Android {
namespace Internal {
class AndroidDeployQtStep;
class AndroidDeployQtWidget : public ProjectExplorer::BuildStepConfigWidget
{
Q_OBJECT
public:
AndroidDeployQtWidget(AndroidDeployQtStep *step);
~AndroidDeployQtWidget() override;
private:
void installMinistro();
void cleanLibsOnDevice();
void resetDefaultDevices();
Ui::AndroidDeployQtWidget *m_ui;
AndroidDeployQtStep *m_step;
};
}
}

View File

@@ -1,58 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>AndroidDeployQtWidget</class>
<widget class="QWidget" name="AndroidDeployQtWidget">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>403</width>
<height>178</height>
</rect>
</property>
<property name="windowTitle">
<string/>
</property>
<layout class="QVBoxLayout" name="verticalLayout_2">
<item>
<widget class="QGroupBox" name="advancedActions">
<property name="title">
<string>Deploy options</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<widget class="QCheckBox" name="uninstallPreviousPackage">
<property name="text">
<string>Uninstall previous package</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="resetDefaultDevices">
<property name="text">
<string>Reset Default Devices</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="cleanLibsPushButton">
<property name="text">
<string>Clean Temporary Libraries Directory on Device</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="installMinistroButton">
<property name="text">
<string>Install Ministro from APK</string>
</property>
</widget>
</item>
</layout>
</widget>
</item>
</layout>
</widget>
<resources/>
<connections/>
</ui>