Qualify as avatar added

This commit is contained in:
Rafael 2016-12-14 00:21:06 +01:00
parent 3184049565
commit 5c9ac81f8e
3 changed files with 420 additions and 0 deletions

212
SnapmaticEditor.cpp Normal file
View file

@ -0,0 +1,212 @@
/*****************************************************************************
* gta5sync GRAND THEFT AUTO V SYNC
* Copyright (C) 2016 Syping
*
* 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 "SnapmaticEditor.h"
#include "ui_SnapmaticEditor.h"
#include "SnapmaticPicture.h"
#include <QMessageBox>
#include <QDebug>
#include <QFile>
SnapmaticEditor::SnapmaticEditor(QWidget *parent) :
QDialog(parent),
ui(new Ui::SnapmaticEditor)
{
ui->setupUi(this);
smpic = 0;
}
SnapmaticEditor::~SnapmaticEditor()
{
delete ui;
}
void SnapmaticEditor::on_cbSelfie_toggled(bool checked)
{
if (checked)
{
ui->cbMugshot->setEnabled(false);
ui->cbEditor->setEnabled(false);
}
else if (!ui->cbDirector->isChecked())
{
ui->cbMugshot->setEnabled(true);
ui->cbEditor->setEnabled(true);
}
}
void SnapmaticEditor::on_cbMugshot_toggled(bool checked)
{
if (checked)
{
ui->cbSelfie->setEnabled(false);
ui->cbEditor->setEnabled(false);
ui->cbDirector->setEnabled(false);
}
else
{
ui->cbSelfie->setEnabled(true);
ui->cbEditor->setEnabled(true);
ui->cbDirector->setEnabled(true);
}
}
void SnapmaticEditor::on_cbDirector_toggled(bool checked)
{
if (checked)
{
ui->cbMugshot->setEnabled(false);
ui->cbEditor->setEnabled(false);
}
else if (!ui->cbSelfie->isChecked())
{
ui->cbMugshot->setEnabled(true);
ui->cbEditor->setEnabled(true);
}
}
void SnapmaticEditor::on_cbEditor_toggled(bool checked)
{
if (checked)
{
ui->cbSelfie->setEnabled(false);
ui->cbMugshot->setEnabled(false);
ui->cbDirector->setEnabled(false);
}
else
{
ui->cbSelfie->setEnabled(true);
ui->cbMugshot->setEnabled(true);
ui->cbDirector->setEnabled(true);
}
}
void SnapmaticEditor::on_rbSelfie_toggled(bool checked)
{
if (checked)
{
ui->cbSelfie->setChecked(true);
ui->cbMugshot->setChecked(false);
ui->cbEditor->setChecked(false);
ui->cbDirector->setChecked(false);
ui->cbMeme->setChecked(false);
ui->cbSelfie->setEnabled(false);
ui->cbMugshot->setEnabled(false);
ui->cbEditor->setEnabled(false);
ui->cbDirector->setEnabled(false);
ui->cbMeme->setEnabled(false);
}
}
void SnapmaticEditor::on_rbMugshot_toggled(bool checked)
{
if (checked)
{
ui->cbSelfie->setChecked(false);
ui->cbMugshot->setChecked(true);
ui->cbEditor->setChecked(false);
ui->cbDirector->setChecked(false);
ui->cbMeme->setChecked(false);
ui->cbSelfie->setEnabled(false);
ui->cbMugshot->setEnabled(false);
ui->cbEditor->setEnabled(false);
ui->cbDirector->setEnabled(false);
ui->cbMeme->setEnabled(false);
}
}
void SnapmaticEditor::on_rbEditor_toggled(bool checked)
{
if (checked)
{
ui->cbSelfie->setChecked(false);
ui->cbMugshot->setChecked(false);
ui->cbEditor->setChecked(true);
ui->cbDirector->setChecked(false);
ui->cbMeme->setChecked(false);
ui->cbSelfie->setEnabled(false);
ui->cbMugshot->setEnabled(false);
ui->cbEditor->setEnabled(false);
ui->cbDirector->setEnabled(false);
ui->cbMeme->setEnabled(false);
}
}
void SnapmaticEditor::on_rbCustom_toggled(bool checked)
{
if (checked)
{
ui->cbSelfie->setChecked(false);
ui->cbMugshot->setChecked(false);
ui->cbEditor->setChecked(false);
ui->cbDirector->setChecked(false);
ui->cbMeme->setChecked(false);
ui->cbSelfie->setEnabled(true);
ui->cbMugshot->setEnabled(true);
ui->cbEditor->setEnabled(true);
ui->cbDirector->setEnabled(true);
ui->cbMeme->setEnabled(true);
}
}
void SnapmaticEditor::setSnapmaticPicture(SnapmaticPicture *picture)
{
smpic = picture;
localSpJson = smpic->getSnapmaticProperties();
ui->rbCustom->setChecked(true);
ui->cbSelfie->setChecked(localSpJson.isSelfie);
ui->cbMugshot->setChecked(localSpJson.isMug);
ui->cbEditor->setChecked(localSpJson.isFromRSEditor);
ui->cbDirector->setChecked(localSpJson.isFromDirector);
ui->cbMeme->setChecked(localSpJson.isMeme);
}
void SnapmaticEditor::on_cmdCancel_clicked()
{
close();
}
void SnapmaticEditor::on_cmdApply_clicked()
{
localSpJson.isSelfie = ui->cbSelfie->isChecked();
localSpJson.isMug = ui->cbMugshot->isChecked();
localSpJson.isFromRSEditor = ui->cbEditor->isChecked();
localSpJson.isFromDirector = ui->cbDirector->isChecked();
localSpJson.isMeme = ui->cbMeme->isChecked();
if (smpic)
{
QString originalFileName = smpic->getPictureFileName();
QString adjustedFileName = originalFileName;
QString backupFileName = originalFileName + ".bak";
if (adjustedFileName.right(7) == ".hidden") // for the hidden file system
{
adjustedFileName.remove(adjustedFileName.length() - 7, 7);
}
if (!QFile::exists(backupFileName))
{
QFile::copy(adjustedFileName, backupFileName);
}
smpic->setSnapmaticProperties(localSpJson);
if (!smpic->exportPicture(adjustedFileName))
{
QMessageBox::warning(this, tr("Snapmatic Properties"), tr("Patching of Snapmatic Properties failed because of I/O Error"));
}
}
close();
}

56
SnapmaticEditor.h Normal file
View file

@ -0,0 +1,56 @@
/*****************************************************************************
* gta5sync GRAND THEFT AUTO V SYNC
* Copyright (C) 2016 Syping
*
* 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 SNAPMATICEDITOR_H
#define SNAPMATICEDITOR_H
#include <QDialog>
#include "SnapmaticPicture.h"
namespace Ui {
class SnapmaticEditor;
}
class SnapmaticEditor : public QDialog
{
Q_OBJECT
public:
explicit SnapmaticEditor(QWidget *parent = 0);
void setSnapmaticPicture(SnapmaticPicture *picture);
~SnapmaticEditor();
private slots:
void on_cbSelfie_toggled(bool checked);
void on_cbMugshot_toggled(bool checked);
void on_cbDirector_toggled(bool checked);
void on_cbEditor_toggled(bool checked);
void on_rbSelfie_toggled(bool checked);
void on_rbMugshot_toggled(bool checked);
void on_rbEditor_toggled(bool checked);
void on_rbCustom_toggled(bool checked);
void on_cmdCancel_clicked();
void on_cmdApply_clicked();
private:
Ui::SnapmaticEditor *ui;
SnapmaticProperties localSpJson;
SnapmaticPicture *smpic;
};
#endif // SNAPMATICEDITOR_H

152
SnapmaticEditor.ui Normal file
View file

@ -0,0 +1,152 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>SnapmaticEditor</class>
<widget class="QDialog" name="SnapmaticEditor">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>350</width>
<height>250</height>
</rect>
</property>
<property name="windowTitle">
<string>Snapmatic Properties</string>
</property>
<layout class="QVBoxLayout" name="vlEditor">
<item>
<widget class="QGroupBox" name="gbMode">
<property name="title">
<string>Snapmatic Type</string>
</property>
<layout class="QGridLayout" name="gridLayout_2">
<item row="2" column="0">
<widget class="QRadioButton" name="rbEditor">
<property name="text">
<string>Editor</string>
</property>
</widget>
</item>
<item row="0" column="0">
<widget class="QRadioButton" name="rbSelfie">
<property name="text">
<string>Selfie</string>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QRadioButton" name="rbMugshot">
<property name="text">
<string>Mugshot</string>
</property>
</widget>
</item>
<item row="2" column="1">
<widget class="QRadioButton" name="rbCustom">
<property name="text">
<string>Custom</string>
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item>
<widget class="QGroupBox" name="gbProperties">
<property name="title">
<string>Snapmatic Properties</string>
</property>
<layout class="QGridLayout" name="gridLayout">
<item row="0" column="0">
<widget class="QCheckBox" name="cbSelfie">
<property name="text">
<string>Selfie</string>
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="QCheckBox" name="cbDirector">
<property name="text">
<string>Director</string>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QCheckBox" name="cbMeme">
<property name="text">
<string>Meme</string>
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QCheckBox" name="cbMugshot">
<property name="text">
<string>Mugshot</string>
</property>
</widget>
</item>
<item row="2" column="0">
<widget class="QCheckBox" name="cbEditor">
<property name="text">
<string>Editor</string>
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item>
<spacer name="vsEditor">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>0</width>
<height>0</height>
</size>
</property>
</spacer>
</item>
<item>
<layout class="QHBoxLayout" name="hlButtons">
<item>
<spacer name="hsButtons">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>0</width>
<height>0</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QPushButton" name="cmdApply">
<property name="text">
<string>&amp;Apply</string>
</property>
<property name="icon">
<iconset theme="dialog-apply"/>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="cmdCancel">
<property name="text">
<string>&amp;Cancel</string>
</property>
<property name="icon">
<iconset theme="dialog-cancel"/>
</property>
</widget>
</item>
</layout>
</item>
</layout>
</widget>
<resources/>
<connections/>
</ui>