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

View File

@@ -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 <codestation404@gmail.com> Thu, 28 Jun 2014 00:00:00 -0000
qcma (0.3.3) unstable; urgency=low
* Fixed wrong file sizes under windows.

1
debian/control vendored
View File

@@ -13,6 +13,7 @@ Build-Depends:
qtbase5-dev,
qttools5-dev-tools,
qt5-default,
libnotify-dev,
pkg-config,
vitamtp-dev

2
debian/qcma.install vendored
View File

@@ -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

View File

@@ -6,7 +6,7 @@
QT += core network sql
VERSION = 0.3.3
VERSION = 0.3.4
TEMPLATE = app

View File

@@ -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

21
qcma_indicator.pro Normal file
View File

@@ -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
}

View File

@@ -1,11 +1,11 @@
<RCC>
<qresource prefix="/main">
<file>resources/xml/psp2-updatelist.xml</file>
<file>resources/images/psv_icon.png</file>
<file>resources/images/psv_icon_16.png</file>
<file>resources/images/tray/qcma_on.png</file>
<file>resources/images/tray/qcma_on_16.png</file>
<file>resources/images/qcma.png</file>
<file>resources/images/edit-clear-locationbar-rtl.png</file>
<file>resources/images/psv_icon_dc.png</file>
<file>resources/images/psv_icon_16_dc.png</file>
<file>resources/images/tray/qcma_off.png</file>
<file>resources/images/tray/qcma_off_16.png</file>
</qresource>
</RCC>

Binary file not shown.

After

Width:  |  Height:  |  Size: 984 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 994 B

View File

Before

Width:  |  Height:  |  Size: 336 B

After

Width:  |  Height:  |  Size: 336 B

View File

Before

Width:  |  Height:  |  Size: 301 B

After

Width:  |  Height:  |  Size: 301 B

View File

Before

Width:  |  Height:  |  Size: 387 B

After

Width:  |  Height:  |  Size: 387 B

View File

Before

Width:  |  Height:  |  Size: 344 B

After

Width:  |  Height:  |  Size: 344 B

View File

@@ -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

View File

@@ -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

View File

@@ -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) {

View File

@@ -14,27 +14,6 @@
<string>Backup Manager</string>
</property>
<layout class="QGridLayout" name="gridLayout">
<item row="0" column="0">
<widget class="QTabWidget" name="tabWidget">
<property name="enabled">
<bool>true</bool>
</property>
<property name="currentIndex">
<number>0</number>
</property>
<widget class="QWidget" name="backupTab">
<attribute name="title">
<string>Backup Manager</string>
</attribute>
<layout class="QGridLayout" name="gridLayout_2">
<item row="1" column="0">
<widget class="QTableWidget" name="tableWidget">
<property name="columnCount">
<number>1</number>
</property>
<column/>
</widget>
</item>
<item row="0" column="0">
<layout class="QHBoxLayout" name="horizontalLayout_3">
<item>
@@ -104,6 +83,14 @@
</item>
</layout>
</item>
<item row="1" column="0">
<widget class="QTableWidget" name="tableWidget">
<property name="columnCount">
<number>1</number>
</property>
<column/>
</widget>
</item>
<item row="2" column="0">
<layout class="QHBoxLayout" name="horizontalLayout">
<item>
@@ -140,182 +127,6 @@
</item>
</layout>
</widget>
<widget class="QWidget" name="downloadTab">
<property name="enabled">
<bool>false</bool>
</property>
<attribute name="title">
<string>Download List</string>
</attribute>
<layout class="QGridLayout" name="gridLayout_3">
<item row="0" column="0">
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<layout class="QHBoxLayout" name="horizontalLayout_4">
<item>
<widget class="QLabel" name="label_5">
<property name="text">
<string>Console</string>
</property>
</widget>
</item>
<item>
<widget class="QComboBox" name="comboBox">
<item>
<property name="text">
<string>PS Vita</string>
</property>
</item>
<item>
<property name="text">
<string>PSP</string>
</property>
</item>
<item>
<property name="text">
<string>Other</string>
</property>
</item>
</widget>
</item>
<item>
<widget class="QLabel" name="label_6">
<property name="text">
<string>Content</string>
</property>
</widget>
</item>
<item>
<widget class="QComboBox" name="comboBox_2">
<item>
<property name="text">
<string>Games</string>
</property>
</item>
<item>
<property name="text">
<string>Demos</string>
</property>
</item>
<item>
<property name="text">
<string>DLC</string>
</property>
</item>
<item>
<property name="text">
<string>Other</string>
</property>
</item>
</widget>
</item>
<item>
<widget class="QLabel" name="label_7">
<property name="text">
<string>Status</string>
</property>
</widget>
</item>
<item>
<widget class="QComboBox" name="comboBox_3">
<item>
<property name="text">
<string>New</string>
</property>
</item>
<item>
<property name="text">
<string>Downloading</string>
</property>
</item>
<item>
<property name="text">
<string>Completed</string>
</property>
</item>
<item>
<property name="text">
<string>Paused</string>
</property>
</item>
</widget>
</item>
</layout>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_5">
<item>
<widget class="QLabel" name="label_8">
<property name="text">
<string>Username:</string>
</property>
</widget>
</item>
<item>
<widget class="QLineEdit" name="usernameEdit"/>
</item>
<item>
<widget class="QLabel" name="label_9">
<property name="text">
<string>Password:</string>
</property>
</widget>
</item>
<item>
<widget class="QLineEdit" name="passwordEdit">
<property name="echoMode">
<enum>QLineEdit::Password</enum>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="refreshButton">
<property name="text">
<string>Refresh</string>
</property>
</widget>
</item>
</layout>
</item>
<item>
<widget class="QListWidget" name="listWidget"/>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_6">
<item>
<widget class="QLabel" name="label_10">
<property name="text">
<string>Filter:</string>
</property>
</widget>
</item>
<item>
<widget class="QLineEdit" name="lineEdit_3"/>
</item>
<item>
<widget class="QPushButton" name="pushButton">
<property name="text">
<string>Resume All</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="pushButton_2">
<property name="text">
<string>Pause All</string>
</property>
</widget>
</item>
</layout>
</item>
</layout>
</item>
</layout>
</widget>
</widget>
</item>
</layout>
</widget>
<customwidgets>
<customwidget>
<class>FilterLineEdit</class>

View File

@@ -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);

