From 0e79aeed710311e28c45456f4f8ea5e66eec21b1 Mon Sep 17 00:00:00 2001 From: Tobias Hunger <tobias.hunger@nokia.com> Date: Tue, 13 Apr 2010 12:44:26 +0200 Subject: [PATCH] Rework targetsetuppage interface slightly * Remove PathChooser widget so that you need to use a proper dialog to select pathes. So typing into that PathChooser is no longer slow;-) The PathChooser does not provide a proper signal on when a user is done entering a directory, so it was not a good choice. Tasknumber: QTCREATORBUG-1128 Reviewed-by: dt --- .../wizards/targetsetuppage.cpp | 43 +++++++++---------- .../wizards/targetsetuppage.h | 11 ++--- 2 files changed, 25 insertions(+), 29 deletions(-) diff --git a/src/plugins/qt4projectmanager/wizards/targetsetuppage.cpp b/src/plugins/qt4projectmanager/wizards/targetsetuppage.cpp index f23f77507ef..0af98ae28bc 100644 --- a/src/plugins/qt4projectmanager/wizards/targetsetuppage.cpp +++ b/src/plugins/qt4projectmanager/wizards/targetsetuppage.cpp @@ -33,11 +33,11 @@ #include "qt4projectmanagerconstants.h" #include "qt4target.h" -#include <utils/pathchooser.h> - +#include <QtGui/QFileDialog> #include <QtGui/QHeaderView> #include <QtGui/QLabel> #include <QtGui/QLayout> +#include <QtGui/QPushButton> #include <QtGui/QTreeWidget> using namespace Qt4ProjectManager::Internal; @@ -64,19 +64,11 @@ TargetSetupPage::TargetSetupPage(QWidget *parent) : m_treeWidget->setHeaderLabels(QStringList() << tr("Qt Version") << tr("Status") << tr("Directory")); vbox->addWidget(m_treeWidget); - QHBoxLayout *hbox = new QHBoxLayout; - m_directoryLabel = new QLabel(this); - m_directoryLabel->setText(tr("Scan for builds")); - hbox->addWidget(m_directoryLabel); - - m_directoryChooser = new Utils::PathChooser(this); - m_directoryChooser->setPromptDialogTitle(tr("Directory to import builds from")); - m_directoryChooser->setExpectedKind(Utils::PathChooser::Directory); - hbox->addWidget(m_directoryChooser); - vbox->addLayout(hbox); + m_addDirectoryButton = new QPushButton(tr("Add shadow build location")); + vbox->addWidget(m_addDirectoryButton); - connect(m_directoryChooser, SIGNAL(changed(QString)), - this, SLOT(importDirectoryAdded(QString))); + connect(m_addDirectoryButton, SIGNAL(clicked()), + this, SLOT(addShadowBuildLocation())); } TargetSetupPage::~TargetSetupPage() @@ -263,14 +255,13 @@ bool TargetSetupPage::isComplete() const void TargetSetupPage::setImportDirectoryBrowsingEnabled(bool browsing) { - m_directoryChooser->setEnabled(browsing); - m_directoryChooser->setVisible(browsing); - m_directoryLabel->setVisible(browsing); + m_addDirectoryButton->setEnabled(browsing); + m_addDirectoryButton->setVisible(browsing); } void TargetSetupPage::setImportDirectoryBrowsingLocation(const QString &directory) { - m_directoryChooser->setInitialBrowsePathBackup(directory); + m_defaultShadowBuildLocation = directory; } void TargetSetupPage::setShowLocationInformation(bool location) @@ -383,15 +374,23 @@ TargetSetupPage::recursivelyCheckDirectoryForBuild(const QString &directory, con return results; } -void TargetSetupPage::importDirectoryAdded(const QString &directory) +void TargetSetupPage::addShadowBuildLocation() { - QFileInfo dir(directory); + QString newPath = + QFileDialog::getExistingDirectory(this, + tr("Choose a directory to scan for additional shadow builds"), + m_defaultShadowBuildLocation); + + if (newPath.isEmpty()) + return; + + QFileInfo dir(QDir::fromNativeSeparators(newPath)); if (!dir.exists() || !dir.isDir()) return; - m_directoryChooser->setPath(QString()); + QList<ImportInfo> tmp = m_infos; m_infos.clear(); // Clear m_infos without deleting temporary QtVersions! - tmp.append(recursivelyCheckDirectoryForBuild(directory, m_proFilePath)); + tmp.append(recursivelyCheckDirectoryForBuild(dir.absoluteFilePath(), m_proFilePath)); setImportInfos(tmp); } diff --git a/src/plugins/qt4projectmanager/wizards/targetsetuppage.h b/src/plugins/qt4projectmanager/wizards/targetsetuppage.h index 9cd23791aee..9c846e101de 100644 --- a/src/plugins/qt4projectmanager/wizards/targetsetuppage.h +++ b/src/plugins/qt4projectmanager/wizards/targetsetuppage.h @@ -40,13 +40,10 @@ QT_BEGIN_NAMESPACE class QLabel; +class QPushButton; class QTreeWidget; QT_END_NAMESPACE -namespace Utils { -class PathChooser; -} - namespace Qt4ProjectManager { class Qt4Project; @@ -112,17 +109,17 @@ public: private slots: void itemWasChanged(); - void importDirectoryAdded(const QString &); + void addShadowBuildLocation(); private: void resetInfos(); QList<ImportInfo> m_infos; QTreeWidget *m_treeWidget; - Utils::PathChooser *m_directoryChooser; - QLabel *m_directoryLabel; + QPushButton *m_addDirectoryButton; bool m_preferMobile; QString m_proFilePath; + QString m_defaultShadowBuildLocation; }; } // namespace Internal -- GitLab