Changeset View
Changeset View
Standalone View
Standalone View
shell/settings/pluginpreferences.cpp
Show All 19 Lines | |||||
20 | 20 | | |||
21 | #include "pluginpreferences.h" | 21 | #include "pluginpreferences.h" | ||
22 | 22 | | |||
23 | #include <QDebug> | 23 | #include <QDebug> | ||
24 | #include <QVBoxLayout> | 24 | #include <QVBoxLayout> | ||
25 | 25 | | |||
26 | #include <KPluginSelector> | 26 | #include <KPluginSelector> | ||
27 | #include <KPluginInfo> | 27 | #include <KPluginInfo> | ||
28 | #include <KMessageWidget> | ||||
28 | 29 | | |||
29 | #include <interfaces/isession.h> | 30 | #include <interfaces/isession.h> | ||
30 | 31 | | |||
31 | #include "../core.h" | 32 | #include "../core.h" | ||
32 | #include "../plugincontroller.h" | 33 | #include "../plugincontroller.h" | ||
33 | #include "../debug.h" | 34 | #include "../debug.h" | ||
34 | 35 | | |||
35 | 36 | | |||
36 | namespace KDevelop | 37 | namespace KDevelop | ||
37 | { | 38 | { | ||
38 | 39 | | |||
39 | PluginPreferences::PluginPreferences(QWidget* parent) | 40 | PluginPreferences::PluginPreferences(QWidget* parent) | ||
40 | : ConfigPage(nullptr, nullptr, parent) | 41 | : ConfigPage(nullptr, nullptr, parent) | ||
41 | { | 42 | { | ||
42 | QVBoxLayout* lay = new QVBoxLayout(this ); | 43 | QVBoxLayout* lay = new QVBoxLayout(this ); | ||
43 | selector = new KPluginSelector( this ); | 44 | selector = new KPluginSelector( this ); | ||
44 | lay->addWidget( selector ); | 45 | | ||
45 | QMap<QString, QList<KPluginInfo>> plugins; | 46 | QMap<QString, QList<KPluginInfo>> plugins; | ||
46 | const QMap<QString, QString> categories = { | 47 | const QMap<QString, QString> categories = { | ||
47 | { "Core", i18nc("@title:group", "Core") }, | 48 | { "Core", i18nc("@title:group", "Core") }, | ||
48 | { "Project Management", i18nc("@title:group", "Project Management") }, | 49 | { "Project Management", i18nc("@title:group", "Project Management") }, | ||
49 | { "Version Control", i18nc("@title:group", "Version Control") }, | 50 | { "Version Control", i18nc("@title:group", "Version Control") }, | ||
50 | { "Utilities", i18nc("@title:group", "Utilities") }, | 51 | { "Utilities", i18nc("@title:group", "Utilities") }, | ||
51 | { "Documentation", i18nc("@title:group", "Documentation") }, | 52 | { "Documentation", i18nc("@title:group", "Documentation") }, | ||
52 | { "Language Support", i18nc("@title:group", "Language Support") }, | 53 | { "Language Support", i18nc("@title:group", "Language Support") }, | ||
53 | { "Debugging", i18nc("@title:group", "Debugging") }, | 54 | { "Debugging", i18nc("@title:group", "Debugging") }, | ||
54 | { "Testing", i18nc("@title:group", "Testing") }, | 55 | { "Testing", i18nc("@title:group", "Testing") }, | ||
55 | { "Analyzers", i18nc("@title:group", "Analyzers") }, | 56 | { "Analyzers", i18nc("@title:group", "Analyzers") }, | ||
56 | { "Other", i18nc("@title:group", "Other") } | 57 | { "Other", i18nc("@title:group", "Other") } | ||
57 | }; | 58 | }; | ||
59 | | ||||
60 | /* If the plugin was marked to be loaded, but it's failing, this applies */ | ||||
61 | PluginController* controller = qobject_cast<PluginController*>(Core::self()->pluginControllerInternal()); | ||||
mwolff: this looks wrong, it should be
auto controller = Core::self()->pluginControllerInternal(); | |||||
62 | QList<QPair<QString,QString>> failedPlugins = controller->failedPlugins(); | ||||
brauch: auto | |||||
mwolff: const auto, even | |||||
63 | qDebug() << "Traying to get the failed to load stuff."; | ||||
brauch: qCDebug and proper wording please ;) | |||||
mwolff: remove altogether | |||||
64 | if (failedPlugins.count()) { | ||||
65 | qDebug() << "Passou por aqui"; | ||||
brauch: remove this | |||||
66 | auto messageWidget = new KMessageWidget(this); | ||||
67 | messageWidget->setCloseButtonVisible(false); | ||||
68 | QString text = i18n("Some plugins failed do load:\n"); | ||||
mwolff: needs to use i18np based on number of errors | |||||
69 | foreach(const auto& plugin, failedPlugins) { | ||||
70 | text += plugin.first + " " + plugin.second + "\n"; | ||||
should probably have a colon : in between or so, but then you need an i18n call as well brauch: should probably have a colon : in between or so, but then you need an i18n call as well | |||||
brauch: also don't add a newline on the last item, the spacing is weird | |||||
And actually, you can return the assembled string already, then you don't need the QPair stuff at all. brauch: And actually, you can return the assembled string already, then you don't need the QPair stuff… | |||||
71 | } | ||||
72 | messageWidget->setText(text); | ||||
73 | lay->addWidget(messageWidget); | ||||
74 | messageWidget->show(); | ||||
75 | } | ||||
76 | | ||||
77 | lay->addWidget( selector ); | ||||
58 | foreach (const KPluginMetaData& info, Core::self()->pluginControllerInternal()->allPluginInfos()) { | 78 | foreach (const KPluginMetaData& info, Core::self()->pluginControllerInternal()->allPluginInfos()) { | ||
59 | const QString loadMode = info.value(QStringLiteral("X-KDevelop-LoadMode")); | 79 | const QString loadMode = info.value(QStringLiteral("X-KDevelop-LoadMode")); | ||
60 | if( loadMode.isEmpty() || loadMode == QLatin1String("UserSelectable") ) | 80 | if( loadMode.isEmpty() || loadMode == QLatin1String("UserSelectable") ) | ||
61 | { | 81 | { | ||
62 | QString category = info.category(); | 82 | QString category = info.category(); | ||
63 | if (!categories.contains(category)) { | 83 | if (!categories.contains(category)) { | ||
64 | if (!category.isEmpty()) { | 84 | if (!category.isEmpty()) { | ||
65 | qWarning() << "unknown category for plugin" << info.name() << ":" << info.category(); | 85 | qWarning() << "unknown category for plugin" << info.name() << ":" << info.category(); | ||
Show All 23 Lines | |||||
89 | } | 109 | } | ||
90 | 110 | | |||
91 | void PluginPreferences::apply() | 111 | void PluginPreferences::apply() | ||
92 | { | 112 | { | ||
93 | selector->save(); | 113 | selector->save(); | ||
94 | qCDebug(SHELL) << "Plugins before apply: " << Core::self()->pluginControllerInternal()->allPluginNames(); | 114 | qCDebug(SHELL) << "Plugins before apply: " << Core::self()->pluginControllerInternal()->allPluginNames(); | ||
95 | Core::self()->pluginControllerInternal()->updateLoadedPlugins(); | 115 | Core::self()->pluginControllerInternal()->updateLoadedPlugins(); | ||
96 | qCDebug(SHELL) << "Plugins after apply: " << Core::self()->pluginControllerInternal()->allPluginNames(); | 116 | qCDebug(SHELL) << "Plugins after apply: " << Core::self()->pluginControllerInternal()->allPluginNames(); | ||
97 | selector->load(); // Some plugins may have failed to load, they must be unchecked. | 117 | selector->load(); | ||
98 | } | 118 | } | ||
99 | 119 | | |||
100 | void PluginPreferences::reset() | 120 | void PluginPreferences::reset() | ||
101 | { | 121 | { | ||
102 | selector->load(); | 122 | selector->load(); | ||
103 | } | 123 | } | ||
104 | 124 | | |||
105 | } | 125 | } | ||
106 | 126 | | |||
107 | 127 | |
this looks wrong, it should be
auto controller = Core::self()->pluginControllerInternal();