View File

@@ -48,6 +48,7 @@ private:
private slots:
void browseBtnPressed(int from);
void resetButtonPressed();
void accept();
};

View File

@@ -7,7 +7,7 @@
<x>0</x>
<y>0</y>
<width>520</width>
<height>450</height>
<height>439</height>
</rect>
</property>
<property name="windowTitle">
@@ -19,7 +19,7 @@
<item>
<widget class="QTabWidget" name="tabWidget">
<property name="currentIndex">
<number>0</number>
<number>1</number>
</property>
<widget class="QWidget" name="tab">
<attribute name="title">
@@ -211,6 +211,8 @@
</item>
</layout>
</item>
</layout>
</item>
<item>
<layout class="QVBoxLayout" name="verticalLayout_9">
<item>
@@ -239,8 +241,6 @@
</layout>
</item>
</layout>
</item>
</layout>
</widget>
<widget class="QWidget" name="tab_2">
<attribute name="title">
@@ -299,6 +299,9 @@
</item>
<item>
<layout class="QFormLayout" name="formLayout">
<property name="fieldGrowthPolicy">
<enum>QFormLayout::AllNonFixedFieldsGrow</enum>
</property>
<item row="0" column="0">
<widget class="QLabel" name="label_8">
<property name="text">
@@ -346,6 +349,31 @@
</property>
</widget>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_3">
<item>
<widget class="QLabel" name="label_10">
<property name="text">
<string>CMA Protocol version</string>
</property>
</widget>
</item>
<item>
<widget class="QLineEdit" name="protocolEdit">
<property name="inputMask">
<string>9999999</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="resetProtocolButton">
<property name="text">
<string>Reset to default</string>
</property>
</widget>
</item>
</layout>
</item>
<item>
<spacer name="verticalSpacer">
<property name="orientation">

View File

@@ -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

View File

@@ -28,22 +28,22 @@
#include "qlistdb.h"
#include "sqlitedb.h"
#include <QAction>
#ifdef ENABLE_APPINDICATOR
#include "indicator/unityindicator.h"
#else
#include "indicator/qtrayicon.h"
#endif
#include <QApplication>
#include <QDebug>
#include <QDir>
#include <QGridLayout>
#include <QMenu>
#include <QMessageBox>
#include <QSettings>
#include <QTimer>
#include <QSettings>
#include <QSpacerItem>
#ifdef ENABLE_KDE_NOTIFIER
#include <kmenu.h>
#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,15 +269,9 @@ 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()
{

View File

@@ -40,6 +40,8 @@
#include <vitamtp.h>
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;

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