Files
qt-creator/src/libs/extensionsystem/pluginerroroverview.cpp
hjk 8cf500c5bc Utils: Make Layouting a top level namespace
The whole machinery is now almost only layoutbuilder.{h,cpp},
mostly independent of the rest of Utils. Idea is to finish the
separation to make it stand-alone usable also outside creator.

Change-Id: I958aa667d17ae26b21209f22412309c5307a579c
Reviewed-by: Eike Ziller <eike.ziller@qt.io>
Reviewed-by: Alessandro Portale <alessandro.portale@qt.io>
2023-04-25 13:31:25 +00:00

77 lines
2.3 KiB
C++

// 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 <utils/layoutbuilder.h>
#include <QCoreApplication>
#include <QDialogButtonBox>
#include <QLabel>
#include <QListWidget>
#include <QTextEdit>
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);
using namespace Layouting;
auto createLabel = [this](const QString &text) {
QLabel *label = new QLabel(text, this);
label->setWordWrap(true);
return label;
};
Column {
createLabel(Tr::tr("The following plugins have errors and cannot be loaded:")),
pluginList,
createLabel(Tr::tr("Details:")),
pluginError,
buttonBox
}.attachTo(this);
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