gta5view/src/ImportDialog.cpp

971 lines
38 KiB
C++
Raw Normal View History

2017-10-09 08:35:48 +02:00
/*****************************************************************************
* gta5view Grand Theft Auto V Profile Viewer
* Copyright (C) 2017-2023 Syping
2017-10-09 08:35:48 +02:00
*
* 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 "ui_ImportDialog.h"
2020-11-16 15:29:31 +01:00
#include "SnapmaticPicture.h"
2017-12-17 13:03:43 +01:00
#include "SidebarGenerator.h"
#include "StandardPaths.h"
2020-11-16 15:29:31 +01:00
#include "ImportDialog.h"
2018-07-20 15:58:51 +02:00
#include "imagecropper.h"
2017-10-09 08:35:48 +02:00
#include "AppEnv.h"
2017-12-17 13:03:43 +01:00
#include "config.h"
#include <QStringBuilder>
2018-07-25 20:52:30 +02:00
#include <QInputDialog>
2017-12-17 13:03:43 +01:00
#include <QImageReader>
2017-10-09 08:35:48 +02:00
#include <QColorDialog>
2017-12-17 13:03:43 +01:00
#include <QFileDialog>
2017-10-09 08:35:48 +02:00
#include <QMessageBox>
2017-12-17 13:03:43 +01:00
#include <QSettings>
2017-10-09 08:35:48 +02:00
#include <QPainter>
#include <QPixmap>
#include <QImage>
#include <QDebug>
2018-05-30 08:17:12 +02:00
#include <QStyle>
2017-12-17 13:03:43 +01:00
#include <QFile>
2017-10-09 08:35:48 +02:00
#include <QRgb>
// IMAGES VALUES
#define snapmaticAvatarResolution 470
#define snapmaticAvatarPlacementW 145
#define snapmaticAvatarPlacementH 66
ImportDialog::ImportDialog(QString profileName, QWidget *parent) :
QDialog(parent), profileName(profileName),
2017-10-09 08:35:48 +02:00
ui(new Ui::ImportDialog)
{
2017-12-12 04:45:46 +01:00
// Set Window Flags
2021-02-15 23:12:44 +01:00
setWindowFlag(Qt::WindowContextHelpButtonHint, false);
2017-12-12 04:45:46 +01:00
2017-10-09 08:35:48 +02:00
ui->setupUi(this);
ui->cmdOK->setDefault(true);
ui->cmdOK->setFocus();
2017-10-09 08:35:48 +02:00
importAgreed = false;
2018-07-21 18:33:08 +02:00
settingsLocked = false;
2018-07-09 20:39:27 +02:00
watermarkAvatar = true;
watermarkPicture = false;
2017-10-09 08:35:48 +02:00
insideAvatarZone = false;
2021-04-02 19:51:05 +02:00
avatarAreaImage = QImage(AppEnv::getImagesFolder() % "/avatarareaimport.png");
2017-10-09 08:35:48 +02:00
selectedColour = QColor::fromRgb(0, 0, 0, 255);
2018-01-11 08:41:00 +01:00
// Set Icon for OK Button
2021-02-03 20:22:00 +01:00
if (QIcon::hasThemeIcon("dialog-ok")) {
2017-10-09 08:35:48 +02:00
ui->cmdOK->setIcon(QIcon::fromTheme("dialog-ok"));
}
2021-02-03 20:22:00 +01:00
else if (QIcon::hasThemeIcon("gtk-ok")) {
2018-01-11 08:41:00 +01:00
ui->cmdOK->setIcon(QIcon::fromTheme("gtk-ok"));
}
// Set Icon for Cancel Button
2021-02-03 20:22:00 +01:00
if (QIcon::hasThemeIcon("dialog-cancel")) {
2017-10-09 08:35:48 +02:00
ui->cmdCancel->setIcon(QIcon::fromTheme("dialog-cancel"));
}
2021-02-03 20:22:00 +01:00
else if (QIcon::hasThemeIcon("gtk-cancel")) {
2018-01-11 08:41:00 +01:00
ui->cmdCancel->setIcon(QIcon::fromTheme("gtk-cancel"));
}
2017-10-09 08:35:48 +02:00
ui->cbIgnore->setChecked(false);
ui->labColour->setText(tr("Background Colour: <span style=\"color: %1\">%1</span>").arg(selectedColour.name()));
2017-12-17 13:03:43 +01:00
ui->labBackgroundImage->setText(tr("Background Image:"));
ui->cmdBackgroundWipe->setVisible(false);
2017-10-09 08:35:48 +02:00
2020-11-16 15:29:31 +01:00
// Snapmatic Resolution
snapmaticResolution = SnapmaticPicture::getSnapmaticResolution();
ui->cbResolution->addItem("GTA V", snapmaticResolution);
ui->cbResolution->addItem("FiveM", QSize(1920, 1072));
ui->cbResolution->addItem("1280x720", QSize(1280, 720));
ui->cbResolution->addItem("1920x1080", QSize(1920, 1080));
ui->cbResolution->addItem("2560x1440", QSize(2560, 1440));
// Set Import Settings
QSettings settings(GTA5SYNC_APPVENDOR, GTA5SYNC_APPSTR);
settings.beginGroup("Import");
QString currentProfile = settings.value("Profile", "Default").toString();
settings.endGroup();
processSettings(currentProfile);
2017-12-12 04:45:46 +01:00
// DPI calculation
2017-10-09 08:35:48 +02:00
qreal screenRatio = AppEnv::screenRatio();
2017-12-17 13:03:43 +01:00
snapmaticResolutionLW = 516 * screenRatio; // 430
snapmaticResolutionLH = 288 * screenRatio; // 240
ui->labPicture->setMinimumSize(snapmaticResolutionLW, snapmaticResolutionLH);
2017-12-12 04:45:46 +01:00
ui->vlButtom->setSpacing(6 * screenRatio);
#ifndef Q_OS_MAC
ui->vlButtom->setContentsMargins(9 * screenRatio, 6 * screenRatio, 9 * screenRatio, 9 * screenRatio);
#else
#if QT_VERSION >= 0x060000
if (QApplication::style()->objectName() == "macos") {
2017-12-12 04:45:46 +01:00
#else
2021-02-03 20:22:00 +01:00
if (QApplication::style()->objectName() == "macintosh") {
#endif
2017-12-12 04:45:46 +01:00
ui->vlButtom->setContentsMargins(9 * screenRatio, 9 * screenRatio, 9 * screenRatio, 9 * screenRatio);
}
2021-02-03 20:22:00 +01:00
else {
2017-12-12 04:45:46 +01:00
ui->vlButtom->setContentsMargins(9 * screenRatio, 6 * screenRatio, 9 * screenRatio, 9 * screenRatio);
}
#endif
2017-12-17 13:03:43 +01:00
// Options menu
2020-11-16 15:29:31 +01:00
optionsMenu.addAction(tr("&Import new Picture..."), this, SLOT(importNewPicture()));
optionsMenu.addAction(tr("&Crop Picture..."), this, SLOT(cropPicture()));
optionsMenu.addSeparator();
optionsMenu.addAction(tr("&Load Settings..."), this, SLOT(loadImportSettings()));
optionsMenu.addAction(tr("&Save Settings..."), this, SLOT(saveImportSettings()));
ui->cmdOptions->setMenu(&optionsMenu);
2021-02-03 20:22:00 +01:00
const QSize windowSize = sizeHint();
setMinimumSize(windowSize);
setMaximumSize(windowSize);
2017-10-09 08:35:48 +02:00
}
ImportDialog::~ImportDialog()
{
delete ui;
}
void ImportDialog::processImage()
{
2020-11-16 15:29:31 +01:00
if (workImage.isNull())
return;
2017-10-09 08:35:48 +02:00
QImage snapmaticImage = workImage;
2020-11-16 15:29:31 +01:00
QPixmap snapmaticPixmap(snapmaticResolution);
2017-10-09 08:35:48 +02:00
snapmaticPixmap.fill(selectedColour);
QPainter snapmaticPainter(&snapmaticPixmap);
2019-01-13 14:32:12 +01:00
qreal screenRatioPR = AppEnv::screenRatioPR();
2020-11-16 15:29:31 +01:00
if (!backImage.isNull()) {
if (!ui->cbStretch->isChecked()) {
2017-12-17 13:03:43 +01:00
int diffWidth = 0;
int diffHeight = 0;
2020-11-16 15:29:31 +01:00
if (backImage.width() != snapmaticResolution.width()) {
diffWidth = snapmaticResolution.width() - backImage.width();
2017-12-17 13:03:43 +01:00
diffWidth = diffWidth / 2;
}
2020-11-16 15:29:31 +01:00
else if (backImage.height() != snapmaticResolution.height()) {
diffHeight = snapmaticResolution.height() - backImage.height();
2017-12-17 13:03:43 +01:00
diffHeight = diffHeight / 2;
}
snapmaticPainter.drawImage(0 + diffWidth, 0 + diffHeight, backImage);
}
2020-11-16 15:29:31 +01:00
else {
snapmaticPainter.drawImage(0, 0, QImage(backImage).scaled(snapmaticResolution, Qt::IgnoreAspectRatio, Qt::SmoothTransformation));
2017-12-17 13:03:43 +01:00
}
2020-11-16 15:29:31 +01:00
if (ui->cbAvatar->isChecked() && ui->cbForceAvatarColour->isChecked()) {
2017-12-17 13:03:43 +01:00
snapmaticPainter.fillRect(snapmaticAvatarPlacementW, snapmaticAvatarPlacementH, snapmaticAvatarResolution, snapmaticAvatarResolution, selectedColour);
}
}
2020-11-16 15:29:31 +01:00
if (insideAvatarZone) {
2017-10-09 08:35:48 +02:00
// Avatar mode
int diffWidth = 0;
int diffHeight = 0;
2021-02-03 20:22:00 +01:00
if (ui->cbIgnore->isChecked()) {
snapmaticImage = snapmaticImage.scaled(snapmaticAvatarResolution, snapmaticAvatarResolution, Qt::IgnoreAspectRatio, Qt::SmoothTransformation);
}
else if (ui->cbBorderless->isChecked()) {
snapmaticImage = snapmaticImage.scaled(snapmaticAvatarResolution, snapmaticAvatarResolution, Qt::KeepAspectRatioByExpanding, Qt::SmoothTransformation);
if (snapmaticImage.width() > snapmaticAvatarResolution) {
int diffWidth = snapmaticImage.width() - snapmaticAvatarResolution;
diffWidth = diffWidth / 2;
QImage croppedImage(snapmaticAvatarResolution, snapmaticAvatarResolution, QImage::Format_ARGB32);
croppedImage.fill(Qt::transparent);
QPainter croppedPainter(&croppedImage);
croppedPainter.drawImage(0 - diffWidth, 0, snapmaticImage);
croppedPainter.end();
snapmaticImage = croppedImage;
}
else if (snapmaticImage.height() > snapmaticAvatarResolution) {
int diffHeight = snapmaticImage.height() - snapmaticAvatarResolution;
diffHeight = diffHeight / 2;
QImage croppedImage(snapmaticAvatarResolution, snapmaticAvatarResolution, QImage::Format_ARGB32);
croppedImage.fill(Qt::transparent);
QPainter croppedPainter(&croppedImage);
croppedPainter.drawImage(0, 0 - diffHeight, snapmaticImage);
croppedPainter.end();
snapmaticImage = croppedImage;
}
}
else {
2017-10-09 08:35:48 +02:00
snapmaticImage = snapmaticImage.scaled(snapmaticAvatarResolution, snapmaticAvatarResolution, Qt::KeepAspectRatio, Qt::SmoothTransformation);
2020-11-16 15:29:31 +01:00
if (snapmaticImage.width() > snapmaticImage.height()) {
2017-10-09 08:35:48 +02:00
diffHeight = snapmaticAvatarResolution - snapmaticImage.height();
diffHeight = diffHeight / 2;
}
2020-11-16 15:29:31 +01:00
else if (snapmaticImage.width() < snapmaticImage.height()) {
2017-10-09 08:35:48 +02:00
diffWidth = snapmaticAvatarResolution - snapmaticImage.width();
diffWidth = diffWidth / 2;
}
}
snapmaticPainter.drawImage(snapmaticAvatarPlacementW + diffWidth, snapmaticAvatarPlacementH + diffHeight, snapmaticImage);
2020-11-16 15:29:31 +01:00
if (ui->cbWatermark->isChecked())
processWatermark(&snapmaticPainter);
imageTitle = tr("Custom Avatar", "Custom Avatar Description in SC, don't use Special Character!");
2017-10-09 08:35:48 +02:00
}
2020-11-16 15:29:31 +01:00
else {
2017-10-09 08:35:48 +02:00
// Picture mode
int diffWidth = 0;
int diffHeight = 0;
2021-02-03 20:22:00 +01:00
if (ui->cbIgnore->isChecked()) {
snapmaticImage = snapmaticImage.scaled(snapmaticResolution, Qt::IgnoreAspectRatio, Qt::SmoothTransformation);
}
else if (ui->cbBorderless->isChecked()) {
snapmaticImage = snapmaticImage.scaled(snapmaticResolution, Qt::KeepAspectRatioByExpanding, Qt::SmoothTransformation);
if (snapmaticImage.width() > snapmaticResolution.width()) {
int diffWidth = snapmaticImage.width() - snapmaticResolution.width();
diffWidth = diffWidth / 2;
QImage croppedImage(snapmaticResolution, QImage::Format_ARGB32);
croppedImage.fill(Qt::transparent);
QPainter croppedPainter(&croppedImage);
croppedPainter.drawImage(0 - diffWidth, 0, snapmaticImage);
croppedPainter.end();
snapmaticImage = croppedImage;
}
else if (snapmaticImage.height() > snapmaticResolution.height()) {
int diffHeight = snapmaticImage.height() - snapmaticResolution.height();
diffHeight = diffHeight / 2;
QImage croppedImage(snapmaticResolution, QImage::Format_ARGB32);
croppedImage.fill(Qt::transparent);
QPainter croppedPainter(&croppedImage);
croppedPainter.drawImage(0, 0 - diffHeight, snapmaticImage);
croppedPainter.end();
snapmaticImage = croppedImage;
}
}
else {
2020-11-16 15:29:31 +01:00
snapmaticImage = snapmaticImage.scaled(snapmaticResolution, Qt::KeepAspectRatio, Qt::SmoothTransformation);
if (snapmaticImage.width() != snapmaticResolution.width()) {
diffWidth = snapmaticResolution.width() - snapmaticImage.width();
2017-10-09 08:35:48 +02:00
diffWidth = diffWidth / 2;
}
2020-11-16 15:29:31 +01:00
else if (snapmaticImage.height() != snapmaticResolution.height()) {
diffHeight = snapmaticResolution.height() - snapmaticImage.height();
2017-10-09 08:35:48 +02:00
diffHeight = diffHeight / 2;
}
}
snapmaticPainter.drawImage(0 + diffWidth, 0 + diffHeight, snapmaticImage);
2020-11-16 15:29:31 +01:00
if (ui->cbWatermark->isChecked())
processWatermark(&snapmaticPainter);
imageTitle = tr("Custom Picture", "Custom Picture Description in SC, don't use Special Character!");
2017-10-09 08:35:48 +02:00
}
snapmaticPainter.end();
newImage = snapmaticPixmap.toImage();
2019-01-13 14:32:12 +01:00
#if QT_VERSION >= 0x050600
snapmaticPixmap.setDevicePixelRatio(screenRatioPR);
#endif
ui->labPicture->setPixmap(snapmaticPixmap.scaled(snapmaticResolutionLW * screenRatioPR, snapmaticResolutionLH * screenRatioPR, Qt::IgnoreAspectRatio, Qt::SmoothTransformation));
2017-10-09 08:35:48 +02:00
}
2020-11-16 15:29:31 +01:00
void ImportDialog::reworkImage()
{
workImage = QImage();
if (origImage.width() == origImage.height()) {
if (ui->cbResolution->currentIndex() == 0) {
insideAvatarZone = true;
ui->cbAvatar->setChecked(true);
}
else {
insideAvatarZone = false;
ui->cbAvatar->setChecked(false);
}
if (origImage.height() > snapmaticResolution.height()) {
workImage = origImage.scaled(snapmaticResolution.height(), snapmaticResolution.height(), Qt::IgnoreAspectRatio, Qt::SmoothTransformation);
}
else {
workImage = origImage;
}
}
else if (origImage.width() > snapmaticResolution.width() && origImage.width() > origImage.height()) {
insideAvatarZone = false;
ui->cbAvatar->setChecked(false);
workImage = origImage.scaledToWidth(snapmaticResolution.width(), Qt::SmoothTransformation);
}
else if (origImage.height() > snapmaticResolution.height() && origImage.height() > origImage.width()) {
insideAvatarZone = false;
ui->cbAvatar->setChecked(false);
workImage = origImage.scaledToHeight(snapmaticResolution.height(), Qt::SmoothTransformation);
}
else {
insideAvatarZone = false;
ui->cbAvatar->setChecked(false);
workImage = origImage;
}
processImage();
}
2018-07-09 20:39:27 +02:00
void ImportDialog::processWatermark(QPainter *snapmaticPainter)
{
bool blackWatermark = false;
bool redWatermark = false;
2020-11-17 16:38:30 +01:00
if (selectedColour.red() > 127) {
if (selectedColour.green() > 127 || selectedColour.blue() > 127) {
2018-07-09 20:39:27 +02:00
redWatermark = true;
}
}
2020-11-17 16:38:30 +01:00
else {
2018-07-09 20:39:27 +02:00
redWatermark = true;
}
2020-11-17 16:38:30 +01:00
if (selectedColour.lightness() > 127) {
2018-07-09 20:39:27 +02:00
blackWatermark = true;
}
// draw watermark
2020-11-17 16:38:30 +01:00
if (redWatermark) {
2021-04-02 19:51:05 +02:00
const QImage viewWatermark = QImage(AppEnv::getImagesFolder() % "/watermark_2r.png");
2020-11-17 16:38:30 +01:00
snapmaticPainter->drawImage(snapmaticResolution.width() - viewWatermark.width(), 0, viewWatermark);
2018-07-09 20:39:27 +02:00
}
else
{
2021-04-02 19:51:05 +02:00
QImage viewWatermark = QImage(AppEnv::getImagesFolder() % "/watermark_2b.png");
2020-11-17 16:38:30 +01:00
if (!blackWatermark) {
2018-07-09 20:39:27 +02:00
viewWatermark.invertPixels(QImage::InvertRgb);
}
2020-11-17 16:38:30 +01:00
snapmaticPainter->drawImage(snapmaticResolution.width() - viewWatermark.width(), 0, viewWatermark);
2018-07-09 20:39:27 +02:00
}
2021-04-02 19:51:05 +02:00
QImage textWatermark = QImage(AppEnv::getImagesFolder() % "/watermark_1b.png");
2020-11-17 16:38:30 +01:00
if (!blackWatermark) {
2018-07-09 20:39:27 +02:00
textWatermark.invertPixels(QImage::InvertRgb);
}
2020-11-17 16:38:30 +01:00
snapmaticPainter->drawImage(snapmaticResolution.width() - textWatermark.width(), 0, textWatermark);
2018-07-09 20:39:27 +02:00
}
2018-07-25 20:52:30 +02:00
void ImportDialog::processSettings(QString settingsProfile, bool setDefault)
{
QSettings settings(GTA5SYNC_APPVENDOR, GTA5SYNC_APPSTR);
settings.beginGroup("Import");
2020-11-16 15:29:31 +01:00
if (setDefault) {
2018-07-25 20:52:30 +02:00
settings.setValue("Profile", settingsProfile);
}
2020-11-16 15:29:31 +01:00
if (settingsProfile == "Default") {
2018-07-25 20:52:30 +02:00
watermarkAvatar = true;
watermarkPicture = false;
selectedColour = QColor::fromRgb(0, 0, 0, 255);
backImage = QImage();
2021-02-03 20:22:00 +01:00
ui->cbBorderless->setChecked(false);
2018-07-25 20:52:30 +02:00
ui->cbStretch->setChecked(false);
ui->cbForceAvatarColour->setChecked(false);
2020-11-16 15:29:31 +01:00
ui->cbUnlimited->setChecked(false);
ui->cbImportAsIs->setChecked(false);
ui->cbResolution->setCurrentIndex(0);
2018-07-25 20:52:30 +02:00
}
2020-11-16 15:29:31 +01:00
else {
2018-07-25 20:52:30 +02:00
settings.beginGroup(settingsProfile);
watermarkAvatar = settings.value("WatermarkAvatar", true).toBool();
watermarkPicture = settings.value("WatermarkPicture", false).toBool();
backImage = qvariant_cast<QImage>(settings.value("BackgroundImage", QImage()));
selectedColour = qvariant_cast<QColor>(settings.value("SelectedColour", QColor::fromRgb(0, 0, 0, 255)));
2021-02-03 20:22:00 +01:00
ui->cbBorderless->setChecked(settings.value("BorderlessImage", false).toBool());
2018-07-25 20:52:30 +02:00
ui->cbStretch->setChecked(settings.value("BackgroundStretch", false).toBool());
ui->cbForceAvatarColour->setChecked(settings.value("ForceAvatarColour", false).toBool());
2020-11-16 15:29:31 +01:00
ui->cbUnlimited->setChecked(settings.value("UnlimitedBuffer", false).toBool());
ui->cbImportAsIs->setChecked(settings.value("ImportAsIs", false).toBool());
const QVariant data = settings.value("Resolution", SnapmaticPicture::getSnapmaticResolution());
#if QT_VERSION >= 0x060000
if (data.typeId() == QMetaType::QSize)
#else
if (data.type() == QVariant::Size)
#endif
{
2020-11-16 15:29:31 +01:00
int index = ui->cbResolution->findData(data);
if (index != -1) {
ui->cbResolution->setCurrentIndex(index);
}
}
2018-07-25 20:52:30 +02:00
settings.endGroup();
}
2020-11-16 15:29:31 +01:00
if (!workImage.isNull()) {
if (ui->cbAvatar->isChecked()) {
2018-07-25 20:52:30 +02:00
ui->cbWatermark->setChecked(watermarkAvatar);
}
2020-11-16 15:29:31 +01:00
else {
2018-07-25 20:52:30 +02:00
ui->cbWatermark->setChecked(watermarkPicture);
}
}
ui->labColour->setText(tr("Background Colour: <span style=\"color: %1\">%1</span>").arg(selectedColour.name()));
2020-11-16 15:29:31 +01:00
if (!backImage.isNull()) {
2018-07-25 20:52:30 +02:00
ui->labBackgroundImage->setText(tr("Background Image: %1").arg(tr("Storage", "Background Image: Storage")));
ui->cmdBackgroundWipe->setVisible(true);
}
2020-11-16 15:29:31 +01:00
else {
2018-07-25 20:52:30 +02:00
ui->labBackgroundImage->setText(tr("Background Image:"));
ui->cmdBackgroundWipe->setVisible(false);
}
settings.endGroup();
}
void ImportDialog::saveSettings(QString settingsProfile)
{
QSettings settings(GTA5SYNC_APPVENDOR, GTA5SYNC_APPSTR);
settings.beginGroup("Import");
settings.beginGroup(settingsProfile);
settings.setValue("WatermarkAvatar", watermarkAvatar);
settings.setValue("WatermarkPicture", watermarkPicture);
settings.setValue("BackgroundImage", backImage);
settings.setValue("SelectedColour", selectedColour);
2021-02-03 20:22:00 +01:00
settings.setValue("BorderlessImage", ui->cbBorderless->isChecked());
2018-07-25 20:52:30 +02:00
settings.setValue("BackgroundStretch", ui->cbStretch->isChecked());
settings.setValue("ForceAvatarColour", ui->cbForceAvatarColour->isChecked());
2020-11-17 06:58:29 +01:00
#if QT_VERSION >= 0x050000
2020-11-16 15:29:31 +01:00
const QVariant data = ui->cbResolution->currentData();
2020-11-17 06:58:29 +01:00
#else
const QVariant data = ui->cbResolution->itemData(ui->cbResolution->currentIndex());
#endif
#if QT_VERSION >= 0x060000
if (data.typeId() == QMetaType::QSize)
#else
if (data.type() == QVariant::Size)
#endif
{
2020-11-17 06:58:29 +01:00
settings.setValue("Resolution", data);
2020-11-16 15:29:31 +01:00
}
else {
settings.setValue("Resolution", SnapmaticPicture::getSnapmaticResolution());
}
settings.setValue("UnlimitedBuffer", ui->cbUnlimited->isChecked());
settings.setValue("ImportAsIs", ui->cbImportAsIs->isChecked());
2018-07-25 20:52:30 +02:00
settings.endGroup();
settings.setValue("Profile", settingsProfile);
settings.endGroup();
}
2018-07-20 15:58:51 +02:00
void ImportDialog::cropPicture()
{
qreal screenRatio = AppEnv::screenRatio();
QDialog cropDialog(this);
2018-07-21 18:33:08 +02:00
#if QT_VERSION >= 0x050000
cropDialog.setObjectName(QStringLiteral("CropDialog"));
#else
cropDialog.setObjectName(QString::fromUtf8("CropDialog"));
#endif
2018-07-20 15:58:51 +02:00
cropDialog.setWindowTitle(tr("Crop Picture..."));
cropDialog.setWindowFlags(cropDialog.windowFlags()^Qt::WindowContextHelpButtonHint);
cropDialog.setModal(true);
QVBoxLayout cropLayout;
2018-07-21 18:33:08 +02:00
#if QT_VERSION >= 0x050000
cropLayout.setObjectName(QStringLiteral("CropLayout"));
#else
cropLayout.setObjectName(QString::fromUtf8("CropLayout"));
#endif
2018-07-20 15:58:51 +02:00
cropLayout.setContentsMargins(0, 0, 0, 0);
cropLayout.setSpacing(0);
cropDialog.setLayout(&cropLayout);
ImageCropper imageCropper(&cropDialog);
2018-07-21 18:33:08 +02:00
#if QT_VERSION >= 0x050000
imageCropper.setObjectName(QStringLiteral("ImageCropper"));
#else
imageCropper.setObjectName(QString::fromUtf8("ImageCropper"));
#endif
2018-07-20 15:58:51 +02:00
imageCropper.setBackgroundColor(Qt::black);
imageCropper.setCroppingRectBorderColor(QColor(255, 255, 255, 127));
imageCropper.setImage(QPixmap::fromImage(origImage, Qt::AutoColor));
2018-07-20 15:58:51 +02:00
imageCropper.setProportion(QSize(1, 1));
imageCropper.setFixedSize(workImage.size());
cropLayout.addWidget(&imageCropper);
QHBoxLayout buttonLayout;
2018-07-21 18:33:08 +02:00
#if QT_VERSION >= 0x050000
cropLayout.setObjectName(QStringLiteral("ButtonLayout"));
#else
cropLayout.setObjectName(QString::fromUtf8("ButtonLayout"));
#endif
2018-07-20 15:58:51 +02:00
cropLayout.addLayout(&buttonLayout);
QPushButton cropButton(&cropDialog);
2018-07-21 18:33:08 +02:00
#if QT_VERSION >= 0x050000
cropButton.setObjectName(QStringLiteral("CropButton"));
#else
cropButton.setObjectName(QString::fromUtf8("CropButton"));
#endif
2018-07-20 15:58:51 +02:00
cropButton.setMinimumSize(0, 40 * screenRatio);
cropButton.setText(tr("&Crop"));
cropButton.setToolTip(tr("Crop Picture"));
QObject::connect(&cropButton, SIGNAL(clicked(bool)), &cropDialog, SLOT(accept()));
buttonLayout.addWidget(&cropButton);
cropDialog.show();
cropDialog.setFixedSize(cropDialog.sizeHint());
2021-02-03 20:22:00 +01:00
if (cropDialog.exec() == QDialog::Accepted) {
2018-07-20 15:58:51 +02:00
QImage *croppedImage = new QImage(imageCropper.cropImage().toImage());
setImage(croppedImage);
}
}
void ImportDialog::importNewPicture()
{
QSettings settings(GTA5SYNC_APPVENDOR, GTA5SYNC_APPSTR);
settings.beginGroup("FileDialogs");
bool dontUseNativeDialog = settings.value("DontUseNativeDialog", false).toBool();
settings.beginGroup("ImportCopy");
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(QApplication::translate("ProfileInterface", "Import..."));
fileDialog.setLabelText(QFileDialog::Accept, QApplication::translate("ProfileInterface", "Import"));
// Getting readable Image formats
QString imageFormatsStr = " ";
2021-02-03 20:22:00 +01:00
for (const 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(profileName % "+Directory", StandardPaths::documentsLocation()).toString());
fileDialog.restoreGeometry(settings.value(profileName % "+Geometry", "").toByteArray());
2021-02-03 20:22:00 +01:00
if (fileDialog.exec()) {
QStringList selectedFiles = fileDialog.selectedFiles();
2021-02-03 20:22:00 +01:00
if (selectedFiles.length() == 1) {
QString selectedFile = selectedFiles.at(0);
QString selectedFileName = QFileInfo(selectedFile).fileName();
QFile snapmaticFile(selectedFile);
2021-02-03 20:22:00 +01:00
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 = new QImage();
QImageReader snapmaticImageReader;
snapmaticImageReader.setDecideFormatFromContent(true);
snapmaticImageReader.setDevice(&snapmaticFile);
2021-02-03 20:22:00 +01:00
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+"\""));
delete importImage;
goto fileDialogPreOpen;
}
setImage(importImage);
}
}
settings.setValue(profileName % "+Geometry", fileDialog.saveGeometry());
settings.setValue(profileName % "+Directory", fileDialog.directory().absolutePath());
settings.endGroup();
settings.endGroup();
}
2018-07-25 20:52:30 +02:00
void ImportDialog::loadImportSettings()
{
2021-02-03 20:22:00 +01:00
if (settingsLocked) {
2018-07-25 20:52:30 +02:00
QMessageBox::information(this, tr("Load Settings..."), tr("Please import a new picture first"));
return;
}
bool ok;
QStringList profileList;
profileList << tr("Default", "Default as Default Profile")
2020-11-16 15:29:31 +01:00
<< tr("Profile %1", "Profile %1 as Profile 1").arg("1")
<< tr("Profile %1", "Profile %1 as Profile 1").arg("2")
<< tr("Profile %1", "Profile %1 as Profile 1").arg("3")
<< tr("Profile %1", "Profile %1 as Profile 1").arg("4")
<< tr("Profile %1", "Profile %1 as Profile 1").arg("5");
2018-07-25 20:52:30 +02:00
QString sProfile = QInputDialog::getItem(this, tr("Load Settings..."), tr("Please select your settings profile"), profileList, 0, false, &ok, windowFlags());
2021-02-03 20:22:00 +01:00
if (ok) {
2018-07-25 20:52:30 +02:00
QString pProfile;
2021-02-03 20:22:00 +01:00
if (sProfile == tr("Default", "Default as Default Profile")) {
2018-07-25 20:52:30 +02:00
pProfile = "Default";
}
2021-02-03 20:22:00 +01:00
else if (sProfile == tr("Profile %1", "Profile %1 as Profile 1").arg("1")) {
2018-07-25 20:52:30 +02:00
pProfile = "Profile 1";
}
2021-02-03 20:22:00 +01:00
else if (sProfile == tr("Profile %1", "Profile %1 as Profile 1").arg("2")) {
2018-07-25 20:52:30 +02:00
pProfile = "Profile 2";
}
2021-02-03 20:22:00 +01:00
else if (sProfile == tr("Profile %1", "Profile %1 as Profile 1").arg("3")) {
2018-07-25 20:52:30 +02:00
pProfile = "Profile 3";
}
else if (sProfile == tr("Profile %1", "Profile %1 as Profile 1").arg("4"))
{
pProfile = "Profile 4";
}
2021-02-03 20:22:00 +01:00
else if (sProfile == tr("Profile %1", "Profile %1 as Profile 1").arg("5")) {
2018-07-25 20:52:30 +02:00
pProfile = "Profile 5";
}
processSettings(pProfile, true);
processImage();
}
}
void ImportDialog::saveImportSettings()
{
2021-02-03 20:22:00 +01:00
if (settingsLocked) {
2018-07-25 20:52:30 +02:00
QMessageBox::information(this, tr("Save Settings..."), tr("Please import a new picture first"));
return;
}
bool ok;
QStringList profileList;
profileList << tr("Profile %1", "Profile %1 as Profile 1").arg("1")
2020-11-16 15:29:31 +01:00
<< tr("Profile %1", "Profile %1 as Profile 1").arg("2")
<< tr("Profile %1", "Profile %1 as Profile 1").arg("3")
<< tr("Profile %1", "Profile %1 as Profile 1").arg("4")
<< tr("Profile %1", "Profile %1 as Profile 1").arg("5");
2018-07-25 20:52:30 +02:00
QString sProfile = QInputDialog::getItem(this, tr("Save Settings..."), tr("Please select your settings profile"), profileList, 0, false, &ok, windowFlags());
2021-02-03 20:22:00 +01:00
if (ok) {
2018-07-25 20:52:30 +02:00
QString pProfile;
2021-02-03 20:22:00 +01:00
if (sProfile == tr("Profile %1", "Profile %1 as Profile 1").arg("1")) {
2018-07-25 20:52:30 +02:00
pProfile = "Profile 1";
}
2021-02-03 20:22:00 +01:00
else if (sProfile == tr("Profile %1", "Profile %1 as Profile 1").arg("2")) {
2018-07-25 20:52:30 +02:00
pProfile = "Profile 2";
}
2021-02-03 20:22:00 +01:00
else if (sProfile == tr("Profile %1", "Profile %1 as Profile 1").arg("3")) {
2018-07-25 20:52:30 +02:00
pProfile = "Profile 3";
}
2021-02-03 20:22:00 +01:00
else if (sProfile == tr("Profile %1", "Profile %1 as Profile 1").arg("4")) {
2018-07-25 20:52:30 +02:00
pProfile = "Profile 4";
}
2021-02-03 20:22:00 +01:00
else if (sProfile == tr("Profile %1", "Profile %1 as Profile 1").arg("5")) {
2018-07-25 20:52:30 +02:00
pProfile = "Profile 5";
}
saveSettings(pProfile);
}
}
2017-10-09 08:35:48 +02:00
QImage ImportDialog::image()
{
2020-11-16 15:29:31 +01:00
if (ui->cbImportAsIs->isChecked()) {
return origImage;
}
else {
return newImage;
}
2017-10-09 08:35:48 +02:00
}
void ImportDialog::setImage(QImage *image_)
2017-10-09 08:35:48 +02:00
{
origImage = *image_;
workImage = QImage();
2020-11-16 15:29:31 +01:00
if (image_->width() == image_->height()) {
if (ui->cbResolution->currentIndex() == 0) {
insideAvatarZone = true;
ui->cbAvatar->setChecked(true);
}
else {
insideAvatarZone = false;
ui->cbAvatar->setChecked(false);
}
if (image_->height() > snapmaticResolution.height()) {
workImage = image_->scaled(snapmaticResolution.height(), snapmaticResolution.height(), Qt::IgnoreAspectRatio, Qt::SmoothTransformation);
delete image_;
}
2020-11-16 15:29:31 +01:00
else {
workImage = *image_;
delete image_;
}
}
2020-11-16 15:29:31 +01:00
else if (image_->width() > snapmaticResolution.width() && image_->width() > image_->height()) {
insideAvatarZone = false;
ui->cbAvatar->setChecked(false);
2020-11-16 15:29:31 +01:00
workImage = image_->scaledToWidth(snapmaticResolution.width(), Qt::SmoothTransformation);
delete image_;
}
2020-11-16 15:29:31 +01:00
else if (image_->height() > snapmaticResolution.height() && image_->height() > image_->width()) {
insideAvatarZone = false;
ui->cbAvatar->setChecked(false);
2020-11-16 15:29:31 +01:00
workImage = image_->scaledToHeight(snapmaticResolution.height(), Qt::SmoothTransformation);
delete image_;
}
2020-11-16 15:29:31 +01:00
else {
insideAvatarZone = false;
ui->cbAvatar->setChecked(false);
workImage = *image_;
delete image_;
2017-10-09 08:35:48 +02:00
}
processImage();
2018-07-21 18:33:08 +02:00
lockSettings(false);
}
void ImportDialog::lockSettings(bool lock)
{
2020-11-16 15:29:31 +01:00
ui->gbAdvanced->setDisabled(lock);
if (ui->cbImportAsIs->isChecked()) {
ui->gbBackground->setDisabled(true);
ui->gbSettings->setDisabled(true);
}
else {
ui->gbBackground->setDisabled(lock);
ui->gbSettings->setDisabled(lock);
}
2018-07-21 18:33:08 +02:00
ui->cmdOK->setDisabled(lock);
settingsLocked = lock;
}
void ImportDialog::enableOverwriteMode()
{
setWindowTitle(QApplication::translate("ImageEditorDialog", "Overwrite Image..."));
ui->cmdOK->setText(QApplication::translate("ImageEditorDialog", "&Overwrite"));
ui->cmdOK->setToolTip(QApplication::translate("ImageEditorDialog", "Apply changes"));
ui->cmdCancel->setText(QApplication::translate("ImageEditorDialog", "&Close"));
ui->cmdCancel->setToolTip(QApplication::translate("ImageEditorDialog", "Discard changes"));
ui->cmdCancel->setDefault(true);
ui->cmdCancel->setFocus();
lockSettings(true);
2017-10-09 08:35:48 +02:00
}
bool ImportDialog::isImportAgreed()
{
return importAgreed;
}
2020-11-16 15:29:31 +01:00
bool ImportDialog::isUnlimitedBuffer()
{
return ui->cbUnlimited->isChecked();
}
2018-07-21 18:33:08 +02:00
bool ImportDialog::areSettingsLocked()
{
return settingsLocked;
}
2017-10-09 08:35:48 +02:00
QString ImportDialog::getImageTitle()
{
2021-02-03 20:22:00 +01:00
if (ui->cbImportAsIs->isChecked()) {
return tr("Custom Picture", "Custom Picture Description in SC, don't use Special Character!");
}
else {
return imageTitle;
}
2017-10-09 08:35:48 +02:00
}
void ImportDialog::on_cbIgnore_toggled(bool checked)
{
2021-02-03 20:22:00 +01:00
ui->cbBorderless->setDisabled(checked);
2017-10-09 08:35:48 +02:00
processImage();
}
void ImportDialog::on_cbAvatar_toggled(bool checked)
{
2020-11-16 15:29:31 +01:00
if (ui->cbResolution->currentIndex() != 0)
return;
if (!workImage.isNull() && workImage.width() == workImage.height() && !checked) {
if (QMessageBox::No == QMessageBox::warning(this, tr("Snapmatic Avatar Zone"), tr("Are you sure to use a square image outside of the Avatar Zone?\nWhen you want to use it as Avatar the image will be detached!"), QMessageBox::Yes | QMessageBox::No, QMessageBox::No)) {
2017-10-09 08:35:48 +02:00
ui->cbAvatar->setChecked(true);
insideAvatarZone = true;
return;
}
}
insideAvatarZone = ui->cbAvatar->isChecked();
2018-07-09 20:39:27 +02:00
watermarkBlock = true;
2020-11-16 15:29:31 +01:00
if (insideAvatarZone) {
2018-07-09 20:39:27 +02:00
ui->cbWatermark->setChecked(watermarkAvatar);
}
2020-11-16 15:29:31 +01:00
else {
2018-07-09 20:39:27 +02:00
ui->cbWatermark->setChecked(watermarkPicture);
}
watermarkBlock = false;
2017-10-09 08:35:48 +02:00
processImage();
}
void ImportDialog::on_cmdCancel_clicked()
{
close();
}
void ImportDialog::on_cmdOK_clicked()
{
importAgreed = true;
close();
}
void ImportDialog::on_labPicture_labelPainted()
{
2021-02-03 20:22:00 +01:00
if (insideAvatarZone) {
2017-10-09 08:35:48 +02:00
QImage avatarAreaFinalImage(avatarAreaImage);
2021-02-03 20:22:00 +01:00
if (selectedColour.lightness() > 127) {
2017-10-09 08:35:48 +02:00
avatarAreaFinalImage.setColor(1, qRgb(0, 0, 0));
}
QPainter labelPainter(ui->labPicture);
labelPainter.drawImage(0, 0, avatarAreaFinalImage.scaled(snapmaticResolutionLW, snapmaticResolutionLH, Qt::IgnoreAspectRatio, Qt::SmoothTransformation));
labelPainter.end();
}
}
void ImportDialog::on_cmdColourChange_clicked()
{
QColor newSelectedColour = QColorDialog::getColor(selectedColour, this, tr("Select Colour..."));
2021-02-03 20:22:00 +01:00
if (newSelectedColour.isValid()) {
2017-10-09 08:35:48 +02:00
selectedColour = newSelectedColour;
ui->labColour->setText(tr("Background Colour: <span style=\"color: %1\">%1</span>").arg(selectedColour.name()));
processImage();
}
}
2017-12-17 13:03:43 +01:00
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 = " ";
2021-02-03 20:22:00 +01:00
for (const QByteArray &imageFormat : QImageReader::supportedImageFormats()) {
2017-12-17 13:03:43 +01:00
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());
2021-02-03 20:22:00 +01:00
if (fileDialog.exec()) {
2017-12-17 13:03:43 +01:00
QStringList selectedFiles = fileDialog.selectedFiles();
2021-02-03 20:22:00 +01:00
if (selectedFiles.length() == 1) {
2017-12-17 13:03:43 +01:00
QString selectedFile = selectedFiles.at(0);
QString selectedFileName = QFileInfo(selectedFile).fileName();
QFile snapmaticFile(selectedFile);
2021-02-03 20:22:00 +01:00
if (!snapmaticFile.open(QFile::ReadOnly)) {
2017-12-17 13:03:43 +01:00
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);
2021-02-03 20:22:00 +01:00
if (!snapmaticImageReader.read(&importImage)) {
2017-12-17 13:03:43 +01:00
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;
}
2020-11-16 15:29:31 +01:00
backImage = importImage.scaled(snapmaticResolution, Qt::KeepAspectRatio, Qt::SmoothTransformation);
2017-12-17 13:03:43 +01:00
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();
}
2018-07-09 20:39:27 +02:00
void ImportDialog::on_cbWatermark_toggled(bool checked)
{
2021-02-03 20:22:00 +01:00
if (!watermarkBlock) {
2020-11-16 15:29:31 +01:00
if (insideAvatarZone) {
2018-07-09 20:39:27 +02:00
watermarkAvatar = checked;
}
2020-11-16 15:29:31 +01:00
else {
2018-07-09 20:39:27 +02:00
watermarkPicture = checked;
}
processImage();
}
}
2020-11-16 15:29:31 +01:00
2021-02-03 20:22:00 +01:00
void ImportDialog::on_cbBorderless_toggled(bool checked)
{
ui->cbIgnore->setDisabled(checked);
processImage();
}
2020-11-16 15:29:31 +01:00
void ImportDialog::on_cbImportAsIs_toggled(bool checked)
{
ui->cbResolution->setDisabled(checked);
ui->labResolution->setDisabled(checked);
ui->gbBackground->setDisabled(checked);
ui->gbSettings->setDisabled(checked);
}
void ImportDialog::on_cbResolution_currentIndexChanged(int index)
{
Q_UNUSED(index)
2020-11-17 06:58:29 +01:00
#if QT_VERSION >= 0x050000
2020-11-16 15:29:31 +01:00
const QVariant data = ui->cbResolution->currentData();
2020-11-17 06:58:29 +01:00
#else
const QVariant data = ui->cbResolution->itemData(ui->cbResolution->currentIndex());
#endif
#if QT_VERSION >= 0x060000
if (data.typeId() == QMetaType::QSize)
#else
if (data.type() == QVariant::Size)
#endif
{
2020-11-16 15:29:31 +01:00
const QSize dataSize = data.toSize();
if (dataSize == SnapmaticPicture::getSnapmaticResolution()) {
ui->cbAvatar->setEnabled(true);
snapmaticResolution = dataSize;
reworkImage();
}
else {
if (!workImage.isNull() && workImage.width() == workImage.height() && ui->cbAvatar->isChecked()) {
if (QMessageBox::No == QMessageBox::warning(this, tr("Snapmatic Avatar Zone"), tr("Are you sure to use a square image outside of the Avatar Zone?\nWhen you want to use it as Avatar the image will be detached!"), QMessageBox::Yes | QMessageBox::No, QMessageBox::No)) {
ui->cbResolution->setCurrentIndex(0);
ui->cbAvatar->setChecked(true);
insideAvatarZone = true;
return;
}
}
ui->cbAvatar->setChecked(false);
ui->cbAvatar->setDisabled(true);
insideAvatarZone = false;
ui->cbWatermark->setChecked(watermarkPicture);
snapmaticResolution = dataSize;
reworkImage();
}
}
}