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 @@ ...@@ -44,6 +44,8 @@
#include <qtsupport/qtkitinformation.h> #include <qtsupport/qtkitinformation.h>
#include <qtsupport/qtversionmanager.h> #include <qtsupport/qtversionmanager.h>
#include <utils/pathchooser.h>
#include <QFile> #include <QFile>
#include <QTextStream> #include <QTextStream>
#include <QProcess> #include <QProcess>
...@@ -132,11 +134,32 @@ AndroidSettingsWidget::AndroidSettingsWidget(QWidget *parent) ...@@ -132,11 +134,32 @@ AndroidSettingsWidget::AndroidSettingsWidget(QWidget *parent)
{ {
m_ui->setupUi(this); m_ui->setupUi(this);
m_ui->SDKLocationLineEdit->setText(m_androidConfig.sdkLocation().toUserOutput()); m_ui->SDKLocationPathChooser->setFileName(m_androidConfig.sdkLocation());
m_ui->NDKLocationLineEdit->setText(m_androidConfig.ndkLocation().toUserOutput()); 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()); QString dir;
m_ui->OpenJDKLocationLineEdit->setText(m_androidConfig.openJDKLocation().toUserOutput()); 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->DataPartitionSizeSpinBox->setValue(m_androidConfig.partitionSize());
m_ui->CreateKitCheckBox->setChecked(m_androidConfig.automaticKitCreation()); m_ui->CreateKitCheckBox->setChecked(m_androidConfig.automaticKitCreation());
m_ui->AVDTableView->setModel(&m_AVDModel); m_ui->AVDTableView->setModel(&m_AVDModel);
...@@ -147,11 +170,6 @@ AndroidSettingsWidget::AndroidSettingsWidget(QWidget *parent) ...@@ -147,11 +170,6 @@ AndroidSettingsWidget::AndroidSettingsWidget(QWidget *parent)
m_ui->downloadAntToolButton->setVisible(!Utils::HostOsInfo::isLinuxHost()); m_ui->downloadAntToolButton->setVisible(!Utils::HostOsInfo::isLinuxHost());
m_ui->downloadOpenJDKToolButton->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); check(All);
applyToUi(All); applyToUi(All);
...@@ -249,7 +267,7 @@ void AndroidSettingsWidget::applyToUi(AndroidSettingsWidget::Mode mode) ...@@ -249,7 +267,7 @@ void AndroidSettingsWidget::applyToUi(AndroidSettingsWidget::Mode mode)
if (m_sdkState == Error) { if (m_sdkState == Error) {
m_ui->sdkWarningIconLabel->setVisible(true); m_ui->sdkWarningIconLabel->setVisible(true);
m_ui->sdkWarningLabel->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()) if (sdkLocationIsValid())
m_ui->sdkWarningLabel->setText(tr("The Platform tools are missing. Please use the Android SDK Manager to install them.")); m_ui->sdkWarningLabel->setText(tr("The Platform tools are missing. Please use the Android SDK Manager to install them."));
else else
...@@ -351,7 +369,7 @@ int indexOf(const QList<AndroidToolChainFactory::AndroidToolChainInformation> &l ...@@ -351,7 +369,7 @@ int indexOf(const QList<AndroidToolChainFactory::AndroidToolChainInformation> &l
void AndroidSettingsWidget::sdkLocationEditingFinished() 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); check(Sdk);
...@@ -363,7 +381,7 @@ void AndroidSettingsWidget::sdkLocationEditingFinished() ...@@ -363,7 +381,7 @@ void AndroidSettingsWidget::sdkLocationEditingFinished()
void AndroidSettingsWidget::ndkLocationEditingFinished() 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); check(Ndk);
...@@ -390,7 +408,7 @@ void AndroidSettingsWidget::searchForAnt(const Utils::FileName &location) ...@@ -390,7 +408,7 @@ void AndroidSettingsWidget::searchForAnt(const Utils::FileName &location)
ant.appendPath(QLatin1String("ant")); ant.appendPath(QLatin1String("ant"));
if (ant.toFileInfo().exists()) { if (ant.toFileInfo().exists()) {
m_androidConfig.setAntLocation(ant); 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) ...@@ -398,72 +416,17 @@ void AndroidSettingsWidget::searchForAnt(const Utils::FileName &location)
void AndroidSettingsWidget::antLocationEditingFinished() 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() 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); check(Java);
applyToUi(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() void AndroidSettingsWidget::openSDKDownloadUrl()
{ {
QDesktopServices::openUrl(QUrl::fromUserInput(QLatin1String("http://developer.android.com/sdk"))); QDesktopServices::openUrl(QUrl::fromUserInput(QLatin1String("http://developer.android.com/sdk")));
......
...@@ -79,10 +79,6 @@ private slots: ...@@ -79,10 +79,6 @@ private slots:
void searchForAnt(const Utils::FileName &location); void searchForAnt(const Utils::FileName &location);
void antLocationEditingFinished(); void antLocationEditingFinished();
void openJDKLocationEditingFinished(); void openJDKLocationEditingFinished();
void browseSDKLocation();
void browseNDKLocation();
void browseAntLocation();
void browseOpenJDKLocation();
void openSDKDownloadUrl(); void openSDKDownloadUrl();
void openNDKDownloadUrl(); void openNDKDownloadUrl();
void openAntDownloadUrl(); void openAntDownloadUrl();
......
...@@ -13,7 +13,7 @@ ...@@ -13,7 +13,7 @@
<property name="windowTitle"> <property name="windowTitle">
<string>Android Configuration</string> <string>Android Configuration</string>
</property> </property>
<layout class="QGridLayout" name="gridLayout"> <layout class="QGridLayout" name="gridLayout" columnstretch="0,1,0,0">
<item row="0" column="0"> <item row="0" column="0">
<widget class="QLabel" name="OpenJDKLocationLabel"> <widget class="QLabel" name="OpenJDKLocationLabel">
<property name="sizePolicy"> <property name="sizePolicy">
...@@ -30,15 +30,8 @@ ...@@ -30,15 +30,8 @@
</property> </property>
</widget> </widget>
</item> </item>
<item row="0" column="1"> <item row="0" column="1" colspan="2">
<widget class="QLineEdit" name="OpenJDKLocationLineEdit"/> <widget class="Utils::PathChooser" name="OpenJDKLocationPathChooser" native="true"/>
</item>
<item row="0" column="2">
<widget class="QPushButton" name="OpenJDKLocationPushButton">
<property name="text">
<string>Browse</string>
</property>
</widget>
</item> </item>
<item row="0" column="3"> <item row="0" column="3">
<widget class="QToolButton" name="downloadOpenJDKToolButton"> <widget class="QToolButton" name="downloadOpenJDKToolButton">
...@@ -103,15 +96,8 @@ ...@@ -103,15 +96,8 @@
</property> </property>
</widget> </widget>
</item> </item>
<item row="2" column="1"> <item row="2" column="1" colspan="2">
<widget class="QLineEdit" name="SDKLocationLineEdit"/> <widget class="Utils::PathChooser" name="SDKLocationPathChooser" native="true"/>
</item>
<item row="2" column="2">
<widget class="QPushButton" name="SDKLocationPushButton">
<property name="text">
<string>Browse</string>
</property>
</widget>
</item> </item>
<item row="2" column="3"> <item row="2" column="3">
<widget class="QToolButton" name="downloadSDKToolButton"> <widget class="QToolButton" name="downloadSDKToolButton">
...@@ -176,15 +162,8 @@ ...@@ -176,15 +162,8 @@
</property> </property>
</widget> </widget>
</item> </item>
<item row="4" column="1"> <item row="4" column="1" colspan="2">
<widget class="QLineEdit" name="NDKLocationLineEdit"/> <widget class="Utils::PathChooser" name="NDKLocationPathChooser" native="true"/>
</item>
<item row="4" column="2">
<widget class="QPushButton" name="NDKLocationPushButton">
<property name="text">
<string>Browse</string>
</property>
</widget>
</item> </item>
<item row="4" column="3"> <item row="4" column="3">
<widget class="QToolButton" name="downloadNDKToolButton"> <widget class="QToolButton" name="downloadNDKToolButton">
...@@ -304,15 +283,8 @@ ...@@ -304,15 +283,8 @@
</property> </property>
</widget> </widget>
</item> </item>
<item row="8" column="1"> <item row="8" column="1" colspan="2">
<widget class="QLineEdit" name="AntLocationLineEdit"/> <widget class="Utils::PathChooser" name="AntLocationPathChooser" native="true"/>
</item>
<item row="8" column="2">
<widget class="QPushButton" name="AntLocationPushButton">
<property name="text">
<string>Browse</string>
</property>
</widget>
</item> </item>
<item row="8" column="3"> <item row="8" column="3">
<widget class="QToolButton" name="downloadAntToolButton"> <widget class="QToolButton" name="downloadAntToolButton">
...@@ -446,13 +418,21 @@ ...@@ -446,13 +418,21 @@
</item> </item>
</layout> </layout>
</widget> </widget>
<customwidgets>
<customwidget>
<class>Utils::PathChooser</class>
<extends>QWidget</extends>
<header location="global">utils/pathchooser.h</header>
<container>1</container>
</customwidget>
</customwidgets>
<resources> <resources>
<include location="android.qrc"/> <include location="android.qrc"/>
</resources> </resources>
<connections> <connections>
<connection> <connection>
<sender>NDKLocationLineEdit</sender> <sender>NDKLocationPathChooser</sender>
<signal>editingFinished()</signal> <signal>changed(QString)</signal>
<receiver>AndroidSettingsWidget</receiver> <receiver>AndroidSettingsWidget</receiver>
<slot>ndkLocationEditingFinished()</slot> <slot>ndkLocationEditingFinished()</slot>
<hints> <hints>
...@@ -467,24 +447,8 @@ ...@@ -467,24 +447,8 @@
</hints> </hints>
</connection> </connection>
<connection> <connection>
<sender>NDKLocationPushButton</sender> <sender>SDKLocationPathChooser</sender>
<signal>clicked()</signal> <signal>changed(QString)</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>
<receiver>AndroidSettingsWidget</receiver> <receiver>AndroidSettingsWidget</receiver>
<slot>sdkLocationEditingFinished()</slot> <slot>sdkLocationEditingFinished()</slot>
<hints> <hints>
...@@ -499,24 +463,8 @@ ...@@ -499,24 +463,8 @@
</hints> </hints>
</connection> </connection>
<connection> <connection>
<sender>SDKLocationPushButton</sender> <sender>AntLocationPathChooser</sender>
<signal>clicked()</signal> <signal>changed(QString)</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>
<receiver>AndroidSettingsWidget</receiver> <receiver>AndroidSettingsWidget</receiver>
<slot>antLocationEditingFinished()</slot> <slot>antLocationEditingFinished()</slot>
<hints> <hints>
...@@ -531,24 +479,8 @@ ...@@ -531,24 +479,8 @@
</hints> </hints>
</connection> </connection>
<connection> <connection>
<sender>AntLocationPushButton</sender> <sender>OpenJDKLocationPathChooser</sender>
<signal>clicked()</signal> <signal>changed(QString)</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>
<receiver>AndroidSettingsWidget</receiver> <receiver>AndroidSettingsWidget</receiver>
<slot>openJDKLocationEditingFinished()</slot> <slot>openJDKLocationEditingFinished()</slot>
<hints> <hints>
...@@ -562,22 +494,6 @@ ...@@ -562,22 +494,6 @@
</hint> </hint>
</hints> </hints>
</connection> </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> <connection>
<sender>AVDAddPushButton</sender> <sender>AVDAddPushButton</sender>
<signal>clicked()</signal> <signal>clicked()</signal>
...@@ -734,17 +650,13 @@ ...@@ -734,17 +650,13 @@
<slots> <slots>
<slot>sdkLocationEditingFinished()</slot> <slot>sdkLocationEditingFinished()</slot>
<slot>ndkLocationEditingFinished()</slot> <slot>ndkLocationEditingFinished()</slot>
<slot>browseSDKLocation()</slot>
<slot>browseNDKLocation()</slot>
<slot>antLocationEditingFinished()</slot> <slot>antLocationEditingFinished()</slot>
<slot>browseAntLocation()</slot>
<slot>addAVD()</slot> <slot>addAVD()</slot>
<slot>removeAVD()</slot> <slot>removeAVD()</slot>
<slot>startAVD()</slot> <slot>startAVD()</slot>
<slot>avdActivated(QModelIndex)</slot> <slot>avdActivated(QModelIndex)</slot>
<slot>dataPartitionSizeEditingFinished()</slot> <slot>dataPartitionSizeEditingFinished()</slot>
<slot>openJDKLocationEditingFinished()</slot> <slot>openJDKLocationEditingFinished()</slot>
<slot>browseOpenJDKLocation()</slot>
<slot>manageAVD()</slot> <slot>manageAVD()</slot>
<slot>createKitToggled()</slot> <slot>createKitToggled()</slot>
<slot>openSDKDownloadUrl()</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