From 4779f01ebd5f0c0843b31c725e2a705a2a71c837 Mon Sep 17 00:00:00 2001
From: El Mehdi Fekari <mfekari@rim.com>
Date: Wed, 20 Feb 2013 11:19:46 +0100
Subject: [PATCH] Qnx: Wait for user's confirmation to setup a bar-descriptor
 file
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

In some cases, the user does't need to package the project
and the generated bar-descriptor is useless.

Change-Id: I3f3336190939ef6ded405e3e0793a956cd0e15cc
Reviewed-by: Tobias Nätterlund <tobias.naetterlund@kdab.com>
Reviewed-by: Nicolas Arnaud-Cormos <nicolas@kdab.com>
---
 .../qnx/blackberrydeployconfiguration.cpp     | 29 +++++++++++++------
 .../qnx/blackberrydeployconfiguration.h       |  1 +
 2 files changed, 21 insertions(+), 9 deletions(-)

diff --git a/src/plugins/qnx/blackberrydeployconfiguration.cpp b/src/plugins/qnx/blackberrydeployconfiguration.cpp
index 08040da2275..809e6e74a6d 100644
--- a/src/plugins/qnx/blackberrydeployconfiguration.cpp
+++ b/src/plugins/qnx/blackberrydeployconfiguration.cpp
@@ -35,6 +35,8 @@
 #include "blackberrydeployconfigurationwidget.h"
 #include "blackberrydeployinformation.h"
 
+#include "utils/checkablemessagebox.h"
+
 #include <projectexplorer/kitinformation.h>
 #include <projectexplorer/target.h>
 #include <projectexplorer/projectexplorer.h>
@@ -52,6 +54,7 @@ using namespace Qnx::Internal;
 namespace {
 const char DEPLOYMENT_INFO_SETTING[] = "Qnx.BlackBerry.DeploymentInfo";
 const char DEPLOYMENT_INFO_KEY[]     = "Qnx.BlackBerry.DeployInformation";
+const char BAR_DESC_SETUP[]          = "Qnx.BlackBerry.DeployInformation.BarDescriptorSetup";
 }
 
 BlackBerryDeployConfiguration::BlackBerryDeployConfiguration(ProjectExplorer::Target *parent)
@@ -71,6 +74,7 @@ BlackBerryDeployConfiguration::BlackBerryDeployConfiguration(ProjectExplorer::Ta
 void BlackBerryDeployConfiguration::ctor()
 {
     m_deployInformation = new BlackBerryDeployInformation(target());
+    m_appBarDesciptorSetup = false;
 
     connect(target()->project(), SIGNAL(proFilesEvaluated()), this, SLOT(setupBarDescriptor()), Qt::UniqueConnection);
 
@@ -93,6 +97,18 @@ void BlackBerryDeployConfiguration::setupBarDescriptor()
         if (barDescriptorFile.exists())
             return;
 
+        if (m_appBarDesciptorSetup)
+            return;
+
+        QDialogButtonBox::StandardButton button = Utils::CheckableMessageBox::question(Core::ICore::mainWindow(),
+                                             tr("Setup Application Descriptor File"),
+                                             tr("You need to set up a bar descriptor file to enable "
+                                                "packaging.\nDo you want Qt Creator to generate it for your project?"),
+                                             tr("Don't ask again for this project"), &m_appBarDesciptorSetup);
+
+        if (button == QDialogButtonBox::No)
+            return;
+
         Utils::FileReader reader;
         QString barDescriptorTemplate;
         if (QDir(Utils::FileName::fromString(target()->project()->projectDirectory()).appendPath(QLatin1String("qml")).toString()).exists())
@@ -134,15 +150,8 @@ void BlackBerryDeployConfiguration::addBarDescriptorToProject(const QString &bar
     if (barDesciptorPath.isEmpty())
         return;
 
-    QMessageBox::StandardButton button =
-            QMessageBox::question(Core::ICore::mainWindow(),
-                                  tr("Add bar-descriptor.xml File to Project"),
-                                  tr("Qt Creator has set up a bar descriptor file to enable "
-                                     "packaging.\nDo you want to add it to the project?"),
-                                  QMessageBox::Yes | QMessageBox::No);
-    if (button == QMessageBox::Yes)
-        ProjectExplorer::ProjectExplorerPlugin::instance()
-                ->addExistingFiles(target()->project()->rootProjectNode(), QStringList() << barDesciptorPath);
+    ProjectExplorer::ProjectExplorerPlugin::instance()
+            ->addExistingFiles(target()->project()->rootProjectNode(), QStringList() << barDesciptorPath);
 }
 
 BlackBerryDeployConfiguration::~BlackBerryDeployConfiguration()
@@ -163,6 +172,7 @@ QVariantMap BlackBerryDeployConfiguration::toMap() const
 {
     QVariantMap map(ProjectExplorer::DeployConfiguration::toMap());
     map.insert(QLatin1String(DEPLOYMENT_INFO_KEY), deploymentInfo()->toMap());
+    map.insert(QLatin1String(BAR_DESC_SETUP), m_appBarDesciptorSetup);
     return map;
 }
 
@@ -171,6 +181,7 @@ bool BlackBerryDeployConfiguration::fromMap(const QVariantMap &map)
     if (!ProjectExplorer::DeployConfiguration::fromMap(map))
         return false;
 
+    m_appBarDesciptorSetup = map.value(QLatin1String(BAR_DESC_SETUP)).toBool();
     QVariantMap deployInfoMap = map.value(QLatin1String(DEPLOYMENT_INFO_KEY)).toMap();
     deploymentInfo()->fromMap(deployInfoMap);
     return true;
diff --git a/src/plugins/qnx/blackberrydeployconfiguration.h b/src/plugins/qnx/blackberrydeployconfiguration.h
index 5fc646ce722..f9ef8e01063 100644
--- a/src/plugins/qnx/blackberrydeployconfiguration.h
+++ b/src/plugins/qnx/blackberrydeployconfiguration.h
@@ -73,6 +73,7 @@ private:
     void addBarDescriptorToProject(const QString& barDescriptorPath);
 
     BlackBerryDeployInformation *m_deployInformation;
+    bool m_appBarDesciptorSetup;
 };
 
 } // namespace Internal
-- 
GitLab