Commit c263b1ce authored by Daniel Teske's avatar Daniel Teske Committed by Robert Loehning

Use PathChooser in AndroidSettingsWidget

Task-number: QTCREATORBUG-11500
Change-Id: I8e449cb3c89fc3474344b4f9959b567681a6ab1a
Reviewed-by: default avatarDaniel Teske <daniel.teske@digia.com>
Reviewed-by: default avatarRobert Loehning <robert.loehning@digia.com>
parent b7b8c47b
......@@ -44,6 +44,8 @@
#include <qtsupport/qtkitinformation.h>
#include <qtsupport/qtversionmanager.h>
#include <utils/pathchooser.h>
#include <QFile>
#include <QTextStream>
#include <QProcess>
......@@ -132,11 +134,32 @@ AndroidSettingsWidget::AndroidSettingsWidget(QWidget *parent)
{
m_ui->setupUi(this);
m_ui->SDKLocationLineEdit->setText(m_androidConfig.sdkLocation().toUserOutput());
m_ui->NDKLocationLineEdit->setText(m_androidConfig.ndkLocation().toUserOutput());
m_ui->SDKLocationPathChooser->setFileName(m_androidConfig.sdkLocation());
m_ui->SDKLocationPathChooser->setPromptDialogTitle(tr("Select Android SDK folder"));
m_ui->NDKLocationPathChooser->setFileName(m_androidConfig.ndkLocation());
m_ui->NDKLocationPathChooser->setPromptDialogTitle(tr("Select Android NDK folder"));
m_ui->AntLocationLineEdit->setText(m_androidConfig.antLocation().toUserOutput());
m_ui->OpenJDKLocationLineEdit->setText(m_androidConfig.openJDKLocation().toUserOutput());
QString dir;
QString filter;
if (Utils::HostOsInfo::isWindowsHost()) {
dir = QDir::homePath() + QLatin1String("/ant.bat");
filter = QLatin1String("ant (ant.bat)");
} else if (Utils::HostOsInfo::isMacHost()) {
// work around QTBUG-7739 that prohibits filters that don't start with *
dir = QLatin1String("/usr/bin/ant");
filter = QLatin1String("ant (*ant)");
} else {
dir = QLatin1String("/usr/bin/ant");
filter = QLatin1String("ant (ant)");
}
m_ui->AntLocationPathChooser->setFileName(m_androidConfig.antLocation());
m_ui->AntLocationPathChooser->setExpectedKind(Utils::PathChooser::Command);
m_ui->AntLocationPathChooser->setPromptDialogTitle(tr("Select ant Script"));
m_ui->AntLocationPathChooser->setInitialBrowsePathBackup(dir);
m_ui->AntLocationPathChooser->setPromptDialogFilter(filter);
m_ui->OpenJDKLocationPathChooser->setFileName(m_androidConfig.openJDKLocation());
m_ui->OpenJDKLocationPathChooser->setPromptDialogTitle(tr("Select JDK Path"));
m_ui->DataPartitionSizeSpinBox->setValue(m_androidConfig.partitionSize());
m_ui->CreateKitCheckBox->setChecked(m_androidConfig.automaticKitCreation());
m_ui->AVDTableView->setModel(&m_AVDModel);
......@@ -147,11 +170,6 @@ AndroidSettingsWidget::AndroidSettingsWidget(QWidget *parent)
m_ui->downloadAntToolButton->setVisible(!Utils::HostOsInfo::isLinuxHost());
m_ui->downloadOpenJDKToolButton->setVisible(!Utils::HostOsInfo::isLinuxHost());
m_ui->SDKLocationPushButton->setText(Utils::PathChooser::browseButtonLabel());
m_ui->NDKLocationPushButton->setText(Utils::PathChooser::browseButtonLabel());
m_ui->AntLocationPushButton->setText(Utils::PathChooser::browseButtonLabel());
m_ui->OpenJDKLocationPushButton->setText(Utils::PathChooser::browseButtonLabel());
check(All);
applyToUi(All);
......@@ -249,7 +267,7 @@ void AndroidSettingsWidget::applyToUi(AndroidSettingsWidget::Mode mode)
if (m_sdkState == Error) {
m_ui->sdkWarningIconLabel->setVisible(true);
m_ui->sdkWarningLabel->setVisible(true);
Utils::FileName location = Utils::FileName::fromUserInput(m_ui->SDKLocationLineEdit->text());
Utils::FileName location = Utils::FileName::fromUserInput(m_ui->SDKLocationPathChooser->rawPath());
if (sdkLocationIsValid())
m_ui->sdkWarningLabel->setText(tr("The Platform tools are missing. Please use the Android SDK Manager to install them."));
else
......@@ -351,7 +369,7 @@ int indexOf(const QList<AndroidToolChainFactory::AndroidToolChainInformation> &l
void AndroidSettingsWidget::sdkLocationEditingFinished()
{
m_androidConfig.setSdkLocation(Utils::FileName::fromUserInput(m_ui->SDKLocationLineEdit->text()));
m_androidConfig.setSdkLocation(Utils::FileName::fromUserInput(m_ui->SDKLocationPathChooser->rawPath()));
check(Sdk);
......@@ -363,7 +381,7 @@ void AndroidSettingsWidget::sdkLocationEditingFinished()
void AndroidSettingsWidget::ndkLocationEditingFinished()
{
m_androidConfig.setNdkLocation(Utils::FileName::fromUserInput(m_ui->NDKLocationLineEdit->text()));
m_androidConfig.setNdkLocation(Utils::FileName::fromUserInput(m_ui->NDKLocationPathChooser->rawPath()));
check(Ndk);
......@@ -390,7 +408,7 @@ void AndroidSettingsWidget::searchForAnt(const Utils::FileName &location)
ant.appendPath(QLatin1String("ant"));
if (ant.toFileInfo().exists()) {
m_androidConfig.setAntLocation(ant);
m_ui->AntLocationLineEdit->setText(ant.toUserOutput());
m_ui->AntLocationPathChooser->setFileName(ant);
}
}
}
......@@ -398,72 +416,17 @@ void AndroidSettingsWidget::searchForAnt(const Utils::FileName &location)
void AndroidSettingsWidget::antLocationEditingFinished()
{
m_androidConfig.setAntLocation(Utils::FileName::fromUserInput(m_ui->AntLocationLineEdit->text()));
m_androidConfig.setAntLocation(Utils::FileName::fromUserInput(m_ui->AntLocationPathChooser->rawPath()));
}
void AndroidSettingsWidget::openJDKLocationEditingFinished()
{
m_androidConfig.setOpenJDKLocation(Utils::FileName::fromUserInput(m_ui->OpenJDKLocationLineEdit->text()));
m_androidConfig.setOpenJDKLocation(Utils::FileName::fromUserInput(m_ui->OpenJDKLocationPathChooser->rawPath()));
check(Java);
applyToUi(Java);
}
void AndroidSettingsWidget::browseSDKLocation()
{
Utils::FileName dir = Utils::FileName::fromString(
QFileDialog::getExistingDirectory(this, tr("Select Android SDK folder"),
m_ui->SDKLocationLineEdit->text()));
if (dir.isEmpty())
return;
m_ui->SDKLocationLineEdit->setText(dir.toUserOutput());
sdkLocationEditingFinished();
}
void AndroidSettingsWidget::browseNDKLocation()
{
Utils::FileName dir = Utils::FileName::fromString(
QFileDialog::getExistingDirectory(this, tr("Select Android NDK folder"),
m_ui->NDKLocationLineEdit->text()));
if (dir.isEmpty())
return;
m_ui->NDKLocationLineEdit->setText(dir.toUserOutput());
ndkLocationEditingFinished();
}
void AndroidSettingsWidget::browseAntLocation()
{
QString dir;
QString filter;
if (Utils::HostOsInfo::isWindowsHost()) {
dir = QDir::homePath() + QLatin1String("/ant.bat");
filter = QLatin1String("ant (ant.bat)");
} else if (Utils::HostOsInfo::isMacHost()) {
// work around QTBUG-7739 that prohibits filters that don't start with *
dir = QLatin1String("/usr/bin/ant");
filter = QLatin1String("ant (*ant)");
} else {
dir = QLatin1String("/usr/bin/ant");
filter = QLatin1String("ant (ant)");
}
const QString file =
QFileDialog::getOpenFileName(this, tr("Select ant Script"), dir, filter);
if (!file.length())
return;
m_ui->AntLocationLineEdit->setText(QDir::toNativeSeparators(file));
antLocationEditingFinished();
}
void AndroidSettingsWidget::browseOpenJDKLocation()
{
Utils::FileName openJDKPath = m_androidConfig.openJDKLocation();
Utils::FileName file = Utils::FileName::fromString(QFileDialog::getExistingDirectory(this, tr("Select JDK Path"), openJDKPath.toString()));
if (file.isEmpty())
return;
m_ui->OpenJDKLocationLineEdit->setText(file.toUserOutput());
openJDKLocationEditingFinished();
}
void AndroidSettingsWidget::openSDKDownloadUrl()
{
QDesktopServices::openUrl(QUrl::fromUserInput(QLatin1String("http://developer.android.com/sdk")));
......
......@@ -79,10 +79,6 @@ private slots:
void searchForAnt(const Utils::FileName &location);
void antLocationEditingFinished();
void openJDKLocationEditingFinished();
void browseSDKLocation();
void browseNDKLocation();
void browseAntLocation();
void browseOpenJDKLocation();
void openSDKDownloadUrl();
void openNDKDownloadUrl();
void openAntDownloadUrl();
......
......@@ -13,7 +13,7 @@
<property name="windowTitle">
<string>Android Configuration</string>
</property>
<layout class="QGridLayout" name="gridLayout">
<layout class="QGridLayout" name="gridLayout" columnstretch="0,1,0,0">
<item row="0" column="0">
<widget class="QLabel" name="OpenJDKLocationLabel">
<property name="sizePolicy">
......@@ -30,15 +30,8 @@
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QLineEdit" name="OpenJDKLocationLineEdit"/>
</item>
<item row="0" column="2">
<widget class="QPushButton" name="OpenJDKLocationPushButton">
<property name="text">
<string>Browse</string>
</property>
</widget>
<item row="0" column="1" colspan="2">
<widget class="Utils::PathChooser" name="OpenJDKLocationPathChooser" native="true"/>
</item>
<item row="0" column="3">
<widget class="QToolButton" name="downloadOpenJDKToolButton">
......@@ -103,15 +96,8 @@
</property>
</widget>
</item>
<item row="2" column="1">
<widget class="QLineEdit" name="SDKLocationLineEdit"/>
</item>
<item row="2" column="2">
<widget class="QPushButton" name="SDKLocationPushButton">
<property name="text">
<string>Browse</string>
</property>
</widget>
<item row="2" column="1" colspan="2">
<widget class="Utils::PathChooser" name="SDKLocationPathChooser" native="true"/>
</item>
<item row="2" column="3">
<widget class="QToolButton" name="downloadSDKToolButton">
......@@ -176,15 +162,8 @@
</property>
</widget>
</item>
<item row="4" column="1">
<widget class="QLineEdit" name="NDKLocationLineEdit"/>
</item>
<item row="4" column="2">
<widget class="QPushButton" name="NDKLocationPushButton">
<property name="text">
<string>Browse</string>
</property>
</widget>
<item row="4" column="1" colspan="2">
<widget class="Utils::PathChooser" name="NDKLocationPathChooser" native="true"/>
</item>
<item row="4" column="3">
<widget class="QToolButton" name="downloadNDKToolButton">
......@@ -304,15 +283,8 @@
</property>
</widget>
</item>
<item row="8" column="1">
<widget class="QLineEdit" name="AntLocationLineEdit"/>
</item>
<item row="8" column="2">
<widget class="QPushButton" name="AntLocationPushButton">
<property name="text">
<string>Browse</string>
</property>
</widget>
<item row="8" column="1" colspan="2">
<widget class="Utils::PathChooser" name="AntLocationPathChooser" native="true"/>
</item>
<item row="8" column="3">
<widget class="QToolButton" name="downloadAntToolButton">
......@@ -446,13 +418,21 @@
</item>
</layout>
</widget>
<customwidgets>
<customwidget>
<class>Utils::PathChooser</class>
<extends>QWidget</extends>
<header location="global">utils/pathchooser.h</header>
<container>1</container>
</customwidget>
</customwidgets>
<resources>
<include location="android.qrc"/>
</resources>
<connections>
<connection>
<sender>NDKLocationLineEdit</sender>
<signal>editingFinished()</signal>
<sender>NDKLocationPathChooser</sender>
<signal>changed(QString)</signal>
<receiver>AndroidSettingsWidget</receiver>
<slot>ndkLocationEditingFinished()</slot>
<hints>
......@@ -467,24 +447,8 @@
</hints>
</connection>
<connection>
<sender>NDKLocationPushButton</sender>
<signal>clicked()</signal>
<receiver>AndroidSettingsWidget</receiver>
<slot>browseNDKLocation()</slot>
<hints>
<hint type="sourcelabel">
<x>657</x>
<y>49</y>
</hint>
<hint type="destinationlabel">
<x>352</x>
<y>210</y>
</hint>
</hints>
</connection>
<connection>
<sender>SDKLocationLineEdit</sender>
<signal>editingFinished()</signal>
<sender>SDKLocationPathChooser</sender>
<signal>changed(QString)</signal>
<receiver>AndroidSettingsWidget</receiver>
<slot>sdkLocationEditingFinished()</slot>
<hints>
......@@ -499,24 +463,8 @@
</hints>
</connection>
<connection>
<sender>SDKLocationPushButton</sender>
<signal>clicked()</signal>
<receiver>AndroidSettingsWidget</receiver>
<slot>browseSDKLocation()</slot>
<hints>
<hint type="sourcelabel">
<x>657</x>
<y>17</y>
</hint>
<hint type="destinationlabel">
<x>352</x>
<y>210</y>
</hint>
</hints>
</connection>
<connection>
<sender>AntLocationLineEdit</sender>
<signal>editingFinished()</signal>
<sender>AntLocationPathChooser</sender>
<signal>changed(QString)</signal>
<receiver>AndroidSettingsWidget</receiver>
<slot>antLocationEditingFinished()</slot>
<hints>
......@@ -531,24 +479,8 @@
</hints>
</connection>
<connection>
<sender>AntLocationPushButton</sender>
<signal>clicked()</signal>
<receiver>AndroidSettingsWidget</receiver>
<slot>browseAntLocation()</slot>
<hints>
<hint type="sourcelabel">
<x>657</x>
<y>113</y>
</hint>
<hint type="destinationlabel">
<x>352</x>
<y>210</y>
</hint>
</hints>
</connection>
<connection>
<sender>OpenJDKLocationLineEdit</sender>
<signal>editingFinished()</signal>
<sender>OpenJDKLocationPathChooser</sender>
<signal>changed(QString)</signal>
<receiver>AndroidSettingsWidget</receiver>
<slot>openJDKLocationEditingFinished()</slot>
<hints>
......@@ -562,22 +494,6 @@
</hint>
</hints>
</connection>
<connection>
<sender>OpenJDKLocationPushButton</sender>
<signal>clicked()</signal>
<receiver>AndroidSettingsWidget</receiver>
<slot>browseOpenJDKLocation()</slot>
<hints>
<hint type="sourcelabel">
<x>657</x>
<y>49</y>
</hint>
<hint type="destinationlabel">
<x>352</x>
<y>210</y>
</hint>
</hints>
</connection>
<connection>
<sender>AVDAddPushButton</sender>
<signal>clicked()</signal>
......@@ -734,17 +650,13 @@
<slots>
<slot>sdkLocationEditingFinished()</slot>
<slot>ndkLocationEditingFinished()</slot>
<slot>browseSDKLocation()</slot>
<slot>browseNDKLocation()</slot>
<slot>antLocationEditingFinished()</slot>
<slot>browseAntLocation()</slot>
<slot>addAVD()</slot>
<slot>removeAVD()</slot>
<slot>startAVD()</slot>
<slot>avdActivated(QModelIndex)</slot>
<slot>dataPartitionSizeEditingFinished()</slot>
<slot>openJDKLocationEditingFinished()</slot>
<slot>browseOpenJDKLocation()</slot>
<slot>manageAVD()</slot>
<slot>createKitToggled()</slot>
<slot>openSDKDownloadUrl()</slot>
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment