-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathpluginerroroverview.cpp
66 lines (52 loc) · 2.21 KB
/
pluginerroroverview.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
// Copyright (C) 2016 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
#include "pluginerroroverview.h"
#include "extensionsystemtr.h"
#include "pluginmanager.h"
#include "pluginspec.h"
#include <QtWidgets>
Q_DECLARE_METATYPE(ExtensionSystem::PluginSpec *)
namespace ExtensionSystem {
PluginErrorOverview::PluginErrorOverview(QWidget *parent)
: QDialog(parent)
{
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::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);
auto createLabel = [this](const QString &text) {
QLabel *label = new QLabel(text, this);
label->setWordWrap(true);
return label;
};
auto layout = new QVBoxLayout(this);
layout->addWidget(
createLabel(Tr::tr("The following plugins have errors and cannot be loaded:")));
layout->addWidget(pluginList);
layout->addWidget(createLabel(Tr::tr("Details:")));
layout->addWidget(pluginError);
layout->addWidget(buttonBox);
for (PluginSpec *spec : PluginManager::plugins()) {
// only show errors on startup if plugin is enabled.
if (spec->hasError() && spec->isEffectivelyEnabled()) {
QListWidgetItem *item = new QListWidgetItem(spec->name());
item->setData(Qt::UserRole, QVariant::fromValue(spec));
pluginList->addItem(item);
}
}
if (pluginList->count() > 0)
pluginList->setCurrentRow(0);
resize(434, 361);
}
} // namespace ExtensionSystem