aboutsummaryrefslogtreecommitdiffstats
path: root/src/plugins/coreplugin/dialogs/ioptionspage.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/plugins/coreplugin/dialogs/ioptionspage.cpp')
-rw-r--r--src/plugins/coreplugin/dialogs/ioptionspage.cpp41
1 files changed, 28 insertions, 13 deletions
diff --git a/src/plugins/coreplugin/dialogs/ioptionspage.cpp b/src/plugins/coreplugin/dialogs/ioptionspage.cpp
index 451859c5274..4def6095a11 100644
--- a/src/plugins/coreplugin/dialogs/ioptionspage.cpp
+++ b/src/plugins/coreplugin/dialogs/ioptionspage.cpp
@@ -9,6 +9,7 @@
#include <coreplugin/icore.h>
#include <utils/aspects.h>
+#include <utils/layoutbuilder.h>
#include <utils/qtcassert.h>
#include <utils/stringutils.h>
@@ -135,9 +136,6 @@ QWidget *IOptionsPage::widget()
if (!m_widget) {
if (m_widgetCreator) {
m_widget = m_widgetCreator();
- } else if (m_layouter) {
- m_widget = new QWidget;
- m_layouter(m_widget);
} else {
QTC_CHECK(false);
}
@@ -156,9 +154,10 @@ QWidget *IOptionsPage::widget()
void IOptionsPage::apply()
{
- if (auto widget = qobject_cast<IOptionsPageWidget *>(m_widget)) {
+ if (auto widget = qobject_cast<IOptionsPageWidget *>(m_widget))
widget->apply();
- } else if (m_settings) {
+
+ if (m_settings) {
if (m_settings->isDirty()) {
m_settings->apply();
m_settings->writeSettings(ICore::settings());
@@ -179,7 +178,8 @@ void IOptionsPage::finish()
{
if (auto widget = qobject_cast<IOptionsPageWidget *>(m_widget))
widget->finish();
- else if (m_settings)
+
+ if (m_settings)
m_settings->finish();
delete m_widget;
@@ -199,9 +199,13 @@ void IOptionsPage::setSettings(AspectContainer *settings)
m_settings = settings;
}
-void IOptionsPage::setLayouter(const std::function<void(QWidget *w)> &layouter)
+void IOptionsPage::setLayouter(const std::function<Layouting::LayoutItem ()> &layouter)
{
- m_layouter = layouter;
+ m_widgetCreator = [layouter] {
+ auto widget = new IOptionsPageWidget;
+ layouter().attachTo(widget);
+ return widget;
+ };
}
/*!
@@ -237,11 +241,10 @@ void IOptionsPage::setLayouter(const std::function<void(QWidget *w)> &layouter)
static QList<IOptionsPage *> g_optionsPages;
/*!
- Constructs an options page with the given \a parent and registers it
+ Constructs an options page and registers it
at the global options page pool if \a registerGlobally is \c true.
*/
-IOptionsPage::IOptionsPage(QObject *parent, bool registerGlobally)
- : QObject(parent)
+IOptionsPage::IOptionsPage(bool registerGlobally)
{
if (registerGlobally)
g_optionsPages.append(this);
@@ -278,8 +281,7 @@ bool IOptionsPage::matches(const QRegularExpression &regexp) const
static QList<IOptionsPageProvider *> g_optionsPagesProviders;
-IOptionsPageProvider::IOptionsPageProvider(QObject *parent)
- : QObject(parent)
+IOptionsPageProvider::IOptionsPageProvider()
{
g_optionsPagesProviders.append(this);
}
@@ -299,4 +301,17 @@ QIcon IOptionsPageProvider::categoryIcon() const
return m_categoryIcon.icon();
}
+// PagedSettings
+
+PagedSettings::PagedSettings()
+{
+ setSettings(this);
+ setAutoApply(false);
+}
+
+void PagedSettings::readSettings()
+{
+ return AspectContainer::readSettings(Core::ICore::settings());
+}
+
} // Core