forked from qt-creator/qt-creator
ExtensionManager: Enable/disable dependencies, inform users accordingly
This instantiates PluginView in order to use setPluginsEnabled. It enables dependencies of a plugin that is being enabled. Likewise, it disables dependent plugins when users disable a plugin. In both cases, the user sees the familiar info dialog. On confirmation, a "Restart now" button is shown. Change-Id: Ie74ed377bfdd1ce3cb06289c2aae78377475bc53 Reviewed-by: Alessandro Portale <alessandro.portale@qt.io> Reviewed-by: hjk <hjk@qt.io>
This commit is contained in:
@@ -369,6 +369,11 @@ void PluginView::updatePlugins()
|
|||||||
m_categoryView->expandAll();
|
m_categoryView->expandAll();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
PluginData &PluginView::data()
|
||||||
|
{
|
||||||
|
return m_data;
|
||||||
|
}
|
||||||
|
|
||||||
static QString pluginListString(const QSet<PluginSpec *> &plugins)
|
static QString pluginListString(const QSet<PluginSpec *> &plugins)
|
||||||
{
|
{
|
||||||
QStringList names = Utils::transform<QList>(plugins, &PluginSpec::name);
|
QStringList names = Utils::transform<QList>(plugins, &PluginSpec::name);
|
||||||
|
@@ -60,6 +60,8 @@ public:
|
|||||||
void setFilter(const QString &filter);
|
void setFilter(const QString &filter);
|
||||||
void cancelChanges();
|
void cancelChanges();
|
||||||
|
|
||||||
|
PluginData &data();
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void currentPluginChanged(ExtensionSystem::PluginSpec *spec);
|
void currentPluginChanged(ExtensionSystem::PluginSpec *spec);
|
||||||
void pluginActivated(ExtensionSystem::PluginSpec *spec);
|
void pluginActivated(ExtensionSystem::PluginSpec *spec);
|
||||||
|
@@ -16,6 +16,7 @@
|
|||||||
|
|
||||||
#include <extensionsystem/pluginmanager.h>
|
#include <extensionsystem/pluginmanager.h>
|
||||||
#include <extensionsystem/pluginspec.h>
|
#include <extensionsystem/pluginspec.h>
|
||||||
|
#include <extensionsystem/pluginview.h>
|
||||||
|
|
||||||
#include <solutions/tasking/networkquery.h>
|
#include <solutions/tasking/networkquery.h>
|
||||||
#include <solutions/tasking/tasktree.h>
|
#include <solutions/tasking/tasktree.h>
|
||||||
@@ -279,21 +280,33 @@ public:
|
|||||||
{
|
{
|
||||||
m_label = new InfoLabel;
|
m_label = new InfoLabel;
|
||||||
m_checkBox = new QCheckBox(Tr::tr("Load on Start"));
|
m_checkBox = new QCheckBox(Tr::tr("Load on Start"));
|
||||||
|
m_restartButton = new Button("Restart now", Button::MediumPrimary);
|
||||||
|
m_restartButton->setVisible(false);
|
||||||
|
m_pluginView.hide();
|
||||||
|
|
||||||
using namespace Layouting;
|
using namespace Layouting;
|
||||||
Column {
|
Column {
|
||||||
m_label,
|
m_label,
|
||||||
m_checkBox,
|
m_checkBox,
|
||||||
|
m_restartButton,
|
||||||
}.attachTo(this);
|
}.attachTo(this);
|
||||||
|
|
||||||
connect(m_checkBox, &QCheckBox::clicked, this, [this](bool checked) {
|
connect(m_checkBox, &QCheckBox::clicked, this, [this](bool checked) {
|
||||||
ExtensionSystem::PluginSpec *spec = ExtensionsModel::pluginSpecForName(m_pluginName);
|
ExtensionSystem::PluginSpec *spec = ExtensionsModel::pluginSpecForName(m_pluginName);
|
||||||
if (spec == nullptr)
|
if (spec == nullptr)
|
||||||
return;
|
return;
|
||||||
spec->setEnabledBySettings(checked);
|
const bool doIt = m_pluginView.data().setPluginsEnabled({spec}, checked);
|
||||||
ExtensionSystem::PluginManager::writeSettings();
|
if (doIt) {
|
||||||
|
m_restartButton->show();
|
||||||
|
ExtensionSystem::PluginManager::writeSettings();
|
||||||
|
} else {
|
||||||
|
m_checkBox->setChecked(!checked);
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
connect(m_restartButton, &QAbstractButton::clicked,
|
||||||
|
ICore::instance(), &ICore::restart, Qt::QueuedConnection);
|
||||||
|
|
||||||
update();
|
update();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -328,7 +341,9 @@ private:
|
|||||||
|
|
||||||
InfoLabel *m_label;
|
InfoLabel *m_label;
|
||||||
QCheckBox *m_checkBox;
|
QCheckBox *m_checkBox;
|
||||||
|
QAbstractButton *m_restartButton;
|
||||||
QString m_pluginName;
|
QString m_pluginName;
|
||||||
|
ExtensionSystem::PluginView m_pluginView{this};
|
||||||
};
|
};
|
||||||
|
|
||||||
class TagList : public QWidget
|
class TagList : public QWidget
|
||||||
|
Reference in New Issue
Block a user