Debugger: Use AspectContainer directly for L&E settings page layout

Change-Id: I538362541e67499ee1a93fbd5452bdd76694f87b
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
This commit is contained in:
hjk
2023-07-26 07:39:55 +02:00
parent 55b9e3d151
commit 323e94c2fa
5 changed files with 180 additions and 155 deletions

View File

@@ -11,6 +11,8 @@
#include "registerpostmortemaction.h"
#endif
#include <coreplugin/dialogs/ioptionspage.h>
#include <utils/layoutbuilder.h>
#include <QGuiApplication>
@@ -205,21 +207,110 @@ public:
const CommonSettingsPage commonSettingsPage;
///////////////////////////////////////////////////////////////////////
//
// LocalsAndExpressionsOptionsPage
//
///////////////////////////////////////////////////////////////////////
class LocalsAndExpressionsOptionsPageWidget : public IOptionsPageWidget
// LocalsAndExpressions
LocalsAndExpressionsSettings &localsAndExpressionSettings()
{
public:
LocalsAndExpressionsOptionsPageWidget()
{
DebuggerSettings &s = settings();
setOnApply([&s] { s.page4.apply(); s.page4.writeSettings(); });
setOnFinish([&s] { s.page4.finish(); });
static LocalsAndExpressionsSettings settings;
return settings;
}
LocalsAndExpressionsSettings::LocalsAndExpressionsSettings()
{
setAutoApply(false);
const QString debugModeGroup("DebugMode");
useDebuggingHelpers.setSettingsKey(debugModeGroup, "UseDebuggingHelper");
useDebuggingHelpers.setDefaultValue(true);
useDebuggingHelpers.setLabelText(Tr::tr("Use Debugging Helpers"));
useCodeModel.setSettingsKey(debugModeGroup, "UseCodeModel");
useCodeModel.setDefaultValue(true);
useCodeModel.setLabelText(Tr::tr("Use code model"));
useCodeModel.setToolTip(
"<p>"
+ Tr::tr("Selecting this causes the C++ Code Model being asked "
"for variable scope information. This might result in slightly faster "
"debugger operation but may fail for optimized code."));
showThreadNames.setSettingsKey(debugModeGroup, "ShowThreadNames");
showThreadNames.setLabelText(Tr::tr("Display thread names"));
showThreadNames.setToolTip("<p>" + Tr::tr("Displays names of QThread based threads."));
showStdNamespace.setSettingsKey(debugModeGroup, "ShowStandardNamespace");
showStdNamespace.setDefaultValue(true);
showStdNamespace.setDisplayName(Tr::tr("Show \"std::\" Namespace in Types"));
showStdNamespace.setLabelText(Tr::tr("Show \"std::\" namespace in types"));
showStdNamespace.setToolTip(
"<p>" + Tr::tr("Shows \"std::\" prefix for types from the standard library."));
showQtNamespace.setSettingsKey(debugModeGroup, "ShowQtNamespace");
showQtNamespace.setDefaultValue(true);
showQtNamespace.setDisplayName(Tr::tr("Show Qt's Namespace in Types"));
showQtNamespace.setLabelText(Tr::tr("Show Qt's namespace in types"));
showQtNamespace.setToolTip("<p>"
+ Tr::tr("Shows Qt namespace prefix for Qt types. This is only "
"relevant if Qt was configured with \"-qtnamespace\"."));
showQObjectNames.setSettingsKey(debugModeGroup, "ShowQObjectNames2");
showQObjectNames.setDefaultValue(true);
showQObjectNames.setDisplayName(Tr::tr("Show QObject names if available"));
showQObjectNames.setLabelText(Tr::tr("Show QObject names if available"));
showQObjectNames.setToolTip(
"<p>"
+ Tr::tr("Displays the objectName property of QObject based items. "
"Note that this can negatively impact debugger performance "
"even if no QObjects are present."));
extraDumperCommands.setSettingsKey(debugModeGroup, "GdbCustomDumperCommands");
extraDumperCommands.setDisplayStyle(StringAspect::TextEditDisplay);
extraDumperCommands.setUseGlobalMacroExpander();
extraDumperCommands.setToolTip("<html><head/><body><p>"
+ Tr::tr("Python commands entered here will be executed after built-in "
"debugging helpers have been loaded and fully initialized. You can "
"load additional debugging helpers or modify existing ones here.")
+ "</p></body></html>");
extraDumperFile.setSettingsKey(debugModeGroup, "ExtraDumperFile");
extraDumperFile.setDisplayName(Tr::tr("Extra Debugging Helpers"));
// Label text is intentional empty in the GUI.
extraDumperFile.setToolTip(Tr::tr("Path to a Python file containing additional data dumpers."));
displayStringLimit.setSettingsKey(debugModeGroup, "DisplayStringLimit");
displayStringLimit.setDefaultValue(300);
displayStringLimit.setSpecialValueText(Tr::tr("<unlimited>"));
displayStringLimit.setRange(20, 10000);
displayStringLimit.setSingleStep(10);
displayStringLimit.setLabelText(Tr::tr("Display string length:"));
displayStringLimit.setToolTip(
"<p>"
+ Tr::tr("The maximum length of string entries in the "
"Locals and Expressions views. Longer than that are cut off "
"and displayed with an ellipsis attached."));
maximalStringLength.setSettingsKey(debugModeGroup, "MaximalStringLength");
maximalStringLength.setDefaultValue(10000);
maximalStringLength.setSpecialValueText(Tr::tr("<unlimited>"));
maximalStringLength.setRange(20, 10000000);
maximalStringLength.setSingleStep(20);
maximalStringLength.setLabelText(Tr::tr("Maximum string length:"));
maximalStringLength.setToolTip(
"<p>"
+ Tr::tr("The maximum length for strings in separated windows. "
"Longer strings are cut off and displayed with an ellipsis attached."));
defaultArraySize.setSettingsKey(debugModeGroup, "DefaultArraySize");
defaultArraySize.setDefaultValue(100);
defaultArraySize.setRange(10, 1000000000);
defaultArraySize.setSingleStep(100);
defaultArraySize.setLabelText(Tr::tr("Default array size:"));
defaultArraySize.setToolTip("<p>"
+ Tr::tr("The number of array elements requested when expanding "
"entries in the Locals and Expressions views."));
setLayouter([this] {
auto label = new QLabel; //(useHelperGroup);
label->setTextFormat(Qt::AutoText);
label->setWordWrap(true);
@@ -232,9 +323,9 @@ public:
using namespace Layouting;
Column left {
label,
s.useCodeModel,
s.showThreadNames,
Group { title(Tr::tr("Extra Debugging Helper")), Column { s.extraDumperFile } }
useCodeModel,
showThreadNames,
Group { title(Tr::tr("Extra Debugging Helper")), Column { extraDumperFile } }
};
Group useHelper {
@@ -242,38 +333,46 @@ public:
left,
Group {
title(Tr::tr("Debugging Helper Customization")),
Column { s.extraDumperCommands }
Column { extraDumperCommands }
}
}
};
Grid limits {
s.maximalStringLength, br,
s.displayStringLimit, br,
s.defaultArraySize
maximalStringLength, br,
displayStringLimit, br,
defaultArraySize
};
Column {
s.useDebuggingHelpers,
return Column {
useDebuggingHelpers,
useHelper,
Space(10),
s.showStdNamespace,
s.showQtNamespace,
s.showQObjectNames,
showStdNamespace,
showQtNamespace,
showQObjectNames,
Space(10),
Row { limits, st },
st
}.attachTo(this);
};
});
readSettings();
}
class LocalsAndExpressionsSettingsPage final : public Core::IOptionsPage
{
public:
LocalsAndExpressionsSettingsPage()
{
setId("Z.Debugger.LocalsAndExpressions");
//: '&&' will appear as one (one is marking keyboard shortcut)
setDisplayName(Tr::tr("Locals && Expressions"));
setCategory(DEBUGGER_SETTINGS_CATEGORY);
setSettingsProvider([] { return &localsAndExpressionSettings(); });
}
};
LocalsAndExpressionsOptionsPage::LocalsAndExpressionsOptionsPage()
{
setId("Z.Debugger.LocalsAndExpressions");
//: '&&' will appear as one (one is marking keyboard shortcut)
setDisplayName(Tr::tr("Locals && Expressions"));
setCategory(DEBUGGER_SETTINGS_CATEGORY);
setWidgetCreator([] { return new LocalsAndExpressionsOptionsPageWidget; });
}
const LocalsAndExpressionsSettingsPage localsAndExpressionSettingsPage;
} // Debugger::Internal

