123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274 |
- /****************************************************************************
- **
- ** Copyright (C) 2013 Jarek Pelczar <jpelczar@gmail.com>
- ** Copyright (C) 2013 Tomasz Olszak <olszak.tomasz@gmail.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 "tizensettingspage.h"
- #include "tizenconfigurations.h"
- #include "tizentoolchain.h"
- #include "tizenconstants.h"
- #include <utils/hostosinfo.h>
- #include <utils/environment.h>
- #include <QFileDialog>
- #include <projectexplorer/toolchain.h>
- #include <projectexplorer/toolchainmanager.h>
- using namespace Core;
- namespace Tizen {
- TizenSettingsWidget::TizenSettingsWidget(QWidget * parent) :
- QWidget(parent)
- {
- ui.setupUi(this);
- TizenConfigurations * config = TizenConfigurations::instance();
- ui.sdkLocationLineEdit->setText(config->tizenConfig().m_sdkLocation.toString());
- ui.sdkDataPathLineEdit->setText(config->tizenConfig().m_sdkDataLocation.toString());
- ui.sdbPortSpinBox->setValue(config->tizenConfig().m_sdbPort);
- ui.sdbExecutablePath->setText(config->tizenConfig().m_sdbLocation.toString());
- ui.nativePackagingExecutablePath->setText(config->tizenConfig().m_nativePackagingLocation.toString());
- ui.authorCertificatePath->setText(config->tizenConfig().m_authorCertificateLocation.toString());
- ui.authorCertificatePassword->setText(config->tizenConfig().m_authorCertificatePassword);
- connect(ui.sdkLocationBrowse, SIGNAL(clicked()), SLOT(browseSdk()));
- connect(ui.sdkDataPathBrowse, SIGNAL(clicked()), SLOT(browseSdkData()));
- connect(ui.sdbLocationBrowse, SIGNAL(clicked()), SLOT(browseSdbPath()));
- connect(ui.authorCertificatePathBrowse, SIGNAL(clicked()), SLOT(browseAuthorCertificatePath()));
- connect(ui.nativePackagingLocationBrowse, SIGNAL(clicked()), SLOT(browseNativePackagingPath()));
- connect(ui.sdkLocationLineEdit, SIGNAL(editingFinished()),SLOT(tryToFindOutConfigurationFromSdkPath()));
- }
- QString TizenSettingsWidget::widgetKeywords() const
- {
- QString result;
- result.append(ui.label->text());
- result.append(ui.label_2->text());
- result.append(ui.label_3->text());
- result.append(ui.label_4->text());
- result.append(ui.label_5->text());
- result.append(ui.label_6->text());
- result.append(ui.label_7->text());
- return result;
- }
- void TizenSettingsWidget::browseSdk()
- {
- Utils::FileName dir = Utils::FileName::fromString(
- QFileDialog::getExistingDirectory(this,
- tr("Select Tizen SDK folder"),
- ui.sdkLocationLineEdit->text()));
- if(!QFileInfo(dir.toString()).exists())
- return;
- ui.sdkLocationLineEdit->setText(dir.toString());
- tryToFindOutConfigurationFromSdkPath();
- }
- void TizenSettingsWidget::browseSdkData()
- {
- Utils::FileName dir = Utils::FileName::fromString(
- QFileDialog::getExistingDirectory(this,
- tr("Select Tizen SDK data folder"),
- ui.sdkDataPathLineEdit->text()));
- if(!QFileInfo(dir.toString()).exists())
- return;
- ui.sdkDataPathLineEdit->setText(dir.toString());
- }
- void TizenSettingsWidget::browseSdbPath()
- {
- Utils::FileName file = Utils::FileName::fromString(
- QFileDialog::getOpenFileName(this,
- tr("Select SDB executable"),
- ui.sdbExecutablePath->text()));
- QFileInfo fi(file.toFileInfo());
- if(!fi.exists() || !fi.isExecutable())
- return;
- ui.sdbExecutablePath->setText(file.toString());
- }
- void TizenSettingsWidget::browseNativePackagingPath()
- {
- QString dir = ui.nativePackagingExecutablePath->text();
- if (ui.nativePackagingExecutablePath->text().isEmpty() && !ui.sdkLocationLineEdit->text().isEmpty()) {
- QDir tmpDir = QDir(ui.sdkLocationLineEdit->text());
- if (tmpDir.cd(QLatin1String("tools"))) {
- dir = tmpDir.canonicalPath();
- }
- }
- Utils::FileName file = Utils::FileName::fromString(
- QFileDialog::getOpenFileName(this,
- tr("Select native-packaging executable"),
- dir));
- QFileInfo fi(file.toFileInfo());
- if(!fi.exists() || !fi.isExecutable())
- return;
- ui.nativePackagingExecutablePath->setText(file.toString());
- }
- void TizenSettingsWidget::browseAuthorCertificatePath()
- {
- QString dir = ui.authorCertificatePath->text();
- if (ui.authorCertificatePath->text().isEmpty() && !ui.sdkDataPathLineEdit->text().isEmpty()) {
- QDir tmpDir = QDir(ui.sdkDataPathLineEdit->text());
- if (tmpDir.cd(QLatin1String("keystore")) && tmpDir.cd(QLatin1String("author"))) {
- dir = tmpDir.canonicalPath();
- }
- }
- Utils::FileName file = Utils::FileName::fromString(
- QFileDialog::getOpenFileName(this,
- tr("Select author certificate executable"),
- dir,
- QLatin1String("*.p12")));
- QFileInfo fi(file.toFileInfo());
- if(!fi.exists())
- return;
- ui.authorCertificatePath->setText(file.toString());
- }
- void TizenSettingsWidget::tryToFindOutConfigurationFromSdkPath()
- {
- QString sdkPath = ui.sdkLocationLineEdit->text();
- if (sdkPath.isEmpty())
- return;
- if (ui.sdkDataPathLineEdit->text().isEmpty()) {
- QDir sdkDataDir(sdkPath);
- if (sdkDataDir.cdUp()
- && sdkDataDir.cd(QLatin1String("tizen-sdk-data"))
- && sdkDataDir.exists()) {
- ui.sdkDataPathLineEdit->setText(sdkDataDir.canonicalPath());
- }
- }
- if (ui.sdbExecutablePath->text().isEmpty()) {
- ui.sdbExecutablePath->setText(Utils::FileName::fromString(sdkPath)
- .appendPath(QLatin1String("tools"))
- .appendPath(Utils::HostOsInfo::withExecutableSuffix(QLatin1String("sdb")))
- .toString());
- }
- if (ui.nativePackagingExecutablePath->text().isEmpty()) {
- ui.nativePackagingExecutablePath->setText(Utils::FileName::fromString(sdkPath)
- .appendPath(QLatin1String("tools"))
- .appendPath(QLatin1String("native-packaging"))
- .toString());
- }
- }
- TizenSettingsPage::TizenSettingsPage(QObject *parent) :
- IOptionsPage(parent),
- m_widget(NULL)
- {
- setId(Constants::TIZEN_SETTINGS_ID);
- setDisplayName(tr("Tizen Configuration"));
- setCategory(Constants::TIZEN_SETTINGS_CATEGORY);
- setDisplayCategory(QCoreApplication::translate("Tizen", Constants::TIZEN_SETTINGS_TR_CATEGORY));
- setCategoryIcon(QLatin1String(":/tizen/images/tizen.png"));
- }
- bool TizenSettingsPage::matches(const QString& searchKeyWord) const
- {
- return m_keywords.contains(searchKeyWord, Qt::CaseInsensitive);
- }
- QWidget * TizenSettingsPage::createPage(QWidget *parent)
- {
- m_widget = new TizenSettingsWidget(parent);
- if(m_keywords.isEmpty())
- m_keywords = m_widget->widgetKeywords();
- return m_widget;
- }
- void TizenSettingsPage::apply()
- {
- if(m_widget) {
- TizenConfigurations * config = TizenConfigurations::instance();
- config->tizenConfig().m_sdkLocation = Utils::FileName::fromString(m_widget->ui.sdkLocationLineEdit->text());
- config->tizenConfig().m_sdkDataLocation = Utils::FileName::fromString(m_widget->ui.sdkDataPathLineEdit->text());
- config->tizenConfig().m_sdbPort = m_widget->ui.sdbPortSpinBox->value();
- config->tizenConfig().m_sdbLocation = Utils::FileName::fromString(m_widget->ui.sdbExecutablePath->text());
- config->tizenConfig().m_nativePackagingLocation = Utils::FileName::fromString(m_widget->ui.nativePackagingExecutablePath->text());
- config->tizenConfig().m_authorCertificateLocation = Utils::FileName::fromString(m_widget->ui.authorCertificatePath->text());
- config->tizenConfig().m_authorCertificatePassword = m_widget->ui.authorCertificatePassword->text();
- config->save();
- QList<ProjectExplorer::ToolChain *> existingToolchains = ProjectExplorer::ToolChainManager::instance()->toolChains();
- QList<ProjectExplorer::ToolChain *> toolchains = TizenToolchainFactory::createToolchainsForSdk(
- config->tizenConfig().m_sdkLocation.toString(),
- config->tizenConfig().m_sbiLocation.toString());
- Q_FOREACH(ProjectExplorer::ToolChain * tc, toolchains) {
- bool found = false;
- for(int i = 0 ; i < existingToolchains.count() ; ++i) {
- if(*existingToolchains.at(i) == *tc) {
- found = true;
- break;
- }
- }
- if(found)
- delete tc;
- else
- ProjectExplorer::ToolChainManager::instance()->registerToolChain(tc);
- }
- for(int i = 0 ; i < existingToolchains.count() ; ++i) {
- ProjectExplorer::ToolChain * tc = existingToolchains.at(i);
- if(tc->type() == QLatin1String(Constants::TIZEN_TOOLCHAIN_GCC_TYPE)) {
- if(!tc->isValid()) {
- ProjectExplorer::ToolChainManager::instance()->deregisterToolChain(tc);
- }
- }
- }
- config->updateAutomaticKitList();
- }
- }
- void TizenSettingsPage::finish()
- {
- }
- } // namespace Tizen
|