picture navigation in fullscreen added

This commit is contained in:
Rafael 2016-04-12 21:53:21 +02:00
parent e27fb34908
commit f5be86aec4
5 changed files with 301 additions and 168 deletions

View File

@ -17,6 +17,7 @@
*****************************************************************************/ *****************************************************************************/
#include "PictureDialog.h" #include "PictureDialog.h"
#include "PictureWidget.h"
#include "ProfileDatabase.h" #include "ProfileDatabase.h"
#include "ui_PictureDialog.h" #include "ui_PictureDialog.h"
#include "SidebarGenerator.h" #include "SidebarGenerator.h"
@ -91,13 +92,21 @@ bool PictureDialog::eventFilter(QObject *obj, QEvent *ev)
return false; return false;
} }
void PictureDialog::dialogNextPictureRequested()
{
emit nextPictureRequested();
}
void PictureDialog::dialogPreviousPictureRequested()
{
emit previousPictureRequested();
}
void PictureDialog::setSnapmaticPicture(SnapmaticPicture *picture, QString picturePath, bool readOk, bool _indexed, int _index) void PictureDialog::setSnapmaticPicture(SnapmaticPicture *picture, QString picturePath, bool readOk, bool _indexed, int _index)
{ {
snapmaticPicture = QImage();
indexed = _indexed; indexed = _indexed;
index = _index; index = _index;
// Showing error if reading error
QImage snapmaticPicture;
picPath = picturePath; picPath = picturePath;
smpic = picture; smpic = picture;
if (!readOk) if (!readOk)
@ -105,7 +114,6 @@ void PictureDialog::setSnapmaticPicture(SnapmaticPicture *picture, QString pictu
QMessageBox::warning(this, tr("Snapmatic Picture Viewer"), tr("Failed at %1").arg(picture->getLastStep())); QMessageBox::warning(this, tr("Snapmatic Picture Viewer"), tr("Failed at %1").arg(picture->getLastStep()));
return; return;
} }
if (picture->isPicOk()) if (picture->isPicOk())
{ {
snapmaticPicture = picture->getPicture(); snapmaticPicture = picture->getPicture();
@ -152,6 +160,7 @@ void PictureDialog::setSnapmaticPicture(SnapmaticPicture *picture, QString pictu
ui->labJSON->setText(jsonDrawString.arg("0.0", "0.0", "0.0", tr("No player"), tr("No crew"))); ui->labJSON->setText(jsonDrawString.arg("0.0", "0.0", "0.0", tr("No player"), tr("No crew")));
QMessageBox::warning(this,tr("Snapmatic Picture Viewer"),tr("Failed at %1").arg(picture->getLastStep())); QMessageBox::warning(this,tr("Snapmatic Picture Viewer"),tr("Failed at %1").arg(picture->getLastStep()));
} }
emit newPictureCommited(snapmaticPicture);
} }
void PictureDialog::setSnapmaticPicture(SnapmaticPicture *picture, QString picPath, bool readOk) void PictureDialog::setSnapmaticPicture(SnapmaticPicture *picture, QString picPath, bool readOk)
@ -224,33 +233,21 @@ void PictureDialog::copySnapmaticPicture()
void PictureDialog::on_labPicture_mouseDoubleClicked() void PictureDialog::on_labPicture_mouseDoubleClicked()
{ {
QDialog *pictureWidget = new QDialog(this); QRect desktopRect = QApplication::desktop()->screenGeometry();
QRect rec = QApplication::desktop()->screenGeometry(); PictureWidget *pictureWidget = new PictureWidget(this);
QHBoxLayout *widgetLayout = new QHBoxLayout(pictureWidget);
widgetLayout->setSpacing(0);
widgetLayout->setContentsMargins(0, 0, 0, 0);
UiModLabel *pictureLabel = new UiModLabel(pictureWidget);
pictureLabel->setPixmap(ui->labPicture->pixmap()->scaled(rec.width(), rec.height(), Qt::KeepAspectRatio, Qt::SmoothTransformation));
pictureLabel->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
pictureLabel->setAlignment(Qt::AlignCenter);
widgetLayout->addWidget(pictureLabel);
QObject::connect(pictureLabel, SIGNAL(mouseDoubleClicked()), pictureWidget, SLOT(close()));
pictureWidget->setLayout(widgetLayout);
pictureWidget->setWindowFlags(pictureWidget->windowFlags()^Qt::WindowContextHelpButtonHint); pictureWidget->setWindowFlags(pictureWidget->windowFlags()^Qt::WindowContextHelpButtonHint);
pictureWidget->setWindowTitle(this->windowTitle()); pictureWidget->setWindowTitle(this->windowTitle());
pictureWidget->setStyleSheet("background-color: black;"); pictureWidget->setStyleSheet("background-color: black;");
pictureWidget->setImage(snapmaticPicture, desktopRect);
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->showFullScreen(); pictureWidget->showFullScreen();
pictureWidget->setModal(true); pictureWidget->setModal(true);
pictureWidget->exec(); pictureWidget->exec();
widgetLayout->deleteLater();
delete widgetLayout;
pictureLabel->deleteLater();
delete pictureLabel;
pictureWidget->deleteLater();
delete pictureWidget; delete pictureWidget;
} }

