diff options
author | Tobias Hunger <tobias.hunger@digia.com> | 2014-07-18 15:47:20 +0200 |
---|---|---|
committer | Tobias Hunger <tobias.hunger@digia.com> | 2014-07-24 13:29:41 +0200 |
commit | ff33e989c725da9c3a01668be28d023f9c0dc9a4 (patch) | |
tree | 335977ce142aaa2bfeea4459afc8130fd356b869 | |
parent | f7e8acbd09faed40dbcc13a5e4a7956e270bd6dd (diff) |
Move code from Designer to QtSupport
* Move settings pages for Qt code generation from Designer to QtSupport
plugin.
* Make Designer plugin depend on QtSupport
Change-Id: I222dac0a648c194ce46fd9f8bbb09c70db851bbd
Reviewed-by: Daniel Teske <daniel.teske@digia.com>
16 files changed, 244 insertions, 154 deletions
diff --git a/src/plugins/designer/cpp/cpp.pri b/src/plugins/designer/cpp/cpp.pri index 690ca7fc9f..1527c50cde 100644 --- a/src/plugins/designer/cpp/cpp.pri +++ b/src/plugins/designer/cpp/cpp.pri @@ -3,14 +3,11 @@ DEFINES+=CPP_ENABLED HEADERS+=$$PWD/formclasswizardpage.h \ $$PWD/formclasswizarddialog.h \ $$PWD/formclasswizard.h \ - $$PWD/formclasswizardparameters.h \ - $$PWD/cppsettingspage.h + $$PWD/formclasswizardparameters.h SOURCES+=$$PWD/formclasswizardpage.cpp \ $$PWD/formclasswizarddialog.cpp \ $$PWD/formclasswizard.cpp \ - $$PWD/formclasswizardparameters.cpp \ - $$PWD/cppsettingspage.cpp + $$PWD/formclasswizardparameters.cpp -FORMS+=$$PWD/formclasswizardpage.ui \ -$$PWD/cppsettingspagewidget.ui +FORMS+=$$PWD/formclasswizardpage.ui diff --git a/src/plugins/designer/designer.qbs b/src/plugins/designer/designer.qbs index 433e63d88b..8cef355cf8 100644 --- a/src/plugins/designer/designer.qbs +++ b/src/plugins/designer/designer.qbs @@ -15,6 +15,7 @@ QtcPlugin { Depends { name: "ResourceEditor" } Depends { name: "TextEditor" } Depends { name: "ProjectExplorer" } + Depends { name: "QtSupport" } cpp.defines: base.concat(["CPP_ENABLED"]) cpp.includePaths: base.concat([ @@ -66,8 +67,6 @@ QtcPlugin { name: "cpp" prefix: "cpp/" files: [ - "cppsettingspage.cpp", "cppsettingspage.h", - "cppsettingspagewidget.ui", "formclasswizard.cpp", "formclasswizard.h", "formclasswizarddialog.cpp", "formclasswizarddialog.h", "formclasswizardpage.cpp", "formclasswizardpage.h", "formclasswizardpage.ui", diff --git a/src/plugins/designer/designer_dependencies.pri b/src/plugins/designer/designer_dependencies.pri index b4bb0d46b4..ef981aa7d0 100644 --- a/src/plugins/designer/designer_dependencies.pri +++ b/src/plugins/designer/designer_dependencies.pri @@ -7,5 +7,6 @@ QTC_PLUGIN_DEPENDS += \ resourceeditor\ cpptools \ projectexplorer \ + qtsupport \ texteditor \ coreplugin diff --git a/src/plugins/designer/designerconstants.h b/src/plugins/designer/designerconstants.h index 205abf0566..60683fd654 100644 --- a/src/plugins/designer/designerconstants.h +++ b/src/plugins/designer/designerconstants.h @@ -43,8 +43,6 @@ const char C_DESIGNER_XML_DISPLAY_NAME[] = QT_TRANSLATE_NOOP("Designer", "Form const char SETTINGS_CATEGORY[] = "P.Designer"; const char SETTINGS_CATEGORY_ICON[] = ":/core/images/category_design.png"; const char SETTINGS_TR_CATEGORY[] = QT_TRANSLATE_NOOP("Designer", "Designer"); -const char SETTINGS_CPP_SETTINGS_ID[] = "Class Generation"; -const char SETTINGS_CPP_SETTINGS_NAME[] = QT_TRANSLATE_NOOP("Designer", "Class Generation"); // Context const char C_FORMEDITOR[] = "FormEditor.FormEditor"; diff --git a/src/plugins/designer/formeditorplugin.cpp b/src/plugins/designer/formeditorplugin.cpp index fecadb23e5..c4d284a267 100644 --- a/src/plugins/designer/formeditorplugin.cpp +++ b/src/plugins/designer/formeditorplugin.cpp @@ -34,7 +34,6 @@ #ifdef CPP_ENABLED # include "cpp/formclasswizard.h" -# include "cpp/cppsettingspage.h" #endif #include "settingspage.h" @@ -49,6 +48,7 @@ #include <coreplugin/designmode.h> #include <cpptools/cpptoolsconstants.h> +#include <QApplication> #include <QDebug> #include <QLibraryInfo> #include <QTranslator> @@ -146,8 +146,6 @@ void FormEditorPlugin::initializeTemplates() wizard->setDescription(tr("Creates a Qt Designer form along with a matching class (C++ header and source file) " "for implementation purposes. You can add the form and class to an existing Qt Widget Project.")); addAutoReleasedObject(wizard); - - addAutoReleasedObject(new CppSettingsPage); #endif } diff --git a/src/plugins/designer/qtdesignerformclasscodegenerator.cpp b/src/plugins/designer/qtdesignerformclasscodegenerator.cpp index 57c589528b..0b9ddf8dd8 100644 --- a/src/plugins/designer/qtdesignerformclasscodegenerator.cpp +++ b/src/plugins/designer/qtdesignerformclasscodegenerator.cpp @@ -34,6 +34,7 @@ #include <utils/codegeneration.h> #include <coreplugin/icore.h> #include <cpptools/abstracteditorsupport.h> +#include <qtsupport/codegensettings.h> #include <QTextStream> #include <QSettings> @@ -43,69 +44,22 @@ static const char uiMemberC[] = "ui"; static const char uiNamespaceC[] = "Ui"; -static const char formClassWizardPageGroupC[] = "FormClassWizardPage"; -static const char translationKeyC[] = "RetranslationSupport"; -static const char embeddingModeKeyC[] = "Embedding"; - -// TODO: These 2 are general coding convention settings and -// should go to CppTools... -static const char includeQtModuleKeyC[] = "IncludeQtModule"; -static const char addQtVersionCheckKeyC[] = "AddQtVersionCheck"; - -static const bool retranslationSupportDefault = false; - namespace Designer { namespace Internal { -FormClassWizardGenerationParameters::FormClassWizardGenerationParameters() : - embedding(PointerAggregatedUiClass), - retranslationSupport(retranslationSupportDefault), - includeQtModule(false), - addQtVersionCheck(false) -{ -} - -void FormClassWizardGenerationParameters::fromSettings(const QSettings *settings) -{ - QString group = QLatin1String(formClassWizardPageGroupC) + QLatin1Char('/'); - - retranslationSupport = settings->value(group + QLatin1String(translationKeyC), retranslationSupportDefault).toBool(); - embedding = static_cast<UiClassEmbedding>(settings->value(group + QLatin1String(embeddingModeKeyC), int(PointerAggregatedUiClass)).toInt()); - includeQtModule = settings->value(group + QLatin1String(includeQtModuleKeyC), false).toBool(); - addQtVersionCheck = settings->value(group + QLatin1String(addQtVersionCheckKeyC), false).toBool(); -} - -void FormClassWizardGenerationParameters::toSettings(QSettings *settings) const -{ - settings->beginGroup(QLatin1String(formClassWizardPageGroupC)); - settings->setValue(QLatin1String(translationKeyC), retranslationSupport); - settings->setValue(QLatin1String(embeddingModeKeyC), embedding); - settings->setValue(QLatin1String(includeQtModuleKeyC), includeQtModule); - settings->setValue(QLatin1String(addQtVersionCheckKeyC), addQtVersionCheck); - settings->endGroup(); -} - -bool FormClassWizardGenerationParameters::equals(const FormClassWizardGenerationParameters &rhs) const -{ - return embedding == rhs.embedding - && retranslationSupport == rhs.retranslationSupport - && includeQtModule == rhs.includeQtModule - && addQtVersionCheck == rhs.addQtVersionCheck; -} - // Generation code // Write out how to access the Ui class in the source code. -static inline void writeUiMemberAccess(const FormClassWizardGenerationParameters &fp, QTextStream &str) +static inline void writeUiMemberAccess(const QtSupport::CodeGenSettings &fp, QTextStream &str) { switch (fp.embedding) { - case PointerAggregatedUiClass: + case QtSupport::CodeGenSettings::PointerAggregatedUiClass: str << uiMemberC << "->"; break; - case AggregatedUiClass: + case QtSupport::CodeGenSettings::AggregatedUiClass: str << uiMemberC << '.'; break; - case InheritedUiClass: + case QtSupport::CodeGenSettings::InheritedUiClass: break; } } @@ -115,7 +69,7 @@ static inline void writeUiMemberAccess(const FormClassWizardGenerationParameters bool QtDesignerFormClassCodeGenerator::generateCpp(const FormClassWizardParameters ¶meters, QString *header, QString *source, int indentation) { - Internal::FormClassWizardGenerationParameters generationParameters; + QtSupport::CodeGenSettings generationParameters; generationParameters.fromSettings(Core::ICore::settings()); const QString indent = QString(indentation, QLatin1Char(' ')); @@ -158,7 +112,7 @@ bool QtDesignerFormClassCodeGenerator::generateCpp(const FormClassWizardParamete << "\n#define " << guard << '\n' << '\n'; // Include 'ui_' - if (generationParameters.embedding != Internal::PointerAggregatedUiClass) { + if (generationParameters.embedding != QtSupport::CodeGenSettings::PointerAggregatedUiClass) { Utils::writeIncludeFileDirective(uiInclude, false, headerStr); } else { // Todo: Can we obtain the header from the code model for custom widgets? @@ -184,7 +138,7 @@ bool QtDesignerFormClassCodeGenerator::generateCpp(const FormClassWizardParamete headerStr); // Forward-declare the UI class - if (generationParameters.embedding == Internal::PointerAggregatedUiClass) { + if (generationParameters.embedding == QtSupport::CodeGenSettings::PointerAggregatedUiClass) { headerStr << '\n' << namespaceIndent << "namespace " << uiNamespaceC << " {\n" << namespaceIndent << indent << "class " << Internal::FormTemplateWizardPage::stripNamespaces(uiClassName) << ";\n" @@ -194,22 +148,22 @@ bool QtDesignerFormClassCodeGenerator::generateCpp(const FormClassWizardParamete // Class declaration headerStr << '\n' << namespaceIndent << "class " << unqualifiedClassName << " : public " << formBaseClass; - if (generationParameters.embedding == Internal::InheritedUiClass) + if (generationParameters.embedding == QtSupport::CodeGenSettings::InheritedUiClass) headerStr << ", private " << uiClassName; headerStr << "\n{\n" << namespaceIndent << indent << "Q_OBJECT\n\n" << namespaceIndent << "public:\n" << namespaceIndent << indent << "explicit " << unqualifiedClassName << "(QWidget *parent = 0);\n"; - if (generationParameters.embedding == Internal::PointerAggregatedUiClass) + if (generationParameters.embedding == QtSupport::CodeGenSettings::PointerAggregatedUiClass) headerStr << namespaceIndent << indent << "~" << unqualifiedClassName << "();\n"; // retranslation if (generationParameters.retranslationSupport) headerStr << '\n' << namespaceIndent << "protected:\n" << namespaceIndent << indent << "void changeEvent(QEvent *e);\n"; // Member variable - if (generationParameters.embedding != Internal::InheritedUiClass) { + if (generationParameters.embedding != QtSupport::CodeGenSettings::InheritedUiClass) { headerStr << '\n' << namespaceIndent << "private:\n" << namespaceIndent << indent << uiClassName << ' '; - if (generationParameters.embedding == Internal::PointerAggregatedUiClass) + if (generationParameters.embedding == QtSupport::CodeGenSettings::PointerAggregatedUiClass) headerStr << '*'; headerStr << uiMemberC << ";\n"; } @@ -221,20 +175,20 @@ bool QtDesignerFormClassCodeGenerator::generateCpp(const FormClassWizardParamete QTextStream sourceStr(source); sourceStr << sourceLicense; Utils::writeIncludeFileDirective(parameters.headerFile, false, sourceStr); - if (generationParameters.embedding == Internal::PointerAggregatedUiClass) + if (generationParameters.embedding == QtSupport::CodeGenSettings::PointerAggregatedUiClass) Utils::writeIncludeFileDirective(uiInclude, false, sourceStr); // NameSpaces( Utils::writeOpeningNameSpaces(namespaceList, QString(), sourceStr); // Constructor with setupUi sourceStr << '\n' << namespaceIndent << unqualifiedClassName << "::" << unqualifiedClassName << "(QWidget *parent) :\n" << namespaceIndent << indent << formBaseClass << "(parent)"; - if (generationParameters.embedding == Internal::PointerAggregatedUiClass) + if (generationParameters.embedding == QtSupport::CodeGenSettings::PointerAggregatedUiClass) sourceStr << ",\n" << namespaceIndent << indent << uiMemberC << "(new " << uiClassName << ")"; sourceStr << '\n' << namespaceIndent << "{\n" << namespaceIndent << indent; - writeUiMemberAccess(generationParameters, sourceStr); + Internal::writeUiMemberAccess(generationParameters, sourceStr); sourceStr << "setupUi(this);\n" << namespaceIndent << "}\n"; // Deleting destructor for ptr - if (generationParameters.embedding == Internal::PointerAggregatedUiClass) { + if (generationParameters.embedding == QtSupport::CodeGenSettings::PointerAggregatedUiClass) { sourceStr << '\n' << namespaceIndent << unqualifiedClassName << "::~" << unqualifiedClassName << "()\n" << namespaceIndent << "{\n" << namespaceIndent << indent << "delete " << uiMemberC << ";\n" @@ -247,7 +201,7 @@ bool QtDesignerFormClassCodeGenerator::generateCpp(const FormClassWizardParamete << namespaceIndent << indent << formBaseClass << "::changeEvent(e);\n" << namespaceIndent << indent << "switch (e->type()) {\n" << namespaceIndent << indent << "case QEvent::LanguageChange:\n" << namespaceIndent << indent << indent; - writeUiMemberAccess(generationParameters, sourceStr); + Internal::writeUiMemberAccess(generationParameters, sourceStr); sourceStr << "retranslateUi(this);\n" << namespaceIndent << indent << indent << "break;\n" << namespaceIndent << indent << "default:\n" diff --git a/src/plugins/designer/qtdesignerformclasscodegenerator.h b/src/plugins/designer/qtdesignerformclasscodegenerator.h index 168d54e03e..aa71301ac7 100644 --- a/src/plugins/designer/qtdesignerformclasscodegenerator.h +++ b/src/plugins/designer/qtdesignerformclasscodegenerator.h @@ -40,35 +40,6 @@ QT_END_NAMESPACE namespace Designer { class FormClassWizardParameters; -namespace Internal { - -// How to embed the Ui::Form class. -enum UiClassEmbedding -{ - PointerAggregatedUiClass, // "Ui::Form *m_ui"; - AggregatedUiClass, // "Ui::Form m_ui"; - InheritedUiClass // "...private Ui::Form..." -}; - -// Parameters influencing the code generation to be used in settings page. -struct FormClassWizardGenerationParameters -{ - FormClassWizardGenerationParameters(); - bool equals(const FormClassWizardGenerationParameters &rhs) const; - - void fromSettings(const QSettings *); - void toSettings(QSettings *) const; - - UiClassEmbedding embedding; - bool retranslationSupport; // Add handling for language change events - bool includeQtModule; // Include "<QtGui/[Class]>" or just "<[Class]>" - bool addQtVersionCheck; // Include #ifdef when using "#include <QtGui/..." -}; - -inline bool operator==(const FormClassWizardGenerationParameters &p1, const FormClassWizardGenerationParameters &p2) { return p1.equals(p2); } -inline bool operator!=(const FormClassWizardGenerationParameters &p1, const FormClassWizardGenerationParameters &p2) { return !p1.equals(p2); } - -} // namespace Internal // Publicly registered service to generate the code for a form class // (See PluginManager::Invoke) to be accessed by Qt4ProjectManager. diff --git a/src/plugins/qtsupport/codegensettings.cpp b/src/plugins/qtsupport/codegensettings.cpp new file mode 100644 index 0000000000..60c1cfbec6 --- /dev/null +++ b/src/plugins/qtsupport/codegensettings.cpp @@ -0,0 +1,84 @@ +/**************************************************************************** +** +** Copyright (C) 2014 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 "codegensettings.h" + +#include <coreplugin/icore.h> + +#include <QSettings> + +static const char CODE_GEN_GROUP[] = "FormClassWizardPage"; +static const char TRANSLATION_KEY[] = "RetranslationSupport"; +static const char EMBEDDING_KEY[] = "Embedding"; +static const char INCLUDE_QT_MODULE_KEY[] = "IncludeQtModule"; +static const char ADD_QT_VERSION_CHECK_KEY[] = "AddQtVersionCheck"; + +static const bool retranslationSupportDefault = false; + +namespace QtSupport { + +CodeGenSettings::CodeGenSettings() : + embedding(PointerAggregatedUiClass), + retranslationSupport(retranslationSupportDefault), + includeQtModule(false), + addQtVersionCheck(false) +{ + +} + +bool CodeGenSettings::equals(const CodeGenSettings &rhs) const +{ + return embedding == rhs.embedding + && retranslationSupport == rhs.retranslationSupport + && includeQtModule == rhs.includeQtModule + && addQtVersionCheck == rhs.addQtVersionCheck; +} + +void CodeGenSettings::fromSettings(const QSettings *settings) +{ + QString group = QLatin1String(CODE_GEN_GROUP) + QLatin1Char('/'); + + retranslationSupport = settings->value(group + QLatin1String(TRANSLATION_KEY), retranslationSupportDefault).toBool(); + embedding = static_cast<UiClassEmbedding>(settings->value(group + QLatin1String(EMBEDDING_KEY), int(PointerAggregatedUiClass)).toInt()); + includeQtModule = settings->value(group + QLatin1String(INCLUDE_QT_MODULE_KEY), false).toBool(); + addQtVersionCheck = settings->value(group + QLatin1String(ADD_QT_VERSION_CHECK_KEY), false).toBool(); +} + +void CodeGenSettings::toSettings(QSettings *settings) const +{ + settings->beginGroup(QLatin1String(CODE_GEN_GROUP)); + settings->setValue(QLatin1String(TRANSLATION_KEY), retranslationSupport); + settings->setValue(QLatin1String(EMBEDDING_KEY), embedding); + settings->setValue(QLatin1String(INCLUDE_QT_MODULE_KEY), includeQtModule); + settings->setValue(QLatin1String(ADD_QT_VERSION_CHECK_KEY), addQtVersionCheck); + settings->endGroup(); + +} + +} // namespace QtSupport diff --git a/src/plugins/qtsupport/codegensettings.h b/src/plugins/qtsupport/codegensettings.h new file mode 100644 index 0000000000..6c68ecc9da --- /dev/null +++ b/src/plugins/qtsupport/codegensettings.h @@ -0,0 +1,67 @@ +/**************************************************************************** +** +** Copyright (C) 2014 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 CODEGENSETTINGS_H +#define CODEGENSETTINGS_H + +#include "qtsupport_global.h" + +QT_FORWARD_DECLARE_CLASS(QSettings) + +namespace QtSupport { + +class QTSUPPORT_EXPORT CodeGenSettings +{ +public: + // How to embed the Ui::Form class. + enum UiClassEmbedding + { + PointerAggregatedUiClass, // "Ui::Form *m_ui"; + AggregatedUiClass, // "Ui::Form m_ui"; + InheritedUiClass // "...private Ui::Form..." + }; + + CodeGenSettings(); + bool equals(const CodeGenSettings &rhs) const; + + void fromSettings(const QSettings *settings); + void toSettings(QSettings *settings) const; + + UiClassEmbedding embedding; + bool retranslationSupport; // Add handling for language change events + bool includeQtModule; // Include "<QtGui/[Class]>" or just "<[Class]>" + bool addQtVersionCheck; // Include #ifdef when using "#include <QtGui/..." +}; + +inline bool operator==(const CodeGenSettings &p1, const CodeGenSettings &p2) { return p1.equals(p2); } +inline bool operator!=(const CodeGenSettings &p1, const CodeGenSettings &p2) { return !p1.equals(p2); } + +} // namespace QtSupport + +#endif // CODEGENSETTINGS_H diff --git a/src/plugins/designer/cpp/cppsettingspage.cpp b/src/plugins/qtsupport/codegensettingspage.cpp index f3ddc32379..51cb741dde 100644 --- a/src/plugins/designer/cpp/cppsettingspage.cpp +++ b/src/plugins/qtsupport/codegensettingspage.cpp @@ -27,19 +27,22 @@ ** ****************************************************************************/ -#include "cppsettingspage.h" -#include <designer/designerconstants.h> +#include "codegensettingspage.h" + +#include "qtsupportconstants.h" + +#include <cpptools/cpptoolsconstants.h> #include <QCoreApplication> #include <QTextStream> #include <coreplugin/icore.h> -namespace Designer { +namespace QtSupport { namespace Internal { -// ---------- CppSettingsPageWidget +// ---------- CodeGenSettingsPageWidget -CppSettingsPageWidget::CppSettingsPageWidget(QWidget *parent) : +CodeGenSettingsPageWidget::CodeGenSettingsPageWidget(QWidget *parent) : QWidget(parent) { m_ui.setupUi(this); @@ -47,17 +50,17 @@ CppSettingsPageWidget::CppSettingsPageWidget(QWidget *parent) : m_ui.addQtVersionCheckBox, SLOT(setEnabled(bool))); } -FormClassWizardGenerationParameters CppSettingsPageWidget::parameters() const +CodeGenSettings CodeGenSettingsPageWidget::parameters() const { - FormClassWizardGenerationParameters rc; - rc.embedding = static_cast<UiClassEmbedding>(uiEmbedding()); + CodeGenSettings rc; + rc.embedding = static_cast<CodeGenSettings::UiClassEmbedding>(uiEmbedding()); rc.retranslationSupport =m_ui.retranslateCheckBox->isChecked(); rc.includeQtModule = m_ui.includeQtModuleCheckBox->isChecked(); rc.addQtVersionCheck = m_ui.addQtVersionCheckBox->isChecked(); return rc; } -void CppSettingsPageWidget::setParameters(const FormClassWizardGenerationParameters &p) +void CodeGenSettingsPageWidget::setParameters(const CodeGenSettings &p) { m_ui.retranslateCheckBox->setChecked(p.retranslationSupport); m_ui.includeQtModuleCheckBox->setChecked(p.includeQtModule); @@ -65,54 +68,56 @@ void CppSettingsPageWidget::setParameters(const FormClassWizardGenerationParamet setUiEmbedding(p.embedding); } -int CppSettingsPageWidget::uiEmbedding() const +int CodeGenSettingsPageWidget::uiEmbedding() const { if (m_ui.ptrAggregationRadioButton->isChecked()) - return PointerAggregatedUiClass; + return CodeGenSettings::PointerAggregatedUiClass; if (m_ui.aggregationButton->isChecked()) - return AggregatedUiClass; - return InheritedUiClass; + return CodeGenSettings::AggregatedUiClass; + return CodeGenSettings::InheritedUiClass; } -void CppSettingsPageWidget::setUiEmbedding(int v) +void CodeGenSettingsPageWidget::setUiEmbedding(int v) { switch (v) { - case PointerAggregatedUiClass: + case CodeGenSettings::PointerAggregatedUiClass: m_ui.ptrAggregationRadioButton->setChecked(true); break; - case AggregatedUiClass: + case CodeGenSettings::AggregatedUiClass: m_ui.aggregationButton->setChecked(true); break; - case InheritedUiClass: + case CodeGenSettings::InheritedUiClass: m_ui.multipleInheritanceButton->setChecked(true); break; } } -// ---------- CppSettingsPage -CppSettingsPage::CppSettingsPage(QObject *parent) : Core::IOptionsPage(parent) +// ---------- CodeGenSettingsPage +CodeGenSettingsPage::CodeGenSettingsPage(QObject *parent) : + Core::IOptionsPage(parent), + m_widget(0) { m_parameters.fromSettings(Core::ICore::settings()); - setId(Designer::Constants::SETTINGS_CPP_SETTINGS_ID); - setDisplayName(QCoreApplication::translate("Designer", Designer::Constants::SETTINGS_CPP_SETTINGS_NAME)); - setCategory(Designer::Constants::SETTINGS_CATEGORY); - setDisplayCategory(QCoreApplication::translate("Designer", Designer::Constants::SETTINGS_TR_CATEGORY)); - setCategoryIcon(QLatin1String(Designer::Constants::SETTINGS_CATEGORY_ICON)); + setId(Constants::CODEGEN_SETTINGS_PAGE_ID); + setDisplayName(QCoreApplication::translate("QtSupport", Constants::CODEGEN_SETTINGS_PAGE_NAME)); + setCategory(CppTools::Constants::CPP_SETTINGS_CATEGORY); + setDisplayCategory(QCoreApplication::translate("CppTools", CppTools::Constants::CPP_SETTINGS_TR_CATEGORY)); + setCategoryIcon(QLatin1String(CppTools::Constants::SETTINGS_CATEGORY_CPP_ICON)); } -QWidget *CppSettingsPage::widget() +QWidget *CodeGenSettingsPage::widget() { if (!m_widget) { - m_widget = new CppSettingsPageWidget; + m_widget = new CodeGenSettingsPageWidget; m_widget->setParameters(m_parameters); } return m_widget; } -void CppSettingsPage::apply() +void CodeGenSettingsPage::apply() { if (m_widget) { - const FormClassWizardGenerationParameters newParameters = m_widget->parameters(); + const CodeGenSettings newParameters = m_widget->parameters(); if (newParameters != m_parameters) { m_parameters = newParameters; m_parameters.toSettings(Core::ICore::settings()); @@ -120,10 +125,10 @@ void CppSettingsPage::apply() } } -void CppSettingsPage::finish() +void CodeGenSettingsPage::finish() { delete m_widget; } } // namespace Internal -} // namespace Designer +} // namespace QtSupport diff --git a/src/plugins/designer/cpp/cppsettingspage.h b/src/plugins/qtsupport/codegensettingspage.h index 644c6da33c..e3ec44bd60 100644 --- a/src/plugins/designer/cpp/cppsettingspage.h +++ b/src/plugins/qtsupport/codegensettingspage.h @@ -27,50 +27,51 @@ ** ****************************************************************************/ -#ifndef CPPSETTINGSPAGE_H -#define CPPSETTINGSPAGE_H +#ifndef CODEGENSETTINGSPAGE_H +#define CODEGENSETTINGSPAGE_H -#include "ui_cppsettingspagewidget.h" -#include <designer/qtdesignerformclasscodegenerator.h> +#include "ui_codegensettingspagewidget.h" + +#include "codegensettings.h" #include <coreplugin/dialogs/ioptionspage.h> #include <QPointer> -namespace Designer { +namespace QtSupport { namespace Internal { -class CppSettingsPageWidget : public QWidget +class CodeGenSettingsPageWidget : public QWidget { Q_OBJECT public: - explicit CppSettingsPageWidget(QWidget *parent = 0); + explicit CodeGenSettingsPageWidget(QWidget *parent = 0); - FormClassWizardGenerationParameters parameters() const; - void setParameters(const FormClassWizardGenerationParameters &p); + CodeGenSettings parameters() const; + void setParameters(const CodeGenSettings &p); private: int uiEmbedding() const; void setUiEmbedding(int); - Ui::CppSettingsPageWidget m_ui; + Ui::CodeGenSettingsPageWidget m_ui; }; -class CppSettingsPage : public Core::IOptionsPage +class CodeGenSettingsPage : public Core::IOptionsPage { public: - explicit CppSettingsPage(QObject *parent = 0); + explicit CodeGenSettingsPage(QObject *parent = 0); QWidget *widget(); void apply(); void finish(); private: - QPointer<CppSettingsPageWidget> m_widget; - FormClassWizardGenerationParameters m_parameters; + QPointer<CodeGenSettingsPageWidget> m_widget; + CodeGenSettings m_parameters; }; } // namespace Internal -} // namespace Designer +} // namespace QtSupport -#endif // CPPSETTINGSPAGE_H +#endif // CODEGENSETTINGSPAGE_H diff --git a/src/plugins/designer/cpp/cppsettingspagewidget.ui b/src/plugins/qtsupport/codegensettingspagewidget.ui index f9a88364ca..7ad9af8196 100644 --- a/src/plugins/designer/cpp/cppsettingspagewidget.ui +++ b/src/plugins/qtsupport/codegensettingspagewidget.ui @@ -1,7 +1,7 @@ <?xml version="1.0" encoding="UTF-8"?> <ui version="4.0"> - <class>Designer::Internal::CppSettingsPageWidget</class> - <widget class="QWidget" name="Designer::Internal::CppSettingsPageWidget"> + <class>QtSupport::Internal::CodeGenSettingsPageWidget</class> + <widget class="QWidget" name="QtSupport::Internal::CodeGenSettingsPageWidget"> <property name="geometry"> <rect> <x>0</x> diff --git a/src/plugins/qtsupport/qtsupport.pro b/src/plugins/qtsupport/qtsupport.pro index dcea5b3330..4e6ee53152 100644 --- a/src/plugins/qtsupport/qtsupport.pro +++ b/src/plugins/qtsupport/qtsupport.pro @@ -7,6 +7,8 @@ DEFINES += QMAKE_LIBRARY include(../../shared/proparser/proparser.pri) HEADERS += \ + codegensettings.h \ + codegensettingspage.h \ qtsupportplugin.h \ qtsupport_global.h \ qtkitconfigwidget.h \ @@ -36,6 +38,8 @@ HEADERS += \ winceqtversion.h SOURCES += \ + codegensettings.cpp \ + codegensettingspage.cpp \ qtsupportplugin.cpp \ qtkitconfigwidget.cpp \ qtkitinformation.cpp \ @@ -68,6 +72,7 @@ greaterThan(QT_MAJOR_VERSION, 4) { } FORMS += \ + codegensettingspagewidget.ui \ showbuildlog.ui \ qtversioninfo.ui \ debugginghelper.ui \ diff --git a/src/plugins/qtsupport/qtsupport.qbs b/src/plugins/qtsupport/qtsupport.qbs index fedbd84578..1f97a61c7d 100644 --- a/src/plugins/qtsupport/qtsupport.qbs +++ b/src/plugins/qtsupport/qtsupport.qbs @@ -60,6 +60,11 @@ QtcPlugin { files: [ "baseqtversion.cpp", "baseqtversion.h", + "codegensettings.cpp", + "codegensettings.h", + "codegensettingspage.cpp", + "codegensettingspage.h", + "codegensettingswidget.ui", "qtconfigwidget.cpp", "qtconfigwidget.h", "qtsupport.qrc", diff --git a/src/plugins/qtsupport/qtsupportconstants.h b/src/plugins/qtsupport/qtsupportconstants.h index 77c54b2620..6e43613742 100644 --- a/src/plugins/qtsupport/qtsupportconstants.h +++ b/src/plugins/qtsupport/qtsupportconstants.h @@ -33,10 +33,13 @@ namespace QtSupport { namespace Constants { -// Qt4 settings pages +// Qt settings pages const char QTVERSION_SETTINGS_PAGE_ID[] = "H.Qt Versions"; const char QTVERSION_SETTINGS_PAGE_NAME[] = QT_TRANSLATE_NOOP("QtSupport", "Qt Versions"); +const char CODEGEN_SETTINGS_PAGE_ID[] = "Class Generation"; +const char CODEGEN_SETTINGS_PAGE_NAME[] = QT_TRANSLATE_NOOP("QtSupport", "Qt Class Generation"); + // QtVersions const char DESKTOPQT[] = "Qt4ProjectManager.QtVersion.Desktop"; const char SIMULATORQT[] = "Qt4ProjectManager.QtVersion.Simulator"; diff --git a/src/plugins/qtsupport/qtsupportplugin.cpp b/src/plugins/qtsupport/qtsupportplugin.cpp index 9a9d2e2c72..f3cd82edb1 100644 --- a/src/plugins/qtsupport/qtsupportplugin.cpp +++ b/src/plugins/qtsupport/qtsupportplugin.cpp @@ -29,6 +29,7 @@ #include "qtsupportplugin.h" +#include "codegensettingspage.h" #include "customexecutablerunconfiguration.h" #include "desktopqtversionfactory.h" #include "qtfeatureprovider.h" @@ -81,6 +82,7 @@ bool QtSupportPlugin::initialize(const QStringList &arguments, QString *errorMes QtFeatureProvider *featureMgr = new QtFeatureProvider; addAutoReleasedObject(featureMgr); + addAutoReleasedObject(new CodeGenSettingsPage); addAutoReleasedObject(new QtOptionsPage); #if (QT_VERSION >= QT_VERSION_CHECK(5, 1, 0)) |