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 "extensionsmodel.h"
|
||||||
|
|
||||||
#include <coreplugin/coreconstants.h>
|
#include <coreplugin/coreconstants.h>
|
||||||
|
#include <coreplugin/coreplugintr.h>
|
||||||
#include <coreplugin/icontext.h>
|
#include <coreplugin/icontext.h>
|
||||||
#include <coreplugin/icore.h>
|
#include <coreplugin/icore.h>
|
||||||
#include <coreplugin/iwelcomepage.h>
|
#include <coreplugin/iwelcomepage.h>
|
||||||
@@ -27,6 +28,7 @@
|
|||||||
#include <utils/fileutils.h>
|
#include <utils/fileutils.h>
|
||||||
#include <utils/hostosinfo.h>
|
#include <utils/hostosinfo.h>
|
||||||
#include <utils/icon.h>
|
#include <utils/icon.h>
|
||||||
|
#include <utils/infobar.h>
|
||||||
#include <utils/infolabel.h>
|
#include <utils/infolabel.h>
|
||||||
#include <utils/layoutbuilder.h>
|
#include <utils/layoutbuilder.h>
|
||||||
#include <utils/markdownbrowser.h>
|
#include <utils/markdownbrowser.h>
|
||||||
@@ -239,6 +241,8 @@ private:
|
|||||||
QString m_currentVendor;
|
QString m_currentVendor;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const char kRestartSetting[] = "RestartAfterPluginEnabledChanged";
|
||||||
|
|
||||||
class PluginStatusWidget : public QWidget
|
class PluginStatusWidget : public QWidget
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
@@ -246,9 +250,7 @@ public:
|
|||||||
: QWidget(parent)
|
: QWidget(parent)
|
||||||
{
|
{
|
||||||
m_label = new InfoLabel;
|
m_label = new InfoLabel;
|
||||||
m_switch = new Switch(Tr::tr("Load on start"));
|
m_switch = new Switch(Tr::tr("Active"));
|
||||||
m_restartButton = new Button(Tr::tr("Restart Now"), Button::MediumPrimary);
|
|
||||||
m_restartButton->setVisible(false);
|
|
||||||
m_pluginView.hide();
|
m_pluginView.hide();
|
||||||
setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Maximum);
|
setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Maximum);
|
||||||
|
|
||||||
@@ -256,7 +258,6 @@ public:
|
|||||||
Column {
|
Column {
|
||||||
m_label,
|
m_label,
|
||||||
m_switch,
|
m_switch,
|
||||||
m_restartButton,
|
|
||||||
}.attachTo(this);
|
}.attachTo(this);
|
||||||
|
|
||||||
connect(m_switch, &QCheckBox::clicked, this, [this](bool checked) {
|
connect(m_switch, &QCheckBox::clicked, this, [this](bool checked) {
|
||||||
@@ -265,7 +266,18 @@ public:
|
|||||||
return;
|
return;
|
||||||
const bool doIt = m_pluginView.data().setPluginsEnabled({spec}, checked);
|
const bool doIt = m_pluginView.data().setPluginsEnabled({spec}, checked);
|
||||||
if (doIt) {
|
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();
|
ExtensionSystem::PluginManager::writeSettings();
|
||||||
} else {
|
} else {
|
||||||
m_switch->setChecked(!checked);
|
m_switch->setChecked(!checked);
|
||||||
@@ -274,8 +286,6 @@ public:
|
|||||||
|
|
||||||
connect(ExtensionSystem::PluginManager::instance(),
|
connect(ExtensionSystem::PluginManager::instance(),
|
||||||
&ExtensionSystem::PluginManager::pluginsChanged, this, &PluginStatusWidget::update);
|
&ExtensionSystem::PluginManager::pluginsChanged, this, &PluginStatusWidget::update);
|
||||||
connect(m_restartButton, &QAbstractButton::clicked,
|
|
||||||
ICore::instance(), &ICore::restart, Qt::QueuedConnection);
|
|
||||||
|
|
||||||
update();
|
update();
|
||||||
}
|
}
|
||||||
@@ -311,7 +321,6 @@ private:
|
|||||||
|
|
||||||
InfoLabel *m_label;
|
InfoLabel *m_label;
|
||||||
Switch *m_switch;
|
Switch *m_switch;
|
||||||
QAbstractButton *m_restartButton;
|
|
||||||
QString m_pluginId;
|
QString m_pluginId;
|
||||||
ExtensionSystem::PluginView m_pluginView{this};
|
ExtensionSystem::PluginView m_pluginView{this};
|
||||||
};
|
};
|
||||||
@@ -493,7 +502,6 @@ ExtensionManagerWidget::ExtensionManagerWidget()
|
|||||||
WelcomePageHelpers::createRule(Qt::Vertical),
|
WelcomePageHelpers::createRule(Qt::Vertical),
|
||||||
Column {
|
Column {
|
||||||
m_secondaryContent,
|
m_secondaryContent,
|
||||||
m_pluginStatus,
|
|
||||||
},
|
},
|
||||||
noMargin, spacing(0),
|
noMargin, spacing(0),
|
||||||
}.attachTo(m_secondaryDescriptionWidget);
|
}.attachTo(m_secondaryDescriptionWidget);
|
||||||
@@ -501,8 +509,9 @@ ExtensionManagerWidget::ExtensionManagerWidget()
|
|||||||
Row {
|
Row {
|
||||||
Row {
|
Row {
|
||||||
Column {
|
Column {
|
||||||
Column {
|
Row {
|
||||||
m_headingWidget,
|
m_headingWidget,
|
||||||
|
m_pluginStatus,
|
||||||
customMargins(SpacingTokens::ExVPaddingGapXl, SpacingTokens::ExVPaddingGapXl,
|
customMargins(SpacingTokens::ExVPaddingGapXl, SpacingTokens::ExVPaddingGapXl,
|
||||||
SpacingTokens::ExVPaddingGapXl, SpacingTokens::ExVPaddingGapXl),
|
SpacingTokens::ExVPaddingGapXl, SpacingTokens::ExVPaddingGapXl),
|
||||||
},
|
},
|
||||||
|
@@ -157,9 +157,9 @@ static QString extensionStateDisplayString(ExtensionState state)
|
|||||||
{
|
{
|
||||||
switch (state) {
|
switch (state) {
|
||||||
case InstalledEnabled:
|
case InstalledEnabled:
|
||||||
return Tr::tr("Loaded");
|
return Tr::tr("Active");
|
||||||
case InstalledDisabled:
|
case InstalledDisabled:
|
||||||
return Tr::tr("Installed");
|
return Tr::tr("Inactive");
|
||||||
default:
|
default:
|
||||||
return {};
|
return {};
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user