View File

@ -46,6 +46,8 @@ public:
public slots: public slots:
void playerNameUpdated(); void playerNameUpdated();
void dialogNextPictureRequested();
void dialogPreviousPictureRequested();
private slots: private slots:
void copySnapmaticPicture(); void copySnapmaticPicture();
@ -55,6 +57,7 @@ private slots:
signals: signals:
void nextPictureRequested(); void nextPictureRequested();
void previousPictureRequested(); void previousPictureRequested();
void newPictureCommited(QImage picture);
protected: protected:
bool eventFilter(QObject *obj, QEvent *ev); bool eventFilter(QObject *obj, QEvent *ev);
@ -63,6 +66,7 @@ private:
ProfileDatabase *profileDB; ProfileDatabase *profileDB;
Ui::PictureDialog *ui; Ui::PictureDialog *ui;
SnapmaticPicture *smpic; SnapmaticPicture *smpic;
QImage snapmaticPicture;
QString jsonDrawString; QString jsonDrawString;
QString windowTitleStr; QString windowTitleStr;
QStringList plyrsList; QStringList plyrsList;

79
PictureWidget.cpp Normal file
View File

@ -0,0 +1,79 @@
/*****************************************************************************
* gta5sync GRAND THEFT AUTO V SYNC
* Copyright (C) 2016 Syping
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*****************************************************************************/
#include "PictureWidget.h"
#include "UiModLabel.h"
#include <QHBoxLayout>
#include <QKeyEvent>
#include <QPixmap>
#include <QEvent>
PictureWidget::PictureWidget(QWidget *parent) : QDialog(parent)
{
installEventFilter(this);
widgetLayout = new QHBoxLayout(this);
widgetLayout->setSpacing(0);
widgetLayout->setContentsMargins(0, 0, 0, 0);
pictureLabel = new UiModLabel(this);
pictureLabel->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
pictureLabel->setAlignment(Qt::AlignCenter);
widgetLayout->addWidget(pictureLabel);
QObject::connect(pictureLabel, SIGNAL(mouseDoubleClicked()), this, SLOT(close()));
setLayout(widgetLayout);
}
PictureWidget::~PictureWidget()
{
widgetLayout->removeWidget(pictureLabel);
delete pictureLabel;
delete widgetLayout;
}
bool PictureWidget::eventFilter(QObject *obj, QEvent *ev)
{
if (obj == this)
{
if (ev->type() == QEvent::KeyPress)
{
QKeyEvent *keyEvent = (QKeyEvent*)ev;
switch (keyEvent->key()){
case Qt::Key_Left:
emit previousPictureRequested();
break;
case Qt::Key_Right:
emit nextPictureRequested();
break;
}
}
}
return false;
}
void PictureWidget::setImage(QImage image, QRect rec)
{
pictureLabel->setPixmap(QPixmap::fromImage(image.scaled(rec.width(), rec.height(), Qt::KeepAspectRatio, Qt::SmoothTransformation)));
}
void PictureWidget::setImage(QImage image)
{
pictureLabel->setPixmap(QPixmap::fromImage(image.scaled(geometry().width(), geometry().height(), Qt::KeepAspectRatio, Qt::SmoothTransformation)));
}

51
PictureWidget.h Normal file
View File

@ -0,0 +1,51 @@
/*****************************************************************************
* gta5sync GRAND THEFT AUTO V SYNC
* Copyright (C) 2016 Syping
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*****************************************************************************/
#ifndef PICTUREWIDGET_H
#define PICTUREWIDGET_H
#include "UiModLabel.h"
#include <QHBoxLayout>
#include <QDialog>
#include <QWidget>
#include <QEvent>
class PictureWidget : public QDialog
{
Q_OBJECT
public:
explicit PictureWidget(QWidget *parent = 0);
void setImage(QImage image, QRect rec);
~PictureWidget();
public slots:
void setImage(QImage image);
protected:
bool eventFilter(QObject *obj, QEvent *ev);
private:
QHBoxLayout *widgetLayout;
UiModLabel *pictureLabel;
signals:
void nextPictureRequested();
void previousPictureRequested();
};
#endif // PICTUREWIDGET_H

View File

