Debugger: Use new IOptionsPage apply convenience

Change-Id: I2954bec762fb3f5d3426663108ff493f140f1b5e
Reviewed-by: David Schulz <david.schulz@qt.io>
This commit is contained in:
hjk
2021-03-25 15:45:58 +01:00
parent 1dba079cbd
commit c38739df57

View File

@@ -29,7 +29,6 @@
#include <debugger/debuggerconstants.h>
#include <coreplugin/dialogs/ioptionspage.h>
#include <coreplugin/icore.h>
#include <utils/layoutbuilder.h>
@@ -41,7 +40,7 @@ namespace Internal {
/////////////////////////////////////////////////////////////////////////
//
// GdbOptionsPageWidget - harmless options
// GdbOptionsPage - harmless options
//
/////////////////////////////////////////////////////////////////////////
@@ -50,24 +49,14 @@ class GdbOptionsPage : public Core::IOptionsPage
Q_DECLARE_TR_FUNCTIONS(Debugger::Internal::GdbOptionsPage)
public:
GdbOptionsPage();
};
GdbOptionsPage()
{
setId("M.Gdb");
setDisplayName(tr("GDB"));
setCategory(Constants::DEBUGGER_SETTINGS_CATEGORY);
setSettings(&debuggerSettings()->page2);
class GdbOptionsPageWidget : public IOptionsPageWidget
{
Q_DECLARE_TR_FUNCTIONS(Debugger::Internal::GdbOptionsPage)
public:
GdbOptionsPageWidget();
void apply() final { group.apply(); group.writeSettings(ICore::settings()); }
void finish() final { group.finish(); }
AspectContainer &group = debuggerSettings()->page2;
};
GdbOptionsPageWidget::GdbOptionsPageWidget()
{
setLayouter([](QWidget *w) {
using namespace Layouting;
DebuggerSettings &s = *debuggerSettings();
@@ -91,36 +80,29 @@ GdbOptionsPageWidget::GdbOptionsPageWidget()
Stretch()
};
Row { general, commands }.attachTo(this);
}
GdbOptionsPage::GdbOptionsPage()
{
setId("M.Gdb");
setDisplayName(tr("GDB"));
setCategory(Constants::DEBUGGER_SETTINGS_CATEGORY);
setWidgetCreator([] { return new GdbOptionsPageWidget; });
}
/////////////////////////////////////////////////////////////////////////
//
// GdbOptionsPageWidget2 - dangerous options
//
/////////////////////////////////////////////////////////////////////////
class GdbOptionsPageWidget2 : public IOptionsPageWidget
{
public:
GdbOptionsPageWidget2();
void apply() final { group.apply(); group.writeSettings(ICore::settings()); }
void finish() final { group.finish(); }
AspectContainer &group = debuggerSettings()->page3;
Row { general, commands }.attachTo(w);
});
}
};
GdbOptionsPageWidget2::GdbOptionsPageWidget2()
/////////////////////////////////////////////////////////////////////////
//
// GdbOptionsPage2 - dangerous options
//
/////////////////////////////////////////////////////////////////////////
// The "Dangerous" options.
class GdbOptionsPage2 : public Core::IOptionsPage
{
public:
GdbOptionsPage2()
{
setId("M.Gdb2");
setDisplayName(GdbOptionsPage::tr("GDB Extended"));
setCategory(Constants::DEBUGGER_SETTINGS_CATEGORY);
setSettings(&debuggerSettings()->page3);
setLayouter([](QWidget *w) {
auto labelDangerous = new QLabel("<html><head/><body><i>" +
GdbOptionsPage::tr("The options below give access to advanced "
"or experimental functions of GDB.<br>Enabling them may negatively "
@@ -141,19 +123,8 @@ GdbOptionsPageWidget2::GdbOptionsPageWidget2()
s.multiInferior,
};
Column { extended, Stretch() }.attachTo(this);
}
// The "Dangerous" options.
class GdbOptionsPage2 : public Core::IOptionsPage
{
public:
GdbOptionsPage2()
{
setId("M.Gdb2");
setDisplayName(GdbOptionsPage::tr("GDB Extended"));
setCategory(Constants::DEBUGGER_SETTINGS_CATEGORY);
setWidgetCreator([] { return new GdbOptionsPageWidget2; });
Column { extended, Stretch() }.attachTo(w);
});
}
};