diff --git a/src/app/main.cpp b/src/app/main.cpp index dc3f22ed49d1d053b3a845d925d9f7c37500d773..f9d694cf5021e589813d26a3a2733b278e9e71a4 100644 --- a/src/app/main.cpp +++ b/src/app/main.cpp @@ -35,6 +35,7 @@ #include <extensionsystem/pluginmanager.h> #include <extensionsystem/pluginspec.h> #include <extensionsystem/iplugin.h> +#include <extensionsystem/pluginerroroverview.h> #include <QtCore/QDir> #include <QtCore/QUrl> @@ -353,15 +354,10 @@ int main(int argc, char **argv) return 1; } { - QStringList errors; - foreach (ExtensionSystem::PluginSpec *p, pluginManager.plugins()) - // only show errors on startup if plugin is enabled. - if (p->hasError() && p->isEnabled() && !p->isDisabledIndirectly()) - errors.append(p->name() + "\n" + p->errorString()); - if (!errors.isEmpty()) - QMessageBox::warning(0, - QCoreApplication::translate("Application", "Qt Creator - Plugin loader messages"), - errors.join(QString::fromLatin1("\n\n"))); + if (pluginManager.hasError()) { + ExtensionSystem::PluginErrorOverview errorOverview(&pluginManager); + errorOverview.exec(); + } } if (isFirstInstance) { @@ -385,4 +381,3 @@ int main(int argc, char **argv) return app.exec(); } - diff --git a/src/libs/extensionsystem/extensionsystem.pro b/src/libs/extensionsystem/extensionsystem.pro index de1f49f25b25bf15fb979ecffce783bd20bac8e3..3d9b36c44c3ebec45ebae2304540de3e56908731 100644 --- a/src/libs/extensionsystem/extensionsystem.pro +++ b/src/libs/extensionsystem/extensionsystem.pro @@ -21,7 +21,8 @@ HEADERS += pluginerrorview.h \ pluginview.h \ pluginview_p.h \ optionsparser.h \ - plugincollection.h + plugincollection.h \ + pluginerroroverview.h SOURCES += pluginerrorview.cpp \ plugindetailsview.cpp \ invoker.cpp \ @@ -30,8 +31,13 @@ SOURCES += pluginerrorview.cpp \ pluginspec.cpp \ pluginview.cpp \ optionsparser.cpp \ - plugincollection.cpp + plugincollection.cpp \ + pluginerroroverview.cpp FORMS += pluginview.ui \ pluginerrorview.ui \ - plugindetailsview.ui + plugindetailsview.ui \ + pluginerroroverview.ui RESOURCES += pluginview.qrc + + + diff --git a/src/libs/extensionsystem/pluginerroroverview.cpp b/src/libs/extensionsystem/pluginerroroverview.cpp new file mode 100644 index 0000000000000000000000000000000000000000..fd4c39f8240540405eac31b15468b334dd1a7774 --- /dev/null +++ b/src/libs/extensionsystem/pluginerroroverview.cpp @@ -0,0 +1,113 @@ +/************************************************************************** +** +** This file is part of Qt Creator +** +** Copyright (c) 2011 Nokia Corporation and/or its subsidiary(-ies). +** +** Contact: Nokia Corporation (info@qt.nokia.com) +** +** +** GNU Lesser General Public License Usage +** +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this file. +** Please review the following information to ensure the GNU Lesser General +** Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** Other Usage +** +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** If you have questions regarding the use of this file, please contact +** Nokia at info@qt.nokia.com. +** +**************************************************************************/ + +#include "pluginerroroverview.h" +#include "ui_pluginerroroverview.h" +#include "pluginspec.h" +#include "pluginmanager.h" + +Q_DECLARE_METATYPE(ExtensionSystem::PluginSpec*) + +namespace ExtensionSystem { +namespace Internal { + +class PluginErrorOverviewPrivate : public QObject +{ + Q_OBJECT +public: + PluginErrorOverviewPrivate(PluginManager *manager, QDialog *dialog); + ~PluginErrorOverviewPrivate(); + +private slots: + void showDetails(QListWidgetItem *item); + +private: + Ui::PluginErrorOverview *m_ui; + PluginManager *m_manager; +}; + +} // Internal +} // ExtensionSystem + +using namespace ExtensionSystem; +using namespace ExtensionSystem::Internal; + +PluginErrorOverview::PluginErrorOverview(PluginManager *manager, QWidget *parent) : + QDialog(parent), + d(new PluginErrorOverviewPrivate(manager, this)) +{ +} + +PluginErrorOverview::~PluginErrorOverview() +{ + delete d; +} + +PluginErrorOverviewPrivate::PluginErrorOverviewPrivate(PluginManager *manager, QDialog *dialog) + : m_ui(new Ui::PluginErrorOverview), + m_manager(manager) +{ + m_ui->setupUi(dialog); + m_ui->buttonBox->addButton(tr("Continue"), QDialogButtonBox::AcceptRole); + + foreach (PluginSpec *spec, m_manager->plugins()) { + // only show errors on startup if plugin is enabled. + if (spec->hasError() && spec->isEnabled() && !spec->isDisabledIndirectly()) { + QListWidgetItem *item = new QListWidgetItem(spec->name()); + item->setData(Qt::UserRole, qVariantFromValue(spec)); + m_ui->pluginList->addItem(item); + } + } + + connect(m_ui->pluginList, SIGNAL(currentItemChanged(QListWidgetItem*,QListWidgetItem*)), + this, SLOT(showDetails(QListWidgetItem*))); + + if (m_ui->pluginList->count() > 0) + m_ui->pluginList->setCurrentRow(0); +} + +PluginErrorOverviewPrivate::~PluginErrorOverviewPrivate() +{ + delete m_ui; +} + +void PluginErrorOverviewPrivate::showDetails(QListWidgetItem *item) +{ + if (item) { + PluginSpec *spec = item->data(Qt::UserRole).value<PluginSpec *>(); + m_ui->pluginError->setText(spec->errorString()); + } else { + m_ui->pluginError->setText(QString()); + } +} + +#include "pluginerroroverview.moc" diff --git a/src/libs/extensionsystem/pluginerroroverview.h b/src/libs/extensionsystem/pluginerroroverview.h new file mode 100644 index 0000000000000000000000000000000000000000..44f63cc8d229c5eba09851ded6e088ef7f85bcb0 --- /dev/null +++ b/src/libs/extensionsystem/pluginerroroverview.h @@ -0,0 +1,62 @@ +/************************************************************************** +** +** This file is part of Qt Creator +** +** Copyright (c) 2011 Nokia Corporation and/or its subsidiary(-ies). +** +** Contact: Nokia Corporation (info@qt.nokia.com) +** +** +** GNU Lesser General Public License Usage +** +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this file. +** Please review the following information to ensure the GNU Lesser General +** Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** Other Usage +** +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** If you have questions regarding the use of this file, please contact +** Nokia at info@qt.nokia.com. +** +**************************************************************************/ + +#ifndef PLUGINERROROVERVIEW_H +#define PLUGINERROROVERVIEW_H + +#include "extensionsystem_global.h" + +#include <QtGui/QDialog> + +namespace ExtensionSystem { + +class PluginManager; + +namespace Internal { +class PluginErrorOverviewPrivate; +} + +class EXTENSIONSYSTEM_EXPORT PluginErrorOverview : public QDialog +{ + Q_OBJECT + +public: + explicit PluginErrorOverview(PluginManager *manager, QWidget *parent = 0); + ~PluginErrorOverview(); + +private: + Internal::PluginErrorOverviewPrivate *d; +}; + +} // ExtensionSystem + +#endif // PLUGINERROROVERVIEW_H diff --git a/src/libs/extensionsystem/pluginerroroverview.ui b/src/libs/extensionsystem/pluginerroroverview.ui new file mode 100644 index 0000000000000000000000000000000000000000..768b2f65732746079e519782d5c77e0e09148a22 --- /dev/null +++ b/src/libs/extensionsystem/pluginerroroverview.ui @@ -0,0 +1,91 @@ +<?xml version="1.0" encoding="UTF-8"?> +<ui version="4.0"> + <class>ExtensionSystem::Internal::PluginErrorOverview</class> + <widget class="QDialog" name="ExtensionSystem::Internal::PluginErrorOverview"> + <property name="geometry"> + <rect> + <x>0</x> + <y>0</y> + <width>434</width> + <height>361</height> + </rect> + </property> + <property name="windowTitle"> + <string>Qt Creator - Plugin loader messages</string> + </property> + <layout class="QVBoxLayout" name="verticalLayout"> + <item> + <widget class="QLabel" name="label"> + <property name="text"> + <string>The following plugins have errors and cannot be loaded:</string> + </property> + <property name="wordWrap"> + <bool>true</bool> + </property> + </widget> + </item> + <item> + <widget class="QListWidget" name="pluginList"/> + </item> + <item> + <widget class="QLabel" name="label_2"> + <property name="text"> + <string>Details:</string> + </property> + </widget> + </item> + <item> + <widget class="QTextEdit" name="pluginError"> + <property name="readOnly"> + <bool>true</bool> + </property> + </widget> + </item> + <item> + <widget class="QDialogButtonBox" name="buttonBox"> + <property name="orientation"> + <enum>Qt::Horizontal</enum> + </property> + <property name="standardButtons"> + <set>QDialogButtonBox::NoButton</set> + </property> + </widget> + </item> + </layout> + </widget> + <resources/> + <connections> + <connection> + <sender>buttonBox</sender> + <signal>accepted()</signal> + <receiver>ExtensionSystem::Internal::PluginErrorOverview</receiver> + <slot>accept()</slot> + <hints> + <hint type="sourcelabel"> + <x>248</x> + <y>254</y> + </hint> + <hint type="destinationlabel"> + <x>157</x> + <y>274</y> + </hint> + </hints> + </connection> + <connection> + <sender>buttonBox</sender> + <signal>rejected()</signal> + <receiver>ExtensionSystem::Internal::PluginErrorOverview</receiver> + <slot>reject()</slot> + <hints> + <hint type="sourcelabel"> + <x>316</x> + <y>260</y> + </hint> + <hint type="destinationlabel"> + <x>286</x> + <y>274</y> + </hint> + </hints> + </connection> + </connections> +</ui> diff --git a/src/libs/extensionsystem/pluginmanager.cpp b/src/libs/extensionsystem/pluginmanager.cpp index fcb4c8443cbbaea45683f81aeaba1fc220b736b1..e5edf5caa661727cf4fed00e9825202fb8878900 100644 --- a/src/libs/extensionsystem/pluginmanager.cpp +++ b/src/libs/extensionsystem/pluginmanager.cpp @@ -328,6 +328,22 @@ void PluginManager::loadPlugins() return d->loadPlugins(); } +/*! + \fn bool PluginManager::hasError() const + Returns true if any plugin has errors even though it is enabled. + Most useful to call after loadPlugins(). +*/ +bool PluginManager::hasError() const +{ + foreach (PluginSpec *spec, plugins()) { + // only show errors on startup if plugin is enabled. + if (spec->hasError() && spec->isEnabled() && !spec->isDisabledIndirectly()) { + return true; + } + } + return false; +} + /*! \fn void PluginManager::shutdown() Shuts down and deletes all plugins. diff --git a/src/libs/extensionsystem/pluginmanager.h b/src/libs/extensionsystem/pluginmanager.h index 883c2a14cc1f6982d5e7adf2f338719f4f0fbc3c..80b4c91157ae5a5bd5447cc776067c456d276ba3 100644 --- a/src/libs/extensionsystem/pluginmanager.h +++ b/src/libs/extensionsystem/pluginmanager.h @@ -106,6 +106,7 @@ public: QHash<QString, PluginCollection *> pluginCollections() const; void setFileExtension(const QString &extension); QString fileExtension() const; + bool hasError() const; // Settings void setSettings(QSettings *settings);