forked from qt-creator/qt-creator
Designer: Use IOptionPage::setWidgetCreator() for settings
Change-Id: I731905a84110966640cef0bfd8cf7eeb9e7527cc Reviewed-by: Christian Stenger <christian.stenger@qt.io>
This commit is contained in:
@@ -11,38 +11,34 @@
|
||||
|
||||
#include <QDesignerOptionsPageInterface>
|
||||
#include <QCoreApplication>
|
||||
#include <QVBoxLayout>
|
||||
|
||||
namespace Designer::Internal {
|
||||
|
||||
class SettingsPageWidget : public Core::IOptionsPageWidget
|
||||
{
|
||||
public:
|
||||
explicit SettingsPageWidget(QDesignerOptionsPageInterface *designerPage)
|
||||
: m_designerPage(designerPage)
|
||||
{
|
||||
auto vbox = new QVBoxLayout(this);
|
||||
vbox->addWidget(m_designerPage->createPage(nullptr));
|
||||
}
|
||||
|
||||
void apply() { m_designerPage->apply(); }
|
||||
void finish() { m_designerPage->finish(); }
|
||||
|
||||
QDesignerOptionsPageInterface *m_designerPage;
|
||||
};
|
||||
|
||||
using namespace Designer::Internal;
|
||||
|
||||
SettingsPage::SettingsPage(QDesignerOptionsPageInterface *designerPage) :
|
||||
Core::IOptionsPage(nullptr, false),
|
||||
m_designerPage(designerPage)
|
||||
Core::IOptionsPage(nullptr, false)
|
||||
{
|
||||
setId(Utils::Id::fromString(m_designerPage->name()));
|
||||
setDisplayName(m_designerPage->name());
|
||||
setId(Utils::Id::fromString(designerPage->name()));
|
||||
setDisplayName(designerPage->name());
|
||||
setCategory(Designer::Constants::SETTINGS_CATEGORY);
|
||||
}
|
||||
|
||||
QWidget *SettingsPage::widget()
|
||||
{
|
||||
m_initialized = true;
|
||||
if (!m_widget)
|
||||
m_widget = m_designerPage->createPage(nullptr);
|
||||
return m_widget;
|
||||
|
||||
}
|
||||
|
||||
void SettingsPage::apply()
|
||||
{
|
||||
if (m_initialized)
|
||||
m_designerPage->apply();
|
||||
}
|
||||
|
||||
void SettingsPage::finish()
|
||||
{
|
||||
if (m_initialized)
|
||||
m_designerPage->finish();
|
||||
delete m_widget;
|
||||
setWidgetCreator([designerPage] { return new SettingsPageWidget(designerPage); });
|
||||
}
|
||||
|
||||
SettingsPageProvider::SettingsPageProvider()
|
||||
@@ -102,3 +98,5 @@ bool SettingsPageProvider::matches(const QRegularExpression ®ex) const
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
} // Designer::Internal
|
||||
|
||||
@@ -5,32 +5,16 @@
|
||||
|
||||
#include <coreplugin/dialogs/ioptionspage.h>
|
||||
|
||||
#include <QPointer>
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
class QDesignerOptionsPageInterface;
|
||||
QT_END_NAMESPACE
|
||||
|
||||
namespace Designer {
|
||||
namespace Internal {
|
||||
|
||||
class SettingsPageWidget;
|
||||
namespace Designer::Internal {
|
||||
|
||||
class SettingsPage : public Core::IOptionsPage
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit SettingsPage(QDesignerOptionsPageInterface *designerPage);
|
||||
|
||||
QWidget *widget() override;
|
||||
void apply() override;
|
||||
void finish() override;
|
||||
|
||||
private:
|
||||
QDesignerOptionsPageInterface *m_designerPage;
|
||||
bool m_initialized = false;
|
||||
QPointer<QWidget> m_widget;
|
||||
};
|
||||
|
||||
class SettingsPageProvider : public Core::IOptionsPageProvider
|
||||
@@ -48,5 +32,4 @@ private:
|
||||
mutable QStringList m_keywords;
|
||||
};
|
||||
|
||||
} // namespace Internal
|
||||
} // namespace Designer
|
||||
} // Designer::Internal
|
||||
|
||||
Reference in New Issue
Block a user