gta5view/PictureDialog.cpp

642 lines
20 KiB
C++
Raw Normal View History

2016-03-21 07:54:14 +01:00
/*****************************************************************************
* gta5sync GRAND THEFT AUTO V SYNC
2017-02-11 04:21:55 +01:00
* Copyright (C) 2016-2017 Syping
2016-03-21 07:54:14 +01: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/>.
*****************************************************************************/
2016-03-20 21:57:18 +01:00
#include "PictureDialog.h"
2016-04-12 21:53:21 +02:00
#include "PictureWidget.h"
2016-03-22 05:20:42 +01:00
#include "ProfileDatabase.h"
2016-03-20 21:57:18 +01:00
#include "ui_PictureDialog.h"
#include "SidebarGenerator.h"
#include "StandardPaths.h"
#include "PictureExport.h"
#include "GlobalString.h"
#include "UiModLabel.h"
2016-03-20 21:57:18 +01:00
#ifdef GTA5SYNC_WIN
2016-11-02 07:43:59 +01:00
#if QT_VERSION >= 0x050200
#include <QtWinExtras/QtWin>
2016-11-02 07:43:59 +01:00
#include <QtWinExtras/QWinEvent>
#endif
#endif
#include <QDesktopWidget>
2016-03-21 20:44:07 +01:00
#include <QJsonDocument>
2016-04-26 14:59:14 +02:00
#include <QApplication>
#include <QStaticText>
2016-03-22 05:20:42 +01:00
#include <QFileDialog>
2016-03-21 22:14:32 +01:00
#include <QMessageBox>
2016-03-21 20:44:07 +01:00
#include <QJsonObject>
#include <QVariantMap>
#include <QJsonArray>
#include <QKeyEvent>
2016-04-14 03:44:38 +02:00
#include <QMimeData>
#include <QToolBar>
#include <QPainter>
2016-12-02 13:55:27 +01:00
#include <QPicture>
#include <QBitmap>
2016-04-14 03:44:38 +02:00
#include <QBuffer>
2017-02-17 12:07:37 +01:00
#include <QImage>
2016-03-21 20:44:07 +01:00
#include <QDebug>
2016-03-23 03:33:46 +01:00
#include <QList>
2016-04-14 03:44:38 +02:00
#include <QDrag>
#include <QIcon>
2016-03-23 03:33:46 +01:00
#include <QUrl>
#include <QDir>
PictureDialog::PictureDialog(ProfileDatabase *profileDB, CrewDatabase *crewDB, QWidget *parent) :
QDialog(parent), profileDB(profileDB), crewDB(crewDB),
2016-03-20 21:57:18 +01:00
ui(new Ui::PictureDialog)
2017-02-17 12:07:37 +01:00
{
primaryWindow = false;
setupPictureDialog(true);
}
PictureDialog::PictureDialog(QWidget *parent) :
QDialog(parent),
ui(new Ui::PictureDialog)
{
primaryWindow = false;
setupPictureDialog(false);
}
PictureDialog::PictureDialog(bool primaryWindow, ProfileDatabase *profileDB, CrewDatabase *crewDB, QWidget *parent) :
QDialog(parent), primaryWindow(primaryWindow), profileDB(profileDB), crewDB(crewDB),
ui(new Ui::PictureDialog)
{
setupPictureDialog(true);
}
PictureDialog::PictureDialog(bool primaryWindow, QWidget *parent) :
QDialog(parent), primaryWindow(primaryWindow),
ui(new Ui::PictureDialog)
{
setupPictureDialog(false);
}
void PictureDialog::setupPictureDialog(bool withDatabase_)
2016-03-20 21:57:18 +01:00
{
ui->setupUi(this);
2016-03-21 22:06:17 +01:00
windowTitleStr = this->windowTitle();
2016-03-21 20:44:07 +01:00
jsonDrawString = ui->labJSON->text();
2016-03-22 05:20:42 +01:00
ui->cmdExport->setEnabled(0);
2016-03-22 05:59:17 +01:00
plyrsList = QStringList();
fullscreenWidget = 0;
2017-02-17 12:07:37 +01:00
rqFullscreen = 0;
previewMode = 0;
naviEnabled = 0;
indexed = 0;
picArea = "";
picTitl = "";
picPath = "";
created = "";
2016-03-22 05:59:17 +01:00
crewID = "";
locX = "";
locY = "";
locZ = "";
2016-03-29 12:23:21 +02:00
smpic = 0;
2016-04-08 16:55:28 +02:00
2017-02-17 12:07:37 +01:00
// With datebase
withDatabase = withDatabase_;
// Avatar area
avatarAreaPicture = QImage(":/img/avatararea.png");
avatarLocX = 145;
avatarLocY = 66;
avatarSize = 470;
2017-01-27 01:48:47 +01:00
// Overlay area
renderOverlayPicture();
2017-02-17 12:07:37 +01:00
overlayEnabled = 1;
2017-01-27 01:48:47 +01:00
2016-04-08 16:55:28 +02:00
// Export menu
exportMenu = new QMenu(this);
2016-04-24 14:44:41 +02:00
jpegExportAction = exportMenu->addAction(tr("Export as &JPG picture..."), this, SLOT(exportSnapmaticPicture()));
pgtaExportAction = exportMenu->addAction(tr("Export as &GTA Snapmatic..."), this, SLOT(copySnapmaticPicture()));
2016-04-08 16:55:28 +02:00
ui->cmdExport->setMenu(exportMenu);
2016-04-23 21:01:00 +02:00
// Global map
globalMap = GlobalString::getGlobalMap();
2016-12-02 13:55:27 +01:00
// Event connects
connect(ui->labJSON, SIGNAL(resized(QSize)), this, SLOT(adaptNewDialogSize(QSize)));
2017-02-11 04:21:55 +01:00
// Dialog buttons
if (QIcon::hasThemeIcon("dialog-close"))
{
ui->cmdClose->setIcon(QIcon::fromTheme("dialog-close"));
}
installEventFilter(this);
2016-04-14 03:51:48 +02:00
installEventFilter(ui->labPicture);
ui->labPicture->setFocusPolicy(Qt::StrongFocus);
2016-03-20 21:57:18 +01:00
}
PictureDialog::~PictureDialog()
{
2016-04-24 14:44:41 +02:00
delete jpegExportAction;
delete pgtaExportAction;
2016-04-08 16:55:28 +02:00
delete exportMenu;
2016-03-20 21:57:18 +01:00
delete ui;
}
2017-02-17 12:07:37 +01:00
void PictureDialog::closeEvent(QCloseEvent *ev)
{
Q_UNUSED(ev)
if (primaryWindow && withDatabase)
{
emit endDatabaseThread();
}
}
void PictureDialog::addPreviousNextButtons()
{
// Windows Vista additions
#ifdef GTA5SYNC_WIN
2016-11-02 07:43:59 +01:00
#if QT_VERSION >= 0x050200
QPalette palette;
QToolBar *uiToolbar = new QToolBar("Picture Toolbar", this);
layout()->setMenuBar(uiToolbar);
uiToolbar->addAction(QIcon(":/img/back.png"), "", this, SLOT(previousPictureRequestedSlot()));
uiToolbar->addAction(QIcon(":/img/next.png"), "", this, SLOT(nextPictureRequestedSlot()));
ui->jsonFrame->setStyleSheet(QString("QFrame { background: %1; }").arg(palette.window().color().name()));
2017-02-17 12:07:37 +01:00
naviEnabled = true;
#endif
#endif
}
2016-12-02 13:55:27 +01:00
void PictureDialog::adaptNewDialogSize(QSize newLabelSize)
{
Q_UNUSED(newLabelSize)
int newDialogHeight = ui->labPicture->pixmap()->height();
newDialogHeight = newDialogHeight + ui->jsonFrame->height();
2017-02-17 12:07:37 +01:00
if (naviEnabled) newDialogHeight = newDialogHeight + layout()->menuBar()->height();
2016-12-02 13:55:27 +01:00
setMinimumSize(width(), newDialogHeight);
setMaximumSize(width(), newDialogHeight);
2017-01-22 19:52:39 +01:00
setFixedHeight(newDialogHeight);
2016-12-02 13:55:27 +01:00
ui->labPicture->updateGeometry();
ui->jsonFrame->updateGeometry();
2017-01-22 19:52:39 +01:00
updateGeometry();
2016-12-02 13:55:27 +01:00
}
2016-11-01 18:49:44 +01:00
void PictureDialog::stylizeDialog()
{
2016-11-02 07:33:47 +01:00
#ifdef GTA5SYNC_WIN
2016-11-02 07:43:59 +01:00
#if QT_VERSION >= 0x050200
if (QtWin::isCompositionEnabled())
{
2016-11-01 18:49:44 +01:00
QtWin::extendFrameIntoClientArea(this, 0, this->layout()->menuBar()->height(), 0, 0);
setAttribute(Qt::WA_TranslucentBackground, true);
setAttribute(Qt::WA_NoSystemBackground, false);
setStyleSheet("PictureDialog { background: transparent; }");
}
else
{
QtWin::resetExtendedFrame(this);
setAttribute(Qt::WA_TranslucentBackground, false);
2016-11-01 18:43:54 +01:00
setStyleSheet(QString("PictureDialog { background: %1; }").arg(QtWin::realColorizationColor().name()));
}
2016-11-02 07:33:47 +01:00
#endif
#endif
}
bool PictureDialog::event(QEvent *event)
{
#ifdef GTA5SYNC_WIN
2016-11-02 07:43:59 +01:00
#if QT_VERSION >= 0x050200
2017-02-17 12:07:37 +01:00
if (naviEnabled)
{
if (event->type() == QWinEvent::CompositionChange || event->type() == QWinEvent::ColorizationChange)
{
stylizeDialog();
}
}
#endif
#endif
return QDialog::event(event);
}
void PictureDialog::nextPictureRequestedSlot()
{
emit nextPictureRequested();
}
void PictureDialog::previousPictureRequestedSlot()
{
emit previousPictureRequested();
}
bool PictureDialog::eventFilter(QObject *obj, QEvent *ev)
{
2016-04-14 03:44:38 +02:00
bool returnValue = false;
2016-04-14 03:51:48 +02:00
if (obj == this || obj == ui->labPicture)
{
if (ev->type() == QEvent::KeyPress)
{
QKeyEvent *keyEvent = (QKeyEvent*)ev;
switch (keyEvent->key()){
case Qt::Key_Left:
emit previousPictureRequested();
2016-04-14 03:44:38 +02:00
returnValue = true;
break;
case Qt::Key_Right:
emit nextPictureRequested();
2016-04-14 03:44:38 +02:00
returnValue = true;
break;
case Qt::Key_E: case Qt::Key_S: case Qt::Key_Save:
ui->cmdExport->click();
returnValue = true;
break;
2017-01-27 01:48:47 +01:00
case Qt::Key_1:
2017-02-17 12:07:37 +01:00
if (previewMode)
{
2017-02-17 12:07:37 +01:00
previewMode = false;
renderPicture();
}
else
{
2017-02-17 12:07:37 +01:00
previewMode = true;
renderPicture();
}
break;
2017-01-27 01:48:47 +01:00
case Qt::Key_2:
2017-02-17 12:07:37 +01:00
if (overlayEnabled)
2017-01-27 01:48:47 +01:00
{
2017-02-17 12:07:37 +01:00
overlayEnabled = false;
if (!previewMode) renderPicture();
2017-01-27 01:48:47 +01:00
}
else
{
2017-02-17 12:07:37 +01:00
overlayEnabled = true;
if (!previewMode) renderPicture();
2017-01-27 01:48:47 +01:00
}
break;
#if QT_VERSION >= 0x050300
case Qt::Key_Exit:
2016-04-14 03:44:38 +02:00
ui->cmdClose->click();
returnValue = true;
break;
2016-04-18 07:23:19 +02:00
#endif
2016-04-14 03:44:38 +02:00
case Qt::Key_Enter: case Qt::Key_Return:
on_labPicture_mouseDoubleClicked(Qt::LeftButton);
2016-04-14 03:44:38 +02:00
returnValue = true;
break;
2017-02-17 12:07:37 +01:00
case Qt::Key_Escape:
ui->cmdClose->click();
returnValue = true;
break;
}
}
}
2016-04-14 03:44:38 +02:00
return returnValue;
}
2016-04-24 14:44:41 +02:00
void PictureDialog::triggerFullscreenDoubeClick()
{
on_labPicture_mouseDoubleClicked(Qt::LeftButton);
}
void PictureDialog::exportCustomContextMenuRequestedPrivate(const QPoint &pos, bool fullscreen)
{
2017-02-17 12:07:37 +01:00
rqFullscreen = fullscreen;
2016-04-24 14:44:41 +02:00
exportMenu->popup(pos);
}
void PictureDialog::exportCustomContextMenuRequested(const QPoint &pos)
{
exportCustomContextMenuRequestedPrivate(pos, true);
}
2016-04-14 03:44:38 +02:00
void PictureDialog::mousePressEvent(QMouseEvent *ev)
{
QDialog::mousePressEvent(ev);
}
2016-04-12 21:53:21 +02:00
void PictureDialog::dialogNextPictureRequested()
{
emit nextPictureRequested();
}
void PictureDialog::dialogPreviousPictureRequested()
{
emit previousPictureRequested();
}
2017-01-27 01:48:47 +01:00
void PictureDialog::renderOverlayPicture()
{
// Generating Overlay Preview
QRect preferedRect = QRect(0, 0, 200, 160);
QString overlayText = tr("Key 1 - Avatar Preview Mode\nKey 2 - Toggle Overlay\nArrow Keys - Navigate");
2017-02-17 12:07:37 +01:00
QImage overlayImage(1, 1, QImage::Format_ARGB32_Premultiplied);
overlayImage.fill(Qt::transparent);
2017-01-27 01:48:47 +01:00
2017-02-17 12:07:37 +01:00
QPainter overlayPainter(&overlayImage);
2017-01-27 01:48:47 +01:00
QFont overlayPainterFont;
overlayPainterFont.setPixelSize(12);
overlayPainter.setFont(overlayPainterFont);
QRect overlaySpace = overlayPainter.boundingRect(preferedRect, Qt::AlignLeft | Qt::AlignTop | Qt::TextDontClip | Qt::TextWordWrap, overlayText);
overlayPainter.end();
int hOverlay = Qt::AlignTop;
if (overlaySpace.height() < 74)
{
hOverlay = Qt::AlignVCenter;
preferedRect.setHeight(71);
overlaySpace.setHeight(80);
}
else
{
overlaySpace.setHeight(overlaySpace.height() + 6);
}
2017-02-17 12:07:37 +01:00
overlayImage = overlayImage.scaled(overlaySpace.size());
overlayPainter.begin(&overlayImage);
2017-01-27 01:48:47 +01:00
overlayPainter.setPen(QColor::fromRgb(255, 255, 255, 255));
overlayPainter.setFont(overlayPainterFont);
overlayPainter.drawText(preferedRect, Qt::AlignLeft | hOverlay | Qt::TextDontClip | Qt::TextWordWrap, overlayText);
overlayPainter.end();
if (overlaySpace.width() < 194)
{
overlaySpace.setWidth(200);
}
else
{
overlaySpace.setWidth(overlaySpace.width() + 6);
}
2017-02-17 12:07:37 +01:00
QImage overlayBorderImage(overlaySpace.width(), overlaySpace.height(), QImage::Format_ARGB6666_Premultiplied);
2017-01-27 01:48:47 +01:00
overlayBorderImage.fill(QColor(15, 15, 15, 162));
2017-02-17 12:07:37 +01:00
overlayTempImage = QImage(overlaySpace.width(), overlaySpace.height(), QImage::Format_ARGB6666_Premultiplied);
overlayTempImage.fill(Qt::transparent);
QPainter overlayTempPainter(&overlayTempImage);
overlayTempPainter.drawImage(0, 0, overlayBorderImage);
overlayTempPainter.drawImage(3, 3, overlayImage);
2017-01-27 01:48:47 +01:00
overlayTempPainter.end();
}
2017-02-11 04:21:55 +01:00
void PictureDialog::setSnapmaticPicture(SnapmaticPicture *picture, bool readOk, bool _indexed, int _index)
2016-03-21 20:44:07 +01:00
{
2016-04-12 21:53:21 +02:00
snapmaticPicture = QImage();
indexed = _indexed;
index = _index;
2017-02-11 04:21:55 +01:00
picPath = picture->getPictureFilePath();
2016-03-29 12:23:21 +02:00
smpic = picture;
2016-03-21 22:40:03 +01:00
if (!readOk)
{
2016-03-23 02:08:16 +01:00
QMessageBox::warning(this, tr("Snapmatic Picture Viewer"), tr("Failed at %1").arg(picture->getLastStep()));
return;
2016-03-21 22:40:03 +01:00
}
if (picture->isPicOk())
{
2017-02-11 04:21:55 +01:00
snapmaticPicture = picture->getImage();
renderPicture();
2016-03-22 05:20:42 +01:00
ui->cmdExport->setEnabled(true);
2016-03-21 22:40:03 +01:00
}
if (picture->isJsonOk())
2016-03-21 22:14:32 +01:00
{
2016-12-10 04:35:24 +01:00
locX = QString::number(picture->getSnapmaticProperties().location.x);
locY = QString::number(picture->getSnapmaticProperties().location.y);
locZ = QString::number(picture->getSnapmaticProperties().location.z);
2017-02-17 12:07:37 +01:00
if (withDatabase)
{
crewID = crewDB->getCrewName(picture->getSnapmaticProperties().crewID);
}
else
{
crewID = QString::number(picture->getSnapmaticProperties().crewID);
}
2016-12-10 04:35:24 +01:00
created = picture->getSnapmaticProperties().createdDateTime.toString(Qt::DefaultLocaleShortDate);
plyrsList = picture->getSnapmaticProperties().playersList;
picTitl = picture->getPictureTitl();
2017-02-11 04:21:55 +01:00
picArea = picture->getSnapmaticProperties().location.area;
2016-04-23 21:01:00 +02:00
if (globalMap.contains(picArea))
{
picAreaStr = globalMap[picArea];
}
2016-04-23 21:01:41 +02:00
else
{
picAreaStr = picArea;
}
2016-03-21 22:14:32 +01:00
QString plyrsStr;
2016-03-21 22:40:03 +01:00
if (plyrsList.length() >= 1)
{
foreach (const QString &player, plyrsList)
{
2017-02-17 12:07:37 +01:00
QString playerName;
if (withDatabase)
{
playerName = profileDB->getPlayerName(player.toInt());
}
else
{
playerName = player;
}
2016-04-07 17:36:15 +02:00
plyrsStr.append(", <a href=\"https://socialclub.rockstargames.com/member/");
plyrsStr.append(playerName);
plyrsStr.append("/");
plyrsStr.append(player);
plyrsStr.append("\">");
plyrsStr.append(playerName);
plyrsStr.append("</a>");
2016-03-21 22:40:03 +01:00
}
plyrsStr.remove(0,2);
}
else
2016-03-21 22:14:32 +01:00
{
2016-03-21 22:40:03 +01:00
plyrsStr = tr("No player");
2016-03-21 22:14:32 +01:00
}
2016-03-21 22:40:03 +01:00
if (crewID == "") { crewID = tr("No crew"); }
2016-03-21 20:44:07 +01:00
this->setWindowTitle(windowTitleStr.arg(picture->getPictureStr()));
ui->labJSON->setText(jsonDrawString.arg(locX, locY, locZ, plyrsStr, crewID, picTitl, picAreaStr, created));
2016-03-21 22:14:32 +01:00
}
else
2016-03-21 20:44:07 +01:00
{
2016-04-23 20:28:55 +02:00
ui->labJSON->setText(jsonDrawString.arg("0.0", "0.0", "0.0", tr("No player"), tr("No crew"), tr("Unknown Location")));
2016-03-21 22:14:32 +01:00
QMessageBox::warning(this,tr("Snapmatic Picture Viewer"),tr("Failed at %1").arg(picture->getLastStep()));
2016-03-21 20:44:07 +01:00
}
2016-04-12 21:53:21 +02:00
emit newPictureCommited(snapmaticPicture);
2016-03-21 20:44:07 +01:00
}
2016-03-21 21:54:46 +01:00
void PictureDialog::setSnapmaticPicture(SnapmaticPicture *picture, bool readOk, int index)
{
2017-02-11 04:21:55 +01:00
setSnapmaticPicture(picture, readOk, true, index);
}
void PictureDialog::setSnapmaticPicture(SnapmaticPicture *picture, bool readOk)
{
2017-02-11 04:21:55 +01:00
setSnapmaticPicture(picture, readOk, false, 0);
}
void PictureDialog::setSnapmaticPicture(SnapmaticPicture *picture, int index)
{
setSnapmaticPicture(picture, true, index);
}
void PictureDialog::setSnapmaticPicture(SnapmaticPicture *picture)
{
setSnapmaticPicture(picture, true);
}
void PictureDialog::renderPicture()
{
2017-02-17 12:07:37 +01:00
if (!previewMode)
{
2017-02-17 12:07:37 +01:00
if (overlayEnabled)
2017-01-27 01:48:47 +01:00
{
QPixmap overlayAreaPixmap(960, 536);
overlayAreaPixmap.fill(Qt::transparent);
QPainter overlayAreaPainter(&overlayAreaPixmap);
overlayAreaPainter.drawImage(0, 0, snapmaticPicture);
overlayAreaPainter.drawImage(3, 3, overlayTempImage);
overlayAreaPainter.end();
ui->labPicture->setPixmap(overlayAreaPixmap);
}
else
{
ui->labPicture->setPixmap(QPixmap::fromImage(snapmaticPicture));
}
}
else
{
2017-01-27 01:48:47 +01:00
// Generating Avatar Preview
QPixmap avatarPixmap(960, 536);
QPainter snapPainter(&avatarPixmap);
QFont snapPainterFont;
snapPainterFont.setPixelSize(12);
snapPainter.drawImage(0, 0, snapmaticPicture);
snapPainter.drawImage(0, 0, avatarAreaPicture);
snapPainter.setPen(QColor::fromRgb(255, 255, 255, 255));
snapPainter.setFont(snapPainterFont);
snapPainter.drawText(QRect(3, 3, 140, 60), Qt::AlignLeft | Qt::TextWordWrap, tr("Avatar Preview Mode\nPress 1 for Default View"));
snapPainter.end();
ui->labPicture->setPixmap(avatarPixmap);
}
}
void PictureDialog::playerNameUpdated()
2016-03-22 05:59:17 +01:00
{
if (plyrsList.count() >= 1)
{
QString plyrsStr;
foreach (const QString &player, plyrsList)
{
2017-02-17 12:07:37 +01:00
QString playerName;
if (withDatabase)
{
playerName = profileDB->getPlayerName(player.toInt());
}
else
{
playerName = player;
}
2016-04-07 17:36:15 +02:00
plyrsStr.append(", <a href=\"https://socialclub.rockstargames.com/member/");
if (playerName != player)
{
plyrsStr.append(playerName);
}
else
{
plyrsStr.append("id");
}
plyrsStr.append("/");
plyrsStr.append(player);
plyrsStr.append("\">");
plyrsStr.append(playerName);
plyrsStr.append("</a>");
2016-03-22 05:59:17 +01:00
}
plyrsStr.remove(0,2);
ui->labJSON->setText(jsonDrawString.arg(locX, locY, locZ, plyrsStr, crewID, picTitl, picAreaStr, created));
2016-03-22 05:59:17 +01:00
}
}
2016-04-08 16:55:28 +02:00
void PictureDialog::exportSnapmaticPicture()
2016-03-22 05:20:42 +01:00
{
2017-02-17 12:07:37 +01:00
if (rqFullscreen && fullscreenWidget)
{
2017-02-11 04:21:55 +01:00
PictureExport::exportAsPicture(fullscreenWidget, smpic);
}
else
{
2017-02-11 04:21:55 +01:00
PictureExport::exportAsPicture(this, smpic);
}
2016-03-22 05:20:42 +01:00
}
2016-04-08 16:55:28 +02:00
void PictureDialog::copySnapmaticPicture()
{
2017-02-17 12:07:37 +01:00
if (rqFullscreen && fullscreenWidget)
{
2017-02-11 04:21:55 +01:00
PictureExport::exportAsSnapmatic(fullscreenWidget, smpic);
}
else
{
2017-02-11 04:21:55 +01:00
PictureExport::exportAsSnapmatic(this, smpic);
}
}
void PictureDialog::on_labPicture_mouseDoubleClicked(Qt::MouseButton button)
{
if (button == Qt::LeftButton)
{
2016-11-20 10:08:07 +01:00
QRect desktopRect = QApplication::desktop()->screenGeometry(this);
PictureWidget *pictureWidget = new PictureWidget(this);
2016-04-24 13:34:03 +02:00
pictureWidget->setObjectName("PictureWidget");
#if QT_VERSION >= 0x050600
2017-02-11 04:21:55 +01:00
pictureWidget->setWindowFlags(pictureWidget->windowFlags()^Qt::FramelessWindowHint^Qt::WindowStaysOnTopHint^Qt::MaximizeUsingFullscreenGeometryHint);
2016-11-28 08:03:32 +01:00
#else
2017-02-11 04:21:55 +01:00
pictureWidget->setWindowFlags(pictureWidget->windowFlags()^Qt::FramelessWindowHint^Qt::WindowStaysOnTopHint);
2016-11-28 08:03:32 +01:00
#endif
pictureWidget->setWindowTitle(this->windowTitle());
pictureWidget->setStyleSheet("QLabel#pictureLabel{background-color: black;}");
pictureWidget->setImage(snapmaticPicture, desktopRect);
pictureWidget->setModal(true);
fullscreenWidget = pictureWidget;
QObject::connect(this, SIGNAL(newPictureCommited(QImage)), pictureWidget, SLOT(setImage(QImage)));
QObject::connect(pictureWidget, SIGNAL(nextPictureRequested()), this, SLOT(dialogNextPictureRequested()));
QObject::connect(pictureWidget, SIGNAL(previousPictureRequested()), this, SLOT(dialogPreviousPictureRequested()));
pictureWidget->move(desktopRect.x(), desktopRect.y());
pictureWidget->resize(desktopRect.width(), desktopRect.height());
pictureWidget->showFullScreen();
pictureWidget->setFocus();
2016-11-20 10:08:07 +01:00
pictureWidget->raise();
pictureWidget->exec();
fullscreenWidget = 0;
delete pictureWidget;
}
}
void PictureDialog::on_labPicture_customContextMenuRequested(const QPoint &pos)
{
exportCustomContextMenuRequestedPrivate(ui->labPicture->mapToGlobal(pos), false);
}
bool PictureDialog::isIndexed()
{
return indexed;
}
int PictureDialog::getIndex()
{
return index;
}