mirror of
https://github.com/linuxdeepin/dde-dock.git
synced 2025-06-03 00:15:21 +00:00
dde-dock-systray-plugin.so file existence check
This commit is contained in:
parent
1b04e2a3bc
commit
ca5e659ab0
@ -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
|
||||
|
@ -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!";
|
||||
}
|
||||
}
|
||||
|
@ -16,6 +16,7 @@ private:
|
||||
DockPluginInterface *m_plugin;
|
||||
|
||||
void loadPlugin();
|
||||
void unloadPlugin();
|
||||
};
|
||||
|
||||
#endif // SYSTRAYMANAGER_H
|
||||
|
Loading…
x
Reference in New Issue
Block a user