Utils: Rework CheckableMessageBox

Remove function overloads, thes are hard to read, to use and to extend.
I'd even argue this should be a plain default ctor and a few setters +
exec(), pretty much like Process::start() nowadays.

Move "decider" magic into a structure that can be filled ad-hoc outside
checkablemessagebox.cpp paving the ground for:

...removing  aspect dependency from CheckableMessageBox, Instead, add a
convenience function to BoolAspect.  Arguably, the latter is not needed
and could be done on the user side.

Use pointers instead of mutable references for in-out parameter.
Makes the "specialness" visible on the user side.

Pass ICore::settings() centrally as done elsewhere to reduce line noise
on the user side.

Change-Id: Ibb366353d1ea35401723fd05ce05672617a0a8fd
Reviewed-by: Marcus Tillmanns <marcus.tillmanns@qt.io>
This commit is contained in:
hjk
2023-05-19 10:09:59 +02:00
parent c0ebf227a7
commit d740a355bb
29 changed files with 129 additions and 319 deletions

View File

@@ -4,6 +4,7 @@
#include "aspects.h"
#include "algorithm.h"
#include "checkablemessagebox.h"
#include "environment.h"
#include "fancylineedit.h"
#include "layoutbuilder.h"
@@ -1358,11 +1359,10 @@ FilePathAspect::FilePathAspect()
The color aspect is displayed using a QtColorButton.
*/
ColorAspect::ColorAspect(const QString &settingsKey)
ColorAspect::ColorAspect()
: d(new Internal::ColorAspectPrivate)
{
setDefaultValue(QColor::fromRgb(0, 0, 0));
setSettingsKey(settingsKey);
setSpan(1, 1);
addDataExtractor(this, &ColorAspect::value, &Data::value);
@@ -1587,6 +1587,14 @@ void BoolAspect::setLabelPlacement(BoolAspect::LabelPlacement labelPlacement)
d->m_labelPlacement = labelPlacement;
}
CheckableDecider BoolAspect::checkableDecider()
{
return CheckableDecider(
[this] { return !value(); },
[this] { setValue(true); }
);
}
/*!
\class Utils::SelectionAspect
\inmodule QtCreator