diff --git a/share/qtcreator/templates/wizards/bb-qt5-bardescriptor/bar-descriptor.xml b/share/qtcreator/templates/wizards/bb-qt5-bardescriptor/bar-descriptor.xml index 4b2a41577a5..421dfa82f82 100644 --- a/share/qtcreator/templates/wizards/bb-qt5-bardescriptor/bar-descriptor.xml +++ b/share/qtcreator/templates/wizards/bb-qt5-bardescriptor/bar-descriptor.xml @@ -24,19 +24,4 @@ run_native PROJECTNAME - - - lib - plugins - imports - - diff --git a/src/plugins/qnx/blackberrycreatepackagestep.cpp b/src/plugins/qnx/blackberrycreatepackagestep.cpp index 440388556d1..ee1c6d6236c 100644 --- a/src/plugins/qnx/blackberrycreatepackagestep.cpp +++ b/src/plugins/qnx/blackberrycreatepackagestep.cpp @@ -35,6 +35,7 @@ #include "blackberrycreatepackagestepconfigwidget.h" #include "blackberrydeployconfiguration.h" #include "qnxutils.h" +#include "bardescriptordocument.h" #include "blackberryqtversion.h" #include "blackberrydeviceconfiguration.h" #include "blackberrydeployinformation.h" @@ -61,6 +62,8 @@ const char PACKAGE_MODE_KEY[] = "Qt4ProjectManager.BlackBerryCreatePackageS const char CSK_PASSWORD_KEY[] = "Qt4ProjectManager.BlackBerryCreatePackageStep.CskPassword"; const char KEYSTORE_PASSWORD_KEY[] = "Qt4ProjectManager.BlackBerryCreatePackageStep.KeystorePassword"; const char SAVE_PASSWORDS_KEY[] = "Qt4ProjectManager.BlackBerryCreatePackageStep.SavePasswords"; +const char BUNDLE_MODE_KEY[] = "Qt4ProjectManager.BlackBerryCreatePackageStep.BundleMode"; +const char QT_LIBRARY_PATH_KEY[] = "Qt4ProjectManager.BlackBerryCreatePackageStep.QtLibraryPath"; } BlackBerryCreatePackageStep::BlackBerryCreatePackageStep(ProjectExplorer::BuildStepList *bsl) @@ -81,6 +84,8 @@ void BlackBerryCreatePackageStep::ctor() setDisplayName(tr("Create packages")); m_packageMode = DevelopmentMode; + m_bundleMode = PreInstalledQt; + m_qtLibraryPath = QLatin1String("qt"); } bool BlackBerryCreatePackageStep::init() @@ -159,6 +164,40 @@ bool BlackBerryCreatePackageStep::init() } args << QLatin1String("-package") << QnxUtils::addQuotes(QDir::toNativeSeparators(info.packagePath())); args << QnxUtils::addQuotes(QDir::toNativeSeparators(preparedFilePath)); + + if (m_packageMode == DevelopmentMode && m_bundleMode == BundleQt) { + BlackBerryQtVersion *qtVersion = dynamic_cast + (QtSupport::QtKitInformation::qtVersion(target()->kit())); + if (!qtVersion) { + raiseError(tr("Qt version configured for BlackBerry kit " + "is not a BlackBerry Qt version")); + return false; + } + + QMap qtFolders; + qtFolders[QLatin1String("lib")] = + qtVersion->versionInfo().value(QLatin1String("QT_INSTALL_LIBS")); + qtFolders[QLatin1String("plugins")] = + qtVersion->versionInfo().value(QLatin1String("QT_INSTALL_PLUGINS")); + qtFolders[QLatin1String("imports")] = + qtVersion->versionInfo().value(QLatin1String("QT_INSTALL_IMPORTS")); + qtFolders[QLatin1String("qml")] = + qtVersion->versionInfo().value(QLatin1String("QT_INSTALL_QML")); + + for (QMap::const_iterator it = qtFolders.constBegin(); + it != qtFolders.constEnd(); ++it) { + const QString target = it.key(); + const QString qtFolder = it.value(); + if (QFileInfo(qtFolder).exists()) { + args << QLatin1String("-e"); + args << qtFolder; + args << target; + } + } + + args << QLatin1String("."); + } + addCommand(packageCmd, args); } @@ -181,12 +220,17 @@ QString BlackBerryCreatePackageStep::debugToken() const bool BlackBerryCreatePackageStep::fromMap(const QVariantMap &map) { - m_packageMode = static_cast(map.value(QLatin1String(PACKAGE_MODE_KEY), DevelopmentMode).toInt()); + m_packageMode = static_cast(map.value(QLatin1String(PACKAGE_MODE_KEY), + DevelopmentMode).toInt()); m_savePasswords = map.value(QLatin1String(SAVE_PASSWORDS_KEY), false).toBool(); if (m_savePasswords) { m_cskPassword = map.value(QLatin1String(CSK_PASSWORD_KEY)).toString(); m_keystorePassword = map.value(QLatin1String(KEYSTORE_PASSWORD_KEY)).toString(); } + m_bundleMode = static_cast(map.value(QLatin1String(BUNDLE_MODE_KEY), + PreInstalledQt).toInt()); + m_qtLibraryPath = map.value(QLatin1String(QT_LIBRARY_PATH_KEY), + QLatin1String("qt")).toString(); return BlackBerryAbstractDeployStep::fromMap(map); } @@ -199,6 +243,8 @@ QVariantMap BlackBerryCreatePackageStep::toMap() const map.insert(QLatin1String(CSK_PASSWORD_KEY), m_cskPassword); map.insert(QLatin1String(KEYSTORE_PASSWORD_KEY), m_keystorePassword); } + map.insert(QLatin1String(BUNDLE_MODE_KEY), m_bundleMode); + map.insert(QLatin1String(QT_LIBRARY_PATH_KEY), m_qtLibraryPath); return map; } @@ -222,6 +268,21 @@ bool BlackBerryCreatePackageStep::savePasswords() const return m_savePasswords; } +BlackBerryCreatePackageStep::BundleMode BlackBerryCreatePackageStep::bundleMode() const +{ + return m_bundleMode; +} + +QString BlackBerryCreatePackageStep::qtLibraryPath() const +{ + return m_qtLibraryPath; +} + +QString BlackBerryCreatePackageStep::fullQtLibraryPath() const +{ + return QLatin1String(Constants::QNX_BLACKBERRY_DEFAULT_DEPLOY_QT_BASEPATH) + m_qtLibraryPath; +} + void BlackBerryCreatePackageStep::setPackageMode(BlackBerryCreatePackageStep::PackageMode packageMode) { m_packageMode = packageMode; @@ -242,11 +303,14 @@ void BlackBerryCreatePackageStep::setSavePasswords(bool savePasswords) m_savePasswords = savePasswords; } -static void addQtInfoPlaceHolderToHash(QHash &hash, - const BlackBerryQtVersion *qtVersion, const char *key) +void BlackBerryCreatePackageStep::setBundleMode(BlackBerryCreatePackageStep::BundleMode bundleMode) { - hash[QLatin1Char('%') + QString::fromLatin1(key) + QLatin1Char('%')] = - qtVersion->versionInfo().value(QLatin1String(key)); + m_bundleMode = bundleMode; +} + +void BlackBerryCreatePackageStep::setQtLibraryPath(const QString &qtLibraryPath) +{ + m_qtLibraryPath = qtLibraryPath; } bool BlackBerryCreatePackageStep::prepareAppDescriptorFile(const QString &appDescriptorPath, const QString &preparedFilePath) @@ -270,42 +334,66 @@ bool BlackBerryCreatePackageStep::prepareAppDescriptorFile(const QString &appDes " any changes will get overwritten if deploying with Qt Creator"); doc.setBannerComment(warningText); - // Replace Qt path placeholders - QHash placeHoldersHash; - addQtInfoPlaceHolderToHash(placeHoldersHash, qtVersion, "QT_INSTALL_LIBS"); - addQtInfoPlaceHolderToHash(placeHoldersHash, qtVersion, "QT_INSTALL_PLUGINS"); - addQtInfoPlaceHolderToHash(placeHoldersHash, qtVersion, "QT_INSTALL_IMPORTS"); - addQtInfoPlaceHolderToHash(placeHoldersHash, qtVersion, "QT_INSTALL_QML"); //Replace Source path placeholder + QHash placeHoldersHash; placeHoldersHash[QLatin1String("%SRC_DIR%")] = QDir::toNativeSeparators(target()->project()->projectDirectory()); doc.expandPlaceHolders(placeHoldersHash); - QStringList commandLineArguments = doc.value(BarDescriptorDocument::arg).toStringList(); - QStringList extraCommandLineArguments; - // Add parameter for QML debugging (if enabled) Debugger::DebuggerRunConfigurationAspect *aspect = target()->activeRunConfiguration()->extraAspect(); if (aspect->useQmlDebugger()) { - bool qmljsdebuggerExists = false; - foreach (const QString &s, commandLineArguments) { - if (s.startsWith(QLatin1String("-qmljsdebugger="))) { - qmljsdebuggerExists = true; - break; - } - } - if (!qmljsdebuggerExists) { - extraCommandLineArguments << QString::fromLatin1("-qmljsdebugger=port:%1") + const QString qmlDebuggerArg = QString::fromLatin1("-qmljsdebugger=port:%1") .arg(aspect->qmlDebugServerPort()); - } + + QStringList args = doc.value(BarDescriptorDocument::arg).toStringList(); + if (!args.contains(qmlDebuggerArg)) + args.append(qmlDebuggerArg); + + doc.setValue(BarDescriptorDocument::arg, args); } - if (extraCommandLineArguments.count()) { - commandLineArguments << extraCommandLineArguments; - doc.setValue(BarDescriptorDocument::arg, commandLineArguments); + // Set up correct environment depending on using bundled/pre-installed Qt + QList envItems = + doc.value(BarDescriptorDocument::env).value >(); + Utils::Environment env(Utils::EnvironmentItem::toStringList(envItems), Utils::OsTypeOtherUnix); + + if (m_packageMode == SigningPackageMode + || (m_packageMode == DevelopmentMode && m_bundleMode == PreInstalledQt)) { + QtSupport::QtVersionNumber versionNumber = qtVersion->qtVersion(); + env.appendOrSet(QLatin1String("QML_IMPORT_PATH"), + QString::fromLatin1("/usr/lib/qt%1/imports").arg(versionNumber.majorVersion), + QLatin1String(":")); + env.appendOrSet(QLatin1String("QT_PLUGIN_PATH"), + QString::fromLatin1("/usr/lib/qt%1/plugins").arg(versionNumber.majorVersion), + QLatin1String(":")); + env.prependOrSetLibrarySearchPath(QString::fromLatin1("/usr/lib/qt%1/lib") + .arg(versionNumber.majorVersion)); + } else if (m_packageMode == DevelopmentMode && m_bundleMode == BundleQt) { + env.appendOrSet(QLatin1String("QML2_IMPORT_PATH"), + QLatin1String("app/native/imports:app/native/qml"), QLatin1String(":")); + env.appendOrSet(QLatin1String("QML_IMPORT_PATH"), + QLatin1String("app/native/imports:app/native/qml"), QLatin1String(":")); + env.appendOrSet(QLatin1String("QT_PLUGIN_PATH"), + QLatin1String("app/native/plugins"), QLatin1String(":")); + env.prependOrSetLibrarySearchPath(QLatin1String("app/native/lib")); + } else if (m_packageMode == DevelopmentMode && m_bundleMode == DeployedQt) { + env.appendOrSet(QLatin1String("QML2_IMPORT_PATH"), + QString::fromLatin1("%1/qml:%1/imports").arg(fullQtLibraryPath()), + QLatin1String(":")); + env.appendOrSet(QLatin1String("QML_IMPORT_PATH"), + QString::fromLatin1("%1/qml:%1/imports").arg(fullQtLibraryPath()), + QLatin1String(":")); + env.appendOrSet(QLatin1String("QT_PLUGIN_PATH"), + QString::fromLatin1("%1/plugins").arg(fullQtLibraryPath()), QLatin1String(":")); + env.prependOrSetLibrarySearchPath(QString::fromLatin1("%1/lib").arg(fullQtLibraryPath())); } + QVariant envVar; + envVar.setValue(Utils::EnvironmentItem::fromStringList(env.toStringList())); + doc.setValue(BarDescriptorDocument::env, envVar); + doc.setFilePath(preparedFilePath); if (!doc.save(&errorString)) { raiseError(tr("Error saving prepared application descriptor file '%1' - %2") diff --git a/src/plugins/qnx/blackberrycreatepackagestep.h b/src/plugins/qnx/blackberrycreatepackagestep.h index c9b8521dc67..40d0618e8f5 100644 --- a/src/plugins/qnx/blackberrycreatepackagestep.h +++ b/src/plugins/qnx/blackberrycreatepackagestep.h @@ -52,6 +52,12 @@ public: DevelopmentMode }; + enum BundleMode { + PreInstalledQt, + BundleQt, + DeployedQt + }; + explicit BlackBerryCreatePackageStep(ProjectExplorer::BuildStepList *bsl); bool init(); @@ -67,12 +73,18 @@ public: QString keystorePassword() const; bool savePasswords() const; + BundleMode bundleMode() const; + QString qtLibraryPath() const; + public slots: void setPackageMode(PackageMode packageMode); void setCskPassword(const QString &cskPassword); void setKeystorePassword(const QString &keystorePassword); void setSavePasswords(bool savePasswords); + void setBundleMode(BundleMode bundleMode); + void setQtLibraryPath(const QString &qtLibraryPath); + signals: void cskPasswordChanged(QString); void keystorePasswordChanged(QString); @@ -86,11 +98,14 @@ private: void ctor(); bool prepareAppDescriptorFile(const QString &appDescriptorPath, const QString &preparedFilePath); + QString fullQtLibraryPath() const; PackageMode m_packageMode; QString m_cskPassword; QString m_keystorePassword; bool m_savePasswords; + BundleMode m_bundleMode; + QString m_qtLibraryPath; }; } // namespace Internal diff --git a/src/plugins/qnx/blackberrycreatepackagestepconfigwidget.cpp b/src/plugins/qnx/blackberrycreatepackagestepconfigwidget.cpp index 1970dc2ec55..e1663eaa3d7 100644 --- a/src/plugins/qnx/blackberrycreatepackagestepconfigwidget.cpp +++ b/src/plugins/qnx/blackberrycreatepackagestepconfigwidget.cpp @@ -32,6 +32,12 @@ #include "blackberrycreatepackagestepconfigwidget.h" #include "ui_blackberrycreatepackagestepconfigwidget.h" #include "blackberrycreatepackagestep.h" +#include "blackberrydeployqtlibrariesdialog.h" + +#include +#include +#include +#include using namespace Qnx; using namespace Qnx::Internal; @@ -43,22 +49,46 @@ BlackBerryCreatePackageStepConfigWidget::BlackBerryCreatePackageStepConfigWidget m_ui = new Ui::BlackBerryCreatePackageStepConfigWidget; m_ui->setupUi(this); - m_ui->signPackages->setChecked(m_step->packageMode() == BlackBerryCreatePackageStep::SigningPackageMode); - m_ui->developmentMode->setChecked(m_step->packageMode() == BlackBerryCreatePackageStep::DevelopmentMode); - m_ui->cskPassword->setText(m_step->cskPassword()); m_ui->keystorePassword->setText(m_step->keystorePassword()); m_ui->savePasswords->setChecked(m_step->savePasswords()); + m_ui->qtLibraryPath->setText(m_step->qtLibraryPath()); + + m_qtLibraryExplanations[0] = tr("Use the Qt libraries shipped with the BlackBerry device."); + m_qtLibraryExplanations[1] = tr("Include Qt libraries in the package. " + "This will increase the package size."); + m_qtLibraryExplanations[2] = tr("Use deployed Qt libraries on the device."); + m_ui->qtLibrary->addItem(tr("Use pre-installed Qt"), BlackBerryCreatePackageStep::PreInstalledQt); + m_ui->qtLibrary->addItem(tr("Bundle Qt in package"), BlackBerryCreatePackageStep::BundleQt); + m_ui->qtLibrary->addItem(tr("Use deployed Qt"), BlackBerryCreatePackageStep::DeployedQt); connect(m_ui->signPackages, SIGNAL(toggled(bool)), this, SLOT(setPackageMode(bool))); connect(m_ui->cskPassword, SIGNAL(textChanged(QString)), m_step, SLOT(setCskPassword(QString))); - connect(m_ui->keystorePassword, SIGNAL(textChanged(QString)), m_step, SLOT(setKeystorePassword(QString))); + connect(m_ui->keystorePassword, SIGNAL(textChanged(QString)), + m_step, SLOT(setKeystorePassword(QString))); connect(m_ui->showPasswords, SIGNAL(toggled(bool)), this, SLOT(showPasswords(bool))); connect(m_ui->savePasswords, SIGNAL(toggled(bool)), m_step, SLOT(setSavePasswords(bool))); - connect(m_step, SIGNAL(cskPasswordChanged(QString)), m_ui->cskPassword, SLOT(setText(QString))); - connect(m_step, SIGNAL(keystorePasswordChanged(QString)), m_ui->keystorePassword, SLOT(setText(QString))); + connect(m_ui->qtLibrary, SIGNAL(currentIndexChanged(int)), this, SLOT(setBundleMode(int))); + connect(m_ui->qtLibrary, SIGNAL(currentIndexChanged(int)), this, SLOT(updateDeployWidgetsState())); + connect(m_ui->qtLibraryPath, SIGNAL(textChanged(QString)), + m_step, SLOT(setQtLibraryPath(QString))); + connect(m_ui->qtLibraryPath, SIGNAL(textChanged(QString)), + this, SLOT(updateDeployWidgetsState())); + connect(m_ui->deployNowButton, SIGNAL(clicked()), this, SLOT(deployLibraries())); + connect(ProjectExplorer::KitManager::instance(), SIGNAL(kitsChanged()), this, SLOT(updateDeployWidgetsState())); - m_ui->signPackagesWidget->setEnabled(m_ui->signPackages->isChecked()); + connect(m_step, SIGNAL(cskPasswordChanged(QString)), m_ui->cskPassword, SLOT(setText(QString))); + connect(m_step, SIGNAL(keystorePasswordChanged(QString)), + m_ui->keystorePassword, SLOT(setText(QString))); + + m_ui->signPackages->setChecked(m_step->packageMode() == + BlackBerryCreatePackageStep::SigningPackageMode); + m_ui->developmentMode->setChecked(m_step->packageMode() == + BlackBerryCreatePackageStep::DevelopmentMode); + + m_ui->qtLibrary->setCurrentIndex(m_ui->qtLibrary->findData(m_step->bundleMode())); + setBundleMode(m_step->bundleMode()); + updateDeployWidgetsState(); } BlackBerryCreatePackageStepConfigWidget::~BlackBerryCreatePackageStepConfigWidget() @@ -92,3 +122,48 @@ void BlackBerryCreatePackageStepConfigWidget::showPasswords(bool show) m_ui->cskPassword->setEchoMode(show ? QLineEdit::Normal : QLineEdit::Password); m_ui->keystorePassword->setEchoMode(show ? QLineEdit::Normal : QLineEdit::Password); } + +void BlackBerryCreatePackageStepConfigWidget::setBundleMode(int qtLibraryIndex) +{ + QTC_ASSERT(m_qtLibraryExplanations.contains(qtLibraryIndex), return); + + BlackBerryCreatePackageStep::BundleMode bundleMode = + static_cast( + m_ui->qtLibrary->itemData(qtLibraryIndex).toInt()); + + m_step->setBundleMode(bundleMode); + m_ui->qtLibraryExplanationLabel->setText(m_qtLibraryExplanations[qtLibraryIndex]); + m_ui->qtLibraryPath->setVisible(bundleMode == BlackBerryCreatePackageStep::DeployedQt); + m_ui->qtLibraryLabel->setVisible(bundleMode == BlackBerryCreatePackageStep::DeployedQt); +} + +void BlackBerryCreatePackageStepConfigWidget::updateDeployWidgetsState() +{ + BlackBerryCreatePackageStep::BundleMode bundleMode = + static_cast( + m_ui->qtLibrary->itemData(m_ui->qtLibrary->currentIndex()).toInt()); + + ProjectExplorer::Kit *kit = m_step->target()->kit(); + ProjectExplorer::IDevice::ConstPtr device = ProjectExplorer::DeviceKitInformation::device(kit); + + const bool enableButton = !m_ui->qtLibraryPath->text().isEmpty() + && bundleMode == BlackBerryCreatePackageStep::DeployedQt + && !device.isNull(); + const bool visibleButton = bundleMode == BlackBerryCreatePackageStep::DeployedQt; + const bool visibleLabels = bundleMode == BlackBerryCreatePackageStep::DeployedQt + && device.isNull(); + + m_ui->deployNowButton->setEnabled(enableButton); + m_ui->deployNowButton->setVisible(visibleButton); + + m_ui->deployErrorPixmap->setVisible(visibleLabels); + m_ui->deployErrorLabel->setVisible(visibleLabels); +} + +void BlackBerryCreatePackageStepConfigWidget::deployLibraries() +{ + ProjectExplorer::Kit *kit = m_step->target()->kit(); + BlackBerryDeployQtLibrariesDialog dlg(ProjectExplorer::DeviceKitInformation::device(kit), + this); + dlg.execAndDeploy(QtSupport::QtKitInformation::qtVersionId(kit), m_ui->qtLibraryPath->text()); +} diff --git a/src/plugins/qnx/blackberrycreatepackagestepconfigwidget.h b/src/plugins/qnx/blackberrycreatepackagestepconfigwidget.h index e7d3a74da3a..66e8d1aa1f6 100644 --- a/src/plugins/qnx/blackberrycreatepackagestepconfigwidget.h +++ b/src/plugins/qnx/blackberrycreatepackagestepconfigwidget.h @@ -56,10 +56,15 @@ public: private slots: void setPackageMode(bool signPackagesChecked); void showPasswords(bool show); + void setBundleMode(int qtLibraryIndex); + void updateDeployWidgetsState(); + void deployLibraries(); private: BlackBerryCreatePackageStep *m_step; Ui::BlackBerryCreatePackageStepConfigWidget *m_ui; + + QMap m_qtLibraryExplanations; }; } // namespace Internal diff --git a/src/plugins/qnx/blackberrycreatepackagestepconfigwidget.ui b/src/plugins/qnx/blackberrycreatepackagestepconfigwidget.ui index 6c3f214152c..ae89b80c949 100644 --- a/src/plugins/qnx/blackberrycreatepackagestepconfigwidget.ui +++ b/src/plugins/qnx/blackberrycreatepackagestepconfigwidget.ui @@ -6,8 +6,8 @@ 0 0 - 803 - 135 + 613 + 204 @@ -24,7 +24,16 @@ - + + 0 + + + 0 + + + 0 + + 0 @@ -115,9 +124,109 @@ + + + + + 0 + + + 0 + + + 0 + + + 0 + + + + + Qt::Horizontal + + + QSizePolicy::Fixed + + + + 20 + 20 + + + + + + + + + + + 0 + + + + + /accounts/devuser/ + + + + + + + + + + + + Deploy now + + + + + + + + + + :/projectexplorer/images/compile_warning.png + + + + + + + No device configured, cannot deploy. + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + + + + + + + - + + + signPackages @@ -135,5 +244,53 @@ + + developmentMode + toggled(bool) + developmentModeWidget + setEnabled(bool) + + + 44 + 129 + + + 22 + 169 + + + + + signPackages + toggled(bool) + developmentModeWidget + setDisabled(bool) + + + 66 + 16 + + + 115 + 174 + + + + + developmentMode + toggled(bool) + signPackagesWidget + setDisabled(bool) + + + 69 + 132 + + + 338 + 97 + + + diff --git a/src/plugins/qnx/blackberrydeployqtlibrariesdialog.cpp b/src/plugins/qnx/blackberrydeployqtlibrariesdialog.cpp new file mode 100644 index 00000000000..c29c3affa3a --- /dev/null +++ b/src/plugins/qnx/blackberrydeployqtlibrariesdialog.cpp @@ -0,0 +1,295 @@ +/************************************************************************** +** +** Copyright (C) 2014 BlackBerry Limited. All rights reserved. +** +** Contact: BlackBerry (qt@blackberry.com) +** Contact: KDAB (info@kdab.com) +** +** This file is part of Qt Creator. +** +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and Digia. For licensing terms and +** conditions see http://qt.digia.com/licensing. For further information +** use the contact form at http://qt.digia.com/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Digia gives you certain additional +** rights. These rights are described in the Digia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +****************************************************************************/ + +#include "blackberrydeployqtlibrariesdialog.h" +#include "ui_blackberrydeployqtlibrariesdialog.h" + +#include "blackberryqtversion.h" + +#include +#include +#include +#include +#include + +#include +#include + +using namespace Qnx; +using namespace Qnx::Internal; + +BlackBerryDeployQtLibrariesDialog::BlackBerryDeployQtLibrariesDialog( + const ProjectExplorer::IDevice::ConstPtr &device, QWidget *parent) + : QDialog(parent) + , m_ui(new Ui::BlackBerryDeployQtLibrariesDialog) + , m_device(device) + , m_progressCount(0) + , m_state(Inactive) +{ + m_ui->setupUi(this); + + QList qtVersions = QtSupport::QtVersionManager::validVersions(); + foreach (QtSupport::BaseQtVersion *qtVersion, qtVersions) { + BlackBerryQtVersion *blackBerryQt = dynamic_cast(qtVersion); + if (!blackBerryQt) + continue; + + m_ui->qtLibraryCombo->addItem(blackBerryQt->displayName(), blackBerryQt->uniqueId()); + } + + m_uploadService = new RemoteLinux::GenericDirectUploadService(this); + m_uploadService->setDevice(m_device); + + connect(m_uploadService, SIGNAL(progressMessage(QString)), this, SLOT(updateProgress(QString))); + connect(m_uploadService, SIGNAL(progressMessage(QString)), + m_ui->deployLogWindow, SLOT(appendPlainText(QString))); + connect(m_uploadService, SIGNAL(errorMessage(QString)), + m_ui->deployLogWindow, SLOT(appendPlainText(QString))); + connect(m_uploadService, SIGNAL(warningMessage(QString)), + m_ui->deployLogWindow, SLOT(appendPlainText(QString))); + connect(m_uploadService, SIGNAL(stdOutData(QString)), + m_ui->deployLogWindow, SLOT(appendPlainText(QString))); + connect(m_uploadService, SIGNAL(stdErrData(QString)), + m_ui->deployLogWindow, SLOT(appendPlainText(QString))); + connect(m_uploadService, SIGNAL(finished()), this, SLOT(handleUploadFinished())); + + m_processRunner = new QSsh::SshRemoteProcessRunner(this); + connect(m_processRunner, SIGNAL(connectionError()), + this, SLOT(handleRemoteProcessError())); + connect(m_processRunner, SIGNAL(processClosed(int)), + this, SLOT(handleRemoteProcessCompleted())); + + connect(m_ui->deployButton, SIGNAL(clicked()), this, SLOT(deployLibraries())); + connect(m_ui->closeButton, SIGNAL(clicked()), this, SLOT(close())); +} + +BlackBerryDeployQtLibrariesDialog::~BlackBerryDeployQtLibrariesDialog() +{ + delete m_ui; +} + +int BlackBerryDeployQtLibrariesDialog::execAndDeploy(int qtVersionId, const QString &remoteDirectory) +{ + m_ui->remoteDirectory->setText(remoteDirectory); + m_ui->qtLibraryCombo->setCurrentIndex(m_ui->qtLibraryCombo->findData(qtVersionId)); + + deployLibraries(); + return exec(); +} + +void BlackBerryDeployQtLibrariesDialog::closeEvent(QCloseEvent *event) +{ + // A disabled Deploy button indicates the upload is still running + if (!m_ui->deployButton->isEnabled()) { + int answer = QMessageBox::question(this, windowTitle(), + tr("Closing the dialog will stop the deployment. " + "Are you sure you want to do this?"), + QMessageBox::Yes | QMessageBox::No); + if (answer == QMessageBox::No) + event->ignore(); + else if (answer == QMessageBox::Yes) + m_uploadService->stop(); + } +} + +void BlackBerryDeployQtLibrariesDialog::deployLibraries() +{ + QTC_ASSERT(m_state == Inactive, return); + + if (m_ui->remoteDirectory->text().isEmpty()) { + QMessageBox::warning(this, windowTitle(), + tr("Please input a remote directory to deploy to.")); + return; + } + + QTC_ASSERT(!m_device.isNull(), return); + + m_progressCount = 0; + m_ui->deployProgress->setValue(0); + m_ui->remoteDirectory->setEnabled(false); + m_ui->deployButton->setEnabled(false); + m_ui->qtLibraryCombo->setEnabled(false); + m_ui->deployLogWindow->clear(); + + checkRemoteDirectoryExistance(); +} + +void BlackBerryDeployQtLibrariesDialog::startUpload() +{ + QTC_CHECK(m_state == CheckingRemoteDirectory || m_state == RemovingRemoteDirectory); + + m_state = Uploading; + + QList filesToUpload = gatherFiles(); + + m_ui->deployProgress->setRange(0, filesToUpload.count()); + + m_uploadService->setDeployableFiles(filesToUpload); + m_uploadService->start(); +} + +void BlackBerryDeployQtLibrariesDialog::updateProgress(const QString &progressMessage) +{ + QTC_CHECK(m_state == Uploading); + + if (!progressMessage.startsWith(QLatin1String("Uploading file"))) + return; + + ++m_progressCount; + + m_ui->deployProgress->setValue(m_progressCount); +} + +void BlackBerryDeployQtLibrariesDialog::handleUploadFinished() +{ + m_ui->remoteDirectory->setEnabled(true); + m_ui->deployButton->setEnabled(true); + m_ui->qtLibraryCombo->setEnabled(true); + + m_state = Inactive; +} + +void BlackBerryDeployQtLibrariesDialog::handleRemoteProcessError() +{ + QTC_CHECK(m_state == CheckingRemoteDirectory || m_state == RemovingRemoteDirectory); + + m_ui->deployLogWindow->appendPlainText( + tr("Connection failed: %1") + .arg(m_processRunner->lastConnectionErrorString())); + handleUploadFinished(); +} + +void BlackBerryDeployQtLibrariesDialog::handleRemoteProcessCompleted() +{ + QTC_CHECK(m_state == CheckingRemoteDirectory || m_state == RemovingRemoteDirectory); + + if (m_state == CheckingRemoteDirectory) { + // Directory exists + if (m_processRunner->processExitCode() == 0) { + int answer = QMessageBox::question(this, windowTitle(), + tr("The remote directory '%1' already exist. " + "Deploying to that directory will remove any files " + "already present.\n\n" + "Are you sure you want to continue?") + .arg(fullRemoteDirectory()), + QMessageBox::Yes | QMessageBox::No); + if (answer == QMessageBox::Yes) + removeRemoteDirectory(); + else + handleUploadFinished(); + } else { + startUpload(); + } + } else if (m_state == RemovingRemoteDirectory) { + QTC_ASSERT(m_processRunner->processExitCode() == 0, return); + + startUpload(); + } +} + +QList BlackBerryDeployQtLibrariesDialog::gatherFiles() +{ + QList result; + + const int qtVersionId = + m_ui->qtLibraryCombo->itemData(m_ui->qtLibraryCombo->currentIndex()).toInt(); + BlackBerryQtVersion *qtVersion = + dynamic_cast(QtSupport::QtVersionManager::version(qtVersionId)); + + QTC_ASSERT(qtVersion, return result); + + result.append(gatherFiles(qtVersion->versionInfo().value(QLatin1String("QT_INSTALL_LIBS")))); + result.append(gatherFiles(qtVersion->versionInfo().value(QLatin1String("QT_INSTALL_PLUGINS")))); + result.append(gatherFiles(qtVersion->versionInfo().value(QLatin1String("QT_INSTALL_IMPORTS")))); + result.append(gatherFiles(qtVersion->versionInfo().value(QLatin1String("QT_INSTALL_QML")))); + + return result; +} + +QList BlackBerryDeployQtLibrariesDialog::gatherFiles( + const QString &dirPath, const QString &baseDirPath) +{ + QList result; + QDir dir(dirPath); + QFileInfoList list = dir.entryInfoList(QDir::Dirs | QDir::Files | QDir::NoDotAndDotDot); + + for (int i = 0; i < list.size(); ++i) { + QFileInfo fileInfo = list.at(i); + if (fileInfo.isDir()) { + result.append(gatherFiles(fileInfo.absoluteFilePath(), baseDirPath.isEmpty() ? + dirPath : baseDirPath)); + } else { + QString remoteDir; + if (baseDirPath.isEmpty()) { + remoteDir = fullRemoteDirectory() + QLatin1Char('/') + + QFileInfo(dirPath).baseName(); + } else { + QDir baseDir(baseDirPath); + baseDir.cdUp(); + remoteDir = fullRemoteDirectory() + QLatin1Char('/') + + baseDir.relativeFilePath(dirPath); + } + result.append(ProjectExplorer::DeployableFile(fileInfo.absoluteFilePath(), remoteDir)); + } + } + + return result; +} + +QString BlackBerryDeployQtLibrariesDialog::fullRemoteDirectory() const +{ + return QLatin1String(Constants::QNX_BLACKBERRY_DEFAULT_DEPLOY_QT_BASEPATH) + m_ui->remoteDirectory->text(); +} + +void BlackBerryDeployQtLibrariesDialog::checkRemoteDirectoryExistance() +{ + QTC_CHECK(m_state == Inactive); + + m_state = CheckingRemoteDirectory; + + m_ui->deployLogWindow->appendPlainText(tr("Checking existence of '%1'") + .arg(fullRemoteDirectory())); + + const QByteArray cmd = "test -d " + fullRemoteDirectory().toLatin1(); + m_processRunner->run(cmd, m_device->sshParameters()); +} + +void BlackBerryDeployQtLibrariesDialog::removeRemoteDirectory() +{ + QTC_CHECK(m_state == CheckingRemoteDirectory); + + m_state = RemovingRemoteDirectory; + + m_ui->deployLogWindow->appendPlainText(tr("Removing '%1'").arg(fullRemoteDirectory())); + + const QByteArray cmd = "rm -rf " + fullRemoteDirectory().toLatin1(); + m_processRunner->run(cmd, m_device->sshParameters()); +} diff --git a/src/plugins/qnx/blackberrydeployqtlibrariesdialog.h b/src/plugins/qnx/blackberrydeployqtlibrariesdialog.h new file mode 100644 index 00000000000..44e7536462f --- /dev/null +++ b/src/plugins/qnx/blackberrydeployqtlibrariesdialog.h @@ -0,0 +1,109 @@ +/************************************************************************** +** +** Copyright (C) 2014 BlackBerry Limited. All rights reserved. +** +** Contact: BlackBerry (qt@blackberry.com) +** Contact: KDAB (info@kdab.com) +** +** This file is part of Qt Creator. +** +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and Digia. For licensing terms and +** conditions see http://qt.digia.com/licensing. For further information +** use the contact form at http://qt.digia.com/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Digia gives you certain additional +** rights. These rights are described in the Digia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +****************************************************************************/ + +#ifndef QNX_INTERNAL_BLACKBERRYDEPLOYQTLIBRARIESDIALOG_H +#define QNX_INTERNAL_BLACKBERRYDEPLOYQTLIBRARIESDIALOG_H + +#include + +#include +#include + +namespace QSsh { +class SshRemoteProcessRunner; +} + +namespace RemoteLinux { +class GenericDirectUploadService; +} + +namespace Qnx { +namespace Internal { + +namespace Ui { +class BlackBerryDeployQtLibrariesDialog; +} + +class BlackBerryDeployQtLibrariesDialog : public QDialog +{ + Q_OBJECT + +public: + enum State { + Inactive, + CheckingRemoteDirectory, + RemovingRemoteDirectory, + Uploading + }; + + explicit BlackBerryDeployQtLibrariesDialog(const ProjectExplorer::IDevice::ConstPtr &device, + QWidget *parent = 0); + ~BlackBerryDeployQtLibrariesDialog(); + + int execAndDeploy(int qtVersionId, const QString &remoteDirectory); + +protected: + void closeEvent(QCloseEvent *event); + +private slots: + void deployLibraries(); + void updateProgress(const QString &progressMessage); + void handleUploadFinished(); + + void handleRemoteProcessError(); + void handleRemoteProcessCompleted(); + +private: + QList gatherFiles(); + QList gatherFiles(const QString &dirPath, + const QString &baseDir = QString()); + + QString fullRemoteDirectory() const; + void checkRemoteDirectoryExistance(); + void removeRemoteDirectory(); + void startUpload(); + + Ui::BlackBerryDeployQtLibrariesDialog *m_ui; + + QSsh::SshRemoteProcessRunner *m_processRunner; + RemoteLinux::GenericDirectUploadService *m_uploadService; + + ProjectExplorer::IDevice::ConstPtr m_device; + + int m_progressCount; + + State m_state; +}; + + +} // namespace Internal +} // namespace Qnx +#endif // QNX_INTERNAL_BLACKBERRYDEPLOYQTLIBRARIESDIALOG_H diff --git a/src/plugins/qnx/blackberrydeployqtlibrariesdialog.ui b/src/plugins/qnx/blackberrydeployqtlibrariesdialog.ui new file mode 100644 index 00000000000..befef4957a0 --- /dev/null +++ b/src/plugins/qnx/blackberrydeployqtlibrariesdialog.ui @@ -0,0 +1,117 @@ + + + Qnx::Internal::BlackBerryDeployQtLibrariesDialog + + + + 0 + 0 + 520 + 479 + + + + Deploy Qt to BlackBerry device + + + + + + + + Qt library to deploy: + + + + + + + + + + + + + 0 + 0 + + + + Deploy + + + + + + + + + Remote directory: + + + + + + + 0 + + + + + /accounts/devuser/ + + + + + + + qt + + + + + + + + + + + 0 + + + true + + + + + + + + + + + + Qt::Horizontal + + + + 218 + 20 + + + + + + + + Close + + + + + + + + + + diff --git a/src/plugins/qnx/qnx.pro b/src/plugins/qnx/qnx.pro index c1f74c7f71c..67dcdfc7960 100644 --- a/src/plugins/qnx/qnx.pro +++ b/src/plugins/qnx/qnx.pro @@ -101,7 +101,8 @@ SOURCES += qnxplugin.cpp \ blackberrycheckdevicestatusstepconfigwidget.cpp \ blackberrycheckdevicestatusstep.cpp \ qnxattachdebugsupport.cpp \ - qnxattachdebugdialog.cpp + qnxattachdebugdialog.cpp \ + blackberrydeployqtlibrariesdialog.cpp HEADERS += qnxplugin.h\ qnxconstants.h \ @@ -202,7 +203,8 @@ HEADERS += qnxplugin.h\ blackberrycheckdevicestatusstepfactory.h \ blackberrycheckdevicestatusstepconfigwidget.h \ qnxattachdebugsupport.h \ - qnxattachdebugdialog.h + qnxattachdebugdialog.h \ + blackberrydeployqtlibrariesdialog.h FORMS += \ blackberrydeviceconfigurationwizardsetuppage.ui \ @@ -235,7 +237,8 @@ FORMS += \ blackberryinstallwizardprocesspage.ui \ blackberryinstallwizardoptionpage.ui \ blackberrydebugtokenpinsdialog.ui \ - blackberrycheckdevicestatusstepconfigwidget.ui + blackberrycheckdevicestatusstepconfigwidget.ui \ + blackberrydeployqtlibrariesdialog.ui include(../../private_headers.pri) include(./cascadesimport/cascadesimport.pri) diff --git a/src/plugins/qnx/qnx.qbs b/src/plugins/qnx/qnx.qbs index c5ce9711f5c..9061e93a9d3 100644 --- a/src/plugins/qnx/qnx.qbs +++ b/src/plugins/qnx/qnx.qbs @@ -87,6 +87,9 @@ QtcPlugin { "blackberrydeployconfigurationwidget.ui", "blackberrydeployinformation.cpp", "blackberrydeployinformation.h", + "blackberrydeployqtlibrariesdialog.cpp", + "blackberrydeployqtlibrariesdialog.h", + "blackberrydeployqtlibrariesdialog.ui", "blackberrydeploystep.cpp", "blackberrydeploystep.h", "blackberrydeploystepconfigwidget.cpp", diff --git a/src/plugins/qnx/qnxconstants.h b/src/plugins/qnx/qnxconstants.h index 478a3267f73..8d92a172642 100644 --- a/src/plugins/qnx/qnxconstants.h +++ b/src/plugins/qnx/qnxconstants.h @@ -117,6 +117,8 @@ const char QNX_BLACKBERRY_CONFIGS_FILENAME[] = "bbndkconfigurations.xml"; const char QNX_DEBUGGING_GROUP[] = "Debugger.Group.Qnx"; +const char QNX_BLACKBERRY_DEFAULT_DEPLOY_QT_BASEPATH[] = "/accounts/devuser/"; + } // namespace Constants } // namespace Qnx