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