@ -1,144 +1,146 @@
#/***************************************************************************** #/*****************************************************************************
#* gta5sync GRAND THEFT AUTO V SYNC #* gta5sync GRAND THEFT AUTO V SYNC
#* Copyright (C) 2015-2016 Syping #* Copyright (C) 2015-2016 Syping
#* #*
#* This program is free software: you can redistribute it and/or modify #* 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 #* it under the terms of the GNU General Public License as published by
#* the Free Software Foundation, either version 3 of the License, or #* the Free Software Foundation, either version 3 of the License, or
#* (at your option) any later version. #* (at your option) any later version.
#* #*
#* This program is distributed in the hope that it will be useful, #* This program is distributed in the hope that it will be useful,
#* but WITHOUT ANY WARRANTY; without even the implied warranty of #* but WITHOUT ANY WARRANTY; without even the implied warranty of
#* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the #* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
#* GNU General Public License for more details. #* GNU General Public License for more details.
#* #*
#* You should have received a copy of the GNU General Public License #* You should have received a copy of the GNU General Public License
#* along with this program. If not, see <http://www.gnu.org/licenses/>. #* along with this program. If not, see <http://www.gnu.org/licenses/>.
#*****************************************************************************/ #*****************************************************************************/
QT += core gui network QT += core gui network
greaterThan(QT_MAJOR_VERSION, 4): QT += widgets greaterThan(QT_MAJOR_VERSION, 4): QT += widgets
TARGET = gta5sync TARGET = gta5sync
TEMPLATE = app TEMPLATE = app
SOURCES += main.cpp \ SOURCES += main.cpp \
AboutDialog.cpp \ AboutDialog.cpp \
AppEnv.cpp \ AppEnv.cpp \
CrewDatabase.cpp \ CrewDatabase.cpp \
DatabaseThread.cpp \ DatabaseThread.cpp \
ExportThread.cpp \ ExportThread.cpp \
IconLoader.cpp \ IconLoader.cpp \
OptionsDialog.cpp \ OptionsDialog.cpp \
PictureCopy.cpp \ PictureCopy.cpp \
PictureDialog.cpp \ PictureDialog.cpp \
PictureExport.cpp \ PictureExport.cpp \
ProfileDatabase.cpp \ PictureWidget.cpp \
ProfileInterface.cpp \ ProfileDatabase.cpp \
ProfileLoader.cpp \ ProfileInterface.cpp \
ProfileWidget.cpp \ ProfileLoader.cpp \
SavegameCopy.cpp \ ProfileWidget.cpp \
SavegameData.cpp \ SavegameCopy.cpp \
SavegameDialog.cpp \ SavegameData.cpp \
SavegameWidget.cpp \ SavegameDialog.cpp \
SidebarGenerator.cpp \ SavegameWidget.cpp \
SnapmaticPicture.cpp \ SidebarGenerator.cpp \
SnapmaticWidget.cpp \ SnapmaticPicture.cpp \
StandardPaths.cpp \ SnapmaticWidget.cpp \
StringParser.cpp \ StandardPaths.cpp \
UserInterface.cpp \ StringParser.cpp \
uimod/UiModLabel.cpp UserInterface.cpp \
uimod/UiModLabel.cpp
HEADERS += \
AboutDialog.h \ HEADERS += \
AppEnv.h \ AboutDialog.h \
CrewDatabase.h \ AppEnv.h \
DatabaseThread.h \ CrewDatabase.h \
ExportThread.h \ DatabaseThread.h \
IconLoader.h \ ExportThread.h \
OptionsDialog.h \ IconLoader.h \
PictureCopy.h \ OptionsDialog.h \
PictureDialog.h \ PictureCopy.h \
PictureExport.h \ PictureDialog.h \
ProfileDatabase.h \ PictureExport.h \
ProfileInterface.h \ PictureWidget.h \
ProfileLoader.h \ ProfileDatabase.h \
ProfileWidget.h \ ProfileInterface.h \
SavegameCopy.h \ ProfileLoader.h \
SavegameData.h \ ProfileWidget.h \
SavegameDialog.h \ SavegameCopy.h \
SavegameWidget.h \ SavegameData.h \
SidebarGenerator.h \ SavegameDialog.h \
SnapmaticPicture.h \ SavegameWidget.h \
SnapmaticWidget.h \ SidebarGenerator.h \
StandardPaths.h \ SnapmaticPicture.h \
StringParser.h \ SnapmaticWidget.h \
UserInterface.h \ StandardPaths.h \
uimod/UiModLabel.h StringParser.h \
UserInterface.h \
FORMS += \ uimod/UiModLabel.h
AboutDialog.ui \
OptionsDialog.ui \ FORMS += \
PictureDialog.ui \ AboutDialog.ui \
ProfileInterface.ui \ OptionsDialog.ui \
SavegameDialog.ui \ PictureDialog.ui \
SavegameWidget.ui \ ProfileInterface.ui \
SnapmaticWidget.ui \ SavegameDialog.ui \
UserInterface.ui SavegameWidget.ui \
SnapmaticWidget.ui \
TRANSLATIONS += \ UserInterface.ui
res/gta5sync_de.ts \
lang/gta5sync_ru.ts TRANSLATIONS += \
res/gta5sync_de.ts \
RESOURCES += \ lang/gta5sync_ru.ts
res/app.qrc
RESOURCES += \
DISTFILES += res/app.rc \ res/app.qrc
res/gta5sync.desktop \
res/gta5sync_de.ts \ DISTFILES += res/app.rc \
lang/gta5sync_ru.qm \ res/gta5sync.desktop \
lang/qtbase_ru.qm \ res/gta5sync_de.ts \
lang/README.txt \ lang/gta5sync_ru.qm \
lang/gta5sync_ru.ts \ lang/qtbase_ru.qm \
lang/qt_ru.qm lang/README.txt \
lang/gta5sync_ru.ts \
INCLUDEPATH += ./uimod lang/qt_ru.qm
# WINDOWS ONLY INCLUDEPATH += ./uimod
win32: DEFINES += GTA5SYNC_WIN # WINDOWS ONLY
win32: RC_FILE += res/app.rc
win32: LIBS += -luser32 win32: DEFINES += GTA5SYNC_WIN
win32: RC_FILE += res/app.rc
# QT4 ONLY STUFF win32: LIBS += -luser32
isEqual(QT_MAJOR_VERSION, 4): INCLUDEPATH += ./qjson4 # QT4 ONLY STUFF
isEqual(QT_MAJOR_VERSION, 4): HEADERS += qjson4/QJsonArray.h \
qjson4/QJsonDocument.h \ isEqual(QT_MAJOR_VERSION, 4): INCLUDEPATH += ./qjson4
qjson4/QJsonObject.h \ isEqual(QT_MAJOR_VERSION, 4): HEADERS += qjson4/QJsonArray.h \
qjson4/QJsonParseError.h \ qjson4/QJsonDocument.h \
qjson4/QJsonValue.h \ qjson4/QJsonObject.h \
qjson4/QJsonValueRef.h \ qjson4/QJsonParseError.h \
qjson4/QJsonParser.h \ qjson4/QJsonValue.h \
qjson4/QJsonRoot.h qjson4/QJsonValueRef.h \
qjson4/QJsonParser.h \
isEqual(QT_MAJOR_VERSION, 4): SOURCES += qjson4/QJsonArray.cpp \ qjson4/QJsonRoot.h
qjson4/QJsonDocument.cpp \
qjson4/QJsonObject.cpp \ isEqual(QT_MAJOR_VERSION, 4): SOURCES += qjson4/QJsonArray.cpp \
qjson4/QJsonParseError.cpp \ qjson4/QJsonDocument.cpp \
qjson4/QJsonValue.cpp \ qjson4/QJsonObject.cpp \
qjson4/QJsonValueRef.cpp \ qjson4/QJsonParseError.cpp \
qjson4/QJsonParser.cpp qjson4/QJsonValue.cpp \
qjson4/QJsonValueRef.cpp \
# UNIX SYSTEM STUFF qjson4/QJsonParser.cpp
unix: !macx: appfiles.path = $$(INSTALL_PATH)/share/applications # UNIX SYSTEM STUFF
unix: !macx: appfiles.files = $$PWD/res/gta5sync.desktop
unix: !macx: pixmaps.path = $$(INSTALL_PATH)/share/pixmaps unix: !macx: appfiles.path = $$(INSTALL_PATH)/share/applications
unix: !macx: pixmaps.files = $$PWD/res/gta5sync.xpm unix: !macx: appfiles.files = $$PWD/res/gta5sync.desktop
unix: !macx: target.path = $$(INSTALL_PATH)/bin unix: !macx: pixmaps.path = $$(INSTALL_PATH)/share/pixmaps
unix: !macx: INSTALLS += target pixmaps appfiles unix: !macx: pixmaps.files = $$PWD/res/gta5sync.xpm
unix: !macx: target.path = $$(INSTALL_PATH)/bin
# STATIC BUILD STUFF unix: !macx: INSTALLS += target pixmaps appfiles
static: isEqual(QT_MAJOR_VERSION, 4): QTPLUGIN += qjpcodecs
# STATIC BUILD STUFF
static: isEqual(QT_MAJOR_VERSION, 4): QTPLUGIN += qjpcodecs