added Snapmatic Players Editor

This commit is contained in:
Syping 2017-12-12 04:45:46 +01:00
parent eeb0c01a5f
commit 6938ca577d
26 changed files with 1104 additions and 194 deletions

View File

@ -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-dev5\\\\\\\"" 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-dev6\\\\\\\"" DEFINES+=GTA5SYNC_QCONF ../../gta5view.pro
- make -j 4
- sudo checkinstall -D --default --nodoc --install=no --pkgname=gta5view-qt5 --pkgversion=$PACKAGE_VERSION --pkgrelease=dev5 --pkggroup=utility --maintainer="Syping on Travis \<travisci@syping.de\>" --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=dev6 --pkggroup=utility --maintainer="Syping on Travis \<travisci@syping.de\>" --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-dev5\\\\\\\"" 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-dev6\\\\\\\"" DEFINES+=GTA5SYNC_QCONF ../../gta5view.pro
- make -j 4
- sudo checkinstall -D --default --nodoc --install=no --pkgname=gta5view-qt4 --pkgversion=$PACKAGE_VERSION --pkgrelease=dev5 --pkggroup=utility --maintainer="Syping on Travis \<travisci@syping.de\>" --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=dev6 --pkggroup=utility --maintainer="Syping on Travis \<travisci@syping.de\>" --requires=libqtcore4,libqtgui4,libqt4-network,qtcore4-l10n --conflicts=gta5view,gta5view-qt5 --replaces=gta5view,gta5view-qt5 --pakdir=../../package
- cd ..
deploy:

View File

@ -28,6 +28,10 @@ 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();

View File

@ -38,6 +38,13 @@ ImportDialog::ImportDialog(QWidget *parent) :
QDialog(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
ui->setupUi(this);
importAgreed = false;
insideAvatarZone = false;
@ -56,14 +63,26 @@ ImportDialog::ImportDialog(QWidget *parent) :
ui->cbIgnore->setChecked(false);
ui->labColour->setText(tr("Background Colour: <span style=\"color: %1\">%1</span>").arg(selectedColour.name()));
// DPI calculation
qreal screenRatio = AppEnv::screenRatio();
snapmaticResolutionLW = 430 * screenRatio;
snapmaticResolutionLH = 240 * screenRatio;
ui->vlButtom->setSpacing(6 * screenRatio);
#ifndef Q_OS_MAC
ui->vlButtom->setContentsMargins(9 * screenRatio, 6 * screenRatio, 9 * screenRatio, 9 * screenRatio);
#else
if (QApplication::style()->objectName() == "macintosh")
{
ui->vlButtom->setContentsMargins(9 * screenRatio, 9 * screenRatio, 9 * screenRatio, 9 * screenRatio);
}
else
{
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);
ui->vlButtom->setSpacing(6 * screenRatio);
ui->vlButtom->setContentsMargins(9 * screenRatio, 6 * screenRatio, 9 * screenRatio, 9 * screenRatio);
}
ImportDialog::~ImportDialog()

View File

@ -89,7 +89,7 @@
<property name="title">
<string>Settings</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<layout class="QVBoxLayout" name="vlSettings">
<item>
<layout class="QHBoxLayout" name="hlColor">
<item>

View File

