Commit 22ffadc1 authored by Friedemann Kleint's avatar Friedemann Kleint
Browse files

Add Qt 5 support to Widget Gui wizard.



- Add flags to the wizards' QtProjectParameters, introduce
  flag to add widgets if required.
- Change the modules to be lists for easier checking.

Change-Id: I49a000565ffea1a1593cf20a84b240f5c7458ae3
Reviewed-by: default avatarThomas Hartmann <Thomas.Hartmann@nokia.com>
parent 6decffac
......@@ -68,8 +68,8 @@ QtProjectParameters ConsoleAppWizardDialog::parameters() const
rc.fileName = projectName();
rc.path = path();
rc.selectedModules = selectedModules();
rc.deselectedModules = deselectedModules();
rc.selectedModules = selectedModulesList();
rc.deselectedModules = deselectedModulesList();
return rc;
}
......
......@@ -98,10 +98,11 @@ QtProjectParameters GuiAppWizardDialog::projectParameters() const
{
QtProjectParameters rc;
rc.type = QtProjectParameters::GuiApp;
rc.flags |= QtProjectParameters::WidgetsRequiredFlag;
rc.fileName = projectName();
rc.path = path();
rc.selectedModules = selectedModules();
rc.deselectedModules = deselectedModules();
rc.selectedModules = selectedModulesList();
rc.deselectedModules = deselectedModulesList();
return rc;
}
......
......@@ -85,9 +85,9 @@ static const PluginBaseClasses *findPluginBaseClass(const QString &name)
// return dependencies of a plugin as a line ready for the 'QT=' line in a pro
// file
static QString pluginDependencies(const PluginBaseClasses *plb)
static QStringList pluginDependencies(const PluginBaseClasses *plb)
{
QString dependencies;
QStringList dependencies;
const QChar blank = QLatin1Char(' ');
// Find the module names and convert to ids
QStringList pluginModules= plb->dependentModules ?
......@@ -95,9 +95,7 @@ static QString pluginDependencies(const PluginBaseClasses *plb)
QStringList();
pluginModules.push_back(QLatin1String(plb->module));
foreach (const QString &module, pluginModules) {
if (!dependencies.isEmpty())
dependencies += blank;
dependencies += ModulesPage::idOfModule(module);
dependencies.append(ModulesPage::idOfModule(module));
}
return dependencies;
}
......@@ -303,8 +301,8 @@ QtProjectParameters LibraryWizardDialog::parameters() const
}
} else {
// Modules from modules page
rc.selectedModules = selectedModules();
rc.deselectedModules = deselectedModules();
rc.selectedModules = selectedModulesList();
rc.deselectedModules = deselectedModulesList();
}
return rc;
}
......
......@@ -91,12 +91,12 @@ QString ModulesPage::idOfModule(const QString &module)
return QString();
}
QString ModulesPage::selectedModules() const
QStringList ModulesPage::selectedModulesList() const
{
return modules(true);
}
QString ModulesPage::deselectedModules() const
QStringList ModulesPage::deselectedModulesList() const
{
return modules(false);
}
......@@ -115,7 +115,7 @@ void ModulesPage::setModuleEnabled(const QString &module, bool enabled) const
checkBox->setEnabled(enabled);
}
QString ModulesPage::modules(bool selected) const
QStringList ModulesPage::modules(bool selected) const
{
QStringList modules;
foreach (const QString &module, QtModulesInfo::modules()) {
......@@ -123,5 +123,5 @@ QString ModulesPage::modules(bool selected) const
&& selected == field(module).toBool())
modules << module;
}
return modules.join(QString(QLatin1Char(' ')));
return modules;
}
......@@ -34,6 +34,7 @@
#define MODULESPAGE_H
#include <QtCore/QMap>
#include <QtCore/QStringList>
#include <QtGui/QWizard>
QT_BEGIN_NAMESPACE
......@@ -49,8 +50,10 @@ class ModulesPage : public QWizardPage
public:
explicit ModulesPage(QWidget* parent = 0);
QString selectedModules() const;
QString deselectedModules() const;
QStringList selectedModulesList() const;
QStringList deselectedModulesList() const;
void setModuleSelected(const QString &module, bool selected = true) const;
void setModuleEnabled(const QString &module, bool enabled = true) const;
......@@ -59,7 +62,7 @@ public:
private:
QMap<QString, QCheckBox*> m_moduleCheckBoxMap;
QString modules(bool selected = true) const;
QStringList modules(bool selected = true) const;
};
} // namespace Internal
......
......@@ -44,7 +44,7 @@ namespace Internal {
// ----------- QtProjectParameters
QtProjectParameters::QtProjectParameters()
: type(ConsoleApp)
: type(ConsoleApp), flags(WidgetsRequiredFlag), qtVersionSupport(SupportQt4And5)
{
}
......@@ -57,12 +57,37 @@ QString QtProjectParameters::projectPath() const
return rc;
}
// Write out a QT module line.
static inline void writeQtModulesList(QTextStream &str,
const QStringList &modules,
char op ='+')
{
if (const int size = modules.size()) {
str << "QT " << op << "= ";
for (int i =0; i < size; ++i) {
if (i)
str << ' ';
str << modules.at(i);
}
str << "\n\n";
}
}
void QtProjectParameters::writeProFile(QTextStream &str) const
{
if (!selectedModules.isEmpty())
str << "QT += " << selectedModules << "\n\n";
if (!deselectedModules.isEmpty())
str << "QT -= " << deselectedModules << "\n\n";
QStringList allSelectedModules = selectedModules;
// Handling of widgets module.
const bool addWidgetsModule =
(flags & WidgetsRequiredFlag) && qtVersionSupport != SupportQt4Only
&& !allSelectedModules.contains(QLatin1String("widgets"));
if (addWidgetsModule && qtVersionSupport == SupportQt5Only)
allSelectedModules.append(QLatin1String("widgets"));
writeQtModulesList(str, allSelectedModules, '+');
writeQtModulesList(str, deselectedModules, '-');
if (addWidgetsModule && qtVersionSupport == SupportQt4And5)
str << "greaterThan(QT_MAJOR_VERSION, 4): QT += widgets\n\n";
const QString &effectiveTarget = target.isEmpty() ? fileName : target;
if (!effectiveTarget.isEmpty())
str << "TARGET = " << effectiveTarget << '\n';
......
......@@ -51,6 +51,8 @@ QString createMacro(const QString &name, const QString &suffix);
struct QtProjectParameters {
enum Type { ConsoleApp, GuiApp, StaticLibrary, SharedLibrary, Qt4Plugin, EmptyProject };
enum QtVersionSupport { SupportQt4And5, SupportQt4Only, SupportQt5Only };
enum Flags { WidgetsRequiredFlag = 0x1 };
QtProjectParameters();
// Return project path as "path/name"
......@@ -64,11 +66,13 @@ struct QtProjectParameters {
static QString libraryMacro(const QString &projectName);
Type type;
unsigned flags;
QtVersionSupport qtVersionSupport;
QString fileName;
QString target;
QString path;
QString selectedModules;
QString deselectedModules;
QStringList selectedModules;
QStringList deselectedModules;
QString targetDirectory;
};
......
......@@ -260,35 +260,37 @@ int BaseQt4ProjectWizardDialog::addTargetSetupPage(QSet<QString> targets, bool m
return id;
}
QString BaseQt4ProjectWizardDialog::selectedModules() const
QStringList BaseQt4ProjectWizardDialog::selectedModulesList() const
{
return m_modulesPage ? m_modulesPage->selectedModules() : m_selectedModules;
return m_modulesPage ? m_modulesPage->selectedModulesList() : m_selectedModules;
}
void BaseQt4ProjectWizardDialog::setSelectedModules(const QString &modules, bool lock)
{
const QStringList modulesList = modules.split(QLatin1Char(' '));
if (m_modulesPage) {
foreach(const QString &module, modules.split(QLatin1Char(' '))) {
foreach (const QString &module, modulesList) {
m_modulesPage->setModuleSelected(module, true);
m_modulesPage->setModuleEnabled(module, !lock);
}
} else {
m_selectedModules = modules;
m_selectedModules = modulesList;
}
}
QString BaseQt4ProjectWizardDialog::deselectedModules() const
QStringList BaseQt4ProjectWizardDialog::deselectedModulesList() const
{
return m_modulesPage ? m_modulesPage->deselectedModules() : m_deselectedModules;
return m_modulesPage ? m_modulesPage->deselectedModulesList() : m_deselectedModules;
}
void BaseQt4ProjectWizardDialog::setDeselectedModules(const QString &modules)
{
const QStringList modulesList = modules.split(QLatin1Char(' '));
if (m_modulesPage) {
foreach(const QString &module, modules.split(QLatin1Char(' ')))
foreach (const QString &module, modulesList)
m_modulesPage->setModuleSelected(module, false);
} else {
m_deselectedModules = modules;
m_deselectedModules = modulesList;
}
}
......
......@@ -134,10 +134,10 @@ public:
static QSet<QString> desktopTarget();
QString selectedModules() const;
QStringList selectedModulesList() const;
void setSelectedModules(const QString &, bool lock = false);
QString deselectedModules() const;
QStringList deselectedModulesList() const;
void setDeselectedModules(const QString &);
bool writeUserFile(const QString &proFileName) const;
......@@ -152,8 +152,8 @@ private:
ModulesPage *m_modulesPage;
TargetSetupPage *m_targetSetupPage;
QString m_selectedModules;
QString m_deselectedModules;
QStringList m_selectedModules;
QStringList m_deselectedModules;
QSet<QString> m_targets;
};
......
......@@ -91,8 +91,8 @@ QtProjectParameters TestWizardDialog::projectParameters() const
rc.path = path();
// Name binary "tst_xx" after the main source
rc.target = QFileInfo(m_testPage->sourcefileName()).baseName();
rc.selectedModules = selectedModules();
rc.deselectedModules = deselectedModules();
rc.selectedModules = selectedModulesList();
rc.deselectedModules = deselectedModulesList();
return rc;
}
......
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