Browse Source

added mass tool and improved import

1.5.x
Syping 4 years ago
parent
commit
9b6253b848
  1. 8
      .travis.yml
  2. 4
      AboutDialog.cpp
  3. 185
      ImageEditorDialog.cpp
  4. 53
      ImageEditorDialog.h
  5. 130
      ImageEditorDialog.ui
  6. 148
      ImportDialog.cpp
  7. 6
      ImportDialog.h
  8. 194
      ImportDialog.ui
  9. 4
      JsonEditorDialog.cpp
  10. 4
      MapLocationDialog.cpp
  11. 6
      OptionsDialog.cpp
  12. 70
      PictureDialog.cpp
  13. 5
      PictureDialog.h
  14. 17
      PlayerListDialog.cpp
  15. 3
      PlayerListDialog.h
  16. 427
      ProfileInterface.cpp
  17. 3
      ProfileInterface.h
  18. 23
      SavegameDialog.cpp
  19. 1
      SavegameDialog.h
  20. 13
      SnapmaticEditor.cpp
  21. 26
      SnapmaticPicture.cpp
  22. 3
      SnapmaticPicture.h
  23. 33
      SnapmaticWidget.cpp
  24. 5
      SnapmaticWidget.h
  25. 22
      UserInterface.cpp
  26. 4
      UserInterface.h
  27. 68
      UserInterface.ui
  28. 2
      config.h
  29. 3
      gta5view.pro
  30. 4
      main.cpp
  31. 4
      res/app.rc
  32. BIN
      res/gta5sync_de.qm
  33. 778
      res/gta5sync_de.ts
  34. BIN
      res/gta5sync_en_US.qm
  35. 834
      res/gta5sync_en_US.ts
  36. BIN
      res/gta5sync_fr.qm
  37. 710
      res/gta5sync_fr.ts
  38. BIN
      res/gta5sync_ru.qm
  39. 714
      res/gta5sync_ru.ts
  40. 16450
      res/qtbase_en_GB.ts

8
.travis.yml

@ -32,14 +32,14 @@ before_script:
script:
- cd qt5
- qmake -qt=5 GTA5SYNC_PREFIX=/usr QMAKE_CXXFLAGS+=-std=c++11 DEFINES+=GTA5SYNC_BUILDTYPE_DEV "DEFINES+=GTA5SYNC_APPVER=\\\\\\\"$PACKAGE_VERSION-dev6\\\\\\\"" DEFINES+=GTA5SYNC_QCONF ../../gta5view.pro
- qmake -qt=5 GTA5SYNC_PREFIX=/usr QMAKE_CXXFLAGS+=-std=c++11 DEFINES+=GTA5SYNC_BUILDTYPE_DEV "DEFINES+=GTA5SYNC_APPVER=\\\\\\\"$PACKAGE_VERSION-dev7\\\\\\\"" DEFINES+=GTA5SYNC_QCONF ../../gta5view.pro
- make -j 4
- sudo checkinstall -D --default --nodoc --install=no --pkgname=gta5view-qt5 --pkgversion=$PACKAGE_VERSION --pkgrelease=dev6 --pkggroup=utility --maintainer="Syping on Travis \<[email protected]\>" --requires=libqt5core5a,libqt5gui5,libqt5network5,libqt5widgets5,qttranslations5-l10n --conflicts=gta5view,gta5view-qt4 --replaces=gta5view,gta5view-qt4 --pakdir=../../package
- sudo checkinstall -D --default --nodoc --install=no --pkgname=gta5view-qt5 --pkgversion=$PACKAGE_VERSION --pkgrelease=dev7 --pkggroup=utility --maintainer="Syping on Travis \<[email protected]\>" --requires=libqt5core5a,libqt5gui5,libqt5network5,libqt5widgets5,qttranslations5-l10n --conflicts=gta5view,gta5view-qt4 --replaces=gta5view,gta5view-qt4 --pakdir=../../package
- cd ..
- cd qt4
- qmake -qt=4 GTA5SYNC_PREFIX=/usr QMAKE_CXXFLAGS+=-std=c++11 DEFINES+=GTA5SYNC_BUILDTYPE_DEV "DEFINES+=GTA5SYNC_APPVER=\\\\\\\"$PACKAGE_VERSION-dev6\\\\\\\"" DEFINES+=GTA5SYNC_QCONF ../../gta5view.pro
- qmake -qt=4 GTA5SYNC_PREFIX=/usr QMAKE_CXXFLAGS+=-std=c++11 DEFINES+=GTA5SYNC_BUILDTYPE_DEV "DEFINES+=GTA5SYNC_APPVER=\\\\\\\"$PACKAGE_VERSION-dev7\\\\\\\"" DEFINES+=GTA5SYNC_QCONF ../../gta5view.pro
- make -j 4
- sudo checkinstall -D --default --nodoc --install=no --pkgname=gta5view-qt4 --pkgversion=$PACKAGE_VERSION --pkgrelease=dev6 --pkggroup=utility --maintainer="Syping on Travis \<[email protected]\>" --requires=libqtcore4,libqtgui4,libqt4-network,qtcore4-l10n --conflicts=gta5view,gta5view-qt5 --replaces=gta5view,gta5view-qt5 --pakdir=../../package
- sudo checkinstall -D --default --nodoc --install=no --pkgname=gta5view-qt4 --pkgversion=$PACKAGE_VERSION --pkgrelease=dev7 --pkggroup=utility --maintainer="Syping on Travis \<[email protected]\>" --requires=libqtcore4,libqtgui4,libqt4-network,qtcore4-l10n --conflicts=gta5view,gta5view-qt5 --replaces=gta5view,gta5view-qt5 --pakdir=../../package
- cd ..
deploy:

4
AboutDialog.cpp

