Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
This patch extends plugins interface. add new function icon to PsiPlugin Also add that icon to plugins combobox
- Loading branch information
Showing
1 changed file
with
122 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,122 @@ | ||
diff --git a/src/options/opt_plugins.cpp b/src/options/opt_plugins.cpp | ||
index c99f1b5..79d362d 100644 | ||
--- a/src/options/opt_plugins.cpp | ||
+++ b/src/options/opt_plugins.cpp | ||
@@ -100,7 +100,7 @@ void OptionsTabPlugins::listPlugins() | ||
QStringList plugins = pm->availablePlugins(); | ||
plugins.sort(); | ||
foreach (const QString& plugin, plugins){ | ||
- d->cb_plugins->addItem(plugin); | ||
+ d->cb_plugins->addItem(pm->icon(plugin), plugin); | ||
} | ||
pluginSelected(0); | ||
} | ||
diff --git a/src/pluginhost.cpp b/src/pluginhost.cpp | ||
index 5056ce2..44154a3 100644 | ||
--- a/src/pluginhost.cpp | ||
+++ b/src/pluginhost.cpp | ||
@@ -155,6 +155,16 @@ int PluginHost::priority() const | ||
} | ||
|
||
/** | ||
+ * \brief Returns plugin icon. | ||
+ * | ||
+ * Data is available also when plugin is not loaded. | ||
+ */ | ||
+const QIcon& PluginHost::icon() const | ||
+{ | ||
+ return icon_; | ||
+} | ||
+ | ||
+/** | ||
* \brief Returns plugin options widget. | ||
* | ||
* Always returns null if plugin is not currently loaded. | ||
@@ -218,6 +228,10 @@ bool PluginHost::load() | ||
shortName_ = psiPlugin->shortName(); | ||
version_ = psiPlugin->version(); | ||
priority_ = psiPlugin->priority(); | ||
+ icon_ = QIcon(psiPlugin->icon()); | ||
+ // FIXME No icon if plugin disabled. | ||
+ // I don't know how but this workaround works. | ||
+ icon_.availableSizes(); | ||
PluginInfoProvider *pip = qobject_cast<PluginInfoProvider*>(plugin_); | ||
if (pip) { | ||
hasInfo_ = true; | ||
diff --git a/src/pluginhost.h b/src/pluginhost.h | ||
index ca41b7d..b8507c0 100644 | ||
--- a/src/pluginhost.h | ||
+++ b/src/pluginhost.h | ||
@@ -12,6 +12,7 @@ | ||
#include <QMultiMap> | ||
#include <QPointer> | ||
#include <QTextEdit> | ||
+#include <QIcon> | ||
|
||
#include "applicationinfo.h" | ||
#include "userlist.h" | ||
@@ -61,6 +62,7 @@ public: | ||
const QString& shortName() const; | ||
const QString& version() const; | ||
int priority() const; | ||
+ const QIcon& icon() const; | ||
|
||
// loading | ||
bool load(); | ||
@@ -197,6 +199,7 @@ private: | ||
QString shortName_; | ||
QString version_; | ||
int priority_; | ||
+ QIcon icon_; | ||
QPluginLoader* loader_; | ||
Iconset* iconset_; | ||
|
||
diff --git a/src/pluginmanager.cpp b/src/pluginmanager.cpp | ||
index 48e6f53..c5b90da 100644 | ||
--- a/src/pluginmanager.cpp | ||
+++ b/src/pluginmanager.cpp | ||
@@ -759,6 +759,16 @@ QString PluginManager::pluginInfo(const QString& plugin) const | ||
return info; | ||
} | ||
|
||
+QIcon PluginManager::icon(const QString& plugin) const | ||
+{ | ||
+ QIcon icon; | ||
+ if (hosts_.contains(plugin)) { | ||
+ icon = hosts_[plugin]->icon(); | ||
+ } | ||
+ | ||
+ return icon; | ||
+} | ||
+ | ||
/** | ||
* Tells the plugin manager about an XMPP::Client and the owning PsiAccount | ||
*/ | ||
diff --git a/src/pluginmanager.h b/src/pluginmanager.h | ||
index b683cbe..ee9401c 100644 | ||
--- a/src/pluginmanager.h | ||
+++ b/src/pluginmanager.h | ||
@@ -68,6 +68,7 @@ public: | ||
|
||
QString pluginInfo(const QString& plugin) const; | ||
bool hasInfoProvider(const QString& plugin) const; | ||
+ QIcon icon(const QString& plugin) const; | ||
|
||
static const QString loadOptionPrefix; | ||
static const QString pluginOptionPrefix; | ||
diff --git a/src/plugins/include/psiplugin.h b/src/plugins/include/psiplugin.h | ||
index 13fa9c6..1ed5a74 100644 | ||
--- a/src/plugins/include/psiplugin.h | ||
+++ b/src/plugins/include/psiplugin.h | ||
@@ -110,8 +110,10 @@ public: | ||
|
||
virtual void applyOptions() = 0; | ||
virtual void restoreOptions() = 0; | ||
+ | ||
+ virtual QIcon icon() const = 0; | ||
}; | ||
|
||
-Q_DECLARE_INTERFACE(PsiPlugin, "org.psi-im.PsiPlugin/0.3"); | ||
+Q_DECLARE_INTERFACE(PsiPlugin, "org.psi-im.PsiPlugin/0.4"); | ||
|
||
#endif |