forked from qt-creator/qt-creator
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 <marcus.tillmanns@qt.io>
This commit is contained in:
@@ -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),
|
||||
},
|
||||
|
@@ -157,9 +157,9 @@ static QString extensionStateDisplayString(ExtensionState state)
|
||||
{
|
||||
switch (state) {
|
||||
case InstalledEnabled:
|
||||
return Tr::tr("Loaded");
|
||||
return Tr::tr("Active");
|
||||
case InstalledDisabled:
|
||||
return Tr::tr("Installed");
|
||||
return Tr::tr("Inactive");
|
||||
default:
|
||||
return {};
|
||||
}
|
||||
|
Reference in New Issue
Block a user