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.
This commit is contained in:
codestation
2015-03-21 14:48:25 -04:30
parent c223016725
commit 9f790dc788
106 changed files with 13921 additions and 0 deletions

104
gui/forms/backupitem.cpp Normal file
View 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;\">&nbsp;%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
View 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
View 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">&lt;p&gt;&lt;span style=&quot; font-size:12pt; font-weight:600;&quot;&gt;Game Name&lt;/span&gt;&lt;/p&gt;</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">&lt;p&gt;&lt;span style=&quot; font-size:10pt;&quot;&gt;0.00 GiB&lt;/span&gt;&lt;/p&gt;</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">&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;&lt;span style=&quot; font-size:9pt;&quot;&gt;[APP] [SAVE] [UPDATE] [DLC]&lt;/span&gt;&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</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>

View 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);
}
}
}
}

View 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

View 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
View 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
View 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
View 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>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p align=&quot;center&quot;&gt;&lt;span style=&quot; font-size:14pt; font-weight:600;&quot;&gt;Advanced settings&lt;/span&gt;&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</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>

View 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
View 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
View 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>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;&lt;span style=&quot; font-size:10pt;&quot;&gt;Are you sure to delete the backup of the following game?&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style=&quot; font-size:12pt; font-weight:600;&quot;&gt;Game Name&lt;/span&gt;&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;
</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
View 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
View 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
View 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>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;&lt;span style=&quot; font-size:24pt; font-weight:600;&quot;&gt;12345678&lt;/span&gt;&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</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>

View 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
View 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
View 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>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;&lt;span style=&quot; font-size:11pt; font-weight:600;&quot;&gt;Reading directory:&lt;/span&gt;&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</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>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;&lt;span style=&quot; font-size:11pt; font-weight:600;&quot;&gt;Processing file:&lt;/span&gt;&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</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>