Android: Inline AndroidDeployStepWidget

BuildStepConfigWidget with manual tweaks is good enough.

Also move AndroidDeployQtStepFactory to the usual place at the
end of the file.

Change-Id: I92af31ef77f986b6fcd84a14ac62b70e2da32ff2
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
This commit is contained in:
hjk
2020-08-25 11:47:09 +02:00
parent 29a9565c89
commit 8cf1b598fe
4 changed files with 57 additions and 84 deletions

View File

@@ -70,6 +70,7 @@ const char ANDROID_PACKAGENAME[] = "Android.PackageName";
const char ANDROID_PACKAGE_INSTALLATION_STEP_ID[]
= "Qt4ProjectManager.AndroidPackageInstallationStep";
const char ANDROID_BUILD_APK_ID[] = "QmakeProjectManager.AndroidBuildApkStep";
const char ANDROID_DEPLOY_QT_ID[] = "Qt4ProjectManager.AndroidDeployQtStep";
const char AndroidPackageSourceDir[] = "AndroidPackageSourceDir"; // QString
const char AndroidDeploySettingsFile[] = "AndroidDeploySettingsFile"; // QString

View File

@@ -80,63 +80,6 @@ const QLatin1String InstallFailedUpdateIncompatible("INSTALL_FAILED_UPDATE_INCOM
const QLatin1String InstallFailedPermissionModelDowngrade("INSTALL_FAILED_PERMISSION_MODEL_DOWNGRADE");
const QLatin1String InstallFailedVersionDowngrade("INSTALL_FAILED_VERSION_DOWNGRADE");
// AndroidDeployQtStepFactory
AndroidDeployQtStepFactory::AndroidDeployQtStepFactory()
{
registerStep<AndroidDeployQtStep>(AndroidDeployQtStep::stepId());
setSupportedStepList(ProjectExplorer::Constants::BUILDSTEPS_DEPLOY);
setSupportedDeviceType(Constants::ANDROID_DEVICE_TYPE);
setRepeatable(false);
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(AndroidDeployQtStep::tr("Uninstall the existing app first"));
uninstallPreviousPackage->setChecked(step->uninstallPreviousPackage() > AndroidDeployQtStep::Keep);
uninstallPreviousPackage->setEnabled(step->uninstallPreviousPackage() != AndroidDeployQtStep::ForceUnintall);
connect(uninstallPreviousPackage, &QAbstractButton::toggled,
step, &AndroidDeployQtStep::setUninstallPreviousPackage);
auto resetDefaultDevices = new QPushButton(this);
resetDefaultDevices->setText(AndroidDeployQtStep::tr("Reset Default Deployment Devices"));
connect(resetDefaultDevices, &QAbstractButton::clicked, this, [step] {
AndroidConfigurations::clearDefaultDevices(step->project());
});
auto installCustomApkButton = new QPushButton(this);
installCustomApkButton->setText(AndroidDeployQtStep::tr("Install an APK File"));
connect(installCustomApkButton, &QAbstractButton::clicked, this, [this, step] {
const QString packagePath
= QFileDialog::getOpenFileName(this,
AndroidDeployQtStep::tr("Qt Android Installer"),
QDir::homePath(),
AndroidDeployQtStep::tr("Android package (*.apk)"));
if (!packagePath.isEmpty())
AndroidManager::installQASIPackage(step->target(), packagePath);
});
auto layout = new QVBoxLayout(this);
layout->addWidget(uninstallPreviousPackage);
layout->addWidget(resetDefaultDevices);
layout->addWidget(installCustomApkButton);
}
};
// AndroidDeployQtStep
AndroidDeployQtStep::AndroidDeployQtStep(BuildStepList *parent, Utils::Id id)
@@ -152,14 +95,6 @@ AndroidDeployQtStep::AndroidDeployQtStep(BuildStepList *parent, Utils::Id id)
connect(this, &AndroidDeployQtStep::askForUninstall,
this, &AndroidDeployQtStep::slotAskForUninstall,
Qt::BlockingQueuedConnection);
connect(this, &AndroidDeployQtStep::setSerialNumber,
this, &AndroidDeployQtStep::slotSetSerialNumber);
}
Utils::Id AndroidDeployQtStep::stepId()
{
return "Qt4ProjectManager.AndroidDeployQtStep";
}
bool AndroidDeployQtStep::init()
@@ -435,12 +370,6 @@ void AndroidDeployQtStep::slotAskForUninstall(DeployErrorCode errorCode)
m_askForUninstall = button == QMessageBox::Yes;
}
void AndroidDeployQtStep::slotSetSerialNumber(const QString &serialNumber)
{
qCDebug(deployStepLog) << "Target device serial number change:" << serialNumber;
AndroidManager::setDeviceSerialNumber(target(), serialNumber);
}
bool AndroidDeployQtStep::runImpl()
{
if (!m_avdName.isEmpty()) {
@@ -449,7 +378,8 @@ bool AndroidDeployQtStep::runImpl()
if (serialNumber.isEmpty())
return false;
m_serialNumber = serialNumber;
emit setSerialNumber(serialNumber);
qCDebug(deployStepLog) << "Target device serial number change:" << serialNumber;
AndroidManager::setDeviceSerialNumber(target(), serialNumber);
}
DeployErrorCode returnValue = runDeploy();
@@ -532,9 +462,47 @@ void AndroidDeployQtStep::runCommand(const CommandLine &command)
OutputFormat::ErrorMessage);
}
ProjectExplorer::BuildStepConfigWidget *AndroidDeployQtStep::createConfigWidget()
BuildStepConfigWidget *AndroidDeployQtStep::createConfigWidget()
{
return new AndroidDeployQtWidget(this);
auto widget = new BuildStepConfigWidget(this);
widget->setDisplayName(QString("<b>%1</b>").arg(displayName()));
widget->setSummaryText(displayName());
auto uninstallPreviousCheckBox = new QCheckBox(widget);
uninstallPreviousCheckBox->setText(tr("Uninstall the existing app first"));
uninstallPreviousCheckBox->setChecked(uninstallPreviousPackage() > Keep);
uninstallPreviousCheckBox->setEnabled(uninstallPreviousPackage() != ForceUninstall);
connect(uninstallPreviousCheckBox, &QAbstractButton::toggled,
this, &AndroidDeployQtStep::setUninstallPreviousPackage);
auto resetDefaultDevices = new QPushButton(widget);
resetDefaultDevices->setText(tr("Reset Default Deployment Devices"));
connect(resetDefaultDevices, &QAbstractButton::clicked, this, [this] {
AndroidConfigurations::clearDefaultDevices(project());
});
auto installCustomApkButton = new QPushButton(widget);
installCustomApkButton->setText(tr("Install an APK File"));
connect(installCustomApkButton, &QAbstractButton::clicked, this, [this, widget] {
const QString packagePath
= QFileDialog::getOpenFileName(widget,
tr("Qt Android Installer"),
QDir::homePath(),
tr("Android package (*.apk)"));
if (!packagePath.isEmpty())
AndroidManager::installQASIPackage(target(), packagePath);
});
auto layout = new QVBoxLayout(widget);
layout->addWidget(uninstallPreviousCheckBox);
layout->addWidget(resetDefaultDevices);
layout->addWidget(installCustomApkButton);
return widget;
}
void AndroidDeployQtStep::processReadyReadStdOutput(DeployErrorCode &errorCode)
@@ -605,9 +573,20 @@ AndroidDeployQtStep::UninstallType AndroidDeployQtStep::uninstallPreviousPackage
{
const QtSupport::BaseQtVersion * const qt = QtSupport::QtKitAspect::qtVersion(target()->kit());
if (qt && qt->qtVersion() < QtSupport::QtVersionNumber(5, 4, 0))
return ForceUnintall;
return ForceUninstall;
return m_uninstallPreviousPackage ? Uninstall : Keep;
}
// AndroidDeployQtStepFactory
AndroidDeployQtStepFactory::AndroidDeployQtStepFactory()
{
registerStep<AndroidDeployQtStep>(Constants::ANDROID_DEPLOY_QT_ID);
setSupportedStepList(ProjectExplorer::Constants::BUILDSTEPS_DEPLOY);
setSupportedDeviceType(Constants::ANDROID_DEVICE_TYPE);
setRepeatable(false);
setDisplayName(AndroidDeployQtStep::tr("Deploy to Android device or emulator"));
}
} // Internal
} // Android

