Commit 196d8ddb authored by El Mehdi Fekari's avatar El Mehdi Fekari Committed by Mehdi Fekari

Qnx: Activate/Deactivate auto detected configurations

Add activate and deactivate actions to only create kits
for used NDK targets and not for all installed ones.

Users may want to switch between different targets
without uninstalling non active taregts.

Change-Id: Ie023ebdedbf3494bb7f1c251ce5f7fadec9f9206
Reviewed-by: default avatarTobias Hunger <tobias.hunger@digia.com>
Reviewed-by: default avatarTobias Nätterlund <tobias.naetterlund@kdab.com>
Reviewed-by: default avatarDavid Kaspar <dkaspar@blackberry.com>
parent 3c94b88c
...@@ -62,6 +62,7 @@ const QLatin1String NDKLocationKey("NDKLocation"); // For 10.1 NDK support (< QT ...@@ -62,6 +62,7 @@ const QLatin1String NDKLocationKey("NDKLocation"); // For 10.1 NDK support (< QT
const QLatin1String NDKEnvFileKey("NDKEnvFile"); const QLatin1String NDKEnvFileKey("NDKEnvFile");
const QLatin1String CertificateGroup("Certificates"); const QLatin1String CertificateGroup("Certificates");
const QLatin1String ManualNDKsGroup("ManualNDKs"); const QLatin1String ManualNDKsGroup("ManualNDKs");
const QLatin1String ActiveNDKsGroup("ActiveNDKs");
} }
BlackBerryConfigurationManager::BlackBerryConfigurationManager(QObject *parent) BlackBerryConfigurationManager::BlackBerryConfigurationManager(QObject *parent)
...@@ -129,13 +130,47 @@ void BlackBerryConfigurationManager::loadManualConfigurations() ...@@ -129,13 +130,47 @@ void BlackBerryConfigurationManager::loadManualConfigurations()
void BlackBerryConfigurationManager::loadAutoDetectedConfigurations() void BlackBerryConfigurationManager::loadAutoDetectedConfigurations()
{ {
QStringList activePaths = activeConfigurationNdkEnvPaths();
foreach (const NdkInstallInformation &ndkInfo, QnxUtils::installedNdks()) { foreach (const NdkInstallInformation &ndkInfo, QnxUtils::installedNdks()) {
QString envFilePath = QnxUtils::envFilePath(ndkInfo.path, ndkInfo.version); QString envFilePath = QnxUtils::envFilePath(ndkInfo.path, ndkInfo.version);
BlackBerryConfiguration *config = new BlackBerryConfiguration(Utils::FileName::fromString(envFilePath), BlackBerryConfiguration *config = new BlackBerryConfiguration(Utils::FileName::fromString(envFilePath),
true, ndkInfo.name); true, ndkInfo.name);
if (!addConfiguration(config)) if (!addConfiguration(config)) {
delete config; delete config;
continue;
}
// Activate targets
foreach (const QString activeNdkEnvPath, activePaths) {
if (config->ndkEnvFile().toString() == activeNdkEnvPath)
config->activate();
}
}
// If no target was/is activated, activate one since it's needed by
// device connection and CSK code.
if (activeConfigurations().isEmpty())
m_configs.first()->activate();
}
QStringList BlackBerryConfigurationManager::activeConfigurationNdkEnvPaths()
{
QStringList actives;
QSettings *settings = Core::ICore::settings();
settings->beginGroup(SettingsGroup);
settings->beginGroup(ActiveNDKsGroup);
foreach (const QString &activeNdkEnvPath, settings->childGroups()) {
settings->beginGroup(activeNdkEnvPath);
actives.append(settings->value(NDKEnvFileKey).toString());
settings->endGroup();
} }
settings->endGroup();
settings->endGroup();
return actives;
} }
void BlackBerryConfigurationManager::saveCertificates() void BlackBerryConfigurationManager::saveCertificates()
...@@ -180,6 +215,26 @@ void BlackBerryConfigurationManager::saveManualConfigurations() ...@@ -180,6 +215,26 @@ void BlackBerryConfigurationManager::saveManualConfigurations()
settings->endGroup(); settings->endGroup();
} }
void BlackBerryConfigurationManager::saveActiveConfigurationNdkEnvPath()
{
if (activeConfigurations().isEmpty())
return;
QSettings *settings = Core::ICore::settings();
settings->beginGroup(SettingsGroup);
settings->beginGroup(ActiveNDKsGroup);
settings->clear();
foreach (BlackBerryConfiguration *config, activeConfigurations()) {
settings->beginGroup(config->displayName());
settings->setValue(NDKEnvFileKey, config->ndkEnvFile().toString());
settings->endGroup();
}
settings->endGroup();
settings->endGroup();
}
// Remove no longer available/valid 'auto detected' BlackBerry kits and qt versions // Remove no longer available/valid 'auto detected' BlackBerry kits and qt versions
void BlackBerryConfigurationManager::clearInvalidConfigurations() void BlackBerryConfigurationManager::clearInvalidConfigurations()
{ {
...@@ -216,7 +271,7 @@ bool BlackBerryConfigurationManager::addConfiguration(BlackBerryConfiguration *c ...@@ -216,7 +271,7 @@ bool BlackBerryConfigurationManager::addConfiguration(BlackBerryConfiguration *c
} }
} }
if (config->activate()) { if (config->isValid()) {
m_configs.append(config); m_configs.append(config);
return true; return true;
} }
...@@ -254,6 +309,17 @@ QList<BlackBerryConfiguration *> BlackBerryConfigurationManager::manualConfigura ...@@ -254,6 +309,17 @@ QList<BlackBerryConfiguration *> BlackBerryConfigurationManager::manualConfigura
return manuals; return manuals;
} }
QList<BlackBerryConfiguration *> BlackBerryConfigurationManager::activeConfigurations() const
{
QList<BlackBerryConfiguration*> actives;
foreach (BlackBerryConfiguration *config, m_configs) {
if (config->isActive())
actives << config;
}
return actives;
}
BlackBerryConfiguration *BlackBerryConfigurationManager::configurationFromEnvFile(const Utils::FileName &envFile) const BlackBerryConfiguration *BlackBerryConfigurationManager::configurationFromEnvFile(const Utils::FileName &envFile) const
{ {
foreach (BlackBerryConfiguration *config, m_configs) { foreach (BlackBerryConfiguration *config, m_configs) {
...@@ -315,7 +381,7 @@ BlackBerryCertificate * BlackBerryConfigurationManager::activeCertificate() ...@@ -315,7 +381,7 @@ BlackBerryCertificate * BlackBerryConfigurationManager::activeCertificate()
QMultiMap<QString, QString> BlackBerryConfigurationManager::defaultQnxEnv() QMultiMap<QString, QString> BlackBerryConfigurationManager::defaultQnxEnv()
{ {
foreach (BlackBerryConfiguration *config, m_configs) { foreach (BlackBerryConfiguration *config, m_configs) {
if (!config->qnxEnv().isEmpty()) if (config->isActive() && !config->qnxEnv().isEmpty())
return config->qnxEnv(); return config->qnxEnv();
} }
...@@ -354,6 +420,7 @@ void BlackBerryConfigurationManager::clearConfigurationSettings(BlackBerryConfig ...@@ -354,6 +420,7 @@ void BlackBerryConfigurationManager::clearConfigurationSettings(BlackBerryConfig
void BlackBerryConfigurationManager::saveSettings() void BlackBerryConfigurationManager::saveSettings()
{ {
saveActiveConfigurationNdkEnvPath();
saveManualConfigurations(); saveManualConfigurations();
saveCertificates(); saveCertificates();
} }
......
...@@ -54,6 +54,7 @@ public: ...@@ -54,6 +54,7 @@ public:
void removeConfiguration(BlackBerryConfiguration *config); void removeConfiguration(BlackBerryConfiguration *config);
QList<BlackBerryConfiguration*> configurations() const; QList<BlackBerryConfiguration*> configurations() const;
QList<BlackBerryConfiguration*> manualConfigurations() const; QList<BlackBerryConfiguration*> manualConfigurations() const;
QList<BlackBerryConfiguration *> activeConfigurations() const;
BlackBerryConfiguration *configurationFromEnvFile(const Utils::FileName &envFile) const; BlackBerryConfiguration *configurationFromEnvFile(const Utils::FileName &envFile) const;
QString barsignerCskPath() const; QString barsignerCskPath() const;
...@@ -91,7 +92,10 @@ private: ...@@ -91,7 +92,10 @@ private:
void loadAutoDetectedConfigurations(); void loadAutoDetectedConfigurations();
void saveCertificates(); void saveCertificates();
void saveManualConfigurations(); void saveManualConfigurations();
void saveActiveConfigurationNdkEnvPath();
void clearInvalidConfigurations(); void clearInvalidConfigurations();
QStringList activeConfigurationNdkEnvPaths();
}; };
} // namespace Internal } // namespace Internal
......
...@@ -31,6 +31,7 @@ ...@@ -31,6 +31,7 @@
#include "blackberryndksettingspage.h" #include "blackberryndksettingspage.h"
#include "blackberryndksettingswidget.h" #include "blackberryndksettingswidget.h"
#include "blackberryconfiguration.h"
#include "qnxconstants.h" #include "qnxconstants.h"
#include <projectexplorer/projectexplorerconstants.h> #include <projectexplorer/projectexplorerconstants.h>
...@@ -59,6 +60,15 @@ QWidget *BlackBerryNDKSettingsPage::createPage(QWidget *parent) ...@@ -59,6 +60,15 @@ QWidget *BlackBerryNDKSettingsPage::createPage(QWidget *parent)
void BlackBerryNDKSettingsPage::apply() void BlackBerryNDKSettingsPage::apply()
{ {
foreach (BlackBerryConfiguration* config, m_widget->activatedTargets()) {
if (!config->isActive())
config->activate();
}
foreach (BlackBerryConfiguration* config, m_widget->deactivatedTargets()) {
if (config->isActive())
config->deactivate();
}
} }
void BlackBerryNDKSettingsPage::finish() void BlackBerryNDKSettingsPage::finish()
......
...@@ -61,12 +61,18 @@ BlackBerryNDKSettingsWidget::BlackBerryNDKSettingsWidget(QWidget *parent) : ...@@ -61,12 +61,18 @@ BlackBerryNDKSettingsWidget::BlackBerryNDKSettingsWidget(QWidget *parent) :
m_ui->setupUi(this); m_ui->setupUi(this);
m_ui->removeNdkButton->setEnabled(false); m_ui->removeNdkButton->setEnabled(false);
m_ui->activateNdkTargetButton->setEnabled(false);
m_ui->deactivateNdkTargetButton->setEnabled(false);
m_activatedTargets << m_bbConfigManager->activeConfigurations();
initNdkList(); initNdkList();
connect(m_ui->wizardButton, SIGNAL(clicked()), this, SLOT(launchBlackBerrySetupWizard())); connect(m_ui->wizardButton, SIGNAL(clicked()), this, SLOT(launchBlackBerrySetupWizard()));
connect(m_ui->addNdkButton, SIGNAL(clicked()), this, SLOT(addNdkTarget())); connect(m_ui->addNdkButton, SIGNAL(clicked()), this, SLOT(addNdkTarget()));
connect(m_ui->removeNdkButton, SIGNAL(clicked()), this, SLOT(removeNdkTarget())); connect(m_ui->removeNdkButton, SIGNAL(clicked()), this, SLOT(removeNdkTarget()));
connect(m_ui->activateNdkTargetButton, SIGNAL(clicked()), this, SLOT(activateNdkTarget()));
connect(m_ui->deactivateNdkTargetButton, SIGNAL(clicked()), this, SLOT(deactivateNdkTarget()));
connect(m_ui->ndksTreeWidget, SIGNAL(currentItemChanged(QTreeWidgetItem*,QTreeWidgetItem*)), this, SLOT(updateInfoTable(QTreeWidgetItem*))); connect(m_ui->ndksTreeWidget, SIGNAL(currentItemChanged(QTreeWidgetItem*,QTreeWidgetItem*)), this, SLOT(updateInfoTable(QTreeWidgetItem*)));
} }
...@@ -81,6 +87,16 @@ bool BlackBerryNDKSettingsWidget::hasActiveNdk() const ...@@ -81,6 +87,16 @@ bool BlackBerryNDKSettingsWidget::hasActiveNdk() const
return !m_bbConfigManager->configurations().isEmpty(); return !m_bbConfigManager->configurations().isEmpty();
} }
QList<BlackBerryConfiguration *> BlackBerryNDKSettingsWidget::activatedTargets()
{
return m_activatedTargets;
}
QList<BlackBerryConfiguration *> BlackBerryNDKSettingsWidget::deactivatedTargets()
{
return m_deactivatedTargets;
}
void BlackBerryNDKSettingsWidget::launchBlackBerrySetupWizard() const void BlackBerryNDKSettingsWidget::launchBlackBerrySetupWizard() const
{ {
const bool alreadyConfigured = BlackBerryUtils::hasRegisteredKeys(); const bool alreadyConfigured = BlackBerryUtils::hasRegisteredKeys();
...@@ -95,11 +111,16 @@ void BlackBerryNDKSettingsWidget::launchBlackBerrySetupWizard() const ...@@ -95,11 +111,16 @@ void BlackBerryNDKSettingsWidget::launchBlackBerrySetupWizard() const
wizard.exec(); wizard.exec();
} }
void BlackBerryNDKSettingsWidget::updateInfoTable(QTreeWidgetItem* currentNdk) void BlackBerryNDKSettingsWidget::updateInfoTable(QTreeWidgetItem* currentItem)
{ {
QString envFilePath = currentNdk->text(1); if (!currentItem)
return;
QString envFilePath = currentItem->text(1);
if (envFilePath.isEmpty()) { if (envFilePath.isEmpty()) {
m_ui->removeNdkButton->setEnabled(false); m_ui->removeNdkButton->setEnabled(false);
m_ui->activateNdkTargetButton->setEnabled(false);
m_ui->deactivateNdkTargetButton->setEnabled(false);
return; return;
} }
...@@ -109,7 +130,7 @@ void BlackBerryNDKSettingsWidget::updateInfoTable(QTreeWidgetItem* currentNdk) ...@@ -109,7 +130,7 @@ void BlackBerryNDKSettingsWidget::updateInfoTable(QTreeWidgetItem* currentNdk)
foreach (const NdkInstallInformation &ndkInfo, QnxUtils::installedNdks()) foreach (const NdkInstallInformation &ndkInfo, QnxUtils::installedNdks())
{ {
if (ndkInfo.target.contains(config->targetName())) { if (ndkInfo.name == config->displayName()) {
m_ui->baseNameLabel->setText(ndkInfo.name); m_ui->baseNameLabel->setText(ndkInfo.name);
m_ui->ndkPathLabel->setText(ndkInfo.path); m_ui->ndkPathLabel->setText(ndkInfo.path);
m_ui->versionLabel->setText(ndkInfo.version); m_ui->versionLabel->setText(ndkInfo.version);
...@@ -119,7 +140,7 @@ void BlackBerryNDKSettingsWidget::updateInfoTable(QTreeWidgetItem* currentNdk) ...@@ -119,7 +140,7 @@ void BlackBerryNDKSettingsWidget::updateInfoTable(QTreeWidgetItem* currentNdk)
} }
} }
m_ui->removeNdkButton->setEnabled(!config->isAutoDetected()); updateUi(currentItem, config);
} }
void BlackBerryNDKSettingsWidget::updateNdkList() void BlackBerryNDKSettingsWidget::updateNdkList()
...@@ -129,6 +150,10 @@ void BlackBerryNDKSettingsWidget::updateNdkList() ...@@ -129,6 +150,10 @@ void BlackBerryNDKSettingsWidget::updateNdkList()
QTreeWidgetItem *item = new QTreeWidgetItem(parent); QTreeWidgetItem *item = new QTreeWidgetItem(parent);
item->setText(0, config->displayName()); item->setText(0, config->displayName());
item->setText(1, config->ndkEnvFile().toString()); item->setText(1, config->ndkEnvFile().toString());
QFont font;
font.setBold(config->isActive());
item->setFont(0, font);
item->setFont(1, font);
} }
if (m_autoDetectedNdks->child(0)) { if (m_autoDetectedNdks->child(0)) {
...@@ -162,6 +187,9 @@ void BlackBerryNDKSettingsWidget::addNdkTarget() ...@@ -162,6 +187,9 @@ void BlackBerryNDKSettingsWidget::addNdkTarget()
void BlackBerryNDKSettingsWidget::removeNdkTarget() void BlackBerryNDKSettingsWidget::removeNdkTarget()
{ {
if (!m_ui->ndksTreeWidget->currentItem())
return;
QString ndk = m_ui->ndksTreeWidget->currentItem()->text(0); QString ndk = m_ui->ndksTreeWidget->currentItem()->text(0);
QString envFilePath = m_ui->ndksTreeWidget->currentItem()->text(1); QString envFilePath = m_ui->ndksTreeWidget->currentItem()->text(1);
QMessageBox::StandardButton button = QMessageBox::StandardButton button =
...@@ -172,11 +200,61 @@ void BlackBerryNDKSettingsWidget::removeNdkTarget() ...@@ -172,11 +200,61 @@ void BlackBerryNDKSettingsWidget::removeNdkTarget()
if (button == QMessageBox::Yes) { if (button == QMessageBox::Yes) {
BlackBerryConfiguration *config = m_bbConfigManager->configurationFromEnvFile(Utils::FileName::fromString(envFilePath)); BlackBerryConfiguration *config = m_bbConfigManager->configurationFromEnvFile(Utils::FileName::fromString(envFilePath));
if (config) if (config) {
m_bbConfigManager->removeConfiguration(config); m_bbConfigManager->removeConfiguration(config);
m_manualNdks->removeChild(m_ui->ndksTreeWidget->currentItem()); m_manualNdks->removeChild(m_ui->ndksTreeWidget->currentItem());
}
}
}
void BlackBerryNDKSettingsWidget::activateNdkTarget()
{
if (!m_ui->ndksTreeWidget->currentItem())
return;
QString envFilePath = m_ui->ndksTreeWidget->currentItem()->text(1);
BlackBerryConfiguration *config = m_bbConfigManager->configurationFromEnvFile(Utils::FileName::fromString(envFilePath));
if (config && !m_activatedTargets.contains(config)) {
m_activatedTargets << config;
if (m_deactivatedTargets.contains(config))
m_deactivatedTargets.removeAt(m_deactivatedTargets.indexOf(config));
updateUi(m_ui->ndksTreeWidget->currentItem(), config);
} }
}
void BlackBerryNDKSettingsWidget::deactivateNdkTarget()
{
if (!m_ui->ndksTreeWidget->currentItem())
return;
QString envFilePath = m_ui->ndksTreeWidget->currentItem()->text(1);
BlackBerryConfiguration *config = m_bbConfigManager->configurationFromEnvFile(Utils::FileName::fromString(envFilePath));
if (config && m_activatedTargets.contains(config)) {
m_deactivatedTargets << config;
m_activatedTargets.removeAt(m_activatedTargets.indexOf(config));
updateUi(m_ui->ndksTreeWidget->currentItem(), config);
}
}
void BlackBerryNDKSettingsWidget::updateUi(QTreeWidgetItem *item, BlackBerryConfiguration *config)
{
if (!item || !config)
return;
QFont font;
font.setBold(m_activatedTargets.contains(config));
item->setFont(0, font);
item->setFont(1, font);
m_ui->activateNdkTargetButton->setEnabled((!m_activatedTargets.contains(config))
&& config->isAutoDetected());
m_ui->deactivateNdkTargetButton->setEnabled((m_activatedTargets.contains(config))
&& m_activatedTargets.size() > 1
&& config->isAutoDetected());
m_ui->removeNdkButton->setEnabled(!config->isAutoDetected());
} }
void BlackBerryNDKSettingsWidget::initNdkList() void BlackBerryNDKSettingsWidget::initNdkList()
......
...@@ -42,6 +42,7 @@ QT_END_NAMESPACE ...@@ -42,6 +42,7 @@ QT_END_NAMESPACE
namespace Qnx { namespace Qnx {
namespace Internal { namespace Internal {
class BlackBerryConfiguration;
class BlackBerryConfigurationManager; class BlackBerryConfigurationManager;
class Ui_BlackBerryNDKSettingsWidget; class Ui_BlackBerryNDKSettingsWidget;
...@@ -55,15 +56,21 @@ public: ...@@ -55,15 +56,21 @@ public:
bool hasActiveNdk() const; bool hasActiveNdk() const;
QList<BlackBerryConfiguration *> activatedTargets();
QList<BlackBerryConfiguration *> deactivatedTargets();
signals: signals:
void kitsUpdated(); void kitsUpdated();
public slots: public slots:
void launchBlackBerrySetupWizard() const; void launchBlackBerrySetupWizard() const;
void updateInfoTable(QTreeWidgetItem* currentNdk); void updateInfoTable(QTreeWidgetItem* currentItem);
void updateNdkList(); void updateNdkList();
void addNdkTarget(); void addNdkTarget();
void removeNdkTarget(); void removeNdkTarget();
void activateNdkTarget();
void deactivateNdkTarget();
void updateUi(QTreeWidgetItem* item, BlackBerryConfiguration* config);
private: private:
void initNdkList(); void initNdkList();
...@@ -72,6 +79,8 @@ private: ...@@ -72,6 +79,8 @@ private:
BlackBerryConfigurationManager *m_bbConfigManager; BlackBerryConfigurationManager *m_bbConfigManager;
QTreeWidgetItem *m_autoDetectedNdks; QTreeWidgetItem *m_autoDetectedNdks;
QTreeWidgetItem *m_manualNdks; QTreeWidgetItem *m_manualNdks;
QList<BlackBerryConfiguration *> m_activatedTargets;
QList<BlackBerryConfiguration *> m_deactivatedTargets;
}; };
} // namespace Internal } // namespace Internal
......
...@@ -163,14 +163,35 @@ ...@@ -163,14 +163,35 @@
<item> <item>
<widget class="QPushButton" name="addNdkButton"> <widget class="QPushButton" name="addNdkButton">
<property name="text"> <property name="text">
<string>Add Target</string> <string>Add </string>
</property> </property>
</widget> </widget>
</item> </item>
<item> <item>
<widget class="QPushButton" name="removeNdkButton"> <widget class="QPushButton" name="removeNdkButton">
<property name="text"> <property name="text">
<string>Remove Target</string> <string>Remove</string>
</property>
</widget>
</item>
<item>
<widget class="Line" name="line">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="activateNdkTargetButton">
<property name="text">
<string>Activate</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="deactivateNdkTargetButton">
<property name="text">
<string>Deactivate</string>
</property> </property>
</widget> </widget>
</item> </item>
......
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