Core: Even terser layout setup for option pages

Change-Id: Id39c841da70c87d47c125903b390a75c4414cc2f
Reviewed-by: Alessandro Portale <alessandro.portale@qt.io>
Reviewed-by: <github-actions-qt-creator@cristianadam.eu>
This commit is contained in:
hjk
2023-05-17 09:43:14 +02:00
parent d4cf9b667b
commit 22af1a0255
7 changed files with 25 additions and 17 deletions

View File

@@ -22,15 +22,15 @@ BoostTestSettings::BoostTestSettings(Id settingsId)
setDisplayName(Tr::tr(BoostTest::Constants::FRAMEWORK_SETTINGS_CATEGORY));
setSettingsGroups("Autotest", "BoostTest");
setLayouter([this](QWidget *widget) {
Row { Form {
setLayouter([this] {
return Row { Form {
logLevel, br,
reportLevel, br,
randomize, Row { seed }, br,
systemErrors, br,
fpExceptions, br,
memLeaks,
}, st}.attachTo(widget);
}, st};
});
registerAspect(&logLevel);

View File

@@ -6,8 +6,6 @@
#include "../autotestconstants.h"
#include "../autotesttr.h"
#include <coreplugin/icore.h>
#include <utils/layoutbuilder.h>
using namespace Layouting;
@@ -22,8 +20,8 @@ CatchTestSettings::CatchTestSettings(Id settingsId)
setDisplayName(Tr::tr("Catch Test"));
setSettingsGroups("Autotest", "Catch2");
setLayouter([this](QWidget *widget) {
Row { Form {
setLayouter([this] {
return Row { Form {
showSuccess, br,
breakOnFailure, br,
noThrow, br,
@@ -34,7 +32,7 @@ CatchTestSettings::CatchTestSettings(Id settingsId)
confidenceIntervalChecked, confidenceInterval, br,
warmupChecked, benchmarkWarmupTime, br,
noAnalysis
}, st }.attachTo(widget);
}, st };
});
registerAspect(&abortAfter);

View File

@@ -23,15 +23,15 @@ GTestSettings::GTestSettings(Id settingsId)
setCategory(Constants::AUTOTEST_SETTINGS_CATEGORY);
setDisplayName(Tr::tr(GTest::Constants::FRAMEWORK_SETTINGS_CATEGORY));
setLayouter([this](QWidget *widget) {
Row { Form {
setLayouter([this] {
return Row { Form {
runDisabled, br,
breakOnFailure, br,
repeat, iterations, br,
shuffle, seed, br,
groupMode, br,
gtestFilter, br
}, st }.attachTo(widget);
}, st };
});
registerAspect(&iterations);

View File

@@ -22,8 +22,8 @@ QtTestSettings::QtTestSettings(Id settingsId)
setCategory(Constants::AUTOTEST_SETTINGS_CATEGORY);
setDisplayName(Tr::tr(QtTest::Constants::FRAMEWORK_SETTINGS_CATEGORY));
setLayouter([this](QWidget *widget) {
Row { Form {
setLayouter([this] {
return Row { Form {
noCrashHandler, br,
useXMLOutput, br,
verboseBench, br,
@@ -34,7 +34,7 @@ QtTestSettings::QtTestSettings(Id settingsId)
Column { metrics }
}, br,
quickCheckForDerivedTests, br
}, st }.attachTo(widget);
}, st };
});
registerAspect(&metrics);

View File

@@ -208,6 +208,15 @@ void IOptionsPage::setLayouter(const std::function<void(QWidget *w)> &layouter)
};
}
void IOptionsPage::setLayouter(const std::function<Layouting::LayoutItem ()> &layouter)
{
m_widgetCreator = [layouter] {
auto widget = new IOptionsPageWidget;
layouter().attachTo(widget);
return widget;
};
}
/*!
\fn void Core::IOptionsPage::setId(Utils::Id id)

View File

@@ -75,6 +75,7 @@ protected:
void setCategoryIconPath(const Utils::FilePath &categoryIconPath);
void setSettings(Utils::AspectContainer *settings);
void setLayouter(const std::function<void(QWidget *w)> &layouter);
void setLayouter(const std::function<Layouting::LayoutItem()> &layouter);
// Used in FontSettingsPage. FIXME?
QPointer<QWidget> m_widget; // Used in conjunction with m_widgetCreator

View File

@@ -33,7 +33,7 @@ FileShareProtocolSettings::FileShareProtocolSettings()
displayCount.setSuffix(' ' + Tr::tr("entries"));
displayCount.setLabelText(Tr::tr("&Display:"));
setLayouter([this](QWidget *widget) {
setLayouter([this] {
using namespace Layouting;
auto label = new QLabel(Tr::tr(
@@ -41,14 +41,14 @@ FileShareProtocolSettings::FileShareProtocolSettings()
"simple files on a shared network drive. Files are never deleted."));
label->setWordWrap(true);
Column {
return Column {
Form {
label, br,
path, br,
displayCount
},
st
}.attachTo(widget);
};
});
readSettings();