View File

@@ -62,13 +62,11 @@ public:
enum UninstallType {
Keep,
Uninstall,
ForceUnintall
ForceUninstall
};
AndroidDeployQtStep(ProjectExplorer::BuildStepList *bc, Utils::Id id);
static Utils::Id stepId();
bool fromMap(const QVariantMap &map) override;
QVariantMap toMap() const override;
@@ -77,7 +75,6 @@ public:
signals:
void askForUninstall(DeployErrorCode errorCode);
void setSerialNumber(const QString &serialNumber);
private:
void runCommand(const Utils::CommandLine &command);
@@ -87,7 +84,6 @@ private:
void gatherFilesToPull();
DeployErrorCode runDeploy();
void slotAskForUninstall(DeployErrorCode errorCode);
void slotSetSerialNumber(const QString &serialNumber);
bool runImpl();
@@ -99,9 +95,6 @@ private:
void stdError(const QString &line);
DeployErrorCode parseDeployErrors(QString &deployOutputLine) const;
void slotProcessFinished(int, QProcess::ExitStatus);
void processFinished(int exitCode, QProcess::ExitStatus status);
friend void operator|=(DeployErrorCode &e1, const DeployErrorCode &e2) { e1 = static_cast<AndroidDeployQtStep::DeployErrorCode>((int)e1 | (int)e2); }
friend DeployErrorCode operator|(const DeployErrorCode &e1, const DeployErrorCode &e2) { return static_cast<AndroidDeployQtStep::DeployErrorCode>((int)e1 | (int)e2); }

View File

@@ -78,7 +78,7 @@ public:
addSupportedTargetDeviceType(Constants::ANDROID_DEVICE_TYPE);
setDefaultDisplayName(QCoreApplication::translate("Android::Internal",
"Deploy to Android Device"));
addInitialStep(AndroidDeployQtStep::stepId());
addInitialStep(Constants::ANDROID_DEPLOY_QT_ID);
}
};