From e077b2338e046e92db86489c81372cfaafc91e48 Mon Sep 17 00:00:00 2001 From: Rafael Roquetto Date: Fri, 5 Apr 2013 09:46:47 -0300 Subject: [PATCH] BlackBerry: set default path for debug token request MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Task-number: QTCREATORBUG-9077 Change-Id: I5b969077a679cdc4da667fbbfcabd0bd6fa75fb9 Reviewed-by: Laszlo Papp Reviewed-by: Mehdi Fekari Reviewed-by: Nicolas Arnaud-Cormos Reviewed-by: Tobias Nätterlund --- .../qnx/blackberrydebugtokenrequestdialog.cpp | 37 ++++++++++++++++++- .../qnx/blackberrydebugtokenrequestdialog.h | 2 + 2 files changed, 38 insertions(+), 1 deletion(-) diff --git a/src/plugins/qnx/blackberrydebugtokenrequestdialog.cpp b/src/plugins/qnx/blackberrydebugtokenrequestdialog.cpp index 955ed226d43..22b60051b28 100644 --- a/src/plugins/qnx/blackberrydebugtokenrequestdialog.cpp +++ b/src/plugins/qnx/blackberrydebugtokenrequestdialog.cpp @@ -51,7 +51,7 @@ BlackBerryDebugTokenRequestDialog::BlackBerryDebugTokenRequestDialog( m_ui->setupUi(this); m_ui->progressBar->hide(); m_ui->status->clear(); - m_ui->debugTokenPath->setExpectedKind(Utils::PathChooser::Any); + m_ui->debugTokenPath->setExpectedKind(Utils::PathChooser::SaveFile); m_ui->debugTokenPath->setPromptDialogTitle(tr("Request Debug Token")); m_ui->debugTokenPath->setPromptDialogFilter(tr("BAR Files (*.bar)")); @@ -67,8 +67,12 @@ BlackBerryDebugTokenRequestDialog::BlackBerryDebugTokenRequestDialog( this, SLOT(requestDebugToken())); connect(m_ui->debugTokenPath, SIGNAL(changed(QString)), this, SLOT(validate())); + connect(m_ui->debugTokenPath, SIGNAL(beforeBrowsing()), + this, SLOT(setDefaultPath())); connect(m_ui->debugTokenPath, SIGNAL(editingFinished()), this, SLOT(appendExtension())); + connect(m_ui->debugTokenPath, SIGNAL(editingFinished()), + this, SLOT(expandPath())); connect(m_ui->keystorePassword, SIGNAL(textChanged(QString)), this, SLOT(validate())); connect(m_ui->cskPassword, SIGNAL(textChanged(QString)), @@ -133,16 +137,47 @@ void BlackBerryDebugTokenRequestDialog::requestDebugToken() m_ui->keystorePassword->text(), m_ui->devicePin->text()); } +void BlackBerryDebugTokenRequestDialog::setDefaultPath() +{ + const QString path = m_ui->debugTokenPath->path(); + const QString defaultFileName = QLatin1String("/debugToken.bar"); + + if (path.isEmpty()) { + m_ui->debugTokenPath->setPath(QDir::homePath() + defaultFileName); + return; + } + + const QFileInfo fileInfo(path); + + if (fileInfo.isDir()) + m_ui->debugTokenPath->setPath(path + defaultFileName); +} + void BlackBerryDebugTokenRequestDialog::appendExtension() { QString path = m_ui->debugTokenPath->path(); + if (path.isEmpty()) + return; + if (!path.endsWith(QLatin1String(".bar"))) { path += QLatin1String(".bar"); m_ui->debugTokenPath->setPath(path); } } +void BlackBerryDebugTokenRequestDialog::expandPath() +{ + const QString path = m_ui->debugTokenPath->path(); + + if (path.isEmpty() || path.startsWith(QLatin1String("/"))) + return; + + const QFileInfo fileInfo(path); + + m_ui->debugTokenPath->setPath(fileInfo.absoluteFilePath()); +} + void BlackBerryDebugTokenRequestDialog::checkBoxChanged(int state) { if (state == Qt::Checked) { diff --git a/src/plugins/qnx/blackberrydebugtokenrequestdialog.h b/src/plugins/qnx/blackberrydebugtokenrequestdialog.h index e31a1fd8885..e70f56d528b 100644 --- a/src/plugins/qnx/blackberrydebugtokenrequestdialog.h +++ b/src/plugins/qnx/blackberrydebugtokenrequestdialog.h @@ -57,7 +57,9 @@ public: private slots: void validate(); void requestDebugToken(); + void setDefaultPath(); void appendExtension(); + void expandPath(); void checkBoxChanged(int state); void debugTokenArrived(int status);