SPlitted kde and appindicator code into shared libraries to avoid
additional dependencies.
This commit is contained in:
10
qcma.pro
10
qcma.pro
@@ -15,6 +15,16 @@ android {
|
|||||||
# Compile the headless binary only on Linux because it depends on dbus
|
# Compile the headless binary only on Linux because it depends on dbus
|
||||||
unix:!macx:!android {
|
unix:!macx:!android {
|
||||||
SUBDIRS += qcma_cli.pro
|
SUBDIRS += qcma_cli.pro
|
||||||
|
# The appindicator and kde extensions are linux only too
|
||||||
|
ENABLE_APPINDICATOR {
|
||||||
|
SUBDIRS += qcma_appindicator.pro
|
||||||
|
}
|
||||||
|
ENABLE_KDENOTIFIER {
|
||||||
|
greaterThan(QT_MAJOR_VERSION, 4) {
|
||||||
|
#error("ENABLE_KDE can only be used with Qt4")
|
||||||
|
}
|
||||||
|
SUBDIRS += qcma_kdenotifier.pro
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
TRANSLATIONS += \
|
TRANSLATIONS += \
|
||||||
|
26
qcma_appindicator.pro
Normal file
26
qcma_appindicator.pro
Normal file
@@ -0,0 +1,26 @@
|
|||||||
|
QT += gui widgets
|
||||||
|
|
||||||
|
TARGET = qcma_appindicator
|
||||||
|
TEMPLATE = lib
|
||||||
|
CONFIG += plugin link_pkgconfig
|
||||||
|
DEFINES += QCMA_TRAYINDICATOR_LIBRARY
|
||||||
|
|
||||||
|
QT_CONFIG -= no-pkg-config
|
||||||
|
|
||||||
|
PKGCONFIG += appindicator-0.1 libnotify
|
||||||
|
INCLUDEPATH += src/
|
||||||
|
|
||||||
|
SOURCES += \
|
||||||
|
src/indicator/unityindicator.cpp
|
||||||
|
|
||||||
|
HEADERS += \
|
||||||
|
src/indicator/trayindicator_global.h \
|
||||||
|
src/indicator/trayindicator.h \
|
||||||
|
src/indicator/unityindicator.h
|
||||||
|
|
||||||
|
actions64.path = $$DATADIR/icons/hicolor/64x64/actions
|
||||||
|
actions64.files += resources/images/qcma_on.png
|
||||||
|
actions64.files += resources/images/qcma_off.png
|
||||||
|
|
||||||
|
target.path = /usr/lib/qcma
|
||||||
|
INSTALLS += target actions64
|
35
qcma_gui.pro
35
qcma_gui.pro
@@ -10,7 +10,6 @@ SOURCES += \
|
|||||||
src/gui/singleapplication.cpp \
|
src/gui/singleapplication.cpp \
|
||||||
src/gui/clientmanager.cpp \
|
src/gui/clientmanager.cpp \
|
||||||
src/gui/filterlineedit.cpp \
|
src/gui/filterlineedit.cpp \
|
||||||
src/indicator/trayindicator.cpp \
|
|
||||||
src/indicator/qtrayicon.cpp \
|
src/indicator/qtrayicon.cpp \
|
||||||
# forms
|
# forms
|
||||||
src/forms/backupitem.cpp \
|
src/forms/backupitem.cpp \
|
||||||
@@ -25,8 +24,7 @@ HEADERS += \
|
|||||||
src/gui/singleapplication.h \
|
src/gui/singleapplication.h \
|
||||||
src/gui/clientmanager.h \
|
src/gui/clientmanager.h \
|
||||||
src/gui/filterlineedit.h \
|
src/gui/filterlineedit.h \
|
||||||
src/indicator/trayindicator_global.h \
|
src/indicator/trayindicator_import.h \
|
||||||
src/indicator/trayindicator.h \
|
|
||||||
src/indicator/qtrayicon.h \
|
src/indicator/qtrayicon.h \
|
||||||
# forms
|
# forms
|
||||||
src/forms/backupitem.h \
|
src/forms/backupitem.h \
|
||||||
@@ -46,6 +44,8 @@ FORMS += \
|
|||||||
|
|
||||||
#Linux-only config
|
#Linux-only config
|
||||||
unix:!macx {
|
unix:!macx {
|
||||||
|
PKGCONFIG += libnotify
|
||||||
|
|
||||||
DATADIR = $$PREFIX/share
|
DATADIR = $$PREFIX/share
|
||||||
|
|
||||||
# config for desktop file and icon
|
# config for desktop file and icon
|
||||||
@@ -55,46 +55,19 @@ unix:!macx {
|
|||||||
icon64.path = $$DATADIR/icons/hicolor/64x64/apps
|
icon64.path = $$DATADIR/icons/hicolor/64x64/apps
|
||||||
icon64.files += resources/images/$${TARGET}.png
|
icon64.files += resources/images/$${TARGET}.png
|
||||||
|
|
||||||
# AppIndicator support
|
|
||||||
ENABLE_INDICATOR {
|
|
||||||
actions64.path = $$DATADIR/icons/hicolor/64x64/actions
|
|
||||||
actions64.files += resources/images/qcma_on.png
|
|
||||||
actions64.files += resources/images/qcma_off.png
|
|
||||||
|
|
||||||
SOURCES += src/indicator/unityindicator.cpp
|
|
||||||
HEADERS += src/indicator/unityindicator.h
|
|
||||||
PKGCONFIG += appindicator3-0.1
|
|
||||||
DEFINES += ENABLE_APPINDICATOR=1
|
|
||||||
}
|
|
||||||
target.path = $$BINDIR
|
target.path = $$BINDIR
|
||||||
|
|
||||||
INSTALLS += target desktop icon64 actions64
|
INSTALLS += target desktop icon64
|
||||||
|
|
||||||
# KDE support
|
|
||||||
ENABLE_KDE {
|
|
||||||
greaterThan(QT_MAJOR_VERSION, 4) {
|
|
||||||
error("ENABLE_KDE can only be used with Qt4")
|
|
||||||
}
|
|
||||||
LIBS += -lkdeui
|
|
||||||
DEFINES += ENABLE_KDE_NOTIFIER=1
|
|
||||||
SOURCES += src/gui/kdenotifier.cpp
|
|
||||||
HEADERS += src/gui/kdenotifier.h
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
unix:!macx {
|
unix:!macx {
|
||||||
|
|
||||||
PKGCONFIG += libnotify
|
|
||||||
|
|
||||||
QT += dbus
|
QT += dbus
|
||||||
|
|
||||||
# Create the introspection XML
|
# Create the introspection XML
|
||||||
QT5_SUFFIX {
|
QT5_SUFFIX {
|
||||||
system(qdbuscpp2xml-qt5 -M -s src/gui/mainwidget.h -o org.qcma.ClientManager.xml)
|
system(qdbuscpp2xml-qt5 -M -s src/gui/mainwidget.h -o org.qcma.ClientManager.xml)
|
||||||
} else {
|
} else {
|
||||||
system(qdbuscpp2xml -M -s src/gui/mainwidget.h -o org.qcma.ClientManager.xml)
|
system(qdbuscpp2xml -M -s src/gui/mainwidget.h -o org.qcma.ClientManager.xml)
|
||||||
}
|
}
|
||||||
|
|
||||||
# Create the helper class
|
# Create the helper class
|
||||||
DBUS_ADAPTORS = org.qcma.ClientManager.xml
|
DBUS_ADAPTORS = org.qcma.ClientManager.xml
|
||||||
}
|
}
|
||||||
|
@@ -1,21 +0,0 @@
|
|||||||
QT += gui widgets
|
|
||||||
|
|
||||||
TARGET = qcma_trayindicator
|
|
||||||
TEMPLATE = lib
|
|
||||||
CONFIG += plugin
|
|
||||||
|
|
||||||
PKGCONFIG += appindicator3-0.1
|
|
||||||
DEFINES += QCMA_TRAYINDICATOR_LIBRARY
|
|
||||||
|
|
||||||
SOURCES += \
|
|
||||||
src/indicator/trayindicator.cpp \
|
|
||||||
src/indicator/qtrayicon.cpp
|
|
||||||
|
|
||||||
HEADERS += \
|
|
||||||
src/indicator/trayindicator_global.h \
|
|
||||||
src/indicator/trayindicator.h
|
|
||||||
|
|
||||||
unix {
|
|
||||||
target.path = /usr/lib/qcma
|
|
||||||
INSTALLS += target
|
|
||||||
}
|
|
19
qcma_kdenotifier.pro
Normal file
19
qcma_kdenotifier.pro
Normal file
@@ -0,0 +1,19 @@
|
|||||||
|
QT += gui widgets
|
||||||
|
|
||||||
|
TARGET = qcma_kdenotifier
|
||||||
|
TEMPLATE = lib
|
||||||
|
CONFIG += plugin
|
||||||
|
DEFINES += QCMA_TRAYINDICATOR_LIBRARY
|
||||||
|
LIBS += -lkdeui
|
||||||
|
INCLUDEPATH += src/
|
||||||
|
|
||||||
|
SOURCES += \
|
||||||
|
src/indicator/kdenotifier.cpp \
|
||||||
|
src/indicator/kdenotifiertray.cpp
|
||||||
|
|
||||||
|
HEADERS += \
|
||||||
|
src/indicator/trayindicator.h \
|
||||||
|
src/indicator/kdenotifier.h \
|
||||||
|
src/indicator/kdenotifiertray.h
|
||||||
|
|
||||||
|
target.path = /usr/lib/qcma
|
@@ -28,11 +28,7 @@
|
|||||||
#include "qlistdb.h"
|
#include "qlistdb.h"
|
||||||
#include "sqlitedb.h"
|
#include "sqlitedb.h"
|
||||||
|
|
||||||
#ifdef ENABLE_APPINDICATOR
|
|
||||||
#include "indicator/unityindicator.h"
|
|
||||||
#else
|
|
||||||
#include "indicator/qtrayicon.h"
|
#include "indicator/qtrayicon.h"
|
||||||
#endif
|
|
||||||
|
|
||||||
#include <QApplication>
|
#include <QApplication>
|
||||||
#include <QDebug>
|
#include <QDebug>
|
||||||
@@ -57,21 +53,13 @@ MainWidget::MainWidget(QWidget *parent) :
|
|||||||
// expose qcma over dbus so the database update can be triggered
|
// expose qcma over dbus so the database update can be triggered
|
||||||
dbus.registerObject("/ClientManager", this);
|
dbus.registerObject("/ClientManager", this);
|
||||||
dbus.registerService("org.qcma.ClientManager");
|
dbus.registerService("org.qcma.ClientManager");
|
||||||
#ifndef ENABLE_KDE_NOTIFIER
|
|
||||||
trayIcon = NULL;
|
trayIcon = NULL;
|
||||||
#else
|
|
||||||
notifierItem = NULL;
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
MainWidget::MainWidget(QWidget *parent) :
|
MainWidget::MainWidget(QWidget *parent) :
|
||||||
QWidget(parent), db(NULL), configForm(NULL), managerForm(NULL), backupForm(NULL)
|
QWidget(parent), db(NULL), configForm(NULL), managerForm(NULL), backupForm(NULL)
|
||||||
{
|
{
|
||||||
#ifndef ENABLE_KDE_NOTIFIER
|
|
||||||
trayIcon = NULL;
|
trayIcon = NULL;
|
||||||
#else
|
|
||||||
notifierItem = NULL;
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@@ -113,14 +101,10 @@ void MainWidget::stopServer()
|
|||||||
|
|
||||||
void MainWidget::deviceDisconnect()
|
void MainWidget::deviceDisconnect()
|
||||||
{
|
{
|
||||||
#ifndef ENABLE_KDE_NOTIFIER
|
|
||||||
#ifndef Q_OS_WIN32
|
#ifndef Q_OS_WIN32
|
||||||
trayIcon->setIcon("qcma_off.png");
|
trayIcon->setIcon("qcma_off.png");
|
||||||
#else
|
#else
|
||||||
trayIcon->setIcon("qcma_off_16.png");
|
trayIcon->setIcon("qcma_off_16.png");
|
||||||
#endif
|
|
||||||
#else
|
|
||||||
notifierItem->setIconByPixmap(QIcon(":/main/resources/images/tray/qcma_off.png"));
|
|
||||||
#endif
|
#endif
|
||||||
qDebug("Icon changed - disconnected");
|
qDebug("Icon changed - disconnected");
|
||||||
setTrayTooltip(tr("Disconnected"));
|
setTrayTooltip(tr("Disconnected"));
|
||||||
@@ -129,14 +113,10 @@ void MainWidget::deviceDisconnect()
|
|||||||
|
|
||||||
void MainWidget::deviceConnect(QString message)
|
void MainWidget::deviceConnect(QString message)
|
||||||
{
|
{
|
||||||
#ifndef ENABLE_KDE_NOTIFIER
|
|
||||||
#ifndef Q_OS_WIN32
|
#ifndef Q_OS_WIN32
|
||||||
trayIcon->setIcon("qcma_on.png");
|
trayIcon->setIcon("qcma_on.png");
|
||||||
#else
|
#else
|
||||||
trayIcon->setIcon("qcma_off_16.png");
|
trayIcon->setIcon("qcma_off_16.png");
|
||||||
#endif
|
|
||||||
#else
|
|
||||||
notifierItem->setIconByPixmap(QIcon(":/main/resources/images/tray/qcma_on.png"));
|
|
||||||
#endif
|
#endif
|
||||||
qDebug("Icon changed - connected");
|
qDebug("Icon changed - connected");
|
||||||
setTrayTooltip(message);
|
setTrayTooltip(message);
|
||||||
@@ -232,13 +212,41 @@ void MainWidget::refreshDatabase()
|
|||||||
managerForm->refreshDatabase();
|
managerForm->refreshDatabase();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
TrayIndicator *MainWidget::createTrayObject(QWidget *parent)
|
||||||
|
{
|
||||||
|
TrayFunctionPointer create_tray = NULL;
|
||||||
|
|
||||||
|
QString desktop = getenv("XDG_CURRENT_DESKTOP");
|
||||||
|
|
||||||
|
#if QT_VERSION < QT_VERSION_CHECK(5, 0, 0)
|
||||||
|
if(desktop.toLower() == "kde")
|
||||||
|
{
|
||||||
|
// KDENotifier
|
||||||
|
QLibrary library("/usr/share/qcma/qcma_kdenotifier.so");
|
||||||
|
if(library.load())
|
||||||
|
create_tray = reinterpret_cast<TrayFunctionPointer>(library.resolve("createTrayIndicator"));
|
||||||
|
else
|
||||||
|
qDebug() << "Cannot load qcma_kdenotifier plugin";
|
||||||
|
}
|
||||||
|
else
|
||||||
|
#endif
|
||||||
|
// if(desktop.toLower() == "unity")
|
||||||
|
{
|
||||||
|
// AppIndicator
|
||||||
|
QLibrary library("/usr/share/qcma/qcma_appindicator.so");
|
||||||
|
if(library.load())
|
||||||
|
create_tray = reinterpret_cast<TrayFunctionPointer>(library.resolve("createTrayIndicator"));
|
||||||
|
else
|
||||||
|
qDebug() << "Cannot load qcma_appindicator plugin";
|
||||||
|
}
|
||||||
|
|
||||||
|
// else QSystemTrayIcon
|
||||||
|
return (create_tray != NULL) ? create_tray(parent) : createTrayIndicator(parent);
|
||||||
|
}
|
||||||
|
|
||||||
void MainWidget::createTrayIcon()
|
void MainWidget::createTrayIcon()
|
||||||
{
|
{
|
||||||
#ifdef ENABLE_APPINDICATOR
|
trayIcon = createTrayObject(this);
|
||||||
trayIcon = new UnityIndicator(this);
|
|
||||||
#else
|
|
||||||
trayIcon = new QTrayIcon(this);
|
|
||||||
#endif
|
|
||||||
trayIcon->init();
|
trayIcon->init();
|
||||||
|
|
||||||
#ifndef Q_OS_WIN32
|
#ifndef Q_OS_WIN32
|
||||||
@@ -275,10 +283,8 @@ void MainWidget::receiveMessage(QString message)
|
|||||||
|
|
||||||
MainWidget::~MainWidget()
|
MainWidget::~MainWidget()
|
||||||
{
|
{
|
||||||
#ifndef ENABLE_KDE_NOTIFIER
|
|
||||||
if(trayIcon) {
|
if(trayIcon) {
|
||||||
trayIcon->hide();
|
trayIcon->hide();
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
delete db;
|
delete db;
|
||||||
}
|
}
|
||||||
|
@@ -57,6 +57,7 @@ private:
|
|||||||
void connectSignals();
|
void connectSignals();
|
||||||
void createTrayIcon();
|
void createTrayIcon();
|
||||||
void checkSettings();
|
void checkSettings();
|
||||||
|
TrayIndicator *createTrayObject(QWidget *parent);
|
||||||
|
|
||||||
bool first_run;
|
bool first_run;
|
||||||
|
|
||||||
|
94
src/indicator/kdenotifiertray.cpp
Normal file
94
src/indicator/kdenotifiertray.cpp
Normal file
@@ -0,0 +1,94 @@
|
|||||||
|
/*
|
||||||
|
* QCMA: Cross-platform content manager assistant for the PS Vita
|
||||||
|
*
|
||||||
|
* Copyright (C) 2014 Codestation
|
||||||
|
*
|
||||||
|
* This program is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "kdenotifiertray.h"
|
||||||
|
#include <kmenu.h>
|
||||||
|
|
||||||
|
KDENotifierTray::KDENotifierTray(QWidget *parent)
|
||||||
|
: TrayIndicator(parent)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
void KDENotifierTray::init()
|
||||||
|
{
|
||||||
|
options = new QAction(tr("Settings"), this);
|
||||||
|
reload = new QAction(tr("Refresh database"), this);
|
||||||
|
backup = new QAction(tr("Backup Manager"), this);
|
||||||
|
about = new QAction(tr("About QCMA"), this);
|
||||||
|
about_qt = new QAction(tr("About Qt"), this);
|
||||||
|
quit = new QAction(tr("Quit"), this);
|
||||||
|
|
||||||
|
connect(options, SIGNAL(triggered()), this, SIGNAL(openConfig()));
|
||||||
|
connect(backup, SIGNAL(triggered()), this, SIGNAL(openManager()));
|
||||||
|
connect(reload, SIGNAL(triggered()), this, SIGNAL(refreshDatabase()));
|
||||||
|
connect(about, SIGNAL(triggered()), this, SIGNAL(showAboutDialog()));
|
||||||
|
connect(about_qt, SIGNAL(triggered()), this, SIGNAL(showAboutQt()));
|
||||||
|
connect(quit, SIGNAL(triggered()), this, SIGNAL(stopServer()));
|
||||||
|
|
||||||
|
KMenu *tray_icon_menu = new KMenu(this);
|
||||||
|
|
||||||
|
tray_icon_menu->addAction(options);
|
||||||
|
tray_icon_menu->addAction(reload);
|
||||||
|
tray_icon_menu->addAction(backup);
|
||||||
|
tray_icon_menu->addSeparator();
|
||||||
|
tray_icon_menu->addAction(about);
|
||||||
|
tray_icon_menu->addAction(about_qt);
|
||||||
|
tray_icon_menu->addSeparator();
|
||||||
|
tray_icon_menu->addAction(quit);
|
||||||
|
|
||||||
|
m_notifier_item = new KDENotifier("QcmaNotifier", this);
|
||||||
|
m_notifier_item->setContextMenu(tray_icon_menu);
|
||||||
|
m_notifier_item->setTitle("Qcma");
|
||||||
|
m_notifier_item->setCategory(KStatusNotifierItem::ApplicationStatus);
|
||||||
|
m_notifier_item->setIconByPixmap(QIcon(":/main/resources/images/tray/qcma_off.png"));
|
||||||
|
m_notifier_item->setStatus(KStatusNotifierItem::Active);
|
||||||
|
m_notifier_item->setToolTipTitle(tr("Qcma status"));
|
||||||
|
m_notifier_item->setToolTipIconByPixmap(QIcon(":/main/resources/images/qcma.png"));
|
||||||
|
m_notifier_item->setToolTipSubTitle(tr("Disconnected"));
|
||||||
|
m_notifier_item->setStandardActionsEnabled(false);
|
||||||
|
}
|
||||||
|
|
||||||
|
void KDENotifierTray::showMessage(const QString &title, const QString &message)
|
||||||
|
{
|
||||||
|
m_notifier_item->showMessage(title, message, "dialog-information", 3000);
|
||||||
|
}
|
||||||
|
|
||||||
|
bool KDENotifierTray::isVisible()
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
void KDENotifierTray::setIcon(const QString &icon)
|
||||||
|
{
|
||||||
|
m_notifier_item->setIconByPixmap(QIcon(":/main/resources/images/tray/" + icon));
|
||||||
|
}
|
||||||
|
|
||||||
|
void KDENotifierTray::show()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
void KDENotifierTray::hide()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
// exported library function
|
||||||
|
TrayIndicator *createTrayIndicator(QWidget *parent)
|
||||||
|
{
|
||||||
|
return new KDENotifierTray(parent);
|
||||||
|
}
|
@@ -17,38 +17,40 @@
|
|||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
#ifndef KDENOTIFIERTRAY_H
|
||||||
|
#define KDENOTIFIERTRAY_H
|
||||||
|
|
||||||
#include "trayindicator.h"
|
#include "trayindicator.h"
|
||||||
|
#include "kdenotifier.h"
|
||||||
|
|
||||||
#undef signals
|
class QAction;
|
||||||
extern "C" {
|
class QSystemTrayIcon;
|
||||||
#include <libnotify/notify.h>
|
|
||||||
}
|
|
||||||
#define signals public
|
|
||||||
|
|
||||||
|
class KDENotifierTray : public TrayIndicator
|
||||||
TrayIndicator::TrayIndicator(QWidget *parent)
|
|
||||||
: QWidget(parent)
|
|
||||||
{
|
{
|
||||||
#ifdef Q_OS_LINUX
|
Q_OBJECT
|
||||||
notify_init("qcma");
|
public:
|
||||||
#endif
|
explicit KDENotifierTray(QWidget *parent = 0);
|
||||||
}
|
void init();
|
||||||
|
void setIcon(const QString &icon);
|
||||||
|
bool isVisible();
|
||||||
|
void show();
|
||||||
|
void hide();
|
||||||
|
void showMessage(const QString &title, const QString &message);
|
||||||
|
|
||||||
TrayIndicator::~TrayIndicator()
|
private:
|
||||||
{
|
//system tray
|
||||||
#ifdef Q_OS_LINUX
|
QAction *quit;
|
||||||
notify_uninit();
|
QAction *reload;
|
||||||
#endif
|
QAction *options;
|
||||||
}
|
QAction *backup;
|
||||||
|
QAction *about;
|
||||||
|
QAction *about_qt;
|
||||||
|
|
||||||
void TrayIndicator::showMessage(const QString &title, const QString &message)
|
KDENotifier *m_notifier_item;
|
||||||
{
|
|
||||||
#ifdef Q_OS_LINUX
|
public slots:
|
||||||
NotifyNotification *notif = notify_notification_new(qPrintable(title), qPrintable(message), "dialog-information");
|
|
||||||
notify_notification_show(notif, NULL);
|
};
|
||||||
g_object_unref(G_OBJECT(notif));
|
|
||||||
#else
|
#endif // KDENOTIFIERTRAY_H
|
||||||
Q_UNUSED(title);
|
|
||||||
Q_UNUSED(message);
|
|
||||||
#endif
|
|
||||||
}
|
|
@@ -19,18 +19,31 @@
|
|||||||
|
|
||||||
#include "qtrayicon.h"
|
#include "qtrayicon.h"
|
||||||
|
|
||||||
#include <QSystemTrayIcon>
|
|
||||||
|
|
||||||
#ifdef ENABLE_KDE_NOTIFIER
|
|
||||||
#include <kmenu.h>
|
|
||||||
#else
|
|
||||||
#include <QIcon>
|
#include <QIcon>
|
||||||
#include <QMenu>
|
#include <QMenu>
|
||||||
|
#include <QSystemTrayIcon>
|
||||||
|
|
||||||
|
#ifdef Q_OS_LINUX
|
||||||
|
#undef signals
|
||||||
|
extern "C" {
|
||||||
|
#include <libnotify/notify.h>
|
||||||
|
}
|
||||||
|
#define signals public
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
QTrayIcon::QTrayIcon(QWidget *parent)
|
QTrayIcon::QTrayIcon(QWidget *parent)
|
||||||
: TrayIndicator(parent)
|
: TrayIndicator(parent)
|
||||||
{
|
{
|
||||||
|
#ifdef Q_OS_LINUX
|
||||||
|
notify_init("qcma");
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
QTrayIcon::~QTrayIcon()
|
||||||
|
{
|
||||||
|
#ifdef Q_OS_LINUX
|
||||||
|
notify_uninit();
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
void QTrayIcon::init()
|
void QTrayIcon::init()
|
||||||
@@ -49,11 +62,7 @@ void QTrayIcon::init()
|
|||||||
connect(about_qt, SIGNAL(triggered()), this, SIGNAL(showAboutQt()));
|
connect(about_qt, SIGNAL(triggered()), this, SIGNAL(showAboutQt()));
|
||||||
connect(quit, SIGNAL(triggered()), this, SIGNAL(stopServer()));
|
connect(quit, SIGNAL(triggered()), this, SIGNAL(stopServer()));
|
||||||
|
|
||||||
#ifndef ENABLE_KDE_NOTIFIER
|
|
||||||
QMenu *tray_icon_menu = new QMenu(this);
|
QMenu *tray_icon_menu = new QMenu(this);
|
||||||
#else
|
|
||||||
KMenu *tray_icon_menu = new KMenu(this);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
tray_icon_menu->addAction(options);
|
tray_icon_menu->addAction(options);
|
||||||
tray_icon_menu->addAction(reload);
|
tray_icon_menu->addAction(reload);
|
||||||
@@ -64,37 +73,25 @@ void QTrayIcon::init()
|
|||||||
tray_icon_menu->addSeparator();
|
tray_icon_menu->addSeparator();
|
||||||
tray_icon_menu->addAction(quit);
|
tray_icon_menu->addAction(quit);
|
||||||
|
|
||||||
#ifndef ENABLE_KDE_NOTIFIER
|
|
||||||
m_tray_icon = new QSystemTrayIcon(this);
|
m_tray_icon = new QSystemTrayIcon(this);
|
||||||
m_tray_icon->setContextMenu(tray_icon_menu);
|
m_tray_icon->setContextMenu(tray_icon_menu);
|
||||||
#else
|
|
||||||
m_notifier_item = new KDENotifier("QcmaNotifier", this);
|
|
||||||
m_notifier_item->setContextMenu(tray_icon_menu);
|
|
||||||
m_notifier_item->setTitle("Qcma");
|
|
||||||
m_notifier_item->setCategory(KStatusNotifierItem::ApplicationStatus);
|
|
||||||
m_notifier_item->setIconByPixmap(QIcon(":/main/resources/images/tray/qcma_off.png"));
|
|
||||||
m_notifier_item->setStatus(KStatusNotifierItem::Active);
|
|
||||||
m_notifier_item->setToolTipTitle(tr("Qcma status"));
|
|
||||||
m_notifier_item->setToolTipIconByPixmap(QIcon(":/main/resources/images/qcma.png"));
|
|
||||||
m_notifier_item->setToolTipSubTitle(tr("Disconnected"));
|
|
||||||
m_notifier_item->setStandardActionsEnabled(false);
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifndef Q_OS_LINUX
|
|
||||||
void QTrayIcon::showMessage(const QString &title, const QString &message)
|
void QTrayIcon::showMessage(const QString &title, const QString &message)
|
||||||
{
|
{
|
||||||
|
#ifdef Q_OS_LINUX
|
||||||
|
NotifyNotification *notif = notify_notification_new(qPrintable(title), qPrintable(message), "dialog-information");
|
||||||
|
notify_notification_show(notif, NULL);
|
||||||
|
g_object_unref(G_OBJECT(notif));
|
||||||
|
#else
|
||||||
m_tray_icon->showMessage(title, message);
|
m_tray_icon->showMessage(title, message);
|
||||||
}
|
|
||||||
#endif
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
bool QTrayIcon::isVisible()
|
bool QTrayIcon::isVisible()
|
||||||
{
|
{
|
||||||
#ifndef ENABLE_KDE_NOTIFIER
|
|
||||||
return m_tray_icon->isVisible();
|
return m_tray_icon->isVisible();
|
||||||
#else
|
|
||||||
return true;
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void QTrayIcon::setIcon(const QString &icon)
|
void QTrayIcon::setIcon(const QString &icon)
|
||||||
@@ -104,14 +101,16 @@ void QTrayIcon::setIcon(const QString &icon)
|
|||||||
|
|
||||||
void QTrayIcon::show()
|
void QTrayIcon::show()
|
||||||
{
|
{
|
||||||
#ifndef ENABLE_KDE_NOTIFIER
|
|
||||||
m_tray_icon->show();
|
m_tray_icon->show();
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void QTrayIcon::hide()
|
void QTrayIcon::hide()
|
||||||
{
|
{
|
||||||
#ifndef ENABLE_KDE_NOTIFIER
|
|
||||||
m_tray_icon->hide();
|
m_tray_icon->hide();
|
||||||
#endif
|
}
|
||||||
|
|
||||||
|
// exported library function
|
||||||
|
TrayIndicator *createTrayIndicator(QWidget *parent)
|
||||||
|
{
|
||||||
|
return new QTrayIcon(parent);
|
||||||
}
|
}
|
||||||
|
@@ -30,11 +30,13 @@ class QTrayIcon : public TrayIndicator
|
|||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
public:
|
public:
|
||||||
explicit QTrayIcon(QWidget *parent = 0);
|
explicit QTrayIcon(QWidget *parent = 0);
|
||||||
|
~QTrayIcon();
|
||||||
void init();
|
void init();
|
||||||
void setIcon(const QString &icon);
|
void setIcon(const QString &icon);
|
||||||
bool isVisible();
|
bool isVisible();
|
||||||
void show();
|
void show();
|
||||||
void hide();
|
void hide();
|
||||||
|
void showMessage(const QString &title, const QString &message);
|
||||||
|
|
||||||
#ifndef Q_OS_LINUX
|
#ifndef Q_OS_LINUX
|
||||||
void showMessage(const QString &title, const QString &message);
|
void showMessage(const QString &title, const QString &message);
|
||||||
|
@@ -1,8 +1,3 @@
|
|||||||
#ifndef TRAYINDICATOR_H
|
|
||||||
#define TRAYINDICATOR_H
|
|
||||||
|
|
||||||
#include "trayindicator_global.h"
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* QCMA: Cross-platform content manager assistant for the PS Vita
|
* QCMA: Cross-platform content manager assistant for the PS Vita
|
||||||
*
|
*
|
||||||
@@ -22,23 +17,34 @@
|
|||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
#ifndef TRAYINDICATOR_H
|
||||||
|
#define TRAYINDICATOR_H
|
||||||
|
|
||||||
#include <QString>
|
#include <QString>
|
||||||
#include <QWidget>
|
#include <QWidget>
|
||||||
|
|
||||||
class TRAYINDICATORSHARED_EXPORT TrayIndicator : public QWidget
|
#include "trayindicator_global.h"
|
||||||
|
|
||||||
|
#if QT_VERSION < QT_VERSION_CHECK(5, 0, 0)
|
||||||
|
// in Qt4 signals are protected
|
||||||
|
#undef signals
|
||||||
|
#define signals public
|
||||||
|
#endif
|
||||||
|
|
||||||
|
class TrayIndicator : public QWidget
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
public:
|
public:
|
||||||
virtual ~TrayIndicator();
|
virtual ~TrayIndicator() {}
|
||||||
virtual void init() = 0;
|
virtual void init() = 0;
|
||||||
virtual bool isVisible() = 0;
|
virtual bool isVisible() = 0;
|
||||||
virtual void setIcon(const QString &icon) = 0;
|
virtual void setIcon(const QString &icon) = 0;
|
||||||
virtual void showMessage(const QString &title, const QString &message);
|
virtual void showMessage(const QString &title, const QString &message) = 0;
|
||||||
virtual void show() = 0;
|
virtual void show() = 0;
|
||||||
virtual void hide() = 0;
|
virtual void hide() = 0;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
TrayIndicator(QWidget *parent = 0);
|
TrayIndicator(QWidget *parent = 0) : QWidget(parent) {}
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void openConfig();
|
void openConfig();
|
||||||
@@ -50,4 +56,7 @@ signals:
|
|||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
typedef TrayIndicator *(*TrayFunctionPointer)(QWidget *parent);
|
||||||
|
extern "C" TRAYINDICATORSHARED_EXPORT TrayIndicator *createTrayIndicator(QWidget *parent = 0);
|
||||||
|
|
||||||
#endif // TRAYINDICATOR_H
|
#endif // TRAYINDICATOR_H
|
||||||
|
1
src/indicator/trayindicator_import.h
Symbolic link
1
src/indicator/trayindicator_import.h
Symbolic link
@@ -0,0 +1 @@
|
|||||||
|
trayindicator.h
|
@@ -28,10 +28,13 @@
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include <QDir>
|
#include <QDir>
|
||||||
|
#include <QVector>
|
||||||
|
|
||||||
|
#undef signals
|
||||||
|
|
||||||
extern "C" {
|
extern "C" {
|
||||||
|
|
||||||
#include <gtk/gtk.h>
|
#include <libnotify/notify.h>
|
||||||
|
|
||||||
void optionsIndicator(GtkMenu *menu, gpointer data);
|
void optionsIndicator(GtkMenu *menu, gpointer data);
|
||||||
void reloadIndicator(GtkMenu *menu, gpointer data);
|
void reloadIndicator(GtkMenu *menu, gpointer data);
|
||||||
@@ -39,16 +42,19 @@ void backupIndicator(GtkMenu *menu, gpointer data);
|
|||||||
void aboutIndicator(GtkMenu *menu, gpointer data);
|
void aboutIndicator(GtkMenu *menu, gpointer data);
|
||||||
void aboutQtIndicator(GtkMenu *menu, gpointer data);
|
void aboutQtIndicator(GtkMenu *menu, gpointer data);
|
||||||
void quitIndicator(GtkMenu *menu, gpointer data);
|
void quitIndicator(GtkMenu *menu, gpointer data);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#define signals public
|
||||||
|
|
||||||
UnityIndicator::UnityIndicator(QWidget *parent) :
|
UnityIndicator::UnityIndicator(QWidget *parent) :
|
||||||
TrayIndicator(parent)
|
TrayIndicator(parent)
|
||||||
{
|
{
|
||||||
|
notify_init("qcma");
|
||||||
}
|
}
|
||||||
|
|
||||||
UnityIndicator::~UnityIndicator()
|
UnityIndicator::~UnityIndicator()
|
||||||
{
|
{
|
||||||
|
notify_uninit();
|
||||||
for(QVector<QPair<gpointer, gulong> >::iterator it = m_handlers.begin(); it != m_handlers.end(); ++it)
|
for(QVector<QPair<gpointer, gulong> >::iterator it = m_handlers.begin(); it != m_handlers.end(); ++it)
|
||||||
{
|
{
|
||||||
g_signal_handler_disconnect(it->first, it->second);
|
g_signal_handler_disconnect(it->first, it->second);
|
||||||
@@ -142,12 +148,16 @@ void UnityIndicator::init()
|
|||||||
APP_INDICATOR_CATEGORY_APPLICATION_STATUS
|
APP_INDICATOR_CATEGORY_APPLICATION_STATUS
|
||||||
);
|
);
|
||||||
|
|
||||||
QString icon_name = QStandardPaths::locate(QStandardPaths::GenericDataLocation, "icons/hicolor/64x64/tray/qcma_on.png");
|
QString icon_path;
|
||||||
if(!icon_name.isEmpty())
|
QString icon_name = "share/icons/hicolor/64x64/tray/qcma_on.png";
|
||||||
{
|
|
||||||
QString icon_path = QFileInfo(icon_name).absolutePath();
|
if(QFile("/usr/" + icon_name).exists())
|
||||||
|
icon_path = QFileInfo("/usr/" + icon_name).absolutePath();
|
||||||
|
else if(QFile("/usr/local" + icon_name).exists())
|
||||||
|
icon_path = QFileInfo("/usr/" + icon_name).absolutePath();
|
||||||
|
|
||||||
|
if(!icon_path.isEmpty())
|
||||||
app_indicator_set_icon_theme_path(m_indicator, qPrintable(icon_path));
|
app_indicator_set_icon_theme_path(m_indicator, qPrintable(icon_path));
|
||||||
}
|
|
||||||
|
|
||||||
app_indicator_set_status(m_indicator, APP_INDICATOR_STATUS_ACTIVE);
|
app_indicator_set_status(m_indicator, APP_INDICATOR_STATUS_ACTIVE);
|
||||||
app_indicator_set_menu(m_indicator, GTK_MENU(menu));
|
app_indicator_set_menu(m_indicator, GTK_MENU(menu));
|
||||||
@@ -170,3 +180,16 @@ void UnityIndicator::show()
|
|||||||
void UnityIndicator::hide()
|
void UnityIndicator::hide()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void UnityIndicator::showMessage(const QString &title, const QString &message)
|
||||||
|
{
|
||||||
|
NotifyNotification *notif = notify_notification_new(qPrintable(title), qPrintable(message), "dialog-information");
|
||||||
|
notify_notification_show(notif, NULL);
|
||||||
|
g_object_unref(G_OBJECT(notif));
|
||||||
|
}
|
||||||
|
|
||||||
|
// exported library function
|
||||||
|
TrayIndicator *createTrayIndicator(QWidget *parent)
|
||||||
|
{
|
||||||
|
return new UnityIndicator(parent);
|
||||||
|
}
|
||||||
|
@@ -1,6 +1,3 @@
|
|||||||
#ifndef UNITYINDICATOR_H
|
|
||||||
#define UNITYINDICATOR_H
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* QCMA: Cross-platform content manager assistant for the PS Vita
|
* QCMA: Cross-platform content manager assistant for the PS Vita
|
||||||
*
|
*
|
||||||
@@ -20,16 +17,28 @@
|
|||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "indicator/trayindicator.h"
|
#ifndef UNITYINDICATOR_H
|
||||||
|
#define UNITYINDICATOR_H
|
||||||
|
|
||||||
#undef signals
|
#include "trayindicator.h"
|
||||||
extern "C" {
|
|
||||||
#include <libappindicator/app-indicator.h>
|
|
||||||
}
|
|
||||||
#define signals public
|
|
||||||
|
|
||||||
#include <QVector>
|
#include <QVector>
|
||||||
|
|
||||||
|
#undef signals
|
||||||
|
|
||||||
|
extern "C" {
|
||||||
|
#include <libappindicator/app-indicator.h>
|
||||||
|
#include <gtk/gtk.h>
|
||||||
|
|
||||||
|
void optionsIndicator(GtkMenu *menu, gpointer data);
|
||||||
|
void reloadIndicator(GtkMenu *menu, gpointer data);
|
||||||
|
void backupIndicator(GtkMenu *menu, gpointer data);
|
||||||
|
void aboutIndicator(GtkMenu *menu, gpointer data);
|
||||||
|
void aboutQtIndicator(GtkMenu *menu, gpointer data);
|
||||||
|
void quitIndicator(GtkMenu *menu, gpointer data);
|
||||||
|
}
|
||||||
|
|
||||||
|
#define signals public
|
||||||
|
|
||||||
class UnityIndicator : public TrayIndicator
|
class UnityIndicator : public TrayIndicator
|
||||||
{
|
{
|
||||||
@@ -42,6 +51,7 @@ public:
|
|||||||
bool isVisible();
|
bool isVisible();
|
||||||
void show();
|
void show();
|
||||||
void hide();
|
void hide();
|
||||||
|
void showMessage(const QString &title, const QString &message);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
AppIndicator *m_indicator;
|
AppIndicator *m_indicator;
|
||||||
|
Reference in New Issue
Block a user