Bump version to 0.3.4.

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.
This commit is contained in:
codestation
2014-10-03 01:40:35 -04:30
parent a85d49ebc9
commit fb5b881345
30 changed files with 781 additions and 387 deletions

117
src/indicator/qtrayicon.cpp Normal file
View File

@@ -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 <http://www.gnu.org/licenses/>.
*/
#include "qtrayicon.h"
#include <QSystemTrayIcon>
#ifdef ENABLE_KDE_NOTIFIER
#include <kmenu.h>
#else
#include <QIcon>
#include <QMenu>
#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
}

62
src/indicator/qtrayicon.h Normal file
View File

@@ -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 <http://www.gnu.org/licenses/>.
*/
#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

View File

@@ -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 <http://www.gnu.org/licenses/>.
*/
#include "trayindicator.h"
#undef signals
extern "C" {
#include <libnotify/notify.h>
}
#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
}

View File

@@ -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 <http://www.gnu.org/licenses/>.
*/
#include <QString>
#include <QWidget>
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

View File

@@ -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 <http://www.gnu.org/licenses/>.
*/
#ifndef TRAYINDICATOR_GLOBAL_H
#define TRAYINDICATOR_GLOBAL_H
#include <QtCore/qglobal.h>
#if defined(QCMA_TRAYINDICATOR_LIBRARY)
# define TRAYINDICATORSHARED_EXPORT Q_DECL_EXPORT
#else
# define TRAYINDICATORSHARED_EXPORT Q_DECL_IMPORT
#endif
#endif // TRAYINDICATOR_GLOBAL_H

View File

@@ -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 <http://www.gnu.org/licenses/>.
*/
#include "unityindicator.h"
#if QT_VERSION >= QT_VERSION_CHECK(5, 0, 0)
#include <QStandardPaths>
#else
#include <QDesktopServices>
#define QStandardPaths QDesktopServices
#define writableLocation storageLocation
#endif
#include <QDir>
extern "C" {
#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);
}
UnityIndicator::UnityIndicator(QWidget *parent) :
TrayIndicator(parent)
{
}
UnityIndicator::~UnityIndicator()
{
for(QVector<QPair<gpointer, gulong> >::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<UnityIndicator *>(data);
emit m_this->openConfig();
}
void reloadIndicator(GtkMenu *, gpointer data)
{
UnityIndicator *m_this = reinterpret_cast<UnityIndicator *>(data);
emit m_this->refreshDatabase();
}
void backupIndicator(GtkMenu *, gpointer data)
{
UnityIndicator *m_this = reinterpret_cast<UnityIndicator *>(data);
emit m_this->openManager();
}
void aboutIndicator(GtkMenu *, gpointer data)
{
UnityIndicator *m_this = reinterpret_cast<UnityIndicator *>(data);
emit m_this->showAboutDialog();
}
void aboutQtIndicator(GtkMenu *, gpointer data)
{
UnityIndicator *m_this = reinterpret_cast<UnityIndicator *>(data);
emit m_this->showAboutQt();
}
void quitIndicator(GtkMenu *, gpointer data)
{
UnityIndicator *m_this = reinterpret_cast<UnityIndicator *>(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<gpointer, gulong>(options, handle));
handle = g_signal_connect(reload, "activate", G_CALLBACK(reloadIndicator), this);
m_handlers.append(QPair<gpointer, gulong>(reload, handle));
handle = g_signal_connect(backup, "activate", G_CALLBACK(backupIndicator), this);
m_handlers.append(QPair<gpointer, gulong>(backup, handle));
handle = g_signal_connect(about, "activate", G_CALLBACK(aboutIndicator), this);
m_handlers.append(QPair<gpointer, gulong>(about, handle));
handle = g_signal_connect(about_qt, "activate", G_CALLBACK(aboutQtIndicator), this);
m_handlers.append(QPair<gpointer, gulong>(about_qt, handle));
handle = g_signal_connect(quit, "activate", G_CALLBACK(quitIndicator), this);
m_handlers.append(QPair<gpointer, gulong>(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()
{
}

View File

@@ -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 <http://www.gnu.org/licenses/>.
*/
#include "indicator/trayindicator.h"
#undef signals
extern "C" {
#include <libappindicator/app-indicator.h>
}
#define signals public
#include <QVector>
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<QPair<gpointer, gulong> > m_handlers;
};
#endif // UNITYINDICATOR_H