UpdateInfoPlugin: Remove unneeded scopes

Change-Id: Iccb376a4b0230c3b988415c126aa0bca73b89b09
Reviewed-by: Eike Ziller <eike.ziller@qt.io>
This commit is contained in:
Jarek Kobus
2022-10-11 14:07:57 +02:00
parent 80938eae9a
commit 894f1b81c8

View File

@@ -204,10 +204,10 @@ void UpdateInfoPlugin::stopCheckForUpdates()
static void showUpdateInfo(const QList<Update> &updates, const std::function<void()> &startUpdater) static void showUpdateInfo(const QList<Update> &updates, const std::function<void()> &startUpdater)
{ {
Utils::InfoBarEntry info(InstallUpdates, InfoBarEntry info(InstallUpdates,
UpdateInfoPlugin::tr("New updates are available. Start the update?")); UpdateInfoPlugin::tr("New updates are available. Start the update?"));
info.addCustomButton(UpdateInfoPlugin::tr("Start Update"), [startUpdater] { info.addCustomButton(UpdateInfoPlugin::tr("Start Update"), [startUpdater] {
Core::ICore::infoBar()->removeInfo(InstallUpdates); ICore::infoBar()->removeInfo(InstallUpdates);
startUpdater(); startUpdater();
}); });
info.setDetailsWidgetCreator([updates]() -> QWidget * { info.setDetailsWidgetCreator([updates]() -> QWidget * {
@@ -224,30 +224,28 @@ static void showUpdateInfo(const QList<Update> &updates, const std::function<voi
label->setContentsMargins(0, 0, 0, 8); label->setContentsMargins(0, 0, 0, 8);
return label; return label;
}); });
Core::ICore::infoBar()->removeInfo(InstallUpdates); // remove any existing notifications ICore::infoBar()->removeInfo(InstallUpdates); // remove any existing notifications
Core::ICore::infoBar()->unsuppressInfo(InstallUpdates); ICore::infoBar()->unsuppressInfo(InstallUpdates);
Core::ICore::infoBar()->addInfo(info); ICore::infoBar()->addInfo(info);
} }
static void showQtUpdateInfo(const QtPackage &package, static void showQtUpdateInfo(const QtPackage &package,
const std::function<void()> &startPackageManager) const std::function<void()> &startPackageManager)
{ {
Utils::InfoBarEntry info(InstallQtUpdates, InfoBarEntry info(InstallQtUpdates, UpdateInfoPlugin::tr(
UpdateInfoPlugin::tr(
"%1 is available. Check the <a %2>Qt blog</a> for details.") "%1 is available. Check the <a %2>Qt blog</a> for details.")
.arg(package.displayName, .arg(package.displayName, QString("href=\"https://www.qt.io/blog/tag/releases\"")));
QString("href=\"https://www.qt.io/blog/tag/releases\"")));
info.addCustomButton(UpdateInfoPlugin::tr("Start Package Manager"), [startPackageManager] { info.addCustomButton(UpdateInfoPlugin::tr("Start Package Manager"), [startPackageManager] {
Core::ICore::infoBar()->removeInfo(InstallQtUpdates); ICore::infoBar()->removeInfo(InstallQtUpdates);
startPackageManager(); startPackageManager();
}); });
info.addCustomButton(UpdateInfoPlugin::tr("Open Settings"), [] { info.addCustomButton(UpdateInfoPlugin::tr("Open Settings"), [] {
Core::ICore::infoBar()->removeInfo(InstallQtUpdates); ICore::infoBar()->removeInfo(InstallQtUpdates);
Core::ICore::showOptionsDialog(FILTER_OPTIONS_PAGE_ID); ICore::showOptionsDialog(FILTER_OPTIONS_PAGE_ID);
}); });
Core::ICore::infoBar()->removeInfo(InstallQtUpdates); // remove any existing notifications ICore::infoBar()->removeInfo(InstallQtUpdates); // remove any existing notifications
Core::ICore::infoBar()->unsuppressInfo(InstallQtUpdates); ICore::infoBar()->unsuppressInfo(InstallQtUpdates);
Core::ICore::infoBar()->addInfo(info); ICore::infoBar()->addInfo(info);
} }
void UpdateInfoPlugin::checkForUpdatesFinished() void UpdateInfoPlugin::checkForUpdatesFinished()
@@ -328,23 +326,23 @@ bool UpdateInfoPlugin::initialize(const QStringList & /* arguments */, QString *
auto mtools = ActionManager::actionContainer(Constants::M_TOOLS); auto mtools = ActionManager::actionContainer(Constants::M_TOOLS);
ActionContainer *mmaintenanceTool = ActionManager::createMenu(M_MAINTENANCE_TOOL); ActionContainer *mmaintenanceTool = ActionManager::createMenu(M_MAINTENANCE_TOOL);
mmaintenanceTool->setOnAllDisabledBehavior(Core::ActionContainer::Hide); mmaintenanceTool->setOnAllDisabledBehavior(ActionContainer::Hide);
mmaintenanceTool->menu()->setTitle(Tr::tr("Qt Maintenance Tool")); mtools->addMenu(mmaintenanceTool); mmaintenanceTool->menu()->setTitle(Tr::tr("Qt Maintenance Tool"));
mtools->addMenu(mmaintenanceTool);
QAction *checkForUpdatesAction = new QAction(tr("Check for Updates"), this); QAction *checkForUpdatesAction = new QAction(tr("Check for Updates"), this);
checkForUpdatesAction->setMenuRole(QAction::ApplicationSpecificRole); checkForUpdatesAction->setMenuRole(QAction::ApplicationSpecificRole);
Core::Command *checkForUpdatesCommand Command *checkForUpdatesCommand = ActionManager::registerAction(checkForUpdatesAction,
= Core::ActionManager::registerAction(checkForUpdatesAction, "Updates.CheckForUpdates"); "Updates.CheckForUpdates");
connect(checkForUpdatesAction, &QAction::triggered, connect(checkForUpdatesAction, &QAction::triggered,
this, &UpdateInfoPlugin::startCheckForUpdates); this, &UpdateInfoPlugin::startCheckForUpdates);
mmaintenanceTool->addAction(checkForUpdatesCommand); mmaintenanceTool->addAction(checkForUpdatesCommand);
QAction *startMaintenanceToolAction = new QAction(Tr::tr("Start Maintenance Tool"), this); QAction *startMaintenanceToolAction = new QAction(Tr::tr("Start Maintenance Tool"), this);
startMaintenanceToolAction->setMenuRole(QAction::ApplicationSpecificRole); startMaintenanceToolAction->setMenuRole(QAction::ApplicationSpecificRole);
Core::Command *startMaintenanceToolCommand Command *startMaintenanceToolCommand = ActionManager::registerAction(startMaintenanceToolAction,
= Core::ActionManager::registerAction(startMaintenanceToolAction,
"Updates.StartMaintenanceTool"); "Updates.StartMaintenanceTool");
connect(startMaintenanceToolAction, &QAction::triggered, this, [this]() { connect(startMaintenanceToolAction, &QAction::triggered, this, [this] {
startMaintenanceTool({}); startMaintenanceTool({});
}); });
mmaintenanceTool->addAction(startMaintenanceToolCommand); mmaintenanceTool->addAction(startMaintenanceToolCommand);
@@ -383,7 +381,7 @@ void UpdateInfoPlugin::loadSettings() const
void UpdateInfoPlugin::saveSettings() void UpdateInfoPlugin::saveSettings()
{ {
UpdateInfoPluginPrivate::Settings def; UpdateInfoPluginPrivate::Settings def;
Utils::QtcSettings *settings = ICore::settings(); QtcSettings *settings = ICore::settings();
settings->beginGroup(UpdaterGroup); settings->beginGroup(UpdaterGroup);
settings->setValueWithDefault(LastCheckDateKey, d->m_lastCheckDate, QDate()); settings->setValueWithDefault(LastCheckDateKey, d->m_lastCheckDate, QDate());
settings->setValueWithDefault(AutomaticCheckKey, settings->setValueWithDefault(AutomaticCheckKey,