2022-08-19 15:59:36 +02:00
|
|
|
// Copyright (C) 2016 The Qt Company Ltd.
|
2023-01-04 08:52:22 +01:00
|
|
|
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
|
2011-08-29 15:59:31 +02:00
|
|
|
|
|
|
|
|
#include "pluginerroroverview.h"
|
2022-11-16 00:29:38 +01:00
|
|
|
|
2011-08-29 15:59:31 +02:00
|
|
|
#include "pluginmanager.h"
|
2022-11-16 00:29:38 +01:00
|
|
|
#include "pluginspec.h"
|
2011-08-29 15:59:31 +02:00
|
|
|
|
2022-11-16 00:29:38 +01:00
|
|
|
#include <utils/layoutbuilder.h>
|
2011-08-29 15:59:31 +02:00
|
|
|
|
2022-11-16 00:29:38 +01:00
|
|
|
#include <QCoreApplication>
|
|
|
|
|
#include <QDialogButtonBox>
|
|
|
|
|
#include <QLabel>
|
|
|
|
|
#include <QListWidget>
|
|
|
|
|
#include <QTextEdit>
|
|
|
|
|
|
|
|
|
|
Q_DECLARE_METATYPE(ExtensionSystem::PluginSpec *)
|
2011-08-29 15:59:31 +02:00
|
|
|
|
2022-11-16 00:29:38 +01:00
|
|
|
namespace ExtensionSystem {
|
2020-02-07 16:02:22 +01:00
|
|
|
|
2022-11-16 00:29:38 +01:00
|
|
|
PluginErrorOverview::PluginErrorOverview(QWidget *parent)
|
|
|
|
|
: QDialog(parent)
|
2011-08-29 15:59:31 +02:00
|
|
|
{
|
2022-11-16 00:29:38 +01:00
|
|
|
QListWidget *pluginList = new QListWidget(this);
|
|
|
|
|
|
|
|
|
|
QTextEdit *pluginError = new QTextEdit(this);
|
|
|
|
|
pluginError->setReadOnly(true);
|
|
|
|
|
|
|
|
|
|
QDialogButtonBox *buttonBox = new QDialogButtonBox(this);
|
|
|
|
|
buttonBox->setOrientation(Qt::Horizontal);
|
|
|
|
|
buttonBox->setStandardButtons(QDialogButtonBox::NoButton);
|
|
|
|
|
buttonBox->addButton(tr("Continue"), QDialogButtonBox::AcceptRole);
|
|
|
|
|
|
|
|
|
|
connect(pluginList, &QListWidget::currentItemChanged,
|
|
|
|
|
this, [pluginError](QListWidgetItem *item) {
|
|
|
|
|
if (item)
|
|
|
|
|
pluginError->setText(item->data(Qt::UserRole).value<PluginSpec *>()->errorString());
|
|
|
|
|
else
|
|
|
|
|
pluginError->clear();
|
|
|
|
|
});
|
|
|
|
|
QObject::connect(buttonBox, &QDialogButtonBox::accepted, this, &QDialog::accept);
|
|
|
|
|
QObject::connect(buttonBox, &QDialogButtonBox::rejected, this, &QDialog::reject);
|
|
|
|
|
|
|
|
|
|
using namespace Utils::Layouting;
|
|
|
|
|
|
|
|
|
|
auto createLabel = [this](const QString &text) {
|
|
|
|
|
QLabel *label = new QLabel(text, this);
|
|
|
|
|
label->setWordWrap(true);
|
|
|
|
|
return label;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
Column {
|
|
|
|
|
createLabel(QCoreApplication::translate("ExtensionSystem::Internal::PluginErrorOverview",
|
|
|
|
|
"The following plugins have errors and cannot be loaded:")),
|
|
|
|
|
pluginList,
|
|
|
|
|
createLabel(QCoreApplication::translate("ExtensionSystem::Internal::PluginErrorOverview",
|
|
|
|
|
"Details:")),
|
|
|
|
|
pluginError,
|
|
|
|
|
buttonBox
|
|
|
|
|
}.attachTo(this);
|
2011-08-29 15:59:31 +02:00
|
|
|
|
2020-02-14 08:51:08 +01:00
|
|
|
for (PluginSpec *spec : PluginManager::plugins()) {
|
2011-08-29 15:59:31 +02:00
|
|
|
// only show errors on startup if plugin is enabled.
|
2015-03-31 17:42:14 +02:00
|
|
|
if (spec->hasError() && spec->isEffectivelyEnabled()) {
|
2011-08-29 15:59:31 +02:00
|
|
|
QListWidgetItem *item = new QListWidgetItem(spec->name());
|
2019-05-27 13:32:20 +02:00
|
|
|
item->setData(Qt::UserRole, QVariant::fromValue(spec));
|
2022-11-16 00:29:38 +01:00
|
|
|
pluginList->addItem(item);
|
2011-08-29 15:59:31 +02:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2022-11-16 00:29:38 +01:00
|
|
|
if (pluginList->count() > 0)
|
|
|
|
|
pluginList->setCurrentRow(0);
|
2011-08-29 15:59:31 +02:00
|
|
|
|
2022-11-16 00:29:38 +01:00
|
|
|
resize(434, 361);
|
2011-08-29 15:59:31 +02:00
|
|
|
}
|
|
|
|
|
|
2012-11-02 09:44:53 +01:00
|
|
|
} // namespace ExtensionSystem
|