@ -35,8 +35,13 @@ 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);
if (QIcon::hasThemeIcon("dialog-close"))
{
ui->cmdClose->setIcon(QIcon::fromTheme("dialog-close"));
@ -46,8 +51,8 @@ JsonEditorDialog::JsonEditorDialog(SnapmaticPicture *picture, QWidget *parent) :
#if QT_VERSION >= 0x050200
ui->txtJSON->setFont(QFontDatabase::systemFont(QFontDatabase::FixedFont));
#endif
QFontMetrics fm(ui->txtJSON->font());
ui->txtJSON->setTabStopWidth(fm.width(" "));
QFontMetrics fontMetrics(ui->txtJSON->font());
ui->txtJSON->setTabStopWidth(fontMetrics.width(" "));
QJsonDocument jsonDocument = QJsonDocument::fromJson(jsonCode.toUtf8());
ui->txtJSON->setStyleSheet("QPlainTextEdit{background-color: rgb(46, 47, 48); color: rgb(238, 231, 172);}");
@ -56,7 +61,15 @@ JsonEditorDialog::JsonEditorDialog(SnapmaticPicture *picture, QWidget *parent) :
// DPI calculation
qreal screenRatio = AppEnv::screenRatio();
#ifndef Q_OS_MAC
ui->hlButtons->setSpacing(6 * screenRatio);
ui->hlButtons->setContentsMargins(9 * screenRatio, 0, 9 * screenRatio, 0);
ui->vlInterface->setContentsMargins(0, 0, 0, 9 * screenRatio);
#else
ui->hlButtons->setSpacing(6 * screenRatio);
ui->hlButtons->setContentsMargins(9 * screenRatio, 0, 9 * screenRatio, 0);
ui->vlInterface->setContentsMargins(0, 0, 0, 9 * screenRatio);
#endif
if (screenRatio > 1)
{
ui->lineJSON->setMinimumHeight(qRound(1 * screenRatio));
@ -127,7 +140,25 @@ bool JsonEditorDialog::saveJsonContent()
smpic->setJsonStr(newCode, true);
if (!smpic->isJsonOk())
{
QMessageBox::warning(this, SnapmaticEditor::tr("Snapmatic Properties"), SnapmaticEditor::tr("Patching of Snapmatic Properties failed because of JSON Error"));
QString lastStep = smpic->getLastStep(false);
QString readableError;
if (lastStep.contains("JSONINCOMPLETE") && lastStep.contains("JSONERROR"))
{
readableError = SnapmaticPicture::tr("JSON is incomplete and malformed");
}
else if (lastStep.contains("JSONINCOMPLETE"))
{
readableError = SnapmaticPicture::tr("JSON is incomplete");
}
else if (lastStep.contains("JSONERROR"))
{
readableError = SnapmaticPicture::tr("JSON is malformed");
}
else
{
readableError = tr("JSON Error");
}
QMessageBox::warning(this, SnapmaticEditor::tr("Snapmatic Properties"), SnapmaticEditor::tr("Patching of Snapmatic Properties failed because of %1").arg(readableError));
smpic->setJsonStr(originalCode, true);
return false;
}

View File

@ -23,6 +23,9 @@
<property name="rightMargin">
<number>0</number>
</property>
<property name="bottomMargin">
<number>9</number>
</property>
<item>
<layout class="QVBoxLayout" name="vlJSON">
<property name="spacing">

View File

@ -29,6 +29,11 @@ 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);
ui->cmdApply->setVisible(false);

View File

@ -42,13 +42,17 @@ 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);
ui->tabWidget->setCurrentIndex(0);
ui->labPicCustomRes->setVisible(false);
QRect desktopResolution = qApp->desktop()->screenGeometry(parent);
QRect desktopResolution = QApplication::desktop()->screenGeometry(this);
int desktopSizeWidth = desktopResolution.width();
int desktopSizeHeight = desktopResolution.height();
aspectRatio = Qt::KeepAspectRatio;
@ -256,7 +260,7 @@ void OptionsDialog::setupInterfaceSettings()
ui->gbFont->setVisible(false);
ui->cbAlwaysUseMessageFont->setVisible(false);
#endif
QString currentStyle = qApp->style()->objectName();
QString currentStyle = QApplication::style()->objectName();
QString appStyle = settings->value("AppStyle", currentStyle).toString();
bool customStyle = settings->value("CustomStyle", false).toBool();
const QStringList availableStyles = QStyleFactory::keys();
@ -374,7 +378,7 @@ void OptionsDialog::applySettings()
QString newStyle = ui->cbStyleList->currentText();
settings->setValue("CustomStyle", true);
settings->setValue("AppStyle", newStyle);
qApp->setStyle(QStyleFactory::create(newStyle));
QApplication::setStyle(QStyleFactory::create(newStyle));
}
else
{

View File

@ -42,6 +42,8 @@
#include <QDesktopWidget>
#include <QJsonDocument>
#include <QApplication>
#include <QFontMetrics>
#include <QSizePolicy>
#include <QStaticText>
#include <QFileDialog>
#include <QMessageBox>
@ -79,35 +81,24 @@ PictureDialog::PictureDialog(ProfileDatabase *profileDB, CrewDatabase *crewDB, Q
ui(new Ui::PictureDialog)
{
primaryWindow = false;
setupPictureDialog(true);
}
PictureDialog::PictureDialog(QWidget *parent) :
QDialog(parent),
ui(new Ui::PictureDialog)
{
primaryWindow = false;
setupPictureDialog(false);
setupPictureDialog();
}
PictureDialog::PictureDialog(bool primaryWindow, ProfileDatabase *profileDB, CrewDatabase *crewDB, QWidget *parent) :
QDialog(parent), primaryWindow(primaryWindow), profileDB(profileDB), crewDB(crewDB),
ui(new Ui::PictureDialog)
{
setupPictureDialog(true);
setupPictureDialog();
}
PictureDialog::PictureDialog(bool primaryWindow, QWidget *parent) :
QDialog(parent), primaryWindow(primaryWindow),
ui(new Ui::PictureDialog)
{
setupPictureDialog(false);
}
void PictureDialog::setupPictureDialog(bool withDatabase_)
void PictureDialog::setupPictureDialog()
{
// Set Window Flags
setWindowFlags(windowFlags()^Qt::WindowContextHelpButtonHint);
setWindowFlags(windowFlags()^Qt::WindowContextHelpButtonHint^Qt::CustomizeWindowHint);
#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);
@ -122,9 +113,6 @@ void PictureDialog::setupPictureDialog(bool withDatabase_)
smpic = nullptr;
crewStr = "";
// With datebase
withDatabase = withDatabase_;
// Avatar area
qreal screenRatio = AppEnv::screenRatio();
if (screenRatio != 1)
@ -145,14 +133,14 @@ void PictureDialog::setupPictureDialog(bool withDatabase_)
// Manage menu
manageMenu = new QMenu(this);
jpegExportAction = manageMenu->addAction(tr("Export as &Picture..."), this, SLOT(exportSnapmaticPicture()));
pgtaExportAction = manageMenu->addAction(tr("Export as &Snapmatic..."), this, SLOT(copySnapmaticPicture()));
manageMenuSep1 = manageMenu->addSeparator();
propEditorAction = manageMenu->addAction(tr("&Edit Properties..."), this, SLOT(editSnapmaticProperties()));
manageMenuSep2 = manageMenu->addSeparator();
openViewerAction = manageMenu->addAction(tr("Open &Map Viewer..."), this, SLOT(openPreviewMap()));
manageMenu->addAction(tr("Export as &Picture..."), this, SLOT(exportSnapmaticPicture()));
manageMenu->addAction(tr("Export as &Snapmatic..."), this, SLOT(copySnapmaticPicture()));
manageMenu->addSeparator();
manageMenu->addAction(tr("&Edit Properties..."), this, SLOT(editSnapmaticProperties()));
manageMenu->addSeparator();
QAction *openViewerAction = manageMenu->addAction(tr("Open &Map Viewer..."), this, SLOT(openPreviewMap()));
openViewerAction->setShortcut(Qt::Key_M);
jsonEditorAction = manageMenu->addAction(tr("Open &JSON Editor..."), this, SLOT(editSnapmaticRawJson()));
manageMenu->addAction(tr("Open &JSON Editor..."), this, SLOT(editSnapmaticRawJson()));
ui->cmdManage->setMenu(manageMenu);
// Global map
@ -179,13 +167,22 @@ void PictureDialog::setupPictureDialog(bool withDatabase_)
PictureDialog::~PictureDialog()
{
delete propEditorAction;
delete openViewerAction;
delete jsonEditorAction;
delete jpegExportAction;
delete pgtaExportAction;
delete manageMenuSep1;
delete manageMenuSep2;
#ifdef GTA5SYNC_WIN
#if QT_VERSION >= 0x050200
if (naviEnabled)
{
for (QObject *obj : layout()->menuBar()->children())
{
delete obj;
}
delete layout()->menuBar();
}
#endif
#endif
for (QObject *obj : manageMenu->children())
{
delete obj;
}
delete manageMenu;
delete ui;
}
@ -193,7 +190,7 @@ PictureDialog::~PictureDialog()
void PictureDialog::closeEvent(QCloseEvent *ev)
{
Q_UNUSED(ev)
if (primaryWindow && withDatabase)
if (primaryWindow)
{
emit endDatabaseThread();
}
@ -204,25 +201,140 @@ void PictureDialog::addPreviousNextButtons()
// Windows Vista additions
#ifdef GTA5SYNC_WIN
#if QT_VERSION >= 0x050200
QPalette palette;
QToolBar *uiToolbar = new QToolBar("Picture Toolbar", this);
layout()->setMenuBar(uiToolbar);
uiToolbar->setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Minimum);
uiToolbar->setObjectName("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()));
layout()->setMenuBar(uiToolbar);
naviEnabled = true;
#endif
#endif
}
#ifdef GTA5SYNC_WIN
#if QT_VERSION >= 0x050200
#ifdef GTA5SYNC_APV
bool PictureDialog::nativeEvent(const QByteArray &eventType, void *message, long *result)
{
*result = 0;
MSG *msg = static_cast<MSG*>(message);
LRESULT lRet = 0;
if (naviEnabled && QtWin::isCompositionEnabled())
{
if (msg->message == WM_NCCALCSIZE && msg->wParam == TRUE)
{
NCCALCSIZE_PARAMS *pncsp = reinterpret_cast<NCCALCSIZE_PARAMS*>(msg->lParam);
int sideBorderSize = ((frameSize().width() - size().width()) / 2);
#ifdef GTA5SYNC_APV_SIDE
int buttomBorderSize = sideBorderSize;
#else
int buttomBorderSize = (frameSize().height() - size().height());
#endif
pncsp->rgrc[0].left += sideBorderSize;
pncsp->rgrc[0].right -= sideBorderSize;
pncsp->rgrc[0].bottom -= buttomBorderSize;
}
else if (msg->message == WM_NCHITTEST)
{
int CLOSE_BUTTON_ID = 20;
lRet = HitTestNCA(msg->hwnd, msg->lParam);
DwmDefWindowProc(msg->hwnd, msg->message, msg->wParam, msg->lParam, &lRet);
*result = lRet;
if (lRet != CLOSE_BUTTON_ID) { return QWidget::nativeEvent(eventType, message, result); }
}
else
{
return QWidget::nativeEvent(eventType, message, result);
}
}
else
{
return QWidget::nativeEvent(eventType, message, result);
}
return true;
}
LRESULT PictureDialog::HitTestNCA(HWND hWnd, LPARAM lParam)
{
int LEFTEXTENDWIDTH = 0;
int RIGHTEXTENDWIDTH = 0;
int BOTTOMEXTENDWIDTH = 0;
int TOPEXTENDWIDTH = layout()->menuBar()->height();
POINT ptMouse = {(int)(short)LOWORD(lParam), (int)(short)HIWORD(lParam)};
RECT rcWindow;
GetWindowRect(hWnd, &rcWindow);
RECT rcFrame = {};
AdjustWindowRectEx(&rcFrame, WS_OVERLAPPEDWINDOW & ~WS_CAPTION, FALSE, NULL);
USHORT uRow = 1;
USHORT uCol = 1;
bool fOnResizeBorder = false;
if (ptMouse.y >= rcWindow.top && ptMouse.y < rcWindow.top + TOPEXTENDWIDTH)
{
fOnResizeBorder = (ptMouse.y < (rcWindow.top - rcFrame.top));
uRow = 0;
}
else if (ptMouse.y < rcWindow.bottom && ptMouse.y >= rcWindow.bottom - BOTTOMEXTENDWIDTH)
{
uRow = 2;
}
if (ptMouse.x >= rcWindow.left && ptMouse.x < rcWindow.left + LEFTEXTENDWIDTH)
{
uCol = 0;
}
else if (ptMouse.x < rcWindow.right && ptMouse.x >= rcWindow.right - RIGHTEXTENDWIDTH)
{
uCol = 2;
}
LRESULT hitTests[3][3] =
{
{ HTTOPLEFT, fOnResizeBorder ? HTTOP : HTCAPTION, HTTOPRIGHT },
{ HTLEFT, HTNOWHERE, HTRIGHT },
{ HTBOTTOMLEFT, HTBOTTOM, HTBOTTOMRIGHT },
};
return hitTests[uRow][uCol];
}
void PictureDialog::resizeEvent(QResizeEvent *event)
{
Q_UNUSED(event)
// int newDialogHeight = ui->labPicture->pixmap()->height();
// newDialogHeight = newDialogHeight + ui->jsonFrame->height();
// if (naviEnabled) newDialogHeight = newDialogHeight + layout()->menuBar()->height();
// int buttomBorderSize = (frameSize().height() - size().height());
// int sideBorderSize = ((frameSize().width() - size().width()) / 2);
// int brokenDialogHeight = newDialogHeight + (buttomBorderSize - sideBorderSize);
// if (event->size().height() == brokenDialogHeight)
// {
// qDebug() << "BROKEN 1";
// setGeometry(geometry().x(), geometry().y(), width(), newDialogHeight);
// qDebug() << "BROKEN 2";
// event->ignore();
// }
}
#endif
#endif
#endif
void PictureDialog::adaptNewDialogSize(QSize newLabelSize)
{
Q_UNUSED(newLabelSize)
int newDialogHeight = ui->labPicture->pixmap()->height();
newDialogHeight = newDialogHeight + ui->jsonFrame->height();
if (naviEnabled) newDialogHeight = newDialogHeight + layout()->menuBar()->height();
setMinimumSize(width(), newDialogHeight);
setMaximumSize(width(), newDialogHeight);
setMinimumSize(width(), newDialogHeight);
setFixedHeight(newDialogHeight);
ui->labPicture->updateGeometry();
ui->jsonFrame->updateGeometry();
@ -235,15 +347,16 @@ void PictureDialog::stylizeDialog()
#if QT_VERSION >= 0x050200
if (QtWin::isCompositionEnabled())
{
QPalette palette;
QtWin::extendFrameIntoClientArea(this, 0, this->layout()->menuBar()->height(), 0, 0);
setAttribute(Qt::WA_TranslucentBackground, true);
setAttribute(Qt::WA_NoSystemBackground, false);
ui->jsonFrame->setStyleSheet(QString("QFrame { background: %1; }").arg(palette.window().color().name()));
setStyleSheet("PictureDialog { background: transparent; }");
}
else
{
QPalette palette;
QtWin::resetExtendedFrame(this);
setAttribute(Qt::WA_TranslucentBackground, false);
ui->jsonFrame->setStyleSheet(QString("QFrame { background: %1; }").arg(palette.window().color().name()));
setStyleSheet(QString("PictureDialog { background: %1; }").arg(QtWin::realColorizationColor().name()));
}
#endif
@ -283,7 +396,7 @@ bool PictureDialog::eventFilter(QObject *obj, QEvent *ev)
{
if (ev->type() == QEvent::KeyPress)
{
QKeyEvent *keyEvent = (QKeyEvent*)ev;
QKeyEvent *keyEvent = dynamic_cast<QKeyEvent*>(ev);
switch (keyEvent->key()){
case Qt::Key_Left:
emit previousPictureRequested();
@ -337,6 +450,49 @@ bool PictureDialog::eventFilter(QObject *obj, QEvent *ev)
break;
}
}
#ifdef GTA5SYNC_WIN
#if QT_VERSION >= 0x050200
if (obj != ui->labPicture && naviEnabled)
{
if (ev->type() == QEvent::MouseButtonPress)
{
QMouseEvent *mouseEvent = dynamic_cast<QMouseEvent*>(ev);
if (mouseEvent->pos().y() <= layout()->menuBar()->height())
{
if (mouseEvent->button() == Qt::LeftButton)
{
dragPosition = mouseEvent->pos();
dragStart = true;
}
}
}
if (ev->type() == QEvent::MouseButtonRelease)
{
QMouseEvent *mouseEvent = dynamic_cast<QMouseEvent*>(ev);
if (mouseEvent->pos().y() <= layout()->menuBar()->height())
{
if (mouseEvent->button() == Qt::LeftButton)
{
dragStart = false;
}
}
}
if (ev->type() == QEvent::MouseMove && dragStart)
{
QMouseEvent *mouseEvent = dynamic_cast<QMouseEvent*>(ev);
if (mouseEvent->pos().y() <= layout()->menuBar()->height())
{
if (mouseEvent->buttons() & Qt::LeftButton)
{
QPoint diff = mouseEvent->pos() - dragPosition;
move(QPoint(pos() + diff));
updateGeometry();
}
}
}
}
#endif
#endif
}
return returnValue;
}
@ -378,15 +534,11 @@ void PictureDialog::renderOverlayPicture()
qreal screenRatio = AppEnv::screenRatio();
QRect preferedRect = QRect(0, 0, 200 * screenRatio, 160 * screenRatio);
QString overlayText = tr("Key 1 - Avatar Preview Mode\nKey 2 - Toggle Overlay\nArrow Keys - Navigate");
QImage overlayImage(1, 1, QImage::Format_ARGB32_Premultiplied);
overlayImage.fill(Qt::transparent);
QPainter overlayPainter(&overlayImage);
QFont overlayPainterFont;
overlayPainterFont.setPixelSize(12 * screenRatio);
overlayPainter.setFont(overlayPainterFont);
QRect overlaySpace = overlayPainter.boundingRect(preferedRect, Qt::AlignLeft | Qt::AlignTop | Qt::TextDontClip | Qt::TextWordWrap, overlayText);
overlayPainter.end();
QFontMetrics fontMetrics(overlayPainterFont);
QRect overlaySpace = fontMetrics.boundingRect(preferedRect, Qt::AlignLeft | Qt::AlignTop | Qt::TextDontClip | Qt::TextWordWrap, overlayText);
int hOverlay = Qt::AlignTop;
if (overlaySpace.height() < 74 * screenRatio)
@ -400,8 +552,10 @@ void PictureDialog::renderOverlayPicture()
overlaySpace.setHeight(overlaySpace.height() + 6 * screenRatio);
}
overlayImage = overlayImage.scaled(overlaySpace.size());
overlayPainter.begin(&overlayImage);
QImage overlayImage(overlaySpace.size(), QImage::Format_ARGB32_Premultiplied);
overlayImage.fill(Qt::transparent);
QPainter overlayPainter(&overlayImage);
overlayPainter.setPen(QColor::fromRgb(255, 255, 255, 255));
overlayPainter.setFont(overlayPainterFont);
overlayPainter.drawText(preferedRect, Qt::AlignLeft | hOverlay | Qt::TextDontClip | Qt::TextWordWrap, overlayText);
@ -447,14 +601,7 @@ void PictureDialog::setSnapmaticPicture(SnapmaticPicture *picture, bool readOk,
}
if (picture->isJsonOk())
{
if (withDatabase)
{
crewStr = crewDB->getCrewName(crewID);
}
else
{
crewStr = crewID;
}
crewStr = crewDB->getCrewName(crewID);
if (globalMap.contains(picArea))
{
picAreaStr = globalMap[picArea];
@ -564,7 +711,7 @@ void PictureDialog::crewNameUpdated()
{
SnapmaticPicture *picture = smpic; // used by macro
QString crewIDStr = crewID;
if (withDatabase && crewIDStr == crewStr)
if (crewIDStr == crewStr)
{
crewStr = crewDB->getCrewName(crewIDStr);
ui->labJSON->setText(jsonDrawString.arg(locX, locY, locZ, generatePlayersString(), generateCrewString(), picTitl, picAreaStr, created));
@ -601,17 +748,10 @@ QString PictureDialog::generatePlayersString()
for (QString player : playersList)
{
QString playerName;
if (withDatabase)
{
playerName = profileDB->getPlayerName(player.toInt());
}
else
{
playerName = player;
}
playerName = profileDB->getPlayerName(player);
plyrsStr += ", <a href=\"https://socialclub.rockstargames.com/member/" % playerName % "/" % player % "\">" % playerName % "</a>";
}
plyrsStr.remove(0,2);
plyrsStr.remove(0, 2);
}
else
{
@ -746,11 +886,11 @@ void PictureDialog::editSnapmaticProperties()
SnapmaticEditor *snapmaticEditor;
if (rqFullscreen && fullscreenWidget != nullptr)
{
snapmaticEditor = new SnapmaticEditor(crewDB, fullscreenWidget);
snapmaticEditor = new SnapmaticEditor(crewDB, profileDB, fullscreenWidget);
}
else
{
snapmaticEditor = new SnapmaticEditor(crewDB, this);
snapmaticEditor = new SnapmaticEditor(crewDB, profileDB, this);
}
snapmaticEditor->setWindowIcon(windowIcon());
snapmaticEditor->setSnapmaticPicture(picture);
@ -782,14 +922,7 @@ void PictureDialog::editSnapmaticRawJson()
void PictureDialog::updated()
{
SnapmaticPicture *picture = smpic; // used by macro
if (withDatabase)
{
crewStr = crewDB->getCrewName(crewID);
}
else
{
crewStr = crewID;
}
crewStr = crewDB->getCrewName(crewID);
if (globalMap.contains(picArea))
{
picAreaStr = globalMap[picArea];

View File

@ -22,11 +22,21 @@
#include "SnapmaticPicture.h"
#include "ProfileDatabase.h"
#include "CrewDatabase.h"
#include <QResizeEvent>
#include <QMouseEvent>
#include <QToolBar>
#include <QDialog>
#include <QEvent>
#include <QMenu>
#ifdef GTA5SYNC_WIN
#if QT_VERSION >= 0x050200
#ifdef GTA5SYNC_APV
#include <dwmapi.h>
#endif
#endif
#endif
namespace Ui {
class PictureDialog;
}
@ -36,10 +46,8 @@ class PictureDialog : public QDialog
Q_OBJECT
public:
explicit PictureDialog(ProfileDatabase *profileDB, CrewDatabase *crewDB, QWidget *parent = 0);
explicit PictureDialog(QWidget *parent = 0);
explicit PictureDialog(bool primaryWindow, ProfileDatabase *profileDB, CrewDatabase *crewDB, QWidget *parent = 0);
explicit PictureDialog(bool primaryWindow, QWidget *parent = 0);
void setupPictureDialog(bool withDatabase);
void setupPictureDialog();
void setSnapmaticPicture(SnapmaticPicture *picture, bool readOk, bool indexed, int index);
void setSnapmaticPicture(SnapmaticPicture *picture, bool readOk, int index);
void setSnapmaticPicture(SnapmaticPicture *picture, bool readOk);
@ -86,6 +94,15 @@ protected:
bool eventFilter(QObject *obj, QEvent *ev);
void mousePressEvent(QMouseEvent *ev);
bool event(QEvent *event);
#ifdef GTA5SYNC_WIN
#if QT_VERSION >= 0x050200
#ifdef GTA5SYNC_APV
bool nativeEvent(const QByteArray &eventType, void *message, long *result);
LRESULT HitTestNCA(HWND hWnd, LPARAM lParam);
void resizeEvent(QResizeEvent *event);
#endif
#endif
#endif
private:
QString generateCrewString();
@ -97,13 +114,6 @@ private:
QMap<QString, QString> globalMap;
SnapmaticPicture *smpic;
QWidget *fullscreenWidget;
QAction *jpegExportAction;
QAction *pgtaExportAction;
QAction *propEditorAction;
QAction *openViewerAction;
QAction *jsonEditorAction;
QAction *manageMenuSep1;
QAction *manageMenuSep2;
QImage avatarAreaPicture;
QImage snapmaticPicture;
QImage overlayTempImage;
@ -112,7 +122,6 @@ private:
QString picAreaStr;
QString crewStr;
bool overlayEnabled;
bool withDatabase;
bool rqFullscreen;
bool naviEnabled;
bool previewMode;
@ -122,6 +131,12 @@ private:
int avatarLocY;
int avatarSize;
QMenu *manageMenu;
#ifdef GTA5SYNC_WIN
#if QT_VERSION >= 0x050200
QPoint dragPosition;
bool dragStart;
#endif
#endif
};
#endif // PICTUREDIALOG_H

241
PlayerListDialog.cpp Normal file
View File

@ -0,0 +1,241 @@
/*****************************************************************************
* 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 "PlayerListDialog.h"
#include "ui_PlayerListDialog.h"
#include "AppEnv.h"
#include <QFontMetrics>
#include <QInputDialog>
#include <QMessageBox>
#include <QPainter>
#include <QPixmap>
#include <QDebug>
PlayerListDialog::PlayerListDialog(QStringList players, ProfileDatabase *profileDB, QWidget *parent) :
QDialog(parent), players(players), profileDB(profileDB),
ui(new Ui::PlayerListDialog)
{
// 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->cmdCancel->setDefault(true);
if (QIcon::hasThemeIcon("dialog-ok-apply"))
{
ui->cmdApply->setIcon(QIcon::fromTheme("dialog-ok-apply"));
}
else if (QIcon::hasThemeIcon("dialog-apply"))
{
ui->cmdApply->setIcon(QIcon::fromTheme("dialog-apply"));
}
else if (QIcon::hasThemeIcon("dialog-ok"))
{
ui->cmdApply->setIcon(QIcon::fromTheme("dialog-ok"));
}
if (QIcon::hasThemeIcon("dialog-cancel"))
{
ui->cmdCancel->setIcon(QIcon::fromTheme("dialog-cancel"));
}
drawSwitchButtons();
buildInterface();
// DPI calculation
qreal screenRatio = AppEnv::screenRatio();
resize(500 * screenRatio, 350 * screenRatio);
}
PlayerListDialog::~PlayerListDialog()
{
for (QObject *object : ui->listAvPlayers->children())
{
delete object;
}
for (QObject *object : ui->listSePlayers->children())
{
delete object;
}
delete ui;
}
void PlayerListDialog::drawSwitchButtons()
{
QFont painterFont = ui->cmdApply->font();
QPalette palette;
QFontMetrics fontMetrics(painterFont);
QRect makeAvRect = fontMetrics.boundingRect(QRect(0, 0, 0, 0), Qt::AlignCenter | Qt::TextDontClip, "<");
QRect makeSeRect = fontMetrics.boundingRect(QRect(0, 0, 0, 0), Qt::AlignCenter | Qt::TextDontClip, ">");
QRect makeAdRect = fontMetrics.boundingRect(QRect(0, 0, 0, 0), Qt::AlignCenter | Qt::TextDontClip, "+");
int makeAvSize;
if (makeAvRect.height() > makeAvRect.width())
{
makeAvSize = makeAvRect.height();
}
else
{
makeAvSize = makeAvRect.width();
}
int makeSeSize;
if (makeSeRect.height() > makeSeRect.width())
{
makeSeSize = makeSeRect.height();
}
else
{
makeSeSize = makeSeRect.width();
}
int makeAdSize;
if (makeAdRect.height() > makeAdRect.width())
{
makeAdSize = makeAdRect.height();
}
else
{
makeAdSize = makeAdRect.width();
}
QImage avImage(makeAvSize, makeAvSize, QImage::Format_ARGB32_Premultiplied);
avImage.fill(Qt::transparent);
QImage seImage(makeSeSize, makeSeSize, QImage::Format_ARGB32_Premultiplied);
seImage.fill(Qt::transparent);
QImage adImage(makeAdSize, makeAdSize, QImage::Format_ARGB32_Premultiplied);
adImage.fill(Qt::transparent);
QPainter avPainter(&avImage);
avPainter.setFont(painterFont);
avPainter.setBrush(palette.buttonText());
avPainter.drawText(0, 0, makeAvSize, makeAvSize, Qt::AlignCenter | Qt::TextDontClip, "<");
avPainter.end();
QPainter sePainter(&seImage);
sePainter.setFont(painterFont);
sePainter.setBrush(palette.buttonText());
sePainter.drawText(0, 0, makeSeSize, makeSeSize, Qt::AlignCenter | Qt::TextDontClip, ">");
sePainter.end();
QPainter adPainter(&adImage);
adPainter.setFont(painterFont);
adPainter.setBrush(palette.buttonText());
adPainter.drawText(0, 0, makeAdSize, makeAdSize, Qt::AlignCenter | Qt::TextDontClip, "+");
adPainter.end();
ui->cmdMakeAv->setIconSize(avImage.size());
ui->cmdMakeSe->setIconSize(seImage.size());
ui->cmdMakeAd->setIconSize(adImage.size());
ui->cmdMakeAv->setIcon(QIcon(QPixmap::fromImage(avImage)));
ui->cmdMakeSe->setIcon(QIcon(QPixmap::fromImage(seImage)));
ui->cmdMakeAd->setIcon(QIcon(QPixmap::fromImage(adImage)));
}
void PlayerListDialog::on_cmdCancel_clicked()
{
close();
}
void PlayerListDialog::buildInterface()
{
const QStringList dbPlayers = profileDB->getPlayers();
for (QString sePlayer : players)
{
ui->listSePlayers->addItem(QString("%1 (%2)").arg(sePlayer, profileDB->getPlayerName(sePlayer)));
}
for (QString dbPlayer : dbPlayers)
{
if (!players.contains(dbPlayer))
{
ui->listAvPlayers->addItem(QString("%1 (%2)").arg(dbPlayer, profileDB->getPlayerName(dbPlayer)));
}
}
}
void PlayerListDialog::on_cmdMakeAv_clicked()
{
for (QListWidgetItem *item : ui->listSePlayers->selectedItems())
{
QString playerItemText = item->text();
delete item;
ui->listAvPlayers->addItem(playerItemText);
ui->listAvPlayers->sortItems(Qt::AscendingOrder);
}
}
void PlayerListDialog::on_cmdMakeSe_clicked()
{
int maxPlayers = 30;
if (maxPlayers < ui->listSePlayers->count() + ui->listAvPlayers->selectedItems().count())
{
QMessageBox::warning(this, tr("Add Players..."), tr("Failed to add more Players because the limit of Players are %1!").arg(QString::number(maxPlayers)));
return;
}
for (QListWidgetItem *item : ui->listAvPlayers->selectedItems())
{
QString playerItemText = item->text();
delete item;
ui->listSePlayers->addItem(playerItemText);
}
}
void PlayerListDialog::on_cmdMakeAd_clicked()
{
bool playerOk;
int playerID = QInputDialog::getInt(this, tr("Add Player..."), tr("Enter Social Club Player ID"), 1, 1, 214783647, 1, &playerOk, windowFlags());
if (playerOk)
{
for (int i = 0; i < ui->listAvPlayers->count(); ++i)
{
QListWidgetItem *item = ui->listAvPlayers->item(i);
QString playerItemText = item->text();
if (playerItemText.split(" ").at(0) == QString::number(playerID))
{
delete item;
ui->listSePlayers->addItem(playerItemText);
return;
}
}
for (int i = 0; i < ui->listSePlayers->count(); ++i)
{
QListWidgetItem *item = ui->listSePlayers->item(i);
QString playerItemText = item->text();
if (playerItemText.split(" ").at(0) == QString::number(playerID))
{
QMessageBox::warning(this, tr("Add Player..."), tr("Failed to add Player %1 because Player %1 is already added!").arg(QString::number(playerID)));
//ui->listSePlayers->setCurrentItem(item);
return;
}
}
QString playerItemText = QString("%1 (%1)").arg(QString::number(playerID));
ui->listSePlayers->addItem(playerItemText);
}
}
void PlayerListDialog::on_cmdApply_clicked()
{
players.clear();
for (int i = 0; i < ui->listSePlayers->count(); ++i)
{
players += ui->listSePlayers->item(i)->text().split(" ").at(0);
}
emit playerListUpdated(players);
close();
}

55
PlayerListDialog.h Normal file
View File

@ -0,0 +1,55 @@
/*****************************************************************************
* 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 PLAYERLISTDIALOG_H
#define PLAYERLISTDIALOG_H
#include "ProfileDatabase.h"
#include <QDialog>
namespace Ui {
class PlayerListDialog;
}
class PlayerListDialog : public QDialog
{
Q_OBJECT
public:
explicit PlayerListDialog(QStringList players, ProfileDatabase *profileDB, QWidget *parent = 0);
~PlayerListDialog();
private slots:
void on_cmdCancel_clicked();
void on_cmdMakeAv_clicked();
void on_cmdMakeSe_clicked();
void on_cmdMakeAd_clicked();
void on_cmdApply_clicked();
private:
QStringList players;
ProfileDatabase *profileDB;
Ui::PlayerListDialog *ui;
void drawSwitchButtons();
void buildInterface();
signals:
void playerListUpdated(QStringList playerList);
};
#endif // PLAYERLISTDIALOG_H

152
PlayerListDialog.ui Normal file
View File

@ -0,0 +1,152 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>PlayerListDialog</class>
<widget class="QDialog" name="PlayerListDialog">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>500</width>
<height>350</height>
</rect>
</property>
<property name="windowTitle">
<string>Edit Players...</string>
</property>
<layout class="QVBoxLayout" name="vlInterface">
<item>
<layout class="QHBoxLayout" name="hlPlayers">
<item>
<layout class="QVBoxLayout" name="vlAvPlayers">
<item>
<widget class="QLabel" name="labAvPlayers">
<property name="text">
<string>Available Players:</string>
</property>
</widget>
</item>
<item>
<widget class="QListWidget" name="listAvPlayers">
<property name="selectionMode">
<enum>QAbstractItemView::ExtendedSelection</enum>
</property>
</widget>
</item>
</layout>
</item>
<item>
<layout class="QVBoxLayout" name="vlButtons">
<item>
<spacer name="vsButtons1">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>0</width>
<height>0</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QPushButton" name="cmdMakeSe">
<property name="text">
<string/>
</property>
<property name="autoDefault">
<bool>false</bool>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="cmdMakeAv">
<property name="text">
<string/>
</property>
<property name="autoDefault">
<bool>false</bool>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="cmdMakeAd">
<property name="text">
<string/>
</property>
<property name="autoDefault">
<bool>false</bool>
</property>
</widget>
</item>
<item>
<spacer name="vsButtons2">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>0</width>
<height>0</height>
</size>
</property>
</spacer>
</item>
</layout>
</item>
<item>
<layout class="QVBoxLayout" name="vlSePlayers">
<item>
<widget class="QLabel" name="labSePlayers">
<property name="text">
<string>Selected Players:</string>
</property>
</widget>
</item>
<item>
<widget class="QListWidget" name="listSePlayers">
<property name="selectionMode">
<enum>QAbstractItemView::ExtendedSelection</enum>
</property>
</widget>
</item>
</layout>
</item>
</layout>
</item>
<item>
<layout class="QHBoxLayout" name="hlButtons">
<item>
<spacer name="hsButtons">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>0</width>
<height>0</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QPushButton" name="cmdApply">
<property name="text">
<string>&amp;Apply</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="cmdCancel">
<property name="text">
<string>&amp;Cancel</string>
</property>
</widget>
</item>
</layout>
</item>
</layout>
</widget>
<resources/>
<connections/>
</ui>

View File

@ -57,6 +57,15 @@ QStringList ProfileDatabase::getPlayers()
return profileDB->childKeys();
}
QString ProfileDatabase::getPlayerName(QString playerID)
{
QMutexLocker locker(&mutex);
#ifdef GTA5SYNC_DEBUG
qDebug() << "getPlayerName" << playerID;
#endif
return profileDB->value(playerID, playerID).toString();
}
QString ProfileDatabase::getPlayerName(int playerID)
{
QMutexLocker locker(&mutex);

View File

@ -29,6 +29,7 @@ class ProfileDatabase : public QObject
Q_OBJECT
public:
explicit ProfileDatabase(QObject *parent = 0);
QString getPlayerName(QString playerID);
QString getPlayerName(int playerID);
QStringList getPlayers();
~ProfileDatabase();

View File

@ -89,8 +89,16 @@ ProfileInterface::ProfileInterface(ProfileDatabase *profileDB, CrewDatabase *cre
ui->hlButtons->setSpacing(6 * screenRatio);
ui->hlButtons->setContentsMargins(9 * screenRatio, 9 * screenRatio, 9 * screenRatio, 9 * screenRatio);
#else
ui->hlButtons->setSpacing(6 * screenRatio);
ui->hlButtons->setContentsMargins(9 * screenRatio, 15 * screenRatio, 15 * screenRatio, 17 * screenRatio);
if (QApplication::style()->objectName() == "macintosh")
{
ui->hlButtons->setSpacing(6 * screenRatio);
ui->hlButtons->setContentsMargins(9 * screenRatio, 15 * screenRatio, 15 * screenRatio, 17 * screenRatio);
}
else
{
ui->hlButtons->setSpacing(6 * screenRatio);
ui->hlButtons->setContentsMargins(9 * screenRatio, 9 * screenRatio, 9 * screenRatio, 9 * screenRatio);
}
#endif
setMouseTracking(true);
@ -512,6 +520,7 @@ void ProfileInterface::importFilesProgress(QStringList selectedFiles)
pbBar.at(0)->setTextVisible(false);
pbDialog.show();
// THREADING HERE PLEASE
QDateTime importDateTime = QDateTime::currentDateTime();
int currentTime = importDateTime.time().toString(importTimeFormat).toInt();
for (QString selectedFile : selectedFiles)
@ -525,6 +534,7 @@ void ProfileInterface::importFilesProgress(QStringList selectedFiles)
}
overallId++;
}
pbDialog.close();
for (QString curErrorStr : failedFiles)
{
@ -689,7 +699,6 @@ bool ProfileInterface::importFile(QString selectedFile, QDateTime importDateTime
return false;
}
ImportDialog *importDialog = new ImportDialog(this);
importDialog->setWindowFlags(importDialog->windowFlags()^Qt::WindowContextHelpButtonHint);
importDialog->setImage(importImage);
importDialog->setModal(true);
importDialog->show();
@ -1117,6 +1126,20 @@ void ProfileInterface::settingsApplied(int _contentMode, bool languageChanged)
if (languageChanged) widget->retranslate();
}
}
#ifdef Q_OS_MAC
// DPI calculation
qreal screenRatio = AppEnv::screenRatio();
if (QApplication::style()->objectName() == "macintosh")
{
ui->hlButtons->setSpacing(6 * screenRatio);
ui->hlButtons->setContentsMargins(9 * screenRatio, 15 * screenRatio, 15 * screenRatio, 17 * screenRatio);
}
else
{
ui->hlButtons->setSpacing(6 * screenRatio);
ui->hlButtons->setContentsMargins(9 * screenRatio, 9 * screenRatio, 9 * screenRatio, 9 * screenRatio);
}
#endif
}
void ProfileInterface::enableSelected()

View File

@ -10,6 +10,10 @@ SavegameDialog::SavegameDialog(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);

View File

@ -19,8 +19,10 @@
#include "SnapmaticEditor.h"
#include "ui_SnapmaticEditor.h"
#include "SnapmaticPicture.h"
#include "PlayerListDialog.h"
#include "StringParser.h"
#include "AppEnv.h"
#include <QStringListIterator>
#include <QStringBuilder>
#include <QTextDocument>
#include <QInputDialog>
@ -28,15 +30,19 @@
#include <QDebug>
#include <QFile>
SnapmaticEditor::SnapmaticEditor(CrewDatabase *crewDB, QWidget *parent) :
QDialog(parent), crewDB(crewDB),
SnapmaticEditor::SnapmaticEditor(CrewDatabase *crewDB, ProfileDatabase *profileDB, QWidget *parent) :
QDialog(parent), crewDB(crewDB), profileDB(profileDB),
ui(new Ui::SnapmaticEditor)
{
// 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->cmdApply->setDefault(true);
ui->cmdCancel->setDefault(true);
if (QIcon::hasThemeIcon("dialog-ok-apply"))
{
@ -55,7 +61,7 @@ SnapmaticEditor::SnapmaticEditor(CrewDatabase *crewDB, QWidget *parent) :
ui->cmdCancel->setIcon(QIcon::fromTheme("dialog-cancel"));
}
snapmaticTitle = "";
snapmaticTitle = QString();
smpic = 0;
// DPI calculation
@ -154,14 +160,15 @@ void SnapmaticEditor::on_rbCustom_toggled(bool checked)
void SnapmaticEditor::setSnapmaticPicture(SnapmaticPicture *picture)
{
smpic = picture;
localSpJson = smpic->getSnapmaticProperties();
snapmaticProperties = smpic->getSnapmaticProperties();
ui->rbCustom->setChecked(true);
crewID = localSpJson.crewID;
isSelfie = localSpJson.isSelfie;
isMugshot = localSpJson.isMug;
isEditor = localSpJson.isFromRSEditor;
ui->cbDirector->setChecked(localSpJson.isFromDirector);
ui->cbMeme->setChecked(localSpJson.isMeme);
crewID = snapmaticProperties.crewID;
isSelfie = snapmaticProperties.isSelfie;
isMugshot = snapmaticProperties.isMug;
isEditor = snapmaticProperties.isFromRSEditor;
playersList = snapmaticProperties.playersList;
ui->cbDirector->setChecked(snapmaticProperties.isFromDirector);
ui->cbMeme->setChecked(snapmaticProperties.isMeme);
if (isSelfie)
{
ui->rbSelfie->setChecked(true);
@ -180,6 +187,47 @@ void SnapmaticEditor::setSnapmaticPicture(SnapmaticPicture *picture)
}
setSnapmaticCrew(returnCrewName(crewID));
setSnapmaticTitle(picture->getPictureTitle());
setSnapmaticPlayers(insertPlayerNames(playersList));
}
void SnapmaticEditor::insertPlayerNames(QStringList *players)
{
for (int i = 0; i < players->size(); ++i)
{
players->replace(i, profileDB->getPlayerName(players->at(i)));
}
}
QStringList SnapmaticEditor::insertPlayerNames(const QStringList &players)
{
QStringList playersWI = players;
insertPlayerNames(&playersWI);
return playersWI;
}
void SnapmaticEditor::setSnapmaticPlayers(const QStringList &players)
{
QString editStr = QString("<a href=\"g5e://editplayers\" style=\"text-decoration: none;\">%1</a>").arg(tr("Edit"));
QString playersStr;
if (players.length() != 1)
{
playersStr = tr("Players: %1 (%2)", "Multiple Player are inserted here");
}
else
{
playersStr = tr("Player: %1 (%2)", "One Player is inserted here");
}
if (players.length() != 0)
{
ui->labPlayers->setText(playersStr.arg(players.join(", "), editStr));
}
else
{
ui->labPlayers->setText(playersStr.arg(QApplication::translate("PictureDialog", "No Players"), editStr));
}
ui->gbValues->resize(ui->gbValues->sizeHint());
ui->frameWidget->resize(ui->frameWidget->sizeHint());
resize(width(), heightForWidth(width()));
}
void SnapmaticEditor::setSnapmaticTitle(const QString &title)
@ -203,6 +251,9 @@ void SnapmaticEditor::setSnapmaticTitle(const QString &title)
{
ui->labAppropriate->setText(tr("Appropriate: %1").arg(QString("<span style=\"color: red\">%1</a>").arg(tr("No", "No, could lead to issues"))));
}
ui->gbValues->resize(ui->gbValues->sizeHint());
ui->frameWidget->resize(ui->frameWidget->sizeHint());
resize(width(), heightForWidth(width()));
}
void SnapmaticEditor::setSnapmaticCrew(const QString &crew)
@ -210,6 +261,9 @@ void SnapmaticEditor::setSnapmaticCrew(const QString &crew)
QString editStr = QString("<a href=\"g5e://editcrew\" style=\"text-decoration: none;\">%1</a>").arg(tr("Edit"));
QString crewStr = tr("Crew: %1 (%2)").arg(StringParser::escapeString(crew), editStr);
ui->labCrew->setText(crewStr);
ui->gbValues->resize(ui->gbValues->sizeHint());
ui->frameWidget->resize(ui->frameWidget->sizeHint());
resize(width(), heightForWidth(width()));
}
QString SnapmaticEditor::returnCrewName(int crewID_)
@ -228,12 +282,13 @@ void SnapmaticEditor::on_cmdApply_clicked()
{
qualifyAvatar();
}
localSpJson.crewID = crewID;
localSpJson.isSelfie = isSelfie;
localSpJson.isMug = isMugshot;
localSpJson.isFromRSEditor = isEditor;
localSpJson.isFromDirector = ui->cbDirector->isChecked();
localSpJson.isMeme = ui->cbMeme->isChecked();
snapmaticProperties.crewID = crewID;
snapmaticProperties.isSelfie = isSelfie;
snapmaticProperties.isMug = isMugshot;
snapmaticProperties.isFromRSEditor = isEditor;
snapmaticProperties.isFromDirector = ui->cbDirector->isChecked();
snapmaticProperties.isMeme = ui->cbMeme->isChecked();
snapmaticProperties.playersList = playersList;
if (smpic)
{
QString currentFilePath = smpic->getPictureFilePath();
@ -245,7 +300,7 @@ void SnapmaticEditor::on_cmdApply_clicked()
}
SnapmaticProperties fallbackProperties = smpic->getSnapmaticProperties();
QString fallbackTitle = smpic->getPictureTitle();
smpic->setSnapmaticProperties(localSpJson);
smpic->setSnapmaticProperties(snapmaticProperties);
smpic->setPictureTitle(snapmaticTitle);
if (!smpic->exportPicture(currentFilePath))
{
@ -294,6 +349,18 @@ void SnapmaticEditor::on_cbQualify_toggled(bool checked)
}
}
void SnapmaticEditor::on_labPlayers_linkActivated(const QString &link)
{
if (link == "g5e://editplayers")
{
PlayerListDialog *playerListDialog = new PlayerListDialog(playersList, profileDB, this);
connect(playerListDialog, SIGNAL(playerListUpdated(QStringList)), this, SLOT(playerListUpdated(QStringList)));
playerListDialog->show();
playerListDialog->exec();
delete playerListDialog;
}
}
void SnapmaticEditor::on_labTitle_linkActivated(const QString &link)
{
if (link == "g5e://edittitle")
@ -345,3 +412,9 @@ void SnapmaticEditor::on_labCrew_linkActivated(const QString &link)
}
}
}
void SnapmaticEditor::playerListUpdated(QStringList playerList)
{
playersList = playerList;
setSnapmaticPlayers(insertPlayerNames(playerList));
}

View File

@ -21,6 +21,7 @@
#include <QDialog>
#include "CrewDatabase.h"
#include "ProfileDatabase.h"
#include "SnapmaticPicture.h"
namespace Ui {
@ -32,8 +33,9 @@ class SnapmaticEditor : public QDialog
Q_OBJECT
public:
explicit SnapmaticEditor(CrewDatabase *crewDB, QWidget *parent = 0);
explicit SnapmaticEditor(CrewDatabase *crewDB, ProfileDatabase *profileDB, QWidget *parent = 0);
void setSnapmaticPicture(SnapmaticPicture *picture);
void setSnapmaticPlayers(const QStringList &players);
void setSnapmaticTitle(const QString &title);
void setSnapmaticCrew(const QString &crew = "");
QString returnCrewName(int crewID);
@ -47,14 +49,18 @@ private slots:
void on_cmdCancel_clicked();
void on_cmdApply_clicked();
void on_cbQualify_toggled(bool checked);
void on_labPlayers_linkActivated(const QString &link);
void on_labTitle_linkActivated(const QString &link);
void on_labCrew_linkActivated(const QString &link);
void playerListUpdated(QStringList playerList);
private:
CrewDatabase *crewDB;
ProfileDatabase *profileDB;
Ui::SnapmaticEditor *ui;
SnapmaticProperties localSpJson;
SnapmaticProperties snapmaticProperties;
SnapmaticPicture *smpic;
QStringList playersList;
QString snapmaticTitle;
int crewID;
bool isSelfie;
@ -64,6 +70,8 @@ private:
void mugshot_toggled(bool checked);
void editor_toggled(bool checked);
void qualifyAvatar();
void insertPlayerNames(QStringList *players);
QStringList insertPlayerNames(const QStringList &players);
};
#endif // SNAPMATICEDITOR_H

View File

@ -104,13 +104,26 @@
<string>Snapmatic Values</string>
</property>
<layout class="QVBoxLayout" name="vlTitle">
<item>
<widget class="UiModLabel" name="labPlayers">
<property name="contextMenuPolicy">
<enum>Qt::NoContextMenu</enum>
</property>
<property name="text">
<string/>
</property>
<property name="wordWrap">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<widget class="UiModLabel" name="labCrew">
<property name="contextMenuPolicy">
<enum>Qt::NoContextMenu</enum>
</property>
<property name="text">
<string>Crew: %1 (%2)</string>
<string/>
</property>
<property name="wordWrap">
<bool>true</bool>
@ -123,7 +136,7 @@
<enum>Qt::NoContextMenu</enum>
</property>
<property name="text">
<string>Title: %1 (%2)</string>
<string/>
</property>
<property name="wordWrap">
<bool>true</bool>
@ -133,7 +146,7 @@
<item>
<widget class="UiModLabel" name="labAppropriate">
<property name="text">
<string>Appropriate: %1</string>
<string/>
</property>
<property name="wordWrap">
<bool>true</bool>

View File

@ -108,7 +108,7 @@ void SnapmaticPicture::reset()
#endif
// SNAPMATIC PROPERTIES
localSpJson = {};
localProperties = {};
}
bool SnapmaticPicture::preloadFile()
@ -437,9 +437,9 @@ void SnapmaticPicture::updateStrings()
cmpPicTitl.remove('*');
cmpPicTitl.remove('?');
cmpPicTitl.remove('.');
pictureStr = tr("PHOTO - %1").arg(localSpJson.createdDateTime.toString("MM/dd/yy HH:mm:ss"));
sortStr = localSpJson.createdDateTime.toString("yyMMddHHmmss") % QString::number(localSpJson.uid);
QString exportStr = localSpJson.createdDateTime.toString("yyyyMMdd") % "-" % QString::number(localSpJson.uid);
pictureStr = tr("PHOTO - %1").arg(localProperties.createdDateTime.toString("MM/dd/yy HH:mm:ss"));
sortStr = localProperties.createdDateTime.toString("yyMMddHHmmss") % QString::number(localProperties.uid);
QString exportStr = localProperties.createdDateTime.toString("yyyyMMdd") % "-" % QString::number(localProperties.uid);
picExportFileName = exportStr % "_" % cmpPicTitl;
}
@ -496,12 +496,12 @@ bool SnapmaticPicture::setImage(const QImage &picture)
return false;
}
bool SnapmaticPicture::setPictureStream(const QByteArray &picByteArray_) // clean method
bool SnapmaticPicture::setPictureStream(const QByteArray &streamArray) // clean method
{
if (writeEnabled)
{
bool customEOI = false;
QByteArray picByteArray = picByteArray_;
QByteArray picByteArray = streamArray;
if (lowRamMode) { rawPicContent = qUncompress(rawPicContent); }
QBuffer snapmaticStream(&rawPicContent);
snapmaticStream.open(QIODevice::ReadWrite);
@ -638,9 +638,89 @@ QString SnapmaticPicture::getPictureStr()
return pictureStr;
}
QString SnapmaticPicture::getLastStep()
QString SnapmaticPicture::getLastStep(bool readable)
{
if (readable)
{
QStringList lastStepList = lastStep.split(";/");
if (lastStepList.length() < 2) { return lastStep; }
bool intOk;
//int stepNumber = lastStepList.at(0).toInt(&intOk);
//if (!intOk) { return lastStep; }
QStringList descStepList = lastStepList.at(1).split(",");
if (descStepList.length() < 1) { return lastStep; }
int argsCount = descStepList.at(0).toInt(&intOk);
if (!intOk) { return lastStep; }
if (argsCount == 1)
{
QString currentAction = descStepList.at(1);
QString actionFile = descStepList.at(2);
if (currentAction == "OpenFile")
{
return tr("open file %1").arg(actionFile);
}
}
else if (argsCount == 3 || argsCount == 4)
{
QString currentAction = descStepList.at(1);
QString actionFile = descStepList.at(2);
//QString actionStep = descStepList.at(3);
QString actionError = descStepList.at(4);
QString actionError2;
if (argsCount == 4) { actionError2 = descStepList.at(5); }
if (currentAction == "ReadingFile")
{
QString readableError = actionError;
if (actionError == "NOHEADER")
{
readableError = tr("header not exists");
}
else if (actionError == "MALFORMEDHEADER")
{
readableError = tr("header is malformed");
}
else if (actionError == "NOJPEG" || actionError == "NOPIC")
{
readableError = tr("picture not exists (%1)").arg(actionError);
}
else if (actionError == "NOJSON" || actionError == "CTJSON")
{
readableError = tr("JSON not exists (%1)").arg(actionError);
}
else if (actionError == "NOTITL" || actionError == "CTTITL")
{
readableError = tr("title not exists (%1)").arg(actionError);
}
else if (actionError == "NODESC" || actionError == "CTDESC")
{
readableError = tr("description not exists (%1)").arg(actionError);
}
else if (actionError == "JSONINCOMPLETE" && actionError2 == "JSONERROR")
{
readableError = tr("JSON is incomplete and malformed");
}
else if (actionError == "JSONINCOMPLETE")
{
readableError = tr("JSON is incomplete");
}
else if (actionError == "JSONERROR")
{
readableError = tr("JSON is malformed");
}
return tr("reading file %1 because of %2", "Example for %2: JSON is malformed error").arg(actionFile, readableError);
}
else
{
return lastStep;
}
}
else
{
return lastStep;
}
}
return lastStep;
}
QImage SnapmaticPicture::getImage(bool fastLoad)
@ -790,7 +870,7 @@ QString SnapmaticPicture::getJsonStr()
SnapmaticProperties SnapmaticPicture::getSnapmaticProperties()
{
return localSpJson;
return localProperties;
}
void SnapmaticPicture::parseJsonContent()
@ -808,19 +888,19 @@ void SnapmaticPicture::parseJsonContent()
QJsonObject locObject = jsonObject["loc"].toObject();
if (locObject.contains("x"))
{
if (locObject["x"].isDouble()) { localSpJson.location.x = locObject["x"].toDouble(); }
if (locObject["x"].isDouble()) { localProperties.location.x = locObject["x"].toDouble(); }
else { jsonError = true; }
}
else { jsonIncomplete = true; }
if (locObject.contains("y"))
{
if (locObject["y"].isDouble()) { localSpJson.location.y = locObject["y"].toDouble(); }
if (locObject["y"].isDouble()) { localProperties.location.y = locObject["y"].toDouble(); }
else { jsonError = true; }
}
else { jsonIncomplete = true; }
if (locObject.contains("z"))
{
if (locObject["z"].isDouble()) { localSpJson.location.z = locObject["z"].toDouble(); }
if (locObject["z"].isDouble()) { localProperties.location.z = locObject["z"].toDouble(); }
else { jsonError = true; }
}
else { jsonIncomplete = true; }
@ -831,27 +911,27 @@ void SnapmaticPicture::parseJsonContent()
if (jsonObject.contains("uid"))
{
bool uidOk;
localSpJson.uid = jsonMap["uid"].toInt(&uidOk);
localProperties.uid = jsonMap["uid"].toInt(&uidOk);
if (!uidOk) { jsonError = true; }
}
else { jsonIncomplete = true; }
if (jsonObject.contains("area"))
{
if (jsonObject["area"].isString()) { localSpJson.location.area = jsonObject["area"].toString(); }
if (jsonObject["area"].isString()) { localProperties.location.area = jsonObject["area"].toString(); }
else { jsonError = true; }
}
else { jsonIncomplete = true; }
if (jsonObject.contains("crewid"))
{
bool crewIDOk;
localSpJson.crewID = jsonMap["crewid"].toInt(&crewIDOk);
localProperties.crewID = jsonMap["crewid"].toInt(&crewIDOk);
if (!crewIDOk) { jsonError = true; }
}
else { jsonIncomplete = true; }
if (jsonObject.contains("street"))
{
bool streetIDOk;
localSpJson.streetID = jsonMap["street"].toInt(&streetIDOk);
localProperties.streetID = jsonMap["street"].toInt(&streetIDOk);
if (!streetIDOk) { jsonError = true; }
}
else { jsonIncomplete = true; }
@ -859,45 +939,45 @@ void SnapmaticPicture::parseJsonContent()
{
bool timestampOk;
QDateTime createdTimestamp;
localSpJson.createdTimestamp = jsonMap["creat"].toUInt(&timestampOk);
createdTimestamp.setTime_t(localSpJson.createdTimestamp);
localSpJson.createdDateTime = createdTimestamp;
localProperties.createdTimestamp = jsonMap["creat"].toUInt(&timestampOk);
createdTimestamp.setTime_t(localProperties.createdTimestamp);
localProperties.createdDateTime = createdTimestamp;
if (!timestampOk) { jsonError = true; }
}
else { jsonIncomplete = true; }
if (jsonObject.contains("plyrs"))
{
if (jsonObject["plyrs"].isArray()) { localSpJson.playersList = jsonMap["plyrs"].toStringList(); }
if (jsonObject["plyrs"].isArray()) { localProperties.playersList = jsonMap["plyrs"].toStringList(); }
else { jsonError = true; }
}
else { jsonIncomplete = true; }
// else { jsonIncomplete = true; } // 2016 Snapmatic pictures left out plyrs when none are captured, so don't force exists on that one
if (jsonObject.contains("meme"))
{
if (jsonObject["meme"].isBool()) { localSpJson.isMeme = jsonObject["meme"].toBool(); }
if (jsonObject["meme"].isBool()) { localProperties.isMeme = jsonObject["meme"].toBool(); }
else { jsonError = true; }
}
else { jsonIncomplete = true; }
if (jsonObject.contains("mug"))
{
if (jsonObject["mug"].isBool()) { localSpJson.isMug = jsonObject["mug"].toBool(); }
if (jsonObject["mug"].isBool()) { localProperties.isMug = jsonObject["mug"].toBool(); }
else { jsonError = true; }
}
else { jsonIncomplete = true; }
if (jsonObject.contains("slf"))
{
if (jsonObject["slf"].isBool()) { localSpJson.isSelfie = jsonObject["slf"].toBool(); }
if (jsonObject["slf"].isBool()) { localProperties.isSelfie = jsonObject["slf"].toBool(); }
else { jsonError = true; }
}
else { jsonIncomplete = true; }
if (jsonObject.contains("drctr"))
{
if (jsonObject["drctr"].isBool()) { localSpJson.isFromDirector = jsonObject["drctr"].toBool(); }
if (jsonObject["drctr"].isBool()) { localProperties.isFromDirector = jsonObject["drctr"].toBool(); }
else { jsonError = true; }
}
else { jsonIncomplete = true; }
if (jsonObject.contains("rsedtr"))
{
if (jsonObject["rsedtr"].isBool()) { localSpJson.isFromRSEditor = jsonObject["rsedtr"].toBool(); }
if (jsonObject["rsedtr"].isBool()) { localProperties.isFromRSEditor = jsonObject["rsedtr"].toBool(); }
else { jsonError = true; }
}
else { jsonIncomplete = true; }
@ -908,38 +988,50 @@ void SnapmaticPicture::parseJsonContent()
}
else
{
if (jsonIncomplete && jsonError)
{
lastStep = "2;/4,ReadingFile," % StringParser::convertDrawStringForLog(picFilePath) % ",3,JSONINCOMPLETE,JSONERROR";
}
else if (jsonIncomplete)
{
lastStep = "2;/3,ReadingFile," % StringParser::convertDrawStringForLog(picFilePath) % ",3,JSONINCOMPLETE";
}
else if (jsonError)
{
lastStep = "2;/3,ReadingFile," % StringParser::convertDrawStringForLog(picFilePath) % ",3,JSONERROR";
}
jsonOk = false;
}
}
bool SnapmaticPicture::setSnapmaticProperties(SnapmaticProperties newSpJson)
bool SnapmaticPicture::setSnapmaticProperties(SnapmaticProperties properties)
{
QJsonDocument jsonDocument = QJsonDocument::fromJson(jsonStr.toUtf8());
QJsonObject jsonObject = jsonDocument.object();
QJsonObject locObject;
locObject["x"] = newSpJson.location.x;
locObject["y"] = newSpJson.location.y;
locObject["z"] = newSpJson.location.z;
locObject["x"] = properties.location.x;
locObject["y"] = properties.location.y;
locObject["z"] = properties.location.z;
jsonObject["loc"] = locObject;
jsonObject["uid"] = newSpJson.uid;
jsonObject["area"] = newSpJson.location.area;
jsonObject["crewid"] = newSpJson.crewID;
jsonObject["street"] = newSpJson.streetID;
jsonObject["creat"] = QJsonValue::fromVariant(newSpJson.createdTimestamp);
jsonObject["plyrs"] = QJsonValue::fromVariant(newSpJson.playersList);
jsonObject["meme"] = newSpJson.isMeme;
jsonObject["mug"] = newSpJson.isMug;
jsonObject["slf"] = newSpJson.isSelfie;
jsonObject["drctr"] = newSpJson.isFromDirector;
jsonObject["rsedtr"] = newSpJson.isFromRSEditor;
jsonObject["uid"] = properties.uid;
jsonObject["area"] = properties.location.area;
jsonObject["crewid"] = properties.crewID;
jsonObject["street"] = properties.streetID;
jsonObject["creat"] = QJsonValue::fromVariant(properties.createdTimestamp);
jsonObject["plyrs"] = QJsonValue::fromVariant(properties.playersList);
jsonObject["meme"] = properties.isMeme;
jsonObject["mug"] = properties.isMug;
jsonObject["slf"] = properties.isSelfie;
jsonObject["drctr"] = properties.isFromDirector;
jsonObject["rsedtr"] = properties.isFromRSEditor;
jsonDocument.setObject(jsonObject);
if (setJsonStr(QString::fromUtf8(jsonDocument.toJson(QJsonDocument::Compact))))
{
localSpJson = newSpJson;
localProperties = properties;
return true;
}
return false;
@ -1157,6 +1249,15 @@ bool SnapmaticPicture::isHidden()
return false;
}
bool SnapmaticPicture::isVisible()
{
if (picFilePath.right(7) == QLatin1String(".hidden"))
{
return false;
}
return true;
}
bool SnapmaticPicture::setPictureHidden()
{
if (isCustomFormat)

View File

@ -59,10 +59,10 @@ public:
bool preloadFile();
bool readingPictureFromFile(const QString &fileName, bool writeEnabled = true, bool cacheEnabled = false, bool fastLoad = true, bool lowRamMode = false);
bool readingPicture(bool writeEnabled = true, bool cacheEnabled = false, bool fastLoad = true, bool lowRamMode = false);
bool isPicOk();
bool isPicOk(); // Please use isPictureOk instead
void clearCache();
QImage getImage(bool fastLoad = false);
QString getLastStep();
QString getLastStep(bool readable = true);
QString getPictureStr();
QString getPictureHead();
QString getPictureTitl();
@ -75,35 +75,48 @@ public:
QString getOriginalPictureFilePath();
int getContentMaxLength();
bool setImage(const QImage &picture);
bool setPictureTitl(const QString &newTitle);
bool setPictureStream(const QByteArray &picByteArray);
bool setPictureTitl(const QString &newTitle); // Please use setPictureTitle instead
bool setPictureStream(const QByteArray &streamArray);
void updateStrings();
void emitUpdate();
// FILE MANAGEMENT
bool exportPicture(const QString &fileName, SnapmaticFormat format = SnapmaticFormat::Auto_Format);
void setPicFileName(const QString &picFileName);
void setPicFilePath(const QString &picFilePath);
bool deletePicFile();
// ALTERNATIVES
QString getPictureTitle() { return getPictureTitl(); }
QString getPictureString() { return getPictureStr(); }
QString getPictureDescription() { return getPictureDesc(); }
bool setPictureTitle(const QString &newTitle) { return setPictureTitl(newTitle); }
void setPicFileName(const QString &picFileName); // Please use setPictureFileName instead
void setPicFilePath(const QString &picFilePath); // Please use setPictureFilePath instead
bool deletePicFile(); // Please use deletePictureFile instead
// JSON
bool isJsonOk();
QString getJsonStr();
QString getJsonStr(); // Please use getPictureJson instead
SnapmaticProperties getSnapmaticProperties();
bool setSnapmaticProperties(SnapmaticProperties newSpJson);
bool setJsonStr(const QString &jsonStr, bool updateProperties = false);
bool setSnapmaticProperties(SnapmaticProperties properties);
bool setJsonStr(const QString &jsonStr, bool updateProperties = false); // Please use setPictureJson instead
// VISIBILITY
bool isHidden();
bool isHidden(); // Please use isPictureHidden instead
bool isVisible(); // Please use isPictureVisible instead
bool setPictureHidden();
bool setPictureVisible();
// ALTERNATIVES (MORE DEVELOPER FRIENDLY FUNCTION CALLS)
QString getJsonString() { return getJsonStr(); } // Please use getPictureJson instead
QString getPictureJson() { return getJsonStr(); }
QString getPictureTitle() { return getPictureTitl(); }
QString getPictureString() { return getPictureStr(); }
QString getPictureDescription() { return getPictureDesc(); }
bool setJsonString(const QString &jsonString, bool updateProperties = false) { return setJsonStr(jsonString, updateProperties); } // Please use setPictureJson instead
bool setPictureJson(const QString &json, bool updateProperties = false) { return setJsonStr(json, updateProperties); }
bool setPictureTitle(const QString &title) { return setPictureTitl(title); }
void setPictureFileName(const QString &fileName) { return setPicFileName(fileName); }
void setPictureFilePath(const QString &filePath) { return setPicFilePath(filePath); }
bool deletePictureFile() { return deletePicFile(); }
bool isPictureOk() { return isPicOk(); }
bool isPictureHidden() { return isHidden(); }
bool isPictureVisible() { return isVisible(); }
bool setHidden() { return setPictureHidden(); } // Please use setPictureHidden instead
bool setVisible() { return setPictureVisible(); } // Please use setPictureVisible instead
// PREDEFINED PROPERTIES
QSize getSnapmaticResolution();
@ -151,7 +164,7 @@ private:
void parseJsonContent();
bool jsonOk;
QString jsonStr;
SnapmaticProperties localSpJson;
SnapmaticProperties localProperties;
// VERIFY CONTENT
static bool verifyTitleChar(const QChar &titleChar);

View File

@ -284,7 +284,7 @@ void SnapmaticWidget::makePictureVisibleSlot()
void SnapmaticWidget::editSnapmaticProperties()
{
SnapmaticEditor *snapmaticEditor = new SnapmaticEditor(crewDB, this);
SnapmaticEditor *snapmaticEditor = new SnapmaticEditor(crewDB, profileDB, this);
snapmaticEditor->setSnapmaticPicture(smpic);
snapmaticEditor->setModal(true);
snapmaticEditor->show();

View File

@ -50,7 +50,7 @@
#ifndef GTA5SYNC_APPVER
#ifndef GTA5SYNC_DAILYB
#define GTA5SYNC_APPVER "1.5.0-dev5"
#define GTA5SYNC_APPVER "1.5.0-dev6"
#else
#define GTA5SYNC_APPVER GTA5SYNC_DAILYB
#endif

View File

@ -44,6 +44,7 @@ SOURCES += main.cpp \
PictureDialog.cpp \
PictureExport.cpp \
PictureWidget.cpp \
PlayerListDialog.cpp \
ProfileDatabase.cpp \
ProfileInterface.cpp \
ProfileLoader.cpp \
@ -80,6 +81,7 @@ HEADERS += \
PictureDialog.h \
PictureExport.h \
PictureWidget.h \
PlayerListDialog.h \
ProfileDatabase.h \
ProfileInterface.h \
ProfileLoader.h \
@ -108,6 +110,7 @@ FORMS += \
MapLocationDialog.ui \
OptionsDialog.ui \
PictureDialog.ui \
PlayerListDialog.ui \
ProfileInterface.ui \
SavegameDialog.ui \
SavegameWidget.ui \

View File

@ -25,12 +25,12 @@ BEGIN
BEGIN
VALUE "CompanyName", "Syping"
VALUE "FileDescription", "gta5view\0"
VALUE "FileVersion", "1.5.0-dev5\0"
VALUE "FileVersion", "1.5.0-dev6\0"
VALUE "InternalName", "gta5view\0"
VALUE "LegalCopyright", "Copyright © 2016-2017 Syping\0"
VALUE "OriginalFilename", "gta5view.exe\0"
VALUE "ProductName", "gta5view\0"
VALUE "ProductVersion", "1.5.0-dev5\0"
VALUE "ProductVersion", "1.5.0-dev6\0"
END
END
END