diff --git a/ChangeLog b/ChangeLog index 94cea78..95764c2 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,12 @@ +qcma (0.3.4) unstable; urgency=low + + * Fixed compatibility with FW 3.30. + * Added setting to put a custom protocol version to avoid updates. + * Added notifications via libnotify on Linux. + * Added AppIndicator support for GNOME 3 and Unity. + + -- codestation Thu, 28 Jun 2014 00:00:00 -0000 + qcma (0.3.3) unstable; urgency=low * Fixed wrong file sizes under windows. diff --git a/debian/control b/debian/control index 2c4480b..f24e041 100644 --- a/debian/control +++ b/debian/control @@ -13,6 +13,7 @@ Build-Depends: qtbase5-dev, qttools5-dev-tools, qt5-default, + libnotify-dev, pkg-config, vitamtp-dev diff --git a/debian/qcma.install b/debian/qcma.install index 1aabfc8..f65f133 100644 --- a/debian/qcma.install +++ b/debian/qcma.install @@ -1,3 +1,5 @@ usr/bin/qcma resources/qcma.desktop usr/share/applications/qcma resources/images/qcma.png usr/share/icons/hicolor/64x64/apps +resources/images/qcma_on.png usr/share/icons/hicolor/64x64/actions +resources/images/qcma_off.png usr/share/icons/hicolor/64x64/actions diff --git a/qcma_common.pri b/qcma_common.pri index f5dde8b..5b3c671 100644 --- a/qcma_common.pri +++ b/qcma_common.pri @@ -6,7 +6,7 @@ QT += core network sql -VERSION = 0.3.3 +VERSION = 0.3.4 TEMPLATE = app diff --git a/qcma_gui.pro b/qcma_gui.pro index ddd0328..c1da502 100644 --- a/qcma_gui.pro +++ b/qcma_gui.pro @@ -10,6 +10,8 @@ SOURCES += \ src/gui/singleapplication.cpp \ src/gui/clientmanager.cpp \ src/gui/filterlineedit.cpp \ + src/indicator/trayindicator.cpp \ + src/indicator/qtrayicon.cpp \ # forms src/forms/backupitem.cpp \ src/forms/backupmanagerform.cpp \ @@ -23,6 +25,9 @@ HEADERS += \ src/gui/singleapplication.h \ src/gui/clientmanager.h \ src/gui/filterlineedit.h \ + src/indicator/trayindicator_global.h \ + src/indicator/trayindicator.h \ + src/indicator/qtrayicon.h \ # forms src/forms/backupitem.h \ src/forms/backupmanagerform.h \ @@ -50,9 +55,20 @@ unix:!macx { icon64.path = $$DATADIR/icons/hicolor/64x64/apps 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 - INSTALLS += target desktop icon64 + INSTALLS += target desktop icon64 actions64 # KDE support ENABLE_KDE { @@ -68,6 +84,8 @@ unix:!macx { unix:!macx { +PKGCONFIG += libnotify + QT += dbus # Create the introspection XML diff --git a/qcma_indicator.pro b/qcma_indicator.pro new file mode 100644 index 0000000..6364125 --- /dev/null +++ b/qcma_indicator.pro @@ -0,0 +1,21 @@ +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 +} diff --git a/qcmares.qrc b/qcmares.qrc index 3117dde..39f87a8 100644 --- a/qcmares.qrc +++ b/qcmares.qrc @@ -1,11 +1,11 @@ resources/xml/psp2-updatelist.xml - resources/images/psv_icon.png - resources/images/psv_icon_16.png + resources/images/tray/qcma_on.png + resources/images/tray/qcma_on_16.png resources/images/qcma.png resources/images/edit-clear-locationbar-rtl.png - resources/images/psv_icon_dc.png - resources/images/psv_icon_16_dc.png + resources/images/tray/qcma_off.png + resources/images/tray/qcma_off_16.png diff --git a/resources/images/qcma_off.png b/resources/images/qcma_off.png new file mode 100644 index 0000000..ff2525f Binary files /dev/null and b/resources/images/qcma_off.png differ diff --git a/resources/images/qcma_on.png b/resources/images/qcma_on.png new file mode 100644 index 0000000..ce36ce5 Binary files /dev/null and b/resources/images/qcma_on.png differ diff --git a/resources/images/psv_icon_dc.png b/resources/images/tray/qcma_off.png similarity index 100% rename from resources/images/psv_icon_dc.png rename to resources/images/tray/qcma_off.png diff --git a/resources/images/psv_icon_16_dc.png b/resources/images/tray/qcma_off_16.png similarity index 100% rename from resources/images/psv_icon_16_dc.png rename to resources/images/tray/qcma_off_16.png diff --git a/resources/images/psv_icon.png b/resources/images/tray/qcma_on.png similarity index 100% rename from resources/images/psv_icon.png rename to resources/images/tray/qcma_on.png diff --git a/resources/images/psv_icon_16.png b/resources/images/tray/qcma_on_16.png similarity index 100% rename from resources/images/psv_icon_16.png rename to resources/images/tray/qcma_on_16.png diff --git a/rpmbuild/qcma-fedora.spec b/rpmbuild/qcma-fedora.spec index b1ad9b7..377fa04 100644 --- a/rpmbuild/qcma-fedora.spec +++ b/rpmbuild/qcma-fedora.spec @@ -6,7 +6,7 @@ Name: qcma Summary: PSVita Content Manager Assistant License: GPL-3.0 Release: 1 -Version: 0.3.3 +Version: 0.3.4 URL: https://github.com/codestation/qcma Source: https://github.com/codestation/qcma.git Group: Productivity/File utilities diff --git a/rpmbuild/qcma-openSUSE.spec b/rpmbuild/qcma-openSUSE.spec index ea766af..eb06cb2 100644 --- a/rpmbuild/qcma-openSUSE.spec +++ b/rpmbuild/qcma-openSUSE.spec @@ -6,7 +6,7 @@ Name: qcma Summary: PSVita Content Manager Assistant License: GPL-3.0 Release: 1 -Version: 0.3.3 +Version: 0.3.4 URL: https://github.com/codestation/qcma Source: https://github.com/codestation/qcma.git Group: Productivity/File utilities diff --git a/src/capability.cpp b/src/capability.cpp index 673a3ed..d409370 100644 --- a/src/capability.cpp +++ b/src/capability.cpp @@ -40,7 +40,7 @@ bool DeviceCapability::exchangeInfo(vita_device_t *device) } QString hostname = QHostInfo::localHostName(); - const initiator_info_t *pc_info = VitaMTP_Data_Initiator_New(hostname.toUtf8().data(), vita_info.protocolVersion); + const initiator_info_t *pc_info = VitaMTP_Data_Initiator_New(hostname.toUtf8().data(), VITAMTP_PROTOCOL_MAX_VERSION); // Next, we send the client's (this program) info (discard the const here) if(VitaMTP_SendInitiatorInfo(device, (initiator_info_t *)pc_info) != PTP_RC_OK) { diff --git a/src/forms/backupmanagerform.ui b/src/forms/backupmanagerform.ui index 7a6c8a4..20ef02c 100644 --- a/src/forms/backupmanagerform.ui +++ b/src/forms/backupmanagerform.ui @@ -15,305 +15,116 @@ - - - true - - - 0 - - - - Backup Manager - - - - - - 1 + + + + + + + Online ID / Username - - - - - - - - - Online ID / Username - - - - - - - - - - - - QFormLayout::AllNonFixedFieldsGrow - - - - - Backup Type - - - 2 - - - - - - - - PS Vita Games - - - - - PSP Games - - - - - PSM Games - - - - - PSOne Games - - - - - PSP Savedatas - - - - - Backups - - - - - - - - - - - - - - Backup disk usage - - - - - - - Qt::Horizontal - - - - 40 - 20 - - - - - - - - FilterLineEdit { color:gray; font-style:italic; } - - - Filter - - - - + + - - - - false - - - Download List - - + + + + + QFormLayout::AllNonFixedFieldsGrow + - + + + Backup Type + + + 2 + + + + + - - - - - Console - - - - - - - - PS Vita - - - - - PSP - - - - - Other - - - - - - - - Content - - - - - - - - Games - - - - - Demos - - - - - DLC - - - - - Other - - - - - - - - Status - - - - - - - - New - - - - - Downloading - - - - - Completed - - - - - Paused - - - - - + + PS Vita Games + - - - - - Username: - - - - - - - - - - Password: - - - - - - - QLineEdit::Password - - - - - - - Refresh - - - - + + PSP Games + - + + PSM Games + - - - - - Filter: - - - - - - - - - - Resume All - - - - - - - Pause All - - - - + + PSOne Games + - + + + PSP Savedatas + + + + + Backups + + + - + + + + + + + 1 + + + + + + + + Backup disk usage + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + FilterLineEdit { color:gray; font-style:italic; } + + + Filter + + + + + diff --git a/src/forms/configwidget.cpp b/src/forms/configwidget.cpp index 1a626aa..1ae0c46 100644 --- a/src/forms/configwidget.cpp +++ b/src/forms/configwidget.cpp @@ -62,6 +62,7 @@ void ConfigWidget::connectSignals() connect(mapper, SIGNAL(mapped(int)), this, SLOT(browseBtnPressed(int))); connect(ui->buttonBox, SIGNAL(accepted()), this, SLOT(accept())); connect(ui->buttonBox, SIGNAL(rejected()), this, SLOT(reject())); + connect(ui->resetProtocolButton, SIGNAL(clicked()), this, SLOT(resetButtonPressed())); } void ConfigWidget::setDefaultData() @@ -98,6 +99,8 @@ void ConfigWidget::setDefaultData() ui->photoSkipCheck->setChecked(settings.value("photoSkip", false).toBool()); ui->videoSkipCheck->setChecked(settings.value("videoSkip", false).toBool()); ui->musicSkipCheck->setChecked(settings.value("musicSkip", false).toBool()); + + ui->protocolEdit->setText(settings.value("protocolVersion", VITAMTP_PROTOCOL_MAX_VERSION).toString()); } ConfigWidget::~ConfigWidget() @@ -105,6 +108,11 @@ ConfigWidget::~ConfigWidget() delete ui; } +void ConfigWidget::resetButtonPressed() +{ + ui->protocolEdit->setText(QString::number(VITAMTP_PROTOCOL_MAX_VERSION)); +} + void ConfigWidget::browseBtnPressed(int btn) { QString msg; @@ -179,6 +187,7 @@ void ConfigWidget::accept() settings.setValue("photoSkip", ui->photoSkipCheck->isChecked()); settings.setValue("videoSkip", ui->videoSkipCheck->isChecked()); settings.setValue("musicSkip", ui->musicSkipCheck->isChecked()); + settings.setValue("protocolVersion", ui->protocolEdit->text().toLongLong()); settings.sync(); done(Accepted); diff --git a/src/forms/configwidget.h b/src/forms/configwidget.h index eeda29e..e242ae4 100644 --- a/src/forms/configwidget.h +++ b/src/forms/configwidget.h @@ -48,6 +48,7 @@ private: private slots: void browseBtnPressed(int from); + void resetButtonPressed(); void accept(); }; diff --git a/src/forms/configwidget.ui b/src/forms/configwidget.ui index f4b96e6..e46b33f 100644 --- a/src/forms/configwidget.ui +++ b/src/forms/configwidget.ui @@ -7,7 +7,7 @@ 0 0 520 - 450 + 439 @@ -19,7 +19,7 @@ - 0 + 1 @@ -211,28 +211,28 @@ + + + + - + + + Packages + + + + + - - - Packages - - + - - - - - - - - Browse... - - - - + + + Browse... + + @@ -299,6 +299,9 @@ + + QFormLayout::AllNonFixedFieldsGrow + @@ -346,6 +349,31 @@ + + + + + + CMA Protocol version + + + + + + + 9999999 + + + + + + + Reset to default + + + + + diff --git a/src/gui/main.cpp b/src/gui/main.cpp index 568512f..5fb41f9 100644 --- a/src/gui/main.cpp +++ b/src/gui/main.cpp @@ -104,7 +104,7 @@ int main(int argc, char *argv[]) qDebug("Starting main thread: 0x%016" PRIxPTR, (uintptr_t)QThread::currentThreadId()); // set the organization/application for QSettings to work properly - app.setOrganizationName("qcma"); + app.setOrganizationName("codestation"); app.setApplicationName("qcma"); //TODO: check if this is actually needed since we don't have a main window by default diff --git a/src/gui/mainwidget.cpp b/src/gui/mainwidget.cpp index 2ef825e..be3a3fa 100644 --- a/src/gui/mainwidget.cpp +++ b/src/gui/mainwidget.cpp @@ -28,22 +28,22 @@ #include "qlistdb.h" #include "sqlitedb.h" -#include +#ifdef ENABLE_APPINDICATOR +#include "indicator/unityindicator.h" +#else +#include "indicator/qtrayicon.h" +#endif + #include #include #include #include -#include #include #include #include #include #include -#ifdef ENABLE_KDE_NOTIFIER -#include -#endif - const QStringList MainWidget::path_list = QStringList() << "photoPath" << "musicPath" << "videoPath" << "appsPath" << "urlPath"; bool sleptOnce = false; @@ -115,12 +115,12 @@ void MainWidget::deviceDisconnect() { #ifndef ENABLE_KDE_NOTIFIER #ifndef Q_OS_WIN32 - trayIcon->setIcon(QIcon(":/main/resources/images/psv_icon_dc.png")); + trayIcon->setIcon("qcma_off.png"); #else - trayIcon->setIcon(QIcon(":/main/resources/images/psv_icon_16_dc.png")); + trayIcon->setIcon("qcma_off_16.png"); #endif #else - notifierItem->setIconByPixmap(QIcon(":/main/resources/images/psv_icon_dc.png")); + notifierItem->setIconByPixmap(QIcon(":/main/resources/images/tray/qcma_off.png")); #endif qDebug("Icon changed - disconnected"); setTrayTooltip(tr("Disconnected")); @@ -131,12 +131,12 @@ void MainWidget::deviceConnect(QString message) { #ifndef ENABLE_KDE_NOTIFIER #ifndef Q_OS_WIN32 - trayIcon->setIcon(QIcon(":/main/resources/images/psv_icon.png")); + trayIcon->setIcon("qcma_on.png"); #else - trayIcon->setIcon(QIcon(":/main/resources/images/psv_icon_16.png")); + trayIcon->setIcon("qcma_off_16.png"); #endif #else - notifierItem->setIconByPixmap(QIcon(":/main/resources/images/psv_icon.png")); + notifierItem->setIconByPixmap(QIcon(":/main/resources/images/tray/qcma_on.png")); #endif qDebug("Icon changed - connected"); setTrayTooltip(message); @@ -152,7 +152,7 @@ void MainWidget::prepareApplication(bool showSystray) db = new SQLiteDB(); } - configForm = new ConfigWidget(); + configForm = new ConfigWidget(this); backupForm = new BackupManagerForm(db, this); managerForm = new ClientManager(db, this); connectSignals(); @@ -234,56 +234,26 @@ void MainWidget::refreshDatabase() void MainWidget::createTrayIcon() { - 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("Abou&t Qt"), this); - quit = new QAction(tr("&Quit"), this); - - connect(options, SIGNAL(triggered()), this, SLOT(openConfig())); - connect(backup, SIGNAL(triggered()), this, SLOT(openManager())); - connect(reload, SIGNAL(triggered()), this, SLOT(refreshDatabase())); - connect(about, SIGNAL(triggered()), this, SLOT(showAboutDialog())); - connect(about_qt, SIGNAL(triggered()), this, SLOT(showAboutQt())); - connect(quit, SIGNAL(triggered()), this, SLOT(stopServer())); - -#ifndef ENABLE_KDE_NOTIFIER - QMenu *trayIconMenu = new QMenu(this); +#ifdef ENABLE_APPINDICATOR + trayIcon = new UnityIndicator(this); #else - KMenu *trayIconMenu = new KMenu(this); + trayIcon = new QTrayIcon(this); #endif + trayIcon->init(); - trayIconMenu->addAction(options); - trayIconMenu->addAction(reload); - trayIconMenu->addAction(backup); - trayIconMenu->addSeparator(); - trayIconMenu->addAction(about); - trayIconMenu->addAction(about_qt); - trayIconMenu->addSeparator(); - trayIconMenu->addAction(quit); - -#ifndef ENABLE_KDE_NOTIFIER - trayIcon = new QSystemTrayIcon(this); - trayIcon->setContextMenu(trayIconMenu); #ifndef Q_OS_WIN32 - trayIcon->setIcon(QIcon(":/main/resources/images/psv_icon_dc.png")); + trayIcon->setIcon("qcma_off.png"); #else - trayIcon->setIcon(QIcon(":/main/resources/images/psv_icon_16_dc.png")); + trayIcon->setIcon("qcma_off_16.png"); #endif trayIcon->show(); -#else - notifierItem = new KDENotifier("QcmaNotifier", this); - notifierItem->setContextMenu(trayIconMenu); - notifierItem->setTitle("Qcma"); - notifierItem->setCategory(KStatusNotifierItem::ApplicationStatus); - notifierItem->setIconByPixmap(QIcon(":/main/resources/images/psv_icon_dc.png")); - notifierItem->setStatus(KStatusNotifierItem::Active); - notifierItem->setToolTipTitle(tr("Qcma status")); - notifierItem->setToolTipIconByPixmap(QIcon(":/main/resources/images/qcma.png")); - notifierItem->setToolTipSubTitle(tr("Disconnected")); - notifierItem->setStandardActionsEnabled(false); -#endif + + connect(trayIcon, SIGNAL(openConfig()), this, SLOT(openConfig())); + connect(trayIcon, SIGNAL(openManager()), this, SLOT(openManager())); + connect(trayIcon, SIGNAL(refreshDatabase()), this, SLOT(refreshDatabase())); + connect(trayIcon, SIGNAL(showAboutDialog()), this, SLOT(showAboutDialog())); + connect(trayIcon, SIGNAL(showAboutQt()), this, SLOT(showAboutQt())); + connect(trayIcon, SIGNAL(stopServer()), this, SLOT(stopServer())); connect(managerForm, SIGNAL(deviceConnected(QString)), this, SLOT(deviceConnect(QString))); connect(managerForm, SIGNAL(deviceDisconnected()), this, SLOT(deviceDisconnect())); @@ -299,14 +269,8 @@ void MainWidget::receiveMessage(QString message) sleptOnce = true; } -#ifndef ENABLE_KDE_NOTIFIER - if(trayIcon->isVisible()) { + if(trayIcon->isVisible()) trayIcon->showMessage(tr("Information"), message); - } -#else - notifierItem->showMessage(tr("Qcma - Information"), message, "dialog-information", 3000); -#endif - } MainWidget::~MainWidget() diff --git a/src/gui/mainwidget.h b/src/gui/mainwidget.h index a0be5b9..22c3ecf 100644 --- a/src/gui/mainwidget.h +++ b/src/gui/mainwidget.h @@ -40,6 +40,8 @@ #include +class TrayIndicator; + class MainWidget : public QWidget { Q_OBJECT @@ -66,23 +68,11 @@ private: ClientManager *managerForm; BackupManagerForm *backupForm; - //system tray - QAction *quit; - QAction *reload; - QAction *options; - QAction *backup; - QAction *about; - QAction *about_qt; - #ifdef Q_OS_LINUX QDBusConnection dbus_conn; #endif -#ifndef ENABLE_KDE_NOTIFIER - QSystemTrayIcon *trayIcon; -#else - KDENotifier *notifierItem; -#endif + TrayIndicator *trayIcon; const static QStringList path_list; diff --git a/src/indicator/qtrayicon.cpp b/src/indicator/qtrayicon.cpp new file mode 100644 index 0000000..020e5ed --- /dev/null +++ b/src/indicator/qtrayicon.cpp @@ -0,0 +1,117 @@ +/* + * 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 . + */ + +#include "qtrayicon.h" + +#include + +#ifdef ENABLE_KDE_NOTIFIER +#include +#else +#include +#include +#endif + +QTrayIcon::QTrayIcon(QWidget *parent) + : TrayIndicator(parent) +{ +} + +void QTrayIcon::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())); + +#ifndef ENABLE_KDE_NOTIFIER + 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(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); + +#ifndef ENABLE_KDE_NOTIFIER + m_tray_icon = new QSystemTrayIcon(this); + 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) +{ + m_tray_icon->showMessage(title, message); +} +#endif + +bool QTrayIcon::isVisible() +{ +#ifndef ENABLE_KDE_NOTIFIER + return m_tray_icon->isVisible(); +#else + return true; +#endif +} + +void QTrayIcon::setIcon(const QString &icon) +{ + m_tray_icon->setIcon(QIcon(":/main/resources/images/tray/" + icon)); +} + +void QTrayIcon::show() +{ +#ifndef ENABLE_KDE_NOTIFIER + m_tray_icon->show(); +#endif +} + +void QTrayIcon::hide() +{ +#ifndef ENABLE_KDE_NOTIFIER + m_tray_icon->hide(); +#endif +} diff --git a/src/indicator/qtrayicon.h b/src/indicator/qtrayicon.h new file mode 100644 index 0000000..a5c640b --- /dev/null +++ b/src/indicator/qtrayicon.h @@ -0,0 +1,62 @@ +/* + * 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 . + */ + +#ifndef QTRAYICON_H +#define QTRAYICON_H + +#include "trayindicator.h" + +class QAction; +class QSystemTrayIcon; + +class QTrayIcon : public TrayIndicator +{ + Q_OBJECT +public: + explicit QTrayIcon(QWidget *parent = 0); + void init(); + void setIcon(const QString &icon); + bool isVisible(); + void show(); + void hide(); + +#ifndef Q_OS_LINUX + void showMessage(const QString &title, const QString &message); +#endif + +private: + //system tray + QAction *quit; + QAction *reload; + QAction *options; + QAction *backup; + QAction *about; + QAction *about_qt; + +#ifndef ENABLE_KDE_NOTIFIER + QSystemTrayIcon *m_tray_icon; +#else + KDENotifier *m_notifier_item; +#endif + +public slots: + +}; + +#endif // QTRAYICON_H diff --git a/src/indicator/trayindicator.cpp b/src/indicator/trayindicator.cpp new file mode 100644 index 0000000..ac34c25 --- /dev/null +++ b/src/indicator/trayindicator.cpp @@ -0,0 +1,54 @@ +/* + * 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 . + */ + +#include "trayindicator.h" + +#undef signals +extern "C" { +#include +} +#define signals public + + +TrayIndicator::TrayIndicator(QWidget *parent) + : QWidget(parent) +{ +#ifdef Q_OS_LINUX + notify_init("qcma"); +#endif +} + +TrayIndicator::~TrayIndicator() +{ +#ifdef Q_OS_LINUX + notify_uninit(); +#endif +} + +void TrayIndicator::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 + Q_UNUSED(title); + Q_UNUSED(message); +#endif +} diff --git a/src/indicator/trayindicator.h b/src/indicator/trayindicator.h new file mode 100644 index 0000000..c0a1618 --- /dev/null +++ b/src/indicator/trayindicator.h @@ -0,0 +1,53 @@ +#ifndef TRAYINDICATOR_H +#define TRAYINDICATOR_H + +#include "trayindicator_global.h" + +/* + * 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 . + */ + +#include +#include + +class TRAYINDICATORSHARED_EXPORT TrayIndicator : public QWidget +{ + Q_OBJECT +public: + virtual ~TrayIndicator(); + virtual void init() = 0; + virtual bool isVisible() = 0; + virtual void setIcon(const QString &icon) = 0; + virtual void showMessage(const QString &title, const QString &message); + virtual void show() = 0; + virtual void hide() = 0; + +protected: + TrayIndicator(QWidget *parent = 0); + +signals: + void openConfig(); + void openManager(); + void refreshDatabase(); + void showAboutDialog(); + void showAboutQt(); + void stopServer(); + +}; + +#endif // TRAYINDICATOR_H diff --git a/src/indicator/trayindicator_global.h b/src/indicator/trayindicator_global.h new file mode 100644 index 0000000..1ce7e5d --- /dev/null +++ b/src/indicator/trayindicator_global.h @@ -0,0 +1,31 @@ +/* + * 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 . + */ + +#ifndef TRAYINDICATOR_GLOBAL_H +#define TRAYINDICATOR_GLOBAL_H + +#include + +#if defined(QCMA_TRAYINDICATOR_LIBRARY) +# define TRAYINDICATORSHARED_EXPORT Q_DECL_EXPORT +#else +# define TRAYINDICATORSHARED_EXPORT Q_DECL_IMPORT +#endif + +#endif // TRAYINDICATOR_GLOBAL_H diff --git a/src/indicator/unityindicator.cpp b/src/indicator/unityindicator.cpp new file mode 100644 index 0000000..33cb577 --- /dev/null +++ b/src/indicator/unityindicator.cpp @@ -0,0 +1,172 @@ +/* + * 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 . + */ + +#include "unityindicator.h" + +#if QT_VERSION >= QT_VERSION_CHECK(5, 0, 0) +#include +#else +#include +#define QStandardPaths QDesktopServices +#define writableLocation storageLocation +#endif + +#include + +extern "C" { + +#include + +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); + +} + +UnityIndicator::UnityIndicator(QWidget *parent) : + TrayIndicator(parent) +{ +} + +UnityIndicator::~UnityIndicator() +{ + for(QVector >::iterator it = m_handlers.begin(); it != m_handlers.end(); ++it) + { + g_signal_handler_disconnect(it->first, it->second); + } +} + +void optionsIndicator(GtkMenu *, gpointer data) +{ + UnityIndicator *m_this = reinterpret_cast(data); + emit m_this->openConfig(); +} + +void reloadIndicator(GtkMenu *, gpointer data) +{ + UnityIndicator *m_this = reinterpret_cast(data); + emit m_this->refreshDatabase(); +} + +void backupIndicator(GtkMenu *, gpointer data) +{ + UnityIndicator *m_this = reinterpret_cast(data); + emit m_this->openManager(); +} + +void aboutIndicator(GtkMenu *, gpointer data) +{ + UnityIndicator *m_this = reinterpret_cast(data); + emit m_this->showAboutDialog(); +} + +void aboutQtIndicator(GtkMenu *, gpointer data) +{ + UnityIndicator *m_this = reinterpret_cast(data); + emit m_this->showAboutQt(); +} + +void quitIndicator(GtkMenu *, gpointer data) +{ + UnityIndicator *m_this = reinterpret_cast(data); + emit m_this->stopServer(); +} + +void UnityIndicator::init() +{ + GtkWidget *menu = gtk_menu_new(); + + GtkWidget *options = gtk_menu_item_new_with_label(qPrintable(tr("Settings"))); + GtkWidget *reload = gtk_menu_item_new_with_label(qPrintable(tr("Refresh database"))); + GtkWidget *backup = gtk_menu_item_new_with_label(qPrintable(tr("Backup Manager"))); + GtkWidget *separator1 = gtk_separator_menu_item_new(); + GtkWidget *about = gtk_menu_item_new_with_label(qPrintable(tr("About QCMA"))); + GtkWidget *about_qt = gtk_menu_item_new_with_label(qPrintable(tr("About Qt"))); + GtkWidget *separator2 = gtk_separator_menu_item_new(); + GtkWidget *quit = gtk_menu_item_new_with_label(qPrintable(tr("Quit"))); + + gtk_menu_shell_append(GTK_MENU_SHELL(menu), options); + gtk_menu_shell_append(GTK_MENU_SHELL(menu), reload); + gtk_menu_shell_append(GTK_MENU_SHELL(menu), backup); + gtk_menu_shell_append(GTK_MENU_SHELL(menu), separator1); + gtk_menu_shell_append(GTK_MENU_SHELL(menu), about); + gtk_menu_shell_append(GTK_MENU_SHELL(menu), about_qt); + gtk_menu_shell_append(GTK_MENU_SHELL(menu), separator2); + gtk_menu_shell_append(GTK_MENU_SHELL(menu), quit); + + gulong handle; + handle = g_signal_connect(options, "activate", G_CALLBACK(optionsIndicator), this); + m_handlers.append(QPair(options, handle)); + handle = g_signal_connect(reload, "activate", G_CALLBACK(reloadIndicator), this); + m_handlers.append(QPair(reload, handle)); + handle = g_signal_connect(backup, "activate", G_CALLBACK(backupIndicator), this); + m_handlers.append(QPair(backup, handle)); + handle = g_signal_connect(about, "activate", G_CALLBACK(aboutIndicator), this); + m_handlers.append(QPair(about, handle)); + handle = g_signal_connect(about_qt, "activate", G_CALLBACK(aboutQtIndicator), this); + m_handlers.append(QPair(about_qt, handle)); + handle = g_signal_connect(quit, "activate", G_CALLBACK(quitIndicator), this); + m_handlers.append(QPair(quit, handle)); + + gtk_widget_show(options); + gtk_widget_show(reload); + gtk_widget_show(backup); + gtk_widget_show(separator1); + gtk_widget_show(about); + gtk_widget_show(about_qt); + gtk_widget_show(separator2); + gtk_widget_show(quit); + + m_indicator = app_indicator_new( + "unique-application-name", + "indicator-messages", + APP_INDICATOR_CATEGORY_APPLICATION_STATUS + ); + + QString icon_name = QStandardPaths::locate(QStandardPaths::GenericDataLocation, "icons/hicolor/64x64/tray/qcma_on.png"); + if(!icon_name.isEmpty()) + { + QString icon_path = QFileInfo(icon_name).absolutePath(); + app_indicator_set_icon_theme_path(m_indicator, qPrintable(icon_path)); + } + + app_indicator_set_status(m_indicator, APP_INDICATOR_STATUS_ACTIVE); + app_indicator_set_menu(m_indicator, GTK_MENU(menu)); +} + +bool UnityIndicator::isVisible() +{ + return true; +} + +void UnityIndicator::setIcon(const QString &icon) +{ + app_indicator_set_icon_full(m_indicator, qPrintable(icon), "icon"); +} + +void UnityIndicator::show() +{ +} + +void UnityIndicator::hide() +{ +} diff --git a/src/indicator/unityindicator.h b/src/indicator/unityindicator.h new file mode 100644 index 0000000..a8a8340 --- /dev/null +++ b/src/indicator/unityindicator.h @@ -0,0 +1,51 @@ +#ifndef UNITYINDICATOR_H +#define UNITYINDICATOR_H + +/* + * 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 . + */ + +#include "indicator/trayindicator.h" + +#undef signals +extern "C" { +#include +} +#define signals public + +#include + + +class UnityIndicator : public TrayIndicator +{ + Q_OBJECT +public: + explicit UnityIndicator(QWidget *parent = 0); + ~UnityIndicator(); + void init(); + void setIcon(const QString &icon); + bool isVisible(); + void show(); + void hide(); + +private: + AppIndicator *m_indicator; + QVector > m_handlers; +}; + +#endif // UNITYINDICATOR_H