Changed folder structure
This commit is contained in:
87
src/forms/backupitem.cpp
Normal file
87
src/forms/backupitem.cpp
Normal file
@@ -0,0 +1,87 @@
|
||||
/*
|
||||
* 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 "../utils.h"
|
||||
|
||||
#include <QDesktopServices>
|
||||
#include <QUrl>
|
||||
|
||||
const QString BackupItem::nameTemplate = "<html><head/><body>"
|
||||
"<p><span style=\" font-size:12pt; font-weight:600;\">%1</span></p>"
|
||||
"<p><span style=\" font-size:10pt;\">%2</span></p>"
|
||||
"</body></html>";
|
||||
|
||||
BackupItem::BackupItem(QWidget *parent) :
|
||||
QWidget(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:///" + path));
|
||||
}
|
||||
|
||||
void BackupItem::removeEntry()
|
||||
{
|
||||
emit deleteEntry(this);
|
||||
}
|
||||
|
||||
const QPixmap *BackupItem::getIconPixmap()
|
||||
{
|
||||
return ui->itemPicture->pixmap();
|
||||
}
|
||||
|
||||
void BackupItem::setDirectory(const QString path)
|
||||
{
|
||||
this->path = path;
|
||||
}
|
||||
|
||||
void BackupItem::setItemInfo(const QString name, const QString size)
|
||||
{
|
||||
ui->itemName->setText(nameTemplate.arg(name, size));
|
||||
}
|
||||
|
||||
int BackupItem::getIconWidth()
|
||||
{
|
||||
return ui->itemPicture->width();
|
||||
}
|
||||
|
||||
void BackupItem::setItemIcon(const QString path, int width)
|
||||
{
|
||||
ui->itemPicture->setMinimumWidth(width);
|
||||
ui->itemPicture->setPixmap(QPixmap(path));
|
||||
}
|
||||
|
||||
bool BackupItem::lessThan(const BackupItem *s1, const BackupItem *s2)
|
||||
{
|
||||
return s1->title.compare(s2->title) < 0;
|
||||
}
|
||||
|
62
src/forms/backupitem.h
Normal file
62
src/forms/backupitem.h
Normal file
@@ -0,0 +1,62 @@
|
||||
/*
|
||||
* 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);
|
||||
void setItemIcon(const QString path, int width = 48);
|
||||
void setDirectory(const QString path);
|
||||
const QPixmap *getIconPixmap();
|
||||
int getIconWidth();
|
||||
|
||||
static bool lessThan(const BackupItem *s1, const BackupItem *s2);
|
||||
|
||||
int row;
|
||||
int ohfi;
|
||||
QString title;
|
||||
|
||||
private:
|
||||
QString path;
|
||||
Ui::BackupItem *ui;
|
||||
static const QString nameTemplate;
|
||||
|
||||
signals:
|
||||
void deleteEntry(BackupItem *entry);
|
||||
|
||||
private slots:
|
||||
void openDirectory();
|
||||
void removeEntry();
|
||||
};
|
||||
|
||||
#endif // BACKUPITEM_H
|
102
src/forms/backupitem.ui
Normal file
102
src/forms/backupitem.ui
Normal file
@@ -0,0 +1,102 @@
|
||||
<?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>634</width>
|
||||
<height>86</height>
|
||||
</rect>
|
||||
</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/>
|
||||
</property>
|
||||
<property name="scaledContents">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignCenter</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLabel" name="itemName">
|
||||
<property name="text">
|
||||
<string><html><head/><body><p><span style=" font-size:12pt; font-weight:600;">Game Name</span></p><p><span style=" font-size:10pt;">0.00 GiB</span></p></body></html></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="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>
|
221
src/forms/backupmanagerform.cpp
Normal file
221
src/forms/backupmanagerform.cpp
Normal file
@@ -0,0 +1,221 @@
|
||||
/*
|
||||
* 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 "../utils.h"
|
||||
#include "filterlineedit.h"
|
||||
|
||||
#include <QDebug>
|
||||
#include <QDialogButtonBox>
|
||||
#include <QDir>
|
||||
#include <QSettings>
|
||||
|
||||
#include <vitamtp.h>
|
||||
|
||||
BackupManagerForm::BackupManagerForm(QWidget *parent) :
|
||||
QWidget(parent),
|
||||
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();
|
||||
// the the account name when vitamtp returns this value
|
||||
ui->accountBox->addItem(QSettings().value("lastOnlineId", tr("Default account")).toString());
|
||||
}
|
||||
|
||||
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(&db->mutex);
|
||||
|
||||
CMAObject *obj = db->ohfiToObject(item->ohfi);
|
||||
if(obj) {
|
||||
obj->removeReferencedObject();
|
||||
db->remove(obj);
|
||||
}
|
||||
ui->tableWidget->removeRow(item->row);
|
||||
obj = db->ohfiToObject(obj->metadata.ohfiParent);
|
||||
if(obj) {
|
||||
setBackupUsage(obj->metadata.size);
|
||||
}
|
||||
}
|
||||
|
||||
void BackupManagerForm::setBackupUsage(quint64 size)
|
||||
{
|
||||
ui->usageLabel->setText(tr("Backup disk usage: %1").arg(readable_size(size, true)));
|
||||
}
|
||||
|
||||
void BackupManagerForm::loadBackupListing(int index)
|
||||
{
|
||||
int ohfi;
|
||||
bool sys_dir;
|
||||
int img_width;
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
db->mutex.lock();
|
||||
|
||||
// get the item list
|
||||
metadata_t *meta;
|
||||
int row_count = db->filterObjects(ohfi, &meta);
|
||||
ui->tableWidget->setRowCount(row_count);
|
||||
|
||||
// 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
|
||||
CMAObject *obj = db->ohfiToObject(ohfi);
|
||||
setBackupUsage(obj->metadata.size);
|
||||
|
||||
QList<BackupItem *> item_list;
|
||||
|
||||
while(meta) {
|
||||
QString base_path = obj->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*)));
|
||||
QString size = readable_size(meta->size);
|
||||
|
||||
// check if the game data is present, else is just a LiveArea launcher
|
||||
if(sys_dir && !(QDir(base_path + QDir::separator() + "app").exists() || QDir(base_path + QDir::separator() + "game").exists())) {
|
||||
size.append(tr(" - (Launcher only)"));
|
||||
}
|
||||
|
||||
item->setItemInfo(game_name, size);
|
||||
item->setItemIcon(QDir(parent_path).absoluteFilePath(sys_dir ? "icon0.png" : "ICON0.PNG"), img_width);
|
||||
item->setDirectory(obj->path + QDir::separator() + meta->name);
|
||||
item->resize(646, 70);
|
||||
|
||||
item_list << item;
|
||||
meta = meta->next_metadata;
|
||||
}
|
||||
|
||||
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) {
|
||||
(*it)->row = row;
|
||||
ui->tableWidget->setCellWidget(row, 0, *it);
|
||||
vert_header->resizeSection(row, 70);
|
||||
}
|
||||
|
||||
vert_header->setUpdatesEnabled(true);
|
||||
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
src/forms/backupmanagerform.h
Normal file
55
src/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 <QWidget>
|
||||
|
||||
namespace Ui {
|
||||
class BackupManagerForm;
|
||||
}
|
||||
|
||||
class BackupManagerForm : public QWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit BackupManagerForm(QWidget *parent = 0);
|
||||
~BackupManagerForm();
|
||||
|
||||
Database *db;
|
||||
|
||||
private:
|
||||
void setupForm();
|
||||
void setBackupUsage(quint64 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
src/forms/backupmanagerform.ui
Normal file
139
src/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="1" column="0">
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_2">
|
||||
<item>
|
||||
<layout class="QFormLayout" name="formLayout">
|
||||
<item row="0" column="0">
|
||||
<widget class="QLabel" name="label">
|
||||
<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_2">
|
||||
<property name="fieldGrowthPolicy">
|
||||
<enum>QFormLayout::AllNonFixedFieldsGrow</enum>
|
||||
</property>
|
||||
<item row="0" column="0">
|
||||
<widget class="QLabel" name="label_2">
|
||||
<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="2" column="0">
|
||||
<widget class="QTableWidget" name="tableWidget">
|
||||
<property name="columnCount">
|
||||
<number>1</number>
|
||||
</property>
|
||||
<column/>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="3" 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">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>
|
150
src/forms/configwidget.cpp
Normal file
150
src/forms/configwidget.cpp
Normal file
@@ -0,0 +1,150 @@
|
||||
/*
|
||||
* 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 *parent) :
|
||||
QDialog(parent),
|
||||
ui(new Ui::ConfigWidget)
|
||||
{
|
||||
ui->setupUi(this);
|
||||
connectSignals();
|
||||
setDefaultDirs();
|
||||
}
|
||||
|
||||
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);
|
||||
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(mapper, SIGNAL(mapped(int)), this, SLOT(browseBtnPressed(int)));
|
||||
connect(ui->buttonBox, SIGNAL(accepted()), this, SLOT(accept()));
|
||||
connect(ui->buttonBox, SIGNAL(rejected()), this, SLOT(reject()));
|
||||
}
|
||||
|
||||
void ConfigWidget::setDefaultDirs()
|
||||
{
|
||||
QString defaultdir;
|
||||
QSettings settings;
|
||||
defaultdir = QStandardPaths::writableLocation(QStandardPaths::PicturesLocation);
|
||||
ui->photoPath->setText(settings.value("photoPath", defaultdir).toString());
|
||||
defaultdir = QStandardPaths::writableLocation(QStandardPaths::MusicLocation);
|
||||
ui->musicPath->setText(settings.value("musicPath", defaultdir).toString());
|
||||
defaultdir = QStandardPaths::writableLocation(QStandardPaths::MoviesLocation);
|
||||
ui->videoPath->setText(settings.value("videoPath", defaultdir).toString());
|
||||
defaultdir = QStandardPaths::writableLocation(QStandardPaths::HomeLocation);
|
||||
defaultdir.append(QDir::separator()).append("PS Vita");
|
||||
ui->appPath->setText(settings.value("appsPath", defaultdir).toString());
|
||||
defaultdir = QStandardPaths::writableLocation(QStandardPaths::HomeLocation);
|
||||
defaultdir.append(QDir::separator()).append("PSV Updates");
|
||||
ui->urlPath->setText(settings.value("urlPath", defaultdir).toString());
|
||||
}
|
||||
|
||||
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;
|
||||
|
||||
default:
|
||||
return;
|
||||
}
|
||||
|
||||
QString selected = QFileDialog::getExistingDirectory(this, msg, lineedit->text(), QFileDialog::ShowDirsOnly);
|
||||
|
||||
if(!selected.isEmpty()) {
|
||||
lineedit->setText(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, 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");
|
||||
settings.sync();
|
||||
done(Accepted);
|
||||
}
|
54
src/forms/configwidget.h
Normal file
54
src/forms/configwidget.h
Normal file
@@ -0,0 +1,54 @@
|
||||
/*
|
||||
* 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};
|
||||
|
||||
void connectSignals();
|
||||
void setDefaultDirs();
|
||||
void savePath(QSettings &settings, const QLineEdit *edit, const QString &key);
|
||||
|
||||
Ui::ConfigWidget *ui;
|
||||
|
||||
private slots:
|
||||
void browseBtnPressed(int from);
|
||||
void accept();
|
||||
};
|
||||
|
||||
#endif // CONFIGWIDGET_H
|
342
src/forms/configwidget.ui
Normal file
342
src/forms/configwidget.ui
Normal file
@@ -0,0 +1,342 @@
|
||||
<?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>520</width>
|
||||
<height>405</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="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 Software Updates and Browser Data is Saved to/Imported from.</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>
|
||||
</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="checkBox">
|
||||
<property name="enabled">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Offline Mode</string>
|
||||
</property>
|
||||
<property name="checked">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QCheckBox" name="checkBox_2">
|
||||
<property name="enabled">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Skip metadata extraction</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>
|
||||
<widget class="QCheckBox" name="checkBox_4">
|
||||
<property name="enabled">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Disable USB monitoring</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QCheckBox" name="checkBox_5">
|
||||
<property name="enabled">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Disable Wi-Fi monitoring</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QFormLayout" name="formLayout">
|
||||
<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="comboBox">
|
||||
<property name="enabled">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>In Memory</string>
|
||||
</property>
|
||||
</item>
|
||||
</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
src/forms/confirmdialog.cpp
Normal file
50
src/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 *parent) :
|
||||
QDialog(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 width)
|
||||
{
|
||||
ui->itemPicture->setPixmap(pixmap);
|
||||
ui->itemPicture->setMinimumWidth(width);
|
||||
}
|
||||
|
||||
ConfirmDialog::~ConfirmDialog()
|
||||
{
|
||||
delete ui;
|
||||
}
|
46
src/forms/confirmdialog.h
Normal file
46
src/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
src/forms/confirmdialog.ui
Normal file
120
src/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
src/forms/pinform.cpp
Normal file
71
src/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 *parent) :
|
||||
QWidget(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
src/forms/pinform.h
Normal file
55
src/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
src/forms/pinform.ui
Normal file
115
src/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>
|
64
src/forms/progressform.cpp
Normal file
64
src/forms/progressform.cpp
Normal file
@@ -0,0 +1,64 @@
|
||||
/*
|
||||
* 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 *parent) :
|
||||
QWidget(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);
|
||||
}
|
51
src/forms/progressform.h
Normal file
51
src/forms/progressform.h
Normal file
@@ -0,0 +1,51 @@
|
||||
/*
|
||||
* 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 <QWidget>
|
||||
|
||||
namespace Ui {
|
||||
class ProgressForm;
|
||||
}
|
||||
|
||||
class ProgressForm : public QWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit ProgressForm(QWidget *parent = 0);
|
||||
~ProgressForm();
|
||||
|
||||
private:
|
||||
Ui::ProgressForm *ui;
|
||||
|
||||
signals:
|
||||
void canceled();
|
||||
|
||||
private slots:
|
||||
void cancelConfirm();
|
||||
|
||||
public slots:
|
||||
void setDirectoryName(QString dir);
|
||||
void setFileName(QString file);
|
||||
};
|
||||
|
||||
#endif // PROGRESSFORM_H
|
80
src/forms/progressform.ui
Normal file
80
src/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>
|
Reference in New Issue
Block a user