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 <QDesignerOptionsPageInterface>
|
||||||
#include <QCoreApplication>
|
#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) :
|
SettingsPage::SettingsPage(QDesignerOptionsPageInterface *designerPage) :
|
||||||
Core::IOptionsPage(nullptr, false),
|
Core::IOptionsPage(nullptr, false)
|
||||||
m_designerPage(designerPage)
|
|
||||||
{
|
{
|
||||||
setId(Utils::Id::fromString(m_designerPage->name()));
|
setId(Utils::Id::fromString(designerPage->name()));
|
||||||
setDisplayName(m_designerPage->name());
|
setDisplayName(designerPage->name());
|
||||||
setCategory(Designer::Constants::SETTINGS_CATEGORY);
|
setCategory(Designer::Constants::SETTINGS_CATEGORY);
|
||||||
}
|
setWidgetCreator([designerPage] { return new SettingsPageWidget(designerPage); });
|
||||||
|
|
||||||
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;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
SettingsPageProvider::SettingsPageProvider()
|
SettingsPageProvider::SettingsPageProvider()
|
||||||
@@ -102,3 +98,5 @@ bool SettingsPageProvider::matches(const QRegularExpression ®ex) const
|
|||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
} // Designer::Internal
|
||||||
|
|||||||
@@ -5,32 +5,16 @@
|
|||||||
|
|
||||||
#include <coreplugin/dialogs/ioptionspage.h>
|
#include <coreplugin/dialogs/ioptionspage.h>
|
||||||
|
|
||||||
#include <QPointer>
|
|
||||||
|
|
||||||
QT_BEGIN_NAMESPACE
|
QT_BEGIN_NAMESPACE
|
||||||
class QDesignerOptionsPageInterface;
|
class QDesignerOptionsPageInterface;
|
||||||
QT_END_NAMESPACE
|
QT_END_NAMESPACE
|
||||||
|
|
||||||
namespace Designer {
|
namespace Designer::Internal {
|
||||||
namespace Internal {
|
|
||||||
|
|
||||||
class SettingsPageWidget;
|
|
||||||
|
|
||||||
class SettingsPage : public Core::IOptionsPage
|
class SettingsPage : public Core::IOptionsPage
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
explicit SettingsPage(QDesignerOptionsPageInterface *designerPage);
|
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
|
class SettingsPageProvider : public Core::IOptionsPageProvider
|
||||||
@@ -48,5 +32,4 @@ private:
|
|||||||
mutable QStringList m_keywords;
|
mutable QStringList m_keywords;
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace Internal
|
} // Designer::Internal
|
||||||
} // namespace Designer
|
|
||||||
|
|||||||
Reference in New Issue
Block a user