diff options
author | Eike Ziller <[email protected]> | 2025-04-29 11:39:00 +0200 |
---|---|---|
committer | Eike Ziller <[email protected]> | 2025-04-29 13:14:46 +0000 |
commit | 7a70f962953ca21651415b05ae0a03e668db7a8c (patch) | |
tree | db94c95a08c4c0ca3a72d5b2dcfe646ce53d1ff5 | |
parent | b28bcbf8c8f7db5f6f99ec07d936d30b348c022e (diff) |
InfoBar: Unify code for hiding / suppressing info on button click
Many buttons that are added to info bar entries should also hide the
info bar when clicked, and many should even suppress the info bar from
showing again (persistently or for the session).
The code for that is duplicate in all the button callbacks, which is
error prone and also globally retrieves the info bar again on button
click, which makes assumptions that we want to break in the future
(ICore::infoBar() can return a different info bar, depending on
settings, which can change during runtime).
Add an additional enum parameter to InfoBarEntry::addCustomButton() that
unifies that behavior at a central place, and also unify the button click
handling for the InfoBarDisplay implementations.
This actually fixes a bug with hiding the "Update" info bar which used an
outdated and wrong ID for the duplicated hiding code.
Change-Id: I20cd5b5b566e817a873daa6fb77db25eefcb32f0
Reviewed-by: Alessandro Portale <[email protected]>
23 files changed, 221 insertions, 155 deletions
diff --git a/src/libs/utils/infobar.cpp b/src/libs/utils/infobar.cpp index 7dd10cd226c..bb0884a501e 100644 --- a/src/libs/utils/infobar.cpp +++ b/src/libs/utils/infobar.cpp @@ -167,11 +167,10 @@ InfoBarEntry::GlobalSuppression InfoBarEntry::globalSuppression() const return m_globalSuppression; } -void InfoBarEntry::addCustomButton(const QString &buttonText, - CallBack callBack, - const QString &tooltip) +void InfoBarEntry::addCustomButton( + const QString &buttonText, CallBack callBack, const QString &tooltip, ButtonAction action) { - m_buttons.append({buttonText, callBack, tooltip}); + m_buttons.append({buttonText, callBack, tooltip, action}); } void InfoBarEntry::setCancelButtonInfo(CallBack callBack) @@ -338,6 +337,26 @@ QList<InfoBarEntry> InfoBar::entries() const return m_infoBarEntries; } +void InfoBar::triggerButton(const Id &entryId, const InfoBarEntry::Button &button) +{ + switch (button.action) { + case InfoBarEntry::ButtonAction::Hide: + removeInfo(entryId); + break; + case InfoBarEntry::ButtonAction::Suppress: + suppressInfo(entryId); // hiding is implicit + break; + case InfoBarEntry::ButtonAction::SuppressPersistently: + removeInfo(entryId); + globallySuppressInfo(entryId); + break; + break; + case InfoBarEntry::ButtonAction::None: + break; + } + button.callback(); +} + void InfoBar::clearGloballySuppressed() { globallySuppressed.clear(); @@ -491,7 +510,9 @@ void InfoBarDisplay::update() auto infoWidgetButton = new QToolButton; infoWidgetButton->setText(button.text); infoWidgetButton->setToolTip(button.tooltip); - connect(infoWidgetButton, &QAbstractButton::clicked, [button] { button.callback(); }); + connect(infoWidgetButton, &QAbstractButton::clicked, this, [button, this, id = info.id()] { + m_infoBar->triggerButton(id, button); + }); hbox->addWidget(infoWidgetButton); } diff --git a/src/libs/utils/infobar.h b/src/libs/utils/infobar.h index 418d64913d9..9202aebb4cb 100644 --- a/src/libs/utils/infobar.h +++ b/src/libs/utils/infobar.h @@ -35,6 +35,13 @@ public: Disabled, Enabled }; + enum class ButtonAction + { + None, + Hide, + Suppress, + SuppressPersistently + }; InfoBarEntry() = default; InfoBarEntry(Id _id, const QString &_infoText, GlobalSuppression _globalSuppression = GlobalSuppression::Disabled); @@ -52,8 +59,10 @@ public: QString text; CallBack callback; QString tooltip; + ButtonAction action = ButtonAction::None; }; - void addCustomButton(const QString &_buttonText, CallBack callBack, const QString &tooltip = {}); + void addCustomButton(const QString &_buttonText, CallBack callBack, const QString &tooltip = {}, + ButtonAction action = ButtonAction::None); void setCancelButtonInfo(CallBack callBack); void setCancelButtonInfo(const QString &_cancelButtonText, CallBack callBack); void removeCancelButton(); @@ -129,6 +138,9 @@ public: QList<InfoBarEntry> entries() const; + // for InfoBarDisplay implementations + void triggerButton(const Id &entryId, const InfoBarEntry::Button &button); + signals: void changed(); diff --git a/src/plugins/android/androidplugin.cpp b/src/plugins/android/androidplugin.cpp index edf25cdc770..abe632e25b8 100644 --- a/src/plugins/android/androidplugin.cpp +++ b/src/plugins/android/androidplugin.cpp @@ -145,13 +145,15 @@ class AndroidPlugin final : public ExtensionSystem::IPlugin "Android kits can be usable and all essential packages are installed. " "To do it later, select Edit > Preferences > Devices > Android."), Utils::InfoBarEntry::GlobalSuppression::Enabled); - info.addCustomButton(Tr::tr("Configure Android"), [this] { - Core::ICore::infoBar()->removeInfo(kSetupAndroidSetting); - Core::ICore::infoBar()->globallySuppressInfo(kSetupAndroidSetting); - QTimer::singleShot(0, this, [] { - Core::ICore::showOptionsDialog(Constants::ANDROID_SETTINGS_ID); - }); - }); + info.addCustomButton( + Tr::tr("Configure Android"), + [this] { + QTimer::singleShot(0, this, [] { + Core::ICore::showOptionsDialog(Constants::ANDROID_SETTINGS_ID); + }); + }, + {}, + Utils::InfoBarEntry::ButtonAction::SuppressPersistently); Core::ICore::infoBar()->addInfo(info); } }; diff --git a/src/plugins/clangcodemodel/clangmodelmanagersupport.cpp b/src/plugins/clangcodemodel/clangmodelmanagersupport.cpp index 147ebfc15c3..a198d37b33a 100644 --- a/src/plugins/clangcodemodel/clangmodelmanagersupport.cpp +++ b/src/plugins/clangcodemodel/clangmodelmanagersupport.cpp @@ -185,10 +185,11 @@ static void checkSystemForClangdSuitability() }); return label; }); - info.addCustomButton(Tr::tr("Enable Anyway"), [clangdWarningSetting] { - ClangdSettings::setUseClangdAndSave(true); - ICore::infoBar()->removeInfo(clangdWarningSetting); - }); + info.addCustomButton( + Tr::tr("Enable Anyway"), + [] { ClangdSettings::setUseClangdAndSave(true); }, + {}, + InfoBarEntry::ButtonAction::Hide); ICore::infoBar()->addInfo(info); } diff --git a/src/plugins/coreplugin/coreplugin.cpp b/src/plugins/coreplugin/coreplugin.cpp index b199ca3f115..2230ddac530 100644 --- a/src/plugins/coreplugin/coreplugin.cpp +++ b/src/plugins/coreplugin/coreplugin.cpp @@ -526,11 +526,11 @@ void CorePlugin::warnAboutCrashReporing() Utils::InfoBarEntry info(kWarnCrashReportingSetting, warnStr, Utils::InfoBarEntry::GlobalSuppression::Enabled); info.setTitle(Tr::tr("Crash Reporting")); - info.addCustomButton(ICore::msgShowOptionsDialog(), [] { - ICore::infoBar()->removeInfo(kWarnCrashReportingSetting); - ICore::infoBar()->globallySuppressInfo(kWarnCrashReportingSetting); - ICore::showOptionsDialog(Core::Constants::SETTINGS_ID_SYSTEM); - }); + info.addCustomButton( + ICore::msgShowOptionsDialog(), + [] { ICore::showOptionsDialog(Core::Constants::SETTINGS_ID_SYSTEM); }, + {}, + InfoBarEntry::ButtonAction::SuppressPersistently); info.setDetailsWidgetCreator([]() -> QWidget * { auto label = new QLabel; diff --git a/src/plugins/coreplugin/progressmanager/progressmanager.cpp b/src/plugins/coreplugin/progressmanager/progressmanager.cpp index d7a0ec70f99..d3ea17f10db 100644 --- a/src/plugins/coreplugin/progressmanager/progressmanager.cpp +++ b/src/plugins/coreplugin/progressmanager/progressmanager.cpp @@ -274,7 +274,9 @@ InfoWidget::InfoWidget(const InfoBarEntry &info, QPointer<InfoBar> infoBar) auto infoWidgetButton = new QToolButton; infoWidgetButton->setText(button.text); infoWidgetButton->setToolTip(button.tooltip); - connect(infoWidgetButton, &QAbstractButton::clicked, [button] { button.callback(); }); + connect(infoWidgetButton, &QAbstractButton::clicked, [button, infoBar, id] { + infoBar->triggerButton(id, button); + }); buttonLayout->addWidget(infoWidgetButton); } diff --git a/src/plugins/coreplugin/vcsmanager.cpp b/src/plugins/coreplugin/vcsmanager.cpp index 14a206754cd..e890c61408b 100644 --- a/src/plugins/coreplugin/vcsmanager.cpp +++ b/src/plugins/coreplugin/vcsmanager.cpp @@ -227,13 +227,13 @@ static void askForDisabledVcsPlugins(const FilePath &inputDirectory) Tr::tr("A directory under version control was detected that is supported by the %1 plugin.") .arg(pluginDisplayName), Utils::InfoBarEntry::GlobalSuppression::Enabled); - info.addCustomButton(Tr::tr("Enable %1").arg(pluginDisplayName), [vcsSuggestion, spec] { + info.addCustomButton(Tr::tr("Enable %1").arg(pluginDisplayName), [vcsSuggestion, spec, infoBar] { // TODO In case the plugin is actually loaded during runtime (softloadable), // we'd need to restructure findVersionControlForDirectory below to take the new plugin // into account. // At the moment softloadable VCS plugins are not supported though. if (ICore::enablePlugins({spec})) - ICore::infoBar()->removeInfo(vcsSuggestion); + infoBar->removeInfo(vcsSuggestion); }); info.setDetailsWidgetCreator([toplevel, pluginDisplayName]() -> QWidget * { @@ -246,7 +246,7 @@ static void askForDisabledVcsPlugins(const FilePath &inputDirectory) label->setContentsMargins(0, 0, 0, 8); return label; }); - ICore::infoBar()->addInfo(info); + infoBar->addInfo(info); }; IVersionControl* VcsManager::findVersionControlForDirectory(const FilePath &inputDirectory, diff --git a/src/plugins/cppeditor/cppeditorwidget.cpp b/src/plugins/cppeditor/cppeditorwidget.cpp index 7bf44e1f724..cb5b0340cbc 100644 --- a/src/plugins/cppeditor/cppeditorwidget.cpp +++ b/src/plugins/cppeditor/cppeditorwidget.cpp @@ -792,11 +792,11 @@ void CppEditorWidget::showRenameWarningIfFileIsGenerated(const Utils::FilePath & static const Id infoId("cppeditor.renameWarning"); InfoBarEntry info(infoId, warning); if (ec) { - info.addCustomButton(CppEditor::Tr::tr("Open \"%1\"").arg(ec->source().fileName()), - [source = ec->source()] { - EditorManager::openEditor(source); - ICore::infoBar()->removeInfo(infoId); - }); + info.addCustomButton( + CppEditor::Tr::tr("Open \"%1\"").arg(ec->source().fileName()), + [source = ec->source()] { EditorManager::openEditor(source); }, + {}, + InfoBarEntry::ButtonAction::Hide); } ICore::infoBar()->addInfo(info); return; diff --git a/src/plugins/debugger/dap/pydapengine.cpp b/src/plugins/debugger/dap/pydapengine.cpp index f84ce63c283..6f915a80947 100644 --- a/src/plugins/debugger/dap/pydapengine.cpp +++ b/src/plugins/debugger/dap/pydapengine.cpp @@ -231,24 +231,26 @@ void PyDapEngine::setupEngine() Tr::tr( "Python debugging support is not available. Install the debugpy package."), Utils::InfoBarEntry::GlobalSuppression::Enabled); - info.addCustomButton(Tr::tr("Install debugpy"), [this] { - Core::ICore::infoBar()->removeInfo(installDebugPyInfoBarId); - Core::ICore::infoBar()->globallySuppressInfo(installDebugPyInfoBarId); - const FilePath target = packageDir(runParameters().interpreter(), "debugpy"); - QTC_ASSERT(target.isSameDevice(runParameters().interpreter()), return); - m_installProcess.reset(new Process); - m_installProcess->setCommand( - {runParameters().interpreter(), - {"-m", - "pip", - "install", - "-t", - target.isLocal() ? target.toUserOutput() : target.path(), - "debugpy", - "--upgrade"}}); - m_installProcess->setTerminalMode(TerminalMode::Run); - m_installProcess->start(); - }); + info.addCustomButton( + Tr::tr("Install debugpy"), + [this] { + const FilePath target = packageDir(runParameters().interpreter(), "debugpy"); + QTC_ASSERT(target.isSameDevice(runParameters().interpreter()), return); + m_installProcess.reset(new Process); + m_installProcess->setCommand( + {runParameters().interpreter(), + {"-m", + "pip", + "install", + "-t", + target.isLocal() ? target.toUserOutput() : target.path(), + "debugpy", + "--upgrade"}}); + m_installProcess->setTerminalMode(TerminalMode::Run); + m_installProcess->start(); + }, + {}, + InfoBarEntry::ButtonAction::SuppressPersistently); Core::ICore::infoBar()->addInfo(info); notifyEngineSetupFailed(); diff --git a/src/plugins/extensionmanager/extensionmanagerwidget.cpp b/src/plugins/extensionmanager/extensionmanagerwidget.cpp index 26d43a6ab5c..edcad7b123c 100644 --- a/src/plugins/extensionmanager/extensionmanagerwidget.cpp +++ b/src/plugins/extensionmanager/extensionmanagerwidget.cpp @@ -102,10 +102,11 @@ static void requestRestart() Utils::InfoBarEntry info(kRestartSetting, Core::Tr::tr("Plugin changes will take effect after restart.")); info.setTitle(Tr::tr("Restart Required")); - info.addCustomButton(Tr::tr("Restart Now"), [] { - ICore::infoBar()->removeInfo(kRestartSetting); - QTimer::singleShot(0, ICore::instance(), &ICore::restart); - }); + info.addCustomButton( + Tr::tr("Restart Now"), + [] { QTimer::singleShot(0, ICore::instance(), &ICore::restart); }, + {}, + InfoBarEntry::ButtonAction::Hide); ICore::infoBar()->addInfo(info); } } diff --git a/src/plugins/lua/bindings/fetch.cpp b/src/plugins/lua/bindings/fetch.cpp index f3f936d23fc..71f1e30c3bf 100644 --- a/src/plugins/lua/bindings/fetch.cpp +++ b/src/plugins/lua/bindings/fetch.cpp @@ -233,18 +233,21 @@ void setupFetchModule() list->setMargin(StyleHelper::SpacingTokens::ExPaddingGapS); return list; }); - entry.addCustomButton(Tr::tr("Always Allow"), [mod, pluginName, fetch]() { - mod->setAllowedToFetch(pluginName, Module::IsAllowed::Yes); - ICore::infoBar()->removeInfo(Id("Fetch").withSuffix(pluginName)); - fetch(); - }); - entry.addCustomButton(Tr::tr("Allow Once"), [pluginName, fetch]() { - ICore::infoBar()->removeInfo(Id("Fetch").withSuffix(pluginName)); - fetch(); - }); + entry.addCustomButton( + Tr::tr("Always Allow"), + [mod, pluginName, fetch]() { + mod->setAllowedToFetch(pluginName, Module::IsAllowed::Yes); + fetch(); + }, + {}, + InfoBarEntry::ButtonAction::Hide); + entry.addCustomButton( + Tr::tr("Allow Once"), + [pluginName, fetch]() { fetch(); }, + {}, + InfoBarEntry::ButtonAction::Hide); entry.setCancelButtonInfo(Tr::tr("Deny"), [mod, notAllowed, pluginName]() { - ICore::infoBar()->removeInfo(Id("Fetch").withSuffix(pluginName)); mod->setAllowedToFetch(pluginName, Module::IsAllowed::No); notAllowed(); }); diff --git a/src/plugins/lua/bindings/install.cpp b/src/plugins/lua/bindings/install.cpp index 8171b990c5a..434c5b2e91a 100644 --- a/src/plugins/lua/bindings/install.cpp +++ b/src/plugins/lua/bindings/install.cpp @@ -364,10 +364,11 @@ void setupInstallModule() InfoBarEntry entry(infoBarId, msg, InfoBarEntry::GlobalSuppression::Enabled); - entry.addCustomButton(Tr::tr("Install"), [install, infoBarId]() { - install(); - ICore::infoBar()->removeInfo(infoBarId); - }); + entry.addCustomButton( + Tr::tr("Install"), + [install]() { install(); }, + {}, + InfoBarEntry::ButtonAction::Hide); entry.setCancelButtonInfo(denied); diff --git a/src/plugins/mcusupport/mcukitmanager.cpp b/src/plugins/mcusupport/mcukitmanager.cpp index e60d3781ac4..68aa123b3f2 100644 --- a/src/plugins/mcusupport/mcukitmanager.cpp +++ b/src/plugins/mcusupport/mcukitmanager.cpp @@ -524,12 +524,15 @@ static void askUserAboutMcuSupportKitsUpgrade(const SettingsHandler::Ptr &settin selectedOption = selected.data.value<UpgradeOption>(); }); - info.addCustomButton(Tr::tr("Proceed"), [upgradeMcuSupportKits, settingsHandler] { - ICore::infoBar()->removeInfo(upgradeMcuSupportKits); - QTimer::singleShot(0, [settingsHandler]() { - McuKitManager::upgradeKitsByCreatingNewPackage(settingsHandler, selectedOption); - }); - }); + info.addCustomButton( + Tr::tr("Proceed"), + [settingsHandler] { + QTimer::singleShot(0, [settingsHandler]() { + McuKitManager::upgradeKitsByCreatingNewPackage(settingsHandler, selectedOption); + }); + }, + {}, + InfoBarEntry::ButtonAction::Hide); ICore::infoBar()->addInfo(info); } diff --git a/src/plugins/mcusupport/mcusupportoptions.cpp b/src/plugins/mcusupport/mcusupportoptions.cpp index d5eeee72e58..2c5118df247 100644 --- a/src/plugins/mcusupport/mcusupportoptions.cpp +++ b/src/plugins/mcusupport/mcusupportoptions.cpp @@ -268,12 +268,15 @@ void McuSupportOptions::displayKitCreationMessages(const MessagesList messages, Tr::tr("Errors while creating Qt for MCUs kits"), Utils::InfoBarEntry::GlobalSuppression::Enabled); - info.addCustomButton(Tr::tr("Details"), [messages, &settingsHandler, qtMCUsPackage] { - auto popup = new McuKitCreationDialog(messages, settingsHandler, qtMCUsPackage); - popup->exec(); - delete popup; - Core::ICore::infoBar()->removeInfo(mcuKitCreationErrorInfoId); - }); + info.addCustomButton( + Tr::tr("Details"), + [messages, &settingsHandler, qtMCUsPackage] { + auto popup = new McuKitCreationDialog(messages, settingsHandler, qtMCUsPackage); + popup->exec(); + delete popup; + }, + {}, + InfoBarEntry::ButtonAction::Hide); Core::ICore::infoBar()->addInfo(info); } diff --git a/src/plugins/mcusupport/mcusupportplugin.cpp b/src/plugins/mcusupport/mcusupportplugin.cpp index 1921202e9e4..0dba35bd245 100644 --- a/src/plugins/mcusupport/mcusupportplugin.cpp +++ b/src/plugins/mcusupport/mcusupportplugin.cpp @@ -133,10 +133,11 @@ static void askUserAboutMcuSupportKitsSetup() "To do it later, select Edit > Preferences > SDKs > MCU."), Utils::InfoBarEntry::GlobalSuppression::Enabled); // clazy:excludeall=connect-3arg-lambda - info.addCustomButton(Tr::tr("Create Kits for Qt for MCUs"), [] { - ICore::infoBar()->removeInfo(setupMcuSupportKits); - QTimer::singleShot(0, []() { ICore::showOptionsDialog(Constants::SETTINGS_ID); }); - }); + info.addCustomButton( + Tr::tr("Create Kits for Qt for MCUs"), + [] { QTimer::singleShot(0, []() { ICore::showOptionsDialog(Constants::SETTINGS_ID); }); }, + {}, + InfoBarEntry::ButtonAction::Hide); ICore::infoBar()->addInfo(info); } @@ -156,16 +157,17 @@ static void askUserAboutRemovingUninstalledTargetsKits() uninstalledTargetsKits.size()), Utils::InfoBarEntry::GlobalSuppression::Enabled); - info.addCustomButton(Tr::tr("Keep"), [removeUninstalledKits] { - ICore::infoBar()->removeInfo(removeUninstalledKits); - }); + info.addCustomButton(Tr::tr("Keep"), [] {}, {}, InfoBarEntry::ButtonAction::Hide); - info.addCustomButton(Tr::tr("Remove"), [removeUninstalledKits, uninstalledTargetsKits] { - ICore::infoBar()->removeInfo(removeUninstalledKits); - QTimer::singleShot(0, [uninstalledTargetsKits]() { - McuKitManager::removeUninstalledTargetsKits(uninstalledTargetsKits); - }); - }); + info.addCustomButton( + Tr::tr("Remove"), + [uninstalledTargetsKits] { + QTimer::singleShot(0, [uninstalledTargetsKits]() { + McuKitManager::removeUninstalledTargetsKits(uninstalledTargetsKits); + }); + }, + {}, + InfoBarEntry::ButtonAction::Hide); ICore::infoBar()->addInfo(info); } @@ -245,11 +247,14 @@ void McuSupportPlugin::initialize() qdsMcuDocInfoEntry, Tr::tr("Read about using Qt Design Studio for Qt for MCUs."), Utils::InfoBarEntry::GlobalSuppression::Enabled); - docInfo.addCustomButton(Tr::tr("Go to the Documentation"), [] { - ICore::infoBar()->suppressInfo(qdsMcuDocInfoEntry); - QDesktopServices::openUrl( - QUrl("https://doc.qt.io/qtdesignstudio/studio-on-mcus.html")); - }); + docInfo.addCustomButton( + Tr::tr("Go to the Documentation"), + [] { + QDesktopServices::openUrl( + QUrl("https://doc.qt.io/qtdesignstudio/studio-on-mcus.html")); + }, + {}, + InfoBarEntry::ButtonAction::Suppress); ICore::infoBar()->addInfo(docInfo); }); } diff --git a/src/plugins/python/pyside.cpp b/src/plugins/python/pyside.cpp index 6187244064f..14dd4ded228 100644 --- a/src/plugins/python/pyside.cpp +++ b/src/plugins/python/pyside.cpp @@ -90,9 +90,7 @@ PySideInstaller::PySideInstaller() this, &PySideInstaller::handleDocumentOpened); } -void PySideInstaller::installPyside(const FilePath &python, - const QString &pySide, - TextEditor::TextDocument *document) +void PySideInstaller::installPyside(const FilePath &python, const QString &pySide) { QMap<QVersionNumber, Utils::FilePath> availablePySides; @@ -186,7 +184,6 @@ void PySideInstaller::installPyside(const FilePath &python, install->setRequirements(requirementsFile); } } - document->infoBar()->removeInfo(installPySideInfoBarId); install->run(); } @@ -199,10 +196,11 @@ void PySideInstaller::handlePySideMissing(const FilePath &python, const QString message = Tr::tr("%1 installation missing for %2 (%3)") .arg(pySide, pythonName(python), python.toUserOutput()); InfoBarEntry info(installPySideInfoBarId, message, InfoBarEntry::GlobalSuppression::Enabled); - auto installCallback = [this, python, pySide, document] { installPyside(python, pySide, document); }; + auto installCallback = [this, python, pySide] { installPyside(python, pySide); }; const QString installTooltip = Tr::tr("Install %1 for %2 using pip package installer.") .arg(pySide, python.toUserOutput()); - info.addCustomButton(Tr::tr("Install"), installCallback, installTooltip); + info.addCustomButton( + Tr::tr("Install"), installCallback, installTooltip, InfoBarEntry::ButtonAction::Hide); document->infoBar()->addInfo(info); } diff --git a/src/plugins/python/pyside.h b/src/plugins/python/pyside.h index 3df882acf1b..b2e1a65343a 100644 --- a/src/plugins/python/pyside.h +++ b/src/plugins/python/pyside.h @@ -37,8 +37,7 @@ signals: private: PySideInstaller(); - void installPyside(const Utils::FilePath &python, - const QString &pySide, TextEditor::TextDocument *document); + void installPyside(const Utils::FilePath &python, const QString &pySide); void handlePySideMissing(const Utils::FilePath &python, const QString &pySide, TextEditor::TextDocument *document); diff --git a/src/plugins/python/pythonlanguageclient.cpp b/src/plugins/python/pythonlanguageclient.cpp index a43227a1500..eab9cb9dbe8 100644 --- a/src/plugins/python/pythonlanguageclient.cpp +++ b/src/plugins/python/pythonlanguageclient.cpp @@ -411,22 +411,29 @@ void PyLSConfigureAssistant::handlePyLSState(const FilePath &python, auto message = Tr::tr("Update Python language server (PyLS) for %1 (%2).") .arg(pythonName(python), python.toUserOutput()); InfoBarEntry info(updatePylsInfoBarId, message); - info.addCustomButton(Tr::tr("Always Update"), [this, python, document, state] { - document->infoBar()->removeInfo(updatePylsInfoBarId); - Core::ICore::settings()->setValue(alwaysUpdateKey, true); - InfoBar::globallySuppressInfo(updatePylsInfoBarId); - installPythonLanguageServer(python, document, state.pylsModulePath, false, true); - }); - info.addCustomButton(Tr::tr("Update"), [this, python, document, state] { - document->infoBar()->removeInfo(updatePylsInfoBarId); - installPythonLanguageServer(python, document, state.pylsModulePath, false, true); - }); - info.addCustomButton(Tr::tr("Never"), [document, python] { - document->infoBar()->removeInfo(updatePylsInfoBarId); - InfoBar::globallySuppressInfo(updatePylsInfoBarId); - if (auto client = clientForPython(python)) - LanguageClientManager::openDocumentWithClient(document, client); - }); + info.addCustomButton( + Tr::tr("Always Update"), + [this, python, document, state] { + Core::ICore::settings()->setValue(alwaysUpdateKey, true); + installPythonLanguageServer(python, document, state.pylsModulePath, false, true); + }, + {}, + InfoBarEntry::ButtonAction::SuppressPersistently); + info.addCustomButton( + Tr::tr("Update"), + [this, python, document, state] { + installPythonLanguageServer(python, document, state.pylsModulePath, false, true); + }, + {}, + InfoBarEntry::ButtonAction::Hide); + info.addCustomButton( + Tr::tr("Never"), + [document, python] { + if (auto client = clientForPython(python)) + LanguageClientManager::openDocumentWithClient(document, client); + }, + {}, + InfoBarEntry::ButtonAction::SuppressPersistently); info.setCancelButtonInfo([python, document]{ if (auto client = clientForPython(python)) LanguageClientManager::openDocumentWithClient(document, client); diff --git a/src/plugins/qtsupport/qtsupportplugin.cpp b/src/plugins/qtsupport/qtsupportplugin.cpp index 510f758c352..bd3c954644a 100644 --- a/src/plugins/qtsupport/qtsupportplugin.cpp +++ b/src/plugins/qtsupport/qtsupportplugin.cpp @@ -166,10 +166,11 @@ static void askAboutQtInstallation() "this later, select Edit > Preferences > Kits > Qt Versions > Link with Qt."), Utils::InfoBarEntry::GlobalSuppression::Enabled); info.setTitle(Tr::tr("Link with Qt")); - info.addCustomButton(Tr::tr("Link with Qt"), [] { - ICore::infoBar()->removeInfo(kLinkWithQtInstallationSetting); - QTimer::singleShot(0, ICore::dialogParent(), &LinkWithQtSupport::linkWithQt); - }); + info.addCustomButton( + Tr::tr("Link with Qt"), + [] { QTimer::singleShot(0, ICore::dialogParent(), &LinkWithQtSupport::linkWithQt); }, + {}, + InfoBarEntry::ButtonAction::Hide); ICore::infoBar()->addInfo(info); } diff --git a/src/plugins/texteditor/texteditor.cpp b/src/plugins/texteditor/texteditor.cpp index fbfd9277e8c..cd1aaa723cb 100644 --- a/src/plugins/texteditor/texteditor.cpp +++ b/src/plugins/texteditor/texteditor.cpp @@ -3950,10 +3950,11 @@ void TextEditorWidgetPrivate::updateSyntaxInfoBar(const HighlighterHelper::Defin Tr::tr("A highlight definition was not found for this file. " "Would you like to download additional highlight definition files?"), InfoBarEntry::GlobalSuppression::Enabled); - info.addCustomButton(Tr::tr("Download Definitions"), [missing, this]() { - m_document->infoBar()->removeInfo(missing); - HighlighterHelper::downloadDefinitions(); - }); + info.addCustomButton( + Tr::tr("Download Definitions"), + []() { HighlighterHelper::downloadDefinitions(); }, + {}, + InfoBarEntry::ButtonAction::Hide); infoBar->removeInfo(multiple); infoBar->addInfo(info); @@ -3972,10 +3973,11 @@ void TextEditorWidgetPrivate::updateSyntaxInfoBar(const HighlighterHelper::Defin this->configureGenericHighlighter(HighlighterHelper::definitionForName(info.displayText)); }); - info.addCustomButton(Tr::tr("Remember My Choice"), [multiple, this]() { - m_document->infoBar()->removeInfo(multiple); - rememberCurrentSyntaxDefinition(); - }); + info.addCustomButton( + Tr::tr("Remember My Choice"), + [this]() { rememberCurrentSyntaxDefinition(); }, + {}, + InfoBarEntry::ButtonAction::Hide); infoBar->addInfo(info); } diff --git a/src/plugins/updateinfo/updateinfoplugin.cpp b/src/plugins/updateinfo/updateinfoplugin.cpp index bc7efc03ff0..0a7e29a4fba 100644 --- a/src/plugins/updateinfo/updateinfoplugin.cpp +++ b/src/plugins/updateinfo/updateinfoplugin.cpp @@ -40,7 +40,6 @@ const char LastMaxQtVersionKey[] = "LastMaxQtVersion"; const quint32 OneMinute = 60000; const quint32 OneHour = 3600000; const char InstallUpdates[] = "UpdateInfo.InstallUpdates"; -const char InstallQtUpdates[] = "UpdateInfo.InstallQtUpdates"; const char M_MAINTENANCE_TOOL[] = "QtCreator.Menu.Tools.MaintenanceTool"; using namespace Core; @@ -195,20 +194,23 @@ static void showUpdateInfo(const QList<Update> &updates, { InfoBarEntry info(InstallUpdates, infoTitle(updates, newQt)); info.setTitle(Tr::tr("Updates Available")); - info.addCustomButton(Tr::tr("Open Settings"), [] { - ICore::infoBar()->removeInfo(InstallQtUpdates); - ICore::showOptionsDialog(FILTER_OPTIONS_PAGE_ID); - }); + info.addCustomButton( + Tr::tr("Open Settings"), + [] { ICore::showOptionsDialog(FILTER_OPTIONS_PAGE_ID); }, + {}, + InfoBarEntry::ButtonAction::Hide); if (newQt) { - info.addCustomButton(Tr::tr("Start Package Manager"), [startPackageManager] { - ICore::infoBar()->removeInfo(InstallQtUpdates); - startPackageManager(); - }); + info.addCustomButton( + Tr::tr("Start Package Manager"), + [startPackageManager] { startPackageManager(); }, + {}, + InfoBarEntry::ButtonAction::Hide); } else { - info.addCustomButton(Tr::tr("Start Update"), [startUpdater] { - ICore::infoBar()->removeInfo(InstallUpdates); - startUpdater(); - }); + info.addCustomButton( + Tr::tr("Start Update"), + [startUpdater] { startUpdater(); }, + {}, + InfoBarEntry::ButtonAction::Hide); } if (!updates.isEmpty()) { info.setDetailsWidgetCreator([updates, newQt] { diff --git a/src/plugins/webassembly/webassemblydevice.cpp b/src/plugins/webassembly/webassemblydevice.cpp index 3fcf6c1f88c..9caf7caae28 100644 --- a/src/plugins/webassembly/webassemblydevice.cpp +++ b/src/plugins/webassembly/webassemblydevice.cpp @@ -62,10 +62,11 @@ static void askUserAboutEmSdkSetup() Tr::tr("Setup Emscripten SDK for WebAssembly? " "To do it later, select Edit > Preferences > Devices > WebAssembly."), InfoBarEntry::GlobalSuppression::Enabled); - info.addCustomButton(Tr::tr("Setup Emscripten SDK"), [setupWebAssemblyEmSdk] { - ICore::infoBar()->removeInfo(setupWebAssemblyEmSdk); - QTimer::singleShot(0, []() { ICore::showOptionsDialog(Constants::SETTINGS_ID); }); - }); + info.addCustomButton( + Tr::tr("Setup Emscripten SDK"), + [] { QTimer::singleShot(0, []() { ICore::showOptionsDialog(Constants::SETTINGS_ID); }); }, + {}, + InfoBarEntry::ButtonAction::Hide); ICore::infoBar()->addInfo(info); } diff --git a/src/plugins/welcome/introductionwidget.cpp b/src/plugins/welcome/introductionwidget.cpp index 15256ab9d2c..ebf8c0d8bcd 100644 --- a/src/plugins/welcome/introductionwidget.cpp +++ b/src/plugins/welcome/introductionwidget.cpp @@ -431,11 +431,11 @@ void askUserAboutIntroduction() "select Help > UI Tour."), InfoBarEntry::GlobalSuppression::Enabled); info.setTitle(Tr::tr("UI Tour")); - info.addCustomButton(Tr::tr("Take UI Tour"), [infoBar] { - infoBar->removeInfo(kTakeTourSetting); - infoBar->globallySuppressInfo(kTakeTourSetting); - runUiTour(); - }); + info.addCustomButton( + Tr::tr("Take UI Tour"), + [] { runUiTour(); }, + {}, + InfoBarEntry::ButtonAction::SuppressPersistently); infoBar->addInfo(info); } |