2022-08-19 15:59:36 +02:00
|
|
|
// Copyright (C) 2016 The Qt Company Ltd.
|
|
|
|
|
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0+ OR GPL-3.0 WITH Qt-GPL-exception-1.0
|
2008-12-02 14:09:21 +01:00
|
|
|
|
2008-12-02 12:01:29 +01:00
|
|
|
#include "plugindialog.h"
|
2008-12-02 14:09:21 +01:00
|
|
|
|
2020-01-03 16:47:15 +01:00
|
|
|
#include "icore.h"
|
|
|
|
|
|
|
|
|
|
#include "dialogs/restartdialog.h"
|
2020-06-03 15:56:43 +02:00
|
|
|
#include "plugininstallwizard.h"
|
2020-01-03 16:47:15 +01:00
|
|
|
|
2020-01-21 14:17:05 +01:00
|
|
|
#include <app/app_version.h>
|
|
|
|
|
|
2008-12-02 12:01:29 +01:00
|
|
|
#include <extensionsystem/plugindetailsview.h>
|
|
|
|
|
#include <extensionsystem/pluginerrorview.h>
|
2020-01-21 14:17:05 +01:00
|
|
|
#include <extensionsystem/pluginmanager.h>
|
2008-12-02 12:01:29 +01:00
|
|
|
#include <extensionsystem/pluginspec.h>
|
2020-01-21 14:17:05 +01:00
|
|
|
#include <extensionsystem/pluginview.h>
|
2008-12-02 12:01:29 +01:00
|
|
|
|
2015-04-02 13:44:26 +02:00
|
|
|
#include <utils/fancylineedit.h>
|
|
|
|
|
|
2017-01-04 06:23:32 +01:00
|
|
|
#include <QCheckBox>
|
2020-01-21 14:17:05 +01:00
|
|
|
#include <QDebug>
|
2012-02-15 10:42:41 +01:00
|
|
|
#include <QDialog>
|
|
|
|
|
#include <QDialogButtonBox>
|
2020-01-21 14:17:05 +01:00
|
|
|
#include <QHBoxLayout>
|
2012-02-15 10:42:41 +01:00
|
|
|
#include <QLabel>
|
2020-01-21 14:17:05 +01:00
|
|
|
#include <QPushButton>
|
|
|
|
|
#include <QVBoxLayout>
|
|
|
|
|
|
|
|
|
|
using namespace Utils;
|
2008-12-02 12:01:29 +01:00
|
|
|
|
2015-01-12 15:05:10 +01:00
|
|
|
namespace Core {
|
|
|
|
|
namespace Internal {
|
2008-12-02 12:01:29 +01:00
|
|
|
|
2009-01-26 14:30:04 +01:00
|
|
|
PluginDialog::PluginDialog(QWidget *parent)
|
2008-12-02 14:09:21 +01:00
|
|
|
: QDialog(parent),
|
2012-06-18 11:34:15 +02:00
|
|
|
m_view(new ExtensionSystem::PluginView(this))
|
2008-12-02 12:01:29 +01:00
|
|
|
{
|
2018-07-21 21:11:46 +02:00
|
|
|
auto vl = new QVBoxLayout(this);
|
2015-04-02 13:44:26 +02:00
|
|
|
|
2017-01-04 06:23:32 +01:00
|
|
|
auto filterLayout = new QHBoxLayout;
|
|
|
|
|
vl->addLayout(filterLayout);
|
2015-04-02 13:44:26 +02:00
|
|
|
auto filterEdit = new Utils::FancyLineEdit(this);
|
|
|
|
|
filterEdit->setFiltering(true);
|
|
|
|
|
connect(filterEdit, &Utils::FancyLineEdit::filterChanged,
|
|
|
|
|
m_view, &ExtensionSystem::PluginView::setFilter);
|
2017-01-04 06:23:32 +01:00
|
|
|
filterLayout->addWidget(filterEdit);
|
2015-04-02 13:44:26 +02:00
|
|
|
|
2008-12-02 12:01:29 +01:00
|
|
|
vl->addWidget(m_view);
|
|
|
|
|
|
|
|
|
|
m_detailsButton = new QPushButton(tr("Details"), this);
|
|
|
|
|
m_errorDetailsButton = new QPushButton(tr("Error Details"), this);
|
2020-01-21 14:17:05 +01:00
|
|
|
m_installButton = new QPushButton(tr("Install Plugin..."), this);
|
2008-12-02 12:01:29 +01:00
|
|
|
m_detailsButton->setEnabled(false);
|
|
|
|
|
m_errorDetailsButton->setEnabled(false);
|
|
|
|
|
|
2022-06-23 16:30:46 +02:00
|
|
|
auto buttonBox = new QDialogButtonBox(QDialogButtonBox::Ok | QDialogButtonBox::Cancel);
|
|
|
|
|
buttonBox->addButton(m_detailsButton, QDialogButtonBox::ActionRole);
|
|
|
|
|
buttonBox->addButton(m_errorDetailsButton, QDialogButtonBox::ActionRole);
|
|
|
|
|
buttonBox->addButton(m_installButton, QDialogButtonBox::ActionRole);
|
|
|
|
|
vl->addWidget(buttonBox);
|
2008-12-02 12:01:29 +01:00
|
|
|
|
|
|
|
|
resize(650, 400);
|
|
|
|
|
setWindowTitle(tr("Installed Plugins"));
|
|
|
|
|
|
2015-01-12 15:05:10 +01:00
|
|
|
connect(m_view, &ExtensionSystem::PluginView::currentPluginChanged,
|
|
|
|
|
this, &PluginDialog::updateButtons);
|
|
|
|
|
connect(m_view, &ExtensionSystem::PluginView::pluginActivated,
|
|
|
|
|
this, &PluginDialog::openDetails);
|
2022-06-23 16:30:46 +02:00
|
|
|
connect(m_view, &ExtensionSystem::PluginView::pluginSettingsChanged, this, [this] {
|
|
|
|
|
m_isRestartRequired = true;
|
|
|
|
|
});
|
|
|
|
|
connect(m_detailsButton, &QAbstractButton::clicked, this,
|
2015-01-12 15:05:10 +01:00
|
|
|
[this] { openDetails(m_view->currentPlugin()); });
|
|
|
|
|
connect(m_errorDetailsButton, &QAbstractButton::clicked,
|
|
|
|
|
this, &PluginDialog::openErrorDetails);
|
2020-01-21 14:17:05 +01:00
|
|
|
connect(m_installButton, &QAbstractButton::clicked, this, &PluginDialog::showInstallWizard);
|
2022-06-23 16:30:46 +02:00
|
|
|
connect(buttonBox, &QDialogButtonBox::accepted, this, &PluginDialog::closeDialog);
|
|
|
|
|
connect(buttonBox, &QDialogButtonBox::rejected, this, &QDialog::reject);
|
|
|
|
|
connect(this, &QDialog::rejected, m_view, &ExtensionSystem::PluginView::cancelChanges);
|
2008-12-02 12:01:29 +01:00
|
|
|
updateButtons();
|
|
|
|
|
}
|
|
|
|
|
|
2010-03-12 16:02:23 +01:00
|
|
|
void PluginDialog::closeDialog()
|
|
|
|
|
{
|
2012-06-18 11:34:15 +02:00
|
|
|
ExtensionSystem::PluginManager::writeSettings();
|
2022-06-23 16:30:46 +02:00
|
|
|
if (m_isRestartRequired) {
|
2020-01-03 16:47:15 +01:00
|
|
|
RestartDialog restartDialog(ICore::dialogParent(),
|
|
|
|
|
tr("Plugin changes will take effect after restart."));
|
|
|
|
|
restartDialog.exec();
|
|
|
|
|
}
|
2010-03-12 16:02:23 +01:00
|
|
|
accept();
|
|
|
|
|
}
|
|
|
|
|
|
2020-01-21 14:17:05 +01:00
|
|
|
void PluginDialog::showInstallWizard()
|
|
|
|
|
{
|
2020-06-03 15:56:43 +02:00
|
|
|
if (PluginInstallWizard::exec())
|
2022-06-23 16:30:46 +02:00
|
|
|
m_isRestartRequired = true;
|
2010-03-12 16:02:23 +01:00
|
|
|
}
|
|
|
|
|
|
2008-12-02 12:01:29 +01:00
|
|
|
void PluginDialog::updateButtons()
|
|
|
|
|
{
|
|
|
|
|
ExtensionSystem::PluginSpec *selectedSpec = m_view->currentPlugin();
|
|
|
|
|
if (selectedSpec) {
|
|
|
|
|
m_detailsButton->setEnabled(true);
|
2011-12-09 13:34:19 +01:00
|
|
|
m_errorDetailsButton->setEnabled(selectedSpec->hasError());
|
2008-12-02 12:01:29 +01:00
|
|
|
} else {
|
|
|
|
|
m_detailsButton->setEnabled(false);
|
|
|
|
|
m_errorDetailsButton->setEnabled(false);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void PluginDialog::openDetails(ExtensionSystem::PluginSpec *spec)
|
|
|
|
|
{
|
|
|
|
|
if (!spec)
|
|
|
|
|
return;
|
|
|
|
|
QDialog dialog(this);
|
|
|
|
|
dialog.setWindowTitle(tr("Plugin Details of %1").arg(spec->name()));
|
2018-07-21 21:11:46 +02:00
|
|
|
auto layout = new QVBoxLayout;
|
2008-12-02 12:01:29 +01:00
|
|
|
dialog.setLayout(layout);
|
2018-07-21 21:11:46 +02:00
|
|
|
auto details = new ExtensionSystem::PluginDetailsView(&dialog);
|
2008-12-02 12:01:29 +01:00
|
|
|
layout->addWidget(details);
|
|
|
|
|
details->update(spec);
|
|
|
|
|
QDialogButtonBox *buttons = new QDialogButtonBox(QDialogButtonBox::Close, Qt::Horizontal, &dialog);
|
|
|
|
|
layout->addWidget(buttons);
|
2015-01-12 15:05:10 +01:00
|
|
|
connect(buttons, &QDialogButtonBox::accepted, &dialog, &QDialog::accept);
|
|
|
|
|
connect(buttons, &QDialogButtonBox::rejected, &dialog, &QDialog::reject);
|
2008-12-02 12:01:29 +01:00
|
|
|
dialog.resize(400, 500);
|
|
|
|
|
dialog.exec();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void PluginDialog::openErrorDetails()
|
|
|
|
|
{
|
|
|
|
|
ExtensionSystem::PluginSpec *spec = m_view->currentPlugin();
|
|
|
|
|
if (!spec)
|
|
|
|
|
return;
|
|
|
|
|
QDialog dialog(this);
|
|
|
|
|
dialog.setWindowTitle(tr("Plugin Errors of %1").arg(spec->name()));
|
2018-07-21 21:11:46 +02:00
|
|
|
auto layout = new QVBoxLayout;
|
2008-12-02 12:01:29 +01:00
|
|
|
dialog.setLayout(layout);
|
2018-07-21 21:11:46 +02:00
|
|
|
auto errors = new ExtensionSystem::PluginErrorView(&dialog);
|
2008-12-02 12:01:29 +01:00
|
|
|
layout->addWidget(errors);
|
|
|
|
|
errors->update(spec);
|
|
|
|
|
QDialogButtonBox *buttons = new QDialogButtonBox(QDialogButtonBox::Close, Qt::Horizontal, &dialog);
|
|
|
|
|
layout->addWidget(buttons);
|
2015-01-12 15:05:10 +01:00
|
|
|
connect(buttons, &QDialogButtonBox::accepted, &dialog, &QDialog::accept);
|
|
|
|
|
connect(buttons, &QDialogButtonBox::rejected, &dialog, &QDialog::reject);
|
2008-12-02 12:01:29 +01:00
|
|
|
dialog.resize(500, 300);
|
|
|
|
|
dialog.exec();
|
|
|
|
|
}
|
|
|
|
|
|
2015-01-12 15:05:10 +01:00
|
|
|
} // namespace Internal
|
|
|
|
|
} // namespace Core
|