forked from qt-creator/qt-creator
Core: PagedSettings, next attempt
We cannnot pass the LayoutItem directly but need the lambda to postpone creation of aspect subwidgets until the settings page gets into view. Change-Id: I420e82f66fd5c4781451d6851cc38368e7501abc Reviewed-by: Alessandro Portale <alessandro.portale@qt.io>
This commit is contained in:
@@ -136,9 +136,6 @@ QWidget *IOptionsPage::widget()
|
|||||||
if (!m_widget) {
|
if (!m_widget) {
|
||||||
if (m_widgetCreator) {
|
if (m_widgetCreator) {
|
||||||
m_widget = m_widgetCreator();
|
m_widget = m_widgetCreator();
|
||||||
} else if (m_layouter) {
|
|
||||||
m_widget = new QWidget;
|
|
||||||
m_layouter(m_widget);
|
|
||||||
} else {
|
} else {
|
||||||
QTC_CHECK(false);
|
QTC_CHECK(false);
|
||||||
}
|
}
|
||||||
@@ -157,9 +154,10 @@ QWidget *IOptionsPage::widget()
|
|||||||
|
|
||||||
void IOptionsPage::apply()
|
void IOptionsPage::apply()
|
||||||
{
|
{
|
||||||
if (auto widget = qobject_cast<IOptionsPageWidget *>(m_widget)) {
|
if (auto widget = qobject_cast<IOptionsPageWidget *>(m_widget))
|
||||||
widget->apply();
|
widget->apply();
|
||||||
} else if (m_settings) {
|
|
||||||
|
if (m_settings) {
|
||||||
if (m_settings->isDirty()) {
|
if (m_settings->isDirty()) {
|
||||||
m_settings->apply();
|
m_settings->apply();
|
||||||
m_settings->writeSettings(ICore::settings());
|
m_settings->writeSettings(ICore::settings());
|
||||||
@@ -180,7 +178,8 @@ void IOptionsPage::finish()
|
|||||||
{
|
{
|
||||||
if (auto widget = qobject_cast<IOptionsPageWidget *>(m_widget))
|
if (auto widget = qobject_cast<IOptionsPageWidget *>(m_widget))
|
||||||
widget->finish();
|
widget->finish();
|
||||||
else if (m_settings)
|
|
||||||
|
if (m_settings)
|
||||||
m_settings->finish();
|
m_settings->finish();
|
||||||
|
|
||||||
delete m_widget;
|
delete m_widget;
|
||||||
@@ -202,14 +201,10 @@ void IOptionsPage::setSettings(AspectContainer *settings)
|
|||||||
|
|
||||||
void IOptionsPage::setLayouter(const std::function<void(QWidget *w)> &layouter)
|
void IOptionsPage::setLayouter(const std::function<void(QWidget *w)> &layouter)
|
||||||
{
|
{
|
||||||
m_layouter = layouter;
|
m_widgetCreator = [layouter] {
|
||||||
}
|
auto widget = new IOptionsPageWidget;
|
||||||
|
layouter(widget);
|
||||||
void IOptionsPage::setLayout(const Layouting::LayoutItem &layout)
|
return widget;
|
||||||
{
|
|
||||||
using namespace Layouting;
|
|
||||||
m_layouter = [layout](QWidget *widget) {
|
|
||||||
Column { Row { Column { layout, st }, st } }.attachTo(widget);
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -306,4 +301,8 @@ QIcon IOptionsPageProvider::categoryIcon() const
|
|||||||
return m_categoryIcon.icon();
|
return m_categoryIcon.icon();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// PagedSettings
|
||||||
|
|
||||||
|
PagedSettings::PagedSettings() = default;
|
||||||
|
|
||||||
} // Core
|
} // Core
|
||||||
|
|||||||
@@ -75,7 +75,6 @@ protected:
|
|||||||
void setCategoryIconPath(const Utils::FilePath &categoryIconPath);
|
void setCategoryIconPath(const Utils::FilePath &categoryIconPath);
|
||||||
void setSettings(Utils::AspectContainer *settings);
|
void setSettings(Utils::AspectContainer *settings);
|
||||||
void setLayouter(const std::function<void(QWidget *w)> &layouter);
|
void setLayouter(const std::function<void(QWidget *w)> &layouter);
|
||||||
void setLayout(const Layouting::LayoutItem &layout);
|
|
||||||
|
|
||||||
// Used in FontSettingsPage. FIXME?
|
// Used in FontSettingsPage. FIXME?
|
||||||
QPointer<QWidget> m_widget; // Used in conjunction with m_widgetCreator
|
QPointer<QWidget> m_widget; // Used in conjunction with m_widgetCreator
|
||||||
@@ -92,7 +91,6 @@ private:
|
|||||||
mutable QStringList m_keywords;
|
mutable QStringList m_keywords;
|
||||||
|
|
||||||
Utils::AspectContainer *m_settings = nullptr;
|
Utils::AspectContainer *m_settings = nullptr;
|
||||||
std::function<void(QWidget *w)> m_layouter;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@@ -133,7 +131,7 @@ protected:
|
|||||||
class CORE_EXPORT PagedSettings : public Utils::AspectContainer, public IOptionsPage
|
class CORE_EXPORT PagedSettings : public Utils::AspectContainer, public IOptionsPage
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
PagedSettings() = default;
|
PagedSettings();
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace Core
|
} // namespace Core
|
||||||
|
|||||||
Reference in New Issue
Block a user