2013-01-09 09:23:37 -05:00
|
|
|
/**************************************************************************
|
|
|
|
|
**
|
2013-01-31 17:02:30 +01:00
|
|
|
** Copyright (C) 2011 - 2013 Research In Motion
|
2013-01-09 09:23:37 -05:00
|
|
|
**
|
|
|
|
|
** Contact: Research In Motion (blackberry-qt@qnx.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.
|
|
|
|
|
**
|
|
|
|
|
****************************************************************************/
|
|
|
|
|
|
2013-01-17 15:27:02 -02:00
|
|
|
#include "blackberryndksettingswidget.h"
|
|
|
|
|
#include "ui_blackberryndksettingswidget.h"
|
2013-01-09 09:23:37 -05:00
|
|
|
#include "qnxutils.h"
|
2013-04-12 17:09:11 -03:00
|
|
|
#include "blackberryutils.h"
|
|
|
|
|
#include "blackberrysetupwizard.h"
|
2013-01-09 09:23:37 -05:00
|
|
|
|
2013-07-04 16:21:33 +02:00
|
|
|
#include "blackberryconfigurationmanager.h"
|
|
|
|
|
#include "blackberryconfiguration.h"
|
|
|
|
|
|
2013-01-09 09:23:37 -05:00
|
|
|
#include <utils/pathchooser.h>
|
|
|
|
|
|
|
|
|
|
#include <coreplugin/icore.h>
|
|
|
|
|
|
|
|
|
|
#include <QMessageBox>
|
2013-07-04 16:21:33 +02:00
|
|
|
#include <QFileDialog>
|
|
|
|
|
|
|
|
|
|
#include <QStandardItemModel>
|
|
|
|
|
#include <QTreeWidgetItem>
|
2013-01-09 09:23:37 -05:00
|
|
|
|
|
|
|
|
namespace Qnx {
|
|
|
|
|
namespace Internal {
|
|
|
|
|
|
2013-01-17 15:27:02 -02:00
|
|
|
BlackBerryNDKSettingsWidget::BlackBerryNDKSettingsWidget(QWidget *parent) :
|
2013-01-09 09:23:37 -05:00
|
|
|
QWidget(parent),
|
2013-07-04 16:21:33 +02:00
|
|
|
m_ui(new Ui_BlackBerryNDKSettingsWidget),
|
|
|
|
|
m_autoDetectedNdks(0),
|
|
|
|
|
m_manualNdks(0)
|
2013-01-09 09:23:37 -05:00
|
|
|
{
|
2013-07-04 16:21:33 +02:00
|
|
|
m_bbConfigManager = &BlackBerryConfigurationManager::instance();
|
2013-01-09 09:23:37 -05:00
|
|
|
m_ui->setupUi(this);
|
2013-07-04 16:21:33 +02:00
|
|
|
|
|
|
|
|
m_ui->removeNdkButton->setEnabled(false);
|
2013-01-09 09:23:37 -05:00
|
|
|
|
2013-07-04 16:21:33 +02:00
|
|
|
initNdkList();
|
2013-01-09 09:23:37 -05:00
|
|
|
|
2013-04-12 17:09:11 -03:00
|
|
|
connect(m_ui->wizardButton, SIGNAL(clicked()), this, SLOT(launchBlackBerrySetupWizard()));
|
2013-08-22 17:00:58 +02:00
|
|
|
connect(m_ui->addNdkButton, SIGNAL(clicked()), this, SLOT(addNdkTarget()));
|
|
|
|
|
connect(m_ui->removeNdkButton, SIGNAL(clicked()), this, SLOT(removeNdkTarget()));
|
2013-07-04 16:21:33 +02:00
|
|
|
connect(m_ui->ndksTreeWidget, SIGNAL(currentItemChanged(QTreeWidgetItem*,QTreeWidgetItem*)), this, SLOT(updateInfoTable(QTreeWidgetItem*)));
|
2013-04-12 17:09:11 -03:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void BlackBerryNDKSettingsWidget::setWizardMessageVisible(bool visible)
|
|
|
|
|
{
|
|
|
|
|
m_ui->wizardLabel->setVisible(visible);
|
|
|
|
|
m_ui->wizardButton->setVisible(visible);
|
|
|
|
|
}
|
|
|
|
|
|
2013-07-04 16:21:33 +02:00
|
|
|
bool BlackBerryNDKSettingsWidget::hasActiveNdk() const
|
2013-04-12 17:09:11 -03:00
|
|
|
{
|
2013-07-04 16:21:33 +02:00
|
|
|
return !m_bbConfigManager->configurations().isEmpty();
|
2013-04-12 17:09:11 -03:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void BlackBerryNDKSettingsWidget::launchBlackBerrySetupWizard() const
|
|
|
|
|
{
|
|
|
|
|
const bool alreadyConfigured = BlackBerryUtils::hasRegisteredKeys();
|
|
|
|
|
|
|
|
|
|
if (alreadyConfigured) {
|
|
|
|
|
QMessageBox::information(0, tr("Qt Creator"),
|
|
|
|
|
tr("It appears that your BlackBerry environment has already been configured."));
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
BlackBerrySetupWizard wizard;
|
|
|
|
|
wizard.exec();
|
|
|
|
|
}
|
|
|
|
|
|
2013-07-04 16:21:33 +02:00
|
|
|
void BlackBerryNDKSettingsWidget::updateInfoTable(QTreeWidgetItem* currentNdk)
|
2013-01-09 09:23:37 -05:00
|
|
|
{
|
2013-08-22 17:00:58 +02:00
|
|
|
QString envFilePath = currentNdk->text(1);
|
|
|
|
|
if (envFilePath.isEmpty()) {
|
2013-07-04 16:21:33 +02:00
|
|
|
m_ui->removeNdkButton->setEnabled(false);
|
|
|
|
|
return;
|
2013-04-12 17:09:11 -03:00
|
|
|
}
|
|
|
|
|
|
2013-08-22 17:00:58 +02:00
|
|
|
BlackBerryConfiguration *config = m_bbConfigManager->configurationFromEnvFile(Utils::FileName::fromString(envFilePath));
|
2013-07-04 16:21:33 +02:00
|
|
|
if (!config)
|
|
|
|
|
return;
|
|
|
|
|
|
2013-08-22 17:00:58 +02:00
|
|
|
foreach (const NdkInstallInformation &ndkInfo, QnxUtils::installedNdks())
|
|
|
|
|
{
|
|
|
|
|
if (ndkInfo.target.contains(config->targetName())) {
|
|
|
|
|
m_ui->baseNameLabel->setText(ndkInfo.name);
|
|
|
|
|
m_ui->ndkPathLabel->setText(ndkInfo.path);
|
|
|
|
|
m_ui->versionLabel->setText(ndkInfo.version);
|
|
|
|
|
m_ui->hostLabel->setText(ndkInfo.host);
|
|
|
|
|
m_ui->targetLabel->setText(ndkInfo.target);
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
2013-01-09 09:23:37 -05:00
|
|
|
|
2013-07-04 16:21:33 +02:00
|
|
|
m_ui->removeNdkButton->setEnabled(!config->isAutoDetected());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void BlackBerryNDKSettingsWidget::updateNdkList()
|
|
|
|
|
{
|
|
|
|
|
foreach (BlackBerryConfiguration *config, m_bbConfigManager->configurations()) {
|
|
|
|
|
QTreeWidgetItem *parent = config->isAutoDetected() ? m_autoDetectedNdks : m_manualNdks;
|
|
|
|
|
QTreeWidgetItem *item = new QTreeWidgetItem(parent);
|
|
|
|
|
item->setText(0, config->displayName());
|
2013-08-22 17:00:58 +02:00
|
|
|
item->setText(1, config->ndkEnvFile().toString());
|
2013-07-04 16:21:33 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (m_autoDetectedNdks->child(0)) {
|
|
|
|
|
m_autoDetectedNdks->child(0)->setSelected(true);
|
|
|
|
|
updateInfoTable(m_autoDetectedNdks->child(0));
|
|
|
|
|
}
|
2013-01-09 09:23:37 -05:00
|
|
|
}
|
|
|
|
|
|
2013-08-22 17:00:58 +02:00
|
|
|
void BlackBerryNDKSettingsWidget::addNdkTarget()
|
2013-01-09 09:23:37 -05:00
|
|
|
{
|
2013-08-22 17:00:58 +02:00
|
|
|
QString selectedPath = QFileDialog::getOpenFileName(0, tr("Select the NDK Environment file"),
|
|
|
|
|
QString(), tr("BlackBerry Environment File (*.sh *.bat)"));
|
|
|
|
|
if (selectedPath.isEmpty() || !QFileInfo(selectedPath).exists())
|
2013-07-04 16:21:33 +02:00
|
|
|
return;
|
|
|
|
|
|
2013-08-22 17:00:58 +02:00
|
|
|
BlackBerryConfiguration *config = m_bbConfigManager->configurationFromEnvFile(Utils::FileName::fromString(selectedPath));
|
|
|
|
|
|
2013-07-04 16:21:33 +02:00
|
|
|
if (!config) {
|
2013-08-22 17:00:58 +02:00
|
|
|
config = new BlackBerryConfiguration(Utils::FileName::fromString(selectedPath), false);
|
2013-07-04 16:21:33 +02:00
|
|
|
if (!m_bbConfigManager->addConfiguration(config)) {
|
|
|
|
|
delete config;
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
QTreeWidgetItem *item = new QTreeWidgetItem(m_manualNdks);
|
|
|
|
|
item->setText(0, selectedPath.split(QDir::separator()).last());
|
|
|
|
|
item->setText(1, selectedPath);
|
|
|
|
|
updateInfoTable(item);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2013-08-22 17:00:58 +02:00
|
|
|
void BlackBerryNDKSettingsWidget::removeNdkTarget()
|
2013-01-09 09:23:37 -05:00
|
|
|
{
|
2013-08-22 17:00:58 +02:00
|
|
|
QString ndk = m_ui->ndksTreeWidget->currentItem()->text(0);
|
|
|
|
|
QString envFilePath = m_ui->ndksTreeWidget->currentItem()->text(1);
|
2013-01-09 09:23:37 -05:00
|
|
|
QMessageBox::StandardButton button =
|
|
|
|
|
QMessageBox::question(Core::ICore::mainWindow(),
|
|
|
|
|
tr("Clean BlackBerry 10 Configuration"),
|
2013-08-22 17:00:58 +02:00
|
|
|
tr("Are you sure you want to remove:\n %1?").arg(ndk),
|
2013-01-09 09:23:37 -05:00
|
|
|
QMessageBox::Yes | QMessageBox::No);
|
|
|
|
|
|
2013-07-04 16:21:33 +02:00
|
|
|
if (button == QMessageBox::Yes) {
|
2013-08-22 17:00:58 +02:00
|
|
|
BlackBerryConfiguration *config = m_bbConfigManager->configurationFromEnvFile(Utils::FileName::fromString(envFilePath));
|
2013-07-04 16:21:33 +02:00
|
|
|
if (config)
|
|
|
|
|
m_bbConfigManager->removeConfiguration(config);
|
|
|
|
|
m_manualNdks->removeChild(m_ui->ndksTreeWidget->currentItem());
|
|
|
|
|
}
|
|
|
|
|
|
2013-01-09 09:23:37 -05:00
|
|
|
}
|
|
|
|
|
|
2013-07-04 16:21:33 +02:00
|
|
|
void BlackBerryNDKSettingsWidget::initNdkList()
|
|
|
|
|
{
|
|
|
|
|
m_ui->ndksTreeWidget->header()->setResizeMode(QHeaderView::Stretch);
|
|
|
|
|
m_ui->ndksTreeWidget->header()->setStretchLastSection(false);
|
2013-08-22 17:00:58 +02:00
|
|
|
m_ui->ndksTreeWidget->setHeaderItem(new QTreeWidgetItem(QStringList() << tr("NDK") << tr("NDK Environment File")));
|
2013-07-04 16:21:33 +02:00
|
|
|
m_ui->ndksTreeWidget->setTextElideMode(Qt::ElideNone);
|
|
|
|
|
m_ui->ndksTreeWidget->setColumnCount(2);
|
|
|
|
|
m_autoDetectedNdks = new QTreeWidgetItem(m_ui->ndksTreeWidget);
|
|
|
|
|
m_autoDetectedNdks->setText(0, tr("Auto-Detected"));
|
|
|
|
|
m_autoDetectedNdks->setFirstColumnSpanned(true);
|
|
|
|
|
m_autoDetectedNdks->setFlags(Qt::ItemIsEnabled);
|
|
|
|
|
m_manualNdks = new QTreeWidgetItem(m_ui->ndksTreeWidget);
|
|
|
|
|
m_manualNdks->setText(0, tr("Manual"));
|
|
|
|
|
m_manualNdks->setFirstColumnSpanned(true);
|
|
|
|
|
m_manualNdks->setFlags(Qt::ItemIsEnabled);
|
|
|
|
|
|
|
|
|
|
m_ui->ndksTreeWidget->expandAll();
|
|
|
|
|
|
|
|
|
|
updateNdkList();
|
2013-01-09 09:23:37 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
} // namespace Internal
|
|
|
|
|
} // namespace Qnx
|
|
|
|
|
|