forked from qt-creator/qt-creator
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:
@@ -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
|
||||
|
@@ -24,6 +24,7 @@ namespace Utils {
|
||||
|
||||
class AspectContainer;
|
||||
class BoolAspect;
|
||||
class CheckableDecider;
|
||||
|
||||
namespace Internal {
|
||||
class AspectContainerPrivate;
|
||||
@@ -222,6 +223,7 @@ public:
|
||||
|
||||
void addToLayout(Layouting::LayoutItem &parent) override;
|
||||
std::function<void(QObject *)> groupChecker();
|
||||
Utils::CheckableDecider checkableDecider();
|
||||
|
||||
QAction *action() override;
|
||||
|
||||
@@ -255,7 +257,7 @@ class QTCREATOR_UTILS_EXPORT ColorAspect : public BaseAspect
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit ColorAspect(const QString &settingsKey = QString());
|
||||
ColorAspect();
|
||||
~ColorAspect() override;
|
||||
|
||||
struct Data : BaseAspect::Data
|
||||
|
@@ -31,16 +31,19 @@ static const char kDoNotAskAgainKey[] = "DoNotAskAgain";
|
||||
|
||||
namespace Utils {
|
||||
|
||||
static QSettings *theSettings;
|
||||
|
||||
static QMessageBox::StandardButton exec(
|
||||
QWidget *parent,
|
||||
QMessageBox::Icon icon,
|
||||
const QString &title,
|
||||
const QString &text,
|
||||
std::optional<CheckableMessageBox::Decider> decider,
|
||||
const CheckableDecider &decider,
|
||||
QMessageBox::StandardButtons buttons,
|
||||
QMessageBox::StandardButton defaultButton,
|
||||
QMessageBox::StandardButton acceptButton,
|
||||
QMap<QMessageBox::StandardButton, QString> buttonTextOverrides)
|
||||
QMap<QMessageBox::StandardButton, QString> buttonTextOverrides,
|
||||
const QString &msg)
|
||||
{
|
||||
QMessageBox msgBox(parent);
|
||||
msgBox.setWindowTitle(title);
|
||||
@@ -59,18 +62,13 @@ static QMessageBox::StandardButton exec(
|
||||
}
|
||||
}
|
||||
|
||||
if (decider) {
|
||||
if (!CheckableMessageBox::shouldAskAgain(*decider))
|
||||
if (decider.shouldAskAgain) {
|
||||
if (!decider.shouldAskAgain())
|
||||
return acceptButton;
|
||||
|
||||
msgBox.setCheckBox(new QCheckBox);
|
||||
msgBox.checkBox()->setChecked(false);
|
||||
|
||||
std::visit(
|
||||
[&msgBox](auto &&decider) {
|
||||
msgBox.checkBox()->setText(decider.text);
|
||||
},
|
||||
*decider);
|
||||
msgBox.checkBox()->setText(msg);
|
||||
}
|
||||
|
||||
msgBox.setStandardButtons(buttons);
|
||||
@@ -81,21 +79,44 @@ static QMessageBox::StandardButton exec(
|
||||
|
||||
QMessageBox::StandardButton clickedBtn = msgBox.standardButton(msgBox.clickedButton());
|
||||
|
||||
if (decider && msgBox.checkBox()->isChecked()
|
||||
if (decider.doNotAskAgain && msgBox.checkBox()->isChecked()
|
||||
&& (acceptButton == QMessageBox::NoButton || clickedBtn == acceptButton))
|
||||
CheckableMessageBox::doNotAskAgain(*decider);
|
||||
decider.doNotAskAgain();
|
||||
return clickedBtn;
|
||||
}
|
||||
|
||||
CheckableDecider::CheckableDecider(const QString &settingsSubKey)
|
||||
{
|
||||
QTC_ASSERT(theSettings, return);
|
||||
shouldAskAgain = [settingsSubKey] {
|
||||
theSettings->beginGroup(QLatin1String(kDoNotAskAgainKey));
|
||||
bool shouldNotAsk = theSettings->value(settingsSubKey, false).toBool();
|
||||
theSettings->endGroup();
|
||||
return !shouldNotAsk;
|
||||
};
|
||||
doNotAskAgain = [settingsSubKey] {
|
||||
theSettings->beginGroup(QLatin1String(kDoNotAskAgainKey));
|
||||
theSettings->setValue(settingsSubKey, true);
|
||||
theSettings->endGroup();
|
||||
};
|
||||
}
|
||||
|
||||
CheckableDecider::CheckableDecider(bool *storage)
|
||||
{
|
||||
shouldAskAgain = [storage] { return !*storage; };
|
||||
doNotAskAgain = [storage] { *storage = true; };
|
||||
}
|
||||
|
||||
QMessageBox::StandardButton CheckableMessageBox::question(
|
||||
QWidget *parent,
|
||||
const QString &title,
|
||||
const QString &question,
|
||||
std::optional<Decider> decider,
|
||||
const CheckableDecider &decider,
|
||||
QMessageBox::StandardButtons buttons,
|
||||
QMessageBox::StandardButton defaultButton,
|
||||
QMessageBox::StandardButton acceptButton,
|
||||
QMap<QMessageBox::StandardButton, QString> buttonTextOverrides)
|
||||
QMap<QMessageBox::StandardButton, QString> buttonTextOverrides,
|
||||
const QString &msg)
|
||||
{
|
||||
return exec(parent,
|
||||
QMessageBox::Question,
|
||||
@@ -105,17 +126,19 @@ QMessageBox::StandardButton CheckableMessageBox::question(
|
||||
buttons,
|
||||
defaultButton,
|
||||
acceptButton,
|
||||
buttonTextOverrides);
|
||||
buttonTextOverrides,
|
||||
msg.isEmpty() ? msgDoNotAskAgain() : msg);
|
||||
}
|
||||
|
||||
QMessageBox::StandardButton CheckableMessageBox::information(
|
||||
QWidget *parent,
|
||||
const QString &title,
|
||||
const QString &text,
|
||||
std::optional<Decider> decider,
|
||||
const CheckableDecider &decider,
|
||||
QMessageBox::StandardButtons buttons,
|
||||
QMessageBox::StandardButton defaultButton,
|
||||
QMap<QMessageBox::StandardButton, QString> buttonTextOverrides)
|
||||
QMap<QMessageBox::StandardButton, QString> buttonTextOverrides,
|
||||
const QString &msg)
|
||||
{
|
||||
return exec(parent,
|
||||
QMessageBox::Information,
|
||||
@@ -125,82 +148,33 @@ QMessageBox::StandardButton CheckableMessageBox::information(
|
||||
buttons,
|
||||
defaultButton,
|
||||
QMessageBox::NoButton,
|
||||
buttonTextOverrides);
|
||||
}
|
||||
|
||||
void CheckableMessageBox::doNotAskAgain(Decider &decider)
|
||||
{
|
||||
std::visit(
|
||||
[](auto &&decider) {
|
||||
using T = std::decay_t<decltype(decider)>;
|
||||
if constexpr (std::is_same_v<T, BoolDecision>) {
|
||||
decider.doNotAskAgain = true;
|
||||
} else if constexpr (std::is_same_v<T, SettingsDecision>) {
|
||||
decider.settings->beginGroup(QLatin1String(kDoNotAskAgainKey));
|
||||
decider.settings->setValue(decider.settingsSubKey, true);
|
||||
decider.settings->endGroup();
|
||||
} else if constexpr (std::is_same_v<T, AspectDecision>) {
|
||||
decider.aspect.setValue(true);
|
||||
}
|
||||
},
|
||||
decider);
|
||||
}
|
||||
|
||||
bool CheckableMessageBox::shouldAskAgain(const Decider &decider)
|
||||
{
|
||||
bool result = std::visit(
|
||||
[](auto &&decider) {
|
||||
using T = std::decay_t<decltype(decider)>;
|
||||
if constexpr (std::is_same_v<T, BoolDecision>) {
|
||||
return !decider.doNotAskAgain;
|
||||
} else if constexpr (std::is_same_v<T, SettingsDecision>) {
|
||||
decider.settings->beginGroup(QLatin1String(kDoNotAskAgainKey));
|
||||
bool shouldNotAsk = decider.settings->value(decider.settingsSubKey, false).toBool();
|
||||
decider.settings->endGroup();
|
||||
return !shouldNotAsk;
|
||||
} else if constexpr (std::is_same_v<T, AspectDecision>) {
|
||||
return !decider.aspect.value();
|
||||
}
|
||||
},
|
||||
decider);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
bool CheckableMessageBox::shouldAskAgain(QSettings *settings, const QString &key)
|
||||
{
|
||||
return shouldAskAgain(make_decider(settings, key));
|
||||
}
|
||||
|
||||
void CheckableMessageBox::doNotAskAgain(QSettings *settings, const QString &key)
|
||||
{
|
||||
Decider decider = make_decider(settings, key);
|
||||
return doNotAskAgain(decider);
|
||||
buttonTextOverrides,
|
||||
msg.isEmpty() ? msgDoNotShowAgain() : msg);
|
||||
}
|
||||
|
||||
/*!
|
||||
Resets all suppression settings for doNotAskAgainQuestion() found in \a settings,
|
||||
Resets all suppression settings for doNotAskAgainQuestion()
|
||||
so all these message boxes are shown again.
|
||||
*/
|
||||
void CheckableMessageBox::resetAllDoNotAskAgainQuestions(QSettings *settings)
|
||||
void CheckableMessageBox::resetAllDoNotAskAgainQuestions()
|
||||
{
|
||||
QTC_ASSERT(settings, return);
|
||||
settings->beginGroup(QLatin1String(kDoNotAskAgainKey));
|
||||
settings->remove(QString());
|
||||
settings->endGroup();
|
||||
QTC_ASSERT(theSettings, return);
|
||||
theSettings->beginGroup(QLatin1String(kDoNotAskAgainKey));
|
||||
theSettings->remove(QString());
|
||||
theSettings->endGroup();
|
||||
}
|
||||
|
||||
/*!
|
||||
Returns whether any message boxes from doNotAskAgainQuestion() are suppressed
|
||||
in the \a settings.
|
||||
in the settings.
|
||||
*/
|
||||
bool CheckableMessageBox::hasSuppressedQuestions(QSettings *settings)
|
||||
bool CheckableMessageBox::hasSuppressedQuestions()
|
||||
{
|
||||
QTC_ASSERT(settings, return false);
|
||||
settings->beginGroup(QLatin1String(kDoNotAskAgainKey));
|
||||
const bool hasSuppressed = !settings->childKeys().isEmpty()
|
||||
|| !settings->childGroups().isEmpty();
|
||||
settings->endGroup();
|
||||
QTC_ASSERT(theSettings, return false);
|
||||
theSettings->beginGroup(QLatin1String(kDoNotAskAgainKey));
|
||||
const bool hasSuppressed = !theSettings->childKeys().isEmpty()
|
||||
|| !theSettings->childGroups().isEmpty();
|
||||
theSettings->endGroup();
|
||||
return hasSuppressed;
|
||||
}
|
||||
|
||||
@@ -222,4 +196,9 @@ QString CheckableMessageBox::msgDoNotShowAgain()
|
||||
return Tr::tr("Do not &show again");
|
||||
}
|
||||
|
||||
void CheckableMessageBox::initialize(QSettings *settings)
|
||||
{
|
||||
theSettings = settings;
|
||||
}
|
||||
|
||||
} // namespace Utils
|
||||
|
@@ -5,8 +5,6 @@
|
||||
|
||||
#include "utils_global.h"
|
||||
|
||||
#include "aspects.h"
|
||||
|
||||
#include <QMessageBox>
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
@@ -15,208 +13,51 @@ QT_END_NAMESPACE
|
||||
|
||||
namespace Utils {
|
||||
|
||||
class CheckableMessageBoxPrivate;
|
||||
class QTCREATOR_UTILS_EXPORT CheckableDecider
|
||||
{
|
||||
public:
|
||||
CheckableDecider() = default;
|
||||
CheckableDecider(const QString &settingsSubKey);
|
||||
CheckableDecider(bool *doNotAskAgain);
|
||||
CheckableDecider(const std::function<bool()> &should, const std::function<void()> &doNot)
|
||||
: shouldAskAgain(should), doNotAskAgain(doNot)
|
||||
{}
|
||||
|
||||
std::function<bool()> shouldAskAgain;
|
||||
std::function<void()> doNotAskAgain;
|
||||
};
|
||||
|
||||
class QTCREATOR_UTILS_EXPORT CheckableMessageBox
|
||||
{
|
||||
public:
|
||||
struct BoolDecision
|
||||
{
|
||||
QString text;
|
||||
bool &doNotAskAgain;
|
||||
};
|
||||
|
||||
struct SettingsDecision
|
||||
{
|
||||
QString text;
|
||||
QSettings *settings;
|
||||
QString settingsSubKey;
|
||||
};
|
||||
|
||||
struct AspectDecision
|
||||
{
|
||||
QString text;
|
||||
BoolAspect &aspect;
|
||||
};
|
||||
|
||||
using Decider = std::variant<BoolDecision, SettingsDecision, AspectDecision>;
|
||||
|
||||
static Decider make_decider(QSettings *settings,
|
||||
const QString &settingsSubKey,
|
||||
const QString &text = msgDoNotAskAgain())
|
||||
{
|
||||
return Decider{SettingsDecision{text, settings, settingsSubKey}};
|
||||
}
|
||||
|
||||
static Decider make_decider(bool &doNotAskAgain, const QString &text = msgDoNotAskAgain())
|
||||
{
|
||||
return Decider{BoolDecision{text, doNotAskAgain}};
|
||||
}
|
||||
|
||||
static Decider make_decider(BoolAspect &aspect, const QString &text = msgDoNotAskAgain())
|
||||
{
|
||||
return Decider{AspectDecision{text, aspect}};
|
||||
}
|
||||
|
||||
static QMessageBox::StandardButton question(
|
||||
QWidget *parent,
|
||||
const QString &title,
|
||||
const QString &question,
|
||||
std::optional<Decider> decider = std::nullopt,
|
||||
QMessageBox::StandardButtons buttons = QMessageBox::Yes | QMessageBox::No,
|
||||
QMessageBox::StandardButton defaultButton = QMessageBox::No,
|
||||
QMessageBox::StandardButton acceptButton = QMessageBox::Yes,
|
||||
QMap<QMessageBox::StandardButton, QString> buttonTextOverrides = {});
|
||||
|
||||
static QMessageBox::StandardButton question(
|
||||
QWidget *parent,
|
||||
const QString &title,
|
||||
const QString &question,
|
||||
bool &value,
|
||||
const CheckableDecider &decider,
|
||||
QMessageBox::StandardButtons buttons = QMessageBox::Yes | QMessageBox::No,
|
||||
QMessageBox::StandardButton defaultButton = QMessageBox::No,
|
||||
QMessageBox::StandardButton acceptButton = QMessageBox::Yes,
|
||||
QMap<QMessageBox::StandardButton, QString> buttonTextOverrides = {},
|
||||
const QString &text = msgDoNotAskAgain())
|
||||
{
|
||||
Decider decider = make_decider(value, text);
|
||||
return CheckableMessageBox::question(parent,
|
||||
title,
|
||||
question,
|
||||
decider,
|
||||
buttons,
|
||||
defaultButton,
|
||||
acceptButton,
|
||||
buttonTextOverrides);
|
||||
}
|
||||
|
||||
static QMessageBox::StandardButton question(
|
||||
QWidget *parent,
|
||||
const QString &title,
|
||||
const QString &question,
|
||||
QSettings *settings,
|
||||
const QString &settingsSubKey,
|
||||
QMessageBox::StandardButtons buttons = QMessageBox::Yes | QMessageBox::No,
|
||||
QMessageBox::StandardButton defaultButton = QMessageBox::No,
|
||||
QMessageBox::StandardButton acceptButton = QMessageBox::Yes,
|
||||
QMap<QMessageBox::StandardButton, QString> buttonTextOverrides = {},
|
||||
const QString &text = msgDoNotAskAgain())
|
||||
{
|
||||
Decider decider = make_decider(settings, settingsSubKey, text);
|
||||
return CheckableMessageBox::question(parent,
|
||||
title,
|
||||
question,
|
||||
decider,
|
||||
buttons,
|
||||
defaultButton,
|
||||
acceptButton,
|
||||
buttonTextOverrides);
|
||||
}
|
||||
|
||||
static QMessageBox::StandardButton question(
|
||||
QWidget *parent,
|
||||
const QString &title,
|
||||
const QString &question,
|
||||
BoolAspect &aspect,
|
||||
QMessageBox::StandardButtons buttons = QMessageBox::Yes | QMessageBox::No,
|
||||
QMessageBox::StandardButton defaultButton = QMessageBox::No,
|
||||
QMessageBox::StandardButton acceptButton = QMessageBox::Yes,
|
||||
QMap<QMessageBox::StandardButton, QString> buttonTextOverrides = {},
|
||||
const QString &text = msgDoNotAskAgain())
|
||||
{
|
||||
Decider decider = make_decider(aspect, text);
|
||||
return CheckableMessageBox::question(parent,
|
||||
title,
|
||||
question,
|
||||
decider,
|
||||
buttons,
|
||||
defaultButton,
|
||||
acceptButton,
|
||||
buttonTextOverrides);
|
||||
}
|
||||
const QString &msg = {});
|
||||
|
||||
static QMessageBox::StandardButton information(
|
||||
QWidget *parent,
|
||||
const QString &title,
|
||||
const QString &text,
|
||||
std::optional<Decider> decider = std::nullopt,
|
||||
QMessageBox::StandardButtons buttons = QMessageBox::Ok,
|
||||
QMessageBox::StandardButton defaultButton = QMessageBox::NoButton,
|
||||
QMap<QMessageBox::StandardButton, QString> buttonTextOverrides = {});
|
||||
|
||||
static QMessageBox::StandardButton information(
|
||||
QWidget *parent,
|
||||
const QString &title,
|
||||
const QString &information,
|
||||
bool &value,
|
||||
const CheckableDecider &decider,
|
||||
QMessageBox::StandardButtons buttons = QMessageBox::Ok,
|
||||
QMessageBox::StandardButton defaultButton = QMessageBox::NoButton,
|
||||
QMap<QMessageBox::StandardButton, QString> buttonTextOverrides = {},
|
||||
const QString &text = msgDoNotAskAgain())
|
||||
{
|
||||
Decider decider = make_decider(value, text);
|
||||
return CheckableMessageBox::information(parent,
|
||||
title,
|
||||
information,
|
||||
decider,
|
||||
buttons,
|
||||
defaultButton,
|
||||
buttonTextOverrides);
|
||||
}
|
||||
|
||||
static QMessageBox::StandardButton information(
|
||||
QWidget *parent,
|
||||
const QString &title,
|
||||
const QString &information,
|
||||
QSettings *settings,
|
||||
const QString &settingsSubKey,
|
||||
QMessageBox::StandardButtons buttons = QMessageBox::Ok,
|
||||
QMessageBox::StandardButton defaultButton = QMessageBox::NoButton,
|
||||
QMap<QMessageBox::StandardButton, QString> buttonTextOverrides = {},
|
||||
const QString &text = msgDoNotAskAgain())
|
||||
{
|
||||
Decider decider = make_decider(settings, settingsSubKey, text);
|
||||
return CheckableMessageBox::information(parent,
|
||||
title,
|
||||
information,
|
||||
decider,
|
||||
buttons,
|
||||
defaultButton,
|
||||
buttonTextOverrides);
|
||||
}
|
||||
|
||||
static QMessageBox::StandardButton information(
|
||||
QWidget *parent,
|
||||
const QString &title,
|
||||
const QString &information,
|
||||
BoolAspect &aspect,
|
||||
QMessageBox::StandardButtons buttons = QMessageBox::Ok,
|
||||
QMessageBox::StandardButton defaultButton = QMessageBox::NoButton,
|
||||
QMap<QMessageBox::StandardButton, QString> buttonTextOverrides = {},
|
||||
const QString &text = msgDoNotAskAgain())
|
||||
{
|
||||
Decider decider = make_decider(aspect, text);
|
||||
return CheckableMessageBox::information(parent,
|
||||
title,
|
||||
information,
|
||||
decider,
|
||||
buttons,
|
||||
defaultButton,
|
||||
buttonTextOverrides);
|
||||
}
|
||||
|
||||
// check and set "ask again" status
|
||||
static bool shouldAskAgain(const Decider &decider);
|
||||
static void doNotAskAgain(Decider &decider);
|
||||
|
||||
static bool shouldAskAgain(QSettings *settings, const QString &key);
|
||||
static void doNotAskAgain(QSettings *settings, const QString &key);
|
||||
const QString &msg = {});
|
||||
|
||||
// Conversion convenience
|
||||
static void resetAllDoNotAskAgainQuestions(QSettings *settings);
|
||||
static bool hasSuppressedQuestions(QSettings *settings);
|
||||
static void resetAllDoNotAskAgainQuestions();
|
||||
static bool hasSuppressedQuestions();
|
||||
static QString msgDoNotAskAgain();
|
||||
static QString msgDoNotShowAgain();
|
||||
|
||||
static void initialize(QSettings *settings);
|
||||
};
|
||||
|
||||
} // namespace Utils
|
||||
|
@@ -261,8 +261,7 @@ void BookmarkView::removeAll()
|
||||
Tr::tr("Remove All Bookmarks"),
|
||||
Tr::tr("Are you sure you want to remove all bookmarks from "
|
||||
"all files in the current session?"),
|
||||
ICore::settings(),
|
||||
QLatin1String("RemoveAllBookmarks"))
|
||||
QString("RemoveAllBookmarks"))
|
||||
!= QMessageBox::Yes)
|
||||
return;
|
||||
|
||||
|
@@ -602,8 +602,7 @@ static bool continueDespiteReleaseBuild(const QString &toolName)
|
||||
return CheckableMessageBox::question(ICore::dialogParent(),
|
||||
title,
|
||||
message,
|
||||
ICore::settings(),
|
||||
"ClangToolsCorrectModeWarning")
|
||||
QString("ClangToolsCorrectModeWarning"))
|
||||
== QMessageBox::Yes;
|
||||
}
|
||||
|
||||
|
@@ -141,8 +141,7 @@ void showHintAboutBuildBeforeAnalysis()
|
||||
Utils::CheckableMessageBox::information(Core::ICore::dialogParent(),
|
||||
Tr::tr("Info About Build the Project Before Analysis"),
|
||||
hintAboutBuildBeforeAnalysis(),
|
||||
Core::ICore::settings(),
|
||||
"ClangToolsDisablingBuildBeforeAnalysisHint");
|
||||
QString("ClangToolsDisablingBuildBeforeAnalysisHint"));
|
||||
}
|
||||
|
||||
FilePath fullPath(const FilePath &executable)
|
||||
|
@@ -594,7 +594,7 @@ void CMakeBuildSettingsWidget::reconfigureWithInitialParameters()
|
||||
Core::ICore::dialogParent(),
|
||||
Tr::tr("Re-configure with Initial Parameters"),
|
||||
Tr::tr("Clear CMake configuration and configure with initial parameters?"),
|
||||
settings->askBeforeReConfigureInitialParams,
|
||||
settings->askBeforeReConfigureInitialParams.checkableDecider(),
|
||||
QMessageBox::Yes | QMessageBox::No,
|
||||
QMessageBox::Yes);
|
||||
|
||||
|
@@ -238,7 +238,7 @@ void CMakeManager::reloadCMakePresets()
|
||||
Tr::tr("Reload CMake Presets"),
|
||||
Tr::tr("Re-generates the CMake presets kits. The manual "
|
||||
"CMake project modifications will be lost."),
|
||||
settings->askBeforePresetsReload,
|
||||
settings->askBeforePresetsReload.checkableDecider(),
|
||||
QMessageBox::Yes | QMessageBox::Cancel,
|
||||
QMessageBox::Yes,
|
||||
QMessageBox::Yes,
|
||||
|
@@ -148,6 +148,7 @@ bool CorePlugin::initialize(const QStringList &arguments, QString *errorMessage)
|
||||
Theme::setInitialPalette(theme); // Initialize palette before setting it
|
||||
setCreatorTheme(theme);
|
||||
InfoBar::initialize(ICore::settings());
|
||||
CheckableMessageBox::initialize(ICore::settings());
|
||||
new ActionManager(this);
|
||||
ActionManager::setPresentationModeEnabled(args.presentationMode);
|
||||
m_mainWindow = new MainWindow;
|
||||
|
@@ -753,7 +753,7 @@ bool EditorManagerPrivate::skipOpeningBigTextFile(const FilePath &filePath)
|
||||
.arg(fileSizeInMB, 0, 'f', 2);
|
||||
|
||||
bool askAgain = true;
|
||||
auto decider = CheckableMessageBox::make_decider(askAgain);
|
||||
CheckableDecider decider(&askAgain);
|
||||
|
||||
QMessageBox::StandardButton clickedButton
|
||||
= CheckableMessageBox::question(ICore::dialogParent(), title, text, decider);
|
||||
|
@@ -226,14 +226,13 @@ void GeneralSettingsWidget::resetInterfaceColor()
|
||||
void GeneralSettingsWidget::resetWarnings()
|
||||
{
|
||||
InfoBar::clearGloballySuppressed();
|
||||
CheckableMessageBox::resetAllDoNotAskAgainQuestions(ICore::settings());
|
||||
CheckableMessageBox::resetAllDoNotAskAgainQuestions();
|
||||
m_resetWarningsButton->setEnabled(false);
|
||||
}
|
||||
|
||||
bool GeneralSettingsWidget::canResetWarnings()
|
||||
{
|
||||
return InfoBar::anyGloballySuppressed()
|
||||
|| CheckableMessageBox::hasSuppressedQuestions(ICore::settings());
|
||||
return InfoBar::anyGloballySuppressed() || CheckableMessageBox::hasSuppressedQuestions();
|
||||
}
|
||||
|
||||
void GeneralSettingsWidget::resetLanguage()
|
||||
|
@@ -63,8 +63,7 @@ static bool askForCreating(const QString &title, const FilePath &filePath)
|
||||
= CheckableMessageBox::question(ICore::dialogParent(),
|
||||
title,
|
||||
Tr::tr("Create \"%1\"?").arg(filePath.shortNativePath()),
|
||||
ICore::settings(),
|
||||
kAlwaysCreate,
|
||||
QString(kAlwaysCreate),
|
||||
QMessageBox::Yes | QMessageBox::Cancel,
|
||||
QMessageBox::Cancel,
|
||||
QMessageBox::Yes,
|
||||
|
@@ -2697,8 +2697,7 @@ void BreakpointManager::executeDeleteAllBreakpointsDialog()
|
||||
Tr::tr("Remove All Breakpoints"),
|
||||
Tr::tr("Are you sure you want to remove all breakpoints "
|
||||
"from all files in the current session?"),
|
||||
ICore::settings(),
|
||||
"RemoveAllBreakpoints");
|
||||
QString("RemoveAllBreakpoints"));
|
||||
if (pressed != QMessageBox::Yes)
|
||||
return;
|
||||
|
||||
|
@@ -2265,8 +2265,7 @@ void CdbEngine::checkQtSdkPdbFiles(const QString &module)
|
||||
CheckableMessageBox::information(Core::ICore::dialogParent(),
|
||||
Tr::tr("Missing Qt Debug Information"),
|
||||
message,
|
||||
Core::ICore::settings(),
|
||||
"CdbQtSdkPdbHint");
|
||||
QString("CdbQtSdkPdbHint"));
|
||||
|
||||
showMessage("Missing Qt Debug Information Files package for " + qtName, LogMisc);
|
||||
};
|
||||
@@ -2294,8 +2293,7 @@ void CdbEngine::parseOutputLine(QString line)
|
||||
"Make sure that your antivirus solution is up to date and if that does not work "
|
||||
"consider adding an exception for %1.")
|
||||
.arg(m_extensionFileName),
|
||||
Core::ICore::settings(),
|
||||
"SecureInfoCdbextCannotBeLoaded");
|
||||
QString("SecureInfoCdbextCannotBeLoaded"));
|
||||
notifyEngineSetupFailed();
|
||||
}
|
||||
static const QString creatorExtPrefix = "<qtcreatorcdbext>|";
|
||||
|
@@ -2716,17 +2716,14 @@ Context CppDebuggerEngine::languageContext() const
|
||||
void CppDebuggerEngine::validateRunParameters(DebuggerRunParameters &rp)
|
||||
{
|
||||
static const QString warnOnInappropriateDebuggerKey = "DebuggerWarnOnInappropriateDebugger";
|
||||
QtcSettings *coreSettings = Core::ICore::settings();
|
||||
|
||||
const bool warnOnRelease = debuggerSettings()->warnOnReleaseBuilds.value()
|
||||
&& rp.toolChainAbi.osFlavor() != Abi::AndroidLinuxFlavor;
|
||||
bool warnOnInappropriateDebugger = false;
|
||||
QString detailedWarning;
|
||||
auto shouldAskAgain = CheckableMessageBox::make_decider(coreSettings,
|
||||
warnOnInappropriateDebuggerKey);
|
||||
switch (rp.toolChainAbi.binaryFormat()) {
|
||||
case Abi::PEFormat: {
|
||||
if (CheckableMessageBox::shouldAskAgain(shouldAskAgain)) {
|
||||
if (CheckableDecider(warnOnInappropriateDebuggerKey).shouldAskAgain()) {
|
||||
QString preferredDebugger;
|
||||
if (rp.toolChainAbi.osFlavor() == Abi::WindowsMSysFlavor) {
|
||||
if (rp.cppEngineType == CdbEngineType)
|
||||
@@ -2766,7 +2763,7 @@ void CppDebuggerEngine::validateRunParameters(DebuggerRunParameters &rp)
|
||||
break;
|
||||
}
|
||||
case Abi::ElfFormat: {
|
||||
if (CheckableMessageBox::shouldAskAgain(shouldAskAgain)) {
|
||||
if (CheckableDecider(warnOnInappropriateDebuggerKey).shouldAskAgain()) {
|
||||
if (rp.cppEngineType == CdbEngineType) {
|
||||
warnOnInappropriateDebugger = true;
|
||||
detailedWarning = Tr::tr(
|
||||
@@ -2879,7 +2876,7 @@ void CppDebuggerEngine::validateRunParameters(DebuggerRunParameters &rp)
|
||||
"Examining symbols and setting breakpoints by file name and line number "
|
||||
"may fail.\n")
|
||||
+ '\n' + detailedWarning,
|
||||
shouldAskAgain);
|
||||
warnOnInappropriateDebuggerKey);
|
||||
} else if (warnOnRelease) {
|
||||
AsynchronousMessageBox::information(Tr::tr("Warning"),
|
||||
Tr::tr("This does not seem to be a \"Debug\" build.\n"
|
||||
|
@@ -2243,8 +2243,7 @@ bool wantRunTool(ToolMode toolMode, const QString &toolName)
|
||||
if (Utils::CheckableMessageBox::question(ICore::dialogParent(),
|
||||
title,
|
||||
message,
|
||||
ICore::settings(),
|
||||
"AnalyzerCorrectModeWarning")
|
||||
QString("AnalyzerCorrectModeWarning"))
|
||||
!= QMessageBox::Yes)
|
||||
return false;
|
||||
}
|
||||
|
@@ -620,7 +620,7 @@ void DebuggerRunTool::start()
|
||||
CheckableMessageBox::information(Core::ICore::dialogParent(),
|
||||
Tr::tr("Debugger"),
|
||||
warningMessage,
|
||||
doNotShowAgain,
|
||||
&doNotShowAgain,
|
||||
QMessageBox::Ok);
|
||||
}
|
||||
}
|
||||
|
@@ -2576,8 +2576,7 @@ void WatchModel::clearWatches()
|
||||
ICore::dialogParent(),
|
||||
Tr::tr("Remove All Expression Evaluators"),
|
||||
Tr::tr("Are you sure you want to remove all expression evaluators?"),
|
||||
ICore::settings(),
|
||||
"RemoveAllWatchers");
|
||||
QString("RemoveAllWatchers"));
|
||||
if (ret != QMessageBox::Yes)
|
||||
return;
|
||||
|
||||
|
@@ -1297,8 +1297,7 @@ QStringList GitClient::setupCheckoutArguments(const FilePath &workingDirectory,
|
||||
ICore::dialogParent() /*parent*/,
|
||||
Tr::tr("Create Local Branch") /*title*/,
|
||||
Tr::tr("Would you like to create a local branch?") /*message*/,
|
||||
ICore::settings(),
|
||||
"Git.CreateLocalBranchOnCheckout" /*setting*/,
|
||||
QString("Git.CreateLocalBranchOnCheckout"), /* decider */
|
||||
QMessageBox::Yes | QMessageBox::No /*buttons*/,
|
||||
QMessageBox::No /*default button*/,
|
||||
QMessageBox::No /*button to save*/)
|
||||
|
@@ -1057,8 +1057,9 @@ bool RunControl::showPromptToStopDialog(const QString &title,
|
||||
if (!cancelButtonText.isEmpty())
|
||||
buttonTexts[QMessageBox::Cancel] = cancelButtonText;
|
||||
|
||||
std::optional<CheckableMessageBox::Decider> decider
|
||||
= prompt ? make_optional(CheckableMessageBox::make_decider(*prompt)) : std::nullopt;
|
||||
CheckableDecider decider;
|
||||
if (prompt)
|
||||
decider = CheckableDecider(prompt);
|
||||
|
||||
auto selected = CheckableMessageBox::question(Core::ICore::dialogParent(),
|
||||
title,
|
||||
|
@@ -663,8 +663,7 @@ AlignDistribute::Dimension AlignDistribute::getDimension(Target target) const
|
||||
|
||||
bool AlignDistribute::executePixelPerfectDialog() const
|
||||
{
|
||||
auto decider = Utils::CheckableMessageBox::make_decider(Core::ICore::settings(),
|
||||
"WarnAboutPixelPerfectDistribution");
|
||||
Utils::CheckableDecider decider(QString("WarnAboutPixelPerfectDistribution"));
|
||||
|
||||
QMessageBox::StandardButton pressed = Utils::CheckableMessageBox::question(
|
||||
Core::ICore::dialogParent(),
|
||||
|
@@ -302,8 +302,7 @@ void SquishNavigationWidget::onRecordTestCase(const QString &suiteName, const QS
|
||||
Tr::tr("Do you want to record over the test case \"%1\"? The existing content will "
|
||||
"be overwritten by the recorded script.")
|
||||
.arg(testCase),
|
||||
Core::ICore::settings(),
|
||||
"RecordWithoutApproval");
|
||||
QString("RecordWithoutApproval"));
|
||||
if (pressed != QMessageBox::Yes)
|
||||
return;
|
||||
|
||||
|
@@ -489,8 +489,7 @@ private:
|
||||
|
||||
void StudioWelcomePlugin::closeSplashScreen()
|
||||
{
|
||||
Utils::CheckableMessageBox::doNotAskAgain(Core::ICore::settings(),
|
||||
DO_NOT_SHOW_SPLASHSCREEN_AGAIN_KEY);
|
||||
Utils::CheckableDecider(DO_NOT_SHOW_SPLASHSCREEN_AGAIN_KEY).doNotAskAgain();
|
||||
if (!s_viewWindow.isNull())
|
||||
s_viewWindow->deleteLater();
|
||||
|
||||
@@ -538,8 +537,7 @@ static bool showSplashScreen()
|
||||
return true;
|
||||
}
|
||||
|
||||
return Utils::CheckableMessageBox::shouldAskAgain(Core::ICore::settings(),
|
||||
DO_NOT_SHOW_SPLASHSCREEN_AGAIN_KEY);
|
||||
return Utils::CheckableDecider(DO_NOT_SHOW_SPLASHSCREEN_AGAIN_KEY).shouldAskAgain();
|
||||
}
|
||||
|
||||
void StudioWelcomePlugin::extensionsInitialized()
|
||||
|
@@ -808,8 +808,7 @@ void MemcheckToolPrivate::heobAction()
|
||||
.arg(
|
||||
"<a "
|
||||
"href=\"https://github.com/ssbssa/dwarfstack/releases\">Dwarfstack</a>"),
|
||||
ICore::settings(),
|
||||
"HeobDwarfstackInfo",
|
||||
QString("HeobDwarfstackInfo"),
|
||||
QMessageBox::Ok | QMessageBox::Cancel,
|
||||
QMessageBox::Ok)
|
||||
!= QMessageBox::Ok)
|
||||
|
@@ -26,11 +26,10 @@ const char kTakeTourSetting[] = "TakeUITour";
|
||||
namespace Welcome {
|
||||
namespace Internal {
|
||||
|
||||
void IntroductionWidget::askUserAboutIntroduction(QWidget *parent, QSettings *settings)
|
||||
void IntroductionWidget::askUserAboutIntroduction(QWidget *parent)
|
||||
{
|
||||
auto decider = CheckableMessageBox::make_decider(settings, kTakeTourSetting);
|
||||
// CheckableMessageBox for compatibility with Qt Creator < 4.11
|
||||
if (!CheckableMessageBox::shouldAskAgain(decider)
|
||||
if (!CheckableDecider(QString(kTakeTourSetting)).shouldAskAgain()
|
||||
|| !Core::ICore::infoBar()->canInfoBeAdded(kTakeTourSetting))
|
||||
return;
|
||||
|
||||
|
@@ -11,7 +11,6 @@
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
class QLabel;
|
||||
class QSettings;
|
||||
QT_END_NAMESPACE
|
||||
|
||||
namespace Welcome {
|
||||
@@ -31,7 +30,7 @@ class IntroductionWidget : public QWidget
|
||||
public:
|
||||
explicit IntroductionWidget(QWidget *parent = nullptr);
|
||||
|
||||
static void askUserAboutIntroduction(QWidget *parent, QSettings *settings);
|
||||
static void askUserAboutIntroduction(QWidget *parent);
|
||||
|
||||
protected:
|
||||
bool event(QEvent *e) override;
|
||||
|
@@ -132,8 +132,7 @@ public:
|
||||
|
||||
if (!arguments.contains("-notour")) {
|
||||
connect(ICore::instance(), &ICore::coreOpened, this, []() {
|
||||
IntroductionWidget::askUserAboutIntroduction(ICore::dialogParent(),
|
||||
ICore::settings());
|
||||
IntroductionWidget::askUserAboutIntroduction(ICore::dialogParent());
|
||||
}, Qt::QueuedConnection);
|
||||
}
|
||||
|
||||
|
@@ -209,6 +209,8 @@ bool CrashHandlerDialog::runDebuggerWhileBacktraceNotFinished()
|
||||
QSettings::UserScope,
|
||||
QLatin1String(Core::Constants::IDE_SETTINGSVARIANT_STR),
|
||||
QLatin1String(SettingsApplication));
|
||||
Utils::CheckableMessageBox::initialize(&settings);
|
||||
|
||||
// Ask user.
|
||||
const QString title = tr("Run Debugger And Abort Collecting Backtrace?");
|
||||
const QString message = tr(
|
||||
@@ -222,9 +224,7 @@ bool CrashHandlerDialog::runDebuggerWhileBacktraceNotFinished()
|
||||
= Utils::CheckableMessageBox::question(this,
|
||||
title,
|
||||
message,
|
||||
&settings,
|
||||
QLatin1String(
|
||||
SettingsKeySkipWarningAbortingBacktrace),
|
||||
QString(SettingsKeySkipWarningAbortingBacktrace),
|
||||
QMessageBox::Yes | QMessageBox::No,
|
||||
QMessageBox::No);
|
||||
|
||||
|
Reference in New Issue
Block a user