forked from qt-creator/qt-creator
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>
This commit is contained in:
@@ -10,7 +10,7 @@ add_qtc_plugin(Designer
|
|||||||
codemodelhelpers.cpp codemodelhelpers.h
|
codemodelhelpers.cpp codemodelhelpers.h
|
||||||
cpp/formclasswizard.cpp cpp/formclasswizard.h
|
cpp/formclasswizard.cpp cpp/formclasswizard.h
|
||||||
cpp/formclasswizarddialog.cpp cpp/formclasswizarddialog.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/formclasswizardparameters.cpp cpp/formclasswizardparameters.h
|
||||||
cpp/newclasswidget.cpp cpp/newclasswidget.h cpp/newclasswidget.ui
|
cpp/newclasswidget.cpp cpp/newclasswidget.h cpp/newclasswidget.ui
|
||||||
designer_export.h
|
designer_export.h
|
||||||
|
@@ -24,41 +24,53 @@
|
|||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
#include "formclasswizardpage.h"
|
#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 <coreplugin/icore.h>
|
||||||
#include <cppeditor/cppeditorconstants.h>
|
|
||||||
#include <utils/mimeutils.h>
|
|
||||||
|
|
||||||
#include <QDebug>
|
#include <cppeditor/cppeditorconstants.h>
|
||||||
|
|
||||||
|
#include <utils/mimeutils.h>
|
||||||
|
#include <utils/wizard.h>
|
||||||
|
|
||||||
|
#include <QGridLayout>
|
||||||
|
#include <QGroupBox>
|
||||||
#include <QMessageBox>
|
#include <QMessageBox>
|
||||||
|
#include <QVBoxLayout>
|
||||||
|
#include <QVariant>
|
||||||
|
|
||||||
namespace Designer {
|
namespace Designer {
|
||||||
namespace Internal {
|
namespace Internal {
|
||||||
|
|
||||||
// ----------------- FormClassWizardPage
|
FormClassWizardPage::FormClassWizardPage()
|
||||||
|
|
||||||
FormClassWizardPage::FormClassWizardPage(QWidget * parent) :
|
|
||||||
QWizardPage(parent),
|
|
||||||
m_ui(new Ui::FormClassWizardPage)
|
|
||||||
{
|
{
|
||||||
m_ui->setupUi(this);
|
setTitle(tr("Choose a Class Name"));
|
||||||
|
|
||||||
connect(m_ui->newClassWidget, &NewClassWidget::validChanged, this,
|
auto classGroupBox = new QGroupBox(this);
|
||||||
&FormClassWizardPage::slotValidChanged);
|
classGroupBox->setTitle(tr("Class"));
|
||||||
|
|
||||||
initFileGenerationSettings();
|
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());
|
||||||
|
|
||||||
|
connect(m_newClassWidget, &NewClassWidget::validChanged,
|
||||||
|
this, &FormClassWizardPage::slotValidChanged);
|
||||||
|
|
||||||
setProperty(Utils::SHORT_TITLE_PROPERTY, tr("Class Details"));
|
setProperty(Utils::SHORT_TITLE_PROPERTY, tr("Class Details"));
|
||||||
|
|
||||||
|
auto verticalLayout = new QVBoxLayout(classGroupBox);
|
||||||
|
verticalLayout->addWidget(m_newClassWidget);
|
||||||
|
|
||||||
|
auto gridLayout = new QGridLayout(this);
|
||||||
|
gridLayout->addWidget(classGroupBox, 0, 0, 1, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
FormClassWizardPage::~FormClassWizardPage()
|
FormClassWizardPage::~FormClassWizardPage() = default;
|
||||||
{
|
|
||||||
delete m_ui;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Retrieve settings of CppEditor plugin.
|
// Retrieve settings of CppEditor plugin.
|
||||||
bool FormClassWizardPage::lowercaseHeaderFiles()
|
bool FormClassWizardPage::lowercaseHeaderFiles()
|
||||||
@@ -70,45 +82,35 @@ bool FormClassWizardPage::lowercaseHeaderFiles()
|
|||||||
return Core::ICore::settings()->value(lowerCaseSettingsKey, QVariant(lowerCaseDefault)).toBool();
|
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)
|
void FormClassWizardPage::setClassName(const QString &suggestedClassName)
|
||||||
{
|
{
|
||||||
// Is it valid, now?
|
// Is it valid, now?
|
||||||
m_ui->newClassWidget->setClassName(suggestedClassName);
|
m_newClassWidget->setClassName(suggestedClassName);
|
||||||
slotValidChanged();
|
slotValidChanged();
|
||||||
}
|
}
|
||||||
|
|
||||||
Utils::FilePath FormClassWizardPage::filePath() const
|
Utils::FilePath FormClassWizardPage::filePath() const
|
||||||
{
|
{
|
||||||
return m_ui->newClassWidget->filePath();
|
return m_newClassWidget->filePath();
|
||||||
}
|
}
|
||||||
|
|
||||||
void FormClassWizardPage::setFilePath(const Utils::FilePath &p)
|
void FormClassWizardPage::setFilePath(const Utils::FilePath &p)
|
||||||
{
|
{
|
||||||
m_ui->newClassWidget->setFilePath(p);
|
m_newClassWidget->setFilePath(p);
|
||||||
}
|
}
|
||||||
|
|
||||||
void FormClassWizardPage::getParameters(FormClassWizardParameters *p) const
|
void FormClassWizardPage::getParameters(FormClassWizardParameters *p) const
|
||||||
{
|
{
|
||||||
p->className = m_ui->newClassWidget->className();
|
p->className = m_newClassWidget->className();
|
||||||
p->path = filePath();
|
p->path = filePath();
|
||||||
p->sourceFile = m_ui->newClassWidget->sourceFileName();
|
p->sourceFile = m_newClassWidget->sourceFileName();
|
||||||
p->headerFile = m_ui->newClassWidget->headerFileName();
|
p->headerFile = m_newClassWidget->headerFileName();
|
||||||
p->uiFile = m_ui->newClassWidget-> formFileName();
|
p->uiFile = m_newClassWidget-> formFileName();
|
||||||
}
|
}
|
||||||
|
|
||||||
void FormClassWizardPage::slotValidChanged()
|
void FormClassWizardPage::slotValidChanged()
|
||||||
{
|
{
|
||||||
const bool validNow = m_ui->newClassWidget->isValid();
|
const bool validNow = m_newClassWidget->isValid();
|
||||||
if (m_isValid != validNow) {
|
if (m_isValid != validNow) {
|
||||||
m_isValid = validNow;
|
m_isValid = validNow;
|
||||||
emit completeChanged();
|
emit completeChanged();
|
||||||
@@ -123,7 +125,7 @@ bool FormClassWizardPage::isComplete() const
|
|||||||
bool FormClassWizardPage::validatePage()
|
bool FormClassWizardPage::validatePage()
|
||||||
{
|
{
|
||||||
QString errorMessage;
|
QString errorMessage;
|
||||||
const bool rc = m_ui->newClassWidget->isValid(&errorMessage);
|
const bool rc = m_newClassWidget->isValid(&errorMessage);
|
||||||
if (!rc)
|
if (!rc)
|
||||||
QMessageBox::warning(this, tr("%1 - Error").arg(title()), errorMessage);
|
QMessageBox::warning(this, tr("%1 - Error").arg(title()), errorMessage);
|
||||||
return rc;
|
return rc;
|
||||||
|
@@ -25,6 +25,7 @@
|
|||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
|
#include <QCoreApplication>
|
||||||
#include <QWizardPage>
|
#include <QWizardPage>
|
||||||
|
|
||||||
namespace Utils { class FilePath; }
|
namespace Utils { class FilePath; }
|
||||||
@@ -36,21 +37,21 @@ class FormClassWizardGenerationParameters;
|
|||||||
|
|
||||||
namespace Internal {
|
namespace Internal {
|
||||||
|
|
||||||
namespace Ui { class FormClassWizardPage; }
|
class NewClassWidget;
|
||||||
|
|
||||||
|
|
||||||
class FormClassWizardPage : public QWizardPage
|
class FormClassWizardPage : public QWizardPage
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_DECLARE_TR_FUNCTIONS(Designer::Internal::FormClassWizardPage)
|
||||||
|
|
||||||
public:
|
public:
|
||||||
explicit FormClassWizardPage(QWidget *parent = nullptr);
|
FormClassWizardPage();
|
||||||
~FormClassWizardPage() override;
|
~FormClassWizardPage() override;
|
||||||
|
|
||||||
bool isComplete () const override;
|
bool isComplete () const override;
|
||||||
bool validatePage() override;
|
bool validatePage() override;
|
||||||
|
|
||||||
void setClassName(const QString &suggestedClassName);
|
void setClassName(const QString &suggestedClassName);
|
||||||
|
|
||||||
void setFilePath(const Utils::FilePath &);
|
void setFilePath(const Utils::FilePath &);
|
||||||
Utils::FilePath filePath() const;
|
Utils::FilePath filePath() const;
|
||||||
|
|
||||||
@@ -65,11 +66,8 @@ public:
|
|||||||
private:
|
private:
|
||||||
void slotValidChanged();
|
void slotValidChanged();
|
||||||
|
|
||||||
private:
|
|
||||||
void initFileGenerationSettings();
|
|
||||||
|
|
||||||
Ui::FormClassWizardPage *m_ui = nullptr;
|
|
||||||
bool m_isValid = false;
|
bool m_isValid = false;
|
||||||
|
Designer::Internal::NewClassWidget *m_newClassWidget;
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace Internal
|
} // namespace Internal
|
||||||
|
@@ -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>
|
|
@@ -70,7 +70,7 @@ QtcPlugin {
|
|||||||
files: [
|
files: [
|
||||||
"formclasswizard.cpp", "formclasswizard.h",
|
"formclasswizard.cpp", "formclasswizard.h",
|
||||||
"formclasswizarddialog.cpp", "formclasswizarddialog.h",
|
"formclasswizarddialog.cpp", "formclasswizarddialog.h",
|
||||||
"formclasswizardpage.cpp", "formclasswizardpage.h", "formclasswizardpage.ui",
|
"formclasswizardpage.cpp", "formclasswizardpage.h",
|
||||||
"formclasswizardparameters.cpp", "formclasswizardparameters.h",
|
"formclasswizardparameters.cpp", "formclasswizardparameters.h",
|
||||||
"newclasswidget.cpp", "newclasswidget.h", "newclasswidget.ui",
|
"newclasswidget.cpp", "newclasswidget.h", "newclasswidget.ui",
|
||||||
]
|
]
|
||||||
|
Reference in New Issue
Block a user