@ -28,10 +28,6 @@ AboutDialog::AboutDialog(QWidget *parent) :
{
// Set Window Flags
setWindowFlags(windowFlags()^Qt::WindowContextHelpButtonHint);
#ifdef Q_OS_LINUX
// for stupid Window Manager (GNOME 3 should feel triggered)
setWindowFlags(windowFlags()^Qt::Dialog^Qt::Window);
#endif
// Build Strings
QString appVersion = qApp->applicationVersion();

185
ImageEditorDialog.cpp

@ -0,0 +1,185 @@
/*****************************************************************************
* gta5sync GRAND THEFT AUTO V SYNC
* Copyright (C) 2016-2017 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 "ImageEditorDialog.h"
#include "ui_ImageEditorDialog.h"
#include "ProfileInterface.h"
#include "SidebarGenerator.h"
#include "StandardPaths.h"
#include "ImportDialog.h"
#include "AppEnv.h"
#include "config.h"
#include <QStringBuilder>
#include <QImageReader>
#include <QFileDialog>
#include <QMessageBox>
ImageEditorDialog::ImageEditorDialog(SnapmaticPicture *picture, QString profileName, QWidget *parent) :
QDialog(parent), smpic(picture), profileName(profileName),
ui(new Ui::ImageEditorDialog)
{
// Set Window Flags
setWindowFlags(windowFlags()^Qt::WindowContextHelpButtonHint);
ui->setupUi(this);
ui->cmdClose->setFocus();
// DPI calculation
qreal screenRatio = AppEnv::screenRatio();
snapmaticResolutionLW = 516 * screenRatio; // 430
snapmaticResolutionLH = 288 * screenRatio; // 240
ui->labPicture->setMinimumSize(snapmaticResolutionLW, snapmaticResolutionLH);
ui->labCapacity->setText(tr("Capacity: %1").arg(QString::number(qRound((double)picture->getContentMaxLength() / 1024)) % " KB"));
imageIsChanged = false;
pictureCache = picture->getImage();
ui->labPicture->setPixmap(QPixmap::fromImage(pictureCache).scaled(snapmaticResolutionLW, snapmaticResolutionLH, Qt::IgnoreAspectRatio, Qt::SmoothTransformation));
setMaximumSize(sizeHint());
setMinimumSize(sizeHint());
setFixedSize(sizeHint());
}
ImageEditorDialog::~ImageEditorDialog()
{
delete ui;
}
void ImageEditorDialog::on_cmdClose_clicked()
{
close();
}
void ImageEditorDialog::on_cmdReplace_clicked()
{
QSettings settings(GTA5SYNC_APPVENDOR, GTA5SYNC_APPSTR);
settings.beginGroup("FileDialogs");
bool dontUseNativeDialog = settings.value("DontUseNativeDialog", false).toBool();
settings.beginGroup("ImportReplace");
fileDialogPreOpen: //Work?
QFileDialog fileDialog(this);
fileDialog.setFileMode(QFileDialog::ExistingFile);
fileDialog.setViewMode(QFileDialog::Detail);
fileDialog.setAcceptMode(QFileDialog::AcceptOpen);
fileDialog.setOption(QFileDialog::DontUseNativeDialog, dontUseNativeDialog);
fileDialog.setWindowFlags(fileDialog.windowFlags()^Qt::WindowContextHelpButtonHint);
fileDialog.setWindowTitle(ProfileInterface::tr("Import..."));
fileDialog.setLabelText(QFileDialog::Accept, ProfileInterface::tr("Import"));
// Getting readable Image formats
QString imageFormatsStr = " ";
for (QByteArray imageFormat : QImageReader::supportedImageFormats())
{
imageFormatsStr += QString("*.") % QString::fromUtf8(imageFormat).toLower() % " ";
}
QStringList filters;
filters << ProfileInterface::tr("All image files (%1)").arg(imageFormatsStr.trimmed());
filters << ProfileInterface::tr("All files (**)");
fileDialog.setNameFilters(filters);
QList<QUrl> sidebarUrls = SidebarGenerator::generateSidebarUrls(fileDialog.sidebarUrls());
fileDialog.setSidebarUrls(sidebarUrls);
fileDialog.setDirectory(settings.value(profileName % "+Directory", StandardPaths::documentsLocation()).toString());
fileDialog.restoreGeometry(settings.value(profileName % "+Geometry", "").toByteArray());
if (fileDialog.exec())
{
QStringList selectedFiles = fileDialog.selectedFiles();
if (selectedFiles.length() == 1)
{
QString selectedFile = selectedFiles.at(0);
QString selectedFileName = QFileInfo(selectedFile).fileName();
QFile snapmaticFile(selectedFile);
if (!snapmaticFile.open(QFile::ReadOnly))
{
QMessageBox::warning(this, ProfileInterface::tr("Import"), ProfileInterface::tr("Can't import %1 because file can't be open").arg("\""+selectedFileName+"\""));
goto fileDialogPreOpen;
}
QImage *importImage = new QImage();
QImageReader snapmaticImageReader;
snapmaticImageReader.setDecideFormatFromContent(true);
snapmaticImageReader.setDevice(&snapmaticFile);
if (!snapmaticImageReader.read(importImage))
{
QMessageBox::warning(this, ProfileInterface::tr("Import"), ProfileInterface::tr("Can't import %1 because file can't be parsed properly").arg("\""+selectedFileName+"\""));
delete importImage;
goto fileDialogPreOpen;
}
ImportDialog *importDialog = new ImportDialog(this);
importDialog->setImage(importImage);
importDialog->setModal(true);
importDialog->show();
importDialog->exec();
if (importDialog->isImportAgreed())
{
pictureCache = importDialog->image();
ui->labPicture->setPixmap(QPixmap::fromImage(pictureCache).scaled(snapmaticResolutionLW, snapmaticResolutionLH, Qt::KeepAspectRatio, Qt::SmoothTransformation));
imageIsChanged = true;
}
delete importDialog;
}
}
settings.setValue(profileName % "+Geometry", fileDialog.saveGeometry());
settings.setValue(profileName % "+Directory", fileDialog.directory().absolutePath());
settings.endGroup();
settings.endGroup();
}
void ImageEditorDialog::on_cmdSave_clicked()
{
if (imageIsChanged)
{
const QByteArray previousPicture = smpic->getPictureStream();
bool success = smpic->setImage(pictureCache);
if (success)
{
QString currentFilePath = smpic->getPictureFilePath();
QString originalFilePath = smpic->getOriginalPictureFilePath();
QString backupFileName = originalFilePath % ".bak";
if (!QFile::exists(backupFileName))
{
QFile::copy(currentFilePath, backupFileName);
}
if (!smpic->exportPicture(currentFilePath))
{
smpic->setPictureStream(previousPicture);
QMessageBox::warning(this, tr("Snapmatic Image Editor"), tr("Patching of Snapmatic Image failed because of I/O Error"));
return;
}
smpic->emitCustomSignal("PictureUpdated");
}
else
{
QMessageBox::warning(this, tr("Snapmatic Image Editor"), tr("Patching of Snapmatic Image failed because of Image Error"));
return;
}
}
close();
}
void ImageEditorDialog::on_cmdQuestion_clicked()
{
QMessageBox::information(this, tr("Snapmatic Image Editor"), tr("Every taken Snapmatic have a different Capacity, a Snapmatic with higher Capacity can store a picture with better quality."));
}

53
ImageEditorDialog.h

@ -0,0 +1,53 @@
/*****************************************************************************
* gta5sync GRAND THEFT AUTO V SYNC
* Copyright (C) 2016-2017 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 IMAGEEDITORDIALOG_H
#define IMAGEEDITORDIALOG_H
#include "SnapmaticPicture.h"
#include <QDialog>
namespace Ui {
class ImageEditorDialog;
}
class ImageEditorDialog : public QDialog
{
Q_OBJECT
public:
explicit ImageEditorDialog(SnapmaticPicture *picture, QString profileName, QWidget *parent = 0);
~ImageEditorDialog();
private slots:
void on_cmdClose_clicked();
void on_cmdReplace_clicked();
void on_cmdSave_clicked();
void on_cmdQuestion_clicked();
private:
SnapmaticPicture *smpic;
QString profileName;
Ui::ImageEditorDialog *ui;
int snapmaticResolutionLW;
int snapmaticResolutionLH;
bool imageIsChanged;
QImage pictureCache;
};
#endif // IMAGEEDITORDIALOG_H

130
ImageEditorDialog.ui

@ -0,0 +1,130 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>ImageEditorDialog</class>
<widget class="QDialog" name="ImageEditorDialog">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>516</width>
<height>335</height>
</rect>
</property>
<property name="windowTitle">
<string>Overwrite Image...</string>
</property>
<layout class="QVBoxLayout" name="vlInterface">
<property name="leftMargin">
<number>0</number>
</property>
<property name="topMargin">
<number>0</number>
</property>
<property name="rightMargin">
<number>0</number>
</property>
<property name="bottomMargin">
<number>0</number>
</property>
<item>
<widget class="QLabel" name="labPicture">
<property name="minimumSize">
<size>
<width>516</width>
<height>288</height>
</size>
</property>
<property name="text">
<string/>
</property>
</widget>
</item>
<item>
<widget class="QFrame" name="buttomFrame">
<property name="frameShape">
<enum>QFrame::NoFrame</enum>
</property>
<property name="frameShadow">
<enum>QFrame::Plain</enum>
</property>
<property name="lineWidth">
<number>0</number>
</property>
<layout class="QVBoxLayout" name="vlButtons">
<item>
<layout class="QHBoxLayout" name="hlCapacity">
<item>
<widget class="QLabel" name="labCapacity">
<property name="text">
<string>Capacity: %1</string>
</property>
</widget>
</item>
<item>
<widget class="QToolButton" name="cmdQuestion">
<property name="text">
<string>?</string>
</property>
</widget>
</item>
<item>
<spacer name="hsCapacity">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>0</width>
<height>0</height>
</size>
</property>
</spacer>
</item>
</layout>
</item>
<item>
<layout class="QHBoxLayout" name="hlButtons">
<item>
<widget class="QPushButton" name="cmdReplace">
<property name="text">
<string>&amp;Import...</string>
</property>
</widget>
</item>
<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="cmdSave">
<property name="text">
<string>&amp;Overwrite</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="cmdClose">
<property name="text">
<string>&amp;Close</string>
</property>
</widget>
</item>
</layout>
</item>
</layout>
</widget>
</item>
</layout>
</widget>
<resources/>
<connections/>
</ui>

148
ImportDialog.cpp

@ -18,13 +18,21 @@
#include "ImportDialog.h"
#include "ui_ImportDialog.h"
#include "SidebarGenerator.h"
#include "StandardPaths.h"
#include "AppEnv.h"
#include "config.h"
#include <QStringBuilder>
#include <QImageReader>
#include <QColorDialog>
#include <QFileDialog>
#include <QMessageBox>
#include <QSettings>
#include <QPainter>
#include <QPixmap>
#include <QImage>
#include <QDebug>
#include <QFile>
#include <QRgb>
// IMAGES VALUES
@ -39,11 +47,7 @@ ImportDialog::ImportDialog(QWidget *parent) :
ui(new Ui::ImportDialog)
{
// Set Window Flags
setWindowFlags(windowFlags()^Qt::WindowContextHelpButtonHint^Qt::WindowMinMaxButtonsHint);
#ifdef Q_OS_LINUX
// for stupid Window Manager (GNOME 3 should feel triggered)
setWindowFlags(windowFlags()^Qt::Dialog^Qt::Window);
#endif
setWindowFlags(windowFlags()^Qt::WindowContextHelpButtonHint);
ui->setupUi(this);
importAgreed = false;
@ -62,11 +66,15 @@ ImportDialog::ImportDialog(QWidget *parent) :
ui->cbIgnore->setChecked(false);
ui->labColour->setText(tr("Background Colour: <span style=\"color: %1\">%1</span>").arg(selectedColour.name()));
ui->labBackgroundImage->setText(tr("Background Image:"));
ui->cmdBackgroundWipe->setVisible(false);
// DPI calculation
qreal screenRatio = AppEnv::screenRatio();
snapmaticResolutionLW = 430 * screenRatio;
snapmaticResolutionLH = 240 * screenRatio;
snapmaticResolutionLW = 516 * screenRatio; // 430
snapmaticResolutionLH = 288 * screenRatio; // 240
ui->labPicture->setMinimumSize(snapmaticResolutionLW, snapmaticResolutionLH);
ui->vlButtom->setSpacing(6 * screenRatio);
#ifndef Q_OS_MAC
ui->vlButtom->setContentsMargins(9 * screenRatio, 6 * screenRatio, 9 * screenRatio, 9 * screenRatio);
@ -80,9 +88,10 @@ ImportDialog::ImportDialog(QWidget *parent) :
ui->vlButtom->setContentsMargins(9 * screenRatio, 6 * screenRatio, 9 * screenRatio, 9 * screenRatio);
}
#endif
setMinimumSize(430 * screenRatio, 380 * screenRatio);
setMaximumSize(430 * screenRatio, 380 * screenRatio);
setFixedSize(430 * screenRatio, 380 * screenRatio);
setMaximumSize(sizeHint());
setMinimumSize(sizeHint());
setFixedSize(sizeHint());
}
ImportDialog::~ImportDialog()
@ -97,6 +106,33 @@ void ImportDialog::processImage()
QPixmap snapmaticPixmap(snapmaticResolutionW, snapmaticResolutionH);
snapmaticPixmap.fill(selectedColour);
QPainter snapmaticPainter(&snapmaticPixmap);
if (!backImage.isNull())
{
if (!ui->cbStretch->isChecked())
{
int diffWidth = 0;
int diffHeight = 0;
if (backImage.width() != snapmaticResolutionW)
{
diffWidth = snapmaticResolutionW - backImage.width();
diffWidth = diffWidth / 2;
}
else if (backImage.height() != snapmaticResolutionH)
{
diffHeight = snapmaticResolutionH - backImage.height();
diffHeight = diffHeight / 2;
}
snapmaticPainter.drawImage(0 + diffWidth, 0 + diffHeight, backImage);
}
else
{
snapmaticPainter.drawImage(0, 0, QImage(backImage).scaled(snapmaticResolutionW, snapmaticResolutionH, Qt::IgnoreAspectRatio, Qt::SmoothTransformation));
}
if (ui->cbAvatar->isChecked() && ui->cbForceAvatarColour->isChecked())
{
snapmaticPainter.fillRect(snapmaticAvatarPlacementW, snapmaticAvatarPlacementH, snapmaticAvatarResolution, snapmaticAvatarResolution, selectedColour);
}
}
if (insideAvatarZone)
{
// Avatar mode
@ -262,3 +298,95 @@ void ImportDialog::on_cmdColourChange_clicked()
processImage();
}
}
void ImportDialog::on_cmdBackgroundChange_clicked()
{
QSettings settings(GTA5SYNC_APPVENDOR, GTA5SYNC_APPSTR);
settings.beginGroup("FileDialogs");
bool dontUseNativeDialog = settings.value("DontUseNativeDialog", false).toBool();
settings.beginGroup("ImportBackground");
fileDialogPreOpen:
QFileDialog fileDialog(this);
fileDialog.setFileMode(QFileDialog::ExistingFiles);
fileDialog.setViewMode(QFileDialog::Detail);
fileDialog.setAcceptMode(QFileDialog::AcceptOpen);
fileDialog.setOption(QFileDialog::DontUseNativeDialog, dontUseNativeDialog);
fileDialog.setWindowFlags(fileDialog.windowFlags()^Qt::WindowContextHelpButtonHint);
fileDialog.setWindowTitle(QApplication::translate("ProfileInterface", "Import..."));
fileDialog.setLabelText(QFileDialog::Accept, QApplication::translate("ProfileInterface", "Import"));
// Getting readable Image formats
QString imageFormatsStr = " ";
for (QByteArray imageFormat : QImageReader::supportedImageFormats())
{
imageFormatsStr += QString("*.") % QString::fromUtf8(imageFormat).toLower() % " ";
}
QStringList filters;
filters << QApplication::translate("ProfileInterface", "All image files (%1)").arg(imageFormatsStr.trimmed());
filters << QApplication::translate("ProfileInterface", "All files (**)");
fileDialog.setNameFilters(filters);
QList<QUrl> sidebarUrls = SidebarGenerator::generateSidebarUrls(fileDialog.sidebarUrls());
fileDialog.setSidebarUrls(sidebarUrls);
fileDialog.setDirectory(settings.value("Directory", StandardPaths::documentsLocation()).toString());
fileDialog.restoreGeometry(settings.value("Geometry", "").toByteArray());
if (fileDialog.exec())
{
QStringList selectedFiles = fileDialog.selectedFiles();
if (selectedFiles.length() == 1)
{
QString selectedFile = selectedFiles.at(0);
QString selectedFileName = QFileInfo(selectedFile).fileName();
QFile snapmaticFile(selectedFile);
if (!snapmaticFile.open(QFile::ReadOnly))
{
QMessageBox::warning(this, QApplication::translate("ProfileInterface", "Import"), QApplication::translate("ProfileInterface", "Can't import %1 because file can't be open").arg("\""+selectedFileName+"\""));
goto fileDialogPreOpen;
}
QImage importImage;
QImageReader snapmaticImageReader;
snapmaticImageReader.setDecideFormatFromContent(true);
snapmaticImageReader.setDevice(&snapmaticFile);
if (!snapmaticImageReader.read(&importImage))
{
QMessageBox::warning(this, QApplication::translate("ProfileInterface", "Import"), QApplication::translate("ProfileInterface", "Can't import %1 because file can't be parsed properly").arg("\""+selectedFileName+"\""));
goto fileDialogPreOpen;
}
backImage = importImage.scaled(snapmaticResolutionW, snapmaticResolutionH, Qt::KeepAspectRatio, Qt::SmoothTransformation);
backgroundPath = selectedFile;
ui->labBackgroundImage->setText(tr("Background Image: %1").arg(tr("File", "Background Image: File")));
ui->cmdBackgroundWipe->setVisible(true);
processImage();
}
}
settings.setValue("Geometry", fileDialog.saveGeometry());
settings.setValue("Directory", fileDialog.directory().absolutePath());
settings.endGroup();
settings.endGroup();
}
void ImportDialog::on_cmdBackgroundWipe_clicked()
{
backImage = QImage();
ui->labBackgroundImage->setText(tr("Background Image:"));
ui->cmdBackgroundWipe->setVisible(false);
processImage();
}
void ImportDialog::on_cbStretch_toggled(bool checked)
{
Q_UNUSED(checked)
processImage();
}
void ImportDialog::on_cbForceAvatarColour_toggled(bool checked)
{
Q_UNUSED(checked)
processImage();
}

6
ImportDialog.h

@ -45,11 +45,17 @@ private slots:
void on_cmdOK_clicked();
void on_labPicture_labelPainted();
void on_cmdColourChange_clicked();
void on_cmdBackgroundChange_clicked();
void on_cmdBackgroundWipe_clicked();
void on_cbStretch_toggled(bool checked);
void on_cbForceAvatarColour_toggled(bool checked);
private:
Ui::ImportDialog *ui;
QImage avatarAreaImage;
QString backgroundPath;
QString imageTitle;
QImage backImage;
QImage workImage;
QImage newImage;
QColor selectedColour;

194
ImportDialog.ui

@ -6,20 +6,14 @@
<rect>
<x>0</x>
<y>0</y>
<width>430</width>
<height>380</height>
<width>516</width>
<height>425</height>
</rect>
</property>
<property name="minimumSize">
<size>
<width>430</width>
<height>380</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>430</width>
<height>380</height>
<width>516</width>
<height>425</height>
</size>
</property>
<property name="windowTitle">
@ -45,8 +39,8 @@
<widget class="UiModLabel" name="labPicture">
<property name="minimumSize">
<size>
<width>430</width>
<height>240</height>
<width>516</width>
<height>288</height>
</size>
</property>
<property name="text">
@ -87,40 +81,9 @@
<item>
<widget class="QGroupBox" name="gbSettings">
<property name="title">
<string>Settings</string>
<string>Picture</string>
</property>
<layout class="QVBoxLayout" name="vlSettings">
<item>
<layout class="QHBoxLayout" name="hlColor">
<item>
<widget class="QLabel" name="labColour">
<property name="text">
<string>Background Colour: &lt;span style=&quot;color: %1&quot;&gt;%1&lt;/span&gt;</string>
</property>
</widget>
</item>
<item>
<widget class="QToolButton" name="cmdColourChange">
<property name="text">
<string>...</string>
</property>
</widget>
</item>
<item>
<spacer name="hsColourSpacer">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>0</width>
<height>0</height>
</size>
</property>
</spacer>
</item>
</layout>
</item>
<item>
<layout class="QHBoxLayout" name="hlCheckboxes">
<item>
@ -155,7 +118,148 @@
</widget>
</item>
<item>
<spacer name="vsDialog">
<widget class="QGroupBox" name="gbBackground">
<property name="title">
<string>Background</string>
</property>
<layout class="QVBoxLayout" name="vlBackground">
<item>
<layout class="QHBoxLayout" name="hlColor">
<item>
<layout class="QHBoxLayout" name="hlColourManage">
<item>
<widget class="QLabel" name="labColour">
<property name="text">
<string>Background Colour: &lt;span style=&quot;color: %1&quot;&gt;%1&lt;/span&gt;</string>
</property>
</widget>
</item>
<item>
<layout class="QHBoxLayout" name="hlColourButton">
<property name="spacing">
<number>0</number>
</property>
<property name="leftMargin">
<number>0</number>
</property>
<property name="topMargin">
<number>0</number>
</property>
<property name="rightMargin">
<number>0</number>
</property>
<property name="bottomMargin">
<number>0</number>
</property>
<item>
<widget class="QToolButton" name="cmdColourChange">
<property name="text">
<string>...</string>
</property>
</widget>
</item>
</layout>
</item>
<item>
<spacer name="hsColour">
<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>
<item>
<layout class="QHBoxLayout" name="hlBackgroundManage">
<item>
<widget class="QLabel" name="labBackgroundImage">
<property name="text">
<string>Background Image:</string>
</property>
</widget>
</item>
<item>
<layout class="QHBoxLayout" name="hlBackgroundButton">
<property name="spacing">
<number>0</number>
</property>
<property name="leftMargin">
<number>0</number>
</property>
<property name="topMargin">
<number>0</number>
</property>
<property name="rightMargin">
<number>0</number>
</property>
<property name="bottomMargin">
<number>0</number>
</property>
<item>
<widget class="QToolButton" name="cmdBackgroundChange">
<property name="text">
<string>...</string>
</property>
</widget>
</item>
<item>
<widget class="QToolButton" name="cmdBackgroundWipe">
<property name="text">
<string>X</string>
</property>
</widget>
</item>
</layout>
</item>
<item>
<spacer name="hsBackgroundImage">
<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>
<item>
<layout class="QHBoxLayout" name="hlBackground">
<item>
<widget class="QCheckBox" name="cbForceAvatarColour">
<property name="text">
<string>Force Colour in Avatar Zone</string>
</property>
</widget>
</item>
<item>
<widget class="QCheckBox" name="cbStretch">
<property name="enabled">
<bool>true</bool>
</property>
<property name="text">
<string>Ignore Aspect Ratio</string>
</property>
</widget>
</item>
</layout>
</item>
</layout>
</widget>
</item>
<item>
<spacer name="vsInterface">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>

4
JsonEditorDialog.cpp

@ -35,10 +35,6 @@ JsonEditorDialog::JsonEditorDialog(SnapmaticPicture *picture, QWidget *parent) :
{
// Set Window Flags
setWindowFlags(windowFlags()^Qt::WindowContextHelpButtonHint^Qt::WindowMinMaxButtonsHint);
#ifdef Q_OS_LINUX
// for stupid Window Manager (GNOME 3 should feel triggered)
setWindowFlags(windowFlags()^Qt::Dialog^Qt::Window);
#endif
ui->setupUi(this);
ui->cmdClose->setDefault(true);

4
MapLocationDialog.cpp

@ -29,10 +29,6 @@ MapLocationDialog::MapLocationDialog(double x, double y, QWidget *parent) :
{
// Set Window Flags
setWindowFlags(windowFlags()^Qt::WindowContextHelpButtonHint);
#ifdef Q_OS_LINUX
// for stupid Window Manager (GNOME 3 should feel triggered)
setWindowFlags(windowFlags()^Qt::Dialog^Qt::Window);
#endif
ui->setupUi(this);
ui->cmdDone->setVisible(false);

6
OptionsDialog.cpp

@ -42,10 +42,6 @@ OptionsDialog::OptionsDialog(ProfileDatabase *profileDB, QWidget *parent) :
{
// Set Window Flags
setWindowFlags(windowFlags()^Qt::WindowContextHelpButtonHint);
#ifdef Q_OS_LINUX
// for stupid Window Manager (GNOME 3 should feel triggered)
setWindowFlags(windowFlags()^Qt::Dialog^Qt::Window);
#endif
// Setup User Interface
ui->setupUi(this);
@ -86,9 +82,11 @@ OptionsDialog::OptionsDialog(ProfileDatabase *profileDB, QWidget *parent) :
setupInterfaceSettings();
setupSnapmaticPictureViewer();
#ifndef Q_QS_ANDROID
// DPI calculation
qreal screenRatio = AppEnv::screenRatio();
resize(435 * screenRatio, 405 * screenRatio);
#endif
#ifdef GTA5SYNC_DISABLED
ui->tabWidget->removeTab(ui->tabWidget->indexOf(ui->tabSync));

70
PictureDialog.cpp

@ -22,6 +22,7 @@
#include "ui_PictureDialog.h"
#include "SidebarGenerator.h"
#include "MapLocationDialog.h"
#include "ImageEditorDialog.h"
#include "JsonEditorDialog.h"
#include "SnapmaticEditor.h"
#include "StandardPaths.h"
@ -84,6 +85,14 @@ PictureDialog::PictureDialog(ProfileDatabase *profileDB, CrewDatabase *crewDB, Q
setupPictureDialog();
}
PictureDialog::PictureDialog(ProfileDatabase *profileDB, CrewDatabase *crewDB, QString profileName, QWidget *parent) :
QDialog(parent), profileDB(profileDB), crewDB(crewDB), profileName(profileName),
ui(new Ui::PictureDialog)
{
primaryWindow = false;
setupPictureDialog();
}
PictureDialog::PictureDialog(bool primaryWindow, ProfileDatabase *profileDB, CrewDatabase *crewDB, QWidget *parent) :
QDialog(parent), primaryWindow(primaryWindow), profileDB(profileDB), crewDB(crewDB),
ui(new Ui::PictureDialog)
@ -91,6 +100,13 @@ PictureDialog::PictureDialog(bool primaryWindow, ProfileDatabase *profileDB, Cre
setupPictureDialog();
}
PictureDialog::PictureDialog(bool primaryWindow, ProfileDatabase *profileDB, CrewDatabase *crewDB, QString profileName, QWidget *parent) :
QDialog(parent), primaryWindow(primaryWindow), profileDB(profileDB), crewDB(crewDB), profileName(profileName),
ui(new Ui::PictureDialog)
{
setupPictureDialog();
}
void PictureDialog::setupPictureDialog()
{
// Set Window Flags
@ -137,6 +153,7 @@ void PictureDialog::setupPictureDialog()
manageMenu->addAction(tr("Export as &Snapmatic..."), this, SLOT(copySnapmaticPicture()));
manageMenu->addSeparator();
manageMenu->addAction(tr("&Edit Properties..."), this, SLOT(editSnapmaticProperties()));
manageMenu->addAction(tr("&Overwrite Image..."), this, SLOT(editSnapmaticImage()));
manageMenu->addSeparator();
QAction *openViewerAction = manageMenu->addAction(tr("Open &Map Viewer..."), this, SLOT(openPreviewMap()));
openViewerAction->setShortcut(Qt::Key_M);
@ -583,7 +600,7 @@ void PictureDialog::renderOverlayPicture()
void PictureDialog::setSnapmaticPicture(SnapmaticPicture *picture, bool readOk, bool _indexed, int _index)
{
if (smpic != nullptr) smpic->disconnect(this, SLOT(updated()));
if (smpic != nullptr) smpic->disconnect();
snapmaticPicture = QImage();
indexed = _indexed;
index = _index;
@ -620,6 +637,7 @@ void PictureDialog::setSnapmaticPicture(SnapmaticPicture *picture, bool readOk,
QMessageBox::warning(this,tr("Snapmatic Picture Viewer"),tr("Failed at %1").arg(picture->getLastStep()));
}
QObject::connect(smpic, SIGNAL(updated()), this, SLOT(updated()));
QObject::connect(smpic, SIGNAL(customSignal(QString)), this, SLOT(customSignal(QString)));
emit newPictureCommited(snapmaticPicture);
}
@ -808,6 +826,11 @@ void PictureDialog::on_labPicture_mouseDoubleClicked(Qt::MouseButton button)
pictureWidget->move(desktopRect.x(), desktopRect.y());
pictureWidget->resize(desktopRect.width(), desktopRect.height());
#ifdef GTA5SYNC_WIN
#if QT_VERSION >= 0x050200
QtWin::markFullscreenWindow(pictureWidget, true);
#endif
#endif
pictureWidget->showFullScreen();
pictureWidget->setFocus();
pictureWidget->raise();
@ -847,7 +870,11 @@ void PictureDialog::openPreviewMap()
}
mapLocDialog->setWindowIcon(windowIcon());
mapLocDialog->setModal(true);
#ifndef Q_OS_ANDROID
mapLocDialog->show();
#else
mapLocDialog->showMaximized();
#endif
mapLocDialog->exec();
if (mapLocDialog->propUpdated())
{
@ -895,11 +922,38 @@ void PictureDialog::editSnapmaticProperties()
snapmaticEditor->setWindowIcon(windowIcon());
snapmaticEditor->setSnapmaticPicture(picture);
snapmaticEditor->setModal(true);
#ifndef Q_OS_ANDROID
snapmaticEditor->show();
#else
snapmaticEditor->showMaximized();
#endif
snapmaticEditor->exec();
delete snapmaticEditor;
}
void PictureDialog::editSnapmaticImage()
{
SnapmaticPicture *picture = smpic;
ImageEditorDialog *imageEditor;
if (rqFullscreen && fullscreenWidget != nullptr)
{
imageEditor = new ImageEditorDialog(picture, profileName, fullscreenWidget);
}
else
{
imageEditor = new ImageEditorDialog(picture, profileName, this);
}
imageEditor->setWindowIcon(windowIcon());
imageEditor->setModal(true);
#ifndef Q_OS_ANDROID
imageEditor->show();
#else
snapmaticEditor->showMaximized();
#endif
imageEditor->exec();
delete imageEditor;
}
void PictureDialog::editSnapmaticRawJson()
{
SnapmaticPicture *picture = smpic;
@ -914,7 +968,11 @@ void PictureDialog::editSnapmaticRawJson()
}
jsonEditor->setWindowIcon(windowIcon());
jsonEditor->setModal(true);
#ifndef Q_OS_ANDROID
jsonEditor->show();
#else
jsonEditor->showMaximized();
#endif
jsonEditor->exec();
delete jsonEditor;
}
@ -933,3 +991,13 @@ void PictureDialog::updated()
}
ui->labJSON->setText(jsonDrawString.arg(locX, locY, locZ, generatePlayersString(), generateCrewString(), picTitl, picAreaStr, created));
}
void PictureDialog::customSignal(QString signal)
{
SnapmaticPicture *picture = smpic; // used by macro
if (signal == "PictureUpdated")
{
snapmaticPicture = picture->getImage();
renderPicture();
}
}

5
PictureDialog.h

@ -46,7 +46,9 @@ class PictureDialog : public QDialog
Q_OBJECT
public:
explicit PictureDialog(ProfileDatabase *profileDB, CrewDatabase *crewDB, QWidget *parent = 0);
explicit PictureDialog(ProfileDatabase *profileDB, CrewDatabase *crewDB, QString profileName, QWidget *parent = 0);
explicit PictureDialog(bool primaryWindow, ProfileDatabase *profileDB, CrewDatabase *crewDB, QWidget *parent = 0);
explicit PictureDialog(bool primaryWindow, ProfileDatabase *profileDB, CrewDatabase *crewDB, QString profileName, QWidget *parent = 0);
void setupPictureDialog();
void setSnapmaticPicture(SnapmaticPicture *picture, bool readOk, bool indexed, int index);
void setSnapmaticPicture(SnapmaticPicture *picture, bool readOk, int index);
@ -78,10 +80,12 @@ private slots:
void previousPictureRequestedSlot();
void editSnapmaticProperties();
void editSnapmaticRawJson();
void editSnapmaticImage();
void renderOverlayPicture();
void renderPicture();
void openPreviewMap();
void updated();
void customSignal(QString signal);
signals:
void nextPictureRequested();
@ -110,6 +114,7 @@ private:
bool primaryWindow;
ProfileDatabase *profileDB;
CrewDatabase *crewDB;
QString profileName;
Ui::PictureDialog *ui;
QMap<QString, QString> globalMap;
SnapmaticPicture *smpic;

17
PlayerListDialog.cpp

@ -32,10 +32,8 @@ PlayerListDialog::PlayerListDialog(QStringList players, ProfileDatabase *profile
{
// Set Window Flags
setWindowFlags(windowFlags()^Qt::WindowContextHelpButtonHint);
#ifdef Q_OS_LINUX
// for stupid Window Manager (GNOME 3 should feel triggered)
setWindowFlags(windowFlags()^Qt::Dialog^Qt::Window);
#endif
listUpdated = false;
ui->setupUi(this);
ui->cmdCancel->setDefault(true);
@ -237,5 +235,16 @@ void PlayerListDialog::on_cmdApply_clicked()
players += ui->listSePlayers->item(i)->text().split(" ").at(0);
}
emit playerListUpdated(players);
listUpdated = true;
close();
}
QStringList PlayerListDialog::getPlayerList() const
{
return players;
}
bool PlayerListDialog::isListUpdated()
{
return listUpdated;
}

3
PlayerListDialog.h

@ -32,6 +32,8 @@ class PlayerListDialog : public QDialog
public:
explicit PlayerListDialog(QStringList players, ProfileDatabase *profileDB, QWidget *parent = 0);
QStringList getPlayerList() const;
bool isListUpdated();
~PlayerListDialog();
private slots:
@ -45,6 +47,7 @@ private:
QStringList players;
ProfileDatabase *profileDB;
Ui::PlayerListDialog *ui;
bool listUpdated;
void drawSwitchButtons();
void buildInterface();

427
ProfileInterface.cpp

@ -18,6 +18,7 @@
#include "ProfileInterface.h"
#include "ui_ProfileInterface.h"
#include "PlayerListDialog.h"
#include "SidebarGenerator.h"
#include "SnapmaticWidget.h"
#include "DatabaseThread.h"
@ -187,7 +188,7 @@ void ProfileInterface::pictureFixed_event(SnapmaticPicture *picture)
void ProfileInterface::pictureLoaded(SnapmaticPicture *picture, bool inserted)
{
SnapmaticWidget *picWidget = new SnapmaticWidget(profileDB, crewDB, threadDB, this);
SnapmaticWidget *picWidget = new SnapmaticWidget(profileDB, crewDB, threadDB, profileName, this);
picWidget->setSnapmaticPicture(picture);
picWidget->setContentMode(contentMode);
picWidget->setMouseTracking(true);
@ -502,15 +503,15 @@ fileDialogPreOpen: //Work?
void ProfileInterface::importFilesProgress(QStringList selectedFiles)
{
int maximumId = selectedFiles.length();
int overallId = 1;
int overallId = 0;
QString errorStr;
QStringList failedFiles;
QStringList failed;
// Progress dialog
QProgressDialog pbDialog(this);
pbDialog.setWindowFlags(pbDialog.windowFlags()^Qt::WindowContextHelpButtonHint^Qt::WindowCloseButtonHint);
pbDialog.setWindowTitle(tr("Import..."));
pbDialog.setLabelText(tr("Import file %1 of %2 files").arg(QString::number(overallId), QString::number(maximumId)));
pbDialog.setLabelText(tr("Import file %1 of %2 files").arg(QString::number(1), QString::number(maximumId)));
pbDialog.setRange(1, maximumId);
pbDialog.setValue(1);
pbDialog.setModal(true);
@ -518,6 +519,7 @@ void ProfileInterface::importFilesProgress(QStringList selectedFiles)
pbBtn.at(0)->setDisabled(true);
QList<QProgressBar*> pbBar = pbDialog.findChildren<QProgressBar*>();
pbBar.at(0)->setTextVisible(false);
pbDialog.setAutoClose(false);
pbDialog.show();
// THREADING HERE PLEASE
@ -525,18 +527,18 @@ void ProfileInterface::importFilesProgress(QStringList selectedFiles)
int currentTime = importDateTime.time().toString(importTimeFormat).toInt();
for (QString selectedFile : selectedFiles)
{
overallId++;
pbDialog.setValue(overallId);
pbDialog.setLabelText(tr("Import file %1 of %2 files").arg(QString::number(overallId), QString::number(maximumId)));
importDateTime = QDateTime::currentDateTime();
if (!importFile(selectedFile, importDateTime, &currentTime, false))
{
failedFiles << QFileInfo(selectedFile).fileName();
failed << QFileInfo(selectedFile).fileName();
}
overallId++;
}
pbDialog.close();
for (QString curErrorStr : failedFiles)
for (QString curErrorStr : failed)
{
errorStr += ", " % curErrorStr;
}
@ -685,6 +687,7 @@ bool ProfileInterface::importFile(QString selectedFile, QDateTime importDateTime
QFile snapmaticFile(selectedFile);
if (!snapmaticFile.open(QFile::ReadOnly))
{
QMessageBox::warning(this, tr("Import"), tr("Can't import %1 because file can't be open").arg("\""+selectedFileName+"\""));
delete picture;
return false;
}
@ -695,6 +698,7 @@ bool ProfileInterface::importFile(QString selectedFile, QDateTime importDateTime
if (!snapmaticImageReader.read(importImage))
{
QMessageBox::warning(this, tr("Import"), tr("Can't import %1 because file can't be parsed properly").arg("\""+selectedFileName+"\""));
delete importImage;
delete picture;
return false;
}
@ -913,7 +917,7 @@ void ProfileInterface::exportSelected()
settings.beginGroup("FileDialogs");
//bool dontUseNativeDialog = settings.value("DontUseNativeDialog", false).toBool();
settings.beginGroup("ExportDirectory");
QString exportDirectory = QFileDialog::getExistingDirectory(this, tr("Export selected"), settings.value(profileName, profileFolder).toString());
QString exportDirectory = QFileDialog::getExistingDirectory(this, tr("Export selected..."), settings.value(profileName, profileFolder).toString());
if (exportDirectory != "")
{
settings.setValue(profileName, exportDirectory);
@ -951,7 +955,7 @@ void ProfileInterface::exportSelected()
#endif
bool itemSelected = false;
QString selectedItem = inputDialog.getItem(this, tr("Export selected"), tr("%1Export Snapmatic pictures%2<br><br>JPG pictures make it possible to open the picture with a Image Viewer<br>GTA Snapmatic make it possible to import the picture into the game<br><br>Export as:").arg(ExportPreSpan, ExportPostSpan), inputDialogItems, 0, false, &itemSelected, inputDialog.windowFlags()^Qt::WindowContextHelpButtonHint);
QString selectedItem = inputDialog.getItem(this, tr("Export selected..."), tr("%1Export Snapmatic pictures%2<br><br>JPG pictures make it possible to open the picture with a Image Viewer<br>GTA Snapmatic make it possible to import the picture into the game<br><br>Export as:").arg(ExportPreSpan, ExportPostSpan), inputDialogItems, 0, false, &itemSelected, inputDialog.windowFlags()^Qt::WindowContextHelpButtonHint);
if (itemSelected)
{
if (selectedItem == tr("JPG pictures and GTA Snapmatic"))
@ -1012,6 +1016,7 @@ void ProfileInterface::exportSelected()
QObject::connect(exportThread, SIGNAL(exportFinished()), &pbDialog, SLOT(close()));
exportThread->start();
pbDialog.setAutoClose(false);
pbDialog.exec();
QStringList getFailedSavegames = exportThread->getFailedSavegames();
QStringList getFailedCopyPictures = exportThread->getFailedCopyPictures();
@ -1208,6 +1213,7 @@ void ProfileInterface::contextMenuTriggeredPIC(QContextMenuEvent *ev)
editMenu.addAction(SnapmaticWidget::tr("Hide &In-game"), picWidget, SLOT(makePictureHiddenSlot()));
}
editMenu.addAction(PictureDialog::tr("&Edit Properties..."), picWidget, SLOT(editSnapmaticProperties()));
editMenu.addAction(PictureDialog::tr("&Overwrite Image..."), picWidget, SLOT(editSnapmaticImage()));
editMenu.addSeparator();
editMenu.addAction(PictureDialog::tr("Open &Map Viewer..."), picWidget, SLOT(openMapViewer()));
editMenu.addAction(PictureDialog::tr("Open &JSON Editor..."), picWidget, SLOT(editSnapmaticRawJson()));
@ -1490,3 +1496,406 @@ bool ProfileInterface::isSupportedImageFile(QString selectedFileName)
}
return false;
}
void ProfileInterface::massTool(MassTool tool)
{
switch(tool)
{
case MassTool::Qualify:
{
QList<SnapmaticWidget*> snapmaticWidgets;
for (ProfileWidget *widget : widgets.keys())
{
if (widget->isSelected())
{
if (widget->getWidgetType() == "SnapmaticWidget")
{
SnapmaticWidget *snapmaticWidget = qobject_cast<SnapmaticWidget*>(widget);
snapmaticWidgets += snapmaticWidget;
}
}
}
if (snapmaticWidgets.isEmpty())
{
QMessageBox::warning(this, tr("Snapmatic Mass Tool"), tr("You don't have any Snapmatics selected!"));
return;
}
// Prepare Progress
int maximumId = snapmaticWidgets.length();
int overallId = 0;
QProgressDialog pbDialog(this);
pbDialog.setWindowFlags(pbDialog.windowFlags()^Qt::WindowContextHelpButtonHint^Qt::WindowCloseButtonHint);
pbDialog.setWindowTitle(tr("Patch selected..."));
pbDialog.setLabelText(tr("Patch file %1 of %2 files").arg(QString::number(1), QString::number(maximumId)));
pbDialog.setRange(1, maximumId);
pbDialog.setValue(1);
pbDialog.setModal(true);
QList<QPushButton*> pbBtn = pbDialog.findChildren<QPushButton*>();
pbBtn.at(0)->setDisabled(true);
QList<QProgressBar*> pbBar = pbDialog.findChildren<QProgressBar*>();
pbBar.at(0)->setTextVisible(false);
pbDialog.setAutoClose(false);
pbDialog.show();
// Begin Progress
QStringList fails;
for (SnapmaticWidget *snapmaticWidget : snapmaticWidgets)
{
// Update Progress
overallId++;
pbDialog.setValue(overallId);
pbDialog.setLabelText(tr("Patch file %1 of %2 files").arg(QString::number(overallId), QString::number(maximumId)));
SnapmaticPicture *picture = snapmaticWidget->getPicture();
SnapmaticProperties snapmaticProperties = picture->getSnapmaticProperties();
snapmaticProperties.isSelfie = true;
snapmaticProperties.isMug = false;
snapmaticProperties.isFromRSEditor = false;
snapmaticProperties.isFromDirector = false;
snapmaticProperties.isMeme = false;
QString currentFilePath = picture->getPictureFilePath();
QString originalFilePath = picture->getOriginalPictureFilePath();
QString backupFileName = originalFilePath % ".bak";
if (!QFile::exists(backupFileName))
{
QFile::copy(currentFilePath, backupFileName);
}
SnapmaticProperties fallbackProperties = picture->getSnapmaticProperties();
picture->setSnapmaticProperties(snapmaticProperties);
if (!picture->exportPicture(currentFilePath))
{
picture->setSnapmaticProperties(fallbackProperties);
fails << QString("%1 [%2]").arg(picture->getPictureTitle(), picture->getPictureString());
}
else
{
picture->emitUpdate();
qApp->processEvents();
}
}
pbDialog.close();
if (!fails.isEmpty())
{
QMessageBox::warning(this, tr("Snapmatic Mass Tool"), tr("%1 failed with...\n\n%2", "Action failed with...").arg(tr("Qualify", "%1 failed with..."), fails.join(", ")));
}
}
break;
case MassTool::Players:
{
QList<SnapmaticWidget*> snapmaticWidgets;
for (ProfileWidget *widget : widgets.keys())
{
if (widget->isSelected())
{
if (widget->getWidgetType() == "SnapmaticWidget")
{
SnapmaticWidget *snapmaticWidget = qobject_cast<SnapmaticWidget*>(widget);
snapmaticWidgets += snapmaticWidget;
}
}
}
if (snapmaticWidgets.isEmpty())
{
QMessageBox::warning(this, tr("Snapmatic Mass Tool"), tr("You don't have any Snapmatics selected!"));
return;
}
PlayerListDialog *playerListDialog = new PlayerListDialog(QStringList(), profileDB, this);
playerListDialog->setModal(true);
playerListDialog->show();
playerListDialog->exec();
if (!playerListDialog->isListUpdated())
{
return;
}
QStringList players = playerListDialog->getPlayerList();
delete playerListDialog;
// Prepare Progress
int maximumId = snapmaticWidgets.length();
int overallId = 0;
QProgressDialog pbDialog(this);
pbDialog.setWindowFlags(pbDialog.windowFlags()^Qt::WindowContextHelpButtonHint^Qt::WindowCloseButtonHint);
pbDialog.setWindowTitle(tr("Patch selected..."));
pbDialog.setLabelText(tr("Patch file %1 of %2 files").arg(QString::number(1), QString::number(maximumId)));
pbDialog.setRange(1, maximumId);
pbDialog.setValue(1);
pbDialog.setModal(true);
QList<QPushButton*> pbBtn = pbDialog.findChildren<QPushButton*>();
pbBtn.at(0)->setDisabled(true);
QList<QProgressBar*> pbBar = pbDialog.findChildren<QProgressBar*>();
pbBar.at(0)->setTextVisible(false);
pbDialog.setAutoClose(false);
pbDialog.show();
// Begin Progress
QStringList fails;
for (SnapmaticWidget *snapmaticWidget : snapmaticWidgets)
{
// Update Progress
overallId++;
pbDialog.setValue(overallId);
pbDialog.setLabelText(tr("Patch file %1 of %2 files").arg(QString::number(overallId), QString::number(maximumId)));
SnapmaticPicture *picture = snapmaticWidget->getPicture();
SnapmaticProperties snapmaticProperties = picture->getSnapmaticProperties();
snapmaticProperties.playersList = players;
QString currentFilePath = picture->getPictureFilePath();
QString originalFilePath = picture->getOriginalPictureFilePath();
QString backupFileName = originalFilePath % ".bak";
if (!QFile::exists(backupFileName))
{
QFile::copy(currentFilePath, backupFileName);
}
SnapmaticProperties fallbackProperties = picture->getSnapmaticProperties();
picture->setSnapmaticProperties(snapmaticProperties);