forked from qt-creator/qt-creator
QtSupport: use new settings page convenience for CodeGenSettings
Change-Id: I0e3bf34dd709af33136b0f95dc3dcaecf36eb3bc Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
This commit is contained in:
@@ -27,11 +27,10 @@
|
||||
|
||||
#include "qtsupportconstants.h"
|
||||
|
||||
#include <coreplugin/icore.h>
|
||||
#include <cpptools/cpptoolsconstants.h>
|
||||
|
||||
#include <QCoreApplication>
|
||||
#include <QTextStream>
|
||||
#include <coreplugin/icore.h>
|
||||
|
||||
namespace QtSupport {
|
||||
namespace Internal {
|
||||
@@ -41,26 +40,27 @@ namespace Internal {
|
||||
CodeGenSettingsPageWidget::CodeGenSettingsPageWidget()
|
||||
{
|
||||
m_ui.setupUi(this);
|
||||
|
||||
CodeGenSettings parameters;
|
||||
parameters.fromSettings(Core::ICore::settings());
|
||||
|
||||
m_ui.retranslateCheckBox->setChecked(parameters.retranslationSupport);
|
||||
m_ui.includeQtModuleCheckBox->setChecked(parameters.includeQtModule);
|
||||
m_ui.addQtVersionCheckBox->setChecked(parameters.addQtVersionCheck);
|
||||
setUiEmbedding(parameters.embedding);
|
||||
|
||||
connect(m_ui.includeQtModuleCheckBox, &QAbstractButton::toggled,
|
||||
m_ui.addQtVersionCheckBox, &QWidget::setEnabled);
|
||||
}
|
||||
|
||||
CodeGenSettings CodeGenSettingsPageWidget::parameters() const
|
||||
void CodeGenSettingsPageWidget::apply()
|
||||
{
|
||||
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 CodeGenSettingsPageWidget::setParameters(const CodeGenSettings &p)
|
||||
{
|
||||
m_ui.retranslateCheckBox->setChecked(p.retranslationSupport);
|
||||
m_ui.includeQtModuleCheckBox->setChecked(p.includeQtModule);
|
||||
m_ui.addQtVersionCheckBox->setChecked(p.addQtVersionCheck);
|
||||
setUiEmbedding(p.embedding);
|
||||
rc.toSettings(Core::ICore::settings());
|
||||
}
|
||||
|
||||
int CodeGenSettingsPageWidget::uiEmbedding() const
|
||||
@@ -88,9 +88,9 @@ void CodeGenSettingsPageWidget::setUiEmbedding(int v)
|
||||
}
|
||||
|
||||
// ---------- CodeGenSettingsPage
|
||||
|
||||
CodeGenSettingsPage::CodeGenSettingsPage()
|
||||
{
|
||||
m_parameters.fromSettings(Core::ICore::settings());
|
||||
setId(Constants::CODEGEN_SETTINGS_PAGE_ID);
|
||||
setDisplayName(QCoreApplication::translate("QtSupport", "Qt Class Generation"));
|
||||
setCategory(CppTools::Constants::CPP_SETTINGS_CATEGORY);
|
||||
@@ -99,31 +99,7 @@ CodeGenSettingsPage::CodeGenSettingsPage()
|
||||
setCategoryIcon(Utils::Icon({{":/projectexplorer/images/settingscategory_cpp.png",
|
||||
Utils::Theme::PanelTextColorDark}},
|
||||
Utils::Icon::Tint));
|
||||
}
|
||||
|
||||
QWidget *CodeGenSettingsPage::widget()
|
||||
{
|
||||
if (!m_widget) {
|
||||
m_widget = new CodeGenSettingsPageWidget;
|
||||
m_widget->setParameters(m_parameters);
|
||||
}
|
||||
return m_widget;
|
||||
}
|
||||
|
||||
void CodeGenSettingsPage::apply()
|
||||
{
|
||||
if (m_widget) {
|
||||
const CodeGenSettings newParameters = m_widget->parameters();
|
||||
if (newParameters != m_parameters) {
|
||||
m_parameters = newParameters;
|
||||
m_parameters.toSettings(Core::ICore::settings());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void CodeGenSettingsPage::finish()
|
||||
{
|
||||
delete m_widget;
|
||||
setWidgetCreator([] { return new CodeGenSettingsPageWidget; });
|
||||
}
|
||||
|
||||
} // namespace Internal
|
||||
|
@@ -31,21 +31,20 @@
|
||||
|
||||
#include <coreplugin/dialogs/ioptionspage.h>
|
||||
|
||||
#include <QPointer>
|
||||
|
||||
namespace QtSupport {
|
||||
namespace Internal {
|
||||
|
||||
class CodeGenSettingsPageWidget : public QWidget
|
||||
class CodeGenSettingsPageWidget : public Core::IOptionsPageWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
CodeGenSettingsPageWidget();
|
||||
|
||||
CodeGenSettings parameters() const;
|
||||
void setParameters(const CodeGenSettings &p);
|
||||
|
||||
private:
|
||||
void apply() final;
|
||||
void finish() final {}
|
||||
|
||||
int uiEmbedding() const;
|
||||
void setUiEmbedding(int);
|
||||
|
||||
@@ -56,14 +55,6 @@ class CodeGenSettingsPage : public Core::IOptionsPage
|
||||
{
|
||||
public:
|
||||
CodeGenSettingsPage();
|
||||
|
||||
QWidget *widget() override;
|
||||
void apply() override;
|
||||
void finish() override;
|
||||
|
||||
private:
|
||||
QPointer<CodeGenSettingsPageWidget> m_widget;
|
||||
CodeGenSettings m_parameters;
|
||||
};
|
||||
|
||||
} // namespace Internal
|
||||
|
Reference in New Issue
Block a user