Reorganized project to avoid the ".pro not found" by having all the
pro files in the same directory. With this change the android library now builds properly. This also fixes the parallel compilation problem that happened when building using +8 cores.
							
								
								
									
										214
									
								
								gui/clientmanager.cpp
									
									
									
									
									
										Normal file
									
								
							
							
						
						@@ -0,0 +1,214 @@
 | 
			
		||||
/*
 | 
			
		||||
 *  QCMA: Cross-platform content manager assistant for the PS Vita
 | 
			
		||||
 *
 | 
			
		||||
 *  Copyright (C) 2013  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 "clientmanager.h"
 | 
			
		||||
#include "cmaclient.h"
 | 
			
		||||
#include "cmautils.h"
 | 
			
		||||
#include "forms/progressform.h"
 | 
			
		||||
 | 
			
		||||
#include <QSettings>
 | 
			
		||||
 | 
			
		||||
#include <vitamtp.h>
 | 
			
		||||
 | 
			
		||||
#ifdef Q_OS_UNIX
 | 
			
		||||
#include <sys/socket.h>
 | 
			
		||||
#include <unistd.h>
 | 
			
		||||
 | 
			
		||||
int ClientManager::sighup_fd[2];
 | 
			
		||||
int ClientManager::sigterm_fd[2];
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
ClientManager::ClientManager(Database *db, QObject *obj_parent) :
 | 
			
		||||
    QObject(obj_parent), m_db(db)
 | 
			
		||||
{
 | 
			
		||||
#ifdef Q_OS_UNIX
 | 
			
		||||
    if (::socketpair(AF_UNIX, SOCK_STREAM, 0, sighup_fd))
 | 
			
		||||
       qFatal("Couldn't create HUP socketpair");
 | 
			
		||||
 | 
			
		||||
    if (::socketpair(AF_UNIX, SOCK_STREAM, 0, sigterm_fd))
 | 
			
		||||
       qFatal("Couldn't create TERM socketpair");
 | 
			
		||||
 | 
			
		||||
    sn_hup = new QSocketNotifier(sighup_fd[1], QSocketNotifier::Read, this);
 | 
			
		||||
    connect(sn_hup, SIGNAL(activated(int)), this, SLOT(handleSigHup()));
 | 
			
		||||
    sn_term = new QSocketNotifier(sigterm_fd[1], QSocketNotifier::Read, this);
 | 
			
		||||
    connect(sn_term, SIGNAL(activated(int)), this, SLOT(handleSigTerm()));
 | 
			
		||||
#endif
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
ClientManager::~ClientManager()
 | 
			
		||||
{
 | 
			
		||||
    VitaMTP_Cleanup();
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void ClientManager::databaseUpdated(int count)
 | 
			
		||||
{
 | 
			
		||||
    progress.interruptShow();
 | 
			
		||||
    progress.hide();
 | 
			
		||||
    if(count >= 0) {
 | 
			
		||||
        emit messageSent(tr("Added %1 items to the database").arg(count));
 | 
			
		||||
    } else {
 | 
			
		||||
        emit messageSent(tr("Database indexing aborted by user"));
 | 
			
		||||
    }
 | 
			
		||||
    emit updated(count);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void ClientManager::showPinDialog(QString name, int pin)
 | 
			
		||||
{
 | 
			
		||||
    pinForm.setPin(name, pin);
 | 
			
		||||
    pinForm.startCountdown();
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void ClientManager::start()
 | 
			
		||||
{
 | 
			
		||||
    if(VitaMTP_Init() < 0) {
 | 
			
		||||
        emit messageSent(tr("Cannot initialize VitaMTP library"));
 | 
			
		||||
        return;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    // initializing database for the first use
 | 
			
		||||
    refreshDatabase();
 | 
			
		||||
 | 
			
		||||
    connect(m_db, SIGNAL(fileAdded(QString)), &progress, SLOT(setFileName(QString)));
 | 
			
		||||
    connect(m_db, SIGNAL(directoryAdded(QString)), &progress, SLOT(setDirectoryName(QString)));
 | 
			
		||||
    connect(m_db, SIGNAL(updated(int)), this, SLOT(databaseUpdated(int)));
 | 
			
		||||
    connect(&progress, SIGNAL(canceled()), m_db, SLOT(cancelOperation()), Qt::DirectConnection);
 | 
			
		||||
 | 
			
		||||
    thread_count = 0;
 | 
			
		||||
    qDebug("Starting cma threads");
 | 
			
		||||
    CmaClient *client;
 | 
			
		||||
    QSettings settings;
 | 
			
		||||
 | 
			
		||||
    if(!settings.value("disableUSB", false).toBool()) {
 | 
			
		||||
 | 
			
		||||
#ifdef Q_OS_LINUX
 | 
			
		||||
        if(!belongsToGroup("vitamtp"))
 | 
			
		||||
            emit messageSent(tr("This user doesn't belong to the vitamtp group, there could be a problem while reading the USB bus."));
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
        usb_thread = new QThread();
 | 
			
		||||
        client = new CmaClient(m_db);
 | 
			
		||||
        usb_thread->setObjectName("usb_thread");
 | 
			
		||||
        connect(usb_thread, SIGNAL(started()), client, SLOT(connectUsb()));
 | 
			
		||||
        connect(client, SIGNAL(messageSent(QString)), this, SIGNAL(messageSent(QString)));
 | 
			
		||||
        connect(client, SIGNAL(finished()), usb_thread, SLOT(quit()), Qt::DirectConnection);
 | 
			
		||||
        connect(usb_thread, SIGNAL(finished()), usb_thread, SLOT(deleteLater()));
 | 
			
		||||
        connect(usb_thread, SIGNAL(finished()), this, SLOT(threadStopped()));
 | 
			
		||||
        connect(usb_thread, SIGNAL(finished()), client, SLOT(deleteLater()));
 | 
			
		||||
 | 
			
		||||
        connect(client, SIGNAL(deviceConnected(QString)), this, SIGNAL(deviceConnected(QString)));
 | 
			
		||||
        connect(client, SIGNAL(deviceDisconnected()), this, SIGNAL(deviceDisconnected()));
 | 
			
		||||
        connect(client, SIGNAL(refreshDatabase()), this, SLOT(refreshDatabase()));
 | 
			
		||||
 | 
			
		||||
        client->moveToThread(usb_thread);
 | 
			
		||||
        usb_thread->start();
 | 
			
		||||
        thread_count++;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    if(!settings.value("disableWireless", false).toBool()) {
 | 
			
		||||
        CmaBroadcast *broadcast = new CmaBroadcast(this);
 | 
			
		||||
        wireless_thread = new QThread();
 | 
			
		||||
        client = new CmaClient(m_db, broadcast);
 | 
			
		||||
        wireless_thread->setObjectName("wireless_thread");
 | 
			
		||||
        connect(wireless_thread, SIGNAL(started()), client, SLOT(connectWireless()));
 | 
			
		||||
        connect(client, SIGNAL(messageSent(QString)), this, SIGNAL(messageSent(QString)));
 | 
			
		||||
        connect(client, SIGNAL(receivedPin(QString,int)), this, SLOT(showPinDialog(QString,int)));
 | 
			
		||||
        connect(client, SIGNAL(finished()), wireless_thread, SLOT(quit()), Qt::DirectConnection);
 | 
			
		||||
        connect(wireless_thread, SIGNAL(finished()), wireless_thread, SLOT(deleteLater()));
 | 
			
		||||
        connect(wireless_thread, SIGNAL(finished()), this, SLOT(threadStopped()));
 | 
			
		||||
        connect(wireless_thread, SIGNAL(finished()), client, SLOT(deleteLater()));
 | 
			
		||||
 | 
			
		||||
        connect(client, SIGNAL(pinComplete()), &pinForm, SLOT(hide()));
 | 
			
		||||
        connect(client, SIGNAL(deviceConnected(QString)), this, SIGNAL(deviceConnected(QString)));
 | 
			
		||||
        connect(client, SIGNAL(deviceDisconnected()), this, SIGNAL(deviceDisconnected()));
 | 
			
		||||
        connect(client, SIGNAL(refreshDatabase()), this, SLOT(refreshDatabase()));
 | 
			
		||||
 | 
			
		||||
        client->moveToThread(wireless_thread);
 | 
			
		||||
        wireless_thread->start();
 | 
			
		||||
        thread_count++;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    if(thread_count == 0) {
 | 
			
		||||
        emit messageSent(tr("You must enable at least USB or Wireless monitoring"));
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void ClientManager::refreshDatabase()
 | 
			
		||||
{
 | 
			
		||||
    if(m_db->load()) {
 | 
			
		||||
        return;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    if(!m_db->rescan()) {
 | 
			
		||||
        emit messageSent(tr("No PS Vita system has been registered"));
 | 
			
		||||
    } else {
 | 
			
		||||
        progress.showDelayed(1000);
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void ClientManager::stop()
 | 
			
		||||
{
 | 
			
		||||
    if(CmaClient::stop() < 0) {
 | 
			
		||||
        emit stopped();
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void ClientManager::threadStopped()
 | 
			
		||||
{
 | 
			
		||||
    mutex.lock();
 | 
			
		||||
    if(--thread_count == 0) {
 | 
			
		||||
        emit stopped();
 | 
			
		||||
    }
 | 
			
		||||
    mutex.unlock();
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
#ifdef Q_OS_UNIX
 | 
			
		||||
void ClientManager::hupSignalHandler(int)
 | 
			
		||||
{
 | 
			
		||||
    char a = 1;
 | 
			
		||||
    ::write(sighup_fd[0], &a, sizeof(a));
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void ClientManager::termSignalHandler(int)
 | 
			
		||||
{
 | 
			
		||||
    char a = 1;
 | 
			
		||||
    ::write(sigterm_fd[0], &a, sizeof(a));
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void ClientManager::handleSigTerm()
 | 
			
		||||
{
 | 
			
		||||
    sn_term->setEnabled(false);
 | 
			
		||||
    char tmp;
 | 
			
		||||
    ::read(sigterm_fd[1], &tmp, sizeof(tmp));
 | 
			
		||||
 | 
			
		||||
    stop();
 | 
			
		||||
 | 
			
		||||
    sn_term->setEnabled(true);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void ClientManager::handleSigHup()
 | 
			
		||||
{
 | 
			
		||||
    sn_hup->setEnabled(false);
 | 
			
		||||
    char tmp;
 | 
			
		||||
    ::read(sighup_fd[1], &tmp, sizeof(tmp));
 | 
			
		||||
 | 
			
		||||
    refreshDatabase();
 | 
			
		||||
 | 
			
		||||
    sn_hup->setEnabled(true);
 | 
			
		||||
}
 | 
			
		||||
#endif
 | 
			
		||||
							
								
								
									
										94
									
								
								gui/clientmanager.h
									
									
									
									
									
										Normal file
									
								
							
							
						
						@@ -0,0 +1,94 @@
 | 
			
		||||
/*
 | 
			
		||||
 *  QCMA: Cross-platform content manager assistant for the PS Vita
 | 
			
		||||
 *
 | 
			
		||||
 *  Copyright (C) 2013  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 CLIENTMANAGER_H
 | 
			
		||||
#define CLIENTMANAGER_H
 | 
			
		||||
 | 
			
		||||
#include "database.h"
 | 
			
		||||
#include "forms/pinform.h"
 | 
			
		||||
#include "forms/progressform.h"
 | 
			
		||||
 | 
			
		||||
#include <QObject>
 | 
			
		||||
#include <QThread>
 | 
			
		||||
 | 
			
		||||
#ifdef Q_OS_UNIX
 | 
			
		||||
#include <QSocketNotifier>
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
class ClientManager : public QObject
 | 
			
		||||
{
 | 
			
		||||
    Q_OBJECT
 | 
			
		||||
public:
 | 
			
		||||
    explicit ClientManager(Database *db, QObject *parent = 0);
 | 
			
		||||
    ~ClientManager();
 | 
			
		||||
 | 
			
		||||
    void start();
 | 
			
		||||
    void stop();
 | 
			
		||||
 | 
			
		||||
#ifdef Q_OS_UNIX
 | 
			
		||||
    // unix signal handlers
 | 
			
		||||
    static void hupSignalHandler(int);
 | 
			
		||||
    static void termSignalHandler(int);
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
private:
 | 
			
		||||
    int thread_count;
 | 
			
		||||
    QMutex mutex;
 | 
			
		||||
 | 
			
		||||
    Database *m_db;
 | 
			
		||||
 | 
			
		||||
    PinForm pinForm;
 | 
			
		||||
    ProgressForm progress;
 | 
			
		||||
 | 
			
		||||
    QThread *usb_thread;
 | 
			
		||||
    QThread *wireless_thread;
 | 
			
		||||
 | 
			
		||||
#ifdef Q_OS_UNIX
 | 
			
		||||
    // signal handling
 | 
			
		||||
    static int sighup_fd[2];
 | 
			
		||||
    static int sigterm_fd[2];
 | 
			
		||||
 | 
			
		||||
    QSocketNotifier *sn_hup;
 | 
			
		||||
    QSocketNotifier *sn_term;
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
signals:
 | 
			
		||||
    void updated(int);
 | 
			
		||||
    void stopped();
 | 
			
		||||
    void receivedPin(int);
 | 
			
		||||
    void deviceDisconnected();
 | 
			
		||||
    void messageSent(QString);
 | 
			
		||||
    void deviceConnected(QString);
 | 
			
		||||
 | 
			
		||||
public slots:
 | 
			
		||||
    void refreshDatabase();
 | 
			
		||||
 | 
			
		||||
#ifdef Q_OS_UNIX
 | 
			
		||||
    // Qt signal handlers
 | 
			
		||||
    void handleSigHup();
 | 
			
		||||
    void handleSigTerm();
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
private slots:
 | 
			
		||||
    void threadStopped();
 | 
			
		||||
    void databaseUpdated(int count);
 | 
			
		||||
    void showPinDialog(QString name, int pin);
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
#endif // CLIENTMANAGER_H
 | 
			
		||||
							
								
								
									
										2
									
								
								gui/defines.pri
									
									
									
									
									
										Normal file
									
								
							
							
						
						@@ -0,0 +1,2 @@
 | 
			
		||||
INCLUDEPATH += $$IN_PWD
 | 
			
		||||
DEPENDPATH += $$IN_PWD
 | 
			
		||||
							
								
								
									
										89
									
								
								gui/filterlineedit.cpp
									
									
									
									
									
										Normal file
									
								
							
							
						
						@@ -0,0 +1,89 @@
 | 
			
		||||
/*
 | 
			
		||||
 *  QCMA: Cross-platform content manager assistant for the PS Vita
 | 
			
		||||
 *
 | 
			
		||||
 *  Copyright (C) 2013  Xian Nox
 | 
			
		||||
 *
 | 
			
		||||
 *  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 "filterlineedit.h"
 | 
			
		||||
 | 
			
		||||
#include <QIcon>
 | 
			
		||||
#include <QStyle>
 | 
			
		||||
 | 
			
		||||
FilterLineEdit::FilterLineEdit(QWidget *obj_parent) :
 | 
			
		||||
    QLineEdit(obj_parent)
 | 
			
		||||
{
 | 
			
		||||
    int frame_width = frameWidth();
 | 
			
		||||
    clearButton = new QToolButton(this);
 | 
			
		||||
    QIcon clearIcon(":/main/resources/images/edit-clear-locationbar-rtl.png");
 | 
			
		||||
    clearButton->setIcon(clearIcon);
 | 
			
		||||
    clearButton->setIconSize(QSize(sizeHint().height() - 4 * frame_width,
 | 
			
		||||
                                   sizeHint().height() - 4 * frame_width));
 | 
			
		||||
    clearButton->setCursor(Qt::ArrowCursor);
 | 
			
		||||
    clearButton->setStyleSheet("QToolButton { border:none; padding:0px; }");
 | 
			
		||||
    clearButton->hide();
 | 
			
		||||
    connect(clearButton, SIGNAL(clicked()), this, SLOT(clear()));
 | 
			
		||||
    connect(this, SIGNAL(textChanged(const QString&)), this, SLOT(updateCloseButton(const QString&)));
 | 
			
		||||
 | 
			
		||||
    setStyleSheet(QString("LineEdit { color:black; font-style:normal; padding-right:%1px; }").arg(
 | 
			
		||||
                      clearButton->sizeHint().width() + frame_width + 1));
 | 
			
		||||
 | 
			
		||||
    QSize min_size_hint = minimumSizeHint();
 | 
			
		||||
    setMinimumSize(qMax(min_size_hint.width(), clearButton->sizeHint().height() + frame_width),
 | 
			
		||||
                   qMax(min_size_hint.height(), clearButton->sizeHint().height() + frame_width));
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void FilterLineEdit::updateCloseButton(const QString& filter_text)
 | 
			
		||||
{
 | 
			
		||||
    if(filter_text.isEmpty() || filter_text == tr("Filter")) {
 | 
			
		||||
        clearButton->setVisible(false);
 | 
			
		||||
    } else {
 | 
			
		||||
        clearButton->setVisible(true);
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void FilterLineEdit::focusInEvent(QFocusEvent *e)
 | 
			
		||||
{
 | 
			
		||||
    if(this->styleSheet() == "FilterLineEdit { color:gray; font-style:italic; }") {
 | 
			
		||||
        this->clear();
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    setStyleSheet(QString("FilterLineEdit { color:black; font-style:normal; padding-right:%1px; }").arg(clearButton->sizeHint().width() + frameWidth() + 1));
 | 
			
		||||
 | 
			
		||||
    QLineEdit::focusInEvent(e);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void FilterLineEdit::focusOutEvent(QFocusEvent *e)
 | 
			
		||||
{
 | 
			
		||||
    if(this->text().isEmpty()) {
 | 
			
		||||
        this->setText(tr("Filter"));
 | 
			
		||||
        this->setStyleSheet("FilterLineEdit { color:gray; font-style:italic; }");
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    QLineEdit::focusOutEvent(e);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
int FilterLineEdit::frameWidth() const
 | 
			
		||||
{
 | 
			
		||||
    return style()->pixelMetric(QStyle::PM_DefaultFrameWidth, 0, this);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void FilterLineEdit::resizeEvent(QResizeEvent *e)
 | 
			
		||||
{
 | 
			
		||||
    QSize sz = clearButton->sizeHint();
 | 
			
		||||
    clearButton->move(rect().right() - sz.width(), rect().bottom() - sz.height() + frameWidth());
 | 
			
		||||
 | 
			
		||||
    QLineEdit::resizeEvent(e);
 | 
			
		||||
}
 | 
			
		||||
							
								
								
									
										47
									
								
								gui/filterlineedit.h
									
									
									
									
									
										Normal file
									
								
							
							
						
						@@ -0,0 +1,47 @@
 | 
			
		||||
/*
 | 
			
		||||
 *  QCMA: Cross-platform content manager assistant for the PS Vita
 | 
			
		||||
 *
 | 
			
		||||
 *  Copyright (C) 2013  Xian Nox
 | 
			
		||||
 *
 | 
			
		||||
 *  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 FILTERLINEEDIT_H
 | 
			
		||||
#define FILTERLINEEDIT_H
 | 
			
		||||
 | 
			
		||||
#include <QLineEdit>
 | 
			
		||||
#include <QToolButton>
 | 
			
		||||
 | 
			
		||||
class FilterLineEdit : public QLineEdit
 | 
			
		||||
{
 | 
			
		||||
    Q_OBJECT
 | 
			
		||||
 | 
			
		||||
public:
 | 
			
		||||
    explicit FilterLineEdit(QWidget *parent = 0);
 | 
			
		||||
 | 
			
		||||
protected:
 | 
			
		||||
    void focusInEvent(QFocusEvent *e);
 | 
			
		||||
    void focusOutEvent(QFocusEvent *e);
 | 
			
		||||
    void resizeEvent(QResizeEvent *e);
 | 
			
		||||
    int frameWidth() const;
 | 
			
		||||
 | 
			
		||||
private:
 | 
			
		||||
    QToolButton *clearButton;
 | 
			
		||||
 | 
			
		||||
private slots:
 | 
			
		||||
    void updateCloseButton(const QString &text);
 | 
			
		||||
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
#endif // FILTERLINEEDIT_H
 | 
			
		||||
							
								
								
									
										104
									
								
								gui/forms/backupitem.cpp
									
									
									
									
									
										Normal file
									
								
							
							
						
						@@ -0,0 +1,104 @@
 | 
			
		||||
/*
 | 
			
		||||
 *  QCMA: Cross-platform content manager assistant for the PS Vita
 | 
			
		||||
 *
 | 
			
		||||
 *  Copyright (C) 2013  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 "backupitem.h"
 | 
			
		||||
#include "ui_backupitem.h"
 | 
			
		||||
#include "cmautils.h"
 | 
			
		||||
#include "dds.h"
 | 
			
		||||
 | 
			
		||||
#include <QDesktopServices>
 | 
			
		||||
#include <QUrl>
 | 
			
		||||
 | 
			
		||||
const QString BackupItem::gameTemplate = "<html><head/><body>"
 | 
			
		||||
        "<p><span style=\" font-size:13pt; font-weight:600;\">%1</span></p>"
 | 
			
		||||
        "</body></html>";
 | 
			
		||||
 | 
			
		||||
const QString BackupItem::sizeTemplate = "<html><head/><body>"
 | 
			
		||||
        "<p><span style=\" font-size:10pt;\">%1</span></p>"
 | 
			
		||||
        "</body></html>";
 | 
			
		||||
 | 
			
		||||
const QString BackupItem::infoTemplate = "<html><head/><body>"
 | 
			
		||||
        "<p><span style=\" font-size:10pt;\"> %1</span></p>"
 | 
			
		||||
        "</body></html>";
 | 
			
		||||
 | 
			
		||||
BackupItem::BackupItem(QWidget *obj_parent) :
 | 
			
		||||
    QWidget(obj_parent),
 | 
			
		||||
    ui(new Ui::BackupItem)
 | 
			
		||||
{
 | 
			
		||||
    ui->setupUi(this);
 | 
			
		||||
    // connect the buttons
 | 
			
		||||
    connect(ui->openButton, SIGNAL(clicked()), this, SLOT(openDirectory()));
 | 
			
		||||
    connect(ui->deleteButton, SIGNAL(clicked()), this, SLOT(removeEntry()));
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
BackupItem::~BackupItem()
 | 
			
		||||
{
 | 
			
		||||
    delete ui;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void BackupItem::openDirectory()
 | 
			
		||||
{
 | 
			
		||||
    QDesktopServices::openUrl(QUrl("file:///" + m_path));
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void BackupItem::removeEntry()
 | 
			
		||||
{
 | 
			
		||||
    emit deleteEntry(this);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
const QPixmap *BackupItem::getIconPixmap()
 | 
			
		||||
{
 | 
			
		||||
    return ui->itemPicture->pixmap();
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void BackupItem::setDirectory(const QString &path)
 | 
			
		||||
{
 | 
			
		||||
    m_path = path;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void BackupItem::setItemInfo(const QString &name, const QString &item_size, const QString &extra)
 | 
			
		||||
{
 | 
			
		||||
    ui->gameLabel->setText(gameTemplate.arg(name));
 | 
			
		||||
    ui->sizeLabel->setText(sizeTemplate.arg(item_size));
 | 
			
		||||
    ui->infoLabel->setText(infoTemplate.arg(extra));
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
int BackupItem::getIconWidth()
 | 
			
		||||
{
 | 
			
		||||
    return ui->itemPicture->width();
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void BackupItem::setItemIcon(const QString &path, int item_width, bool try_dds)
 | 
			
		||||
{
 | 
			
		||||
    ui->itemPicture->setMinimumWidth(item_width);
 | 
			
		||||
    QPixmap pixmap(path);
 | 
			
		||||
    if((pixmap.width() <= 0 || pixmap.height() <= 0) && try_dds) {
 | 
			
		||||
        QImage image;
 | 
			
		||||
        if(loadDDS(path, &image)) {
 | 
			
		||||
            pixmap = QPixmap::fromImage(image);
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
    ui->itemPicture->setPixmap(pixmap);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
bool BackupItem::lessThan(const BackupItem *s1, const BackupItem *s2)
 | 
			
		||||
{
 | 
			
		||||
    return s1->title.compare(s2->title) < 0;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
							
								
								
									
										63
									
								
								gui/forms/backupitem.h
									
									
									
									
									
										Normal file
									
								
							
							
						
						@@ -0,0 +1,63 @@
 | 
			
		||||
/*
 | 
			
		||||
 *  QCMA: Cross-platform content manager assistant for the PS Vita
 | 
			
		||||
 *
 | 
			
		||||
 *  Copyright (C) 2013  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 BACKUPITEM_H
 | 
			
		||||
#define BACKUPITEM_H
 | 
			
		||||
 | 
			
		||||
#include <QWidget>
 | 
			
		||||
 | 
			
		||||
namespace Ui {
 | 
			
		||||
class BackupItem;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
class BackupItem : public QWidget
 | 
			
		||||
{
 | 
			
		||||
    Q_OBJECT
 | 
			
		||||
 | 
			
		||||
public:
 | 
			
		||||
    explicit BackupItem(QWidget *parent = 0);
 | 
			
		||||
    ~BackupItem();
 | 
			
		||||
 | 
			
		||||
    void setItemInfo(const QString &name, const QString &size, const QString &extra);
 | 
			
		||||
    void setItemIcon(const QString &m_path, int width = 48, bool try_dds = false);
 | 
			
		||||
    void setDirectory(const QString &m_path);
 | 
			
		||||
    const QPixmap *getIconPixmap();
 | 
			
		||||
    int getIconWidth();
 | 
			
		||||
 | 
			
		||||
    static bool lessThan(const BackupItem *s1, const BackupItem *s2);
 | 
			
		||||
 | 
			
		||||
    int ohfi;
 | 
			
		||||
    QString title;
 | 
			
		||||
 | 
			
		||||
private:
 | 
			
		||||
    QString m_path;
 | 
			
		||||
    Ui::BackupItem *ui;
 | 
			
		||||
    static const QString gameTemplate;
 | 
			
		||||
    static const QString sizeTemplate;
 | 
			
		||||
    static const QString infoTemplate;
 | 
			
		||||
 | 
			
		||||
signals:
 | 
			
		||||
    void deleteEntry(BackupItem *entry);
 | 
			
		||||
 | 
			
		||||
private slots:
 | 
			
		||||
    void openDirectory();
 | 
			
		||||
    void removeEntry();
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
#endif // BACKUPITEM_H
 | 
			
		||||
							
								
								
									
										154
									
								
								gui/forms/backupitem.ui
									
									
									
									
									
										Normal file
									
								
							
							
						
						@@ -0,0 +1,154 @@
 | 
			
		||||
<?xml version="1.0" encoding="UTF-8"?>
 | 
			
		||||
<ui version="4.0">
 | 
			
		||||
 <class>BackupItem</class>
 | 
			
		||||
 <widget class="QWidget" name="BackupItem">
 | 
			
		||||
  <property name="geometry">
 | 
			
		||||
   <rect>
 | 
			
		||||
    <x>0</x>
 | 
			
		||||
    <y>0</y>
 | 
			
		||||
    <width>638</width>
 | 
			
		||||
    <height>75</height>
 | 
			
		||||
   </rect>
 | 
			
		||||
  </property>
 | 
			
		||||
  <property name="sizePolicy">
 | 
			
		||||
   <sizepolicy hsizetype="Preferred" vsizetype="Maximum">
 | 
			
		||||
    <horstretch>0</horstretch>
 | 
			
		||||
    <verstretch>0</verstretch>
 | 
			
		||||
   </sizepolicy>
 | 
			
		||||
  </property>
 | 
			
		||||
  <property name="windowTitle">
 | 
			
		||||
   <string/>
 | 
			
		||||
  </property>
 | 
			
		||||
  <layout class="QGridLayout" name="gridLayout">
 | 
			
		||||
   <item row="0" column="0">
 | 
			
		||||
    <layout class="QHBoxLayout" name="horizontalLayout">
 | 
			
		||||
     <item>
 | 
			
		||||
      <widget class="QLabel" name="itemPicture">
 | 
			
		||||
       <property name="minimumSize">
 | 
			
		||||
        <size>
 | 
			
		||||
         <width>48</width>
 | 
			
		||||
         <height>48</height>
 | 
			
		||||
        </size>
 | 
			
		||||
       </property>
 | 
			
		||||
       <property name="maximumSize">
 | 
			
		||||
        <size>
 | 
			
		||||
         <width>0</width>
 | 
			
		||||
         <height>48</height>
 | 
			
		||||
        </size>
 | 
			
		||||
       </property>
 | 
			
		||||
       <property name="text">
 | 
			
		||||
        <string notr="true"/>
 | 
			
		||||
       </property>
 | 
			
		||||
       <property name="scaledContents">
 | 
			
		||||
        <bool>true</bool>
 | 
			
		||||
       </property>
 | 
			
		||||
       <property name="alignment">
 | 
			
		||||
        <set>Qt::AlignCenter</set>
 | 
			
		||||
       </property>
 | 
			
		||||
      </widget>
 | 
			
		||||
     </item>
 | 
			
		||||
     <item>
 | 
			
		||||
      <layout class="QVBoxLayout" name="verticalLayout_2">
 | 
			
		||||
       <property name="rightMargin">
 | 
			
		||||
        <number>5</number>
 | 
			
		||||
       </property>
 | 
			
		||||
       <item>
 | 
			
		||||
        <widget class="QLabel" name="gameLabel">
 | 
			
		||||
         <property name="text">
 | 
			
		||||
          <string notr="true"><p><span style=" font-size:12pt; font-weight:600;">Game Name</span></p></string>
 | 
			
		||||
         </property>
 | 
			
		||||
        </widget>
 | 
			
		||||
       </item>
 | 
			
		||||
       <item>
 | 
			
		||||
        <layout class="QHBoxLayout" name="horizontalLayout_2">
 | 
			
		||||
         <item>
 | 
			
		||||
          <widget class="QLabel" name="sizeLabel">
 | 
			
		||||
           <property name="sizePolicy">
 | 
			
		||||
            <sizepolicy hsizetype="Minimum" vsizetype="Preferred">
 | 
			
		||||
             <horstretch>0</horstretch>
 | 
			
		||||
             <verstretch>0</verstretch>
 | 
			
		||||
            </sizepolicy>
 | 
			
		||||
           </property>
 | 
			
		||||
           <property name="minimumSize">
 | 
			
		||||
            <size>
 | 
			
		||||
             <width>90</width>
 | 
			
		||||
             <height>0</height>
 | 
			
		||||
            </size>
 | 
			
		||||
           </property>
 | 
			
		||||
           <property name="text">
 | 
			
		||||
            <string notr="true"><p><span style=" font-size:10pt;">0.00 GiB</span></p></string>
 | 
			
		||||
           </property>
 | 
			
		||||
          </widget>
 | 
			
		||||
         </item>
 | 
			
		||||
         <item>
 | 
			
		||||
          <widget class="QLabel" name="infoLabel">
 | 
			
		||||
           <property name="sizePolicy">
 | 
			
		||||
            <sizepolicy hsizetype="Expanding" vsizetype="Preferred">
 | 
			
		||||
             <horstretch>0</horstretch>
 | 
			
		||||
             <verstretch>0</verstretch>
 | 
			
		||||
            </sizepolicy>
 | 
			
		||||
           </property>
 | 
			
		||||
           <property name="text">
 | 
			
		||||
            <string notr="true"><html><head/><body><p><span style=" font-size:9pt;">[APP] [SAVE] [UPDATE] [DLC]</span></p></body></html></string>
 | 
			
		||||
           </property>
 | 
			
		||||
           <property name="alignment">
 | 
			
		||||
            <set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter</set>
 | 
			
		||||
           </property>
 | 
			
		||||
          </widget>
 | 
			
		||||
         </item>
 | 
			
		||||
        </layout>
 | 
			
		||||
       </item>
 | 
			
		||||
      </layout>
 | 
			
		||||
     </item>
 | 
			
		||||
     <item>
 | 
			
		||||
      <spacer name="horizontalSpacer">
 | 
			
		||||
       <property name="orientation">
 | 
			
		||||
        <enum>Qt::Horizontal</enum>
 | 
			
		||||
       </property>
 | 
			
		||||
       <property name="sizeHint" stdset="0">
 | 
			
		||||
        <size>
 | 
			
		||||
         <width>40</width>
 | 
			
		||||
         <height>20</height>
 | 
			
		||||
        </size>
 | 
			
		||||
       </property>
 | 
			
		||||
      </spacer>
 | 
			
		||||
     </item>
 | 
			
		||||
     <item>
 | 
			
		||||
      <widget class="QPushButton" name="deleteButton">
 | 
			
		||||
       <property name="sizePolicy">
 | 
			
		||||
        <sizepolicy hsizetype="Minimum" vsizetype="Fixed">
 | 
			
		||||
         <horstretch>0</horstretch>
 | 
			
		||||
         <verstretch>0</verstretch>
 | 
			
		||||
        </sizepolicy>
 | 
			
		||||
       </property>
 | 
			
		||||
       <property name="minimumSize">
 | 
			
		||||
        <size>
 | 
			
		||||
         <width>0</width>
 | 
			
		||||
         <height>32</height>
 | 
			
		||||
        </size>
 | 
			
		||||
       </property>
 | 
			
		||||
       <property name="text">
 | 
			
		||||
        <string>Delete entry</string>
 | 
			
		||||
       </property>
 | 
			
		||||
      </widget>
 | 
			
		||||
     </item>
 | 
			
		||||
     <item>
 | 
			
		||||
      <widget class="QPushButton" name="openButton">
 | 
			
		||||
       <property name="minimumSize">
 | 
			
		||||
        <size>
 | 
			
		||||
         <width>0</width>
 | 
			
		||||
         <height>32</height>
 | 
			
		||||
        </size>
 | 
			
		||||
       </property>
 | 
			
		||||
       <property name="text">
 | 
			
		||||
        <string>Open folder</string>
 | 
			
		||||
       </property>
 | 
			
		||||
      </widget>
 | 
			
		||||
     </item>
 | 
			
		||||
    </layout>
 | 
			
		||||
   </item>
 | 
			
		||||
  </layout>
 | 
			
		||||
 </widget>
 | 
			
		||||
 <resources/>
 | 
			
		||||
 <connections/>
 | 
			
		||||
</ui>
 | 
			
		||||
							
								
								
									
										257
									
								
								gui/forms/backupmanagerform.cpp
									
									
									
									
									
										Normal file
									
								
							
							
						
						@@ -0,0 +1,257 @@
 | 
			
		||||
/*
 | 
			
		||||
 *  QCMA: Cross-platform content manager assistant for the PS Vita
 | 
			
		||||
 *
 | 
			
		||||
 *  Copyright (C) 2013  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 "backupmanagerform.h"
 | 
			
		||||
#include "ui_backupmanagerform.h"
 | 
			
		||||
#include "cmaobject.h"
 | 
			
		||||
#include "sforeader.h"
 | 
			
		||||
#include "confirmdialog.h"
 | 
			
		||||
#include "cmautils.h"
 | 
			
		||||
#include "filterlineedit.h"
 | 
			
		||||
 | 
			
		||||
#include <QDebug>
 | 
			
		||||
#include <QDialogButtonBox>
 | 
			
		||||
#include <QDir>
 | 
			
		||||
#include <QSettings>
 | 
			
		||||
 | 
			
		||||
#include <vitamtp.h>
 | 
			
		||||
 | 
			
		||||
BackupManagerForm::BackupManagerForm(Database *db, QWidget *obj_parent) :
 | 
			
		||||
    QDialog(obj_parent), m_db(db),
 | 
			
		||||
    ui(new Ui::BackupManagerForm)
 | 
			
		||||
{
 | 
			
		||||
    ui->setupUi(this);
 | 
			
		||||
    setupForm();
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
BackupManagerForm::~BackupManagerForm()
 | 
			
		||||
{
 | 
			
		||||
    delete ui;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void BackupManagerForm::setupForm()
 | 
			
		||||
{
 | 
			
		||||
    this->resize(800, 480);
 | 
			
		||||
    connect(ui->backupComboBox, SIGNAL(currentIndexChanged(int)), this, SLOT(loadBackupListing(int)));
 | 
			
		||||
    ui->tableWidget->setVerticalScrollMode(QAbstractItemView::ScrollPerPixel);
 | 
			
		||||
    ui->tableWidget->horizontalHeader()->hide();
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void BackupManagerForm::removeEntry(BackupItem *item)
 | 
			
		||||
{
 | 
			
		||||
    ConfirmDialog msgBox;
 | 
			
		||||
 | 
			
		||||
    msgBox.setMessageText(tr("Are you sure to remove the backup of the following entry?"), item->title);
 | 
			
		||||
    msgBox.setMessagePixmap(*item->getIconPixmap(), item->getIconWidth());
 | 
			
		||||
 | 
			
		||||
    if(msgBox.exec() == 0) {
 | 
			
		||||
        return;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    QMutexLocker locker(&m_db->mutex);
 | 
			
		||||
 | 
			
		||||
    int parent_ohfi = m_db->getParentId(item->ohfi);
 | 
			
		||||
    removeRecursively(m_db->getAbsolutePath(item->ohfi));
 | 
			
		||||
    m_db->deleteEntry(item->ohfi);
 | 
			
		||||
 | 
			
		||||
    for(int i = 0; i < ui->tableWidget->rowCount(); ++i) {
 | 
			
		||||
        BackupItem *iter_item = static_cast<BackupItem *>(ui->tableWidget->cellWidget(i, 0));
 | 
			
		||||
        if(iter_item == item) {
 | 
			
		||||
            ui->tableWidget->removeRow(i);
 | 
			
		||||
            break;
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    if(parent_ohfi > 0) {
 | 
			
		||||
        setBackupUsage(m_db->getObjectSize(parent_ohfi));
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void BackupManagerForm::setBackupUsage(qint64 usage_size)
 | 
			
		||||
{
 | 
			
		||||
    ui->usageLabel->setText(tr("Backup disk usage: %1").arg(readable_size(usage_size, true)));
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void BackupManagerForm::loadBackupListing(int index)
 | 
			
		||||
{
 | 
			
		||||
    int ohfi;
 | 
			
		||||
    bool sys_dir;
 | 
			
		||||
    int img_width;
 | 
			
		||||
 | 
			
		||||
    //TODO: load all the accounts in the combobox
 | 
			
		||||
    ui->accountBox->clear();
 | 
			
		||||
    ui->accountBox->addItem(QSettings().value("lastOnlineId", tr("Default account")).toString());
 | 
			
		||||
 | 
			
		||||
    if(index < 0) {
 | 
			
		||||
        index = ui->backupComboBox->currentIndex();
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    ui->tableWidget->clear();
 | 
			
		||||
 | 
			
		||||
    switch(index) {
 | 
			
		||||
    case 0:
 | 
			
		||||
        ohfi = VITA_OHFI_VITAAPP;
 | 
			
		||||
        img_width = 48;
 | 
			
		||||
        sys_dir = true;
 | 
			
		||||
        break;
 | 
			
		||||
    case 1:
 | 
			
		||||
        ohfi = VITA_OHFI_PSPAPP;
 | 
			
		||||
        img_width = 80;
 | 
			
		||||
        sys_dir = true;
 | 
			
		||||
        break;
 | 
			
		||||
    case 2:
 | 
			
		||||
        ohfi = VITA_OHFI_PSMAPP;
 | 
			
		||||
        img_width = 48;
 | 
			
		||||
        sys_dir = true;
 | 
			
		||||
        break;
 | 
			
		||||
    case 3:
 | 
			
		||||
        ohfi = VITA_OHFI_PSXAPP;
 | 
			
		||||
        img_width = 48;
 | 
			
		||||
        sys_dir = true;
 | 
			
		||||
        break;
 | 
			
		||||
    case 4:
 | 
			
		||||
        ohfi = VITA_OHFI_PSPSAVE;
 | 
			
		||||
        img_width = 80;
 | 
			
		||||
        sys_dir = false;
 | 
			
		||||
        break;
 | 
			
		||||
    case 5:
 | 
			
		||||
        ohfi = VITA_OHFI_BACKUP;
 | 
			
		||||
        img_width = 48;
 | 
			
		||||
        sys_dir = false;
 | 
			
		||||
        break;
 | 
			
		||||
    default:
 | 
			
		||||
        ohfi = VITA_OHFI_VITAAPP;
 | 
			
		||||
        img_width = 48;
 | 
			
		||||
        sys_dir = true;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    m_db->mutex.lock();
 | 
			
		||||
 | 
			
		||||
    // get the item list
 | 
			
		||||
    metadata_t *meta = NULL;
 | 
			
		||||
    int row_count = m_db->getObjectMetadatas(ohfi, &meta);
 | 
			
		||||
    ui->tableWidget->setRowCount(row_count);
 | 
			
		||||
 | 
			
		||||
    // exit if there aren't any items
 | 
			
		||||
    if(row_count == 0) {
 | 
			
		||||
        setBackupUsage(0);
 | 
			
		||||
        m_db->mutex.unlock();
 | 
			
		||||
        return;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    // adjust the table item width to fill all the widget
 | 
			
		||||
    QHeaderView *vert_header = ui->tableWidget->verticalHeader();
 | 
			
		||||
    QHeaderView *horiz_header = ui->tableWidget->horizontalHeader();
 | 
			
		||||
#if QT_VERSION >= QT_VERSION_CHECK(5, 0, 0)
 | 
			
		||||
    horiz_header->setSectionResizeMode(QHeaderView::Stretch);
 | 
			
		||||
#else
 | 
			
		||||
    horiz_header->setResizeMode(QHeaderView::Stretch);
 | 
			
		||||
#endif
 | 
			
		||||
    qint64 backup_size = m_db->getObjectSize(ohfi);
 | 
			
		||||
    setBackupUsage(backup_size);
 | 
			
		||||
    QString path = m_db->getAbsolutePath(ohfi);
 | 
			
		||||
    QList<BackupItem *> item_list;
 | 
			
		||||
 | 
			
		||||
    metadata_t *first = meta;
 | 
			
		||||
    while(meta) {
 | 
			
		||||
        QString base_path = path + QDir::separator() + meta->name;
 | 
			
		||||
        QString parent_path = sys_dir ? base_path + QDir::separator() + "sce_sys" : base_path;
 | 
			
		||||
        SfoReader reader;
 | 
			
		||||
        QString game_name;
 | 
			
		||||
 | 
			
		||||
        // retrieve the game name from the SFO
 | 
			
		||||
        if(reader.load(QDir(parent_path).absoluteFilePath(sys_dir ? "param.sfo" : "PARAM.SFO"))) {
 | 
			
		||||
            game_name = QString::fromUtf8(reader.value("TITLE", meta->name));
 | 
			
		||||
        } else {
 | 
			
		||||
            game_name = QString(meta->name);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        BackupItem *item = new BackupItem();
 | 
			
		||||
        // save the game title and ohfi for sorting/deleting
 | 
			
		||||
        item->ohfi = meta->ohfi;
 | 
			
		||||
        item->title = game_name;
 | 
			
		||||
 | 
			
		||||
        connect(item, SIGNAL(deleteEntry(BackupItem*)), this, SLOT(removeEntry(BackupItem*)));
 | 
			
		||||
 | 
			
		||||
        // show better size info for multi GiB backups
 | 
			
		||||
        bool use_gb = ohfi == VITA_OHFI_BACKUP && meta->size > 1024*1024*1024;
 | 
			
		||||
        QString read_size = readable_size(meta->size, use_gb);
 | 
			
		||||
 | 
			
		||||
        QString info;
 | 
			
		||||
 | 
			
		||||
        // check if is listing PS Vita games
 | 
			
		||||
        if(index == 0) {
 | 
			
		||||
            if(QDir(base_path + QDir::separator() + "app").exists()) {
 | 
			
		||||
                info.append(tr(" [GAME]"));
 | 
			
		||||
            }
 | 
			
		||||
            if(QDir(base_path + QDir::separator() + "savedata").exists()) {
 | 
			
		||||
                info.append(tr(" [SAVE]"));
 | 
			
		||||
            }
 | 
			
		||||
            if(QDir(base_path + QDir::separator() + "patch").exists()) {
 | 
			
		||||
                info.append(tr(" [UPDATE]"));
 | 
			
		||||
            }
 | 
			
		||||
            if(QDir(base_path + QDir::separator() + "addcont").exists()) {
 | 
			
		||||
                info.append(tr(" [DLC]"));
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        item->setItemInfo(game_name, read_size, info);
 | 
			
		||||
        item->setItemIcon(QDir(parent_path).absoluteFilePath(sys_dir ? "icon0.png" : "ICON0.PNG"), img_width, ohfi == VITA_OHFI_PSMAPP);
 | 
			
		||||
        item->setDirectory(path + QDir::separator() + meta->name);
 | 
			
		||||
        item->resize(646, 68);
 | 
			
		||||
 | 
			
		||||
        item_list << item;
 | 
			
		||||
        meta = meta->next_metadata;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    m_db->freeMetadata(first);
 | 
			
		||||
 | 
			
		||||
    qSort(item_list.begin(), item_list.end(), BackupItem::lessThan);
 | 
			
		||||
 | 
			
		||||
    int row;
 | 
			
		||||
    QList<BackupItem *>::iterator it;
 | 
			
		||||
    vert_header->setUpdatesEnabled(false);
 | 
			
		||||
 | 
			
		||||
    // insert the sorted items into the table
 | 
			
		||||
    for(it = item_list.begin(), row = 0; it != item_list.end(); ++it, ++row) {
 | 
			
		||||
        ui->tableWidget->setCellWidget(row, 0, *it);
 | 
			
		||||
        vert_header->resizeSection(row, 68);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    vert_header->setUpdatesEnabled(true);
 | 
			
		||||
    m_db->mutex.unlock();
 | 
			
		||||
 | 
			
		||||
    // apply filter
 | 
			
		||||
    this->on_filterLineEdit_textChanged(ui->filterLineEdit->text());
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void BackupManagerForm::on_filterLineEdit_textChanged(const QString &arg1)
 | 
			
		||||
{
 | 
			
		||||
    if(arg1 != tr("Filter")) {
 | 
			
		||||
        for(int i = 0; i < ui->tableWidget->rowCount(); ++i) {
 | 
			
		||||
            BackupItem *item = (BackupItem*) ui->tableWidget->cellWidget(i, 0);
 | 
			
		||||
 | 
			
		||||
            if(item->title.contains(arg1, Qt::CaseInsensitive)) {
 | 
			
		||||
                ui->tableWidget->setRowHidden(i, false);
 | 
			
		||||
            } else {
 | 
			
		||||
                ui->tableWidget->setRowHidden(i, true);
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
							
								
								
									
										55
									
								
								gui/forms/backupmanagerform.h
									
									
									
									
									
										Normal file
									
								
							
							
						
						@@ -0,0 +1,55 @@
 | 
			
		||||
/*
 | 
			
		||||
 *  QCMA: Cross-platform content manager assistant for the PS Vita
 | 
			
		||||
 *
 | 
			
		||||
 *  Copyright (C) 2013  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 BACKUPMANAGERFORM_H
 | 
			
		||||
#define BACKUPMANAGERFORM_H
 | 
			
		||||
 | 
			
		||||
#include "database.h"
 | 
			
		||||
#include "backupitem.h"
 | 
			
		||||
 | 
			
		||||
#include <QDialog>
 | 
			
		||||
 | 
			
		||||
namespace Ui {
 | 
			
		||||
class BackupManagerForm;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
class BackupManagerForm : public QDialog
 | 
			
		||||
{
 | 
			
		||||
    Q_OBJECT
 | 
			
		||||
 | 
			
		||||
public:
 | 
			
		||||
    explicit BackupManagerForm(Database *db, QWidget *parent = 0);
 | 
			
		||||
    ~BackupManagerForm();
 | 
			
		||||
 | 
			
		||||
    Database *m_db;
 | 
			
		||||
 | 
			
		||||
private:
 | 
			
		||||
    void setupForm();
 | 
			
		||||
    void setBackupUsage(qint64 size);
 | 
			
		||||
 | 
			
		||||
    Ui::BackupManagerForm *ui;
 | 
			
		||||
 | 
			
		||||
public slots:
 | 
			
		||||
    void loadBackupListing(int index);
 | 
			
		||||
    void removeEntry(BackupItem *item);
 | 
			
		||||
private slots:
 | 
			
		||||
    void on_filterLineEdit_textChanged(const QString &arg1);
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
#endif // BACKUPMANAGERFORM_H
 | 
			
		||||
							
								
								
									
										139
									
								
								gui/forms/backupmanagerform.ui
									
									
									
									
									
										Normal file
									
								
							
							
						
						@@ -0,0 +1,139 @@
 | 
			
		||||
<?xml version="1.0" encoding="UTF-8"?>
 | 
			
		||||
<ui version="4.0">
 | 
			
		||||
 <class>BackupManagerForm</class>
 | 
			
		||||
 <widget class="QWidget" name="BackupManagerForm">
 | 
			
		||||
  <property name="geometry">
 | 
			
		||||
   <rect>
 | 
			
		||||
    <x>0</x>
 | 
			
		||||
    <y>0</y>
 | 
			
		||||
    <width>857</width>
 | 
			
		||||
    <height>478</height>
 | 
			
		||||
   </rect>
 | 
			
		||||
  </property>
 | 
			
		||||
  <property name="windowTitle">
 | 
			
		||||
   <string>Backup Manager</string>
 | 
			
		||||
  </property>
 | 
			
		||||
  <layout class="QGridLayout" name="gridLayout">
 | 
			
		||||
   <item row="0" column="0">
 | 
			
		||||
    <layout class="QHBoxLayout" name="horizontalLayout_3">
 | 
			
		||||
     <item>
 | 
			
		||||
      <layout class="QFormLayout" name="formLayout_3">
 | 
			
		||||
       <item row="0" column="0">
 | 
			
		||||
        <widget class="QLabel" name="label_3">
 | 
			
		||||
         <property name="text">
 | 
			
		||||
          <string>Online ID / Username</string>
 | 
			
		||||
         </property>
 | 
			
		||||
        </widget>
 | 
			
		||||
       </item>
 | 
			
		||||
       <item row="0" column="1">
 | 
			
		||||
        <widget class="QComboBox" name="accountBox"/>
 | 
			
		||||
       </item>
 | 
			
		||||
      </layout>
 | 
			
		||||
     </item>
 | 
			
		||||
     <item>
 | 
			
		||||
      <layout class="QFormLayout" name="formLayout_4">
 | 
			
		||||
       <property name="fieldGrowthPolicy">
 | 
			
		||||
        <enum>QFormLayout::AllNonFixedFieldsGrow</enum>
 | 
			
		||||
       </property>
 | 
			
		||||
       <item row="0" column="0">
 | 
			
		||||
        <widget class="QLabel" name="label_4">
 | 
			
		||||
         <property name="text">
 | 
			
		||||
          <string>Backup Type</string>
 | 
			
		||||
         </property>
 | 
			
		||||
         <property name="margin">
 | 
			
		||||
          <number>2</number>
 | 
			
		||||
         </property>
 | 
			
		||||
        </widget>
 | 
			
		||||
       </item>
 | 
			
		||||
       <item row="0" column="1">
 | 
			
		||||
        <widget class="QComboBox" name="backupComboBox">
 | 
			
		||||
         <item>
 | 
			
		||||
          <property name="text">
 | 
			
		||||
           <string>PS Vita Games</string>
 | 
			
		||||
          </property>
 | 
			
		||||
         </item>
 | 
			
		||||
         <item>
 | 
			
		||||
          <property name="text">
 | 
			
		||||
           <string>PSP Games</string>
 | 
			
		||||
          </property>
 | 
			
		||||
         </item>
 | 
			
		||||
         <item>
 | 
			
		||||
          <property name="text">
 | 
			
		||||
           <string>PSM Games</string>
 | 
			
		||||
          </property>
 | 
			
		||||
         </item>
 | 
			
		||||
         <item>
 | 
			
		||||
          <property name="text">
 | 
			
		||||
           <string>PSOne Games</string>
 | 
			
		||||
          </property>
 | 
			
		||||
         </item>
 | 
			
		||||
         <item>
 | 
			
		||||
          <property name="text">
 | 
			
		||||
           <string>PSP Savedatas</string>
 | 
			
		||||
          </property>
 | 
			
		||||
         </item>
 | 
			
		||||
         <item>
 | 
			
		||||
          <property name="text">
 | 
			
		||||
           <string>Backups</string>
 | 
			
		||||
          </property>
 | 
			
		||||
         </item>
 | 
			
		||||
        </widget>
 | 
			
		||||
       </item>
 | 
			
		||||
      </layout>
 | 
			
		||||
     </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>
 | 
			
		||||
      <widget class="QLabel" name="usageLabel">
 | 
			
		||||
       <property name="text">
 | 
			
		||||
        <string>Backup disk usage</string>
 | 
			
		||||
       </property>
 | 
			
		||||
      </widget>
 | 
			
		||||
     </item>
 | 
			
		||||
     <item>
 | 
			
		||||
      <spacer name="horizontalSpacer">
 | 
			
		||||
       <property name="orientation">
 | 
			
		||||
        <enum>Qt::Horizontal</enum>
 | 
			
		||||
       </property>
 | 
			
		||||
       <property name="sizeHint" stdset="0">
 | 
			
		||||
        <size>
 | 
			
		||||
         <width>40</width>
 | 
			
		||||
         <height>20</height>
 | 
			
		||||
        </size>
 | 
			
		||||
       </property>
 | 
			
		||||
      </spacer>
 | 
			
		||||
     </item>
 | 
			
		||||
     <item>
 | 
			
		||||
      <widget class="FilterLineEdit" name="filterLineEdit">
 | 
			
		||||
       <property name="styleSheet">
 | 
			
		||||
        <string notr="true">FilterLineEdit { color:gray; font-style:italic; }</string>
 | 
			
		||||
       </property>
 | 
			
		||||
       <property name="text">
 | 
			
		||||
        <string>Filter</string>
 | 
			
		||||
       </property>
 | 
			
		||||
      </widget>
 | 
			
		||||
     </item>
 | 
			
		||||
    </layout>
 | 
			
		||||
   </item>
 | 
			
		||||
  </layout>
 | 
			
		||||
 </widget>
 | 
			
		||||
 <customwidgets>
 | 
			
		||||
  <customwidget>
 | 
			
		||||
   <class>FilterLineEdit</class>
 | 
			
		||||
   <extends>QLineEdit</extends>
 | 
			
		||||
   <header>filterlineedit.h</header>
 | 
			
		||||
  </customwidget>
 | 
			
		||||
 </customwidgets>
 | 
			
		||||
 <resources/>
 | 
			
		||||
 <connections/>
 | 
			
		||||
</ui>
 | 
			
		||||
							
								
								
									
										249
									
								
								gui/forms/configwidget.cpp
									
									
									
									
									
										Normal file
									
								
							
							
						
						@@ -0,0 +1,249 @@
 | 
			
		||||
/*
 | 
			
		||||
 *  QCMA: Cross-platform content manager assistant for the PS Vita
 | 
			
		||||
 *
 | 
			
		||||
 *  Copyright (C) 2013  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 "configwidget.h"
 | 
			
		||||
#include "ui_configwidget.h"
 | 
			
		||||
 | 
			
		||||
extern "C" {
 | 
			
		||||
#include <vitamtp.h>
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
#include <QFileDialog>
 | 
			
		||||
#include <QSettings>
 | 
			
		||||
 | 
			
		||||
#if QT_VERSION >= QT_VERSION_CHECK(5, 0, 0)
 | 
			
		||||
#include <QStandardPaths>
 | 
			
		||||
#else
 | 
			
		||||
#include <QDesktopServices>
 | 
			
		||||
#define QStandardPaths QDesktopServices
 | 
			
		||||
#define writableLocation storageLocation
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
ConfigWidget::ConfigWidget(QWidget *obj_parent) :
 | 
			
		||||
    QDialog(obj_parent),
 | 
			
		||||
    ui(new Ui::ConfigWidget)
 | 
			
		||||
{
 | 
			
		||||
    ui->setupUi(this);
 | 
			
		||||
    connectSignals();
 | 
			
		||||
    setDefaultData();
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void ConfigWidget::connectSignals()
 | 
			
		||||
{
 | 
			
		||||
    QSignalMapper *mapper = new QSignalMapper(this);
 | 
			
		||||
    mapper->setMapping(ui->photoBtn, BTN_PHOTO);
 | 
			
		||||
    mapper->setMapping(ui->musicBtn, BTN_MUSIC);
 | 
			
		||||
    mapper->setMapping(ui->videoBtn, BTN_VIDEO);
 | 
			
		||||
    mapper->setMapping(ui->appBtn, BTN_APPS);
 | 
			
		||||
    mapper->setMapping(ui->urlBtn, BTN_URL);
 | 
			
		||||
    mapper->setMapping(ui->pkgBtn, BTN_PKG);
 | 
			
		||||
    connect(ui->photoBtn, SIGNAL(clicked()), mapper, SLOT(map()));
 | 
			
		||||
    connect(ui->musicBtn, SIGNAL(clicked()), mapper, SLOT(map()));
 | 
			
		||||
    connect(ui->videoBtn, SIGNAL(clicked()), mapper, SLOT(map()));
 | 
			
		||||
    connect(ui->appBtn, SIGNAL(clicked()), mapper, SLOT(map()));
 | 
			
		||||
    connect(ui->urlBtn, SIGNAL(clicked()), mapper, SLOT(map()));
 | 
			
		||||
    connect(ui->pkgBtn, SIGNAL(clicked()), mapper, SLOT(map()));
 | 
			
		||||
    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->protocolModeBox, SIGNAL(currentIndexChanged(int)), this, SLOT(protocolModeChanged(int)));
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void ConfigWidget::protocolModeChanged(int index)
 | 
			
		||||
{
 | 
			
		||||
    switch(index)
 | 
			
		||||
    {
 | 
			
		||||
    case 0:
 | 
			
		||||
        ui->protocolBox->setEnabled(false);
 | 
			
		||||
        ui->protocolEdit->setEnabled(false);
 | 
			
		||||
        break;
 | 
			
		||||
    case 1:
 | 
			
		||||
        ui->protocolBox->setEnabled(true);
 | 
			
		||||
        ui->protocolEdit->setEnabled(false);
 | 
			
		||||
        break;
 | 
			
		||||
    case 2:
 | 
			
		||||
        ui->protocolBox->setEnabled(false);
 | 
			
		||||
        ui->protocolEdit->setEnabled(true);
 | 
			
		||||
        break;
 | 
			
		||||
    default:
 | 
			
		||||
        ui->protocolBox->setEnabled(false);
 | 
			
		||||
        ui->protocolEdit->setEnabled(false);
 | 
			
		||||
        break;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void ConfigWidget::setDefaultData()
 | 
			
		||||
{
 | 
			
		||||
    QString defaultdir;
 | 
			
		||||
    QSettings settings;
 | 
			
		||||
    defaultdir = QStandardPaths::writableLocation(QStandardPaths::PicturesLocation);
 | 
			
		||||
    ui->photoPath->setText(QDir::toNativeSeparators(settings.value("photoPath", defaultdir).toString()));
 | 
			
		||||
 | 
			
		||||
    defaultdir = QStandardPaths::writableLocation(QStandardPaths::MusicLocation);
 | 
			
		||||
    ui->musicPath->setText(QDir::toNativeSeparators(settings.value("musicPath", defaultdir).toString()));
 | 
			
		||||
 | 
			
		||||
    defaultdir = QStandardPaths::writableLocation(QStandardPaths::MoviesLocation);
 | 
			
		||||
    ui->videoPath->setText(QDir::toNativeSeparators(settings.value("videoPath", defaultdir).toString()));
 | 
			
		||||
 | 
			
		||||
    defaultdir = QStandardPaths::writableLocation(QStandardPaths::HomeLocation);
 | 
			
		||||
    defaultdir.append(QDir::separator()).append("PS Vita");
 | 
			
		||||
    ui->appPath->setText(QDir::toNativeSeparators(settings.value("appsPath", defaultdir).toString()));
 | 
			
		||||
 | 
			
		||||
    defaultdir = QStandardPaths::writableLocation(QStandardPaths::HomeLocation);
 | 
			
		||||
    defaultdir.append(QDir::separator()).append("PSV Updates");
 | 
			
		||||
    ui->urlPath->setText(QDir::toNativeSeparators(settings.value("urlPath", defaultdir).toString()));
 | 
			
		||||
 | 
			
		||||
    defaultdir = QStandardPaths::writableLocation(QStandardPaths::HomeLocation);
 | 
			
		||||
    defaultdir.append(QDir::separator()).append("PSV Packages");
 | 
			
		||||
    ui->pkgPath->setText(QDir::toNativeSeparators(settings.value("pkgPath", defaultdir).toString()));
 | 
			
		||||
 | 
			
		||||
    ui->offlineCheck->setChecked(settings.value("offlineMode", true).toBool());
 | 
			
		||||
    ui->metadataCheck->setChecked(settings.value("skipMetadata", false).toBool());
 | 
			
		||||
    ui->usbCheck->setChecked(settings.value("disableUSB", false).toBool());
 | 
			
		||||
    ui->wifiCheck->setChecked(settings.value("disableWireless", false).toBool());
 | 
			
		||||
    ui->databaseSelect->setCurrentIndex(settings.value("useMemoryStorage", true).toBool() ? 0 : 1);
 | 
			
		||||
 | 
			
		||||
    ui->photoSkipCheck->setChecked(settings.value("photoSkip", false).toBool());
 | 
			
		||||
    ui->videoSkipCheck->setChecked(settings.value("videoSkip", false).toBool());
 | 
			
		||||
    ui->musicSkipCheck->setChecked(settings.value("musicSkip", false).toBool());
 | 
			
		||||
 | 
			
		||||
    QString protocol_mode = settings.value("protocolMode", "automatic").toString();
 | 
			
		||||
 | 
			
		||||
    if(protocol_mode == "manual")
 | 
			
		||||
        ui->protocolModeBox->setCurrentIndex(1);
 | 
			
		||||
    else if(protocol_mode == "custom")
 | 
			
		||||
        ui->protocolModeBox->setCurrentIndex(2);
 | 
			
		||||
    else
 | 
			
		||||
        ui->protocolModeBox->setCurrentIndex(0);
 | 
			
		||||
 | 
			
		||||
    protocolModeChanged(ui->protocolModeBox->currentIndex());
 | 
			
		||||
 | 
			
		||||
    ui->protocolBox->setCurrentIndex(settings.value("protocolIndex", 0).toInt());
 | 
			
		||||
 | 
			
		||||
    bool ok;
 | 
			
		||||
    int protocol_version = settings.value("protocolVersion", VITAMTP_PROTOCOL_MAX_VERSION).toInt(&ok);
 | 
			
		||||
 | 
			
		||||
    if(ok && protocol_version > 0)
 | 
			
		||||
        ui->protocolEdit->setText(QString::number(protocol_version));
 | 
			
		||||
    else
 | 
			
		||||
        ui->protocolEdit->setText(QString::number(VITAMTP_PROTOCOL_MAX_VERSION));
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
ConfigWidget::~ConfigWidget()
 | 
			
		||||
{
 | 
			
		||||
    delete ui;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void ConfigWidget::browseBtnPressed(int btn)
 | 
			
		||||
{
 | 
			
		||||
    QString msg;
 | 
			
		||||
    QLineEdit *lineedit;
 | 
			
		||||
 | 
			
		||||
    switch(btn) {
 | 
			
		||||
    case BTN_PHOTO:
 | 
			
		||||
        lineedit = ui->photoPath;
 | 
			
		||||
        msg = tr("Select the folder to be used as a photo source");
 | 
			
		||||
        break;
 | 
			
		||||
 | 
			
		||||
    case BTN_MUSIC:
 | 
			
		||||
        lineedit = ui->musicPath;
 | 
			
		||||
        msg = tr("Select the folder to be used as a music source");
 | 
			
		||||
        break;
 | 
			
		||||
 | 
			
		||||
    case BTN_VIDEO:
 | 
			
		||||
        lineedit = ui->videoPath;
 | 
			
		||||
        msg = tr("Select the folder to be used as a video source");
 | 
			
		||||
        break;
 | 
			
		||||
 | 
			
		||||
    case BTN_APPS:
 | 
			
		||||
        lineedit = ui->appPath;
 | 
			
		||||
        msg = tr("Select the folder to be used to save PS Vita games and backups");
 | 
			
		||||
        break;
 | 
			
		||||
 | 
			
		||||
    case BTN_URL:
 | 
			
		||||
        lineedit = ui->urlPath;
 | 
			
		||||
        msg = tr("Select the folder to be used to fetch software updates");
 | 
			
		||||
        break;
 | 
			
		||||
 | 
			
		||||
    case BTN_PKG:
 | 
			
		||||
        lineedit = ui->pkgPath;
 | 
			
		||||
        msg = tr("Select the folder to be used to software packages");
 | 
			
		||||
        break;
 | 
			
		||||
 | 
			
		||||
    default:
 | 
			
		||||
        return;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    QString selected = QFileDialog::getExistingDirectory(this, msg, lineedit->text(), QFileDialog::ShowDirsOnly);
 | 
			
		||||
 | 
			
		||||
    if(!selected.isEmpty()) {
 | 
			
		||||
        lineedit->setText(QDir::toNativeSeparators((selected)));
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void ConfigWidget::savePath(QSettings &settings, const QLineEdit *edit, const QString &key)
 | 
			
		||||
{
 | 
			
		||||
    QString path = edit->text();
 | 
			
		||||
    if(path.endsWith(QDir::separator())) {
 | 
			
		||||
        path.chop(1);
 | 
			
		||||
    }
 | 
			
		||||
    settings.setValue(key, QDir::fromNativeSeparators(path));
 | 
			
		||||
    QDir(QDir::root()).mkpath(path);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void ConfigWidget::accept()
 | 
			
		||||
{
 | 
			
		||||
    QSettings settings;
 | 
			
		||||
    savePath(settings, ui->photoPath, "photoPath");
 | 
			
		||||
    savePath(settings, ui->musicPath, "musicPath");
 | 
			
		||||
    savePath(settings, ui->videoPath, "videoPath");
 | 
			
		||||
    savePath(settings, ui->appPath, "appsPath");
 | 
			
		||||
    savePath(settings, ui->urlPath, "urlPath");
 | 
			
		||||
    savePath(settings, ui->pkgPath, "pkgPath");
 | 
			
		||||
    settings.setValue("offlineMode", ui->offlineCheck->isChecked());
 | 
			
		||||
    settings.setValue("skipMetadata", ui->metadataCheck->isChecked());
 | 
			
		||||
    settings.setValue("disableUSB", ui->usbCheck->isChecked());
 | 
			
		||||
    settings.setValue("disableWireless", ui->wifiCheck->isChecked());
 | 
			
		||||
    settings.setValue("useMemoryStorage", ui->databaseSelect->currentIndex() == 0);
 | 
			
		||||
    settings.setValue("photoSkip", ui->photoSkipCheck->isChecked());
 | 
			
		||||
    settings.setValue("videoSkip", ui->videoSkipCheck->isChecked());
 | 
			
		||||
    settings.setValue("musicSkip", ui->musicSkipCheck->isChecked());
 | 
			
		||||
    settings.setValue("protocolIndex", ui->protocolBox->currentIndex());
 | 
			
		||||
 | 
			
		||||
    if(ui->protocolModeBox->currentIndex() == 0)
 | 
			
		||||
        settings.setValue("protocolMode", "automatic");
 | 
			
		||||
    else if(ui->protocolModeBox->currentIndex() == 1)
 | 
			
		||||
        settings.setValue("protocolMode", "manual");
 | 
			
		||||
    else if(ui->protocolModeBox->currentIndex() == 2)
 | 
			
		||||
        settings.setValue("protocolMode", "custom");
 | 
			
		||||
 | 
			
		||||
    bool ok;
 | 
			
		||||
    int protocol = ui->protocolEdit->text().toInt(&ok);
 | 
			
		||||
 | 
			
		||||
    if(ok && protocol > 0)
 | 
			
		||||
        settings.setValue("protocolVersion", protocol);
 | 
			
		||||
    else
 | 
			
		||||
        settings.setValue("protocolVersion", VITAMTP_PROTOCOL_MAX_VERSION);
 | 
			
		||||
 | 
			
		||||
    settings.sync();
 | 
			
		||||
 | 
			
		||||
    done(Accepted);
 | 
			
		||||
}
 | 
			
		||||
							
								
								
									
										55
									
								
								gui/forms/configwidget.h
									
									
									
									
									
										Normal file
									
								
							
							
						
						@@ -0,0 +1,55 @@
 | 
			
		||||
/*
 | 
			
		||||
 *  QCMA: Cross-platform content manager assistant for the PS Vita
 | 
			
		||||
 *
 | 
			
		||||
 *  Copyright (C) 2013  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 CONFIGWIDGET_H
 | 
			
		||||
#define CONFIGWIDGET_H
 | 
			
		||||
 | 
			
		||||
#include <QDialog>
 | 
			
		||||
#include <QLineEdit>
 | 
			
		||||
#include <QSettings>
 | 
			
		||||
#include <QSignalMapper>
 | 
			
		||||
 | 
			
		||||
namespace Ui {
 | 
			
		||||
class ConfigWidget;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
class ConfigWidget : public QDialog
 | 
			
		||||
{
 | 
			
		||||
    Q_OBJECT
 | 
			
		||||
 | 
			
		||||
public:
 | 
			
		||||
    explicit ConfigWidget(QWidget *parent = 0);
 | 
			
		||||
    ~ConfigWidget();
 | 
			
		||||
 | 
			
		||||
private:
 | 
			
		||||
    enum browse_buttons {BTN_PHOTO, BTN_MUSIC, BTN_VIDEO, BTN_APPS, BTN_URL, BTN_PKG};
 | 
			
		||||
 | 
			
		||||
    void connectSignals();
 | 
			
		||||
    void setDefaultData();
 | 
			
		||||
    void savePath(QSettings &settings, const QLineEdit *edit, const QString &key);
 | 
			
		||||
 | 
			
		||||
    Ui::ConfigWidget *ui;
 | 
			
		||||
 | 
			
		||||
private slots:
 | 
			
		||||
    void protocolModeChanged(int index);
 | 
			
		||||
    void browseBtnPressed(int from);
 | 
			
		||||
    void accept();
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
#endif // CONFIGWIDGET_H
 | 
			
		||||
							
								
								
									
										525
									
								
								gui/forms/configwidget.ui
									
									
									
									
									
										Normal file
									
								
							
							
						
						@@ -0,0 +1,525 @@
 | 
			
		||||
<?xml version="1.0" encoding="UTF-8"?>
 | 
			
		||||
<ui version="4.0">
 | 
			
		||||
 <class>ConfigWidget</class>
 | 
			
		||||
 <widget class="QWidget" name="ConfigWidget">
 | 
			
		||||
  <property name="geometry">
 | 
			
		||||
   <rect>
 | 
			
		||||
    <x>0</x>
 | 
			
		||||
    <y>0</y>
 | 
			
		||||
    <width>519</width>
 | 
			
		||||
    <height>525</height>
 | 
			
		||||
   </rect>
 | 
			
		||||
  </property>
 | 
			
		||||
  <property name="windowTitle">
 | 
			
		||||
   <string>QCMA Settings</string>
 | 
			
		||||
  </property>
 | 
			
		||||
  <layout class="QGridLayout" name="gridLayout">
 | 
			
		||||
   <item row="0" column="0">
 | 
			
		||||
    <layout class="QVBoxLayout" name="verticalLayout">
 | 
			
		||||
     <item>
 | 
			
		||||
      <widget class="QTabWidget" name="tabWidget">
 | 
			
		||||
       <property name="currentIndex">
 | 
			
		||||
        <number>0</number>
 | 
			
		||||
       </property>
 | 
			
		||||
       <widget class="QWidget" name="tab">
 | 
			
		||||
        <attribute name="title">
 | 
			
		||||
         <string>Folders</string>
 | 
			
		||||
        </attribute>
 | 
			
		||||
        <layout class="QGridLayout" name="gridLayout_2">
 | 
			
		||||
         <item row="1" column="0">
 | 
			
		||||
          <layout class="QVBoxLayout" name="verticalLayout_2">
 | 
			
		||||
           <item>
 | 
			
		||||
            <widget class="QLabel" name="label">
 | 
			
		||||
             <property name="font">
 | 
			
		||||
              <font>
 | 
			
		||||
               <pointsize>10</pointsize>
 | 
			
		||||
              </font>
 | 
			
		||||
             </property>
 | 
			
		||||
             <property name="text">
 | 
			
		||||
              <string>Specify the folders that the PS Vita will access for each content type.</string>
 | 
			
		||||
             </property>
 | 
			
		||||
             <property name="wordWrap">
 | 
			
		||||
              <bool>true</bool>
 | 
			
		||||
             </property>
 | 
			
		||||
            </widget>
 | 
			
		||||
           </item>
 | 
			
		||||
           <item>
 | 
			
		||||
            <layout class="QVBoxLayout" name="verticalLayout_3">
 | 
			
		||||
             <item>
 | 
			
		||||
              <widget class="QLabel" name="label_2">
 | 
			
		||||
               <property name="whatsThis">
 | 
			
		||||
                <string>This is the location your Screenshots and Pictures are Saved to/Imported from.</string>
 | 
			
		||||
               </property>
 | 
			
		||||
               <property name="text">
 | 
			
		||||
                <string>Photo Folder</string>
 | 
			
		||||
               </property>
 | 
			
		||||
              </widget>
 | 
			
		||||
             </item>
 | 
			
		||||
             <item>
 | 
			
		||||
              <layout class="QHBoxLayout" name="horizontalLayout_7">
 | 
			
		||||
               <item>
 | 
			
		||||
                <widget class="QLineEdit" name="photoPath">
 | 
			
		||||
                 <property name="toolTip">
 | 
			
		||||
                  <string>This is the location your Screenshots and Pictures are Saved to/Imported from.</string>
 | 
			
		||||
                 </property>
 | 
			
		||||
                 <property name="readOnly">
 | 
			
		||||
                  <bool>true</bool>
 | 
			
		||||
                 </property>
 | 
			
		||||
                </widget>
 | 
			
		||||
               </item>
 | 
			
		||||
               <item>
 | 
			
		||||
                <widget class="QPushButton" name="photoBtn">
 | 
			
		||||
                 <property name="text">
 | 
			
		||||
                  <string>Browse...</string>
 | 
			
		||||
                 </property>
 | 
			
		||||
                </widget>
 | 
			
		||||
               </item>
 | 
			
		||||
              </layout>
 | 
			
		||||
             </item>
 | 
			
		||||
            </layout>
 | 
			
		||||
           </item>
 | 
			
		||||
           <item>
 | 
			
		||||
            <layout class="QVBoxLayout" name="verticalLayout_4">
 | 
			
		||||
             <item>
 | 
			
		||||
              <widget class="QLabel" name="label_3">
 | 
			
		||||
               <property name="whatsThis">
 | 
			
		||||
                <string>This is the location your Videos are Saved to/Imported from.</string>
 | 
			
		||||
               </property>
 | 
			
		||||
               <property name="text">
 | 
			
		||||
                <string>Video Folder</string>
 | 
			
		||||
               </property>
 | 
			
		||||
              </widget>
 | 
			
		||||
             </item>
 | 
			
		||||
             <item>
 | 
			
		||||
              <layout class="QHBoxLayout" name="horizontalLayout_8">
 | 
			
		||||
               <item>
 | 
			
		||||
                <widget class="QLineEdit" name="videoPath">
 | 
			
		||||
                 <property name="toolTip">
 | 
			
		||||
                  <string>This is the location your Videos are Saved to/Imported from.</string>
 | 
			
		||||
                 </property>
 | 
			
		||||
                 <property name="readOnly">
 | 
			
		||||
                  <bool>true</bool>
 | 
			
		||||
                 </property>
 | 
			
		||||
                </widget>
 | 
			
		||||
               </item>
 | 
			
		||||
               <item>
 | 
			
		||||
                <widget class="QPushButton" name="videoBtn">
 | 
			
		||||
                 <property name="text">
 | 
			
		||||
                  <string>Browse...</string>
 | 
			
		||||
                 </property>
 | 
			
		||||
                </widget>
 | 
			
		||||
               </item>
 | 
			
		||||
              </layout>
 | 
			
		||||
             </item>
 | 
			
		||||
            </layout>
 | 
			
		||||
           </item>
 | 
			
		||||
           <item>
 | 
			
		||||
            <layout class="QVBoxLayout" name="verticalLayout_5">
 | 
			
		||||
             <item>
 | 
			
		||||
              <widget class="QLabel" name="label_4">
 | 
			
		||||
               <property name="whatsThis">
 | 
			
		||||
                <string>This is the location your Music is Saved to/Imported from.</string>
 | 
			
		||||
               </property>
 | 
			
		||||
               <property name="text">
 | 
			
		||||
                <string>Music Folder</string>
 | 
			
		||||
               </property>
 | 
			
		||||
              </widget>
 | 
			
		||||
             </item>
 | 
			
		||||
             <item>
 | 
			
		||||
              <layout class="QHBoxLayout" name="horizontalLayout_9">
 | 
			
		||||
               <item>
 | 
			
		||||
                <widget class="QLineEdit" name="musicPath">
 | 
			
		||||
                 <property name="toolTip">
 | 
			
		||||
                  <string>This is the location your Music is Saved to/Imported from.</string>
 | 
			
		||||
                 </property>
 | 
			
		||||
                 <property name="readOnly">
 | 
			
		||||
                  <bool>true</bool>
 | 
			
		||||
                 </property>
 | 
			
		||||
                </widget>
 | 
			
		||||
               </item>
 | 
			
		||||
               <item>
 | 
			
		||||
                <widget class="QPushButton" name="musicBtn">
 | 
			
		||||
                 <property name="text">
 | 
			
		||||
                  <string>Browse...</string>
 | 
			
		||||
                 </property>
 | 
			
		||||
                </widget>
 | 
			
		||||
               </item>
 | 
			
		||||
              </layout>
 | 
			
		||||
             </item>
 | 
			
		||||
            </layout>
 | 
			
		||||
           </item>
 | 
			
		||||
           <item>
 | 
			
		||||
            <layout class="QVBoxLayout" name="verticalLayout_7">
 | 
			
		||||
             <item>
 | 
			
		||||
              <widget class="QLabel" name="label_6">
 | 
			
		||||
               <property name="whatsThis">
 | 
			
		||||
                <string>This is the location your Games, Apps, Savegames, and System Backups are Saved to/Imported from.</string>
 | 
			
		||||
               </property>
 | 
			
		||||
               <property name="text">
 | 
			
		||||
                <string>Applications / Backups</string>
 | 
			
		||||
               </property>
 | 
			
		||||
              </widget>
 | 
			
		||||
             </item>
 | 
			
		||||
             <item>
 | 
			
		||||
              <layout class="QHBoxLayout" name="horizontalLayout_2">
 | 
			
		||||
               <item>
 | 
			
		||||
                <widget class="QLineEdit" name="appPath">
 | 
			
		||||
                 <property name="toolTip">
 | 
			
		||||
                  <string>This is the location your Games, Apps, Savegames, and System Backups are Saved to/Imported from.</string>
 | 
			
		||||
                 </property>
 | 
			
		||||
                 <property name="readOnly">
 | 
			
		||||
                  <bool>true</bool>
 | 
			
		||||
                 </property>
 | 
			
		||||
                </widget>
 | 
			
		||||
               </item>
 | 
			
		||||
               <item>
 | 
			
		||||
                <widget class="QPushButton" name="appBtn">
 | 
			
		||||
                 <property name="text">
 | 
			
		||||
                  <string>Browse...</string>
 | 
			
		||||
                 </property>
 | 
			
		||||
                </widget>
 | 
			
		||||
               </item>
 | 
			
		||||
              </layout>
 | 
			
		||||
             </item>
 | 
			
		||||
            </layout>
 | 
			
		||||
           </item>
 | 
			
		||||
           <item>
 | 
			
		||||
            <layout class="QVBoxLayout" name="verticalLayout_6">
 | 
			
		||||
             <item>
 | 
			
		||||
              <widget class="QLabel" name="label_5">
 | 
			
		||||
               <property name="whatsThis">
 | 
			
		||||
                <string>This is the location your Software Updates and Browser Data is Saved to/Imported from.</string>
 | 
			
		||||
               </property>
 | 
			
		||||
               <property name="text">
 | 
			
		||||
                <string>Updates / Web content</string>
 | 
			
		||||
               </property>
 | 
			
		||||
              </widget>
 | 
			
		||||
             </item>
 | 
			
		||||
             <item>
 | 
			
		||||
              <layout class="QHBoxLayout" name="horizontalLayout_10">
 | 
			
		||||
               <item>
 | 
			
		||||
                <widget class="QLineEdit" name="urlPath">
 | 
			
		||||
                 <property name="toolTip">
 | 
			
		||||
                  <string>This is the location your PS Vita system will read all the content that it tries to download.</string>
 | 
			
		||||
                 </property>
 | 
			
		||||
                 <property name="readOnly">
 | 
			
		||||
                  <bool>true</bool>
 | 
			
		||||
                 </property>
 | 
			
		||||
                </widget>
 | 
			
		||||
               </item>
 | 
			
		||||
               <item>
 | 
			
		||||
                <widget class="QPushButton" name="urlBtn">
 | 
			
		||||
                 <property name="text">
 | 
			
		||||
                  <string>Browse...</string>
 | 
			
		||||
                 </property>
 | 
			
		||||
                </widget>
 | 
			
		||||
               </item>
 | 
			
		||||
              </layout>
 | 
			
		||||
             </item>
 | 
			
		||||
            </layout>
 | 
			
		||||
           </item>
 | 
			
		||||
           <item>
 | 
			
		||||
            <layout class="QVBoxLayout" name="verticalLayout_9">
 | 
			
		||||
             <item>
 | 
			
		||||
              <widget class="QLabel" name="label_9">
 | 
			
		||||
               <property name="text">
 | 
			
		||||
                <string>Packages</string>
 | 
			
		||||
               </property>
 | 
			
		||||
              </widget>
 | 
			
		||||
             </item>
 | 
			
		||||
             <item>
 | 
			
		||||
              <layout class="QHBoxLayout" name="horizontalLayout">
 | 
			
		||||
               <item>
 | 
			
		||||
                <widget class="QLineEdit" name="pkgPath"/>
 | 
			
		||||
               </item>
 | 
			
		||||
               <item>
 | 
			
		||||
                <widget class="QPushButton" name="pkgBtn">
 | 
			
		||||
                 <property name="text">
 | 
			
		||||
                  <string>Browse...</string>
 | 
			
		||||
                 </property>
 | 
			
		||||
                </widget>
 | 
			
		||||
               </item>
 | 
			
		||||
              </layout>
 | 
			
		||||
             </item>
 | 
			
		||||
             <item>
 | 
			
		||||
              <spacer name="verticalSpacer_2">
 | 
			
		||||
               <property name="orientation">
 | 
			
		||||
                <enum>Qt::Vertical</enum>
 | 
			
		||||
               </property>
 | 
			
		||||
               <property name="sizeHint" stdset="0">
 | 
			
		||||
                <size>
 | 
			
		||||
                 <width>20</width>
 | 
			
		||||
                 <height>40</height>
 | 
			
		||||
                </size>
 | 
			
		||||
               </property>
 | 
			
		||||
              </spacer>
 | 
			
		||||
             </item>
 | 
			
		||||
            </layout>
 | 
			
		||||
           </item>
 | 
			
		||||
          </layout>
 | 
			
		||||
         </item>
 | 
			
		||||
        </layout>
 | 
			
		||||
       </widget>
 | 
			
		||||
       <widget class="QWidget" name="tab_2">
 | 
			
		||||
        <attribute name="title">
 | 
			
		||||
         <string>Other</string>
 | 
			
		||||
        </attribute>
 | 
			
		||||
        <layout class="QGridLayout" name="gridLayout_3">
 | 
			
		||||
         <item row="2" column="0">
 | 
			
		||||
          <layout class="QVBoxLayout" name="verticalLayout_8">
 | 
			
		||||
           <item>
 | 
			
		||||
            <widget class="QLabel" name="label_7">
 | 
			
		||||
             <property name="text">
 | 
			
		||||
              <string><html><head/><body><p align="center"><span style=" font-size:14pt; font-weight:600;">Advanced settings</span></p></body></html></string>
 | 
			
		||||
             </property>
 | 
			
		||||
            </widget>
 | 
			
		||||
           </item>
 | 
			
		||||
           <item>
 | 
			
		||||
            <widget class="QCheckBox" name="offlineCheck">
 | 
			
		||||
             <property name="text">
 | 
			
		||||
              <string>Offline Mode</string>
 | 
			
		||||
             </property>
 | 
			
		||||
             <property name="checked">
 | 
			
		||||
              <bool>true</bool>
 | 
			
		||||
             </property>
 | 
			
		||||
            </widget>
 | 
			
		||||
           </item>
 | 
			
		||||
           <item>
 | 
			
		||||
            <widget class="QCheckBox" name="metadataCheck">
 | 
			
		||||
             <property name="text">
 | 
			
		||||
              <string>Skip metadata extraction</string>
 | 
			
		||||
             </property>
 | 
			
		||||
            </widget>
 | 
			
		||||
           </item>
 | 
			
		||||
           <item>
 | 
			
		||||
            <widget class="QCheckBox" name="usbCheck">
 | 
			
		||||
             <property name="text">
 | 
			
		||||
              <string>Disable USB monitoring</string>
 | 
			
		||||
             </property>
 | 
			
		||||
            </widget>
 | 
			
		||||
           </item>
 | 
			
		||||
           <item>
 | 
			
		||||
            <widget class="QCheckBox" name="wifiCheck">
 | 
			
		||||
             <property name="text">
 | 
			
		||||
              <string>Disable Wi-Fi monitoring</string>
 | 
			
		||||
             </property>
 | 
			
		||||
            </widget>
 | 
			
		||||
           </item>
 | 
			
		||||
           <item>
 | 
			
		||||
            <widget class="QCheckBox" name="checkBox_3">
 | 
			
		||||
             <property name="enabled">
 | 
			
		||||
              <bool>false</bool>
 | 
			
		||||
             </property>
 | 
			
		||||
             <property name="text">
 | 
			
		||||
              <string>Update database automatically when files on the PC are changed</string>
 | 
			
		||||
             </property>
 | 
			
		||||
            </widget>
 | 
			
		||||
           </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">
 | 
			
		||||
                <string>Database backend</string>
 | 
			
		||||
               </property>
 | 
			
		||||
              </widget>
 | 
			
		||||
             </item>
 | 
			
		||||
             <item row="0" column="1">
 | 
			
		||||
              <widget class="QComboBox" name="databaseSelect">
 | 
			
		||||
               <property name="enabled">
 | 
			
		||||
                <bool>false</bool>
 | 
			
		||||
               </property>
 | 
			
		||||
               <item>
 | 
			
		||||
                <property name="text">
 | 
			
		||||
                 <string>In Memory</string>
 | 
			
		||||
                </property>
 | 
			
		||||
               </item>
 | 
			
		||||
               <item>
 | 
			
		||||
                <property name="text">
 | 
			
		||||
                 <string>SQLite</string>
 | 
			
		||||
                </property>
 | 
			
		||||
               </item>
 | 
			
		||||
              </widget>
 | 
			
		||||
             </item>
 | 
			
		||||
            </layout>
 | 
			
		||||
           </item>
 | 
			
		||||
           <item>
 | 
			
		||||
            <widget class="QCheckBox" name="photoSkipCheck">
 | 
			
		||||
             <property name="text">
 | 
			
		||||
              <string>Skip photo scanning</string>
 | 
			
		||||
             </property>
 | 
			
		||||
            </widget>
 | 
			
		||||
           </item>
 | 
			
		||||
           <item>
 | 
			
		||||
            <widget class="QCheckBox" name="videoSkipCheck">
 | 
			
		||||
             <property name="text">
 | 
			
		||||
              <string>Skip video scanning</string>
 | 
			
		||||
             </property>
 | 
			
		||||
            </widget>
 | 
			
		||||
           </item>
 | 
			
		||||
           <item>
 | 
			
		||||
            <widget class="QCheckBox" name="musicSkipCheck">
 | 
			
		||||
             <property name="text">
 | 
			
		||||
              <string>Skip music scanning</string>
 | 
			
		||||
             </property>
 | 
			
		||||
            </widget>
 | 
			
		||||
           </item>
 | 
			
		||||
           <item>
 | 
			
		||||
            <layout class="QHBoxLayout" name="horizontalLayout_4"/>
 | 
			
		||||
           </item>
 | 
			
		||||
           <item>
 | 
			
		||||
            <layout class="QFormLayout" name="formLayout_2">
 | 
			
		||||
             <property name="fieldGrowthPolicy">
 | 
			
		||||
              <enum>QFormLayout::AllNonFixedFieldsGrow</enum>
 | 
			
		||||
             </property>
 | 
			
		||||
             <item row="1" column="0">
 | 
			
		||||
              <widget class="QLabel" name="label_10">
 | 
			
		||||
               <property name="text">
 | 
			
		||||
                <string>CMA protocol version</string>
 | 
			
		||||
               </property>
 | 
			
		||||
               <property name="alignment">
 | 
			
		||||
                <set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter</set>
 | 
			
		||||
               </property>
 | 
			
		||||
              </widget>
 | 
			
		||||
             </item>
 | 
			
		||||
             <item row="1" column="1">
 | 
			
		||||
              <widget class="QComboBox" name="protocolBox">
 | 
			
		||||
               <property name="minimumSize">
 | 
			
		||||
                <size>
 | 
			
		||||
                 <width>200</width>
 | 
			
		||||
                 <height>0</height>
 | 
			
		||||
                </size>
 | 
			
		||||
               </property>
 | 
			
		||||
               <item>
 | 
			
		||||
                <property name="text">
 | 
			
		||||
                 <string notr="true">FW 3.30 - 1900010</string>
 | 
			
		||||
                </property>
 | 
			
		||||
               </item>
 | 
			
		||||
               <item>
 | 
			
		||||
                <property name="text">
 | 
			
		||||
                 <string notr="true">FW 3.10 - 1800010</string>
 | 
			
		||||
                </property>
 | 
			
		||||
               </item>
 | 
			
		||||
               <item>
 | 
			
		||||
                <property name="text">
 | 
			
		||||
                 <string notr="true">FW 3.00 - 1700010</string>
 | 
			
		||||
                </property>
 | 
			
		||||
               </item>
 | 
			
		||||
               <item>
 | 
			
		||||
                <property name="text">
 | 
			
		||||
                 <string notr="true">FW 2.60 - 1600010</string>
 | 
			
		||||
                </property>
 | 
			
		||||
               </item>
 | 
			
		||||
               <item>
 | 
			
		||||
                <property name="text">
 | 
			
		||||
                 <string notr="true">FW 2.10 - 1500010</string>
 | 
			
		||||
                </property>
 | 
			
		||||
               </item>
 | 
			
		||||
               <item>
 | 
			
		||||
                <property name="text">
 | 
			
		||||
                 <string notr="true">FW 2.00 - 1400010</string>
 | 
			
		||||
                </property>
 | 
			
		||||
               </item>
 | 
			
		||||
               <item>
 | 
			
		||||
                <property name="text">
 | 
			
		||||
                 <string notr="true">FW 1.80 - 1300010</string>
 | 
			
		||||
                </property>
 | 
			
		||||
               </item>
 | 
			
		||||
               <item>
 | 
			
		||||
                <property name="text">
 | 
			
		||||
                 <string notr="true">FW 1.60 - 1200010</string>
 | 
			
		||||
                </property>
 | 
			
		||||
               </item>
 | 
			
		||||
               <item>
 | 
			
		||||
                <property name="text">
 | 
			
		||||
                 <string notr="true">FW 1.50 - 1100010</string>
 | 
			
		||||
                </property>
 | 
			
		||||
               </item>
 | 
			
		||||
               <item>
 | 
			
		||||
                <property name="text">
 | 
			
		||||
                 <string notr="true">FW 1.00 - 1000010</string>
 | 
			
		||||
                </property>
 | 
			
		||||
               </item>
 | 
			
		||||
              </widget>
 | 
			
		||||
             </item>
 | 
			
		||||
             <item row="2" column="1">
 | 
			
		||||
              <widget class="QLineEdit" name="protocolEdit">
 | 
			
		||||
               <property name="inputMask">
 | 
			
		||||
                <string notr="true">9999999</string>
 | 
			
		||||
               </property>
 | 
			
		||||
               <property name="text">
 | 
			
		||||
                <string notr="true"/>
 | 
			
		||||
               </property>
 | 
			
		||||
              </widget>
 | 
			
		||||
             </item>
 | 
			
		||||
             <item row="0" column="0">
 | 
			
		||||
              <widget class="QLabel" name="label_11">
 | 
			
		||||
               <property name="text">
 | 
			
		||||
                <string>CMA protocol selection</string>
 | 
			
		||||
               </property>
 | 
			
		||||
              </widget>
 | 
			
		||||
             </item>
 | 
			
		||||
             <item row="0" column="1">
 | 
			
		||||
              <widget class="QComboBox" name="protocolModeBox">
 | 
			
		||||
               <item>
 | 
			
		||||
                <property name="text">
 | 
			
		||||
                 <string>Latest</string>
 | 
			
		||||
                </property>
 | 
			
		||||
               </item>
 | 
			
		||||
               <item>
 | 
			
		||||
                <property name="text">
 | 
			
		||||
                 <string>Manual</string>
 | 
			
		||||
                </property>
 | 
			
		||||
               </item>
 | 
			
		||||
               <item>
 | 
			
		||||
                <property name="text">
 | 
			
		||||
                 <string>Custom</string>
 | 
			
		||||
                </property>
 | 
			
		||||
               </item>
 | 
			
		||||
              </widget>
 | 
			
		||||
             </item>
 | 
			
		||||
             <item row="2" column="0">
 | 
			
		||||
              <widget class="QLabel" name="label_12">
 | 
			
		||||
               <property name="text">
 | 
			
		||||
                <string>CMA custom version</string>
 | 
			
		||||
               </property>
 | 
			
		||||
              </widget>
 | 
			
		||||
             </item>
 | 
			
		||||
            </layout>
 | 
			
		||||
           </item>
 | 
			
		||||
           <item>
 | 
			
		||||
            <spacer name="verticalSpacer">
 | 
			
		||||
             <property name="orientation">
 | 
			
		||||
              <enum>Qt::Vertical</enum>
 | 
			
		||||
             </property>
 | 
			
		||||
             <property name="sizeHint" stdset="0">
 | 
			
		||||
              <size>
 | 
			
		||||
               <width>20</width>
 | 
			
		||||
               <height>40</height>
 | 
			
		||||
              </size>
 | 
			
		||||
             </property>
 | 
			
		||||
            </spacer>
 | 
			
		||||
           </item>
 | 
			
		||||
          </layout>
 | 
			
		||||
         </item>
 | 
			
		||||
        </layout>
 | 
			
		||||
       </widget>
 | 
			
		||||
      </widget>
 | 
			
		||||
     </item>
 | 
			
		||||
     <item>
 | 
			
		||||
      <widget class="QDialogButtonBox" name="buttonBox">
 | 
			
		||||
       <property name="standardButtons">
 | 
			
		||||
        <set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set>
 | 
			
		||||
       </property>
 | 
			
		||||
      </widget>
 | 
			
		||||
     </item>
 | 
			
		||||
    </layout>
 | 
			
		||||
   </item>
 | 
			
		||||
  </layout>
 | 
			
		||||
 </widget>
 | 
			
		||||
 <resources/>
 | 
			
		||||
 <connections/>
 | 
			
		||||
</ui>
 | 
			
		||||
							
								
								
									
										50
									
								
								gui/forms/confirmdialog.cpp
									
									
									
									
									
										Normal file
									
								
							
							
						
						@@ -0,0 +1,50 @@
 | 
			
		||||
/*
 | 
			
		||||
 *  QCMA: Cross-platform content manager assistant for the PS Vita
 | 
			
		||||
 *
 | 
			
		||||
 *  Copyright (C) 2013  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 "confirmdialog.h"
 | 
			
		||||
#include "ui_confirmdialog.h"
 | 
			
		||||
 | 
			
		||||
const QString ConfirmDialog::messageTemplate = "<html><head/><body>"
 | 
			
		||||
        "<p><span style=\"font-size:10pt;\">%1</span></p>"
 | 
			
		||||
        "<p><span style=\"font-size:12pt; font-weight:600;\">%2</span></p>"
 | 
			
		||||
        "</body></html>";
 | 
			
		||||
 | 
			
		||||
ConfirmDialog::ConfirmDialog(QWidget *obj_parent) :
 | 
			
		||||
    QDialog(obj_parent),
 | 
			
		||||
    ui(new Ui::ConfirmDialog)
 | 
			
		||||
{
 | 
			
		||||
    ui->setupUi(this);
 | 
			
		||||
    this->layout()->setSizeConstraint(QLayout::SetFixedSize);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void ConfirmDialog::setMessageText(const QString message, const QString game_title)
 | 
			
		||||
{
 | 
			
		||||
    ui->confirmText->setText(messageTemplate.arg(message, game_title));
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void ConfirmDialog::setMessagePixmap(const QPixmap &pixmap, int dialog_width)
 | 
			
		||||
{
 | 
			
		||||
    ui->itemPicture->setPixmap(pixmap);
 | 
			
		||||
    ui->itemPicture->setMinimumWidth(dialog_width);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
ConfirmDialog::~ConfirmDialog()
 | 
			
		||||
{
 | 
			
		||||
    delete ui;
 | 
			
		||||
}
 | 
			
		||||
							
								
								
									
										46
									
								
								gui/forms/confirmdialog.h
									
									
									
									
									
										Normal file
									
								
							
							
						
						@@ -0,0 +1,46 @@
 | 
			
		||||
/*
 | 
			
		||||
 *  QCMA: Cross-platform content manager assistant for the PS Vita
 | 
			
		||||
 *
 | 
			
		||||
 *  Copyright (C) 2013  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 CONFIRMDIALOG_H
 | 
			
		||||
#define CONFIRMDIALOG_H
 | 
			
		||||
 | 
			
		||||
#include <QDialog>
 | 
			
		||||
 | 
			
		||||
namespace Ui {
 | 
			
		||||
class ConfirmDialog;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
class ConfirmDialog : public QDialog
 | 
			
		||||
{
 | 
			
		||||
    Q_OBJECT
 | 
			
		||||
 | 
			
		||||
public:
 | 
			
		||||
    explicit ConfirmDialog(QWidget *parent = 0);
 | 
			
		||||
    ~ConfirmDialog();
 | 
			
		||||
 | 
			
		||||
    void setMessageText(const QString message, const QString game_title);
 | 
			
		||||
    void setMessagePixmap(const QPixmap &pixmap, int width);
 | 
			
		||||
 | 
			
		||||
    static const QString messageTemplate;
 | 
			
		||||
 | 
			
		||||
private:
 | 
			
		||||
    Ui::ConfirmDialog *ui;
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
#endif // CONFIRMDIALOG_H
 | 
			
		||||
							
								
								
									
										120
									
								
								gui/forms/confirmdialog.ui
									
									
									
									
									
										Normal file
									
								
							
							
						
						@@ -0,0 +1,120 @@
 | 
			
		||||
<?xml version="1.0" encoding="UTF-8"?>
 | 
			
		||||
<ui version="4.0">
 | 
			
		||||
 <class>ConfirmDialog</class>
 | 
			
		||||
 <widget class="QDialog" name="ConfirmDialog">
 | 
			
		||||
  <property name="geometry">
 | 
			
		||||
   <rect>
 | 
			
		||||
    <x>0</x>
 | 
			
		||||
    <y>0</y>
 | 
			
		||||
    <width>519</width>
 | 
			
		||||
    <height>106</height>
 | 
			
		||||
   </rect>
 | 
			
		||||
  </property>
 | 
			
		||||
  <property name="windowTitle">
 | 
			
		||||
   <string>Confirmation Message</string>
 | 
			
		||||
  </property>
 | 
			
		||||
  <property name="modal">
 | 
			
		||||
   <bool>true</bool>
 | 
			
		||||
  </property>
 | 
			
		||||
  <layout class="QGridLayout" name="gridLayout">
 | 
			
		||||
   <item row="0" column="0">
 | 
			
		||||
    <layout class="QHBoxLayout" name="horizontalLayout">
 | 
			
		||||
     <item>
 | 
			
		||||
      <widget class="QLabel" name="itemPicture">
 | 
			
		||||
       <property name="minimumSize">
 | 
			
		||||
        <size>
 | 
			
		||||
         <width>48</width>
 | 
			
		||||
         <height>48</height>
 | 
			
		||||
        </size>
 | 
			
		||||
       </property>
 | 
			
		||||
       <property name="maximumSize">
 | 
			
		||||
        <size>
 | 
			
		||||
         <width>0</width>
 | 
			
		||||
         <height>48</height>
 | 
			
		||||
        </size>
 | 
			
		||||
       </property>
 | 
			
		||||
       <property name="text">
 | 
			
		||||
        <string/>
 | 
			
		||||
       </property>
 | 
			
		||||
       <property name="scaledContents">
 | 
			
		||||
        <bool>true</bool>
 | 
			
		||||
       </property>
 | 
			
		||||
      </widget>
 | 
			
		||||
     </item>
 | 
			
		||||
     <item>
 | 
			
		||||
      <spacer name="horizontalSpacer">
 | 
			
		||||
       <property name="orientation">
 | 
			
		||||
        <enum>Qt::Horizontal</enum>
 | 
			
		||||
       </property>
 | 
			
		||||
       <property name="sizeType">
 | 
			
		||||
        <enum>QSizePolicy::Fixed</enum>
 | 
			
		||||
       </property>
 | 
			
		||||
       <property name="sizeHint" stdset="0">
 | 
			
		||||
        <size>
 | 
			
		||||
         <width>10</width>
 | 
			
		||||
         <height>0</height>
 | 
			
		||||
        </size>
 | 
			
		||||
       </property>
 | 
			
		||||
      </spacer>
 | 
			
		||||
     </item>
 | 
			
		||||
     <item>
 | 
			
		||||
      <widget class="QLabel" name="confirmText">
 | 
			
		||||
       <property name="text">
 | 
			
		||||
        <string><html><head/><body><p><span style=" font-size:10pt;">Are you sure to delete the backup of the following game?</span></p><p><span style=" font-size:12pt; font-weight:600;">Game Name</span></p></body></html>
 | 
			
		||||
</string>
 | 
			
		||||
       </property>
 | 
			
		||||
       <property name="margin">
 | 
			
		||||
        <number>0</number>
 | 
			
		||||
       </property>
 | 
			
		||||
      </widget>
 | 
			
		||||
     </item>
 | 
			
		||||
    </layout>
 | 
			
		||||
   </item>
 | 
			
		||||
   <item row="1" column="0">
 | 
			
		||||
    <widget class="QDialogButtonBox" name="buttonBox">
 | 
			
		||||
     <property name="orientation">
 | 
			
		||||
      <enum>Qt::Horizontal</enum>
 | 
			
		||||
     </property>
 | 
			
		||||
     <property name="standardButtons">
 | 
			
		||||
      <set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set>
 | 
			
		||||
     </property>
 | 
			
		||||
    </widget>
 | 
			
		||||
   </item>
 | 
			
		||||
  </layout>
 | 
			
		||||
 </widget>
 | 
			
		||||
 <resources/>
 | 
			
		||||
 <connections>
 | 
			
		||||
  <connection>
 | 
			
		||||
   <sender>buttonBox</sender>
 | 
			
		||||
   <signal>accepted()</signal>
 | 
			
		||||
   <receiver>ConfirmDialog</receiver>
 | 
			
		||||
   <slot>accept()</slot>
 | 
			
		||||
   <hints>
 | 
			
		||||
    <hint type="sourcelabel">
 | 
			
		||||
     <x>248</x>
 | 
			
		||||
     <y>254</y>
 | 
			
		||||
    </hint>
 | 
			
		||||
    <hint type="destinationlabel">
 | 
			
		||||
     <x>157</x>
 | 
			
		||||
     <y>274</y>
 | 
			
		||||
    </hint>
 | 
			
		||||
   </hints>
 | 
			
		||||
  </connection>
 | 
			
		||||
  <connection>
 | 
			
		||||
   <sender>buttonBox</sender>
 | 
			
		||||
   <signal>rejected()</signal>
 | 
			
		||||
   <receiver>ConfirmDialog</receiver>
 | 
			
		||||
   <slot>reject()</slot>
 | 
			
		||||
   <hints>
 | 
			
		||||
    <hint type="sourcelabel">
 | 
			
		||||
     <x>316</x>
 | 
			
		||||
     <y>260</y>
 | 
			
		||||
    </hint>
 | 
			
		||||
    <hint type="destinationlabel">
 | 
			
		||||
     <x>286</x>
 | 
			
		||||
     <y>274</y>
 | 
			
		||||
    </hint>
 | 
			
		||||
   </hints>
 | 
			
		||||
  </connection>
 | 
			
		||||
 </connections>
 | 
			
		||||
</ui>
 | 
			
		||||
							
								
								
									
										71
									
								
								gui/forms/pinform.cpp
									
									
									
									
									
										Normal file
									
								
							
							
						
						@@ -0,0 +1,71 @@
 | 
			
		||||
/*
 | 
			
		||||
 *  QCMA: Cross-platform content manager assistant for the PS Vita
 | 
			
		||||
 *
 | 
			
		||||
 *  Copyright (C) 2013  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 "pinform.h"
 | 
			
		||||
#include "ui_pinform.h"
 | 
			
		||||
 | 
			
		||||
#include <QDebug>
 | 
			
		||||
#include <QDesktopWidget>
 | 
			
		||||
 | 
			
		||||
const QString PinForm::pinFormat =
 | 
			
		||||
    "<html><head/><body>"
 | 
			
		||||
    "<p><span style=\"font-size:24pt; font-weight:600;\">%1</span></p>"
 | 
			
		||||
    "</body></html>";
 | 
			
		||||
 | 
			
		||||
PinForm::PinForm(QWidget *obj_parent) :
 | 
			
		||||
    QWidget(obj_parent),
 | 
			
		||||
    ui(new Ui::PinForm)
 | 
			
		||||
{
 | 
			
		||||
    ui->setupUi(this);
 | 
			
		||||
    move(QApplication::desktop()->screen()->rect().center() - rect().center());
 | 
			
		||||
    setFixedSize(size());
 | 
			
		||||
    setWindowFlags(Qt::CustomizeWindowHint | Qt::WindowTitleHint);
 | 
			
		||||
    connect(ui->cancelButton, SIGNAL(clicked()), this, SLOT(hide()));
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void PinForm::setPin(QString name, int pin)
 | 
			
		||||
{
 | 
			
		||||
    qDebug() << "Got pin from user " << name;
 | 
			
		||||
    ui->deviceLabel->setText(tr("Device: %1 (PS Vita)").arg(name));
 | 
			
		||||
    ui->pinLabel->setText(pinFormat.arg(QString::number(pin), 8, QChar('0')));
 | 
			
		||||
    show();
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void PinForm::startCountdown()
 | 
			
		||||
{
 | 
			
		||||
    timer.setInterval(1000);
 | 
			
		||||
    counter = 300;
 | 
			
		||||
    connect(&timer, SIGNAL(timeout()), this, SLOT(decreaseTimer()));
 | 
			
		||||
    timer.start();
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void PinForm::decreaseTimer()
 | 
			
		||||
{
 | 
			
		||||
    counter--;
 | 
			
		||||
    if(counter == 0) {
 | 
			
		||||
        timer.stop();
 | 
			
		||||
        hide();
 | 
			
		||||
    }
 | 
			
		||||
    ui->timeLabel->setText(tr("Time remaining: %1 seconds").arg(counter));
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
PinForm::~PinForm()
 | 
			
		||||
{
 | 
			
		||||
    delete ui;
 | 
			
		||||
}
 | 
			
		||||
							
								
								
									
										55
									
								
								gui/forms/pinform.h
									
									
									
									
									
										Normal file
									
								
							
							
						
						@@ -0,0 +1,55 @@
 | 
			
		||||
/*
 | 
			
		||||
 *  QCMA: Cross-platform content manager assistant for the PS Vita
 | 
			
		||||
 *
 | 
			
		||||
 *  Copyright (C) 2013  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 PINFORM_H
 | 
			
		||||
#define PINFORM_H
 | 
			
		||||
 | 
			
		||||
#include <QTimer>
 | 
			
		||||
#include <QWidget>
 | 
			
		||||
 | 
			
		||||
namespace Ui {
 | 
			
		||||
class PinForm;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
class PinForm : public QWidget
 | 
			
		||||
{
 | 
			
		||||
    Q_OBJECT
 | 
			
		||||
 | 
			
		||||
public:
 | 
			
		||||
    explicit PinForm(QWidget *parent = 0);
 | 
			
		||||
    ~PinForm();
 | 
			
		||||
 | 
			
		||||
private:
 | 
			
		||||
    Ui::PinForm *ui;
 | 
			
		||||
 | 
			
		||||
    // pin timeout
 | 
			
		||||
    int counter;
 | 
			
		||||
    QTimer timer;
 | 
			
		||||
 | 
			
		||||
    static const QString pinFormat;
 | 
			
		||||
 | 
			
		||||
public slots:
 | 
			
		||||
    void startCountdown();
 | 
			
		||||
    void setPin(QString name, int pin);
 | 
			
		||||
 | 
			
		||||
private slots:
 | 
			
		||||
    void decreaseTimer();
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
#endif // PINFORM_H
 | 
			
		||||
							
								
								
									
										115
									
								
								gui/forms/pinform.ui
									
									
									
									
									
										Normal file
									
								
							
							
						
						@@ -0,0 +1,115 @@
 | 
			
		||||
<?xml version="1.0" encoding="UTF-8"?>
 | 
			
		||||
<ui version="4.0">
 | 
			
		||||
 <class>PinForm</class>
 | 
			
		||||
 <widget class="QWidget" name="PinForm">
 | 
			
		||||
  <property name="windowModality">
 | 
			
		||||
   <enum>Qt::ApplicationModal</enum>
 | 
			
		||||
  </property>
 | 
			
		||||
  <property name="geometry">
 | 
			
		||||
   <rect>
 | 
			
		||||
    <x>0</x>
 | 
			
		||||
    <y>0</y>
 | 
			
		||||
    <width>526</width>
 | 
			
		||||
    <height>216</height>
 | 
			
		||||
   </rect>
 | 
			
		||||
  </property>
 | 
			
		||||
  <property name="windowTitle">
 | 
			
		||||
   <string>Device pairing</string>
 | 
			
		||||
  </property>
 | 
			
		||||
  <layout class="QGridLayout" name="gridLayout">
 | 
			
		||||
   <item row="0" column="0">
 | 
			
		||||
    <layout class="QVBoxLayout" name="verticalLayout">
 | 
			
		||||
     <item>
 | 
			
		||||
      <widget class="QLabel" name="label_2">
 | 
			
		||||
       <property name="text">
 | 
			
		||||
        <string>An unregistered PS Vita system is connecting with QCMA via Wi-Fi</string>
 | 
			
		||||
       </property>
 | 
			
		||||
       <property name="alignment">
 | 
			
		||||
        <set>Qt::AlignCenter</set>
 | 
			
		||||
       </property>
 | 
			
		||||
      </widget>
 | 
			
		||||
     </item>
 | 
			
		||||
     <item>
 | 
			
		||||
      <widget class="QLabel" name="deviceLabel">
 | 
			
		||||
       <property name="text">
 | 
			
		||||
        <string>Device: PS Vita</string>
 | 
			
		||||
       </property>
 | 
			
		||||
       <property name="alignment">
 | 
			
		||||
        <set>Qt::AlignCenter</set>
 | 
			
		||||
       </property>
 | 
			
		||||
      </widget>
 | 
			
		||||
     </item>
 | 
			
		||||
     <item>
 | 
			
		||||
      <widget class="QLabel" name="label_3">
 | 
			
		||||
       <property name="text">
 | 
			
		||||
        <string>Input the following number in the PS Vita system to register it with QCMA</string>
 | 
			
		||||
       </property>
 | 
			
		||||
       <property name="alignment">
 | 
			
		||||
        <set>Qt::AlignCenter</set>
 | 
			
		||||
       </property>
 | 
			
		||||
      </widget>
 | 
			
		||||
     </item>
 | 
			
		||||
     <item>
 | 
			
		||||
      <widget class="QLabel" name="pinLabel">
 | 
			
		||||
       <property name="text">
 | 
			
		||||
        <string><html><head/><body><p><span style=" font-size:24pt; font-weight:600;">12345678</span></p></body></html></string>
 | 
			
		||||
       </property>
 | 
			
		||||
       <property name="alignment">
 | 
			
		||||
        <set>Qt::AlignCenter</set>
 | 
			
		||||
       </property>
 | 
			
		||||
      </widget>
 | 
			
		||||
     </item>
 | 
			
		||||
     <item>
 | 
			
		||||
      <widget class="QLabel" name="timeLabel">
 | 
			
		||||
       <property name="text">
 | 
			
		||||
        <string>Time remaining: 300 seconds</string>
 | 
			
		||||
       </property>
 | 
			
		||||
       <property name="alignment">
 | 
			
		||||
        <set>Qt::AlignCenter</set>
 | 
			
		||||
       </property>
 | 
			
		||||
      </widget>
 | 
			
		||||
     </item>
 | 
			
		||||
     <item>
 | 
			
		||||
      <layout class="QHBoxLayout" name="horizontalLayout">
 | 
			
		||||
       <item>
 | 
			
		||||
        <spacer name="horizontalSpacer_2">
 | 
			
		||||
         <property name="orientation">
 | 
			
		||||
          <enum>Qt::Horizontal</enum>
 | 
			
		||||
         </property>
 | 
			
		||||
         <property name="sizeHint" stdset="0">
 | 
			
		||||
          <size>
 | 
			
		||||
           <width>40</width>
 | 
			
		||||
           <height>20</height>
 | 
			
		||||
          </size>
 | 
			
		||||
         </property>
 | 
			
		||||
        </spacer>
 | 
			
		||||
       </item>
 | 
			
		||||
       <item>
 | 
			
		||||
        <widget class="QPushButton" name="cancelButton">
 | 
			
		||||
         <property name="text">
 | 
			
		||||
          <string>Cancel</string>
 | 
			
		||||
         </property>
 | 
			
		||||
        </widget>
 | 
			
		||||
       </item>
 | 
			
		||||
       <item>
 | 
			
		||||
        <spacer name="horizontalSpacer">
 | 
			
		||||
         <property name="orientation">
 | 
			
		||||
          <enum>Qt::Horizontal</enum>
 | 
			
		||||
         </property>
 | 
			
		||||
         <property name="sizeHint" stdset="0">
 | 
			
		||||
          <size>
 | 
			
		||||
           <width>40</width>
 | 
			
		||||
           <height>20</height>
 | 
			
		||||
          </size>
 | 
			
		||||
         </property>
 | 
			
		||||
        </spacer>
 | 
			
		||||
       </item>
 | 
			
		||||
      </layout>
 | 
			
		||||
     </item>
 | 
			
		||||
    </layout>
 | 
			
		||||
   </item>
 | 
			
		||||
  </layout>
 | 
			
		||||
 </widget>
 | 
			
		||||
 <resources/>
 | 
			
		||||
 <connections/>
 | 
			
		||||
</ui>
 | 
			
		||||
							
								
								
									
										77
									
								
								gui/forms/progressform.cpp
									
									
									
									
									
										Normal file
									
								
							
							
						
						@@ -0,0 +1,77 @@
 | 
			
		||||
/*
 | 
			
		||||
 *  QCMA: Cross-platform content manager assistant for the PS Vita
 | 
			
		||||
 *
 | 
			
		||||
 *  Copyright (C) 2013  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 "progressform.h"
 | 
			
		||||
#include "ui_progressform.h"
 | 
			
		||||
 | 
			
		||||
#include <QDesktopWidget>
 | 
			
		||||
#include <QMessageBox>
 | 
			
		||||
 | 
			
		||||
ProgressForm::ProgressForm(QWidget *obj_parent) :
 | 
			
		||||
    QWidget(obj_parent),
 | 
			
		||||
    ui(new Ui::ProgressForm)
 | 
			
		||||
{
 | 
			
		||||
    ui->setupUi(this);
 | 
			
		||||
    move(QApplication::desktop()->screen()->rect().center() - rect().center());
 | 
			
		||||
    setFixedSize(size());
 | 
			
		||||
    setWindowFlags(Qt::CustomizeWindowHint | Qt::WindowTitleHint);
 | 
			
		||||
    connect(ui->cancelButton, SIGNAL(clicked()), this, SLOT(cancelConfirm()));
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
ProgressForm::~ProgressForm()
 | 
			
		||||
{
 | 
			
		||||
    delete ui;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void ProgressForm::cancelConfirm()
 | 
			
		||||
{
 | 
			
		||||
    QMessageBox box;
 | 
			
		||||
    box.setText(tr("Database indexing in progress"));
 | 
			
		||||
    box.setInformativeText(tr("Are you sure to cancel the database indexing?"));
 | 
			
		||||
    box.setIcon(QMessageBox::Warning);
 | 
			
		||||
    box.setStandardButtons(QMessageBox::Ok | QMessageBox::Cancel);
 | 
			
		||||
    if(box.exec() == QMessageBox::Ok) {
 | 
			
		||||
        emit canceled();
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void ProgressForm::setFileName(QString file)
 | 
			
		||||
{
 | 
			
		||||
    QString elided = ui->fileLabel->fontMetrics().elidedText(file, Qt::ElideMiddle, ui->fileLabel->width(), 0);
 | 
			
		||||
    ui->fileLabel->setText(elided);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void ProgressForm::setDirectoryName(QString dir)
 | 
			
		||||
{
 | 
			
		||||
    QString elided = ui->directoryLabel->fontMetrics().elidedText(dir, Qt::ElideMiddle, ui->directoryLabel->width(), 0);
 | 
			
		||||
    ui->directoryLabel->setText(elided);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void ProgressForm::showDelayed(int msec)
 | 
			
		||||
{
 | 
			
		||||
    timer.setSingleShot(true);
 | 
			
		||||
    timer.setInterval(msec);
 | 
			
		||||
    connect(&timer, SIGNAL(timeout()), this, SLOT(show()));
 | 
			
		||||
    timer.start();
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void ProgressForm::interruptShow()
 | 
			
		||||
{
 | 
			
		||||
    timer.stop();
 | 
			
		||||
}
 | 
			
		||||
							
								
								
									
										57
									
								
								gui/forms/progressform.h
									
									
									
									
									
										Normal file
									
								
							
							
						
						@@ -0,0 +1,57 @@
 | 
			
		||||
/*
 | 
			
		||||
 *  QCMA: Cross-platform content manager assistant for the PS Vita
 | 
			
		||||
 *
 | 
			
		||||
 *  Copyright (C) 2013  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 PROGRESSFORM_H
 | 
			
		||||
#define PROGRESSFORM_H
 | 
			
		||||
 | 
			
		||||
#include <QTimer>
 | 
			
		||||
#include <QWidget>
 | 
			
		||||
 | 
			
		||||
namespace Ui {
 | 
			
		||||
class ProgressForm;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
class ProgressForm : public QWidget
 | 
			
		||||
{
 | 
			
		||||
    Q_OBJECT
 | 
			
		||||
 | 
			
		||||
public:
 | 
			
		||||
    explicit ProgressForm(QWidget *parent = 0);
 | 
			
		||||
    ~ProgressForm();
 | 
			
		||||
 | 
			
		||||
    void showDelayed(int msec = 1000);
 | 
			
		||||
    void interruptShow();
 | 
			
		||||
 | 
			
		||||
private:
 | 
			
		||||
    Ui::ProgressForm *ui;
 | 
			
		||||
 | 
			
		||||
    QTimer timer;
 | 
			
		||||
 | 
			
		||||
signals:
 | 
			
		||||
    void canceled();
 | 
			
		||||
 | 
			
		||||
private slots:
 | 
			
		||||
    void cancelConfirm();
 | 
			
		||||
 | 
			
		||||
public slots:
 | 
			
		||||
    void setDirectoryName(QString dir);
 | 
			
		||||
    void setFileName(QString file);
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
#endif // PROGRESSFORM_H
 | 
			
		||||
							
								
								
									
										80
									
								
								gui/forms/progressform.ui
									
									
									
									
									
										Normal file
									
								
							
							
						
						@@ -0,0 +1,80 @@
 | 
			
		||||
<?xml version="1.0" encoding="UTF-8"?>
 | 
			
		||||
<ui version="4.0">
 | 
			
		||||
 <class>ProgressForm</class>
 | 
			
		||||
 <widget class="QWidget" name="ProgressForm">
 | 
			
		||||
  <property name="windowModality">
 | 
			
		||||
   <enum>Qt::ApplicationModal</enum>
 | 
			
		||||
  </property>
 | 
			
		||||
  <property name="geometry">
 | 
			
		||||
   <rect>
 | 
			
		||||
    <x>0</x>
 | 
			
		||||
    <y>0</y>
 | 
			
		||||
    <width>602</width>
 | 
			
		||||
    <height>138</height>
 | 
			
		||||
   </rect>
 | 
			
		||||
  </property>
 | 
			
		||||
  <property name="windowTitle">
 | 
			
		||||
   <string>Refreshing database...</string>
 | 
			
		||||
  </property>
 | 
			
		||||
  <layout class="QGridLayout" name="gridLayout">
 | 
			
		||||
   <item row="1" column="0">
 | 
			
		||||
    <layout class="QVBoxLayout" name="verticalLayout">
 | 
			
		||||
     <item>
 | 
			
		||||
      <widget class="QLabel" name="label">
 | 
			
		||||
       <property name="text">
 | 
			
		||||
        <string><html><head/><body><p><span style=" font-size:11pt; font-weight:600;">Reading directory:</span></p></body></html></string>
 | 
			
		||||
       </property>
 | 
			
		||||
      </widget>
 | 
			
		||||
     </item>
 | 
			
		||||
     <item>
 | 
			
		||||
      <widget class="QLabel" name="directoryLabel">
 | 
			
		||||
       <property name="text">
 | 
			
		||||
        <string>directory name</string>
 | 
			
		||||
       </property>
 | 
			
		||||
      </widget>
 | 
			
		||||
     </item>
 | 
			
		||||
     <item>
 | 
			
		||||
      <widget class="QLabel" name="label_3">
 | 
			
		||||
       <property name="text">
 | 
			
		||||
        <string><html><head/><body><p><span style=" font-size:11pt; font-weight:600;">Processing file:</span></p></body></html></string>
 | 
			
		||||
       </property>
 | 
			
		||||
      </widget>
 | 
			
		||||
     </item>
 | 
			
		||||
     <item>
 | 
			
		||||
      <widget class="QLabel" name="fileLabel">
 | 
			
		||||
       <property name="text">
 | 
			
		||||
        <string>file name</string>
 | 
			
		||||
       </property>
 | 
			
		||||
      </widget>
 | 
			
		||||
     </item>
 | 
			
		||||
     <item>
 | 
			
		||||
      <layout class="QHBoxLayout" name="horizontalLayout">
 | 
			
		||||
       <item>
 | 
			
		||||
        <spacer name="horizontalSpacer">
 | 
			
		||||
         <property name="orientation">
 | 
			
		||||
          <enum>Qt::Horizontal</enum>
 | 
			
		||||
         </property>
 | 
			
		||||
         <property name="sizeHint" stdset="0">
 | 
			
		||||
          <size>
 | 
			
		||||
           <width>40</width>
 | 
			
		||||
           <height>20</height>
 | 
			
		||||
          </size>
 | 
			
		||||
         </property>
 | 
			
		||||
        </spacer>
 | 
			
		||||
       </item>
 | 
			
		||||
       <item>
 | 
			
		||||
        <widget class="QPushButton" name="cancelButton">
 | 
			
		||||
         <property name="text">
 | 
			
		||||
          <string>Cancel</string>
 | 
			
		||||
         </property>
 | 
			
		||||
        </widget>
 | 
			
		||||
       </item>
 | 
			
		||||
      </layout>
 | 
			
		||||
     </item>
 | 
			
		||||
    </layout>
 | 
			
		||||
   </item>
 | 
			
		||||
  </layout>
 | 
			
		||||
 </widget>
 | 
			
		||||
 <resources/>
 | 
			
		||||
 <connections/>
 | 
			
		||||
</ui>
 | 
			
		||||
							
								
								
									
										83
									
								
								gui/gui.pro
									
									
									
									
									
										Normal file
									
								
							
							
						
						@@ -0,0 +1,83 @@
 | 
			
		||||
include(../config.pri)
 | 
			
		||||
include(../common/defines.pri)
 | 
			
		||||
 | 
			
		||||
TARGET = qcma
 | 
			
		||||
TEMPLATE += app
 | 
			
		||||
QT += gui widgets network sql
 | 
			
		||||
LIBS += -L../common -lqcma_common
 | 
			
		||||
 | 
			
		||||
SOURCES += \
 | 
			
		||||
    main.cpp \
 | 
			
		||||
    mainwidget.cpp \
 | 
			
		||||
    singleapplication.cpp \
 | 
			
		||||
    clientmanager.cpp \
 | 
			
		||||
    filterlineedit.cpp \
 | 
			
		||||
    qtrayicon.cpp \
 | 
			
		||||
# forms
 | 
			
		||||
    forms/backupitem.cpp \
 | 
			
		||||
    forms/backupmanagerform.cpp \
 | 
			
		||||
    forms/configwidget.cpp \
 | 
			
		||||
    forms/confirmdialog.cpp \
 | 
			
		||||
    forms/pinform.cpp \
 | 
			
		||||
    forms/progressform.cpp
 | 
			
		||||
 | 
			
		||||
HEADERS += \
 | 
			
		||||
    mainwidget.h \
 | 
			
		||||
    singleapplication.h \
 | 
			
		||||
    clientmanager.h \
 | 
			
		||||
    filterlineedit.h \
 | 
			
		||||
    qtrayicon.h \
 | 
			
		||||
    trayindicator.h \
 | 
			
		||||
    trayindicator_global.h \
 | 
			
		||||
# forms
 | 
			
		||||
    forms/backupitem.h \
 | 
			
		||||
    forms/backupmanagerform.h \
 | 
			
		||||
    forms/configwidget.h \
 | 
			
		||||
    forms/confirmdialog.h \
 | 
			
		||||
    forms/pinform.h \
 | 
			
		||||
    forms/progressform.h
 | 
			
		||||
 | 
			
		||||
FORMS += \
 | 
			
		||||
    forms/configwidget.ui \
 | 
			
		||||
    forms/backupmanagerform.ui \
 | 
			
		||||
    forms/backupitem.ui \
 | 
			
		||||
    forms/confirmdialog.ui \
 | 
			
		||||
    forms/progressform.ui \
 | 
			
		||||
    forms/pinform.ui
 | 
			
		||||
 | 
			
		||||
OTHER_FILES += \
 | 
			
		||||
    resources/images/psv_icon.png \
 | 
			
		||||
    resources/images/psv_icon_16.png \
 | 
			
		||||
    resources/images/qcma.png \
 | 
			
		||||
    resources/qcma.desktop \
 | 
			
		||||
    qcma.rc
 | 
			
		||||
 | 
			
		||||
RESOURCES += gui.qrc
 | 
			
		||||
 | 
			
		||||
# find packages using pkg-config
 | 
			
		||||
PKGCONFIG = libvitamtp libavformat libavcodec libavutil libswscale
 | 
			
		||||
 | 
			
		||||
#Linux-only config
 | 
			
		||||
unix:!macx {
 | 
			
		||||
    PKGCONFIG += libnotify
 | 
			
		||||
 | 
			
		||||
    # config for desktop file and icon
 | 
			
		||||
    desktop.path = $$DATADIR/applications/$${TARGET}
 | 
			
		||||
    desktop.files += resources/$${TARGET}.desktop
 | 
			
		||||
 | 
			
		||||
    icon64.path = $$DATADIR/icons/hicolor/64x64/apps
 | 
			
		||||
    icon64.files += resources/images/$${TARGET}.png
 | 
			
		||||
 | 
			
		||||
    man.files = qcma.1
 | 
			
		||||
    man.path = $$MANDIR
 | 
			
		||||
 | 
			
		||||
    target.path = $$BINDIR
 | 
			
		||||
 | 
			
		||||
    INSTALLS += target desktop icon64 man
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
# Windows config
 | 
			
		||||
win32 {
 | 
			
		||||
    # Windows icon
 | 
			
		||||
    RC_FILE = qcma.rc
 | 
			
		||||
}
 | 
			
		||||
							
								
								
									
										12
									
								
								gui/gui.qrc
									
									
									
									
									
										Normal file
									
								
							
							
						
						@@ -0,0 +1,12 @@
 | 
			
		||||
<RCC>
 | 
			
		||||
    <qresource prefix="/main">
 | 
			
		||||
        <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/tray/qcma_off.png</file>
 | 
			
		||||
        <file>resources/images/tray/qcma_off_16.png</file>
 | 
			
		||||
        <file>resources/images/qcma_on.png</file>
 | 
			
		||||
        <file>resources/images/qcma_off.png</file>
 | 
			
		||||
    </qresource>
 | 
			
		||||
</RCC>
 | 
			
		||||
							
								
								
									
										152
									
								
								gui/main.cpp
									
									
									
									
									
										Normal file
									
								
							
							
						
						@@ -0,0 +1,152 @@
 | 
			
		||||
/*
 | 
			
		||||
 *  QCMA: Cross-platform content manager assistant for the PS Vita
 | 
			
		||||
 *
 | 
			
		||||
 *  Copyright (C) 2013  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 Q_OS_WIN32
 | 
			
		||||
#include <signal.h>
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
#include <QDebug>
 | 
			
		||||
#include <QLibraryInfo>
 | 
			
		||||
#include <QLocale>
 | 
			
		||||
#include <QTextCodec>
 | 
			
		||||
#include <QTextStream>
 | 
			
		||||
#include <QThread>
 | 
			
		||||
#include <QTranslator>
 | 
			
		||||
 | 
			
		||||
#include <inttypes.h>
 | 
			
		||||
 | 
			
		||||
#include "singleapplication.h"
 | 
			
		||||
#include "mainwidget.h"
 | 
			
		||||
 | 
			
		||||
#if QT_VERSION >= QT_VERSION_CHECK(5, 0, 0)
 | 
			
		||||
static void noMessageOutput(QtMsgType type, const QMessageLogContext &, const QString & str)
 | 
			
		||||
{
 | 
			
		||||
    const char * msg = str.toStdString().c_str();
 | 
			
		||||
#else
 | 
			
		||||
static void noMessageOutput(QtMsgType type, const char *msg)
 | 
			
		||||
{
 | 
			
		||||
#endif
 | 
			
		||||
    Q_UNUSED(type);
 | 
			
		||||
    Q_UNUSED(msg);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
#ifndef Q_OS_WIN32
 | 
			
		||||
static bool setup_handlers()
 | 
			
		||||
{
 | 
			
		||||
    struct sigaction hup, term;
 | 
			
		||||
 | 
			
		||||
    hup.sa_handler = ClientManager::hupSignalHandler;
 | 
			
		||||
    sigemptyset(&hup.sa_mask);
 | 
			
		||||
    hup.sa_flags = 0;
 | 
			
		||||
    hup.sa_flags |= SA_RESTART;
 | 
			
		||||
 | 
			
		||||
    if (sigaction(SIGHUP, &hup, NULL) != 0) {
 | 
			
		||||
        qCritical("SIGHUP signal handle failed");
 | 
			
		||||
        return false;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    term.sa_handler = ClientManager::termSignalHandler;
 | 
			
		||||
    sigemptyset(&term.sa_mask);
 | 
			
		||||
    term.sa_flags |= SA_RESTART;
 | 
			
		||||
 | 
			
		||||
    if (sigaction(SIGTERM, &term, NULL) != 0) {
 | 
			
		||||
        qCritical("SIGTERM signal handle failed");
 | 
			
		||||
        return false;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    return true;
 | 
			
		||||
}
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
int main(int argc, char *argv[])
 | 
			
		||||
{
 | 
			
		||||
    if(SingleApplication::sendMessage(QObject::tr("An instance of Qcma is already running"))) {
 | 
			
		||||
        return 0;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    SingleApplication app(argc, argv);
 | 
			
		||||
 | 
			
		||||
#ifndef Q_OS_WIN32
 | 
			
		||||
    // FIXME: libmtp sends SIGPIPE if a socket write fails crashing the whole app
 | 
			
		||||
    // the proper fix is to libmtp to handle the cancel properly or ignoring
 | 
			
		||||
    // SIGPIPE on the socket
 | 
			
		||||
    signal(SIGPIPE, SIG_IGN);
 | 
			
		||||
    setup_handlers();
 | 
			
		||||
#endif    
 | 
			
		||||
 | 
			
		||||
    if(app.arguments().contains("--with-debug")) {
 | 
			
		||||
        VitaMTP_Set_Logging(VitaMTP_DEBUG);
 | 
			
		||||
    } else if(app.arguments().contains("--verbose")) {
 | 
			
		||||
        VitaMTP_Set_Logging(VitaMTP_VERBOSE);
 | 
			
		||||
    } else {
 | 
			
		||||
        VitaMTP_Set_Logging(VitaMTP_NONE);
 | 
			
		||||
#if QT_VERSION >= QT_VERSION_CHECK(5, 0, 0)
 | 
			
		||||
        qInstallMessageHandler(noMessageOutput);
 | 
			
		||||
#else
 | 
			
		||||
        qInstallMsgHandler(noMessageOutput);
 | 
			
		||||
#endif
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
#if QT_VERSION < QT_VERSION_CHECK(5, 0, 0)
 | 
			
		||||
    QTextCodec::setCodecForCStrings(QTextCodec::codecForName("UTF-8"));
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
    QTextStream(stdout) << "Starting Qcma " << QCMA_VER << endl;
 | 
			
		||||
 | 
			
		||||
    QTranslator translator;
 | 
			
		||||
    QString locale = QLocale().system().name();
 | 
			
		||||
    qDebug() << "Current locale:" << locale;
 | 
			
		||||
 | 
			
		||||
    if(app.arguments().contains("--set-locale")) {
 | 
			
		||||
        int index = app.arguments().indexOf("--set-locale");
 | 
			
		||||
        if(index + 1 < app.arguments().length()) {
 | 
			
		||||
            qDebug("Enforcing locale: %s", app.arguments().at(index + 1).toUtf8().data());
 | 
			
		||||
            locale = app.arguments().at(index + 1);
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    if(translator.load("qcma_" + locale, ":/resources/translations")) {
 | 
			
		||||
        app.installTranslator(&translator);
 | 
			
		||||
    } else {
 | 
			
		||||
        qWarning() << "Cannot load translation for locale:" << locale;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    QTranslator system_translator;
 | 
			
		||||
    system_translator.load("qt_" + locale, QLibraryInfo::location(QLibraryInfo::TranslationsPath));
 | 
			
		||||
    app.installTranslator(&system_translator);
 | 
			
		||||
 | 
			
		||||
    qDebug("Starting main thread: 0x%016" PRIxPTR, (uintptr_t)QThread::currentThreadId());
 | 
			
		||||
 | 
			
		||||
    // set the organization/application for QSettings to work properly
 | 
			
		||||
    app.setOrganizationName("codestation");
 | 
			
		||||
    app.setApplicationName("qcma");
 | 
			
		||||
 | 
			
		||||
    //TODO: check if this is actually needed since we don't have a main window by default
 | 
			
		||||
    QApplication::setQuitOnLastWindowClosed(false);
 | 
			
		||||
 | 
			
		||||
    bool showSystray = !app.arguments().contains("--no-systray");
 | 
			
		||||
 | 
			
		||||
    MainWidget widget;
 | 
			
		||||
    widget.prepareApplication(showSystray);
 | 
			
		||||
 | 
			
		||||
    // receive the message from another process
 | 
			
		||||
    QObject::connect(&app, SIGNAL(messageAvailable(QString)), &widget, SLOT(receiveMessage(QString)));
 | 
			
		||||
 | 
			
		||||
    return app.exec();
 | 
			
		||||
}
 | 
			
		||||
							
								
								
									
										281
									
								
								gui/mainwidget.cpp
									
									
									
									
									
										Normal file
									
								
							
							
						
						@@ -0,0 +1,281 @@
 | 
			
		||||
/*
 | 
			
		||||
 *  QCMA: Cross-platform content manager assistant for the PS Vita
 | 
			
		||||
 *
 | 
			
		||||
 *  Copyright (C) 2013  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 "mainwidget.h"
 | 
			
		||||
#include "cmaclient.h"
 | 
			
		||||
#include "cmautils.h"
 | 
			
		||||
 | 
			
		||||
#include "qlistdb.h"
 | 
			
		||||
#include "sqlitedb.h"
 | 
			
		||||
 | 
			
		||||
#include "qtrayicon.h"
 | 
			
		||||
 | 
			
		||||
#include <QApplication>
 | 
			
		||||
#include <QDebug>
 | 
			
		||||
#include <QDir>
 | 
			
		||||
#include <QGridLayout>
 | 
			
		||||
#include <QLibrary>
 | 
			
		||||
#include <QMessageBox>
 | 
			
		||||
#include <QSettings>
 | 
			
		||||
#include <QTimer>
 | 
			
		||||
#include <QSettings>
 | 
			
		||||
#include <QSpacerItem>
 | 
			
		||||
 | 
			
		||||
const QStringList MainWidget::path_list = QStringList() << "photoPath" << "musicPath" << "videoPath" << "appsPath" << "urlPath";
 | 
			
		||||
 | 
			
		||||
bool sleptOnce = false;
 | 
			
		||||
 | 
			
		||||
MainWidget::MainWidget(QWidget *obj_parent) :
 | 
			
		||||
    QWidget(obj_parent), db(NULL), configForm(NULL), managerForm(NULL), backupForm(NULL)
 | 
			
		||||
{
 | 
			
		||||
    trayIcon = NULL;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void MainWidget::checkSettings()
 | 
			
		||||
{
 | 
			
		||||
    QSettings settings;
 | 
			
		||||
    // make sure that all the paths are set, else show the config dialog
 | 
			
		||||
    foreach(const QString &path, path_list) {
 | 
			
		||||
        if(!settings.contains(path)) {
 | 
			
		||||
            first_run = true;
 | 
			
		||||
            configForm->show();
 | 
			
		||||
            return;
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
    first_run = false;
 | 
			
		||||
    managerForm->start();
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void MainWidget::dialogResult(int result)
 | 
			
		||||
{
 | 
			
		||||
    if(result == QDialog::Accepted) {
 | 
			
		||||
        if(first_run) {
 | 
			
		||||
            first_run = false;
 | 
			
		||||
            managerForm->start();
 | 
			
		||||
        }
 | 
			
		||||
    } else if(first_run) {
 | 
			
		||||
        qApp->quit();
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void MainWidget::stopServer()
 | 
			
		||||
{
 | 
			
		||||
    setTrayTooltip(tr("Shutting down..."));
 | 
			
		||||
    if(CmaClient::isRunning()) {
 | 
			
		||||
        receiveMessage(tr("Stopping QCMA (disconnect your PS Vita)"));
 | 
			
		||||
    }
 | 
			
		||||
    managerForm->stop();
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void MainWidget::deviceDisconnect()
 | 
			
		||||
{
 | 
			
		||||
#ifndef Q_OS_WIN32
 | 
			
		||||
    trayIcon->setIcon("qcma_off");
 | 
			
		||||
#else
 | 
			
		||||
    trayIcon->setIcon("tray/qcma_off_16");
 | 
			
		||||
#endif
 | 
			
		||||
    qDebug("Icon changed - disconnected");
 | 
			
		||||
    setTrayTooltip(tr("Disconnected"));
 | 
			
		||||
    receiveMessage(tr("The device has been disconnected"));
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void MainWidget::deviceConnect(QString message)
 | 
			
		||||
{
 | 
			
		||||
#ifndef Q_OS_WIN32
 | 
			
		||||
    trayIcon->setIcon("qcma_on");
 | 
			
		||||
#else
 | 
			
		||||
    trayIcon->setIcon("tray/qcma_on_16");
 | 
			
		||||
#endif
 | 
			
		||||
    qDebug("Icon changed - connected");
 | 
			
		||||
    setTrayTooltip(message);
 | 
			
		||||
    receiveMessage(message);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void MainWidget::prepareApplication(bool showSystray)
 | 
			
		||||
{
 | 
			
		||||
    //TODO: delete database before exit
 | 
			
		||||
    if(QSettings().value("useMemoryStorage", true).toBool()) {
 | 
			
		||||
        db = new QListDB();
 | 
			
		||||
    } else {
 | 
			
		||||
        db = new SQLiteDB();
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    configForm = new ConfigWidget();
 | 
			
		||||
    backupForm = new BackupManagerForm(db, this);
 | 
			
		||||
    managerForm = new ClientManager(db, this);
 | 
			
		||||
    connectSignals();
 | 
			
		||||
 | 
			
		||||
    if(showSystray) {
 | 
			
		||||
        createTrayIcon();
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    checkSettings();
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void MainWidget::connectSignals()
 | 
			
		||||
{
 | 
			
		||||
    connect(configForm, SIGNAL(finished(int)), this, SLOT(dialogResult(int)));
 | 
			
		||||
    connect(managerForm, SIGNAL(stopped()), qApp, SLOT(quit()));
 | 
			
		||||
    connect(managerForm, SIGNAL(deviceConnected(QString)), this, SIGNAL(deviceConnected(QString)));
 | 
			
		||||
    connect(managerForm, SIGNAL(deviceDisconnected()), this, SIGNAL(deviceDisconnected()));
 | 
			
		||||
    connect(managerForm, SIGNAL(messageSent(QString)), this, SIGNAL(messageReceived(QString)));
 | 
			
		||||
    connect(managerForm, SIGNAL(updated(int)), this, SIGNAL(databaseUpdated(int)));
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void MainWidget::setTrayTooltip(QString message)
 | 
			
		||||
{
 | 
			
		||||
    if(trayIcon) {
 | 
			
		||||
        trayIcon->setToolTip(message);
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void MainWidget::openManager()
 | 
			
		||||
{
 | 
			
		||||
    backupForm->loadBackupListing(-1);
 | 
			
		||||
    backupForm->show();
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void MainWidget::showAboutDialog()
 | 
			
		||||
{
 | 
			
		||||
    QMessageBox about;
 | 
			
		||||
 | 
			
		||||
    about.setText(QString("Qcma ") + QCMA_VER);
 | 
			
		||||
    about.setWindowTitle(tr("About Qcma"));
 | 
			
		||||
#ifndef QCMA_BUILD_HASH
 | 
			
		||||
    about.setInformativeText(tr("Copyright (C) 2015  Codestation") + "\n");
 | 
			
		||||
#else
 | 
			
		||||
    about.setInformativeText(tr("Copyright (C) 2015  Codestation\n\nbuild hash: %1\nbuild branch: %2").arg(QCMA_BUILD_HASH).arg(QCMA_BUILD_BRANCH));
 | 
			
		||||
#endif
 | 
			
		||||
    about.setStandardButtons(QMessageBox::Ok);
 | 
			
		||||
    about.setIconPixmap(QPixmap(":/main/resources/images/qcma.png"));
 | 
			
		||||
    about.setDefaultButton(QMessageBox::Ok);
 | 
			
		||||
 | 
			
		||||
    // hack to expand the messagebox minimum size
 | 
			
		||||
    QSpacerItem* horizontalSpacer = new QSpacerItem(300, 0, QSizePolicy::Minimum, QSizePolicy::Expanding);
 | 
			
		||||
    QGridLayout* widget_layout = (QGridLayout*)about.layout();
 | 
			
		||||
    widget_layout->addItem(horizontalSpacer, widget_layout->rowCount(), 0, 1, widget_layout->columnCount());
 | 
			
		||||
 | 
			
		||||
    about.show();
 | 
			
		||||
    about.exec();
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void MainWidget::showAboutQt()
 | 
			
		||||
{
 | 
			
		||||
    QMessageBox::aboutQt(this);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void MainWidget::openConfig()
 | 
			
		||||
{
 | 
			
		||||
    configForm->open();
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void MainWidget::refreshDatabase()
 | 
			
		||||
{
 | 
			
		||||
    managerForm->refreshDatabase();
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
TrayIndicator *MainWidget::createTrayObject(QWidget *obj_parent)
 | 
			
		||||
{
 | 
			
		||||
    TrayFunctionPointer create_tray = NULL;
 | 
			
		||||
 | 
			
		||||
#ifdef Q_OS_LINUX
 | 
			
		||||
    QString desktop = getenv("XDG_CURRENT_DESKTOP");
 | 
			
		||||
    qDebug() << "Current desktop: " << desktop;
 | 
			
		||||
 | 
			
		||||
#ifdef QT_DEBUG
 | 
			
		||||
    QString library_path = QApplication::applicationDirPath();
 | 
			
		||||
#else
 | 
			
		||||
    QString library_path = "/usr/lib/qcma";
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
    if(desktop.toLower() == "kde")
 | 
			
		||||
    {
 | 
			
		||||
#ifdef QT_DEBUG
 | 
			
		||||
        library_path += "/../kdenotifier";
 | 
			
		||||
#endif
 | 
			
		||||
        // KDENotifier
 | 
			
		||||
        QLibrary library(library_path + "/libqcma_kdenotifier.so");
 | 
			
		||||
        if(library.load())
 | 
			
		||||
            create_tray = reinterpret_cast<TrayFunctionPointer>(library.resolve("createTrayIndicator"));
 | 
			
		||||
        else
 | 
			
		||||
            qWarning() << "Cannot load libqcma_kdenotifier plugin from" << library_path;
 | 
			
		||||
    }
 | 
			
		||||
    else
 | 
			
		||||
    // try to use the appindicator if is available
 | 
			
		||||
    // if(desktop.toLower() == "unity")
 | 
			
		||||
    {
 | 
			
		||||
#ifdef QT_DEBUG
 | 
			
		||||
        library_path += "/../appindicator";
 | 
			
		||||
#endif
 | 
			
		||||
        // AppIndicator
 | 
			
		||||
        QLibrary library(library_path + "/libqcma_appindicator.so");
 | 
			
		||||
        if(library.load())
 | 
			
		||||
            create_tray = reinterpret_cast<TrayFunctionPointer>(library.resolve("createTrayIndicator"));
 | 
			
		||||
        else
 | 
			
		||||
            qWarning() << "Cannot load libqcma_appindicator plugin from" << library_path;
 | 
			
		||||
    }
 | 
			
		||||
#endif
 | 
			
		||||
    // else QSystemTrayIcon
 | 
			
		||||
    return (create_tray != NULL) ? create_tray(obj_parent) : createTrayIndicator(obj_parent);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void MainWidget::createTrayIcon()
 | 
			
		||||
{    
 | 
			
		||||
    trayIcon = createTrayObject(this);
 | 
			
		||||
    trayIcon->init();
 | 
			
		||||
 | 
			
		||||
#ifndef Q_OS_WIN32
 | 
			
		||||
    trayIcon->setIcon("qcma_off");
 | 
			
		||||
#else
 | 
			
		||||
    trayIcon->setIcon("tray/qcma_off_16");
 | 
			
		||||
#endif
 | 
			
		||||
    trayIcon->show();
 | 
			
		||||
 | 
			
		||||
    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()));
 | 
			
		||||
    connect(managerForm, SIGNAL(messageSent(QString)), this, SLOT(receiveMessage(QString)));
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void MainWidget::receiveMessage(QString message)
 | 
			
		||||
{
 | 
			
		||||
    // a timeout is added before the popups are displayed to prevent them from
 | 
			
		||||
    // appearing in the wrong location
 | 
			
		||||
    if(!sleptOnce) {
 | 
			
		||||
        Sleeper::sleep(1);
 | 
			
		||||
        sleptOnce = true;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    if(trayIcon->isVisible())
 | 
			
		||||
        trayIcon->showMessage(tr("Information"), message);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
MainWidget::~MainWidget()
 | 
			
		||||
{
 | 
			
		||||
    if(trayIcon) {
 | 
			
		||||
        trayIcon->hide();
 | 
			
		||||
    }
 | 
			
		||||
    delete db;
 | 
			
		||||
}
 | 
			
		||||
							
								
								
									
										90
									
								
								gui/mainwidget.h
									
									
									
									
									
										Normal file
									
								
							
							
						
						@@ -0,0 +1,90 @@
 | 
			
		||||
/*
 | 
			
		||||
 *  QCMA: Cross-platform content manager assistant for the PS Vita
 | 
			
		||||
 *
 | 
			
		||||
 *  Copyright (C) 2013  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 MAINWIDGET_H
 | 
			
		||||
#define MAINWIDGET_H
 | 
			
		||||
 | 
			
		||||
#include "cmaclient.h"
 | 
			
		||||
#include "clientmanager.h"
 | 
			
		||||
#include "forms/configwidget.h"
 | 
			
		||||
#include "forms/backupmanagerform.h"
 | 
			
		||||
#include "forms/progressform.h"
 | 
			
		||||
 | 
			
		||||
#include <QAction>
 | 
			
		||||
#include <QWidget>
 | 
			
		||||
 | 
			
		||||
#include <QSystemTrayIcon>
 | 
			
		||||
 | 
			
		||||
#include <vitamtp.h>
 | 
			
		||||
 | 
			
		||||
class TrayIndicator;
 | 
			
		||||
 | 
			
		||||
class MainWidget : public QWidget
 | 
			
		||||
{
 | 
			
		||||
    Q_OBJECT
 | 
			
		||||
 | 
			
		||||
public:
 | 
			
		||||
    explicit MainWidget(QWidget *parent = 0);
 | 
			
		||||
    ~MainWidget();
 | 
			
		||||
 | 
			
		||||
    void prepareApplication(bool showSystray);
 | 
			
		||||
 | 
			
		||||
private:
 | 
			
		||||
    void connectSignals();
 | 
			
		||||
    void createTrayIcon();
 | 
			
		||||
    void checkSettings();
 | 
			
		||||
    TrayIndicator *createTrayObject(QWidget *parent);
 | 
			
		||||
 | 
			
		||||
    bool first_run;
 | 
			
		||||
 | 
			
		||||
    // database
 | 
			
		||||
    Database *db;
 | 
			
		||||
 | 
			
		||||
    // forms
 | 
			
		||||
    ConfigWidget *configForm;
 | 
			
		||||
    ClientManager *managerForm;
 | 
			
		||||
    BackupManagerForm *backupForm;
 | 
			
		||||
 | 
			
		||||
    TrayIndicator *trayIcon;
 | 
			
		||||
 | 
			
		||||
    const static QStringList path_list;
 | 
			
		||||
 | 
			
		||||
signals:
 | 
			
		||||
    void deviceConnected(QString);
 | 
			
		||||
    void deviceDisconnected();
 | 
			
		||||
    void databaseUpdated(int count);
 | 
			
		||||
    void messageReceived(QString message);
 | 
			
		||||
 | 
			
		||||
public slots:
 | 
			
		||||
    void openConfig();
 | 
			
		||||
    void openManager();
 | 
			
		||||
    void showAboutQt();
 | 
			
		||||
    void showAboutDialog();
 | 
			
		||||
    void refreshDatabase();
 | 
			
		||||
    void stopServer();
 | 
			
		||||
 | 
			
		||||
private slots:
 | 
			
		||||
    void deviceConnect(QString message);
 | 
			
		||||
    void deviceDisconnect();
 | 
			
		||||
    void dialogResult(int result);
 | 
			
		||||
    void receiveMessage(QString message);
 | 
			
		||||
    void setTrayTooltip(QString message);
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
#endif // MAINWIDGET_H
 | 
			
		||||
							
								
								
									
										14
									
								
								gui/qcma.1
									
									
									
									
									
										Normal file
									
								
							
							
						
						@@ -0,0 +1,14 @@
 | 
			
		||||
.TH QCMA 1 "MARCH 2015"
 | 
			
		||||
.SH NAME
 | 
			
		||||
qcma \- Content manager for the PlayStation Vita
 | 
			
		||||
.SH SYNOPSIS
 | 
			
		||||
.B qcma
 | 
			
		||||
 | 
			
		||||
.SH DESCRIPTION
 | 
			
		||||
\fBqcma\fR is a cross-platform application to provide an Open Source implementation
 | 
			
		||||
of the original Content Manager Assistant that comes with the PS Vita.
 | 
			
		||||
.TP
 | 
			
		||||
Qcma will let you backup your games, songs, photos & videos via USB or wireless.
 | 
			
		||||
 | 
			
		||||
.SH "SEE ALSO"
 | 
			
		||||
.I /usr/share/doc/qcma/README.md
 | 
			
		||||
							
								
								
									
										1
									
								
								gui/qcma.rc
									
									
									
									
									
										Normal file
									
								
							
							
						
						@@ -0,0 +1 @@
 | 
			
		||||
IDI_ICON1 ICON DISCARDABLE "resources/images/qcma.ico"
 | 
			
		||||
							
								
								
									
										117
									
								
								gui/qtrayicon.cpp
									
									
									
									
									
										Normal 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 <QIcon>
 | 
			
		||||
#include <QMenu>
 | 
			
		||||
#include <QSystemTrayIcon>
 | 
			
		||||
 | 
			
		||||
#ifdef Q_OS_LINUX
 | 
			
		||||
#undef signals
 | 
			
		||||
extern "C" {
 | 
			
		||||
#include <libnotify/notify.h>
 | 
			
		||||
}
 | 
			
		||||
#define signals public
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
QTrayIcon::QTrayIcon(QWidget *obj_parent)
 | 
			
		||||
    : TrayIndicator(obj_parent)
 | 
			
		||||
{
 | 
			
		||||
#ifdef Q_OS_LINUX
 | 
			
		||||
    notify_init("qcma");
 | 
			
		||||
#endif
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
QTrayIcon::~QTrayIcon()
 | 
			
		||||
{
 | 
			
		||||
#ifdef Q_OS_LINUX
 | 
			
		||||
    notify_uninit();
 | 
			
		||||
#endif
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
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()));
 | 
			
		||||
 | 
			
		||||
    QMenu *tray_icon_menu = new QMenu(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_tray_icon = new QSystemTrayIcon(this);
 | 
			
		||||
    m_tray_icon->setContextMenu(tray_icon_menu);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
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);
 | 
			
		||||
#endif
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
bool QTrayIcon::isVisible()
 | 
			
		||||
{
 | 
			
		||||
    return m_tray_icon->isVisible();
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void QTrayIcon::setIcon(const QString &icon)
 | 
			
		||||
{
 | 
			
		||||
    QIcon qicon(":/main/resources/images/" + icon + ".png");
 | 
			
		||||
    m_tray_icon->setIcon(qicon);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void QTrayIcon::show()
 | 
			
		||||
{
 | 
			
		||||
    m_tray_icon->show();
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void QTrayIcon::hide()
 | 
			
		||||
{
 | 
			
		||||
    m_tray_icon->hide();
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// exported library function
 | 
			
		||||
TrayIndicator *createTrayIndicator(QWidget *parent)
 | 
			
		||||
{
 | 
			
		||||
    return new QTrayIcon(parent);
 | 
			
		||||
}
 | 
			
		||||
							
								
								
									
										53
									
								
								gui/qtrayicon.h
									
									
									
									
									
										Normal file
									
								
							
							
						
						@@ -0,0 +1,53 @@
 | 
			
		||||
/*
 | 
			
		||||
 *  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);
 | 
			
		||||
    ~QTrayIcon();
 | 
			
		||||
    void init();
 | 
			
		||||
    void setIcon(const QString &icon);
 | 
			
		||||
    bool isVisible();
 | 
			
		||||
    void show();
 | 
			
		||||
    void hide();
 | 
			
		||||
    void showMessage(const QString &title, const QString &message);
 | 
			
		||||
 | 
			
		||||
private:
 | 
			
		||||
    //system tray
 | 
			
		||||
    QAction *quit;
 | 
			
		||||
    QAction *reload;
 | 
			
		||||
    QAction *options;
 | 
			
		||||
    QAction *backup;
 | 
			
		||||
    QAction *about;
 | 
			
		||||
    QAction *about_qt;
 | 
			
		||||
 | 
			
		||||
    QSystemTrayIcon *m_tray_icon;
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
#endif // QTRAYICON_H
 | 
			
		||||
							
								
								
									
										
											BIN
										
									
								
								gui/resources/images/edit-clear-locationbar-rtl.png
									
									
									
									
									
										Normal file
									
								
							
							
						
						| 
		 After Width: | Height: | Size: 859 B  | 
							
								
								
									
										
											BIN
										
									
								
								gui/resources/images/qcma.icns
									
									
									
									
									
										Normal file
									
								
							
							
						
						
							
								
								
									
										
											BIN
										
									
								
								gui/resources/images/qcma.ico
									
									
									
									
									
										Normal file
									
								
							
							
						
						| 
		 After Width: | Height: | Size: 34 KiB  | 
							
								
								
									
										
											BIN
										
									
								
								gui/resources/images/qcma.png
									
									
									
									
									
										Normal file
									
								
							
							
						
						| 
		 After Width: | Height: | Size: 994 B  | 
							
								
								
									
										
											BIN
										
									
								
								gui/resources/images/qcma_off.png
									
									
									
									
									
										Normal file
									
								
							
							
						
						| 
		 After Width: | Height: | Size: 984 B  | 
							
								
								
									
										
											BIN
										
									
								
								gui/resources/images/qcma_on.png
									
									
									
									
									
										Normal file
									
								
							
							
						
						| 
		 After Width: | Height: | Size: 994 B  | 
							
								
								
									
										
											BIN
										
									
								
								gui/resources/images/tray/qcma_off.png
									
									
									
									
									
										Normal file
									
								
							
							
						
						| 
		 After Width: | Height: | Size: 336 B  | 
							
								
								
									
										
											BIN
										
									
								
								gui/resources/images/tray/qcma_off_16.png
									
									
									
									
									
										Normal file
									
								
							
							
						
						| 
		 After Width: | Height: | Size: 301 B  | 
							
								
								
									
										
											BIN
										
									
								
								gui/resources/images/tray/qcma_on.png
									
									
									
									
									
										Normal file
									
								
							
							
						
						| 
		 After Width: | Height: | Size: 387 B  | 
							
								
								
									
										
											BIN
										
									
								
								gui/resources/images/tray/qcma_on_16.png
									
									
									
									
									
										Normal file
									
								
							
							
						
						| 
		 After Width: | Height: | Size: 344 B  | 
							
								
								
									
										18
									
								
								gui/resources/qcma.desktop
									
									
									
									
									
										Normal file
									
								
							
							
						
						@@ -0,0 +1,18 @@
 | 
			
		||||
[Desktop Entry]
 | 
			
		||||
Encoding=UTF-8
 | 
			
		||||
Exec=qcma
 | 
			
		||||
GenericName=Content Manager Assistant
 | 
			
		||||
GenericName[es]=Asistente del Gestor de Contenido
 | 
			
		||||
GenericName[fr]=Gestionnaire de contenu
 | 
			
		||||
Comment=Content Manager Assistant for the PS Vita
 | 
			
		||||
Comment[es]=Asistente del Gestor de Contenido para PS Vita
 | 
			
		||||
Comment[fr]=Gestionnaire de contenu pour la PS Vita
 | 
			
		||||
Icon=qcma.png
 | 
			
		||||
Name=QCMA
 | 
			
		||||
Path=
 | 
			
		||||
StartupNotify=false
 | 
			
		||||
Terminal=false
 | 
			
		||||
Type=Application
 | 
			
		||||
Version=1.0
 | 
			
		||||
X-KDE-SubstituteUID=false
 | 
			
		||||
Categories=Qt;Utility;
 | 
			
		||||
							
								
								
									
										69
									
								
								gui/singleapplication.cpp
									
									
									
									
									
										Normal file
									
								
							
							
						
						@@ -0,0 +1,69 @@
 | 
			
		||||
/*
 | 
			
		||||
 *  QCMA: Cross-platform content manager assistant for the PS Vita
 | 
			
		||||
 *
 | 
			
		||||
 *  Copyright (C) 2013  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 "singleapplication.h"
 | 
			
		||||
 | 
			
		||||
#include <QDebug>
 | 
			
		||||
 | 
			
		||||
const int SingleApplication::timeout = 500;
 | 
			
		||||
const QString SingleApplication::SHARED_KEY = "QCMA_KEY";
 | 
			
		||||
 | 
			
		||||
SingleApplication::SingleApplication(int &s_argc, char **s_argv) :
 | 
			
		||||
    QApplication(s_argc, s_argv)
 | 
			
		||||
{
 | 
			
		||||
    server = new QLocalServer(this);
 | 
			
		||||
    connect(server, SIGNAL(newConnection()), this, SLOT(receiveMessage()));
 | 
			
		||||
    QLocalServer::removeServer(SHARED_KEY);
 | 
			
		||||
    server->listen(SHARED_KEY);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void SingleApplication::receiveMessage()
 | 
			
		||||
{
 | 
			
		||||
    QLocalSocket *socket = server->nextPendingConnection();
 | 
			
		||||
 | 
			
		||||
    if(!socket->waitForReadyRead(timeout)) {
 | 
			
		||||
        qDebug() << socket->errorString();
 | 
			
		||||
        return;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    QByteArray byteArray = socket->readAll();
 | 
			
		||||
    QString message = QString::fromUtf8(byteArray.constData());
 | 
			
		||||
    emit messageAvailable(message);
 | 
			
		||||
    socket->disconnectFromServer();
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
bool SingleApplication::sendMessage(const QString &message)
 | 
			
		||||
{
 | 
			
		||||
    QLocalSocket socket;
 | 
			
		||||
    socket.connectToServer(SHARED_KEY, QIODevice::WriteOnly);
 | 
			
		||||
 | 
			
		||||
    if(!socket.waitForConnected(timeout)) {
 | 
			
		||||
        return false;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    socket.write(message.toUtf8());
 | 
			
		||||
 | 
			
		||||
    if(!socket.waitForBytesWritten(timeout)) {
 | 
			
		||||
        qDebug() << socket.errorString();
 | 
			
		||||
        return false;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    socket.disconnectFromServer();
 | 
			
		||||
    return true;
 | 
			
		||||
}
 | 
			
		||||
							
								
								
									
										50
									
								
								gui/singleapplication.h
									
									
									
									
									
										Normal file
									
								
							
							
						
						@@ -0,0 +1,50 @@
 | 
			
		||||
/*
 | 
			
		||||
 *  QCMA: Cross-platform content manager assistant for the PS Vita
 | 
			
		||||
 *
 | 
			
		||||
 *  Copyright (C) 2013  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 SINGLEAPPLICATION_H
 | 
			
		||||
#define SINGLEAPPLICATION_H
 | 
			
		||||
 | 
			
		||||
#include <QApplication>
 | 
			
		||||
#include <QLocalSocket>
 | 
			
		||||
#include <QLocalServer>
 | 
			
		||||
#include <QSharedMemory>
 | 
			
		||||
 | 
			
		||||
class SingleApplication : public QApplication
 | 
			
		||||
{
 | 
			
		||||
    Q_OBJECT
 | 
			
		||||
public:
 | 
			
		||||
    explicit SingleApplication(int &argc, char **argv);
 | 
			
		||||
 | 
			
		||||
    static bool sendMessage(const QString &message);
 | 
			
		||||
 | 
			
		||||
private:
 | 
			
		||||
    QLocalServer *server;
 | 
			
		||||
 | 
			
		||||
    static const int timeout;
 | 
			
		||||
    static const QString SHARED_KEY;
 | 
			
		||||
 | 
			
		||||
signals:
 | 
			
		||||
    void messageAvailable(QString message);
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
public slots:
 | 
			
		||||
    void receiveMessage();
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
#endif // SINGLEAPPLICATION_H
 | 
			
		||||
							
								
								
									
										62
									
								
								gui/trayindicator.h
									
									
									
									
									
										Normal 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 TRAYINDICATOR_H
 | 
			
		||||
#define TRAYINDICATOR_H
 | 
			
		||||
 | 
			
		||||
#include <QString>
 | 
			
		||||
#include <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
 | 
			
		||||
public:
 | 
			
		||||
    ~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) = 0;
 | 
			
		||||
    virtual void show() = 0;
 | 
			
		||||
    virtual void hide() = 0;
 | 
			
		||||
 | 
			
		||||
protected:
 | 
			
		||||
    TrayIndicator(QWidget *obj_parent = 0) : QWidget(obj_parent) {}
 | 
			
		||||
 | 
			
		||||
signals:
 | 
			
		||||
    void openConfig();
 | 
			
		||||
    void openManager();
 | 
			
		||||
    void refreshDatabase();
 | 
			
		||||
    void showAboutDialog();
 | 
			
		||||
    void showAboutQt();
 | 
			
		||||
    void stopServer();
 | 
			
		||||
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
typedef TrayIndicator *(*TrayFunctionPointer)(QWidget *parent);
 | 
			
		||||
extern "C" TRAYINDICATORSHARED_EXPORT TrayIndicator *createTrayIndicator(QWidget *parent = 0);
 | 
			
		||||
 | 
			
		||||
#endif // TRAYINDICATOR_H
 | 
			
		||||
							
								
								
									
										35
									
								
								gui/trayindicator_global.h
									
									
									
									
									
										Normal file
									
								
							
							
						
						@@ -0,0 +1,35 @@
 | 
			
		||||
/*
 | 
			
		||||
 *  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>
 | 
			
		||||
 | 
			
		||||
#ifdef Q_OS_LINUX
 | 
			
		||||
#if defined(QCMA_TRAYINDICATOR_LIBRARY)
 | 
			
		||||
#  define TRAYINDICATORSHARED_EXPORT Q_DECL_EXPORT
 | 
			
		||||
#else
 | 
			
		||||
#  define TRAYINDICATORSHARED_EXPORT Q_DECL_IMPORT
 | 
			
		||||
#endif
 | 
			
		||||
#else
 | 
			
		||||
#  define TRAYINDICATORSHARED_EXPORT
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
#endif // TRAYINDICATOR_GLOBAL_H
 | 
			
		||||