dde-dock-systray-plugin.so file existence check

This commit is contained in:
Hualet Wang 2015-07-01 15:04:57 +08:00
parent 1b04e2a3bc
commit ca5e659ab0
3 changed files with 21 additions and 7 deletions

View File

@ -22,3 +22,6 @@ HEADERS += systrayplugin.h \
docktrayitem.h \
../dde-dock/src/abstractdockitem.h \
dbustraymanager.h
target.path = /usr/share/dde-dock/plugins/
INSTALLS += target

View File

@ -4,6 +4,8 @@
#include "systraymanager.h"
static QString SystrayPluginPath = "/usr/share/dde-dock/plugins/libdock-systray-plugin.so";
SystrayManager::SystrayManager(QObject *parent)
: QObject(parent),
m_plugin(0)
@ -13,17 +15,25 @@ SystrayManager::SystrayManager(QObject *parent)
QList<AbstractDockItem*> SystrayManager::trayIcons()
{
return m_plugin->items();
if (m_plugin) {
return m_plugin->items();
} else {
return QList<AbstractDockItem*>();
}
}
void SystrayManager::loadPlugin()
{
QPluginLoader loader("/home/hualet/project/linuxdeepin/dde-workspace-2015/dde-dock-systray-plugin/build/libdock-systray-plugin.so");
QObject *plugin = loader.instance();
if (plugin) {
m_plugin = qobject_cast<DockPluginInterface*>(plugin);
if (QFile::exists(SystrayPluginPath)) {
QPluginLoader loader(SystrayPluginPath);
QObject *plugin = loader.instance();
if (plugin) {
m_plugin = qobject_cast<DockPluginInterface*>(plugin);
} else {
qWarning() << "Failed to load systray plugin.";
qWarning() << loader.errorString();
}
} else {
qWarning() << "Failed to load systray plugin.";
qWarning() << loader.errorString();
qWarning() << "libdock-systray-plugin.so file not found!";
}
}

View File

@ -16,6 +16,7 @@ private:
DockPluginInterface *m_plugin;
void loadPlugin();
void unloadPlugin();
};
#endif // SYSTRAYMANAGER_H