diff options
author | hjk <hjk@qt.io> | 2022-06-21 16:06:28 +0200 |
---|---|---|
committer | hjk <hjk@qt.io> | 2022-06-22 07:22:54 +0000 |
commit | cb0ff08518c30ec73ec09ae77c358c26698662ff (patch) | |
tree | 2f5ff203fbfe653657054370d89e6baa7b2593e6 /src/plugins/designer | |
parent | 253ef8f6065b29c4800551cf13c21c9305a8269d (diff) | |
download | qt-creator-cb0ff08518c30ec73ec09ae77c358c26698662ff.tar.gz |
Designer: Inline formclasswizardpage.ui
No change of translation context yet, just removing a form with
a single widget (and setting of object names etc).
Change-Id: I00a23b63caeff18e1199e6232d1afe6d89696bb7
Reviewed-by: Jarek Kobus <jaroslaw.kobus@qt.io>
Diffstat (limited to 'src/plugins/designer')
-rw-r--r-- | src/plugins/designer/CMakeLists.txt | 2 | ||||
-rw-r--r-- | src/plugins/designer/cpp/formclasswizardpage.cpp | 74 | ||||
-rw-r--r-- | src/plugins/designer/cpp/formclasswizardpage.h | 14 | ||||
-rw-r--r-- | src/plugins/designer/cpp/formclasswizardpage.ui | 33 | ||||
-rw-r--r-- | src/plugins/designer/designer.qbs | 2 |
5 files changed, 46 insertions, 79 deletions
diff --git a/src/plugins/designer/CMakeLists.txt b/src/plugins/designer/CMakeLists.txt index 32fa078e9f..ebc81260d0 100644 --- a/src/plugins/designer/CMakeLists.txt +++ b/src/plugins/designer/CMakeLists.txt @@ -10,7 +10,7 @@ add_qtc_plugin(Designer codemodelhelpers.cpp codemodelhelpers.h cpp/formclasswizard.cpp cpp/formclasswizard.h cpp/formclasswizarddialog.cpp cpp/formclasswizarddialog.h - cpp/formclasswizardpage.cpp cpp/formclasswizardpage.h cpp/formclasswizardpage.ui + cpp/formclasswizardpage.cpp cpp/formclasswizardpage.h cpp/formclasswizardparameters.cpp cpp/formclasswizardparameters.h cpp/newclasswidget.cpp cpp/newclasswidget.h cpp/newclasswidget.ui designer_export.h diff --git a/src/plugins/designer/cpp/formclasswizardpage.cpp b/src/plugins/designer/cpp/formclasswizardpage.cpp index 52bdfe7ccb..81220b532c 100644 --- a/src/plugins/designer/cpp/formclasswizardpage.cpp +++ b/src/plugins/designer/cpp/formclasswizardpage.cpp @@ -24,42 +24,54 @@ ****************************************************************************/ #include "formclasswizardpage.h" -#include "ui_formclasswizardpage.h" -#include "formclasswizardparameters.h" -#include <utils/wizard.h> +#include "formclasswizardparameters.h" +#include "newclasswidget.h" #include <coreplugin/icore.h> + #include <cppeditor/cppeditorconstants.h> + #include <utils/mimeutils.h> +#include <utils/wizard.h> -#include <QDebug> +#include <QGridLayout> +#include <QGroupBox> #include <QMessageBox> +#include <QVBoxLayout> +#include <QVariant> namespace Designer { namespace Internal { -// ----------------- FormClassWizardPage - -FormClassWizardPage::FormClassWizardPage(QWidget * parent) : - QWizardPage(parent), - m_ui(new Ui::FormClassWizardPage) +FormClassWizardPage::FormClassWizardPage() { - m_ui->setupUi(this); + setTitle(tr("Choose a Class Name")); + + auto classGroupBox = new QGroupBox(this); + classGroupBox->setTitle(tr("Class")); - connect(m_ui->newClassWidget, &NewClassWidget::validChanged, this, - &FormClassWizardPage::slotValidChanged); + m_newClassWidget = new NewClassWidget(classGroupBox); + m_newClassWidget->setHeaderExtension( + Utils::mimeTypeForName(CppEditor::Constants::CPP_HEADER_MIMETYPE).preferredSuffix()); + m_newClassWidget->setSourceExtension( + Utils::mimeTypeForName(CppEditor::Constants::CPP_SOURCE_MIMETYPE).preferredSuffix()); + m_newClassWidget->setLowerCaseFiles(lowercaseHeaderFiles()); - initFileGenerationSettings(); + connect(m_newClassWidget, &NewClassWidget::validChanged, + this, &FormClassWizardPage::slotValidChanged); setProperty(Utils::SHORT_TITLE_PROPERTY, tr("Class Details")); -} -FormClassWizardPage::~FormClassWizardPage() -{ - delete m_ui; + auto verticalLayout = new QVBoxLayout(classGroupBox); + verticalLayout->addWidget(m_newClassWidget); + + auto gridLayout = new QGridLayout(this); + gridLayout->addWidget(classGroupBox, 0, 0, 1, 1); } +FormClassWizardPage::~FormClassWizardPage() = default; + // Retrieve settings of CppEditor plugin. bool FormClassWizardPage::lowercaseHeaderFiles() { @@ -70,45 +82,35 @@ bool FormClassWizardPage::lowercaseHeaderFiles() return Core::ICore::settings()->value(lowerCaseSettingsKey, QVariant(lowerCaseDefault)).toBool(); } -// Set up new class widget from settings -void FormClassWizardPage::initFileGenerationSettings() -{ - m_ui->newClassWidget->setHeaderExtension( - Utils::mimeTypeForName(CppEditor::Constants::CPP_HEADER_MIMETYPE).preferredSuffix()); - m_ui->newClassWidget->setSourceExtension( - Utils::mimeTypeForName(CppEditor::Constants::CPP_SOURCE_MIMETYPE).preferredSuffix()); - m_ui->newClassWidget->setLowerCaseFiles(lowercaseHeaderFiles()); -} - void FormClassWizardPage::setClassName(const QString &suggestedClassName) { // Is it valid, now? - m_ui->newClassWidget->setClassName(suggestedClassName); + m_newClassWidget->setClassName(suggestedClassName); slotValidChanged(); } Utils::FilePath FormClassWizardPage::filePath() const { - return m_ui->newClassWidget->filePath(); + return m_newClassWidget->filePath(); } void FormClassWizardPage::setFilePath(const Utils::FilePath &p) { - m_ui->newClassWidget->setFilePath(p); + m_newClassWidget->setFilePath(p); } void FormClassWizardPage::getParameters(FormClassWizardParameters *p) const { - p->className = m_ui->newClassWidget->className(); + p->className = m_newClassWidget->className(); p->path = filePath(); - p->sourceFile = m_ui->newClassWidget->sourceFileName(); - p->headerFile = m_ui->newClassWidget->headerFileName(); - p->uiFile = m_ui->newClassWidget-> formFileName(); + p->sourceFile = m_newClassWidget->sourceFileName(); + p->headerFile = m_newClassWidget->headerFileName(); + p->uiFile = m_newClassWidget-> formFileName(); } void FormClassWizardPage::slotValidChanged() { - const bool validNow = m_ui->newClassWidget->isValid(); + const bool validNow = m_newClassWidget->isValid(); if (m_isValid != validNow) { m_isValid = validNow; emit completeChanged(); @@ -123,7 +125,7 @@ bool FormClassWizardPage::isComplete() const bool FormClassWizardPage::validatePage() { QString errorMessage; - const bool rc = m_ui->newClassWidget->isValid(&errorMessage); + const bool rc = m_newClassWidget->isValid(&errorMessage); if (!rc) QMessageBox::warning(this, tr("%1 - Error").arg(title()), errorMessage); return rc; diff --git a/src/plugins/designer/cpp/formclasswizardpage.h b/src/plugins/designer/cpp/formclasswizardpage.h index 60e848433e..7ba67ed42c 100644 --- a/src/plugins/designer/cpp/formclasswizardpage.h +++ b/src/plugins/designer/cpp/formclasswizardpage.h @@ -25,6 +25,7 @@ #pragma once +#include <QCoreApplication> #include <QWizardPage> namespace Utils { class FilePath; } @@ -36,21 +37,21 @@ class FormClassWizardGenerationParameters; namespace Internal { -namespace Ui { class FormClassWizardPage; } - +class NewClassWidget; class FormClassWizardPage : public QWizardPage { - Q_OBJECT + Q_DECLARE_TR_FUNCTIONS(Designer::Internal::FormClassWizardPage) public: - explicit FormClassWizardPage(QWidget *parent = nullptr); + FormClassWizardPage(); ~FormClassWizardPage() override; bool isComplete () const override; bool validatePage() override; void setClassName(const QString &suggestedClassName); + void setFilePath(const Utils::FilePath &); Utils::FilePath filePath() const; @@ -65,11 +66,8 @@ public: private: void slotValidChanged(); -private: - void initFileGenerationSettings(); - - Ui::FormClassWizardPage *m_ui = nullptr; bool m_isValid = false; + Designer::Internal::NewClassWidget *m_newClassWidget; }; } // namespace Internal diff --git a/src/plugins/designer/cpp/formclasswizardpage.ui b/src/plugins/designer/cpp/formclasswizardpage.ui deleted file mode 100644 index b58e58c4b5..0000000000 --- a/src/plugins/designer/cpp/formclasswizardpage.ui +++ /dev/null @@ -1,33 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<ui version="4.0"> - <class>Designer::Internal::FormClassWizardPage</class> - <widget class="QWizardPage" name="Designer::Internal::FormClassWizardPage"> - <property name="title"> - <string>Choose a Class Name</string> - </property> - <layout class="QGridLayout" name="gridLayout"> - <item row="0" column="0"> - <widget class="QGroupBox" name="classGroupBox"> - <property name="title"> - <string>Class</string> - </property> - <layout class="QVBoxLayout" name="verticalLayout_2"> - <item> - <widget class="Designer::Internal::NewClassWidget" name="newClassWidget"/> - </item> - </layout> - </widget> - </item> - </layout> - </widget> - <customwidgets> - <customwidget> - <class>Designer::Internal::NewClassWidget</class> - <extends>QWidget</extends> - <header location="global">designer/cpp/newclasswidget.h</header> - <container>1</container> - </customwidget> - </customwidgets> - <resources/> - <connections/> -</ui> diff --git a/src/plugins/designer/designer.qbs b/src/plugins/designer/designer.qbs index 739b1c1f98..ff98dfb04f 100644 --- a/src/plugins/designer/designer.qbs +++ b/src/plugins/designer/designer.qbs @@ -70,7 +70,7 @@ QtcPlugin { files: [ "formclasswizard.cpp", "formclasswizard.h", "formclasswizarddialog.cpp", "formclasswizarddialog.h", - "formclasswizardpage.cpp", "formclasswizardpage.h", "formclasswizardpage.ui", + "formclasswizardpage.cpp", "formclasswizardpage.h", "formclasswizardparameters.cpp", "formclasswizardparameters.h", "newclasswidget.cpp", "newclasswidget.h", "newclasswidget.ui", ] |