Android: Inline androidsdkmanagerwidget.ui

Change-Id: Ic20b209d92371184fdb458d1835852b6c042ad69
Reviewed-by: Alessandro Portale <alessandro.portale@qt.io>
This commit is contained in:
hjk
2022-07-22 10:32:08 +02:00
parent 50e53b3e63
commit 14c5390ffc
7 changed files with 232 additions and 442 deletions

View File

@@ -36,7 +36,7 @@ add_qtc_plugin(Android
androidrunnerworker.cpp androidrunnerworker.h androidrunnerworker.cpp androidrunnerworker.h
androidsdkdownloader.cpp androidsdkdownloader.h androidsdkdownloader.cpp androidsdkdownloader.h
androidsdkmanager.cpp androidsdkmanager.h androidsdkmanager.cpp androidsdkmanager.h
androidsdkmanagerwidget.cpp androidsdkmanagerwidget.h androidsdkmanagerwidget.ui androidsdkmanagerwidget.cpp androidsdkmanagerwidget.h
androidsdkmodel.cpp androidsdkmodel.h androidsdkmodel.cpp androidsdkmodel.h
androidsdkpackage.cpp androidsdkpackage.h androidsdkpackage.cpp androidsdkpackage.h
androidservicewidget.cpp androidservicewidget.h androidservicewidget_p.h androidservicewidget.cpp androidservicewidget.h androidservicewidget_p.h

View File

@@ -83,7 +83,6 @@ Project {
"androidsdkmanager.h", "androidsdkmanager.h",
"androidsdkmanagerwidget.cpp", "androidsdkmanagerwidget.cpp",
"androidsdkmanagerwidget.h", "androidsdkmanagerwidget.h",
"androidsdkmanagerwidget.ui",
"androidsdkmodel.cpp", "androidsdkmodel.cpp",
"androidsdkmodel.h", "androidsdkmodel.h",
"androidsdkpackage.cpp", "androidsdkpackage.cpp",

View File

@@ -34,24 +34,19 @@
#include <projectexplorer/toolchain.h> #include <projectexplorer/toolchain.h>
#include <qtsupport/qtversionmanager.h> #include <qtsupport/qtversionmanager.h>
#include <QObject>
#include <QString>
#include <QStringList> #include <QStringList>
#include <QVector> #include <QVector>
#include <QHash> #include <QHash>
#include <QMap> #include <QMap>
#include <QVersionNumber> #include <QVersionNumber>
#include <utils/fileutils.h> #include <utils/filepath.h>
QT_BEGIN_NAMESPACE QT_BEGIN_NAMESPACE
class QSettings; class QSettings;
QT_END_NAMESPACE QT_END_NAMESPACE
namespace ProjectExplorer { namespace ProjectExplorer { class Abi; }
class Abi;
class Project;
}
namespace Android { namespace Android {

View File

@@ -22,15 +22,16 @@
** be met: https://www.gnu.org/licenses/gpl-3.0.html. ** be met: https://www.gnu.org/licenses/gpl-3.0.html.
** **
****************************************************************************/ ****************************************************************************/
#include "androidsdkmanagerwidget.h" #include "androidsdkmanagerwidget.h"
#include "ui_androidsdkmanagerwidget.h"
#include "androidconfigurations.h" #include "androidconfigurations.h"
#include "androidsdkmanager.h" #include "androidsdkmanager.h"
#include "androidsdkmodel.h" #include "androidsdkmodel.h"
#include <app/app_version.h> #include <app/app_version.h>
#include <utils/runextensions.h>
#include <utils/layoutbuilder.h>
#include <utils/outputformatter.h> #include <utils/outputformatter.h>
#include <utils/runextensions.h> #include <utils/runextensions.h>
#include <utils/qtcassert.h> #include <utils/qtcassert.h>
@@ -43,19 +44,17 @@
#include <QMessageBox> #include <QMessageBox>
#include <QSortFilterProxyModel> #include <QSortFilterProxyModel>
namespace { using namespace Utils;
static Q_LOGGING_CATEGORY(androidSdkMgrUiLog, "qtc.android.sdkManagerUi", QtWarningMsg)
}
namespace Android {
namespace Internal {
using namespace std::placeholders; using namespace std::placeholders;
namespace Android::Internal {
static Q_LOGGING_CATEGORY(androidSdkMgrUiLog, "qtc.android.sdkManagerUi", QtWarningMsg)
class PackageFilterModel : public QSortFilterProxyModel class PackageFilterModel : public QSortFilterProxyModel
{ {
public: public:
PackageFilterModel(AndroidSdkModel* sdkModel); PackageFilterModel(AndroidSdkModel *sdkModel);
void setAcceptedPackageState(AndroidSdkPackage::PackageState state); void setAcceptedPackageState(AndroidSdkPackage::PackageState state);
void setAcceptedSearchPackage(const QString &text); void setAcceptedSearchPackage(const QString &text);
@@ -71,91 +70,190 @@ AndroidSdkManagerWidget::AndroidSdkManagerWidget(AndroidConfig &config,
QDialog(parent), QDialog(parent),
m_androidConfig(config), m_androidConfig(config),
m_sdkManager(sdkManager), m_sdkManager(sdkManager),
m_sdkModel(new AndroidSdkModel(m_androidConfig, m_sdkManager, this)), m_sdkModel(new AndroidSdkModel(m_androidConfig, m_sdkManager, this))
m_ui(new Ui::AndroidSdkManagerWidget)
{ {
QTC_CHECK(sdkManager); QTC_CHECK(sdkManager);
m_ui->setupUi(this);
m_ui->sdkLicensebuttonBox->hide(); setWindowTitle(tr("Android SDK Manager"));
m_ui->sdkLicenseLabel->hide(); resize(664, 396);
m_ui->viewStack->setCurrentWidget(m_ui->packagesStack);
setModal(true); setModal(true);
m_formatter = new Utils::OutputFormatter; m_packagesStack = new QWidget;
m_formatter->setPlainTextEdit(m_ui->outputEdit);
connect(m_sdkModel, &AndroidSdkModel::dataChanged, this, [this] { auto packagesView = new QTreeView(m_packagesStack);
if (m_ui->viewStack->currentWidget() == m_ui->packagesStack) packagesView->setIndentation(20);
m_ui->applySelectionButton->setEnabled(!m_sdkModel->userSelection().isEmpty()); packagesView->header()->setCascadingSectionResizes(false);
auto updateInstalledButton = new QPushButton(tr("Update Installed"));
auto applySelectionButton = new QPushButton(tr("Apply"));
applySelectionButton->setEnabled(false);
auto channelCheckbox = new QComboBox;
channelCheckbox->addItem(tr("Default"));
channelCheckbox->addItem(tr("Stable"));
channelCheckbox->addItem(tr("Beta"));
channelCheckbox->addItem(tr("Dev"));
channelCheckbox->addItem(tr("Canary"));
auto obsoleteCheckBox = new QCheckBox(tr("Include obsolete"));
auto line = new QFrame;
line->setFrameShape(QFrame::HLine);
line->setFrameShadow(QFrame::Sunken);
auto showAvailableRadio = new QRadioButton(tr("Available"));
auto showInstalledRadio = new QRadioButton(tr("Installed"));
auto showAllRadio = new QRadioButton(tr("All"));
showAllRadio->setChecked(true);
auto optionsButton = new QPushButton(tr("Advanced Options..."));
auto searchField = new FancyLineEdit(m_packagesStack);
searchField->setPlaceholderText("Filter");
auto expandCheck = new QCheckBox(tr("Expand All"));
m_outputStack = new QWidget;
auto cancelButton = new QPushButton(tr("Cancel"));
m_operationProgress = new QProgressBar(m_outputStack);
m_outputEdit = new QPlainTextEdit(m_outputStack);
m_outputEdit->setReadOnly(true);
m_sdkLicenseLabel = new QLabel(tr("Do you want to accept the Android SDK license?"));
m_sdkLicenseLabel->setAlignment(Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter);
m_sdkLicenseLabel->hide();
m_sdkLicenseButtonBox = new QDialogButtonBox(m_outputStack);
m_sdkLicenseButtonBox->setEnabled(false);
m_sdkLicenseButtonBox->setStandardButtons(QDialogButtonBox::No|QDialogButtonBox::Yes);
m_sdkLicenseButtonBox->hide();
m_buttonBox = new QDialogButtonBox(this);
m_buttonBox->setStandardButtons(QDialogButtonBox::Ok);
m_viewStack = new QStackedWidget(this);
m_viewStack->addWidget(m_packagesStack);
m_viewStack->addWidget(m_outputStack);
m_viewStack->setCurrentWidget(m_packagesStack);
m_formatter = new OutputFormatter;
m_formatter->setPlainTextEdit(m_outputEdit);
auto proxyModel = new PackageFilterModel(m_sdkModel);
packagesView->setModel(proxyModel);
packagesView->header()->setSectionResizeMode(QHeaderView::ResizeToContents);
packagesView->header()->setSectionResizeMode(AndroidSdkModel::packageNameColumn,
QHeaderView::Stretch);
packagesView->header()->setStretchLastSection(false);
using namespace Layouting;
const Break br;
const Stretch st;
Grid {
searchField, expandCheck, br,
Span(2, packagesView),
Column {
updateInstalledButton,
applySelectionButton,
st,
Group {
Title(tr("Show Packages")),
Column {
Row { tr("Channel:"), channelCheckbox },
obsoleteCheckBox,
line,
showAvailableRadio,
showInstalledRadio,
showAllRadio,
}
},
optionsButton
}
}.attachTo(m_packagesStack);
Column {
m_outputEdit,
Row { m_sdkLicenseLabel, m_sdkLicenseButtonBox },
m_operationProgress,
st,
Row { st, cancelButton }
}.attachTo(m_outputStack);
Column {
m_viewStack,
m_buttonBox
}.attachTo(this);
connect(m_sdkModel, &AndroidSdkModel::dataChanged, this, [this, applySelectionButton] {
if (m_viewStack->currentWidget() == m_packagesStack)
applySelectionButton->setEnabled(!m_sdkModel->userSelection().isEmpty());
}); });
connect(m_sdkModel, &AndroidSdkModel::modelAboutToBeReset, this, [this] { connect(m_sdkModel, &AndroidSdkModel::modelAboutToBeReset, this,
m_ui->applySelectionButton->setEnabled(false); [this, applySelectionButton, expandCheck] {
m_ui->expandCheck->setChecked(false); applySelectionButton->setEnabled(false);
expandCheck->setChecked(false);
cancelPendingOperations(); cancelPendingOperations();
switchView(PackageListing); switchView(PackageListing);
}); });
auto proxyModel = new PackageFilterModel(m_sdkModel); connect(expandCheck, &QCheckBox::stateChanged, this, [this, packagesView](int state) {
m_ui->packagesView->setModel(proxyModel);
m_ui->packagesView->header()->setSectionResizeMode(QHeaderView::ResizeToContents);
m_ui->packagesView->header()->setSectionResizeMode(AndroidSdkModel::packageNameColumn,
QHeaderView::Stretch);
m_ui->packagesView->header()->setStretchLastSection(false);
connect(m_ui->expandCheck, &QCheckBox::stateChanged, this, [this](int state) {
if (state == Qt::Checked) if (state == Qt::Checked)
m_ui->packagesView->expandAll(); packagesView->expandAll();
else else
m_ui->packagesView->collapseAll(); packagesView->collapseAll();
}); });
connect(m_ui->updateInstalledButton, &QPushButton::clicked, connect(updateInstalledButton, &QPushButton::clicked,
this, &AndroidSdkManagerWidget::onUpdatePackages); this, &AndroidSdkManagerWidget::onUpdatePackages);
connect(m_ui->showAllRadio, &QRadioButton::toggled, this, [this, proxyModel](bool checked) { connect(showAllRadio, &QRadioButton::toggled, this, [this, proxyModel](bool checked) {
if (checked) { if (checked) {
proxyModel->setAcceptedPackageState(AndroidSdkPackage::AnyValidState); proxyModel->setAcceptedPackageState(AndroidSdkPackage::AnyValidState);
m_sdkModel->resetSelection(); m_sdkModel->resetSelection();
} }
}); });
connect(m_ui->showInstalledRadio, &QRadioButton::toggled, connect(showInstalledRadio, &QRadioButton::toggled,
this, [this, proxyModel](bool checked) { this, [this, proxyModel](bool checked) {
if (checked) { if (checked) {
proxyModel->setAcceptedPackageState(AndroidSdkPackage::Installed); proxyModel->setAcceptedPackageState(AndroidSdkPackage::Installed);
m_sdkModel->resetSelection(); m_sdkModel->resetSelection();
} }
}); });
connect(m_ui->showAvailableRadio, &QRadioButton::toggled, connect(showAvailableRadio, &QRadioButton::toggled, this, [this, proxyModel](bool checked) {
this, [this, proxyModel](bool checked) {
if (checked) { if (checked) {
proxyModel->setAcceptedPackageState(AndroidSdkPackage::Available); proxyModel->setAcceptedPackageState(AndroidSdkPackage::Available);
m_sdkModel->resetSelection(); m_sdkModel->resetSelection();
} }
}); });
m_ui->searchField->setPlaceholderText("Filter"); connect(searchField, &QLineEdit::textChanged,
connect(m_ui->searchField, &QLineEdit::textChanged, this, [this, proxyModel, expandCheck](const QString &text) {
this, [this, proxyModel](const QString &text) {
proxyModel->setAcceptedSearchPackage(text); proxyModel->setAcceptedSearchPackage(text);
m_sdkModel->resetSelection(); m_sdkModel->resetSelection();
// It is more convenient to expand the view with the results // It is more convenient to expand the view with the results
m_ui->expandCheck->setChecked(!text.isEmpty()); expandCheck->setChecked(!text.isEmpty());
}); });
connect(m_ui->buttonBox, &QDialogButtonBox::accepted, this, &AndroidSdkManagerWidget::close); connect(m_buttonBox, &QDialogButtonBox::accepted, this, &AndroidSdkManagerWidget::close);
connect(m_ui->applySelectionButton, &QPushButton::clicked, this, [this] { onApplyButton(); }); connect(applySelectionButton, &QPushButton::clicked, this, [this] { onApplyButton(); });
connect(m_ui->cancelButton, &QPushButton::clicked, this, connect(cancelButton, &QPushButton::clicked, this,
&AndroidSdkManagerWidget::onCancel); &AndroidSdkManagerWidget::onCancel);
connect(m_ui->optionsButton, &QPushButton::clicked, connect(optionsButton, &QPushButton::clicked,
this, &AndroidSdkManagerWidget::onSdkManagerOptions); this, &AndroidSdkManagerWidget::onSdkManagerOptions);
connect(m_ui->sdkLicensebuttonBox, &QDialogButtonBox::accepted, this, [this] { connect(m_sdkLicenseButtonBox, &QDialogButtonBox::accepted, this, [this] {
m_sdkManager->acceptSdkLicense(true); m_sdkManager->acceptSdkLicense(true);
m_ui->sdkLicensebuttonBox->setEnabled(false); // Wait for next license to enable controls m_sdkLicenseButtonBox->setEnabled(false); // Wait for next license to enable controls
}); });
connect(m_ui->sdkLicensebuttonBox, &QDialogButtonBox::rejected, this, [this] { connect(m_sdkLicenseButtonBox, &QDialogButtonBox::rejected, this, [this] {
m_sdkManager->acceptSdkLicense(false); m_sdkManager->acceptSdkLicense(false);
m_ui->sdkLicensebuttonBox->setEnabled(false); // Wait for next license to enable controls m_sdkLicenseButtonBox->setEnabled(false); // Wait for next license to enable controls
}); });
connect(m_ui->oboleteCheckBox, &QCheckBox::stateChanged, this, [this](int state) { connect(obsoleteCheckBox, &QCheckBox::stateChanged, this, [this](int state) {
const QString obsoleteArg = "--include_obsolete"; const QString obsoleteArg = "--include_obsolete";
QStringList args = m_androidConfig.sdkManagerToolArgs(); QStringList args = m_androidConfig.sdkManagerToolArgs();
if (state == Qt::Checked && !args.contains(obsoleteArg)) { if (state == Qt::Checked && !args.contains(obsoleteArg)) {
@@ -168,7 +266,7 @@ AndroidSdkManagerWidget::AndroidSdkManagerWidget(AndroidConfig &config,
m_sdkManager->reloadPackages(true); m_sdkManager->reloadPackages(true);
}); });
connect(m_ui->channelCheckbox, &QComboBox::currentIndexChanged, this, [this](int index) { connect(channelCheckbox, &QComboBox::currentIndexChanged, this, [this](int index) {
QStringList args = m_androidConfig.sdkManagerToolArgs(); QStringList args = m_androidConfig.sdkManagerToolArgs();
QString existingArg; QString existingArg;
for (int i = 0; i < 4; ++i) { for (int i = 0; i < 4; ++i) {
@@ -204,7 +302,6 @@ AndroidSdkManagerWidget::~AndroidSdkManagerWidget()
delete m_currentOperation; delete m_currentOperation;
cancelPendingOperations(); cancelPendingOperations();
delete m_formatter; delete m_formatter;
delete m_ui;
} }
void AndroidSdkManagerWidget::installEssentials() void AndroidSdkManagerWidget::installEssentials()
@@ -224,10 +321,10 @@ void AndroidSdkManagerWidget::installEssentials()
void AndroidSdkManagerWidget::beginLicenseCheck() void AndroidSdkManagerWidget::beginLicenseCheck()
{ {
m_formatter->appendMessage(tr("Checking pending licenses...\n"), Utils::NormalMessageFormat); m_formatter->appendMessage(tr("Checking pending licenses...\n"), NormalMessageFormat);
m_formatter->appendMessage(tr("The installation of Android SDK packages may fail if the " m_formatter->appendMessage(tr("The installation of Android SDK packages may fail if the "
"respective licenses are not accepted.\n"), "respective licenses are not accepted.\n"),
Utils::LogMessageFormat); LogMessageFormat);
addPackageFuture(m_sdkManager->checkPendingLicenses()); addPackageFuture(m_sdkManager->checkPendingLicenses());
} }
@@ -236,7 +333,7 @@ void AndroidSdkManagerWidget::onApplyButton(const QString &extraMessage)
QTC_ASSERT(m_currentView == PackageListing, return); QTC_ASSERT(m_currentView == PackageListing, return);
if (m_sdkManager->isBusy()) { if (m_sdkManager->isBusy()) {
m_formatter->appendMessage(tr("\nSDK Manager is busy."), Utils::StdErrFormat); m_formatter->appendMessage(tr("\nSDK Manager is busy."), StdErrFormat);
return; return;
} }
@@ -290,7 +387,7 @@ void AndroidSdkManagerWidget::onApplyButton(const QString &extraMessage)
void AndroidSdkManagerWidget::onUpdatePackages() void AndroidSdkManagerWidget::onUpdatePackages()
{ {
if (m_sdkManager->isBusy()) { if (m_sdkManager->isBusy()) {
m_formatter->appendMessage(tr("\nSDK Manager is busy."), Utils::StdErrFormat); m_formatter->appendMessage(tr("\nSDK Manager is busy."), StdErrFormat);
return; return;
} }
switchView(Operations); switchView(Operations);
@@ -309,17 +406,17 @@ void AndroidSdkManagerWidget::onOperationResult(int index)
AndroidSdkManager::OperationOutput result = m_currentOperation->resultAt(index); AndroidSdkManager::OperationOutput result = m_currentOperation->resultAt(index);
if (result.type == AndroidSdkManager::LicenseWorkflow) { if (result.type == AndroidSdkManager::LicenseWorkflow) {
// Show license controls and enable to user input. // Show license controls and enable to user input.
m_ui->sdkLicenseLabel->setVisible(true); m_sdkLicenseLabel->setVisible(true);
m_ui->sdkLicensebuttonBox->setVisible(true); m_sdkLicenseButtonBox->setVisible(true);
m_ui->sdkLicensebuttonBox->setEnabled(true); m_sdkLicenseButtonBox->setEnabled(true);
m_ui->sdkLicensebuttonBox->button(QDialogButtonBox::No)->setDefault(true); m_sdkLicenseButtonBox->button(QDialogButtonBox::No)->setDefault(true);
} }
auto breakLine = [](const QString &line) { return line.endsWith("\n") ? line : line + "\n";}; auto breakLine = [](const QString &line) { return line.endsWith("\n") ? line : line + "\n";};
if (!result.stdError.isEmpty() && result.type != AndroidSdkManager::LicenseCheck) if (!result.stdError.isEmpty() && result.type != AndroidSdkManager::LicenseCheck)
m_formatter->appendMessage(breakLine(result.stdError), Utils::StdErrFormat); m_formatter->appendMessage(breakLine(result.stdError), StdErrFormat);
if (!result.stdOutput.isEmpty() && result.type != AndroidSdkManager::LicenseCheck) if (!result.stdOutput.isEmpty() && result.type != AndroidSdkManager::LicenseCheck)
m_formatter->appendMessage(breakLine(result.stdOutput), Utils::StdOutFormat); m_formatter->appendMessage(breakLine(result.stdOutput), StdOutFormat);
m_ui->outputEdit->ensureCursorVisible(); m_outputEdit->ensureCursorVisible();
} }
void AndroidSdkManagerWidget::onLicenseCheckResult(const AndroidSdkManager::OperationOutput& output) void AndroidSdkManagerWidget::onLicenseCheckResult(const AndroidSdkManager::OperationOutput& output)
@@ -345,14 +442,14 @@ void AndroidSdkManagerWidget::addPackageFuture(const QFuture<AndroidSdkManager::
this, &AndroidSdkManagerWidget::packageFutureFinished); this, &AndroidSdkManagerWidget::packageFutureFinished);
connect(m_currentOperation, &QFutureWatcherBase::progressValueChanged, connect(m_currentOperation, &QFutureWatcherBase::progressValueChanged,
this, [this](int value) { this, [this](int value) {
m_ui->operationProgress->setValue(value); m_operationProgress->setValue(value);
}); });
m_currentOperation->setFuture(future); m_currentOperation->setFuture(future);
} else { } else {
qCDebug(androidSdkMgrUiLog) << "Operation canceled/finished before adding to the queue"; qCDebug(androidSdkMgrUiLog) << "Operation canceled/finished before adding to the queue";
if (m_sdkManager->isBusy()) { if (m_sdkManager->isBusy()) {
m_formatter->appendMessage(tr("SDK Manager is busy. Operation cancelled."), m_formatter->appendMessage(tr("SDK Manager is busy. Operation cancelled."),
Utils::StdErrFormat); StdErrFormat);
} }
notifyOperationFinished(); notifyOperationFinished();
switchView(PackageListing); switchView(PackageListing);
@@ -375,22 +472,22 @@ void AndroidSdkManagerWidget::beginExecution()
installSdkPaths << package->sdkStylePath(); installSdkPaths << package->sdkStylePath();
} }
m_formatter->appendMessage(tr("Installing/Uninstalling selected packages...\n"), m_formatter->appendMessage(tr("Installing/Uninstalling selected packages...\n"),
Utils::NormalMessageFormat); NormalMessageFormat);
m_formatter->appendMessage(tr("Closing the %1 dialog will cancel the running and scheduled SDK " m_formatter->appendMessage(tr("Closing the %1 dialog will cancel the running and scheduled SDK "
"operations.\n").arg(Utils::HostOsInfo::isMacHost() ? "operations.\n").arg(HostOsInfo::isMacHost() ?
tr("preferences") : tr("options")), tr("preferences") : tr("options")),
Utils::LogMessageFormat); LogMessageFormat);
addPackageFuture(m_sdkManager->update(installSdkPaths, uninstallSdkPaths)); addPackageFuture(m_sdkManager->update(installSdkPaths, uninstallSdkPaths));
} }
void AndroidSdkManagerWidget::beginUpdate() void AndroidSdkManagerWidget::beginUpdate()
{ {
m_formatter->appendMessage(tr("Updating installed packages...\n"), Utils::NormalMessageFormat); m_formatter->appendMessage(tr("Updating installed packages...\n"), NormalMessageFormat);
m_formatter->appendMessage(tr("Closing the %1 dialog will cancel the running and scheduled SDK " m_formatter->appendMessage(tr("Closing the %1 dialog will cancel the running and scheduled SDK "
"operations.\n").arg(Utils::HostOsInfo::isMacHost() ? "operations.\n").arg(HostOsInfo::isMacHost() ?
tr("preferences") : tr("options")), tr("preferences") : tr("options")),
Utils::LogMessageFormat); LogMessageFormat);
addPackageFuture(m_sdkManager->updateAll()); addPackageFuture(m_sdkManager->updateAll());
} }
@@ -405,7 +502,7 @@ void AndroidSdkManagerWidget::notifyOperationFinished()
if (!m_currentOperation || m_currentOperation->isFinished()) { if (!m_currentOperation || m_currentOperation->isFinished()) {
QMessageBox::information(this, tr("Android SDK Changes"), QMessageBox::information(this, tr("Android SDK Changes"),
tr("Android SDK operations finished."), QMessageBox::Ok); tr("Android SDK operations finished."), QMessageBox::Ok);
m_ui->operationProgress->setValue(0); m_operationProgress->setValue(0);
// Once the update/install is done, let's hide the dialog. // Once the update/install is done, let's hide the dialog.
hide(); hide();
} }
@@ -417,10 +514,10 @@ void AndroidSdkManagerWidget::packageFutureFinished()
bool continueWorkflow = true; bool continueWorkflow = true;
if (m_currentOperation->isCanceled()) { if (m_currentOperation->isCanceled()) {
m_formatter->appendMessage(tr("Operation cancelled.\n"), Utils::StdErrFormat); m_formatter->appendMessage(tr("Operation cancelled.\n"), StdErrFormat);
continueWorkflow = false; continueWorkflow = false;
} }
m_ui->operationProgress->setValue(100); m_operationProgress->setValue(100);
int resultCount = m_currentOperation->future().resultCount(); int resultCount = m_currentOperation->future().resultCount();
if (continueWorkflow && resultCount > 0) { if (continueWorkflow && resultCount > 0) {
AndroidSdkManager::OperationOutput output = m_currentOperation->resultAt(resultCount -1); AndroidSdkManager::OperationOutput output = m_currentOperation->resultAt(resultCount -1);
@@ -432,8 +529,8 @@ void AndroidSdkManagerWidget::packageFutureFinished()
onLicenseCheckResult(output); onLicenseCheckResult(output);
break; break;
case AndroidSdkManager::LicenseWorkflow: case AndroidSdkManager::LicenseWorkflow:
m_ui->sdkLicensebuttonBox->hide(); m_sdkLicenseButtonBox->hide();
m_ui->sdkLicenseLabel->hide(); m_sdkLicenseLabel->hide();
runPendingCommand(); runPendingCommand();
break; break;
case AndroidSdkManager::UpdateAll: case AndroidSdkManager::UpdateAll:
@@ -457,12 +554,12 @@ void AndroidSdkManagerWidget::cancelPendingOperations()
{ {
if (!m_sdkManager->isBusy()) { if (!m_sdkManager->isBusy()) {
m_formatter->appendMessage(tr("\nNo pending operations to cancel...\n"), m_formatter->appendMessage(tr("\nNo pending operations to cancel...\n"),
Utils::NormalMessageFormat); NormalMessageFormat);
switchView(PackageListing); switchView(PackageListing);
return; return;
} }
m_formatter->appendMessage(tr("\nCancelling pending operations...\n"), m_formatter->appendMessage(tr("\nCancelling pending operations...\n"),
Utils::NormalMessageFormat); NormalMessageFormat);
m_sdkManager->cancelOperatons(); m_sdkManager->cancelOperatons();
} }
@@ -474,19 +571,19 @@ void AndroidSdkManagerWidget::switchView(AndroidSdkManagerWidget::View view)
if (m_currentView == PackageListing) { if (m_currentView == PackageListing) {
// We need the buttonBox only in the main listing view, as the license and update // We need the buttonBox only in the main listing view, as the license and update
// views already have a cancel button. // views already have a cancel button.
m_ui->buttonBox->button(QDialogButtonBox::Ok)->setVisible(true); m_buttonBox->button(QDialogButtonBox::Ok)->setVisible(true);
emit updatingSdkFinished(); emit updatingSdkFinished();
} else { } else {
m_ui->buttonBox->button(QDialogButtonBox::Ok)->setVisible(false); m_buttonBox->button(QDialogButtonBox::Ok)->setVisible(false);
emit updatingSdk(); emit updatingSdk();
} }
if (m_currentView == LicenseWorkflow) if (m_currentView == LicenseWorkflow)
emit licenseWorkflowStarted(); emit licenseWorkflowStarted();
m_ui->operationProgress->setValue(0); m_operationProgress->setValue(0);
m_ui->viewStack->setCurrentWidget(m_currentView == PackageListing ? m_viewStack->setCurrentWidget(m_currentView == PackageListing ?
m_ui->packagesStack : m_ui->outputStack); m_packagesStack : m_outputStack);
} }
void AndroidSdkManagerWidget::runPendingCommand() void AndroidSdkManagerWidget::runPendingCommand()
@@ -566,15 +663,15 @@ OptionsDialog::OptionsDialog(AndroidSdkManager *sdkManager, const QStringList &a
resize(800, 480); resize(800, 480);
setWindowTitle(tr("SDK Manager Arguments")); setWindowTitle(tr("SDK Manager Arguments"));
argumentDetailsEdit = new QPlainTextEdit(this); m_argumentDetailsEdit = new QPlainTextEdit(this);
argumentDetailsEdit->setReadOnly(true); m_argumentDetailsEdit->setReadOnly(true);
auto populateOptions = [this](const QString& options) { auto populateOptions = [this](const QString& options) {
if (options.isEmpty()) { if (options.isEmpty()) {
argumentDetailsEdit->setPlainText(tr("Cannot load available arguments for " m_argumentDetailsEdit->setPlainText(tr("Cannot load available arguments for "
"\"sdkmanager\" command.")); "\"sdkmanager\" command."));
} else { } else {
argumentDetailsEdit->setPlainText(options); m_argumentDetailsEdit->setPlainText(options);
} }
}; };
m_optionsFuture = sdkManager->availableArguments(); m_optionsFuture = sdkManager->availableArguments();
@@ -585,14 +682,14 @@ OptionsDialog::OptionsDialog(AndroidSdkManager *sdkManager, const QStringList &a
connect(dialogButtons, &QDialogButtonBox::accepted, this, &OptionsDialog::accept); connect(dialogButtons, &QDialogButtonBox::accepted, this, &OptionsDialog::accept);
connect(dialogButtons, &QDialogButtonBox::rejected, this, &OptionsDialog::reject); connect(dialogButtons, &QDialogButtonBox::rejected, this, &OptionsDialog::reject);
argumentsEdit = new QLineEdit(this); m_argumentsEdit = new QLineEdit(this);
argumentsEdit->setText(args.join(" ")); m_argumentsEdit->setText(args.join(" "));
auto gridLayout = new QGridLayout(this); auto gridLayout = new QGridLayout(this);
gridLayout->addWidget(new QLabel(tr("SDK manager arguments:"), this), 0, 0, 1, 1); gridLayout->addWidget(new QLabel(tr("SDK manager arguments:"), this), 0, 0, 1, 1);
gridLayout->addWidget(argumentsEdit, 0, 1, 1, 1); gridLayout->addWidget(m_argumentsEdit, 0, 1, 1, 1);
gridLayout->addWidget(new QLabel(tr("Available arguments:"), this), 1, 0, 1, 2); gridLayout->addWidget(new QLabel(tr("Available arguments:"), this), 1, 0, 1, 2);
gridLayout->addWidget(argumentDetailsEdit, 2, 0, 1, 2); gridLayout->addWidget(m_argumentDetailsEdit, 2, 0, 1, 2);
gridLayout->addWidget(dialogButtons, 3, 0, 1, 2); gridLayout->addWidget(dialogButtons, 3, 0, 1, 2);
} }
@@ -604,9 +701,8 @@ OptionsDialog::~OptionsDialog()
QStringList OptionsDialog::sdkManagerArguments() const QStringList OptionsDialog::sdkManagerArguments() const
{ {
QString userInput = argumentsEdit->text().simplified(); QString userInput = m_argumentsEdit->text().simplified();
return userInput.isEmpty() ? QStringList() : userInput.split(' '); return userInput.isEmpty() ? QStringList() : userInput.split(' ');
} }
} // namespace Internal } // Android::Internal
} // namespace Android

View File

@@ -36,16 +36,34 @@ class QLineEdit;
class QPlainTextEdit; class QPlainTextEdit;
QT_END_NAMESPACE QT_END_NAMESPACE
#include <QtCore/QVariant>
#include <QtWidgets/QAbstractButton>
#include <QtWidgets/QApplication>
#include <QtWidgets/QCheckBox>
#include <QtWidgets/QComboBox>
#include <QtWidgets/QDialogButtonBox>
#include <QtWidgets/QFrame>
#include <QtWidgets/QGridLayout>
#include <QtWidgets/QGroupBox>
#include <QtWidgets/QHBoxLayout>
#include <QtWidgets/QHeaderView>
#include <QtWidgets/QLabel>
#include <QtWidgets/QPlainTextEdit>
#include <QtWidgets/QProgressBar>
#include <QtWidgets/QPushButton>
#include <QtWidgets/QRadioButton>
#include <QtWidgets/QSpacerItem>
#include <QtWidgets/QStackedWidget>
#include <QtWidgets/QTreeView>
#include <QtWidgets/QVBoxLayout>
#include <QtWidgets/QWidget>
#include <utils/fancylineedit.h>
namespace Utils { class OutputFormatter; } namespace Utils { class OutputFormatter; }
namespace Android { namespace Android::Internal {
namespace Internal {
class AndroidSdkManager; class AndroidSdkManager;
namespace Ui {
class AndroidSdkManagerWidget;
}
class AndroidSdkModel; class AndroidSdkModel;
class OptionsDialog : public QDialog class OptionsDialog : public QDialog
@@ -60,8 +78,8 @@ public:
QStringList sdkManagerArguments() const; QStringList sdkManagerArguments() const;
private: private:
QPlainTextEdit *argumentDetailsEdit; QPlainTextEdit *m_argumentDetailsEdit;
QLineEdit *argumentsEdit; QLineEdit *m_argumentsEdit;
QFuture<QString> m_optionsFuture; QFuture<QString> m_optionsFuture;
}; };
@@ -110,10 +128,17 @@ private:
View m_currentView = PackageListing; View m_currentView = PackageListing;
AndroidSdkManager *m_sdkManager = nullptr; AndroidSdkManager *m_sdkManager = nullptr;
AndroidSdkModel *m_sdkModel = nullptr; AndroidSdkModel *m_sdkModel = nullptr;
Ui::AndroidSdkManagerWidget *m_ui = nullptr;
Utils::OutputFormatter *m_formatter = nullptr; Utils::OutputFormatter *m_formatter = nullptr;
QFutureWatcher<AndroidSdkManager::OperationOutput> *m_currentOperation = nullptr; QFutureWatcher<AndroidSdkManager::OperationOutput> *m_currentOperation = nullptr;
QStackedWidget *m_viewStack;
QWidget *m_packagesStack;
QWidget *m_outputStack;
QProgressBar *m_operationProgress;
QPlainTextEdit *m_outputEdit;
QLabel *m_sdkLicenseLabel;
QDialogButtonBox *m_sdkLicenseButtonBox;
QDialogButtonBox *m_buttonBox;
}; };
} // namespace Internal } // Android::Internal
} // namespace Android

View File

@@ -1,325 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>Android::Internal::AndroidSdkManagerWidget</class>
<widget class="QWidget" name="Android::Internal::AndroidSdkManagerWidget">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>664</width>
<height>396</height>
</rect>
</property>
<property name="windowTitle">
<string>Android SDK Manager</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout_3">
<property name="spacing">
<number>-1</number>
</property>
<property name="leftMargin">
<number>9</number>
</property>
<property name="topMargin">
<number>9</number>
</property>
<property name="rightMargin">
<number>9</number>
</property>
<property name="bottomMargin">
<number>9</number>
</property>
<item>
<widget class="QStackedWidget" name="viewStack">
<property name="currentIndex">
<number>0</number>
</property>
<widget class="QWidget" name="packagesStack">
<layout class="QGridLayout" name="gridLayout">
<property name="leftMargin">
<number>0</number>
</property>
<property name="topMargin">
<number>0</number>
</property>
<property name="rightMargin">
<number>0</number>
</property>
<property name="bottomMargin">
<number>0</number>
</property>
<item row="1" column="0" colspan="2">
<widget class="QTreeView" name="packagesView">
<property name="indentation">
<number>20</number>
</property>
<attribute name="headerCascadingSectionResizes">
<bool>false</bool>
</attribute>
</widget>
</item>
<item row="1" column="2">
<layout class="QVBoxLayout" name="verticalLayout_2">
<item>
<widget class="QPushButton" name="updateInstalledButton">
<property name="text">
<string>Update Installed</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="applySelectionButton">
<property name="enabled">
<bool>false</bool>
</property>
<property name="text">
<string>Apply</string>
</property>
</widget>
</item>
<item>
<spacer name="verticalSpacer">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
</spacer>
</item>
<item>
<widget class="QGroupBox" name="packagesTypeGroup">
<property name="title">
<string>Show Packages</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<layout class="QHBoxLayout" name="channelLayout">
<item>
<widget class="QLabel" name="ChannelLabel">
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>Channel:</string>
</property>
</widget>
</item>
<item>
<widget class="QComboBox" name="channelCheckbox">
<item>
<property name="text">
<string>Default</string>
</property>
</item>
<item>
<property name="text">
<string>Stable</string>
</property>
</item>
<item>
<property name="text">
<string>Beta</string>
</property>
</item>
<item>
<property name="text">
<string>Dev</string>
</property>
</item>
<item>
<property name="text">
<string>Canary</string>
</property>
</item>
</widget>
</item>
</layout>
</item>
<item>
<widget class="QCheckBox" name="oboleteCheckBox">
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>Include obsolete</string>
</property>
</widget>
</item>
<item>
<widget class="Line" name="line">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
</widget>
</item>
<item>
<widget class="QRadioButton" name="showAvailableRadio">
<property name="text">
<string>Available</string>
</property>
</widget>
</item>
<item>
<widget class="QRadioButton" name="showInstalledRadio">
<property name="text">
<string>Installed</string>
</property>
</widget>
</item>
<item>
<widget class="QRadioButton" name="showAllRadio">
<property name="text">
<string>All</string>
</property>
<property name="checked">
<bool>true</bool>
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item>
<widget class="QPushButton" name="optionsButton">
<property name="text">
<string>Advanced Options...</string>
</property>
</widget>
</item>
</layout>
</item>
<item row="0" column="0">
<widget class="Utils::FancyLineEdit" name="searchField"/>
</item>
<item row="0" column="1">
<widget class="QCheckBox" name="expandCheck">
<property name="text">
<string>Expand All</string>
</property>
</widget>
</item>
</layout>
</widget>
<widget class="QWidget" name="outputStack">
<layout class="QGridLayout" name="gridLayout_2">
<property name="leftMargin">
<number>0</number>
</property>
<property name="topMargin">
<number>0</number>
</property>
<property name="rightMargin">
<number>0</number>
</property>
<property name="bottomMargin">
<number>0</number>
</property>
<item row="3" column="2">
<widget class="QPushButton" name="cancelButton">
<property name="text">
<string>Cancel</string>
</property>
</widget>
</item>
<item row="2" column="0" colspan="3">
<widget class="QProgressBar" name="operationProgress">
<property name="maximum">
<number>100</number>
</property>
<property name="value">
<number>0</number>
</property>
<property name="textVisible">
<bool>true</bool>
</property>
<property name="invertedAppearance">
<bool>false</bool>
</property>
</widget>
</item>
<item row="3" column="0">
<spacer name="horizontalSpacer">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item row="0" column="0" colspan="3">
<widget class="QPlainTextEdit" name="outputEdit">
<property name="readOnly">
<bool>true</bool>
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QLabel" name="sdkLicenseLabel">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>Do you want to accept the Android SDK license?</string>
</property>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
</widget>
</item>
<item row="1" column="1" colspan="2">
<widget class="QDialogButtonBox" name="sdkLicensebuttonBox">
<property name="enabled">
<bool>false</bool>
</property>
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="standardButtons">
<set>QDialogButtonBox::No|QDialogButtonBox::Yes</set>
</property>
</widget>
</item>
</layout>
</widget>
</widget>
</item>
<item>
<widget class="QDialogButtonBox" name="buttonBox">
<property name="standardButtons">
<set>QDialogButtonBox::Ok</set>
</property>
</widget>
</item>
</layout>
</widget>
<customwidgets>
<customwidget>
<class>Utils::FancyLineEdit</class>
<extends>QLineEdit</extends>
<header location="global">utils/fancylineedit.h</header>
</customwidget>
</customwidgets>
<tabstops>
<tabstop>packagesView</tabstop>
<tabstop>showAllRadio</tabstop>
<tabstop>showInstalledRadio</tabstop>
<tabstop>showAvailableRadio</tabstop>
<tabstop>outputEdit</tabstop>
</tabstops>
<resources/>
<connections/>
</ui>

View File

@@ -24,7 +24,7 @@
****************************************************************************/ ****************************************************************************/
#pragma once #pragma once
#include "androidconfigurations.h"
#include "androidconfigurations.h" #include "androidconfigurations.h"
#include <QDialog> #include <QDialog>