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 <QCoreApplication>
|
||||||
#include <QWidget>
|
#include <QWidget>
|
||||||
#include <QIcon>
|
|
||||||
|
|
||||||
using namespace Macros;
|
using namespace Macros;
|
||||||
using namespace Macros::Internal;
|
using namespace Macros::Internal;
|
||||||
@@ -44,22 +43,5 @@ MacroOptionsPage::MacroOptionsPage()
|
|||||||
setId(Constants::M_OPTIONS_PAGE);
|
setId(Constants::M_OPTIONS_PAGE);
|
||||||
setDisplayName(QCoreApplication::translate("Macros", Constants::M_OPTIONS_TR_PAGE));
|
setDisplayName(QCoreApplication::translate("Macros", Constants::M_OPTIONS_TR_PAGE));
|
||||||
setCategory(TextEditor::Constants::TEXT_EDITOR_SETTINGS_CATEGORY);
|
setCategory(TextEditor::Constants::TEXT_EDITOR_SETTINGS_CATEGORY);
|
||||||
}
|
setWidgetCreator([] { return new MacroOptionsWidget; });
|
||||||
|
|
||||||
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;
|
|
||||||
}
|
}
|
||||||
|
@@ -27,27 +27,15 @@
|
|||||||
|
|
||||||
#include <coreplugin/dialogs/ioptionspage.h>
|
#include <coreplugin/dialogs/ioptionspage.h>
|
||||||
|
|
||||||
#include <QPointer>
|
|
||||||
|
|
||||||
namespace Macros {
|
namespace Macros {
|
||||||
namespace Internal {
|
namespace Internal {
|
||||||
|
|
||||||
class MacroOptionsWidget;
|
|
||||||
|
|
||||||
class MacroOptionsPage : public Core::IOptionsPage
|
class MacroOptionsPage : public Core::IOptionsPage
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
MacroOptionsPage();
|
MacroOptionsPage();
|
||||||
|
|
||||||
// IOptionsPage implementation
|
|
||||||
QWidget *widget() override;
|
|
||||||
void apply() override;
|
|
||||||
void finish() override;
|
|
||||||
|
|
||||||
private:
|
|
||||||
QPointer<MacroOptionsWidget> m_widget;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace Internal
|
} // namespace Internal
|
||||||
|
@@ -50,10 +50,8 @@ using namespace Macros;
|
|||||||
using namespace Macros::Internal;
|
using namespace Macros::Internal;
|
||||||
|
|
||||||
|
|
||||||
MacroOptionsWidget::MacroOptionsWidget(QWidget *parent) :
|
MacroOptionsWidget::MacroOptionsWidget() :
|
||||||
QWidget(parent),
|
m_ui(new Ui::MacroOptionsWidget)
|
||||||
m_ui(new Ui::MacroOptionsWidget),
|
|
||||||
m_changingCurrent(false)
|
|
||||||
{
|
{
|
||||||
m_ui->setupUi(this);
|
m_ui->setupUi(this);
|
||||||
|
|
||||||
|
@@ -25,7 +25,7 @@
|
|||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <QWidget>
|
#include <coreplugin/dialogs/ioptionspage.h>
|
||||||
|
|
||||||
#include <QStringList>
|
#include <QStringList>
|
||||||
#include <QMap>
|
#include <QMap>
|
||||||
@@ -34,21 +34,23 @@ QT_BEGIN_NAMESPACE
|
|||||||
class QTreeWidgetItem;
|
class QTreeWidgetItem;
|
||||||
QT_END_NAMESPACE
|
QT_END_NAMESPACE
|
||||||
|
|
||||||
|
|
||||||
namespace Macros {
|
namespace Macros {
|
||||||
namespace Internal {
|
namespace Internal {
|
||||||
|
|
||||||
namespace Ui { class MacroOptionsWidget; }
|
namespace Ui { class MacroOptionsWidget; }
|
||||||
|
|
||||||
class MacroOptionsWidget : public QWidget {
|
class MacroOptionsWidget : public Core::IOptionsPageWidget
|
||||||
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
explicit MacroOptionsWidget(QWidget *parent = nullptr);
|
MacroOptionsWidget();
|
||||||
~MacroOptionsWidget() override;
|
~MacroOptionsWidget() final;
|
||||||
|
|
||||||
void initialize();
|
void initialize();
|
||||||
|
|
||||||
void apply();
|
void apply() final;
|
||||||
|
void finish() final {}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void remove();
|
void remove();
|
||||||
@@ -61,7 +63,7 @@ private:
|
|||||||
private:
|
private:
|
||||||
Ui::MacroOptionsWidget *m_ui;
|
Ui::MacroOptionsWidget *m_ui;
|
||||||
QStringList m_macroToRemove;
|
QStringList m_macroToRemove;
|
||||||
bool m_changingCurrent;
|
bool m_changingCurrent = false;
|
||||||
|
|
||||||
QMap<QString, QString> m_macroToChange;
|
QMap<QString, QString> m_macroToChange;
|
||||||
};
|
};
|
||||||
|
Reference in New Issue
Block a user