diff --git a/interfaces/iplugin.h b/interfaces/iplugin.h --- a/interfaces/iplugin.h +++ b/interfaces/iplugin.h @@ -210,14 +210,21 @@ /** * This function is necessary because there is no proper way to signal errors from plugin constructor. - * @returns True if the plugin has encountered an error, false otherwise. + * @returns True if the plugin has encountered an error (and therefore has an error description), + * false otherwise. */ - virtual bool hasError() const; - + bool hasError() const; + /** * Description of the last encountered error, of an empty string if none. */ - virtual QString errorDescription() const; + QString errorDescription() const; + + /** + * Set a @p description of the errror encountered. An empty error + * description implies no error in the plugin. + */ + void setErrorDescription(QString const& description); /** * Get the global config page with the \p number, config pages from 0 to diff --git a/interfaces/iplugin.cpp b/interfaces/iplugin.cpp --- a/interfaces/iplugin.cpp +++ b/interfaces/iplugin.cpp @@ -78,6 +78,7 @@ IPlugin *q; ICore *core; QVector m_extensions; + QString m_errorDescription; }; IPlugin::IPlugin( const QString &componentName, QObject *parent ) @@ -184,12 +185,18 @@ bool KDevelop::IPlugin::hasError() const { - return false; + return !d->m_errorDescription.isEmpty(); } +void KDevelop::IPlugin::setErrorDescription(const QString& description) +{ + d->m_errorDescription = description; +} + + QString KDevelop::IPlugin::errorDescription() const { - return QString(); + return d->m_errorDescription; } int KDevelop::IPlugin::configPages() const diff --git a/plugins/bazaar/bazaarplugin.h b/plugins/bazaar/bazaarplugin.h --- a/plugins/bazaar/bazaarplugin.h +++ b/plugins/bazaar/bazaarplugin.h @@ -40,9 +40,6 @@ explicit BazaarPlugin(QObject* parent, const QVariantList& args = QVariantList()); ~BazaarPlugin() override; - bool hasError() const override; - QString errorDescription() const override; - QString name() const override; KDevelop::VcsJob* add(const QList& localLocations, RecursionMode recursion=Recursive) override; @@ -75,9 +72,6 @@ private: KDevelop::VcsPluginHelper* m_vcsPluginHelper; - - bool m_hasError; - QString m_errorDescription; }; #endif // BAZAAR_BAZAARPLUGIN_H diff --git a/plugins/bazaar/bazaarplugin.cpp b/plugins/bazaar/bazaarplugin.cpp --- a/plugins/bazaar/bazaarplugin.cpp +++ b/plugins/bazaar/bazaarplugin.cpp @@ -45,13 +45,11 @@ BazaarPlugin::BazaarPlugin(QObject* parent, const QVariantList& args) : IPlugin(QStringLiteral("kdevbazaar"), parent), - m_vcsPluginHelper(new KDevelop::VcsPluginHelper(this, this)), m_hasError(false) + m_vcsPluginHelper(new KDevelop::VcsPluginHelper(this, this)) { Q_UNUSED(args); // What is this? if (QStandardPaths::findExecutable(QStringLiteral("bzr")).isEmpty()) { - m_hasError = true; - m_errorDescription = i18n("Bazaar is not installed (bzr executable not" - " found)"); + setErrorDescription(i18n("Unable to find Bazaar (bzr) executable Is it installed on the system?")); return; } @@ -339,12 +337,3 @@ return menuExt; } -bool BazaarPlugin::hasError() const -{ - return m_hasError; -} - -QString BazaarPlugin::errorDescription() const -{ - return m_errorDescription; -} diff --git a/plugins/git/gitplugin.h b/plugins/git/gitplugin.h --- a/plugins/git/gitplugin.h +++ b/plugins/git/gitplugin.h @@ -140,8 +140,6 @@ bool hasModifications(const QDir& repository); bool hasModifications(const QDir& repo, const QUrl& file); - bool hasError() const override; - QString errorDescription() const override; void registerRepositoryForCurrentBranchChanges(const QUrl& repository) override; KDevelop::CheckInRepositoryJob* isInRepository(KTextEditor::Document* document) override; @@ -216,8 +214,6 @@ /** Tells if it's older than 1.7.0 or not */ bool m_oldVersion; - bool m_hasError; - QString m_errorDescription; KDirWatch* m_watcher; QList m_branchesChange; bool m_usePrefix; diff --git a/plugins/git/gitplugin.cpp b/plugins/git/gitplugin.cpp --- a/plugins/git/gitplugin.cpp +++ b/plugins/git/gitplugin.cpp @@ -181,16 +181,14 @@ : DistributedVersionControlPlugin(parent, QStringLiteral("kdevgit")), m_oldVersion(false), m_usePrefix(true) { if (QStandardPaths::findExecutable(QStringLiteral("git")).isEmpty()) { - m_hasError = true; - m_errorDescription = i18n("git is not installed"); + setErrorDescription(i18n("Unable to find git executable. Is it installed on the system?")); return; } KDEV_USE_EXTENSION_INTERFACE( KDevelop::IBasicVersionControl ) KDEV_USE_EXTENSION_INTERFACE( KDevelop::IDistributedVersionControl ) KDEV_USE_EXTENSION_INTERFACE( KDevelop::IBranchingVersionControl ) - m_hasError = false; setObjectName(QStringLiteral("Git")); DVcsJob* versionJob = new DVcsJob(QDir::tempPath(), this, KDevelop::OutputJob::Silent); @@ -1458,16 +1456,6 @@ return new GitVcsLocationWidget(parent); } -bool GitPlugin::hasError() const -{ - return m_hasError; -} - -QString GitPlugin::errorDescription() const -{ - return m_errorDescription; -} - void GitPlugin::registerRepositoryForCurrentBranchChanges(const QUrl& repository) { QDir dir = dotGitDirectory(repository); diff --git a/plugins/konsole/kdevkonsoleviewplugin.h b/plugins/konsole/kdevkonsoleviewplugin.h --- a/plugins/konsole/kdevkonsoleviewplugin.h +++ b/plugins/konsole/kdevkonsoleviewplugin.h @@ -28,8 +28,6 @@ ~KDevKonsoleViewPlugin() override; void unload() override; - bool hasError() const override; - QString errorDescription() const override; KPluginFactory* konsoleFactory() const; diff --git a/plugins/konsole/kdevkonsoleviewplugin.cpp b/plugins/konsole/kdevkonsoleviewplugin.cpp --- a/plugins/konsole/kdevkonsoleviewplugin.cpp +++ b/plugins/konsole/kdevkonsoleviewplugin.cpp @@ -62,7 +62,9 @@ , m_konsoleFactory(konsoleFactory) , m_viewFactory(konsoleFactory ? new KDevKonsoleViewFactory(this) : nullptr) { - if (m_viewFactory) { + if(!m_viewFactory) { + setErrorDescription(i18n("Failed to load 'konsolepart' plugin")); + } else { core()->uiController()->addToolView(QStringLiteral("Konsole"), m_viewFactory); } } @@ -74,16 +76,6 @@ } } -bool KDevKonsoleViewPlugin::hasError() const -{ - return !m_viewFactory; -} - -QString KDevKonsoleViewPlugin::errorDescription() const -{ - return !m_viewFactory ? i18n("Failed to load 'konsolepart' plugin") : QString(); -} - KPluginFactory* KDevKonsoleViewPlugin::konsoleFactory() const { return m_konsoleFactory; diff --git a/plugins/perforce/perforceplugin.h b/plugins/perforce/perforceplugin.h --- a/plugins/perforce/perforceplugin.h +++ b/plugins/perforce/perforceplugin.h @@ -130,9 +130,6 @@ KDevelop::VcsJob* edit(const QList& localLocations); - bool hasError() const override; - QString errorDescription() const override; - KDevelop::ContextMenuExtension contextMenuExtension(KDevelop::Context* context) override; @@ -174,10 +171,6 @@ QString m_perforceConfigName; QString m_perforceExecutable; QAction* m_edit_action; - - bool m_hasError; - QString m_errorDescription; - }; #endif // PERFORCEPLUGIN_H diff --git a/plugins/perforce/perforceplugin.cpp b/plugins/perforce/perforceplugin.cpp --- a/plugins/perforce/perforceplugin.cpp +++ b/plugins/perforce/perforceplugin.cpp @@ -118,19 +118,16 @@ , m_perforceConfigName("p4config.txt") , m_perforceExecutable("p4") , m_edit_action(nullptr) - , m_hasError(true) { QProcessEnvironment currentEviron(QProcessEnvironment::systemEnvironment()); QString tmp(currentEviron.value("P4CONFIG")); if (tmp.isEmpty()) { // We require the P4CONFIG variable to be set because the perforce command line client will need it - m_hasError = true; - m_errorDescription = i18n("The variable P4CONFIG is not set."); + setErrorDescription(i18n("The variable P4CONFIG is not set. Is perforce installed on the system?")); return; } else { m_perforceConfigName = tmp; } - m_hasError = false; qCDebug(PLUGIN_PERFORCE) << "The value of P4CONFIG is : " << tmp; KDEV_USE_EXTENSION_INTERFACE(KDevelop::IBasicVersionControl) @@ -696,14 +693,4 @@ return j; } -bool PerforcePlugin::hasError() const -{ - return m_hasError; -} - -QString PerforcePlugin::errorDescription() const -{ - return m_errorDescription; -} -