forked from qt-creator/qt-creator
QmakeProjectManager: Remove unused modules handling from wizards
Change-Id: If943fc306c8aaf7f8dccaeb4b833988e651108e6 Reviewed-by: Christian Kandeler <christian.kandeler@qt.io> Reviewed-by: Eike Ziller <eike.ziller@qt.io>
This commit is contained in:
@@ -42,7 +42,6 @@ add_qtc_plugin(QmakeProjectManager
|
||||
qmakestep.cpp qmakestep.h qmakestep.ui
|
||||
qtmodulesinfo.cpp qtmodulesinfo.h
|
||||
wizards/filespage.cpp wizards/filespage.h
|
||||
wizards/modulespage.cpp wizards/modulespage.h
|
||||
wizards/qtprojectparameters.cpp wizards/qtprojectparameters.h
|
||||
wizards/qtwizard.cpp wizards/qtwizard.h
|
||||
wizards/simpleprojectwizard.cpp wizards/simpleprojectwizard.h
|
||||
|
@@ -41,7 +41,7 @@ CustomWidgetWizardDialog::CustomWidgetWizardDialog(const Core::BaseFileWizardFac
|
||||
const QString &templateName,
|
||||
const QIcon &icon, QWidget *parent,
|
||||
const Core::WizardDialogParameters ¶meters) :
|
||||
BaseQmakeProjectWizardDialog(factory, false, parent, parameters),
|
||||
BaseQmakeProjectWizardDialog(factory, parent, parameters),
|
||||
m_widgetsPage(new CustomWidgetWidgetsWizardPage),
|
||||
m_pluginPage(new CustomWidgetPluginWizardPage)
|
||||
{
|
||||
|
@@ -19,7 +19,6 @@ HEADERS += \
|
||||
profilehighlighter.h \
|
||||
profilehoverhandler.h \
|
||||
wizards/qtprojectparameters.h \
|
||||
wizards/modulespage.h \
|
||||
wizards/filespage.h \
|
||||
wizards/qtwizard.h \
|
||||
wizards/subdirsprojectwizard.h \
|
||||
@@ -53,7 +52,6 @@ SOURCES += \
|
||||
profilehighlighter.cpp \
|
||||
profilehoverhandler.cpp \
|
||||
wizards/qtprojectparameters.cpp \
|
||||
wizards/modulespage.cpp \
|
||||
wizards/filespage.cpp \
|
||||
wizards/qtwizard.cpp \
|
||||
wizards/subdirsprojectwizard.cpp \
|
||||
|
@@ -77,7 +77,6 @@ Project {
|
||||
prefix: "wizards/"
|
||||
files: [
|
||||
"filespage.cpp", "filespage.h",
|
||||
"modulespage.cpp", "modulespage.h",
|
||||
"qtprojectparameters.cpp", "qtprojectparameters.h",
|
||||
"qtwizard.cpp", "qtwizard.h",
|
||||
"subdirsprojectwizard.cpp", "subdirsprojectwizard.h",
|
||||
|
@@ -1,119 +0,0 @@
|
||||
/****************************************************************************
|
||||
**
|
||||
** Copyright (C) 2016 The Qt Company Ltd.
|
||||
** Contact: https://www.qt.io/licensing/
|
||||
**
|
||||
** 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 The Qt Company. For licensing terms
|
||||
** and conditions see https://www.qt.io/terms-conditions. For further
|
||||
** information use the contact form at https://www.qt.io/contact-us.
|
||||
**
|
||||
** GNU General Public License Usage
|
||||
** Alternatively, this file may be used under the terms of the GNU
|
||||
** General Public License version 3 as published by the Free Software
|
||||
** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
|
||||
** included in the packaging of this file. Please review the following
|
||||
** information to ensure the GNU General Public License requirements will
|
||||
** be met: https://www.gnu.org/licenses/gpl-3.0.html.
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
#include "modulespage.h"
|
||||
|
||||
#include <utils/wizard.h>
|
||||
|
||||
#include <qmakeprojectmanager/qtmodulesinfo.h>
|
||||
|
||||
#include <QDebug>
|
||||
|
||||
#include <QCheckBox>
|
||||
#include <QLabel>
|
||||
#include <QLayout>
|
||||
#include <QWidget>
|
||||
|
||||
using namespace QmakeProjectManager::Internal;
|
||||
|
||||
ModulesPage::ModulesPage(QWidget *parent)
|
||||
: QWizardPage(parent)
|
||||
{
|
||||
setTitle(tr("Select Required Modules"));
|
||||
QLabel *label = new QLabel(tr("Select the modules you want to include in your "
|
||||
"project. The recommended modules for this project are selected by default."));
|
||||
label->setWordWrap(true);
|
||||
|
||||
auto *vlayout = new QVBoxLayout();
|
||||
vlayout->addWidget(label);
|
||||
vlayout->addItem(new QSpacerItem(0, 20));
|
||||
|
||||
auto *layout = new QGridLayout;
|
||||
|
||||
const QStringList &modulesList = QtModulesInfo::modules();
|
||||
int moduleId = 0;
|
||||
int rowsCount = (modulesList.count() + 1) / 2;
|
||||
foreach (const QString &module, modulesList) {
|
||||
QCheckBox *moduleCheckBox = new QCheckBox(QtModulesInfo::moduleName(module));
|
||||
moduleCheckBox->setToolTip(QtModulesInfo::moduleDescription(module));
|
||||
moduleCheckBox->setWhatsThis(QtModulesInfo::moduleDescription(module));
|
||||
registerField(module, moduleCheckBox);
|
||||
int row = moduleId % rowsCount;
|
||||
int column = moduleId / rowsCount;
|
||||
layout->addWidget(moduleCheckBox, row, column);
|
||||
m_moduleCheckBoxMap[module] = moduleCheckBox;
|
||||
moduleId++;
|
||||
}
|
||||
|
||||
vlayout->addLayout(layout);
|
||||
setLayout(vlayout);
|
||||
|
||||
setProperty(Utils::SHORT_TITLE_PROPERTY, tr("Modules"));
|
||||
}
|
||||
|
||||
// Return the key that goes into the Qt config line for a module
|
||||
QString ModulesPage::idOfModule(const QString &module)
|
||||
{
|
||||
const QStringList &moduleIdList = QtModulesInfo::modules();
|
||||
foreach (const QString &id, moduleIdList)
|
||||
if (QtModulesInfo::moduleName(id).startsWith(module))
|
||||
return id;
|
||||
return QString();
|
||||
}
|
||||
|
||||
QStringList ModulesPage::selectedModulesList() const
|
||||
{
|
||||
return modules(true);
|
||||
}
|
||||
|
||||
QStringList ModulesPage::deselectedModulesList() const
|
||||
{
|
||||
return modules(false);
|
||||
}
|
||||
|
||||
void ModulesPage::setModuleSelected(const QString &module, bool selected) const
|
||||
{
|
||||
QCheckBox *checkBox = m_moduleCheckBoxMap[module];
|
||||
Q_ASSERT(checkBox);
|
||||
checkBox->setCheckState(selected?Qt::Checked:Qt::Unchecked);
|
||||
}
|
||||
|
||||
void ModulesPage::setModuleEnabled(const QString &module, bool enabled) const
|
||||
{
|
||||
QCheckBox *checkBox = m_moduleCheckBoxMap[module];
|
||||
Q_ASSERT(checkBox);
|
||||
checkBox->setEnabled(enabled);
|
||||
}
|
||||
|
||||
QStringList ModulesPage::modules(bool selected) const
|
||||
{
|
||||
QStringList modules;
|
||||
foreach (const QString &module, QtModulesInfo::modules()) {
|
||||
if (selected != QtModulesInfo::moduleIsDefault(module)
|
||||
&& selected == field(module).toBool())
|
||||
modules << module;
|
||||
}
|
||||
return modules;
|
||||
}
|
@@ -1,61 +0,0 @@
|
||||
/****************************************************************************
|
||||
**
|
||||
** Copyright (C) 2016 The Qt Company Ltd.
|
||||
** Contact: https://www.qt.io/licensing/
|
||||
**
|
||||
** 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 The Qt Company. For licensing terms
|
||||
** and conditions see https://www.qt.io/terms-conditions. For further
|
||||
** information use the contact form at https://www.qt.io/contact-us.
|
||||
**
|
||||
** GNU General Public License Usage
|
||||
** Alternatively, this file may be used under the terms of the GNU
|
||||
** General Public License version 3 as published by the Free Software
|
||||
** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
|
||||
** included in the packaging of this file. Please review the following
|
||||
** information to ensure the GNU General Public License requirements will
|
||||
** be met: https://www.gnu.org/licenses/gpl-3.0.html.
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <QMap>
|
||||
#include <QStringList>
|
||||
#include <QWizard>
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
class QCheckBox;
|
||||
QT_END_NAMESPACE
|
||||
|
||||
namespace QmakeProjectManager {
|
||||
namespace Internal {
|
||||
|
||||
class ModulesPage : public QWizardPage
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit ModulesPage(QWidget* parent = nullptr);
|
||||
|
||||
QStringList selectedModulesList() const;
|
||||
QStringList deselectedModulesList() const;
|
||||
|
||||
void setModuleSelected(const QString &module, bool selected = true) const;
|
||||
void setModuleEnabled(const QString &module, bool enabled = true) const;
|
||||
|
||||
// Return the key that goes into the Qt config line for a module
|
||||
static QString idOfModule(const QString &module);
|
||||
|
||||
private:
|
||||
QMap<QString, QCheckBox*> m_moduleCheckBoxMap;
|
||||
QStringList modules(bool selected = true) const;
|
||||
};
|
||||
|
||||
} // namespace Internal
|
||||
} // namespace QmakeProjectManager
|
@@ -25,8 +25,6 @@
|
||||
|
||||
#include "qtwizard.h"
|
||||
|
||||
#include "modulespage.h"
|
||||
|
||||
#include <qmakeprojectmanager/qmakeproject.h>
|
||||
#include <qmakeprojectmanager/qmakeprojectmanager.h>
|
||||
#include <qmakeprojectmanager/qmakeprojectmanagerconstants.h>
|
||||
@@ -124,8 +122,7 @@ CustomQmakeProjectWizard::CustomQmakeProjectWizard() = default;
|
||||
Core::BaseFileWizard *CustomQmakeProjectWizard::create(QWidget *parent,
|
||||
const Core::WizardDialogParameters ¶meters) const
|
||||
{
|
||||
auto *wizard = new BaseQmakeProjectWizardDialog(this, false, parent,
|
||||
parameters);
|
||||
auto *wizard = new BaseQmakeProjectWizardDialog(this, parent, parameters);
|
||||
|
||||
if (!parameters.extraValues().contains(QLatin1String(ProjectExplorer::Constants::PROJECT_KIT_IDS)))
|
||||
wizard->addTargetSetupPage(targetPageId);
|
||||
@@ -143,7 +140,6 @@ bool CustomQmakeProjectWizard::postGenerateFiles(const QWizard *w, const Core::G
|
||||
// ----------------- BaseQmakeProjectWizardDialog
|
||||
BaseQmakeProjectWizardDialog::BaseQmakeProjectWizardDialog(
|
||||
const Core::BaseFileWizardFactory *factory,
|
||||
bool showModulesPage,
|
||||
QWidget *parent,
|
||||
const Core::WizardDialogParameters ¶meters)
|
||||
: ProjectExplorer::BaseProjectWizardDialog(factory, parent, parameters)
|
||||
@@ -153,12 +149,12 @@ BaseQmakeProjectWizardDialog::BaseQmakeProjectWizardDialog(
|
||||
.toStringList(),
|
||||
&Core::Id::fromString);
|
||||
|
||||
init(showModulesPage);
|
||||
connect(this, &BaseProjectWizardDialog::projectParametersChanged,
|
||||
this, &BaseQmakeProjectWizardDialog::generateProfileName);
|
||||
}
|
||||
|
||||
BaseQmakeProjectWizardDialog::BaseQmakeProjectWizardDialog(
|
||||
const Core::BaseFileWizardFactory *factory,
|
||||
bool showModulesPage,
|
||||
Utils::ProjectIntroPage *introPage,
|
||||
int introId,
|
||||
QWidget *parent,
|
||||
@@ -169,35 +165,14 @@ BaseQmakeProjectWizardDialog::BaseQmakeProjectWizardDialog(
|
||||
.value(ProjectExplorer::Constants::PROJECT_KIT_IDS)
|
||||
.toStringList(),
|
||||
&Core::Id::fromString);
|
||||
init(showModulesPage);
|
||||
connect(this, &BaseProjectWizardDialog::projectParametersChanged,
|
||||
this, &BaseQmakeProjectWizardDialog::generateProfileName);
|
||||
}
|
||||
|
||||
BaseQmakeProjectWizardDialog::~BaseQmakeProjectWizardDialog()
|
||||
{
|
||||
if (m_targetSetupPage && !m_targetSetupPage->parent())
|
||||
delete m_targetSetupPage;
|
||||
if (m_modulesPage && !m_modulesPage->parent())
|
||||
delete m_modulesPage;
|
||||
}
|
||||
|
||||
void BaseQmakeProjectWizardDialog::init(bool showModulesPage)
|
||||
{
|
||||
if (showModulesPage)
|
||||
m_modulesPage = new ModulesPage;
|
||||
connect(this, &BaseProjectWizardDialog::projectParametersChanged,
|
||||
this, &BaseQmakeProjectWizardDialog::generateProfileName);
|
||||
}
|
||||
|
||||
int BaseQmakeProjectWizardDialog::addModulesPage(int id)
|
||||
{
|
||||
if (!m_modulesPage)
|
||||
return -1;
|
||||
if (id >= 0) {
|
||||
setPage(id, m_modulesPage);
|
||||
return id;
|
||||
}
|
||||
const int newId = addPage(m_modulesPage);
|
||||
return newId;
|
||||
}
|
||||
|
||||
int BaseQmakeProjectWizardDialog::addTargetSetupPage(int id)
|
||||
@@ -221,40 +196,6 @@ int BaseQmakeProjectWizardDialog::addTargetSetupPage(int id)
|
||||
return id;
|
||||
}
|
||||
|
||||
QStringList BaseQmakeProjectWizardDialog::selectedModulesList() const
|
||||
{
|
||||
return m_modulesPage ? m_modulesPage->selectedModulesList() : m_selectedModules;
|
||||
}
|
||||
|
||||
void BaseQmakeProjectWizardDialog::setSelectedModules(const QString &modules, bool lock)
|
||||
{
|
||||
const QStringList modulesList = modules.split(QLatin1Char(' '));
|
||||
if (m_modulesPage) {
|
||||
for (const QString &module : modulesList) {
|
||||
m_modulesPage->setModuleSelected(module, true);
|
||||
m_modulesPage->setModuleEnabled(module, !lock);
|
||||
}
|
||||
} else {
|
||||
m_selectedModules = modulesList;
|
||||
}
|
||||
}
|
||||
|
||||
QStringList BaseQmakeProjectWizardDialog::deselectedModulesList() const
|
||||
{
|
||||
return m_modulesPage ? m_modulesPage->deselectedModulesList() : m_deselectedModules;
|
||||
}
|
||||
|
||||
void BaseQmakeProjectWizardDialog::setDeselectedModules(const QString &modules)
|
||||
{
|
||||
const QStringList modulesList = modules.split(QLatin1Char(' '));
|
||||
if (m_modulesPage) {
|
||||
for (const QString &module : modulesList)
|
||||
m_modulesPage->setModuleSelected(module, false);
|
||||
} else {
|
||||
m_deselectedModules = modulesList;
|
||||
}
|
||||
}
|
||||
|
||||
bool BaseQmakeProjectWizardDialog::writeUserFile(const QString &proFileName) const
|
||||
{
|
||||
if (!m_targetSetupPage)
|
||||
|
@@ -40,8 +40,6 @@ class QmakeProject;
|
||||
|
||||
namespace Internal {
|
||||
|
||||
class ModulesPage;
|
||||
|
||||
/* Base class for wizard creating Qt projects using QtProjectParameters.
|
||||
* To implement a project wizard, overwrite:
|
||||
* - createWizardDialog() to create up the dialog
|
||||
@@ -104,37 +102,24 @@ class BaseQmakeProjectWizardDialog : public ProjectExplorer::BaseProjectWizardDi
|
||||
Q_OBJECT
|
||||
protected:
|
||||
explicit BaseQmakeProjectWizardDialog(const Core::BaseFileWizardFactory *factory,
|
||||
bool showModulesPage,
|
||||
Utils::ProjectIntroPage *introPage,
|
||||
int introId, QWidget *parent,
|
||||
const Core::WizardDialogParameters ¶meters);
|
||||
public:
|
||||
explicit BaseQmakeProjectWizardDialog(const Core::BaseFileWizardFactory *factory,
|
||||
bool showModulesPage, QWidget *parent,
|
||||
QWidget *parent,
|
||||
const Core::WizardDialogParameters ¶meters);
|
||||
~BaseQmakeProjectWizardDialog() override;
|
||||
|
||||
int addModulesPage(int id = -1);
|
||||
int addTargetSetupPage(int id = -1);
|
||||
|
||||
QStringList selectedModulesList() const;
|
||||
void setSelectedModules(const QString &, bool lock = false);
|
||||
|
||||
QStringList deselectedModulesList() const;
|
||||
void setDeselectedModules(const QString &);
|
||||
|
||||
bool writeUserFile(const QString &proFileName) const;
|
||||
QList<Core::Id> selectedKits() const;
|
||||
|
||||
private:
|
||||
void generateProfileName(const QString &name, const QString &path);
|
||||
|
||||
inline void init(bool showModulesPage);
|
||||
|
||||
ModulesPage *m_modulesPage = nullptr;
|
||||
ProjectExplorer::TargetSetupPage *m_targetSetupPage = nullptr;
|
||||
QStringList m_selectedModules;
|
||||
QStringList m_deselectedModules;
|
||||
QList<Core::Id> m_profileIds;
|
||||
};
|
||||
|
||||
|
@@ -33,7 +33,7 @@ SubdirsProjectWizardDialog::SubdirsProjectWizardDialog(const Core::BaseFileWizar
|
||||
const QString &templateName,
|
||||
const QIcon &icon, QWidget *parent,
|
||||
const Core::WizardDialogParameters ¶meters) :
|
||||
BaseQmakeProjectWizardDialog(factory, false, parent, parameters)
|
||||
BaseQmakeProjectWizardDialog(factory, parent, parameters)
|
||||
{
|
||||
setWindowIcon(icon);
|
||||
setWindowTitle(templateName);
|
||||
|
Reference in New Issue
Block a user