diff --git a/src/plugins/debugger/commonoptionspage.cpp b/src/plugins/debugger/commonoptionspage.cpp index 053031e2974..9418c704d6f 100644 --- a/src/plugins/debugger/commonoptionspage.cpp +++ b/src/plugins/debugger/commonoptionspage.cpp @@ -11,6 +11,8 @@ #include "registerpostmortemaction.h" #endif +#include + #include #include @@ -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( + "

" + + 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("

" + 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( + "

" + 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("

" + + 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( + "

" + + 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("

" + + 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.") + + "

"); + + 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("")); + displayStringLimit.setRange(20, 10000); + displayStringLimit.setSingleStep(10); + displayStringLimit.setLabelText(Tr::tr("Display string length:")); + displayStringLimit.setToolTip( + "

" + + 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("")); + maximalStringLength.setRange(20, 10000000); + maximalStringLength.setSingleStep(20); + maximalStringLength.setLabelText(Tr::tr("Maximum string length:")); + maximalStringLength.setToolTip( + "

" + + 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("

" + + 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 diff --git a/src/plugins/debugger/commonoptionspage.h b/src/plugins/debugger/commonoptionspage.h index d60658710a4..6b890b53a56 100644 --- a/src/plugins/debugger/commonoptionspage.h +++ b/src/plugins/debugger/commonoptionspage.h @@ -3,7 +3,7 @@ #pragma once -#include +#include 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) diff --git a/src/plugins/debugger/debuggeractions.cpp b/src/plugins/debugger/debuggeractions.cpp index 17c9ca32587..c6f91192396 100644 --- a/src/plugins/debugger/debuggeractions.cpp +++ b/src/plugins/debugger/debuggeractions.cpp @@ -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( - "

" + 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("

" - + 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( - "

" - + 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( - "

" - + 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("

" + 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("

" - + 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.") - + "

"); - - 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("")); - displayStringLimit.setRange(20, 10000); - displayStringLimit.setSingleStep(10); - displayStringLimit.setLabelText(Tr::tr("Display string length:")); - displayStringLimit.setToolTip( - "

" - + 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("")); - maximalStringLength.setRange(20, 10000000); - maximalStringLength.setSingleStep(20); - maximalStringLength.setLabelText(Tr::tr("Maximum string length:")); - maximalStringLength.setToolTip( - "

" - + 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("

" - + 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); diff --git a/src/plugins/debugger/debuggeractions.h b/src/plugins/debugger/debuggeractions.h index 689580dca9a..f20d60839b0 100644 --- a/src/plugins/debugger/debuggeractions.h +++ b/src/plugins/debugger/debuggeractions.h @@ -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 diff --git a/src/plugins/debugger/debuggerplugin.cpp b/src/plugins/debugger/debuggerplugin.cpp index 18d68ac2bb9..e9acc715755 100644 --- a/src/plugins/debugger/debuggerplugin.cpp +++ b/src/plugins/debugger/debuggerplugin.cpp @@ -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, [] {