aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAssam Boudjelthia <assam.boudjelthia@qt.io>2020-03-11 18:49:02 +0200
committerAssam Boudjelthia <assam.boudjelthia@qt.io>2020-03-16 08:21:22 +0000
commit7fd0f307766b95c9619a645d131fe1e9bdbe68b2 (patch)
tree0c9f9641c818fd95fca27baf539882cf37a119e1
parent3faa91945afc056a8b9ebe3d564be47d57de3576 (diff)
Android: use QListWidget to show defined NDKs
Use QListWidget to show all installed NDKs (from SDK manager), and NDKs Added manually by the user. Each item has an icon to indicate if it's removable when added by the user, or non-removable if installed from the SDK manager. Change-Id: I26ae5909ce930d5cc8af561b6b4e9cc5415d12f1 Reviewed-by: Eike Ziller <eike.ziller@qt.io>
-rw-r--r--src/libs/utils/utilsicons.cpp2
-rw-r--r--src/libs/utils/utilsicons.h1
-rw-r--r--src/plugins/android/androidsettingswidget.cpp67
-rw-r--r--src/plugins/android/androidsettingswidget.ui146
4 files changed, 125 insertions, 91 deletions
diff --git a/src/libs/utils/utilsicons.cpp b/src/libs/utils/utilsicons.cpp
index 3ba5a7514f..704ffd9e3c 100644
--- a/src/libs/utils/utilsicons.cpp
+++ b/src/libs/utils/utilsicons.cpp
@@ -42,6 +42,8 @@ const Icon LOCKED({
{QLatin1String(":/utils/images/locked.png"), Theme::PanelTextColorDark}}, Icon::Tint);
const Icon UNLOCKED_TOOLBAR({
{QLatin1String(":/utils/images/unlocked.png"), Theme::IconsBaseColor}});
+const Icon UNLOCKED({
+ {QLatin1String(":/utils/images/unlocked.png"), Theme::PanelTextColorDark}}, Icon::Tint);
const Icon PINNED({
{QLatin1String(":/utils/images/pinned.png"), Theme::PanelTextColorDark}}, Icon::Tint);
const Icon NEXT({
diff --git a/src/libs/utils/utilsicons.h b/src/libs/utils/utilsicons.h
index 04a7566a28..0bd317fbbb 100644
--- a/src/libs/utils/utilsicons.h
+++ b/src/libs/utils/utilsicons.h
@@ -38,6 +38,7 @@ QTCREATOR_UTILS_EXPORT extern const Icon EDIT_CLEAR_TOOLBAR;
QTCREATOR_UTILS_EXPORT extern const Icon LOCKED_TOOLBAR;
QTCREATOR_UTILS_EXPORT extern const Icon LOCKED;
QTCREATOR_UTILS_EXPORT extern const Icon UNLOCKED_TOOLBAR;
+QTCREATOR_UTILS_EXPORT extern const Icon UNLOCKED;
QTCREATOR_UTILS_EXPORT extern const Icon PINNED;
QTCREATOR_UTILS_EXPORT extern const Icon NEXT;
QTCREATOR_UTILS_EXPORT extern const Icon NEXT_TOOLBAR;
diff --git a/src/plugins/android/androidsettingswidget.cpp b/src/plugins/android/androidsettingswidget.cpp
index 30875271c1..62ba4c2308 100644
--- a/src/plugins/android/androidsettingswidget.cpp
+++ b/src/plugins/android/androidsettingswidget.cpp
@@ -54,6 +54,7 @@
#include <QAbstractTableModel>
#include <QDesktopServices>
#include <QDir>
+#include <QFileDialog>
#include <QFutureWatcher>
#include <QList>
#include <QMessageBox>
@@ -360,25 +361,44 @@ void AndroidSettingsWidget::showEvent(QShowEvent *event)
void AndroidSettingsWidget::updateNdkList()
{
- m_ui->ndkListComboBox->clear();
- for (const Ndk *ndk : m_sdkManager->installedNdkPackages())
- m_ui->ndkListComboBox->addItem(ndk->installedLocation().toString());
+ m_ui->ndkListWidget->clear();
+ for (const Ndk *ndk : m_sdkManager->installedNdkPackages()) {
+ m_ui->ndkListWidget->addItem(new QListWidgetItem(Utils::Icons::LOCKED.icon(),
+ ndk->installedLocation().toString()));
+ }
for (const QString &ndk : m_androidConfig.getCustomNdkList()) {
- if (m_androidConfig.isValidNdk(ndk))
- m_ui->ndkListComboBox->addItem(ndk);
- else
+ if (m_androidConfig.isValidNdk(ndk)) {
+ m_ui->ndkListWidget->addItem(
+ new QListWidgetItem(Utils::Icons::UNLOCKED.icon(), ndk));
+ } else {
m_androidConfig.removeCustomNdk(ndk);
+ }
}
+
+ m_ui->ndkListWidget->setCurrentRow(0);
}
void AndroidSettingsWidget::addCustomNdkItem()
{
- const QString ndkPath = QDir::toNativeSeparators(m_ui->customNdkPathChooser->rawPath());
- m_androidConfig.addCustomNdk(ndkPath);
- if (m_ui->ndkListComboBox->findData(ndkPath) == -1)
- m_ui->ndkListComboBox->addItem(ndkPath);
- m_ui->ndkListComboBox->setCurrentText(ndkPath);
+ const QString homePath = QStandardPaths::standardLocations(QStandardPaths::HomeLocation).first();
+ const QString ndkPath = QFileDialog::getExistingDirectory(this, tr("Select an NDK"), homePath);
+
+ if (m_androidConfig.isValidNdk(ndkPath)) {
+ m_androidConfig.addCustomNdk(ndkPath);
+ if (m_ui->ndkListWidget->findItems(ndkPath, Qt::MatchExactly).size() == 0) {
+ m_ui->ndkListWidget->addItem(
+ new QListWidgetItem(Utils::Icons::UNLOCKED.icon(), ndkPath));
+ }
+ } else if (!ndkPath.isEmpty()) {
+ QMessageBox::warning(
+ this,
+ tr("Add Custom NDK"),
+ tr("The selected path has an invalid NDK. This might mean that the path contains space "
+ "characters, or that it does not have a \"toolchains\" sub-directory, or that the "
+ "NDK version could not be retrieved because of a missing \"source.properties\" or "
+ "\"RELEASE.TXT\" file"));
+ }
}
AndroidSettingsWidget::AndroidSettingsWidget()
@@ -481,25 +501,18 @@ AndroidSettingsWidget::AndroidSettingsWidget()
connect(m_ui->SDKLocationPathChooser, &Utils::PathChooser::rawPathChanged,
this, &AndroidSettingsWidget::onSdkPathChanged);
- connect(m_ui->ndkListComboBox,
- QOverload<const QString &>::of(&QComboBox::currentIndexChanged),
- [this](const QString &ndk) {
- validateNdk();
- m_ui->removeCustomNdkButton->setEnabled(m_androidConfig.getCustomNdkList().contains(ndk));
- });
- connect(m_ui->customNdkPathChooser, &Utils::PathChooser::rawPathChanged, this, [this]() {
- const QString ndkPath = m_ui->customNdkPathChooser->rawPath();
- m_ui->addCustomNdkButton->setEnabled(m_androidConfig.isValidNdk(ndkPath));
+
+ connect(m_ui->ndkListWidget, &QListWidget::currentTextChanged, [this](const QString &ndk) {
+ validateNdk();
+ m_ui->removeCustomNdkButton->setEnabled(m_androidConfig.getCustomNdkList().contains(ndk));
});
connect(m_ui->addCustomNdkButton, &QPushButton::clicked, this,
&AndroidSettingsWidget::addCustomNdkItem);
connect(m_ui->removeCustomNdkButton, &QPushButton::clicked, this, [this]() {
- m_androidConfig.removeCustomNdk(m_ui->ndkListComboBox->currentText());
- m_ui->ndkListComboBox->removeItem(m_ui->ndkListComboBox->currentIndex());
+ m_androidConfig.removeCustomNdk(m_ui->ndkListWidget->currentItem()->text());
+ m_ui->ndkListWidget->takeItem(m_ui->ndkListWidget->currentRow());
});
- connect(m_ui->ndkListComboBox, QOverload<const QString &>::of(&QComboBox::currentIndexChanged),
- [this](const QString) { validateNdk(); });
connect(m_ui->openSslPathChooser, &Utils::PathChooser::rawPathChanged, this,
&AndroidSettingsWidget::validateOpenSsl);
connect(&m_virtualDevicesWatcher, &QFutureWatcherBase::finished,
@@ -664,7 +677,8 @@ Utils::FilePath AndroidSettingsWidget::findJdkInCommonPaths()
void AndroidSettingsWidget::validateNdk()
{
- auto ndkPath = Utils::FilePath::fromUserInput(m_ui->ndkListComboBox->currentText());
+ const QListWidgetItem *currentItem = m_ui->ndkListWidget->currentItem();
+ Utils::FilePath ndkPath = Utils::FilePath::fromString(currentItem ? currentItem->text() : "");
auto summaryWidget = static_cast<SummaryWidget *>(m_ui->androidDetailsWidget->widget());
summaryWidget->setPointValid(NdkPathExistsRow, ndkPath.exists());
@@ -889,7 +903,8 @@ void AndroidSettingsWidget::updateUI()
m_ui->sdkManagerTab->setEnabled(sdkToolsOk);
m_sdkManagerWidget->setSdkManagerControlsEnabled(!m_androidConfig.useNativeUiTools());
- Utils::FilePath currentNdk = Utils::FilePath::fromString(m_ui->ndkListComboBox->currentText());
+ const QListWidgetItem *currentItem = m_ui->ndkListWidget->currentItem();
+ Utils::FilePath currentNdk = Utils::FilePath::fromString(currentItem ? currentItem->text() : "");
auto infoText = tr("(SDK Version: %1, NDK Bundle Version: %2)")
.arg(m_androidConfig.sdkToolsVersion().toString())
.arg(currentNdk.isEmpty() ? "" : m_androidConfig.ndkVersion(currentNdk).toString());
diff --git a/src/plugins/android/androidsettingswidget.ui b/src/plugins/android/androidsettingswidget.ui
index 2a25b93386..12d54c0785 100644
--- a/src/plugins/android/androidsettingswidget.ui
+++ b/src/plugins/android/androidsettingswidget.ui
@@ -106,23 +106,6 @@
</property>
</widget>
</item>
- <item row="1" column="0">
- <widget class="QLabel" name="customNdkLabel">
- <property name="text">
- <string>Add custom NDK:</string>
- </property>
- </widget>
- </item>
- <item row="1" column="6">
- <widget class="QToolButton" name="downloadNDKToolButton">
- <property name="text">
- <string/>
- </property>
- </widget>
- </item>
- <item row="0" column="1" colspan="4">
- <widget class="Utils::PathChooser" name="SDKLocationPathChooser" native="true"/>
- </item>
<item row="0" column="5">
<widget class="QToolButton" name="sdkToolsAutoDownloadButton">
<property name="toolTip">
@@ -133,16 +116,6 @@
</property>
</widget>
</item>
- <item row="3" column="0" colspan="7">
- <widget class="Utils::DetailsWidget" name="androidDetailsWidget" native="true"/>
- </item>
- <item row="2" column="0">
- <widget class="QLabel" name="ndkComboBoxLabel">
- <property name="text">
- <string>Android NDK list:</string>
- </property>
- </widget>
- </item>
<item row="0" column="6">
<widget class="QToolButton" name="downloadSDKToolButton">
<property name="toolTip">
@@ -150,57 +123,100 @@
</property>
</widget>
</item>
- <item row="1" column="1" colspan="3">
- <widget class="Utils::PathChooser" name="customNdkPathChooser" native="true">
- <property name="minimumSize">
- <size>
- <width>20</width>
- <height>0</height>
- </size>
- </property>
- </widget>
- </item>
- <item row="1" column="4">
- <widget class="QPushButton" name="addCustomNdkButton">
- <property name="enabled">
- <bool>false</bool>
- </property>
- <property name="sizePolicy">
- <sizepolicy hsizetype="Maximum" vsizetype="Fixed">
- <horstretch>0</horstretch>
- <verstretch>0</verstretch>
- </sizepolicy>
- </property>
+ <item row="2" column="6">
+ <widget class="QToolButton" name="downloadNDKToolButton">
<property name="toolTip">
- <string>Add the selected custom NDK. The toolchains and debuggers will be created automatically.</string>
+ <string/>
</property>
<property name="text">
- <string>Add</string>
+ <string/>
</property>
</widget>
</item>
- <item row="2" column="1" colspan="3">
- <widget class="QComboBox" name="ndkListComboBox"/>
+ <item row="0" column="1" colspan="4">
+ <widget class="Utils::PathChooser" name="SDKLocationPathChooser" native="true"/>
</item>
- <item row="2" column="4">
- <widget class="QPushButton" name="removeCustomNdkButton">
- <property name="enabled">
- <bool>false</bool>
+ <item row="5" column="0" colspan="7">
+ <widget class="Utils::DetailsWidget" name="androidDetailsWidget" native="true"/>
+ </item>
+ <item row="2" column="0">
+ <widget class="QLabel" name="ndkComboBoxLabel">
+ <property name="text">
+ <string>Android NDK list:</string>
</property>
- <property name="sizePolicy">
- <sizepolicy hsizetype="Maximum" vsizetype="Fixed">
- <horstretch>0</horstretch>
- <verstretch>0</verstretch>
- </sizepolicy>
+ </widget>
+ </item>
+ <item row="2" column="1" rowspan="3">
+ <widget class="QListWidget" name="ndkListWidget">
+ <property name="sizeAdjustPolicy">
+ <enum>QAbstractScrollArea::AdjustToContents</enum>
</property>
- <property name="toolTip">
- <string>Remove the selected custom NDK.</string>
+ <property name="resizeMode">
+ <enum>QListView::Adjust</enum>
</property>
- <property name="text">
- <string>Remove</string>
+ <property name="modelColumn">
+ <number>0</number>
+ </property>
+ <property name="sortingEnabled">
+ <bool>false</bool>
</property>
</widget>
</item>
+ <item row="2" column="2" rowspan="3" colspan="3">
+ <layout class="QVBoxLayout" name="verticalLayout_3">
+ <item>
+ <widget class="QPushButton" name="addCustomNdkButton">
+ <property name="enabled">
+ <bool>true</bool>
+ </property>
+ <property name="sizePolicy">
+ <sizepolicy hsizetype="Maximum" vsizetype="Fixed">
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="toolTip">
+ <string>Add the selected custom NDK. The toolchains and debuggers will be created automatically.</string>
+ </property>
+ <property name="text">
+ <string>Add...</string>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QPushButton" name="removeCustomNdkButton">
+ <property name="enabled">
+ <bool>false</bool>
+ </property>
+ <property name="sizePolicy">
+ <sizepolicy hsizetype="Maximum" vsizetype="Fixed">
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="toolTip">
+ <string>Remove the selected NDK if it has been added manually.</string>
+ </property>
+ <property name="text">
+ <string>Remove</string>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <spacer name="verticalSpacer_3">
+ <property name="orientation">
+ <enum>Qt::Vertical</enum>
+ </property>
+ <property name="sizeHint" stdset="0">
+ <size>
+ <width>20</width>
+ <height>40</height>
+ </size>
+ </property>
+ </spacer>
+ </item>
+ </layout>
+ </item>
</layout>
</widget>
</item>