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();
|
||||
}
|
||||
|
||||
PluginData &PluginView::data()
|
||||
{
|
||||
return m_data;
|
||||
}
|
||||
|
||||
static QString pluginListString(const QSet<PluginSpec *> &plugins)
|
||||
{
|
||||
QStringList names = Utils::transform<QList>(plugins, &PluginSpec::name);
|
||||
|
@@ -60,6 +60,8 @@ public:
|
||||
void setFilter(const QString &filter);
|
||||
void cancelChanges();
|
||||
|
||||
PluginData &data();
|
||||
|
||||
signals:
|
||||
void currentPluginChanged(ExtensionSystem::PluginSpec *spec);
|
||||
void pluginActivated(ExtensionSystem::PluginSpec *spec);
|
||||
|
@@ -16,6 +16,7 @@
|
||||
|
||||
#include <extensionsystem/pluginmanager.h>
|
||||
#include <extensionsystem/pluginspec.h>
|
||||
#include <extensionsystem/pluginview.h>
|
||||
|
||||
#include <solutions/tasking/networkquery.h>
|
||||
#include <solutions/tasking/tasktree.h>
|
||||
@@ -279,21 +280,33 @@ public:
|
||||
{
|
||||
m_label = new InfoLabel;
|
||||
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;
|
||||
Column {
|
||||
m_label,
|
||||
m_checkBox,
|
||||
m_restartButton,
|
||||
}.attachTo(this);
|
||||
|
||||
connect(m_checkBox, &QCheckBox::clicked, this, [this](bool checked) {
|
||||
ExtensionSystem::PluginSpec *spec = ExtensionsModel::pluginSpecForName(m_pluginName);
|
||||
if (spec == nullptr)
|
||||
return;
|
||||
spec->setEnabledBySettings(checked);
|
||||
ExtensionSystem::PluginManager::writeSettings();
|
||||
const bool doIt = m_pluginView.data().setPluginsEnabled({spec}, checked);
|
||||
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();
|
||||
}
|
||||
|
||||
@@ -328,7 +341,9 @@ private:
|
||||
|
||||
InfoLabel *m_label;
|
||||
QCheckBox *m_checkBox;
|
||||
QAbstractButton *m_restartButton;
|
||||
QString m_pluginName;
|
||||
ExtensionSystem::PluginView m_pluginView{this};
|
||||
};
|
||||
|
||||
class TagList : public QWidget
|
||||
|
Reference in New Issue
Block a user