diff options
author | Alessandro Portale <[email protected]> | 2024-10-21 00:25:50 +0200 |
---|---|---|
committer | Alessandro Portale <[email protected]> | 2024-10-21 08:54:03 +0000 |
commit | 99e2f0a65a84d3f52effb15cbe37829b63ef9fdb (patch) | |
tree | 0ba41751f3ce5d83baa6019a6345d30a4c6923a4 /src/plugins/extensionmanager/extensionmanagerwidget.cpp | |
parent | 4b89c18e2373e4d7b0107d14dd11c024600d8e30 (diff) |
ExtensionManager: Implement latest plugin status UI specification
The switch to enable or disable the selected plugin moves from the lower
right corner to the top right of the middle column.
The "Restart Now" button is replaced by an InfoBar entry.
The "Loaded"/"Installed" on the extension cards change to
"Active"/"Inactive".
Fixes: QTCREATORBUG-31856
Change-Id: Iaf79b16255db0c9b55cb683e75eccc949512a4d0
Reviewed-by: Marcus Tillmanns <[email protected]>
Diffstat (limited to 'src/plugins/extensionmanager/extensionmanagerwidget.cpp')
-rw-r--r-- | src/plugins/extensionmanager/extensionmanagerwidget.cpp | 29 |
1 files changed, 19 insertions, 10 deletions
diff --git a/src/plugins/extensionmanager/extensionmanagerwidget.cpp b/src/plugins/extensionmanager/extensionmanagerwidget.cpp index 0239907c5c8..84242e99021 100644 --- a/src/plugins/extensionmanager/extensionmanagerwidget.cpp +++ b/src/plugins/extensionmanager/extensionmanagerwidget.cpp @@ -9,6 +9,7 @@ #include "extensionsmodel.h" #include <coreplugin/coreconstants.h> +#include <coreplugin/coreplugintr.h> #include <coreplugin/icontext.h> #include <coreplugin/icore.h> #include <coreplugin/iwelcomepage.h> @@ -27,6 +28,7 @@ #include <utils/fileutils.h> #include <utils/hostosinfo.h> #include <utils/icon.h> +#include <utils/infobar.h> #include <utils/infolabel.h> #include <utils/layoutbuilder.h> #include <utils/markdownbrowser.h> @@ -239,6 +241,8 @@ private: QString m_currentVendor; }; +const char kRestartSetting[] = "RestartAfterPluginEnabledChanged"; + class PluginStatusWidget : public QWidget { public: @@ -246,9 +250,7 @@ public: : QWidget(parent) { m_label = new InfoLabel; - m_switch = new Switch(Tr::tr("Load on start")); - m_restartButton = new Button(Tr::tr("Restart Now"), Button::MediumPrimary); - m_restartButton->setVisible(false); + m_switch = new Switch(Tr::tr("Active")); m_pluginView.hide(); setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Maximum); @@ -256,7 +258,6 @@ public: Column { m_label, m_switch, - m_restartButton, }.attachTo(this); connect(m_switch, &QCheckBox::clicked, this, [this](bool checked) { @@ -265,7 +266,18 @@ public: return; const bool doIt = m_pluginView.data().setPluginsEnabled({spec}, checked); if (doIt) { - m_restartButton->show(); + if (!ICore::infoBar()->canInfoBeAdded(kRestartSetting)) + return; + + Utils::InfoBarEntry info( + kRestartSetting, + Core::Tr::tr("Plugin changes will take effect after restart.")); + info.addCustomButton(Tr::tr("Restart Now"), [] { + ICore::infoBar()->removeInfo(kRestartSetting); + QTimer::singleShot(0, ICore::instance(), &ICore::restart); + }); + ICore::infoBar()->addInfo(info); + ExtensionSystem::PluginManager::writeSettings(); } else { m_switch->setChecked(!checked); @@ -274,8 +286,6 @@ public: connect(ExtensionSystem::PluginManager::instance(), &ExtensionSystem::PluginManager::pluginsChanged, this, &PluginStatusWidget::update); - connect(m_restartButton, &QAbstractButton::clicked, - ICore::instance(), &ICore::restart, Qt::QueuedConnection); update(); } @@ -311,7 +321,6 @@ private: InfoLabel *m_label; Switch *m_switch; - QAbstractButton *m_restartButton; QString m_pluginId; ExtensionSystem::PluginView m_pluginView{this}; }; @@ -493,7 +502,6 @@ ExtensionManagerWidget::ExtensionManagerWidget() WelcomePageHelpers::createRule(Qt::Vertical), Column { m_secondaryContent, - m_pluginStatus, }, noMargin, spacing(0), }.attachTo(m_secondaryDescriptionWidget); @@ -501,8 +509,9 @@ ExtensionManagerWidget::ExtensionManagerWidget() Row { Row { Column { - Column { + Row { m_headingWidget, + m_pluginStatus, customMargins(SpacingTokens::ExVPaddingGapXl, SpacingTokens::ExVPaddingGapXl, SpacingTokens::ExVPaddingGapXl, SpacingTokens::ExVPaddingGapXl), }, |