diff options
Diffstat (limited to 'src/plugins/qt4projectmanager/wizards')
10 files changed, 23 insertions, 1045 deletions
diff --git a/src/plugins/qt4projectmanager/wizards/abstractmobileappwizard.cpp b/src/plugins/qt4projectmanager/wizards/abstractmobileappwizard.cpp index 9be35ad170..8b94e4cdf6 100644 --- a/src/plugins/qt4projectmanager/wizards/abstractmobileappwizard.cpp +++ b/src/plugins/qt4projectmanager/wizards/abstractmobileappwizard.cpp @@ -30,7 +30,7 @@ #include "abstractmobileappwizard.h" #include "mobileappwizardpages.h" -#include "targetsetuppage.h" +#include "../qmakeprojectimporter.h" #include <extensionsystem/pluginmanager.h> #include <qt4projectmanager/qt4project.h> @@ -38,6 +38,7 @@ #include <qtsupport/qtsupportconstants.h> #include <qtsupport/qtkitinformation.h> #include <projectexplorer/projectexplorer.h> +#include <projectexplorer/targetsetuppage.h> #include <projectexplorer/customwizard/customwizard.h> #include <coreplugin/editormanager/editormanager.h> @@ -64,7 +65,8 @@ AbstractMobileAppWizardDialog::AbstractMobileAppWizardDialog(QWidget *parent, .value<QList<Core::Id> >()) { if (!parameters.extraValues().contains(QLatin1String(ProjectExplorer::Constants::PROJECT_KIT_IDS))) { - m_targetsPage = new TargetSetupPage; + m_targetsPage = new ProjectExplorer::TargetSetupPage; + m_targetsPage->setProjectImporter(new Internal::QmakeProjectImporter(path())); QString platform = selectedPlatform(); if (platform.isEmpty()) { m_targetsPage->setPreferredKitMatcher( @@ -120,7 +122,7 @@ void AbstractMobileAppWizardDialog::addMobilePages() m_targetItem->setNextShownItem(0); } -TargetSetupPage *AbstractMobileAppWizardDialog::targetsPage() const +ProjectExplorer::TargetSetupPage *AbstractMobileAppWizardDialog::targetsPage() const { return m_targetsPage; } @@ -295,7 +297,7 @@ void AbstractMobileAppWizard::useProjectPath(const QString &projectName, app()->setProjectName(projectName); app()->setProjectPath(projectPath); if (wizardDialog()->m_targetsPage) - wizardDialog()->m_targetsPage->setProFilePath(app()->path(AbstractMobileApp::AppPro)); + wizardDialog()->m_targetsPage->setProjectPath(app()->path(AbstractMobileApp::AppPro)); projectPathChanged(app()->path(AbstractMobileApp::AppPro)); } diff --git a/src/plugins/qt4projectmanager/wizards/abstractmobileappwizard.h b/src/plugins/qt4projectmanager/wizards/abstractmobileappwizard.h index 4062f17cdb..cfb2a997f8 100644 --- a/src/plugins/qt4projectmanager/wizards/abstractmobileappwizard.h +++ b/src/plugins/qt4projectmanager/wizards/abstractmobileappwizard.h @@ -33,6 +33,8 @@ #include <qt4projectmanager/qt4projectmanager_global.h> #include <projectexplorer/baseprojectwizarddialog.h> +namespace ProjectExplorer { class TargetSetupPage; } + namespace QtSupport { class QtVersionNumber; class QtVersionManager; @@ -41,7 +43,6 @@ class QtVersionManager; namespace Qt4ProjectManager { class AbstractMobileApp; -class TargetSetupPage; namespace Internal { class MobileAppWizardGenericOptionsPage; @@ -61,7 +62,7 @@ protected: void addMobilePages(); public: - TargetSetupPage *targetsPage() const; + ProjectExplorer::TargetSetupPage *targetsPage() const; protected: int addPageWithTitle(QWizardPage *page, const QString &title); @@ -80,7 +81,7 @@ private: Internal::MobileAppWizardGenericOptionsPage *m_genericOptionsPage; Internal::MobileAppWizardMaemoOptionsPage *m_maemoOptionsPage; Internal::MobileAppWizardHarmattanOptionsPage *m_harmattanOptionsPage; - TargetSetupPage *m_targetsPage; + ProjectExplorer::TargetSetupPage *m_targetsPage; int m_genericOptionsPageId; int m_maemoOptionsPageId; diff --git a/src/plugins/qt4projectmanager/wizards/html5appwizard.cpp b/src/plugins/qt4projectmanager/wizards/html5appwizard.cpp index 754c16859a..854377dd17 100644 --- a/src/plugins/qt4projectmanager/wizards/html5appwizard.cpp +++ b/src/plugins/qt4projectmanager/wizards/html5appwizard.cpp @@ -31,11 +31,11 @@ #include "html5app.h" #include "html5appwizardpages.h" -#include "targetsetuppage.h" #include <qt4projectmanager/qt4projectmanagerconstants.h> #include <qtsupport/baseqtversion.h> #include <projectexplorer/projectexplorerconstants.h> +#include <projectexplorer/targetsetuppage.h> #include <qtsupport/qtsupportconstants.h> #include <limits> @@ -115,7 +115,7 @@ AbstractMobileAppWizardDialog *Html5AppWizard::createWizardDialogInternal(QWidge void Html5AppWizard::projectPathChanged(const QString &path) const { if (d->wizardDialog->targetsPage()) - d->wizardDialog->targetsPage()->setProFilePath(path); + d->wizardDialog->targetsPage()->setProjectPath(path); } void Html5AppWizard::prepareGenerateFiles(const QWizard *w, diff --git a/src/plugins/qt4projectmanager/wizards/importwidget.cpp b/src/plugins/qt4projectmanager/wizards/importwidget.cpp deleted file mode 100644 index d3e5d99395..0000000000 --- a/src/plugins/qt4projectmanager/wizards/importwidget.cpp +++ /dev/null @@ -1,88 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/legal -** -** 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 "importwidget.h" - -#include <utils/detailswidget.h> -#include <utils/pathchooser.h> - -#include <QPushButton> -#include <QVBoxLayout> - -namespace Qt4ProjectManager { -namespace Internal { - -ImportWidget::ImportWidget(QWidget *parent) : - QWidget(parent), - m_pathChooser(new Utils::PathChooser) -{ - setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Fixed); - QVBoxLayout *vboxLayout = new QVBoxLayout(); - setLayout(vboxLayout); - vboxLayout->setContentsMargins(0, 0, 0, 0); - Utils::DetailsWidget *detailsWidget = new Utils::DetailsWidget(this); - detailsWidget->setUseCheckBox(false); - detailsWidget->setSummaryText(tr("Import Build from...")); - detailsWidget->setSummaryFontBold(true); - // m_detailsWidget->setIcon(); // FIXME: Set icon! - vboxLayout->addWidget(detailsWidget); - - QWidget *widget = new QWidget; - QVBoxLayout *layout = new QVBoxLayout(widget); - layout->setContentsMargins(0, 0, 0, 0); - layout->addWidget(m_pathChooser); - - m_pathChooser->setExpectedKind(Utils::PathChooser::ExistingDirectory); - QPushButton *importButton = new QPushButton(tr("Import"), widget); - layout->addWidget(importButton); - - connect(importButton, SIGNAL(clicked()), this, SLOT(handleImportRequest())); - - detailsWidget->setWidget(widget); -} - -ImportWidget::~ImportWidget() -{ } - -void ImportWidget::setCurrentDirectory(const Utils::FileName &dir) -{ - m_pathChooser->setBaseFileName(dir); - m_pathChooser->setFileName(dir); -} - -void ImportWidget::handleImportRequest() -{ - Utils::FileName dir = m_pathChooser->fileName(); - emit importFrom(dir); - - m_pathChooser->setFileName(m_pathChooser->baseFileName()); -} - -} // namespace Internal -} // namespace Qt4ProjectManager diff --git a/src/plugins/qt4projectmanager/wizards/importwidget.h b/src/plugins/qt4projectmanager/wizards/importwidget.h deleted file mode 100644 index 9cb1d728ca..0000000000 --- a/src/plugins/qt4projectmanager/wizards/importwidget.h +++ /dev/null @@ -1,66 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/legal -** -** 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 IMPORTWIDGET_H -#define IMPORTWIDGET_H - -#include <QWidget> - -namespace Utils { -class PathChooser; -class FileName; -} // namespace Utils - -namespace Qt4ProjectManager { -namespace Internal { - -class ImportWidget : public QWidget -{ - Q_OBJECT - -public: - explicit ImportWidget(QWidget *parent = 0); - ~ImportWidget(); - - void setCurrentDirectory(const Utils::FileName &dir); - -signals: - void importFrom(const Utils::FileName &dir); - -private slots: - void handleImportRequest(); - -private: - Utils::PathChooser *m_pathChooser; -}; - -} // namespace Internal -} // namespace Qt4ProjectManager - -#endif // IMPORTWIDGET_H diff --git a/src/plugins/qt4projectmanager/wizards/qtquickappwizard.cpp b/src/plugins/qt4projectmanager/wizards/qtquickappwizard.cpp index 04afef13f2..660fcba083 100644 --- a/src/plugins/qt4projectmanager/wizards/qtquickappwizard.cpp +++ b/src/plugins/qt4projectmanager/wizards/qtquickappwizard.cpp @@ -31,12 +31,12 @@ #include "qtquickapp.h" #include "qtquickappwizardpages.h" -#include "targetsetuppage.h" -#include <qt4projectmanager/qt4projectmanagerconstants.h> +#include "qt4projectmanagerconstants.h" #include <qtsupport/qtsupportconstants.h> #include <qtsupport/baseqtversion.h> #include <projectexplorer/projectexplorerconstants.h> +#include <projectexplorer/targetsetuppage.h> #include <QIcon> #include <QDebug> @@ -226,7 +226,7 @@ AbstractMobileAppWizardDialog *QtQuickAppWizard::createWizardDialogInternal(QWid void QtQuickAppWizard::projectPathChanged(const QString &path) const { if (d->wizardDialog->targetsPage()) - d->wizardDialog->targetsPage()->setProFilePath(path); + d->wizardDialog->targetsPage()->setProjectPath(path); } void QtQuickAppWizard::prepareGenerateFiles(const QWizard *w, diff --git a/src/plugins/qt4projectmanager/wizards/qtwizard.cpp b/src/plugins/qt4projectmanager/wizards/qtwizard.cpp index d1629e5f5c..78d4a6a3cb 100644 --- a/src/plugins/qt4projectmanager/wizards/qtwizard.cpp +++ b/src/plugins/qt4projectmanager/wizards/qtwizard.cpp @@ -30,7 +30,6 @@ #include "qtwizard.h" #include "modulespage.h" -#include "targetsetuppage.h" #include <qt4projectmanager/qt4project.h> #include <qt4projectmanager/qt4projectmanager.h> @@ -41,6 +40,7 @@ #include <cpptools/cpptoolsconstants.h> #include <projectexplorer/projectexplorer.h> +#include <projectexplorer/targetsetuppage.h> #include <qtsupport/qtkitinformation.h> #include <qtsupport/qtsupportconstants.h> @@ -212,7 +212,7 @@ int BaseQt4ProjectWizardDialog::addModulesPage(int id) int BaseQt4ProjectWizardDialog::addTargetSetupPage(bool mobile, int id) { - m_targetSetupPage = new TargetSetupPage; + m_targetSetupPage = new ProjectExplorer::TargetSetupPage; const QString platform = selectedPlatform(); Core::FeatureSet features = mobile ? Core::FeatureSet(QtSupport::Constants::FEATURE_MOBILE) : Core::FeatureSet(QtSupport::Constants::FEATURE_DESKTOP); @@ -323,5 +323,5 @@ void BaseQt4ProjectWizardDialog::generateProfileName(const QString &name, const QDir::cleanPath(path + QLatin1Char('/') + name + QLatin1Char('/') + name + QLatin1String(".pro")); - m_targetSetupPage->setProFilePath(proFile); + m_targetSetupPage->setProjectPath(proFile); } diff --git a/src/plugins/qt4projectmanager/wizards/qtwizard.h b/src/plugins/qt4projectmanager/wizards/qtwizard.h index 459dc61629..bb78c12d6c 100644 --- a/src/plugins/qt4projectmanager/wizards/qtwizard.h +++ b/src/plugins/qt4projectmanager/wizards/qtwizard.h @@ -34,12 +34,14 @@ #include <projectexplorer/baseprojectwizarddialog.h> #include <projectexplorer/customwizard/customwizard.h> -namespace ProjectExplorer { class Kit; } +namespace ProjectExplorer { +class Kit; +class TargetSetupPage; +} // namespace ProjectExplorer namespace Qt4ProjectManager { class Qt4Project; -class TargetSetupPage; namespace Internal { @@ -142,7 +144,7 @@ private: inline void init(bool showModulesPage); ModulesPage *m_modulesPage; - TargetSetupPage *m_targetSetupPage; + ProjectExplorer::TargetSetupPage *m_targetSetupPage; QStringList m_selectedModules; QStringList m_deselectedModules; QList<Core::Id> m_profileIds; diff --git a/src/plugins/qt4projectmanager/wizards/targetsetuppage.cpp b/src/plugins/qt4projectmanager/wizards/targetsetuppage.cpp deleted file mode 100644 index 350bd821bb..0000000000 --- a/src/plugins/qt4projectmanager/wizards/targetsetuppage.cpp +++ /dev/null @@ -1,731 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/legal -** -** 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 "targetsetuppage.h" -#include "importwidget.h" -#include "../qt4targetsetupwidget.h" - -#include <qt4projectmanager/buildconfigurationinfo.h> -#include <qt4projectmanager/qt4buildconfiguration.h> -#include <qt4projectmanager/qt4project.h> -#include <qt4projectmanager/qmakekitinformation.h> - -#include <coreplugin/icore.h> -#include <projectexplorer/projectexplorerconstants.h> -#include <projectexplorer/target.h> -#include <qtsupport/qtkitinformation.h> -#include <qtsupport/qtsupportconstants.h> -#include <qtsupport/qtversionfactory.h> -#include <qtsupport/qtversionmanager.h> -#include <utils/qtcprocess.h> - -#include <QLabel> -#include <QMessageBox> -#include <QScrollArea> -#include <QVBoxLayout> - -using namespace ProjectExplorer; -using namespace QtSupport; - -namespace Qt4ProjectManager { -namespace Internal { - -static const Core::Id QT_IS_TEMPORARY("Qt4PM.TempQt"); -static const Core::Id KIT_IS_TEMPORARY("Qt4PM.TempKit"); -static const Core::Id KIT_TEMPORARY_NAME("Qt4PM.TempName"); -static const Core::Id KIT_FINAL_NAME("Qt4PM.FinalName"); -static const Core::Id TEMPORARY_OF_PROJECTS("Qt4PM.TempProject"); - -class TargetSetupPageUi -{ -public: - QWidget *centralWidget; - QWidget *scrollAreaWidget; - QScrollArea *scrollArea; - QLabel *headerLabel; - QLabel *descriptionLabel; - QLabel *noValidKitLabel; - QLabel *optionHintLabel; - - void setupUi(QWidget *q) - { - QWidget *setupTargetPage = new QWidget(q); - descriptionLabel = new QLabel(setupTargetPage); - descriptionLabel->setWordWrap(true); - descriptionLabel->setVisible(false); - - headerLabel = new QLabel(setupTargetPage); - headerLabel->setWordWrap(true); - headerLabel->setVisible(false); - - noValidKitLabel = new QLabel(setupTargetPage); - noValidKitLabel->setWordWrap(true); - noValidKitLabel->setText(TargetSetupPage::tr("<span style=\" font-weight:600;\">No valid kits found.</span>")); - - - optionHintLabel = new QLabel(setupTargetPage); - optionHintLabel->setWordWrap(true); - optionHintLabel->setText(TargetSetupPage::tr( - "Please add a kit in the <a href=\"buildandrun\">options</a> " - "or via the maintenance tool of the SDK.")); - optionHintLabel->setTextInteractionFlags(Qt::TextBrowserInteraction); - optionHintLabel->setVisible(false); - - centralWidget = new QWidget(setupTargetPage); - QSizePolicy policy(QSizePolicy::Preferred, QSizePolicy::Fixed); - policy.setHorizontalStretch(0); - policy.setVerticalStretch(0); - policy.setHeightForWidth(centralWidget->sizePolicy().hasHeightForWidth()); - centralWidget->setSizePolicy(policy); - - scrollAreaWidget = new QWidget(setupTargetPage); - scrollArea = new QScrollArea(scrollAreaWidget); - scrollArea->setWidgetResizable(true); - - QWidget *scrollAreaWidgetContents; - scrollAreaWidgetContents = new QWidget(); - scrollAreaWidgetContents->setGeometry(QRect(0, 0, 230, 81)); - scrollArea->setWidget(scrollAreaWidgetContents); - - QVBoxLayout *verticalLayout = new QVBoxLayout(scrollAreaWidget); - verticalLayout->setSpacing(0); - verticalLayout->setContentsMargins(0, 0, 0, 0); - verticalLayout->addWidget(scrollArea); - - QVBoxLayout *verticalLayout_2 = new QVBoxLayout(setupTargetPage); - verticalLayout_2->addWidget(headerLabel); - verticalLayout_2->addWidget(noValidKitLabel); - verticalLayout_2->addWidget(descriptionLabel); - verticalLayout_2->addWidget(optionHintLabel); - verticalLayout_2->addWidget(centralWidget); - verticalLayout_2->addWidget(scrollAreaWidget); - - QVBoxLayout *verticalLayout_3 = new QVBoxLayout(q); - verticalLayout_3->setContentsMargins(0, 0, 0, -1); - verticalLayout_3->addWidget(setupTargetPage); - - QObject::connect(optionHintLabel, SIGNAL(linkActivated(QString)), - q, SLOT(openOptions())); - } -}; - -} // namespace Internal - -using namespace Internal; - -TargetSetupPage::TargetSetupPage(QWidget *parent) : - QWizardPage(parent), - m_requiredMatcher(0), - m_preferredMatcher(0), - m_baseLayout(0), - m_importSearch(false), - m_ignoreUpdates(false), - m_firstWidget(0), - m_ui(new TargetSetupPageUi), - m_importWidget(new Internal::ImportWidget(this)), - m_spacer(new QSpacerItem(0,0, QSizePolicy::Minimum, QSizePolicy::MinimumExpanding)), - m_forceOptionHint(false) -{ - setObjectName(QLatin1String("TargetSetupPage")); - setWindowTitle(tr("Select Kits for Your Project")); - m_ui->setupUi(this); - - QSizePolicy policy(QSizePolicy::Preferred, QSizePolicy::Preferred); - policy.setHorizontalStretch(0); - policy.setVerticalStretch(0); - policy.setHeightForWidth(sizePolicy().hasHeightForWidth()); - setSizePolicy(policy); - - QWidget *centralWidget = new QWidget(this); - m_ui->scrollArea->setWidget(centralWidget); - centralWidget->setLayout(new QVBoxLayout); - m_ui->centralWidget->setLayout(new QVBoxLayout); - m_ui->centralWidget->layout()->setMargin(0); - - setUseScrollArea(true); - setImportSearch(false); - - setTitle(tr("Kit Selection")); - - QObject *km = KitManager::instance(); - connect(km, SIGNAL(kitAdded(ProjectExplorer::Kit*)), - this, SLOT(handleKitAddition(ProjectExplorer::Kit*))); - connect(km, SIGNAL(kitRemoved(ProjectExplorer::Kit*)), - this, SLOT(handleKitRemoval(ProjectExplorer::Kit*))); - connect(km, SIGNAL(kitUpdated(ProjectExplorer::Kit*)), - this, SLOT(handleKitUpdate(ProjectExplorer::Kit*))); - connect(m_importWidget, SIGNAL(importFrom(Utils::FileName)), - this, SLOT(import(Utils::FileName))); -} - -void TargetSetupPage::initializePage() -{ - reset(); - - setupWidgets(); - setupImports(); - selectAtLeastOneKit(); -} - -void TargetSetupPage::setRequiredKitMatcher(ProjectExplorer::KitMatcher *matcher) -{ - m_requiredMatcher = matcher; -} - -QList<Core::Id> TargetSetupPage::selectedKits() const -{ - QList<Core::Id> result; - QMap<Core::Id, Qt4TargetSetupWidget *>::const_iterator it, end; - it = m_widgets.constBegin(); - end = m_widgets.constEnd(); - - for ( ; it != end; ++it) { - if (isKitSelected(it.key())) - result << it.key(); - } - return result; -} - -void TargetSetupPage::setPreferredKitMatcher(ProjectExplorer::KitMatcher *matcher) -{ - m_preferredMatcher = matcher; -} - -TargetSetupPage::~TargetSetupPage() -{ - reset(); - delete m_ui; - delete m_preferredMatcher; - delete m_requiredMatcher; -} - -bool TargetSetupPage::isKitSelected(Core::Id id) const -{ - Qt4TargetSetupWidget *widget = m_widgets.value(id); - return widget && widget->isKitSelected(); -} - -void TargetSetupPage::setKitSelected(Core::Id id, bool selected) -{ - Qt4TargetSetupWidget *widget = m_widgets.value(id); - if (widget) - widget->setKitSelected(selected); -} - -bool TargetSetupPage::isComplete() const -{ - foreach (Qt4TargetSetupWidget *widget, m_widgets.values()) - if (widget->isKitSelected()) - return true; - return false; -} - -void TargetSetupPage::setImportSearch(bool b) -{ - m_importSearch = b; - m_importWidget->setVisible(b); -} - -void TargetSetupPage::setupWidgets() -{ - // Known profiles: - QList<Kit *> kits = m_requiredMatcher - ? KitManager::matchingKits(*m_requiredMatcher) : KitManager::kits(); - foreach (Kit *k, kits) - addWidget(k); - - // Setup import widget: - m_baseLayout->addWidget(m_importWidget); - Utils::FileName path = Utils::FileName::fromString(m_proFilePath); - path = path.parentDir(); // base dir - path = path.parentDir(); // parent dir - m_importWidget->setCurrentDirectory(path); - - updateVisibility(); -} - -void TargetSetupPage::reset() -{ - foreach (Qt4TargetSetupWidget *widget, m_widgets.values()) { - ProjectExplorer::Kit *k = widget->kit(); - if (!k) - continue; - removeProject(k, m_proFilePath); - delete widget; - } - - m_widgets.clear(); - m_firstWidget = 0; -} - -ProjectExplorer::Kit *TargetSetupPage::createTemporaryKit(BaseQtVersion *version, - bool temporaryVersion, - const Utils::FileName &parsedSpec) -{ - ProjectExplorer::Kit *k = new ProjectExplorer::Kit; - QtKitInformation::setQtVersion(k, version); - ProjectExplorer::ToolChainKitInformation::setToolChain(k, version->preferredToolChain(parsedSpec)); - QmakeKitInformation::setMkspec(k, parsedSpec); - - k->setDisplayName(tr("%1 - temporary").arg(version->displayName())); - k->setValue(KIT_TEMPORARY_NAME, k->displayName()); - k->setValue(KIT_FINAL_NAME, version->displayName()); - k->setValue(KIT_IS_TEMPORARY, true); - if (temporaryVersion) - k->setValue(QT_IS_TEMPORARY, version->uniqueId()); - - m_ignoreUpdates = true; - ProjectExplorer::KitManager::registerKit(k); - m_ignoreUpdates = false; - - return k; -} - -void TargetSetupPage::cleanKit(ProjectExplorer::Kit *k) -{ - m_ignoreUpdates = true; - k->removeKey(KIT_IS_TEMPORARY); - k->removeKey(QT_IS_TEMPORARY); - k->removeKey(TEMPORARY_OF_PROJECTS); - const QString tempName = k->value(KIT_TEMPORARY_NAME).toString(); - if (!tempName.isNull() && k->displayName() == tempName) - k->setDisplayName(k->value(KIT_FINAL_NAME).toString()); - k->removeKey(KIT_TEMPORARY_NAME); - k->removeKey(KIT_FINAL_NAME); - m_ignoreUpdates = false; -} - -void TargetSetupPage::makeQtPersistent(ProjectExplorer::Kit *k) -{ - m_ignoreUpdates = true; - k->removeKey(QT_IS_TEMPORARY); - m_ignoreUpdates = false; -} - -void TargetSetupPage::addProject(ProjectExplorer::Kit *k, const QString &path) -{ - if (!k->hasValue(KIT_IS_TEMPORARY)) - return; - - QStringList projects = k->value(TEMPORARY_OF_PROJECTS, QStringList()).toStringList(); - if (!projects.contains(path)) { - projects.append(path); - m_ignoreUpdates = true; - k->setValue(TEMPORARY_OF_PROJECTS, projects); - m_ignoreUpdates = false; - } -} - -void TargetSetupPage::removeProject(ProjectExplorer::Kit *k, const QString &path) -{ - if (!k->hasValue(KIT_IS_TEMPORARY) || path.isEmpty()) - return; - - QStringList projects = k->value(TEMPORARY_OF_PROJECTS, QStringList()).toStringList(); - if (projects.contains(path)) { - projects.removeOne(path); - m_ignoreUpdates = true; - if (projects.isEmpty()) - ProjectExplorer::KitManager::deregisterKit(k); - else - k->setValue(TEMPORARY_OF_PROJECTS, projects); - m_ignoreUpdates = false; - } -} - -void TargetSetupPage::setProFilePath(const QString &path) -{ - m_proFilePath = path; - if (!m_proFilePath.isEmpty()) - m_ui->headerLabel->setText(tr("Qt Creator can use the following kits for project <b>%1</b>:", - "%1: Project name").arg(QFileInfo(m_proFilePath).baseName())); - m_ui->headerLabel->setVisible(!m_proFilePath.isEmpty()); - - if (m_widgets.isEmpty()) - return; - - reset(); - setupWidgets(); -} - -void TargetSetupPage::setNoteText(const QString &text) -{ - m_ui->descriptionLabel->setText(text); - m_ui->descriptionLabel->setVisible(!text.isEmpty()); -} - -void TargetSetupPage::showOptionsHint(bool show) -{ - m_forceOptionHint = show; - updateVisibility(); -} - -void TargetSetupPage::import(const Utils::FileName &path) -{ - import(path, false); -} - -void TargetSetupPage::import(const Utils::FileName &path, const bool silent) -{ - QFileInfo fi = path.toFileInfo(); - if (!fi.exists() && !fi.isDir()) - return; - - QStringList makefiles = QDir(path.toString()).entryList(QStringList(QLatin1String("Makefile*"))); - - BaseQtVersion *version = 0; - bool temporaryVersion = false; - bool found = false; - - foreach (const QString &file, makefiles) { - // find interesting makefiles - QString makefile = path.toString() + QLatin1Char('/') + file; - Utils::FileName qmakeBinary = QtVersionManager::findQMakeBinaryFromMakefile(makefile); - QFileInfo fi = qmakeBinary.toFileInfo(); - Utils::FileName canonicalQmakeBinary = Utils::FileName::fromString(fi.canonicalFilePath()); - if (canonicalQmakeBinary.isEmpty()) - continue; - if (QtVersionManager::makefileIsFor(makefile, m_proFilePath) != QtVersionManager::SameProject) - continue; - - // Find version: - foreach (BaseQtVersion *v, QtVersionManager::versions()) { - QFileInfo vfi = v->qmakeCommand().toFileInfo(); - Utils::FileName current = Utils::FileName::fromString(vfi.canonicalFilePath()); - if (current == canonicalQmakeBinary) { - version = v; - break; - } - } - - // Create a new version if not found: - if (!version) { - // Do not use the canonical path here... - version = QtVersionFactory::createQtVersionFromQMakePath(qmakeBinary); - if (!version) - continue; - - QtVersionManager::addVersion(version); - temporaryVersion = true; - } - - // find qmake arguments and mkspec - QPair<BaseQtVersion::QmakeBuildConfigs, QString> makefileBuildConfig = - QtVersionManager::scanMakeFile(makefile, version->defaultBuildConfig()); - - QString additionalArguments = makefileBuildConfig.second; - Utils::FileName parsedSpec = - Qt4BuildConfiguration::extractSpecFromArguments(&additionalArguments, path.toString(), version); - Utils::FileName versionSpec = version->mkspec(); - if (parsedSpec.isEmpty() || parsedSpec == Utils::FileName::fromString(QLatin1String("default"))) - parsedSpec = versionSpec; - - QString specArgument; - // Compare mkspecs and add to additional arguments - if (parsedSpec != versionSpec) - specArgument = QLatin1String("-spec ") + Utils::QtcProcess::quoteArg(parsedSpec.toUserOutput()); - Utils::QtcProcess::addArgs(&specArgument, additionalArguments); - - // Find profiles (can be more than one, e.g. (Linux-)Desktop and embedded linux): - QList<ProjectExplorer::Kit *> kitList; - foreach (ProjectExplorer::Kit *k, ProjectExplorer::KitManager::kits()) { - BaseQtVersion *profileVersion = QtKitInformation::qtVersion(k); - Utils::FileName profileSpec = QmakeKitInformation::mkspec(k); - ProjectExplorer::ToolChain *tc = ProjectExplorer::ToolChainKitInformation::toolChain(k); - if (profileSpec.isEmpty() && profileVersion) - profileSpec = profileVersion->mkspecFor(tc); - - if (profileVersion == version - && profileSpec == parsedSpec) - kitList.append(k); - } - if (kitList.isEmpty()) - kitList.append(createTemporaryKit(version, temporaryVersion, parsedSpec)); - - foreach (ProjectExplorer::Kit *k, kitList) { - addProject(k, m_proFilePath); - - // Create widget: - Qt4TargetSetupWidget *widget = m_widgets.value(k->id(), 0); - if (!widget) - addWidget(k); - widget = m_widgets.value(k->id(), 0); - if (!widget) - continue; - - // create info: - BuildConfigurationInfo info = BuildConfigurationInfo(makefileBuildConfig.first, - specArgument, - path.toString(), - true, - file); - - widget->addBuildConfigurationInfo(info, true); - widget->setKitSelected(true); - found = true; - } - } - - updateVisibility(); - - if (!found && !silent) - QMessageBox::critical(this, - tr("No Build Found"), - tr("No build found in %1 matching project %2.").arg(path.toUserOutput()).arg(m_proFilePath)); -} - -void TargetSetupPage::handleQtUpdate(const QList<int> &add, const QList<int> &rm, const QList<int> &mod) -{ - Q_UNUSED(add); - // Update kit to no longer claim a Qt version is temporary once it is modified/removed. - foreach (ProjectExplorer::Kit *k, ProjectExplorer::KitManager::kits()) { - if (!k->hasValue(QT_IS_TEMPORARY)) - continue; - int qtVersion = k->value(QT_IS_TEMPORARY, -1).toInt(); - if (rm.contains(qtVersion) || mod.contains(qtVersion)) - makeQtPersistent(k); - } -} - -void TargetSetupPage::setupImports() -{ - if (!m_importSearch || m_proFilePath.isEmpty()) - return; - - QFileInfo pfi(m_proFilePath); - const QString prefix = pfi.baseName(); - QStringList toImport; - toImport << pfi.absolutePath(); - - QList<ProjectExplorer::Kit *> kitList = ProjectExplorer::KitManager::kits(); - foreach (ProjectExplorer::Kit *k, kitList) { - QFileInfo fi(Qt4Project::shadowBuildDirectory(m_proFilePath, k, QString())); - const QString baseDir = fi.absolutePath(); - - foreach (const QString &dir, QDir(baseDir).entryList()) { - const QString path = baseDir + QLatin1Char('/') + dir; - if (dir.startsWith(prefix) && !toImport.contains(path)) - toImport << path; - - } - } - foreach (const QString &path, toImport) - import(Utils::FileName::fromString(path), true); -} - -void TargetSetupPage::handleKitAddition(ProjectExplorer::Kit *k) -{ - if (m_ignoreUpdates) - return; - - Q_ASSERT(!m_widgets.contains(k->id())); - addWidget(k); - updateVisibility(); -} - -void TargetSetupPage::handleKitRemoval(ProjectExplorer::Kit *k) -{ - BaseQtVersion *version = QtVersionManager::version(k->value(QT_IS_TEMPORARY, -1).toInt()); - if (version) - QtVersionManager::removeVersion(version); - - if (m_ignoreUpdates) - return; - - removeWidget(k); - updateVisibility(); -} - -void TargetSetupPage::handleKitUpdate(ProjectExplorer::Kit *k) -{ - if (m_ignoreUpdates) - return; - - cleanKit(k); - Qt4TargetSetupWidget *widget = m_widgets.value(k->id()); - - bool acceptable = true; - if (m_requiredMatcher && !m_requiredMatcher->matches(k)) - acceptable = false; - - if (widget && !acceptable) - removeWidget(k); - else if (!widget && acceptable) - addWidget(k); - - updateVisibility(); -} - -void TargetSetupPage::selectAtLeastOneKit() -{ - bool atLeastOneKitSelected = false; - foreach (Qt4TargetSetupWidget *w, m_widgets.values()) { - if (w->isKitSelected()) { - atLeastOneKitSelected = true; - break; - } - } - - if (!atLeastOneKitSelected) { - Qt4TargetSetupWidget *widget = m_firstWidget; - ProjectExplorer::Kit *defaultKit = ProjectExplorer::KitManager::defaultKit(); - if (defaultKit) - widget = m_widgets.value(defaultKit->id(), m_firstWidget); - if (widget) - widget->setKitSelected(true); - m_firstWidget = 0; - } - emit completeChanged(); // Is this necessary? -} - -void TargetSetupPage::updateVisibility() -{ - // Always show the widgets, the import widget always makes sense to show. - m_ui->scrollAreaWidget->setVisible(m_baseLayout == m_ui->scrollArea->widget()->layout()); - m_ui->centralWidget->setVisible(m_baseLayout == m_ui->centralWidget->layout()); - - bool hasKits = !m_widgets.isEmpty(); - m_ui->noValidKitLabel->setVisible(!hasKits); - m_ui->optionHintLabel->setVisible(m_forceOptionHint || !hasKits); - - emit completeChanged(); -} - -void TargetSetupPage::openOptions() -{ - Core::ICore::showOptionsDialog(ProjectExplorer::Constants::PROJECTEXPLORER_SETTINGS_CATEGORY, - ProjectExplorer::Constants::KITS_SETTINGS_PAGE_ID, - this); -} - -void TargetSetupPage::removeWidget(ProjectExplorer::Kit *k) -{ - Qt4TargetSetupWidget *widget = m_widgets.value(k->id()); - if (!widget) - return; - if (widget == m_firstWidget) - m_firstWidget = 0; - widget->deleteLater(); - m_widgets.remove(k->id()); -} - -Qt4TargetSetupWidget *TargetSetupPage::addWidget(ProjectExplorer::Kit *k) -{ - if (m_requiredMatcher && !m_requiredMatcher->matches(k)) - return 0; - - QList<BuildConfigurationInfo> infoList = Qt4BuildConfigurationFactory::availableBuildConfigurations(k, m_proFilePath); - Qt4TargetSetupWidget *widget = infoList.isEmpty() ? 0 : new Qt4TargetSetupWidget(k, m_proFilePath, infoList); - if (!widget) - return 0; - - m_baseLayout->removeWidget(m_importWidget); - m_baseLayout->removeItem(m_spacer); - - widget->setKitSelected(m_preferredMatcher && m_preferredMatcher->matches(k)); - m_widgets.insert(k->id(), widget); - m_baseLayout->addWidget(widget); - - m_baseLayout->addWidget(m_importWidget); - m_baseLayout->addItem(m_spacer); - - connect(widget, SIGNAL(selectedToggled()), - this, SIGNAL(completeChanged())); - - if (!m_firstWidget) - m_firstWidget = widget; - - return widget; -} - -class KitBuildInfo -{ -public: - KitBuildInfo(ProjectExplorer::Kit *k, const QList<BuildConfigurationInfo> &il) : - kit(k), infoList(il) - { } - - ProjectExplorer::Kit *kit; - QList<BuildConfigurationInfo> infoList; -}; - -bool TargetSetupPage::setupProject(Qt4ProjectManager::Qt4Project *project) -{ - QList<KitBuildInfo> toRegister; - foreach (Qt4TargetSetupWidget *widget, m_widgets.values()) { - if (!widget->isKitSelected()) - continue; - - ProjectExplorer::Kit *k = widget->kit(); - cleanKit(k); - toRegister.append(KitBuildInfo(k, widget->selectedBuildConfigurationInfoList())); - widget->clearKit(); - } - reset(); - - // only register kits after we are done cleaning up - foreach (const KitBuildInfo &data, toRegister) - project->addTarget(project->createTarget(data.kit, data.infoList)); - - // Select active target - // a) Simulator target - // b) Desktop target - // c) the first target - ProjectExplorer::Target *activeTarget = 0; - QList<ProjectExplorer::Target *> targets = project->targets(); - int activeTargetPriority = 0; - foreach (ProjectExplorer::Target *t, targets) { - BaseQtVersion *version = QtSupport::QtKitInformation::qtVersion(t->kit()); - if (t->kit() == ProjectExplorer::KitManager::defaultKit()) { - activeTarget = t; - activeTargetPriority = 3; - } else if (activeTargetPriority < 2 && version && version->type() == QLatin1String(QtSupport::Constants::SIMULATORQT)) { - activeTarget = t; - activeTargetPriority = 2; - } else if (activeTargetPriority < 1 && version && version->type() == QLatin1String(QtSupport::Constants::DESKTOPQT)) { - activeTarget = t; - activeTargetPriority = 1; - } - } - if (!activeTarget && !targets.isEmpty()) - activeTarget = targets.first(); - if (activeTarget) - project->setActiveTarget(activeTarget); - - return true; -} - -void TargetSetupPage::setUseScrollArea(bool b) -{ - m_baseLayout = b ? m_ui->scrollArea->widget()->layout() : m_ui->centralWidget->layout(); - m_ui->scrollAreaWidget->setVisible(b); - m_ui->centralWidget->setVisible(!b); -} - -} // namespace Qt4ProjectManager diff --git a/src/plugins/qt4projectmanager/wizards/targetsetuppage.h b/src/plugins/qt4projectmanager/wizards/targetsetuppage.h deleted file mode 100644 index 73dd8a601c..0000000000 --- a/src/plugins/qt4projectmanager/wizards/targetsetuppage.h +++ /dev/null @@ -1,142 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/legal -** -** 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 TARGETSETUPPAGE_H -#define TARGETSETUPPAGE_H - -#include "../qt4projectmanager_global.h" - -#include <QString> -#include <QWizardPage> -#include <QMap> - -QT_FORWARD_DECLARE_CLASS(QSpacerItem) - -namespace Utils { class FileName; } - -namespace Core { -class Id; -} // namespace Core - -namespace ProjectExplorer { -class Kit; -class KitMatcher; -} // namespace ProjectExplorer - -namespace QtSupport { class BaseQtVersion; } - -namespace Qt4ProjectManager { -class Qt4Project; -class Qt4TargetSetupWidget; - -namespace Internal { -class ImportWidget; -class TargetSetupPageUi; -} // namespace Internal - -/// \internal -class QT4PROJECTMANAGER_EXPORT TargetSetupPage : public QWizardPage -{ - Q_OBJECT - -public: - explicit TargetSetupPage(QWidget* parent = 0); - ~TargetSetupPage(); - - /// Initializes the TargetSetupPage - /// \note The import information is gathered in initializePage(), make sure that the right proFilePath is set before - void initializePage(); - - // Call these before initializePage! - void setRequiredKitMatcher(ProjectExplorer::KitMatcher *matcher); - void setPreferredKitMatcher(ProjectExplorer::KitMatcher *matcher); - void setImportSearch(bool b); - - /// Sets whether the targetsetupage uses a scrollarea - /// to host the widgets from the factories - /// call this before \sa initializePage() - void setUseScrollArea(bool b); - - bool isComplete() const; - bool setupProject(Qt4ProjectManager::Qt4Project *project); - bool isKitSelected(Core::Id id) const; - void setKitSelected(Core::Id id, bool selected); - QList<Core::Id> selectedKits() const; - void setProFilePath(const QString &dir); - - /// Overrides the summary text of the targetsetuppage - void setNoteText(const QString &text); - void showOptionsHint(bool show); - -private slots: - void import(const Utils::FileName &path); - void handleQtUpdate(const QList<int> &add, const QList<int> &rm, const QList<int> &mod); - void handleKitAddition(ProjectExplorer::Kit *k); - void handleKitRemoval(ProjectExplorer::Kit *k); - void handleKitUpdate(ProjectExplorer::Kit *k); - void updateVisibility(); - void openOptions(); - -private: - void selectAtLeastOneKit(); - void import(const Utils::FileName &path, const bool silent); - void removeWidget(ProjectExplorer::Kit *k); - Qt4TargetSetupWidget *addWidget(ProjectExplorer::Kit *k); - - void setupImports(); - - void setupWidgets(); - void reset(); - ProjectExplorer::Kit *createTemporaryKit(QtSupport::BaseQtVersion *version, bool temporaryVersion, const Utils::FileName &parsedSpec); - void cleanKit(ProjectExplorer::Kit *k); - void makeQtPersistent(ProjectExplorer::Kit *k); - void addProject(ProjectExplorer::Kit *k, const QString &path); - void removeProject(ProjectExplorer::Kit *k, const QString &path); - - ProjectExplorer::KitMatcher *m_requiredMatcher; - ProjectExplorer::KitMatcher *m_preferredMatcher; - QLayout *m_baseLayout; - bool m_importSearch; - bool m_ignoreUpdates; - QString m_proFilePath; - QString m_defaultShadowBuildLocation; - QMap<Core::Id, Qt4TargetSetupWidget *> m_widgets; - Qt4TargetSetupWidget *m_firstWidget; - - Internal::TargetSetupPageUi *m_ui; - - Internal::ImportWidget *m_importWidget; - QSpacerItem *m_spacer; - - bool m_forceOptionHint; -}; - -} // namespace Qt4ProjectManager - -#endif // TARGETSETUPPAGE_H |