View File

@@ -3,7 +3,7 @@
#pragma once
#include <coreplugin/dialogs/ioptionspage.h>
#include <utils/aspects.h>
namespace Debugger::Internal {
@@ -66,12 +66,30 @@ public:
CommonSettings &commonSettings();
class LocalsAndExpressionsOptionsPage final : public Core::IOptionsPage
class LocalsAndExpressionsSettings final : public Utils::AspectContainer
{
public:
LocalsAndExpressionsOptionsPage();
LocalsAndExpressionsSettings();
Utils::BoolAspect useDebuggingHelpers{this};
Utils::BoolAspect useCodeModel{this};
Utils::BoolAspect showThreadNames{this};
Utils::FilePathAspect extraDumperFile{this}; // For loading a file. Recommended.
Utils::StringAspect extraDumperCommands{this}; // To modify an existing setup.
Utils::BoolAspect showStdNamespace{this};
Utils::BoolAspect showQtNamespace{this};
Utils::BoolAspect showQObjectNames{this};
Utils::IntegerAspect maximalStringLength{this};
Utils::IntegerAspect displayStringLimit{this};
Utils::IntegerAspect defaultArraySize{this};
};
LocalsAndExpressionsSettings &localsAndExpressionSettings();
} // Debugger::Internal
Q_DECLARE_METATYPE(Debugger::Internal::SourcePathMap)

