forked from qt-creator/qt-creator
Macros: Use new settings page convenience
Change-Id: I42caad4311d4238310a767543acafe0a142917f4 Reviewed-by: Eike Ziller <eike.ziller@qt.io>
This commit is contained in:
@@ -33,7 +33,6 @@
|
||||
|
||||
#include <QCoreApplication>
|
||||
#include <QWidget>
|
||||
#include <QIcon>
|
||||
|
||||
using namespace Macros;
|
||||
using namespace Macros::Internal;
|
||||
@@ -44,22 +43,5 @@ MacroOptionsPage::MacroOptionsPage()
|
||||
setId(Constants::M_OPTIONS_PAGE);
|
||||
setDisplayName(QCoreApplication::translate("Macros", Constants::M_OPTIONS_TR_PAGE));
|
||||
setCategory(TextEditor::Constants::TEXT_EDITOR_SETTINGS_CATEGORY);
|
||||
}
|
||||
|
||||
QWidget *MacroOptionsPage::widget()
|
||||
{
|
||||
if (!m_widget)
|
||||
m_widget = new MacroOptionsWidget;
|
||||
return m_widget;
|
||||
}
|
||||
|
||||
void MacroOptionsPage::apply()
|
||||
{
|
||||
if (m_widget)
|
||||
m_widget->apply();
|
||||
}
|
||||
|
||||
void MacroOptionsPage::finish()
|
||||
{
|
||||
delete m_widget;
|
||||
setWidgetCreator([] { return new MacroOptionsWidget; });
|
||||
}
|
||||
|
@@ -27,27 +27,15 @@
|
||||
|
||||
#include <coreplugin/dialogs/ioptionspage.h>
|
||||
|
||||
#include <QPointer>
|
||||
|
||||
namespace Macros {
|
||||
namespace Internal {
|
||||
|
||||
class MacroOptionsWidget;
|
||||
|
||||
class MacroOptionsPage : public Core::IOptionsPage
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
MacroOptionsPage();
|
||||
|
||||
// IOptionsPage implementation
|
||||
QWidget *widget() override;
|
||||
void apply() override;
|
||||
void finish() override;
|
||||
|
||||
private:
|
||||
QPointer<MacroOptionsWidget> m_widget;
|
||||
};
|
||||
|
||||
} // namespace Internal
|
||||
|
@@ -50,10 +50,8 @@ using namespace Macros;
|
||||
using namespace Macros::Internal;
|
||||
|
||||
|
||||
MacroOptionsWidget::MacroOptionsWidget(QWidget *parent) :
|
||||
QWidget(parent),
|
||||
m_ui(new Ui::MacroOptionsWidget),
|
||||
m_changingCurrent(false)
|
||||
MacroOptionsWidget::MacroOptionsWidget() :
|
||||
m_ui(new Ui::MacroOptionsWidget)
|
||||
{
|
||||
m_ui->setupUi(this);
|
||||
|
||||
|
@@ -25,7 +25,7 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <QWidget>
|
||||
#include <coreplugin/dialogs/ioptionspage.h>
|
||||
|
||||
#include <QStringList>
|
||||
#include <QMap>
|
||||
@@ -34,21 +34,23 @@ QT_BEGIN_NAMESPACE
|
||||
class QTreeWidgetItem;
|
||||
QT_END_NAMESPACE
|
||||
|
||||
|
||||
namespace Macros {
|
||||
namespace Internal {
|
||||
|
||||
namespace Ui { class MacroOptionsWidget; }
|
||||
|
||||
class MacroOptionsWidget : public QWidget {
|
||||
class MacroOptionsWidget : public Core::IOptionsPageWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit MacroOptionsWidget(QWidget *parent = nullptr);
|
||||
~MacroOptionsWidget() override;
|
||||
MacroOptionsWidget();
|
||||
~MacroOptionsWidget() final;
|
||||
|
||||
void initialize();
|
||||
|
||||
void apply();
|
||||
void apply() final;
|
||||
void finish() final {}
|
||||
|
||||
private:
|
||||
void remove();
|
||||
@@ -61,7 +63,7 @@ private:
|
||||
private:
|
||||
Ui::MacroOptionsWidget *m_ui;
|
||||
QStringList m_macroToRemove;
|
||||
bool m_changingCurrent;
|
||||
bool m_changingCurrent = false;
|
||||
|
||||
QMap<QString, QString> m_macroToChange;
|
||||
};
|
||||
|
Reference in New Issue
Block a user