View File

@@ -70,7 +70,21 @@ DebuggerSettings::DebuggerSettings() :
breakOnFatal{gdbSettings().breakOnFatal},
breakOnAbort{gdbSettings().breakOnAbort},
enableReverseDebugging{gdbSettings().enableReverseDebugging},
multiInferior{gdbSettings().multiInferior}
multiInferior{gdbSettings().multiInferior},
// Page 4
useDebuggingHelpers{localsAndExpressionSettings().useDebuggingHelpers},
useCodeModel{localsAndExpressionSettings().useCodeModel},
showThreadNames{localsAndExpressionSettings().showThreadNames},
extraDumperFile{localsAndExpressionSettings().extraDumperFile}, // For loading a file. Recommended.
extraDumperCommands{localsAndExpressionSettings().extraDumperCommands}, // To modify an existing setup.
showStdNamespace{localsAndExpressionSettings().showStdNamespace},
showQtNamespace{localsAndExpressionSettings().showQtNamespace},
showQObjectNames{localsAndExpressionSettings().showQObjectNames},
maximalStringLength{localsAndExpressionSettings().maximalStringLength},
displayStringLimit{localsAndExpressionSettings().displayStringLimit},
defaultArraySize{localsAndExpressionSettings().defaultArraySize}
{
const QString debugModeGroup("DebugMode");
const QString cdbSettingsGroup("CDB2");
@@ -175,76 +189,16 @@ DebuggerSettings::DebuggerSettings() :
//
// Locals & Watchers
//
showStdNamespace.setSettingsKey(debugModeGroup, "ShowStandardNamespace");
showStdNamespace.setDefaultValue(true);
showStdNamespace.setDisplayName(Tr::tr("Show \"std::\" Namespace in Types"));
showStdNamespace.setLabelText(Tr::tr("Show \"std::\" namespace in types"));
showStdNamespace.setToolTip(
"<p>" + Tr::tr("Shows \"std::\" prefix for types from the standard library."));
showQtNamespace.setSettingsKey(debugModeGroup, "ShowQtNamespace");
showQtNamespace.setDefaultValue(true);
showQtNamespace.setDisplayName(Tr::tr("Show Qt's Namespace in Types"));
showQtNamespace.setLabelText(Tr::tr("Show Qt's namespace in types"));
showQtNamespace.setToolTip("<p>"
+ Tr::tr("Shows Qt namespace prefix for Qt types. This is only "
"relevant if Qt was configured with \"-qtnamespace\"."));
showQObjectNames.setSettingsKey(debugModeGroup, "ShowQObjectNames2");
showQObjectNames.setDefaultValue(true);
showQObjectNames.setDisplayName(Tr::tr("Show QObject names if available"));
showQObjectNames.setLabelText(Tr::tr("Show QObject names if available"));
showQObjectNames.setToolTip(
"<p>"
+ Tr::tr("Displays the objectName property of QObject based items. "
"Note that this can negatively impact debugger performance "
"even if no QObjects are present."));
sortStructMembers.setSettingsKey(debugModeGroup, "SortStructMembers");
sortStructMembers.setDisplayName(Tr::tr("Sort Members of Classes and Structs Alphabetically"));
sortStructMembers.setLabelText(Tr::tr("Sort members of classes and structs alphabetically"));
sortStructMembers.setDefaultValue(true);
//
// DebuggingHelper
//
useDebuggingHelpers.setSettingsKey(debugModeGroup, "UseDebuggingHelper");
useDebuggingHelpers.setDefaultValue(true);
useDebuggingHelpers.setLabelText(Tr::tr("Use Debugging Helpers"));
useCodeModel.setSettingsKey(debugModeGroup, "UseCodeModel");
useCodeModel.setDefaultValue(true);
useCodeModel.setLabelText(Tr::tr("Use code model"));
useCodeModel.setToolTip(
"<p>"
+ Tr::tr("Selecting this causes the C++ Code Model being asked "
"for variable scope information. This might result in slightly faster "
"debugger operation but may fail for optimized code."));
showThreadNames.setSettingsKey(debugModeGroup, "ShowThreadNames");
showThreadNames.setLabelText(Tr::tr("Display thread names"));
showThreadNames.setToolTip("<p>" + Tr::tr("Displays names of QThread based threads."));
//
// Breakpoints
//
synchronizeBreakpoints.setLabelText(Tr::tr("Synchronize Breakpoints"));
extraDumperCommands.setSettingsKey(debugModeGroup, "GdbCustomDumperCommands");
extraDumperCommands.setDisplayStyle(StringAspect::TextEditDisplay);
extraDumperCommands.setUseGlobalMacroExpander();
extraDumperCommands.setToolTip("<html><head/><body><p>"
+ Tr::tr("Python commands entered here will be executed after built-in "
"debugging helpers have been loaded and fully initialized. You can "
"load additional debugging helpers or modify existing ones here.")
+ "</p></body></html>");
extraDumperFile.setSettingsKey(debugModeGroup, "ExtraDumperFile");
extraDumperFile.setDisplayName(Tr::tr("Extra Debugging Helpers"));
// Label text is intentional empty in the GUI.
extraDumperFile.setToolTip(Tr::tr("Path to a Python file containing additional data dumpers."));
autoQuit.setSettingsKey(debugModeGroup, "AutoQuit");
autoQuit.setLabelText(Tr::tr("Automatically Quit Debugger"));
@@ -277,38 +231,6 @@ DebuggerSettings::DebuggerSettings() :
selectedPluginBreakpointsPattern.setSettingsKey(debugModeGroup, "SelectedPluginBreakpointsPattern");
selectedPluginBreakpointsPattern.setDefaultValue(QString(".*"));
displayStringLimit.setSettingsKey(debugModeGroup, "DisplayStringLimit");
displayStringLimit.setDefaultValue(300);
displayStringLimit.setSpecialValueText(Tr::tr("<unlimited>"));
displayStringLimit.setRange(20, 10000);
displayStringLimit.setSingleStep(10);
displayStringLimit.setLabelText(Tr::tr("Display string length:"));
displayStringLimit.setToolTip(
"<p>"
+ Tr::tr("The maximum length of string entries in the "
"Locals and Expressions views. Longer than that are cut off "
"and displayed with an ellipsis attached."));
maximalStringLength.setSettingsKey(debugModeGroup, "MaximalStringLength");
maximalStringLength.setDefaultValue(10000);
maximalStringLength.setSpecialValueText(Tr::tr("<unlimited>"));
maximalStringLength.setRange(20, 10000000);
maximalStringLength.setSingleStep(20);
maximalStringLength.setLabelText(Tr::tr("Maximum string length:"));
maximalStringLength.setToolTip(
"<p>"
+ Tr::tr("The maximum length for strings in separated windows. "
"Longer strings are cut off and displayed with an ellipsis attached."));
defaultArraySize.setSettingsKey(debugModeGroup, "DefaultArraySize");
defaultArraySize.setDefaultValue(100);
defaultArraySize.setRange(10, 1000000000);
defaultArraySize.setSingleStep(100);
defaultArraySize.setLabelText(Tr::tr("Default array size:"));
defaultArraySize.setToolTip("<p>"
+ Tr::tr("The number of array elements requested when expanding "
"entries in the Locals and Expressions views."));
expandStack.setLabelText(Tr::tr("Reload Full Stack"));
createFullBacktrace.setLabelText(Tr::tr("Create Full Backtrace"));
@@ -319,18 +241,6 @@ DebuggerSettings::DebuggerSettings() :
const QString qmlInspectorGroup = "QML.Inspector";
showAppOnTop.setSettingsKey(qmlInspectorGroup, "QmlInspector.ShowAppOnTop");
// Page 4
page4.registerAspect(&useDebuggingHelpers);
page4.registerAspect(&useCodeModel);
page4.registerAspect(&showThreadNames);
page4.registerAspect(&showStdNamespace);
page4.registerAspect(&showQtNamespace);
page4.registerAspect(&extraDumperFile);
page4.registerAspect(&extraDumperCommands);
page4.registerAspect(&showQObjectNames);
page4.registerAspect(&displayStringLimit);
page4.registerAspect(&maximalStringLength);
page4.registerAspect(&defaultArraySize);
// Page 5
page5.registerAspect(&cdbAdditionalArguments);
@@ -357,7 +267,6 @@ DebuggerSettings::DebuggerSettings() :
all.registerAspect(&sortStructMembers);
// Collect all
all.registerAspects(page4);
all.registerAspects(page5);
all.registerAspects(page6);

View File

@@ -62,15 +62,19 @@ public:
Utils::BoolAspect &multiInferior;
// Page 4: Locals and expressions
Utils::BoolAspect useDebuggingHelpers;
Utils::BoolAspect useCodeModel;
Utils::BoolAspect showThreadNames;
Utils::FilePathAspect extraDumperFile; // For loading a file. Recommended.
Utils::StringAspect extraDumperCommands; // To modify an existing setup.
Utils::BoolAspect &useDebuggingHelpers;
Utils::BoolAspect &useCodeModel;
Utils::BoolAspect &showThreadNames;
Utils::FilePathAspect &extraDumperFile; // For loading a file. Recommended.
Utils::StringAspect &extraDumperCommands; // To modify an existing setup.
Utils::BoolAspect showStdNamespace;
Utils::BoolAspect showQtNamespace;
Utils::BoolAspect showQObjectNames;
Utils::BoolAspect &showStdNamespace;
Utils::BoolAspect &showQtNamespace;
Utils::BoolAspect &showQObjectNames;
Utils::IntegerAspect &maximalStringLength;
Utils::IntegerAspect &displayStringLimit;
Utils::IntegerAspect &defaultArraySize;
// Page 5: CDB
Utils::StringAspect cdbAdditionalArguments;
@@ -101,9 +105,6 @@ public:
// Watchers & Locals
Utils::BoolAspect autoDerefPointers;
Utils::IntegerAspect maximalStringLength;
Utils::IntegerAspect displayStringLimit;
Utils::IntegerAspect defaultArraySize;
Utils::BoolAspect sortStructMembers;
Utils::BoolAspect useToolTipsInLocalsView;
@@ -119,7 +120,6 @@ public:
Utils::BoolAspect showAppOnTop;
Utils::AspectContainer all; // All
Utils::AspectContainer page4; // Locals & Expressions
Utils::AspectContainer page5; // CDB
Utils::AspectContainer page6; // CDB Paths

View File

@@ -1122,7 +1122,6 @@ DebuggerPluginPrivate::DebuggerPluginPrivate(const QStringList &arguments)
// QTC_CHECK(false);
// });
m_optionPages.append(new LocalsAndExpressionsOptionsPage);
addCdbOptionPages(&m_optionPages);
connect(ModeManager::instance(), &ModeManager::currentModeAboutToChange, this, [] {