Compare commits

..

2 Commits
1.8.x ... 1.3.x

Author SHA1 Message Date
Syping ccfb4c7ccb fixed crew fetcher, bump version to 1.3.5 2017-08-26 10:04:59 +02:00
Syping 2bbeb98005 fix UI bug 2017-08-23 07:06:14 +02:00
259 changed files with 14522 additions and 59132 deletions

View File

@ -1,33 +0,0 @@
IDI_ICON1 ICON DISCARDABLE "5sync.ico"
#define RT_MANIFEST 24
#define CREATEPROCESS_MANIFEST_RESOURCE_ID 1
CREATEPROCESS_MANIFEST_RESOURCE_ID RT_MANIFEST "gta5view.exe.manifest"
#include <windows.h>
VS_VERSION_INFO VERSIONINFO
FILEVERSION MAJOR_VER, MINOR_VER, PATCH_VER, INT_BUILD_VER
PRODUCTVERSION MAJOR_VER, MINOR_VER, PATCH_VER, INT_BUILD_VER
FILEFLAGSMASK 0x3fL
FILEFLAGS 0
FILEOS VOS_NT_WINDOWS32
FILETYPE VFT_APP
FILESUBTYPE VFT2_UNKNOWN
BEGIN
BLOCK "VarFileInfo"
BEGIN
VALUE "Translation", 0x0809, 1200
END
BLOCK "StringFileInfo"
BEGIN
BLOCK "040904b0"
BEGIN
VALUE "CompanyName", "Syping"
VALUE "FileDescription", "gta5view"
VALUE "FileVersion", "MAJOR_VER.MINOR_VER.PATCH_VERSTR_BUILD_VER"
VALUE "InternalName", "gta5view"
VALUE "LegalCopyright", "Copyright © 2016-2020 Syping"
VALUE "OriginalFilename", "gta5view.exe"
VALUE "ProductName", "gta5view"
VALUE "ProductVersion", "MAJOR_VER.MINOR_VER.PATCH_VERSTR_BUILD_VER"
END
END
END

View File

@ -1,72 +0,0 @@
#!/bin/bash
if [ $(git name-rev --tags --name-only $(git rev-parse HEAD)) == "undefined" ]; then
export APPLICATION_VERSION=$(lua -e 'for line in io.lines("config.h") do local m = string.match(line, "#define GTA5SYNC_APPVER \"(.+)\"$"); if m then print(m); os.exit(0) end end')
else
export APPLICATION_VERSION=$(git name-rev --tags --name-only $(git rev-parse HEAD))
fi
export PACKAGE_VERSION=$(grep -oE '^[^\-]*' <<< $APPLICATION_VERSION)
export PACKAGE_BUILD=$(grep -oP '\-\K.+' <<< $APPLICATION_VERSION)
export EXECUTABLE_VERSION=${PACKAGE_VERSION}${PACKAGE_BUILD}${EXECUTABLE_TAG}
export APPLICATION_MAJOR_VERSION=$(cut -d. -f1 <<< $APPLICATION_VERSION)
export APPLICATION_MINOR_VERSION=$(cut -d. -f2 <<< $APPLICATION_VERSION)
export APPLICATION_PATCH_VERSION=$(cut -d. -f3 <<< $APPLICATION_VERSION)
if [ "${PACKAGE_BUILD}" == "" ]; then
export PACKAGE_BUILD=1
else
export APPLICATION_BUILD_INT_VERSION=$(grep -oE "[1-9]*$" <<< $PACKAGE_BUILD)
export APPLICATION_BUILD_STR_VERSION=-${PACKAGE_BUILD}
fi
cat ".ci/app.rc" | sed \
-e "s/MAJOR_VER/$APPLICATION_MAJOR_VERSION/g" \
-e "s/MINOR_VER/$APPLICATION_MINOR_VERSION/g" \
-e "s/PATCH_VER/$APPLICATION_PATCH_VERSION/g" \
-e "s/INT_BUILD_VER/0/g" \
-e "s/STR_BUILD_VER/$APPLICATION_BUILD_STR_VERSION/g" \
-e "s/STR_BUILD_VER/$APPLICATION_BUILD_STR_VERSION/g" \
> "res/app.rc"
if [ "${BUILD_TYPE}" == "ALPHA" ]; then
export CMAKE_BUILD_TYPE="-DGTA5VIEW_BUILDTYPE_ALPHA=TRUE"
export QMAKE_BUILD_TYPE="DEFINES+=GTA5SYNC_BUILDTYPE_ALPHA"
elif [ "${BUILD_TYPE}" == "Alpha" ]; then
export CMAKE_BUILD_TYPE="-DGTA5VIEW_BUILDTYPE_ALPHA=TRUE"
export QMAKE_BUILD_TYPE="DEFINES+=GTA5SYNC_BUILDTYPE_ALPHA"
elif [ "${BUILD_TYPE}" == "BETA" ]; then
export CMAKE_BUILD_TYPE="-DGTA5VIEW_BUILDTYPE_BETA=TRUE"
export QMAKE_BUILD_TYPE="DEFINES+=GTA5SYNC_BUILDTYPE_BETA"
elif [ "${BUILD_TYPE}" == "Beta" ]; then
export CMAKE_BUILD_TYPE="-DGTA5VIEW_BUILDTYPE_BETA=TRUE"
export QMAKE_BUILD_TYPE="DEFINES+=GTA5SYNC_BUILDTYPE_BETA"
elif [ "${BUILD_TYPE}" == "DEV" ]; then
export CMAKE_BUILD_TYPE="-DGTA5VIEW_BUILDTYPE_DEV=TRUE"
export QMAKE_BUILD_TYPE="DEFINES+=GTA5SYNC_BUILDTYPE_DEV"
elif [ "${BUILD_TYPE}" == "Development" ]; then
export CMAKE_BUILD_TYPE="-DGTA5VIEW_BUILDTYPE_DEV=TRUE"
export QMAKE_BUILD_TYPE="DEFINES+=GTA5SYNC_BUILDTYPE_DEV"
elif [ "${BUILD_TYPE}" == "DAILY" ]; then
export CMAKE_BUILD_TYPE="-DGTA5VIEW_BUILDTYPE_DAILY=TRUE"
export QMAKE_BUILD_TYPE="DEFINES+=GTA5SYNC_BUILDTYPE_DAILY"
elif [ "${BUILD_TYPE}" == "Daily" ]; then
export CMAKE_BUILD_TYPE="-DGTA5VIEW_BUILDTYPE_DAILY=TRUE"
export QMAKE_BUILD_TYPE="DEFINES+=GTA5SYNC_BUILDTYPE_DAILY"
elif [ "${BUILD_TYPE}" == "RC" ]; then
export CMAKE_BUILD_TYPE="-DGTA5VIEW_BUILDTYPE_RC=TRUE"
export QMAKE_BUILD_TYPE="DEFINES+=GTA5SYNC_BUILDTYPE_RC"
elif [ "${BUILD_TYPE}" == "Release Candidate" ]; then
export CMAKE_BUILD_TYPE="-DGTA5VIEW_BUILDTYPE_RC=TRUE"
export QMAKE_BUILD_TYPE="DEFINES+=GTA5SYNC_BUILDTYPE_RC"
elif [ "${BUILD_TYPE}" == "REL" ]; then
export CMAKE_BUILD_TYPE="-DGTA5VIEW_BUILDTYPE_REL=TRUE"
export QMAKE_BUILD_TYPE="DEFINES+=GTA5SYNC_BUILDTYPE_REL"
elif [ "${BUILD_TYPE}" == "Release" ]; then
export CMAKE_BUILD_TYPE="-DGTA5VIEW_BUILDTYPE_REL=TRUE"
export QMAKE_BUILD_TYPE="DEFINES+=GTA5SYNC_BUILDTYPE_REL"
fi
export PROJECT_DIR=$(pwd)
.ci/${BUILD_SCRIPT}

View File

@ -1,44 +0,0 @@
#!/bin/bash
# Creating folders
cd ${PROJECT_DIR} && \
echo "gta5view build version is ${APPLICATION_VERSION}" && \
mkdir -p build && \
mkdir -p assets && \
chmod -x res/gta5sync_*.qm res/*.desktop res/*gta5view*.png && \
cd build && \
mkdir -p qt4 && \
cd qt4 && \
echo "Grand Theft Auto V Snapmatic and Savegame viewer/editor" > ./description-pak && \
cd .. && \
mkdir -p qt5 && \
cd qt5 && \
echo "Grand Theft Auto V Snapmatic and Savegame viewer/editor" > ./description-pak && \
cd .. && \
# Set compiler
export CC=clang && \
export CXX=clang++ && \
# Prepare checkinstall step
mkdir -p /usr/share/gta5view && \
# Starting build
cd qt5 && \
cmake \
"-DCMAKE_INSTALL_PREFIX=/usr" \
${CMAKE_BUILD_TYPE} \
"-DGTA5VIEW_BUILDCODE=${PACKAGE_CODE}" \
"-DGTA5VIEW_APPVER=${APPLICATION_VERSION}" \
"-DGTA5VIEW_COMMIT=${APPLICATION_COMMIT}" \
"-DWITH_TELEMETRY=ON" \
"-DTELEMETRY_WEBURL=https://dev.syping.de/gta5view-userstats/" \
"-DQCONF_BUILD=ON" \
../../ && \
make -j 4 && \
checkinstall -D --default --nodoc --install=no --pkgname=gta5view-qt5 --pkgversion=${PACKAGE_VERSION} --pkgrelease=${PACKAGE_BUILD} --pkggroup=utility --maintainer="Syping \<dpkg@syping.de\>" --requires=libqt5core5a,libqt5gui5,libqt5network5,libqt5svg5,libqt5widgets5,qttranslations5-l10n --conflicts=gta5view,gta5view-qt4 --replaces=gta5view,gta5view-qt4 --pakdir=${PROJECT_DIR}/assets && \
cd .. && \
cd qt4 && \
qmake -qt=4 GTA5SYNC_PREFIX=/usr QMAKE_CXXFLAGS+=-std=gnu++11 ${QMAKE_FLAGS_QT4} ${QMAKE_BUILD_TYPE} "DEFINES+=GTA5SYNC_BUILDCODE=\\\\\\\"${PACKAGE_CODE}\\\\\\\"" "DEFINES+=GTA5SYNC_APPVER=\\\\\\\"${APPLICATION_VERSION}\\\\\\\"" DEFINES+=GTA5SYNC_QCONF ../../gta5view.pro && \
make -j 4 && \
checkinstall -D --default --nodoc --install=no --pkgname=gta5view-qt4 --pkgversion=${PACKAGE_VERSION} --pkgrelease=${PACKAGE_BUILD} --pkggroup=utility --maintainer="Syping \<dpkg@syping.de\>" --requires=libqtcore4,libqtgui4,libqt4-network,libqt4-svg,qtcore4-l10n --conflicts=gta5view,gta5view-qt5 --replaces=gta5view,gta5view-qt5 --pakdir=${PROJECT_DIR}/assets

View File

@ -1,8 +0,0 @@
#!/bin/bash
# Install packages
.ci/debian_install.sh && \
# Build gta5view
.ci/debian_build.sh && \
cd ${PROJECT_DIR}

View File

@ -1,15 +0,0 @@
#!/bin/bash
if [ "${DOCKER_USER}" != "" ]; then
DOCKER_IMAGE=${DOCKER_USER}/debian:${DEBIAN_VERSION}
else
DOCKER_IMAGE=debian:${DEBIAN_VERSION}
fi
PROJECT_DIR_DOCKER=/gta5view
cd ${PROJECT_DIR} && \
docker pull ${DOCKER_IMAGE} && \
docker run --rm \
-v "${PROJECT_DIR}:${PROJECT_DIR_DOCKER}" \
${DOCKER_IMAGE} \
/bin/bash -c "export PROJECT_DIR=${PROJECT_DIR_DOCKER} && export QT_SELECT=${QT_SELECT} && export APPLICATION_VERSION=${APPLICATION_VERSION} && export APPLICATION_COMMIT=${APPLICATION_COMMIT} && export BUILD_TYPE=${BUILD_TYPE} && export APT_INSTALL=${APT_INSTALL} && export QMAKE_FLAGS_QT4=${QMAKE_FLAGS_QT4} && export QMAKE_FLAGS_QT5=${QMAKE_FLAGS_QT5} && export CMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE} && export QMAKE_BUILD_TYPE=${QMAKE_BUILD_TYPE} && export PACKAGE_VERSION=${PACKAGE_VERSION} && export PACKAGE_BUILD=${PACKAGE_BUILD} && export PACKAGE_CODE=${PACKAGE_CODE} && export EXECUTABLE_VERSION=${EXECUTABLE_VERSION} && export EXECUTABLE_ARCH=${EXECUTABLE_ARCH} && cd ${PROJECT_DIR_DOCKER} && .ci/debian_install.sh && .ci/debian_build.sh"

View File

@ -1,5 +0,0 @@
#!/bin/bash
# Install packages
apt-get update -qq && \
apt-get install -qq ${APT_INSTALL} checkinstall cmake dpkg-dev fakeroot g++ gcc qtbase5-dev qt5-qmake qttranslations5-l10n libqt4-dev libqt5svg5-dev

File diff suppressed because it is too large Load Diff

View File

@ -1,276 +0,0 @@
######################################################################
!define APP_NAME "gta5view"
!define COMP_NAME "Syping"
!define WEB_SITE "https://gta5view.syping.de/"
!define VERSION "1.8.0.0"
!define COPYRIGHT "Copyright © 2016-2020 Syping"
!define DESCRIPTION "Grand Theft Auto V Savegame and Snapmatic Viewer/Editor"
!define INSTALLER_NAME "gta5view_setup.exe"
!define MAIN_APP_EXE "gta5view.exe"
!define INSTALL_TYPE "SetShellVarContext all"
!define REG_ROOT "HKLM"
!define REG_APP_PATH "Software\Microsoft\Windows\CurrentVersion\App Paths\${MAIN_APP_EXE}"
!define UNINSTALL_PATH "Software\Microsoft\Windows\CurrentVersion\Uninstall\${APP_NAME}"
!define LICENSE_TXT "../LICENSE"
######################################################################
VIProductVersion "${VERSION}"
VIAddVersionKey "ProductName" "${APP_NAME}"
VIAddVersionKey "ProductVersion" "${VERSION}"
VIAddVersionKey "CompanyName" "${COMP_NAME}"
VIAddVersionKey "LegalCopyright" "${COPYRIGHT}"
VIAddVersionKey "FileDescription" "${DESCRIPTION}"
VIAddVersionKey "FileVersion" "${VERSION}"
######################################################################
!include "x64.nsh"
SetCompressor LZMA
Name "${APP_NAME}"
Caption "${APP_NAME}"
OutFile "${INSTALLER_NAME}"
#BrandingText "${APP_NAME}"
XPStyle on
Unicode true
InstallDirRegKey "${REG_ROOT}" "${REG_APP_PATH}" ""
InstallDir "$PROGRAMFILES64\Syping\gta5view"
######################################################################
!include "MUI2.nsh"
!define MUI_ABORTWARNING
!define MUI_UNABORTWARNING
!define MUI_LANGDLL_REGISTRY_ROOT "${REG_ROOT}"
!define MUI_LANGDLL_REGISTRY_KEY "${UNINSTALL_PATH}"
!define MUI_LANGDLL_REGISTRY_VALUENAME "Installer Language"
!insertmacro MUI_PAGE_WELCOME
!ifdef LICENSE_TXT
!insertmacro MUI_PAGE_LICENSE "${LICENSE_TXT}"
!endif
!insertmacro MUI_PAGE_DIRECTORY
!ifdef REG_START_MENU
!define MUI_STARTMENUPAGE_NODISABLE
!define MUI_STARTMENUPAGE_DEFAULTFOLDER "gta5view"
!define MUI_STARTMENUPAGE_REGISTRY_ROOT "${REG_ROOT}"
!define MUI_STARTMENUPAGE_REGISTRY_KEY "${UNINSTALL_PATH}"
!define MUI_STARTMENUPAGE_REGISTRY_VALUENAME "${REG_START_MENU}"
!insertmacro MUI_PAGE_STARTMENU Application $SM_Folder
!endif
!insertmacro MUI_PAGE_INSTFILES
!define MUI_FINISHPAGE_RUN "$INSTDIR\${MAIN_APP_EXE}"
!insertmacro MUI_PAGE_FINISH
!insertmacro MUI_UNPAGE_CONFIRM
!insertmacro MUI_UNPAGE_INSTFILES
!insertmacro MUI_UNPAGE_FINISH
!insertmacro MUI_LANGUAGE "English"
!insertmacro MUI_LANGUAGE "French"
!insertmacro MUI_LANGUAGE "German"
!insertmacro MUI_LANGUAGE "Korean"
!insertmacro MUI_LANGUAGE "Russian"
!insertmacro MUI_LANGUAGE "Ukrainian"
!insertmacro MUI_LANGUAGE "TradChinese"
!insertmacro MUI_RESERVEFILE_LANGDLL
######################################################################
Function .onInit
!insertmacro MUI_LANGDLL_DISPLAY
!ifdef WIN32
MessageBox MB_OK|MB_ICONSTOP "Windows 32-Bit is not supported anymore!"
Quit
!endif
SetRegView 64
FunctionEnd
######################################################################
Section -MainProgram
${INSTALL_TYPE}
SetOverwrite ifnewer
SetOutPath "$INSTDIR"
File "../build/gta5view.exe"
File "/opt/llvm-mingw/x86_64-w64-mingw32/bin/libc++.dll"
File "/opt/llvm-mingw/x86_64-w64-mingw32/bin/libunwind.dll"
File "/usr/local/lib/x86_64-w64-mingw32/openssl/bin/libcrypto-1_1-x64.dll"
File "/usr/local/lib/x86_64-w64-mingw32/openssl/bin/libssl-1_1-x64.dll"
File "/usr/local/lib/x86_64-w64-mingw32/qt5/bin/Qt5Core.dll"
File "/usr/local/lib/x86_64-w64-mingw32/qt5/bin/Qt5Gui.dll"
File "/usr/local/lib/x86_64-w64-mingw32/qt5/bin/Qt5Network.dll"
File "/usr/local/lib/x86_64-w64-mingw32/qt5/bin/Qt5Svg.dll"
File "/usr/local/lib/x86_64-w64-mingw32/qt5/bin/Qt5Widgets.dll"
File "/usr/local/lib/x86_64-w64-mingw32/qt5/bin/Qt5WinExtras.dll"
SetOutPath "$INSTDIR\lang"
File "../build/gta5sync_en_US.qm"
File "../build/gta5sync_de.qm"
File "../build/gta5sync_fr.qm"
File "../build/gta5sync_ko.qm"
File "../build/gta5sync_ru.qm"
File "../build/gta5sync_uk.qm"
File "../build/gta5sync_zh_TW.qm"
File "../build/qtbase_en_GB.qm"
File "../res/qtbase_de.qm"
File "../res/qtbase_fr.qm"
File "../res/qtbase_ko.qm"
File "../res/qtbase_ru.qm"
File "../res/qtbase_uk.qm"
File "../res/qtbase_zh_TW.qm"
SetOutPath "$INSTDIR\imageformats"
File "/usr/local/lib/x86_64-w64-mingw32/qt5/plugins/imageformats/qgif.dll"
File "/usr/local/lib/x86_64-w64-mingw32/qt5/plugins/imageformats/qicns.dll"
File "/usr/local/lib/x86_64-w64-mingw32/qt5/plugins/imageformats/qico.dll"
File "/usr/local/lib/x86_64-w64-mingw32/qt5/plugins/imageformats/qjpeg.dll"
File "/usr/local/lib/x86_64-w64-mingw32/qt5/plugins/imageformats/qsvg.dll"
File "/usr/local/lib/x86_64-w64-mingw32/qt5/plugins/imageformats/qtga.dll"
File "/usr/local/lib/x86_64-w64-mingw32/qt5/plugins/imageformats/qtiff.dll"
File "/usr/local/lib/x86_64-w64-mingw32/qt5/plugins/imageformats/qwbmp.dll"
File "/usr/local/lib/x86_64-w64-mingw32/qt5/plugins/imageformats/qwebp.dll"
SetOutPath "$INSTDIR\platforms"
File "/usr/local/lib/x86_64-w64-mingw32/qt5/plugins/platforms/qwindows.dll"
SetOutPath "$INSTDIR\styles"
File "/usr/local/lib/x86_64-w64-mingw32/qt5/plugins/styles/qcleanlooksstyle.dll"
File "/usr/local/lib/x86_64-w64-mingw32/qt5/plugins/styles/qplastiquestyle.dll"
File "/usr/local/lib/x86_64-w64-mingw32/qt5/plugins/styles/qwindowsvistastyle.dll"
SectionEnd
######################################################################
Section -Icons_Reg
SetOutPath "$INSTDIR"
WriteUninstaller "$INSTDIR\uninstall.exe"
!ifdef REG_START_MENU
!insertmacro MUI_STARTMENU_WRITE_BEGIN Application
CreateDirectory "$SMPROGRAMS\$SM_Folder"
CreateShortCut "$SMPROGRAMS\$SM_Folder\${APP_NAME}.lnk" "$INSTDIR\${MAIN_APP_EXE}"
CreateShortCut "$SMPROGRAMS\$SM_Folder\Uninstall ${APP_NAME}.lnk" "$INSTDIR\uninstall.exe"
!ifdef WEB_SITE
WriteIniStr "$INSTDIR\${APP_NAME} website.url" "InternetShortcut" "URL" "${WEB_SITE}"
CreateShortCut "$SMPROGRAMS\$SM_Folder\gta5view Website.lnk" "$INSTDIR\${APP_NAME} website.url"
!endif
!insertmacro MUI_STARTMENU_WRITE_END
!endif
!ifndef REG_START_MENU
CreateDirectory "$SMPROGRAMS\gta5view"
CreateShortCut "$SMPROGRAMS\gta5view\${APP_NAME}.lnk" "$INSTDIR\${MAIN_APP_EXE}"
CreateShortCut "$SMPROGRAMS\gta5view\Uninstall ${APP_NAME}.lnk" "$INSTDIR\uninstall.exe"
!ifdef WEB_SITE
WriteIniStr "$INSTDIR\${APP_NAME} website.url" "InternetShortcut" "URL" "${WEB_SITE}"
CreateShortCut "$SMPROGRAMS\gta5view\gta5view Website.lnk" "$INSTDIR\${APP_NAME} website.url"
!endif
!endif
WriteRegStr ${REG_ROOT} "${REG_APP_PATH}" "" "$INSTDIR\${MAIN_APP_EXE}"
WriteRegStr ${REG_ROOT} "${UNINSTALL_PATH}" "DisplayName" "${APP_NAME}"
WriteRegStr ${REG_ROOT} "${UNINSTALL_PATH}" "UninstallString" "$INSTDIR\uninstall.exe"
WriteRegStr ${REG_ROOT} "${UNINSTALL_PATH}" "DisplayIcon" "$INSTDIR\${MAIN_APP_EXE}"
WriteRegStr ${REG_ROOT} "${UNINSTALL_PATH}" "DisplayVersion" "${VERSION}"
WriteRegStr ${REG_ROOT} "${UNINSTALL_PATH}" "Publisher" "${COMP_NAME}"
!ifdef WEB_SITE
WriteRegStr ${REG_ROOT} "${UNINSTALL_PATH}" "URLInfoAbout" "${WEB_SITE}"
!endif
SectionEnd
######################################################################
Section Uninstall
${INSTALL_TYPE}
Delete "$INSTDIR\gta5view.exe"
Delete "$INSTDIR\libc++.dll"
Delete "$INSTDIR\libunwind.dll"
Delete "$INSTDIR\libcrypto-1_1-x64.dll"
Delete "$INSTDIR\libssl-1_1-x64.dll"
Delete "$INSTDIR\Qt5Core.dll"
Delete "$INSTDIR\Qt5Gui.dll"
Delete "$INSTDIR\Qt5Network.dll"
Delete "$INSTDIR\Qt5Svg.dll"
Delete "$INSTDIR\Qt5Widgets.dll"
Delete "$INSTDIR\Qt5WinExtras.dll"
Delete "$INSTDIR\lang\gta5sync_en_US.qm"
Delete "$INSTDIR\lang\gta5sync_de.qm"
Delete "$INSTDIR\lang\gta5sync_fr.qm"
Delete "$INSTDIR\lang\gta5sync_ko.qm"
Delete "$INSTDIR\lang\gta5sync_ru.qm"
Delete "$INSTDIR\lang\gta5sync_uk.qm"
Delete "$INSTDIR\lang\gta5sync_zh_TW.qm"
Delete "$INSTDIR\lang\qtbase_en_GB.qm"
Delete "$INSTDIR\lang\qtbase_de.qm"
Delete "$INSTDIR\lang\qtbase_fr.qm"
Delete "$INSTDIR\lang\qtbase_ko.qm"
Delete "$INSTDIR\lang\qtbase_ru.qm"
Delete "$INSTDIR\lang\qtbase_uk.qm"
Delete "$INSTDIR\lang\qtbase_zh_TW.qm"
Delete "$INSTDIR\imageformats\qgif.dll"
Delete "$INSTDIR\imageformats\qicns.dll"
Delete "$INSTDIR\imageformats\qico.dll"
Delete "$INSTDIR\imageformats\qjpeg.dll"
Delete "$INSTDIR\imageformats\qsvg.dll"
Delete "$INSTDIR\imageformats\qtga.dll"
Delete "$INSTDIR\imageformats\qtiff.dll"
Delete "$INSTDIR\imageformats\qwbmp.dll"
Delete "$INSTDIR\imageformats\qwebp.dll"
Delete "$INSTDIR\platforms\qwindows.dll"
Delete "$INSTDIR\styles\qcleanlooksstyle.dll"
Delete "$INSTDIR\styles\qplastiquestyle.dll"
Delete "$INSTDIR\styles\qwindowsvistastyle.dll"
RmDir "$INSTDIR\lang"
RmDir "$INSTDIR\imageformats"
RmDir "$INSTDIR\platforms"
RmDir "$INSTDIR\styles"
Delete "$INSTDIR\uninstall.exe"
!ifdef WEB_SITE
Delete "$INSTDIR\${APP_NAME} website.url"
!endif
RmDir "$INSTDIR"
!ifdef REG_START_MENU
!insertmacro MUI_STARTMENU_GETFOLDER "Application" $SM_Folder
Delete "$SMPROGRAMS\$SM_Folder\${APP_NAME}.lnk"
Delete "$SMPROGRAMS\$SM_Folder\Uninstall ${APP_NAME}.lnk"
!ifdef WEB_SITE
Delete "$SMPROGRAMS\$SM_Folder\gta5view Website.lnk"
!endif
RmDir "$SMPROGRAMS\$SM_Folder"
!endif
!ifndef REG_START_MENU
Delete "$SMPROGRAMS\gta5view\${APP_NAME}.lnk"
Delete "$SMPROGRAMS\gta5view\Uninstall ${APP_NAME}.lnk"
!ifdef WEB_SITE
Delete "$SMPROGRAMS\gta5view\gta5view Website.lnk"
!endif
RmDir "$SMPROGRAMS\gta5view"
!endif
DeleteRegKey ${REG_ROOT} "${REG_APP_PATH}"
DeleteRegKey ${REG_ROOT} "${UNINSTALL_PATH}"
SectionEnd
######################################################################
Function un.onInit
!insertmacro MUI_UNGETLANGUAGE
SetRegView 64
FunctionEnd
######################################################################

View File

@ -1,14 +0,0 @@
#!/bin/bash
# Creating folders
cd ${PROJECT_DIR} && \
echo "gta5view build version is ${APPLICATION_VERSION}" && \
echo "gta5view image name is gta5view-osx_${APPLICATION_VERSION}.dmg" && \
mkdir -p build && \
mkdir -p assets && \
cd build && \
/usr/local/opt/qt/bin/qmake ${QMAKE_FLAGS_QT5} ${QMAKE_BUILD_TYPE} "DEFINES+=GTA5SYNC_BUILDCODE=\\\\\\\"${PACKAGE_CODE}\\\\\\\"" "DEFINES+=GTA5SYNC_APPVER=\\\\\\\"${APPLICATION_VERSION}\\\\\\\"" "DEFINES+=GTA5SYNC_COMMIT=\\\\\\\"${APPLICATION_COMMIT}\\\\\\\"" DEFINES+=GTA5SYNC_TELEMETRY "DEFINES+=GTA5SYNC_TELEMETRY_WEBURL=\\\\\\\"https://dev.syping.de/gta5view-userstats/\\\\\\\"" ../gta5view.pro && \
make -j 4 && \
/usr/local/opt/qt/bin/macdeployqt gta5view.app -dmg && \
cp -Rf gta5view.dmg ../assets/gta5view-osx_${APPLICATION_VERSION}.dmg

View File

@ -1,8 +0,0 @@
#!/bin/bash
# Install packages
.ci/osx_install.sh && \
# Build gta5view
.ci/osx_build.sh && \
cd ${PROJECT_DIR}

View File

@ -1,4 +0,0 @@
#!/bin/bash
# Install packages
brew upgrade qt

View File

@ -1,26 +0,0 @@
#!/bin/bash
# Prepare environment variable
export GTA5VIEW_EXECUTABLE=gta5view-${EXECUTABLE_VERSION}${EXECUTABLE_ARCH}.exe && \
# Creating folders
cd ${PROJECT_DIR} && \
echo "gta5view build version is ${APPLICATION_VERSION}" && \
echo "gta5view executable is ${GTA5VIEW_EXECUTABLE}" && \
mkdir -p build && \
mkdir -p assets && \
# Starting build
cd build && \
mingw64-qt-cmake \
${CMAKE_BUILD_TYPE} \
"-DGTA5VIEW_BUILDCODE=${PACKAGE_CODE}" \
"-DGTA5VIEW_APPVER=${APPLICATION_VERSION}" \
"-DGTA5VIEW_COMMIT=${APPLICATION_COMMIT}" \
"-DWITH_TELEMETRY=ON" \
"-DTELEMETRY_WEBURL=https://dev.syping.de/gta5view-userstats/" \
.. && \
make -j 4 && \
x86_64-w64-mingw32-strip -s gta5view.exe && \
cp -Rf *.exe ${PROJECT_DIR}/assets/${GTA5VIEW_EXECUTABLE} && \
cd ${PROJECT_DIR}/assets

View File

@ -1,25 +0,0 @@
#!/bin/bash
DOCKER_IMAGE=sypingauto/gta5view-build:1.8-static
PROJECT_DIR_DOCKER=/gta5view
cd ${PROJECT_DIR} && \
docker pull ${DOCKER_IMAGE} && \
docker run --rm \
-v "${PROJECT_DIR}:${PROJECT_DIR_DOCKER}" \
${DOCKER_IMAGE} \
/bin/bash -c "export PROJECT_DIR=${PROJECT_DIR_DOCKER} && export QT_SELECT=${QT_SELECT} && export APPLICATION_VERSION=${APPLICATION_VERSION} && export APPLICATION_COMMIT=${APPLICATION_COMMIT} && export BUILD_TYPE=${BUILD_TYPE} && export QMAKE_FLAGS_QT4=${QMAKE_FLAGS_QT4} && export QMAKE_FLAGS_QT5=${QMAKE_FLAGS_QT5} && export CMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE} && export QMAKE_BUILD_TYPE=${QMAKE_BUILD_TYPE} && export PACKAGE_VERSION=${PACKAGE_VERSION} && export PACKAGE_BUILD=${PACKAGE_BUILD} && export PACKAGE_CODE=${PACKAGE_CODE} && export EXECUTABLE_VERSION=${EXECUTABLE_VERSION} && export EXECUTABLE_ARCH=${EXECUTABLE_ARCH} && cd ${PROJECT_DIR_DOCKER} && .ci/windows_build.sh" && \
# Prepare environment variable
export GTA5VIEW_EXECUTABLE=gta5view-${EXECUTABLE_VERSION}${EXECUTABLE_ARCH}.exe && \
# Upload Assets to Dropbox
if [ "${PACKAGE_CODE}" == "gta5-mods" ]; then
${PROJECT_DIR}/.ci/dropbox_uploader.sh mkdir gta5-mods/${PACKAGE_VERSION}
${PROJECT_DIR}/.ci/dropbox_uploader.sh upload ${PROJECT_DIR}/assets/${GTA5VIEW_EXECUTABLE} gta5-mods/${PACKAGE_VERSION}/${GTA5VIEW_EXECUTABLE} && \
rm -rf ${GTA5VIEW_EXECUTABLE}
elif [ "${PACKAGE_CODE}" == "gtainside" ]; then
${PROJECT_DIR}/.ci/dropbox_uploader.sh mkdir gtainside/${PACKAGE_VERSION}
${PROJECT_DIR}/.ci/dropbox_uploader.sh upload ${PROJECT_DIR}/assets/${GTA5VIEW_EXECUTABLE} gtainside/${PACKAGE_VERSION}/${GTA5VIEW_EXECUTABLE} && \
rm -rf ${GTA5VIEW_EXECUTABLE}
fi

View File

@ -1,27 +0,0 @@
#!/bin/bash
# Creating folders
cd ${PROJECT_DIR} && \
echo "gta5view build version is ${APPLICATION_VERSION}" && \
mkdir -p build && \
mkdir -p assets && \
# Starting build
cd build && \
mingw64-qt-cmake \
${CMAKE_BUILD_TYPE} \
"-DGTA5VIEW_BUILDCODE=${PACKAGE_CODE}" \
"-DGTA5VIEW_APPVER=${APPLICATION_VERSION}" \
"-DGTA5VIEW_COMMIT=${APPLICATION_COMMIT}" \
"-DWITH_TELEMETRY=ON" \
"-DTELEMETRY_WEBURL=https://dev.syping.de/gta5view-userstats/" \
"-DQCONF_BUILD=ON" \
"-DGTA5VIEW_INLANG=RUNDIR:SEPARATOR:lang" \
"-DGTA5VIEW_LANG=RUNDIR:SEPARATOR:lang" \
"-DGTA5VIEW_PLUG=RUNDIR:SEPARATOR:plugins" \
.. && \
make -j 4 && \
x86_64-w64-mingw32-strip -s gta5view.exe && \
cd ${PROJECT_DIR}/assets && \
makensis -NOCD ${PROJECT_DIR}/.ci/gta5view.nsi && \
mv -f gta5view_setup.exe gta5view-${EXECUTABLE_VERSION}_setup.exe

View File

@ -1,11 +0,0 @@
#!/bin/bash
DOCKER_IMAGE=sypingauto/gta5view-build:1.8-shared
PROJECT_DIR_DOCKER=/gta5view
cd ${PROJECT_DIR} && \
docker pull ${DOCKER_IMAGE} && \
docker run --rm \
-v "${PROJECT_DIR}:${PROJECT_DIR_DOCKER}" \
${DOCKER_IMAGE} \
/bin/bash -c "export PROJECT_DIR=${PROJECT_DIR_DOCKER} && export QT_SELECT=${QT_SELECT} && export APPLICATION_VERSION=${APPLICATION_VERSION} && export APPLICATION_COMMIT=${APPLICATION_COMMIT} && export BUILD_TYPE=${BUILD_TYPE} && export QMAKE_FLAGS_QT4=${QMAKE_FLAGS_QT4} && export QMAKE_FLAGS_QT5=${QMAKE_FLAGS_QT5} && export CMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE} && export QMAKE_BUILD_TYPE=${QMAKE_BUILD_TYPE} && export PACKAGE_VERSION=${PACKAGE_VERSION} && export PACKAGE_BUILD=${PACKAGE_BUILD} && export PACKAGE_CODE=${PACKAGE_CODE} && export EXECUTABLE_VERSION=${EXECUTABLE_VERSION} && export EXECUTABLE_ARCH=${EXECUTABLE_ARCH} && cd ${PROJECT_DIR_DOCKER} && .ci/wininstall_build.sh"

View File

@ -1,36 +0,0 @@
kind: pipeline
type: docker
environment:
BUILD_TYPE: "REL"
steps:
- name: Windows Installer
image: sypingauto/gta5view-build:1.8-shared
environment:
BUILD_SCRIPT: "wininstall_build.sh"
QT_SELECT: "qt5-x86_64-w64-mingw32"
TCA_PASS:
from_secret: tca_pass
commands:
- .drone/drone.sh
volumes:
- name: gta5view
path: /srv/gta5view
- name: Windows Portable
image: sypingauto/gta5view-build:1.8-static
environment:
BUILD_SCRIPT: "windows_build.sh"
QT_SELECT: "qt5-x86_64-w64-mingw32"
TCA_PASS:
from_secret: tca_pass
commands:
- .drone/drone.sh
volumes:
- name: gta5view
path: /srv/gta5view
volumes:
- name: gta5view
host:
path: /srv/gta5view

View File

@ -1,33 +0,0 @@
#!/bin/bash
# Cleanup previous Drone build
if [ -d "assets" ]; then
rm -rf assets
fi
if [ -d "build" ]; then
rm -rf build
fi
# Decrypt Telemetry Authenticator
rm -rf tmext/TelemetryClassAuthenticator.cpp && \
openssl aes-256-cbc -k ${TCA_PASS} -in .drone/TelemetryClassAuthenticator.cpp.enc -out tmext/TelemetryClassAuthenticator.cpp -d -pbkdf2
# Check if build is not tagged
if [ "${DRONE_TAG}" == "" ]; then
export EXECUTABLE_TAG=-$(git rev-parse --short HEAD)
else
export EXECUTABLE_TAG=
fi
# Check if package code is not set
if [ "${PACKAGE_CODE}" == "" ]; then
export PACKAGE_CODE=Drone
fi
# Init Application Commit Hash
export APPLICATION_COMMIT=$(git rev-parse --short HEAD)
# Start CI script and copying assets into gta5view directory
.ci/ci.sh && \
mkdir -p /srv/gta5view/${APPLICATION_COMMIT} && \
cp -Rf assets/* /srv/gta5view/${APPLICATION_COMMIT}/

View File

@ -1,20 +0,0 @@
app-id: de.syping.gta5view
runtime: org.kde.Platform
runtime-version: '5.15'
sdk: org.kde.Sdk
command: gta5view
finish-args:
- --share=network
- --share=ipc
- --socket=fallback-x11
- --socket=wayland
- --device=dri
modules:
- name: gta5view
buildsystem: cmake-ninja
config-opts:
- -DFLATPAK_BUILD=ON
- -DQCONF_BUILD=ON
sources:
- type: dir
path: ../

28
.gitattributes vendored
View File

@ -1,28 +0,0 @@
# Auto detect text files and perform LF normalization
* text=auto eol=lf
# Development files
*.cpp text eol=lf
*.h text eol=lf
*.ui text eol=lf
*.qrc text eol=lf
# Development resources
*.ini text eol=lf
# Linux development files
*.desktop text eol=lf
# Windows development files
*.rc text eol=crlf
*.nsi text eol=crlf
*.exe.manifest text eol=crlf
# Binary files
*.png binary
*.jpg binary
*.qm binary
*.ico binary
*.icns binary
*.xcf binary
*.g5e binary

4
.gitignore vendored
View File

@ -29,7 +29,3 @@
# Qt project user file
*.pro.user
# Gettext translation files
*.po
*.pot

View File

@ -1,31 +0,0 @@
stages:
- build
variables:
BUILD_TYPE: "REL"
Windows Installer:
stage: build
image: sypingauto/gta5view-build:1.8-shared
variables:
BUILD_SCRIPT: "wininstall_build.sh"
QT_SELECT: "qt5-x86_64-w64-mingw32"
script:
- .gitlab/gitlab.sh
artifacts:
name: "gta5view-$CI_COMMIT_REF_NAME-${CI_COMMIT_SHA:0:8}_setup"
paths:
- "gta5view-*.exe"
Windows Portable:
stage: build
image: sypingauto/gta5view-build:1.8-static
variables:
BUILD_SCRIPT: "windows_build.sh"
QT_SELECT: "qt5-x86_64-w64-mingw32"
script:
- .gitlab/gitlab.sh
artifacts:
name: "gta5view-$CI_COMMIT_REF_NAME-${CI_COMMIT_SHA:0:8}_portable"
paths:
- "gta5view-*.exe"

View File

@ -1,24 +0,0 @@
#!/bin/bash
# Decrypt Telemetry Authenticator
rm -rf tmext/TelemetryClassAuthenticator.cpp && \
openssl aes-256-cbc -k ${tca_pass} -in .gitlab/TelemetryClassAuthenticator.cpp.enc -out tmext/TelemetryClassAuthenticator.cpp -d
# Check if build is not tagged
if [ "${CI_COMMIT_TAG}" == "" ]; then
export EXECUTABLE_TAG=-$(git rev-parse --short HEAD)
else
export EXECUTABLE_TAG=
fi
# Check if package code is not set
if [ "${PACKAGE_CODE}" == "" ]; then
export PACKAGE_CODE=GitLab
fi
# Init Application Commit Hash
export APPLICATION_COMMIT=$(git rev-parse --short HEAD)
# Start CI script and copying assets into base directory
.ci/ci.sh && \
cp -Rf assets/* ./

View File

@ -1,59 +1,38 @@
dist: bionic
dist: trusty
sudo: required
language: cpp
service:
- docker
env:
global:
- BUILD_TYPE=REL
matrix:
include:
- env:
- BUILD_SCRIPT=debian_docker.sh
- RELEASE_LABEL="Debian 64-Bit Package"
- DEBIAN_VERSION=stretch
- DOCKER_USER=amd64
- APT_INSTALL=clang
- env:
- BUILD_SCRIPT=windows_docker.sh
- QT_SELECT=qt5-x86_64-w64-mingw32
- RELEASE_LABEL="Windows 64-Bit Portable"
- env:
- BUILD_SCRIPT=windows_docker.sh
- QT_SELECT=qt5-x86_64-w64-mingw32
- RELEASE_LABEL="Windows 64-Bit Portable for gta5-mods"
- PACKAGE_CODE=gta5-mods
- env:
- BUILD_SCRIPT=windows_docker.sh
- QT_SELECT=qt5-x86_64-w64-mingw32
- RELEASE_LABEL="Windows 64-Bit Portable for gtainside"
- PACKAGE_CODE=gtainside
- env:
- BUILD_SCRIPT=wininstall_docker.sh
- QT_SELECT=qt5-x86_64-w64-mingw32
- RELEASE_LABEL="Windows 64-Bit Installer"
- os: osx
env:
- BUILD_SCRIPT=osx_ci.sh
- RELEASE_LABEL="Mac OS X 64-Bit Disk Image"
- PACKAGE_VERSION="0.1.0"
before_install:
- ".travis/source.sh"
- test -n $CC && unset CC
- test -n $CXX && unset CXX
install:
- sudo apt-get update -qq
- sudo apt-get install -qq checkinstall dpkg-dev g++ gcc qtbase5-dev qt5-qmake
before_script:
- export INSTALL_ROOT=/usr
- if [ `git name-rev --tags --name-only $(git rev-parse HEAD)` == "undefined" ]; then export APPLICATION_VERSION="$PACKAGE_VERSION.$TRAVIS_BUILD_NUMBER"; else export APPLICATION_VERSION=`git name-rev --tags --name-only $(git rev-parse HEAD)`; fi
- echo "gta5view build version is $APPLICATION_VERSION"
- mkdir build
- mkdir package
- cd build
- echo "Grand Theft Auto V Snapmatic and Savegame viewer" > ./description-pak
script:
- ".travis/travis.sh"
- qmake -qt=5 "DEFINES+=GTA5SYNC_BUILDTYPE=\\\\\\\"Release\\\\\\\"" "DEFINES+=GTA5SYNC_DAILYB=\\\\\\\"$APPLICATION_VERSION\\\\\\\"" ../gta5view.pro
- make -j 4
- sudo checkinstall -D --default --nodoc --pkgname=gta5view --pkgversion=$APPLICATION_VERSION --pkgrelease=travis1 --pkggroup=utility --maintainer="Syping on Travis \<travisci@syping.de\>" --requires=libqt5core5a,libqt5gui5,libqt5network5,libqt5widgets5 --pakdir=../package
deploy:
provider: releases
api_key:
secure: o7VneEz1aHfdVwZvOZLfopf6uJWNrFsZaBvunTmXFzpmNFhlNS1qwqgMUkIA2yBRbZ3wIzVs4vfwIHv7W9yE/PqK+AYL+R8+AwKGrwlgT4HqJNuk6VM/LNJ6GwT/qkQuaoOVw29bUjmzzgIRdHmw53SlJv6Hh1VE8HphlTT//aex6nCfcFhUZ0BETdZDWz5FSHwL3NalUoqfKfQrJeky5RXzCyCANQC2tKt0bV46GaWIgWrDo2KCTNqPtRWWf5GDmnkXE5IYRMQ3mXvO9iYh0v5Y2jo4PiXGUiFUU6Z3aAWFAiPdGclrBO697cf3lCTzDMhuCETR153qFYsLShUlFf61ITAmCeHAWETjZDri0lmPONo3GoNB6alGfYEA51qw14kXakrTpICtTJj7gw/gtUYOabW6hrzmieNzMBIy62RikDPjyakFnuwW2qNHRlD65e0jYv+6nCpb6E+OV16Ysh1zhV2vTfpfzVmSuyu2J+ELqXD3OZCXRSPpDIih9UQ8335p8FBji6jHORcgym/TRgdgRmENibh8tLzWp+UjpWHuWfcpvZgOskjfwU0iDMCayMJ7tDpOhXHcAhDRnd6XRIiOJ5YZCzflj2nEwmt3YUd7DwXS/AU+WHOmcNQBjXBxF/FJa35XXcy3HKJM5TTKqtph3medo30us5yXHeG6NNg=
label: ${RELEASE_LABEL}
file_glob: true
file: assets/*
secure: "o7VneEz1aHfdVwZvOZLfopf6uJWNrFsZaBvunTmXFzpmNFhlNS1qwqgMUkIA2yBRbZ3wIzVs4vfwIHv7W9yE/PqK+AYL+R8+AwKGrwlgT4HqJNuk6VM/LNJ6GwT/qkQuaoOVw29bUjmzzgIRdHmw53SlJv6Hh1VE8HphlTT//aex6nCfcFhUZ0BETdZDWz5FSHwL3NalUoqfKfQrJeky5RXzCyCANQC2tKt0bV46GaWIgWrDo2KCTNqPtRWWf5GDmnkXE5IYRMQ3mXvO9iYh0v5Y2jo4PiXGUiFUU6Z3aAWFAiPdGclrBO697cf3lCTzDMhuCETR153qFYsLShUlFf61ITAmCeHAWETjZDri0lmPONo3GoNB6alGfYEA51qw14kXakrTpICtTJj7gw/gtUYOabW6hrzmieNzMBIy62RikDPjyakFnuwW2qNHRlD65e0jYv+6nCpb6E+OV16Ysh1zhV2vTfpfzVmSuyu2J+ELqXD3OZCXRSPpDIih9UQ8335p8FBji6jHORcgym/TRgdgRmENibh8tLzWp+UjpWHuWfcpvZgOskjfwU0iDMCayMJ7tDpOhXHcAhDRnd6XRIiOJ5YZCzflj2nEwmt3YUd7DwXS/AU+WHOmcNQBjXBxF/FJa35XXcy3HKJM5TTKqtph3medo30us5yXHeG6NNg="
file: "../package/gta5view_$APPLICATION_VERSION-travis1_amd64.deb"
skip_cleanup: true
on:
tags: true

View File

@ -1 +0,0 @@
Poァ鏖<EFBFBD>劾ラ<作1x」%几<>ャネw|RtZv<>kホ銓顴Z肄2チ廁湮ォ`<1A>,4vヨマ・@€<>ヲeハ・~U$+<2B><>€<EFBFBD><1A><牾&蓬熙

View File

@ -1,5 +0,0 @@
#!/bin/bash
rm -rf tmext/TelemetryClassAuthenticator.cpp && \
openssl aes-256-cbc -K $encrypted_db000a5d87d6_key -iv $encrypted_db000a5d87d6_iv -in .travis/TelemetryClassAuthenticator.cpp.enc -out tmext/TelemetryClassAuthenticator.cpp -d && \
openssl aes-256-cbc -K $encrypted_d57e7d2f8877_key -iv $encrypted_d57e7d2f8877_iv -in .travis/dropbox_uploader.enc -out ~/.dropbox_uploader -d

View File

@ -1,27 +0,0 @@
#!/bin/bash
# Install lua
if [ "${TRAVIS_OS_NAME}" == "osx" ]; then
brew install lua
else
sudo apt-get update -qq && \
sudo apt-get install -qq lua5.2
fi
# Check if build is not tagged
if [ "${TRAVIS_TAG}" == "" ]; then
export EXECUTABLE_TAG=-$(git rev-parse --short HEAD)
else
export EXECUTABLE_TAG=
fi
# Check if package code is not set
if [ "${PACKAGE_CODE}" == "" ]; then
export PACKAGE_CODE=GitHub
fi
# Init Application Commit Hash
export APPLICATION_COMMIT=$(git rev-parse --short HEAD)
# Start CI script
.ci/ci.sh

View File

@ -1,8 +0,0 @@
#!/bin/bash
# Install packages
sudo .ci/debian_install.sh && \
# Build gta5view
sudo .ci/debian_build.sh && \
cd ${PROJECT_DIR}

188
AboutDialog.cpp Normal file → Executable file
View File

@ -1,135 +1,53 @@
/*****************************************************************************
* gta5view Grand Theft Auto V Profile Viewer
* Copyright (C) 2016-2019 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 <QDesktopServices>
#include <QStringBuilder>
#include <QMessageBox>
#include "AboutDialog.h"
#include "ui_AboutDialog.h"
#include "AppEnv.h"
#include "config.h"
AboutDialog::AboutDialog(QWidget *parent) :
QDialog(parent),
ui(new Ui::AboutDialog)
{
// Set Window Flags
setWindowFlags(windowFlags()^Qt::WindowContextHelpButtonHint);
// Build Strings
QString appVersion = qApp->applicationVersion();
QString buildType = tr(GTA5SYNC_BUILDTYPE);
buildType.replace("_", " ");
QString projectBuild = AppEnv::getBuildDateTime();
QString buildStr = GTA5SYNC_BUILDSTRING;
#ifndef GTA5SYNC_BUILDTYPE_REL
#ifdef GTA5SYNC_COMMIT
if (!appVersion.contains("-")) { appVersion = appVersion % "-" % GTA5SYNC_COMMIT; }
#endif
#endif
// Translator Comments
//: Translated by translator, example Translated by Syping
QString translatedByStr = tr("Translated by %1");
//: Insert your name here and profile here in following scheme, First Translator,First Profile\\nSecond Translator\\nThird Translator,Second Profile
QString translatorVal = tr("TRANSLATOR");
QStringList translatorContent;
if (translatorVal != "TRANSLATOR")
{
const QStringList translatorList = translatorVal.split('\n');
for (const QString &translatorStr : translatorList)
{
QStringList translatorStrList = translatorStr.split(',');
QString translatorName = translatorStrList.at(0);
translatorStrList.removeFirst();
QString translatorProfile = translatorStrList.join(QString());
if (!translatorProfile.isEmpty())
{
translatorContent += QString("<a href=\"%1\">%2</a>").arg(translatorProfile, translatorName);
}
else
{
translatorContent += translatorName;
}
}
}
// Project Description
QString projectDes = tr("A project for viewing Grand Theft Auto V Snapmatic<br/>\nPictures and Savegames");
// Copyright Description
QString copyrightDes1 = tr("Copyright &copy; <a href=\"%1\">%2</a> %3");
copyrightDes1 = copyrightDes1.arg(GTA5SYNC_APPVENDORLINK, GTA5SYNC_APPVENDOR, GTA5SYNC_COPYRIGHT);
QString copyrightDes2 = tr("%1 is licensed under <a href=\"https://www.gnu.org/licenses/gpl-3.0.html#content\">GNU GPLv3</a>");
copyrightDes2 = copyrightDes2.arg(GTA5SYNC_APPSTR);
QString copyrightDesA;
if (!translatorContent.isEmpty())
{
copyrightDesA = copyrightDes1 % "<br/>" % translatedByStr.arg(translatorContent.join(", ")) % "<br/>" % copyrightDes2;
}
else
{
copyrightDesA = copyrightDes1 % "<br/>" % copyrightDes2;
}
// Setup User Interface
ui->setupUi(this);
aboutStr = ui->labAbout->text();
titleStr = this->windowTitle();
ui->labAbout->setText(aboutStr.arg(GTA5SYNC_APPSTR, projectDes, appVersion % " (" % buildType % ")", projectBuild, buildStr, qVersion(), copyrightDesA));
this->setWindowTitle(titleStr.arg(GTA5SYNC_APPSTR));
// Set Icon for Close Button
if (QIcon::hasThemeIcon("dialog-close"))
{
ui->cmdClose->setIcon(QIcon::fromTheme("dialog-close"));
}
else if (QIcon::hasThemeIcon("gtk-close"))
{
ui->cmdClose->setIcon(QIcon::fromTheme("gtk-close"));
}
// DPI calculation
qreal screenRatio = AppEnv::screenRatio();
if (!translatorContent.isEmpty())
{
resize(375 * screenRatio, 270 * screenRatio);
}
else
{
resize(375 * screenRatio, 260 * screenRatio);
}
}
AboutDialog::~AboutDialog()
{
delete ui;
}
void AboutDialog::on_labAbout_linkActivated(const QString &link)
{
if (link.left(12) == "g5e://about?")
{
QStringList aboutStrList = QString(link).remove(0, 12).split(":");
QMessageBox::information(this, QString::fromUtf8(QByteArray::fromBase64(aboutStrList.at(0).toUtf8())), QString::fromUtf8(QByteArray::fromBase64(aboutStrList.at(1).toUtf8())));
}
else
{
QDesktopServices::openUrl(QUrl(link));
}
}
/*****************************************************************************
* 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 <QStringBuilder>
#include "AboutDialog.h"
#include "ui_AboutDialog.h"
#include "config.h"
AboutDialog::AboutDialog(QWidget *parent) :
QDialog(parent),
ui(new Ui::AboutDialog)
{
ui->setupUi(this);
aboutStr = ui->labAbout->text();
titleStr = this->windowTitle();
QString appVersion = qApp->applicationVersion();
QString buildType = GTA5SYNC_BUILDTYPE;
buildType.replace("_", " ");
QString projectBuild = GTA5SYNC_BUILDDATETIME;
QString buildStr = GTA5SYNC_BUILDSTRING;
#ifdef GTA5SYNC_ENABLED
QString projectDes = tr("A project for viewing and sync Grand Theft Auto V Snapmatic<br/>\nPictures and Savegames");
#else
QString projectDes = tr("A project for viewing Grand Theft Auto V Snapmatic<br/>\nPictures and Savegames");
#endif
ui->labAbout->setText(aboutStr.arg(appVersion % " (" % buildType % ")", buildStr, qVersion(), projectBuild, GTA5SYNC_APPVENDORLINK, GTA5SYNC_APPVENDOR, GTA5SYNC_COPYRIGHT, GTA5SYNC_APPSTR, projectDes));
this->setWindowTitle(titleStr.arg(GTA5SYNC_APPSTR));
if (QIcon::hasThemeIcon("dialog-close"))
{
ui->cmdClose->setIcon(QIcon::fromTheme("dialog-close"));
}
}
AboutDialog::~AboutDialog()
{
delete ui;
}

89
AboutDialog.h Normal file → Executable file
View File

@ -1,45 +1,44 @@
/*****************************************************************************
* gta5view Grand Theft Auto V Profile Viewer
* 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 ABOUTDIALOG_H
#define ABOUTDIALOG_H
#include <QDialog>
namespace Ui {
class AboutDialog;
}
class AboutDialog : public QDialog
{
Q_OBJECT
public:
explicit AboutDialog(QWidget *parent = 0);
~AboutDialog();
private slots:
void on_labAbout_linkActivated(const QString &link);
private:
Ui::AboutDialog *ui;
QString aboutStr;
QString titleStr;
};
#endif // ABOUTDIALOG_H
/*****************************************************************************
* 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 ABOUTDIALOG_H
#define ABOUTDIALOG_H
#include <QDialog>
namespace Ui {
class AboutDialog;
}
class AboutDialog : public QDialog
{
Q_OBJECT
public:
explicit AboutDialog(QWidget *parent = 0);
~AboutDialog();
private slots:
private:
Ui::AboutDialog *ui;
QString aboutStr;
QString titleStr;
};
#endif // ABOUTDIALOG_H

204
AboutDialog.ui Normal file → Executable file
View File

@ -1,102 +1,102 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>AboutDialog</class>
<widget class="QDialog" name="AboutDialog">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>375</width>
<height>260</height>
</rect>
</property>
<property name="windowTitle">
<string>About %1</string>
</property>
<property name="modal">
<bool>true</bool>
</property>
<layout class="QVBoxLayout" name="vlAbout">
<item>
<widget class="QLabel" name="labAbout">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Expanding">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>&lt;span style=&quot; font-weight:600;&quot;&gt;%1&lt;/span&gt;&lt;br/&gt;
&lt;br/&gt;
%2&lt;br/&gt;
&lt;br/&gt;
Version %3&lt;br/&gt;
Created on %4&lt;br/&gt;
Built with Qt %5&lt;br/&gt;
Running with Qt %6&lt;br/&gt;
&lt;br/&gt;
%7</string>
</property>
<property name="alignment">
<set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop</set>
</property>
<property name="wordWrap">
<bool>false</bool>
</property>
<property name="textInteractionFlags">
<set>Qt::LinksAccessibleByKeyboard|Qt::LinksAccessibleByMouse</set>
</property>
</widget>
</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>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QPushButton" name="cmdClose">
<property name="sizePolicy">
<sizepolicy hsizetype="Minimum" vsizetype="Minimum">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>&amp;Close</string>
</property>
</widget>
</item>
</layout>
</item>
</layout>
</widget>
<resources/>
<connections>
<connection>
<sender>cmdClose</sender>
<signal>clicked()</signal>
<receiver>AboutDialog</receiver>
<slot>close()</slot>
<hints>
<hint type="sourcelabel">
<x>327</x>
<y>228</y>
</hint>
<hint type="destinationlabel">
<x>187</x>
<y>124</y>
</hint>
</hints>
</connection>
</connections>
</ui>
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>AboutDialog</class>
<widget class="QDialog" name="AboutDialog">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>375</width>
<height>260</height>
</rect>
</property>
<property name="windowTitle">
<string>About %1</string>
</property>
<property name="modal">
<bool>true</bool>
</property>
<layout class="QVBoxLayout" name="vlAbout">
<item>
<widget class="QLabel" name="labAbout">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Expanding">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>&lt;span style=&quot; font-weight:600;&quot;&gt;%8&lt;/span&gt;&lt;br/&gt;
&lt;br/&gt;
%9&lt;br/&gt;
&lt;br/&gt;
Project version: %1&lt;br/&gt;
Project build: %4&lt;br/&gt;
Compiled with Qt %2&lt;br/&gt;
Running with Qt %3&lt;br/&gt;
&lt;br/&gt;
Copyright &amp;copy; &lt;a href=&quot;%5&quot;&gt;%6&lt;/a&gt; %7&lt;br/&gt;%8 is licensed under &lt;a href=&quot;https://www.gnu.org/licenses/gpl-3.0.html#content&quot;&gt;GNU GPLv3&lt;/a&gt;</string>
</property>
<property name="alignment">
<set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop</set>
</property>
<property name="wordWrap">
<bool>false</bool>
</property>
<property name="openExternalLinks">
<bool>true</bool>
</property>
</widget>
</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>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QPushButton" name="cmdClose">
<property name="sizePolicy">
<sizepolicy hsizetype="Minimum" vsizetype="Minimum">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>&amp;Close</string>
</property>
</widget>
</item>
</layout>
</item>
</layout>
</widget>
<resources/>
<connections>
<connection>
<sender>cmdClose</sender>
<signal>clicked()</signal>
<receiver>AboutDialog</receiver>
<slot>close()</slot>
<hints>
<hint type="sourcelabel">
<x>327</x>
<y>228</y>
</hint>
<hint type="destinationlabel">
<x>187</x>
<y>124</y>
</hint>
</hints>
</connection>
</connections>
</ui>

661
AppEnv.cpp Normal file → Executable file
View File

@ -1,524 +1,137 @@
/*****************************************************************************
* gta5view Grand Theft Auto V Profile Viewer
* Copyright (C) 2016-2020 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 "config.h"
#include "AppEnv.h"
#include "StringParser.h"
#include "StandardPaths.h"
#include <QtGlobal>
#include <QStringBuilder>
#include <QApplication>
#include <QSettings>
#include <QScreen>
#include <QDebug>
#include <QRect>
#include <QDir>
#if QT_VERSION < 0x050000
#include <QDesktopWidget>
#endif
#include <iostream>
using namespace std;
AppEnv::AppEnv()
{
}
// Build Stuff
QString AppEnv::getBuildDateTime()
{
return GTA5SYNC_BUILDDATETIME;
}
QString AppEnv::getBuildCode()
{
return GTA5SYNC_BUILDCODE;
}
// Folder Stuff
QString AppEnv::getGameFolder(bool *ok)
{
QDir dir;
QString GTAV_FOLDER = QString::fromUtf8(qgetenv("GTAV_FOLDER"));
if (GTAV_FOLDER != "")
{
dir.setPath(GTAV_FOLDER);
if (dir.exists())
{
if (ok != NULL) *ok = true;
qputenv("GTAV_FOLDER", dir.absolutePath().toUtf8());
return dir.absolutePath();
}
}
QString GTAV_defaultFolder = StandardPaths::documentsLocation() % QDir::separator() % "Rockstar Games" % QDir::separator() % "GTA V";
QString GTAV_returnFolder = GTAV_defaultFolder;
QSettings settings(GTA5SYNC_APPVENDOR, GTA5SYNC_APPSTR);
settings.beginGroup("dir");
bool forceDir = settings.value("force", false).toBool();
GTAV_returnFolder = settings.value("dir", GTAV_defaultFolder).toString();
settings.endGroup();
if (forceDir)
{
dir.setPath(GTAV_returnFolder);
if (dir.exists())
{
if (ok != 0) *ok = true;
qputenv("GTAV_FOLDER", dir.absolutePath().toUtf8());
return dir.absolutePath();
}
}
dir.setPath(GTAV_defaultFolder);
if (dir.exists())
{
if (ok != 0) *ok = true;
qputenv("GTAV_FOLDER", dir.absolutePath().toUtf8());
return dir.absolutePath();
}
if (!forceDir)
{
dir.setPath(GTAV_returnFolder);
if (dir.exists())
{
if (ok != 0) *ok = true;
qputenv("GTAV_FOLDER", dir.absolutePath().toUtf8());
return dir.absolutePath();
}
}
if (ok != 0) *ok = false;
return "";
}
bool AppEnv::setGameFolder(QString gameFolder)
{
QDir dir;
dir.setPath(gameFolder);
if (dir.exists())
{
qputenv("GTAV_FOLDER", dir.absolutePath().toUtf8());
return true;
}
return false;
}
QString AppEnv::getExLangFolder()
{
return StringParser::convertBuildedString(GTA5SYNC_LANG);
}
QString AppEnv::getInLangFolder()
{
#ifdef GTA5SYNC_QCONF
#ifdef GTA5SYNC_INLANG
return StringParser::convertBuildedString(GTA5SYNC_INLANG);
#else
return StringParser::convertBuildedString(GTA5SYNC_SHARE % QLatin1String("SEPARATOR:APPNAME:SEPARATOR:translations"));
#endif
#else
#ifdef GTA5SYNC_INLANG
return StringParser::convertBuildedString(GTA5SYNC_INLANG);
#else
return QString(":/tr");
#endif
#endif
}
QString AppEnv::getPluginsFolder()
{
return StringParser::convertBuildedString(GTA5SYNC_PLUG);
}
// Web Stuff
QByteArray AppEnv::getUserAgent()
{
#if QT_VERSION >= 0x050400
#ifdef Q_OS_WIN
QString kernelVersion = QSysInfo::kernelVersion();
const QStringList &kernelVersionList = kernelVersion.split(".");
if (kernelVersionList.length() > 2)
{
kernelVersion = kernelVersionList.at(0) % "." % kernelVersionList.at(1);
}
QString runArch = QSysInfo::buildCpuArchitecture();
if (runArch == "x86_64")
{
runArch = "Win64; x64";
}
else if (runArch == "i686")
{
const QString &curArch = QSysInfo::currentCpuArchitecture();
if (curArch == "x86_64")
{
runArch = "WOW64";
}
else if (curArch == "i686")
{
runArch = "Win32; x86";
}
}
return QString("Mozilla/5.0 (Windows NT %1; %2) %3/%4").arg(kernelVersion, runArch, GTA5SYNC_APPSTR, GTA5SYNC_APPVER).toUtf8();
#else
return QString("Mozilla/5.0 (%1; %2) %3/%4").arg(QSysInfo::kernelType(), QSysInfo::kernelVersion(), GTA5SYNC_APPSTR, GTA5SYNC_APPVER).toUtf8();
#endif
#else
return QString("Mozilla/5.0 %1/%2").arg(GTA5SYNC_APPSTR, GTA5SYNC_APPVER).toUtf8();
#endif
}
// QUrl AppEnv::getCrewFetchingUrl(QString crewID)
// {
// return QUrl(QString("https://socialclub.rockstargames.com/reference/crewfeed/%1").arg(crewID));
// }
QUrl AppEnv::getCrewFetchingUrl(QString crewID)
{
return QUrl(QString("https://socialclub.rockstargames.com/crew/%1/%1").arg(crewID));
}
QUrl AppEnv::getPlayerFetchingUrl(QString crewID, QString pageNumber)
{
return QUrl(QString("https://socialclub.rockstargames.com/crewsapi/GetMembersList?crewId=%1&pageNumber=%2&pageSize=5000").arg(crewID, pageNumber));
}
QUrl AppEnv::getPlayerFetchingUrl(QString crewID, int pageNumber)
{
return getPlayerFetchingUrl(crewID, QString::number(pageNumber));
}
// Game Stuff
GameVersion AppEnv::getGameVersion()
{
#ifdef Q_OS_WIN
QString argumentValue;
#ifdef _WIN64
argumentValue = "\\WOW6432Node";
#endif
QSettings registrySettingsSc(QString("HKEY_LOCAL_MACHINE\\SOFTWARE%1\\Rockstar Games\\Grand Theft Auto V").arg(argumentValue), QSettings::NativeFormat);
QString installFolderSc = registrySettingsSc.value("InstallFolder", "").toString();
QDir installFolderScDir(installFolderSc);
bool scVersionInstalled = false;
if (!installFolderSc.isEmpty() && installFolderScDir.exists())
{
#ifdef GTA5SYNC_DEBUG
qDebug() << "gameVersionFoundSocialClubVersion";
#endif
scVersionInstalled = true;
}
QSettings registrySettingsSteam(QString("HKEY_LOCAL_MACHINE\\SOFTWARE%1\\Rockstar Games\\GTAV").arg(argumentValue), QSettings::NativeFormat);
QString installFolderSteam = registrySettingsSteam.value("installfoldersteam", "").toString();
if (installFolderSteam.right(5) == "\\GTAV")
{
installFolderSteam = installFolderSteam.remove(installFolderSteam.length() - 5, 5);
}
QDir installFolderSteamDir(installFolderSteam);
bool steamVersionInstalled = false;
if (!installFolderSteam.isEmpty() && installFolderSteamDir.exists())
{
#ifdef GTA5SYNC_DEBUG
qDebug() << "gameVersionFoundSteamVersion";
#endif
steamVersionInstalled = true;
}
if (scVersionInstalled && steamVersionInstalled)
{
return GameVersion::BothVersions;
}
else if (scVersionInstalled)
{
return GameVersion::SocialClubVersion;
}
else if (steamVersionInstalled)
{
return GameVersion::SteamVersion;
}
else
{
return GameVersion::NoVersion;
}
#else
return GameVersion::NoVersion;
#endif
}
GameLanguage AppEnv::getGameLanguage(GameVersion gameVersion)
{
if (gameVersion == GameVersion::SocialClubVersion)
{
#ifdef Q_OS_WIN
QString argumentValue;
#ifdef _WIN64
argumentValue = "\\WOW6432Node";
#endif
QSettings registrySettingsSc(QString("HKEY_LOCAL_MACHINE\\SOFTWARE%1\\Rockstar Games\\Grand Theft Auto V").arg(argumentValue), QSettings::NativeFormat);
QString languageSc = registrySettingsSc.value("Language", "").toString();
return gameLanguageFromString(languageSc);
#else
return GameLanguage::Undefined;
#endif
}
else if (gameVersion == GameVersion::SteamVersion)
{
#ifdef Q_OS_WIN
QString argumentValue;
#ifdef _WIN64
argumentValue = "\\WOW6432Node";
#endif
QSettings registrySettingsSteam(QString("HKEY_LOCAL_MACHINE\\SOFTWARE%1\\Rockstar Games\\Grand Theft Auto V Steam").arg(argumentValue), QSettings::NativeFormat);
QString languageSteam = registrySettingsSteam.value("Language", "").toString();
return gameLanguageFromString(languageSteam);
#else
return GameLanguage::Undefined;
#endif
}
else
{
return GameLanguage::Undefined;
}
}
GameLanguage AppEnv::gameLanguageFromString(QString gameLanguage)
{
if (gameLanguage == "en-US")
{
return GameLanguage::English;
}
else if (gameLanguage == "fr-FR")
{
return GameLanguage::French;
}
else if (gameLanguage == "it-IT")
{
return GameLanguage::Italian;
}
else if (gameLanguage == "de-DE")
{
return GameLanguage::German;
}
else if (gameLanguage == "es-ES")
{
return GameLanguage::Spanish;
}
else if (gameLanguage == "es-MX")
{
return GameLanguage::Mexican;
}
else if (gameLanguage == "pt-BR")
{
return GameLanguage::Brasilian;
}
else if (gameLanguage == "ru-RU")
{
return GameLanguage::Russian;
}
else if (gameLanguage == "pl-PL")
{
return GameLanguage::Polish;
}
else if (gameLanguage == "ja-JP")
{
return GameLanguage::Japanese;
}
else if (gameLanguage == "zh-CHS")
{
return GameLanguage::SChinese;
}
else if (gameLanguage == "zh-CHT")
{
return GameLanguage::TChinese;
}
else if (gameLanguage == "ko-KR")
{
return GameLanguage::Koreana;
}
else
{
return GameLanguage::Undefined;
}
}
QString AppEnv::gameLanguageToString(GameLanguage gameLanguage)
{
if (gameLanguage == GameLanguage::English)
{
return "en-US";
}
else if (gameLanguage == GameLanguage::French)
{
return "fr-FR";
}
else if (gameLanguage == GameLanguage::Italian)
{
return "it-IT";
}
else if (gameLanguage == GameLanguage::German)
{
return "de-DE";
}
else if (gameLanguage == GameLanguage::Spanish)
{
return "es-ES";
}
else if (gameLanguage == GameLanguage::Mexican)
{
return "es-MX";
}
else if (gameLanguage == GameLanguage::Brasilian)
{
return "pt-BR";
}
else if (gameLanguage == GameLanguage::Russian)
{
return "ru-RU";
}
else if (gameLanguage == GameLanguage::Polish)
{
return "pl-PL";
}
else if (gameLanguage == GameLanguage::Japanese)
{
return "ja-JP";
}
else if (gameLanguage == GameLanguage::SChinese)
{
return "zh-CHS";
}
else if (gameLanguage == GameLanguage::TChinese)
{
return "zh-CHT";
}
else if (gameLanguage == GameLanguage::Koreana)
{
return "ko-KR";
}
else
{
return "Undefinied";
}
}
bool AppEnv::setGameLanguage(GameVersion gameVersion, GameLanguage gameLanguage)
{
bool socialClubVersion = false;
bool steamVersion = false;
if (gameVersion == GameVersion::SocialClubVersion)
{
socialClubVersion = true;
}
else if (gameVersion == GameVersion::SteamVersion)
{
steamVersion = true;
}
else if (gameVersion == GameVersion::BothVersions)
{
socialClubVersion = true;
steamVersion = true;
}
else
{
return false;
}
if (socialClubVersion)
{
#ifdef Q_OS_WIN
QString argumentValue;
#ifdef _WIN64
argumentValue = "\\WOW6432Node";
#endif
QSettings registrySettingsSc(QString("HKEY_LOCAL_MACHINE\\SOFTWARE%1\\Rockstar Games\\Grand Theft Auto V").arg(argumentValue), QSettings::NativeFormat);
if (gameLanguage != GameLanguage::Undefined)
{
registrySettingsSc.setValue("Language", gameLanguageToString(gameLanguage));
}
else
{
registrySettingsSc.remove("Language");
}
registrySettingsSc.sync();
if (registrySettingsSc.status() != QSettings::NoError)
{
return false;
}
#else
Q_UNUSED(gameLanguage)
#endif
}
if (steamVersion)
{
#ifdef Q_OS_WIN
QString argumentValue;
#ifdef _WIN64
argumentValue = "\\WOW6432Node";
#endif
QSettings registrySettingsSteam(QString("HKEY_LOCAL_MACHINE\\SOFTWARE%1\\Rockstar Games\\Grand Theft Auto V Steam").arg(argumentValue), QSettings::NativeFormat);
if (gameLanguage != GameLanguage::Undefined)
{
registrySettingsSteam.setValue("Language", gameLanguageToString(gameLanguage));
}
else
{
registrySettingsSteam.remove("Language");
}
registrySettingsSteam.sync();
if (registrySettingsSteam.status() != QSettings::NoError)
{
return false;
}
#else
Q_UNUSED(gameLanguage)
#endif
}
return true;
}
// Screen Stuff
qreal AppEnv::screenRatio()
{
#if QT_VERSION >= 0x050000
qreal dpi = QApplication::primaryScreen()->logicalDotsPerInch();
#else
qreal dpi = QApplication::desktop()->logicalDpiX();
#endif
#ifdef Q_OS_MAC
return (dpi / 72);
#else
return (dpi / 96);
#endif
}
qreal AppEnv::screenRatioPR()
{
#if QT_VERSION >= 0x050600
return QApplication::primaryScreen()->devicePixelRatio();
#else
return 1;
#endif
}
/*****************************************************************************
* 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 "config.h"
#include "AppEnv.h"
#include "StringParser.h"
#include "StandardPaths.h"
#include <QDir>
#include <QDebug>
#include <QtGlobal>
#include <QSettings>
#include <iostream>
using namespace std;
AppEnv::AppEnv()
{
}
// Folder Stuff
QString AppEnv::getGameFolder(bool *ok)
{
QDir dir;
QString GTAV_FOLDER = QString::fromUtf8(qgetenv("GTAV_FOLDER"));
if (GTAV_FOLDER != "")
{
dir.setPath(GTAV_FOLDER);
if (dir.exists())
{
if (ok != NULL) *ok = true;
qputenv("GTAV_FOLDER", dir.absolutePath().toUtf8());
return dir.absolutePath();
}
}
QString GTAV_defaultFolder = StandardPaths::documentsLocation() + QDir::separator() + "Rockstar Games" + QDir::separator() + "GTA V";
QString GTAV_returnFolder = GTAV_defaultFolder;
QSettings SyncSettings(GTA5SYNC_APPVENDOR, GTA5SYNC_APPSTR);
SyncSettings.beginGroup("dir");
bool forceDir = SyncSettings.value("force", false).toBool();
GTAV_returnFolder = SyncSettings.value("dir", GTAV_defaultFolder).toString();
SyncSettings.endGroup();
if (forceDir)
{
dir.setPath(GTAV_returnFolder);
if (dir.exists())
{
if (ok != 0) *ok = true;
qputenv("GTAV_FOLDER", dir.absolutePath().toUtf8());
return dir.absolutePath();
}
}
dir.setPath(GTAV_defaultFolder);
if (dir.exists())
{
if (ok != 0) *ok = true;
qputenv("GTAV_FOLDER", dir.absolutePath().toUtf8());
return dir.absolutePath();
}
if (!forceDir)
{
dir.setPath(GTAV_returnFolder);
if (dir.exists())
{
if (ok != 0) *ok = true;
qputenv("GTAV_FOLDER", dir.absolutePath().toUtf8());
return dir.absolutePath();
}
}
if (ok != 0) *ok = false;
return "";
}
bool AppEnv::setGameFolder(QString gameFolder)
{
QDir dir;
dir.setPath(gameFolder);
if (dir.exists())
{
qputenv("GTAV_FOLDER", dir.absolutePath().toUtf8());
return true;
}
return false;
}
QString AppEnv::getLangFolder()
{
return StringParser::convertBuildedString(QString::fromUtf8(GTA5SYNC_LANG));
}
QString AppEnv::getPluginsFolder()
{
return StringParser::convertBuildedString(QString::fromUtf8(GTA5SYNC_PLUG));
}
// Web Stuff
QByteArray AppEnv::getUserAgent()
{
return QString("Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Firefox/45.0 %1/%2").arg(GTA5SYNC_APPSTR, GTA5SYNC_APPVER).toUtf8();
}
// QUrl AppEnv::getCrewFetchingUrl(QString crewID)
// {
// return QUrl(QString("https://socialclub.rockstargames.com/reference/crewfeed/%1").arg(crewID));
// }
QUrl AppEnv::getCrewFetchingUrl(QString crewID)
{
return QUrl(QString("https://socialclub.rockstargames.com/crew/%1/%1").arg(crewID));
}
QUrl AppEnv::getPlayerFetchingUrl(QString crewID, QString pageNumber)
{
return QUrl(QString("https://socialclub.rockstargames.com/crewsapi/GetMembersList?crewId=%1&pageNumber=%2").arg(crewID, pageNumber));
}

104
AppEnv.h Normal file → Executable file
View File

@ -1,62 +1,42 @@
/*****************************************************************************
* gta5view Grand Theft Auto V Profile Viewer
* Copyright (C) 2016-2018 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 APPENV_H
#define APPENV_H
#include <QString>
#include <QUrl>
enum class GameVersion : int { NoVersion = 0, SocialClubVersion = 1, SteamVersion = 2, BothVersions = 3 };
enum class GameLanguage : int { Undefined = 0, English = 1, French = 2, Italian = 3, German = 4, Spanish = 5, Mexican = 6, Brasilian = 7, Russian = 8, Polish = 9, Japanese = 10, SChinese = 11, TChinese = 12, Koreana = 13 };
class AppEnv
{
public:
AppEnv();
// Build Stuff
static QString getBuildDateTime();
static QString getBuildCode();
// Folder Stuff
static QString getGameFolder(bool *ok = 0);
static bool setGameFolder(QString gameFolder);
static QString getExLangFolder();
static QString getInLangFolder();
static QString getPluginsFolder();
// Web Stuff
static QByteArray getUserAgent();
static QUrl getCrewFetchingUrl(QString crewID);
static QUrl getPlayerFetchingUrl(QString crewID, QString pageNumber);
static QUrl getPlayerFetchingUrl(QString crewID, int pageNumber);
// Game Stuff
static GameVersion getGameVersion();
static GameLanguage getGameLanguage(GameVersion gameVersion);
static GameLanguage gameLanguageFromString(QString gameLanguage);
static QString gameLanguageToString(GameLanguage gameLanguage);
static bool setGameLanguage(GameVersion gameVersion, GameLanguage gameLanguage);
// Screen Stuff
static qreal screenRatio();
static qreal screenRatioPR();
};
#endif // APPENV_H
/*****************************************************************************
* 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 APPENV_H
#define APPENV_H
#include <QString>
#include <QUrl>
class AppEnv
{
public:
AppEnv();
// Folder Stuff
static QString getGameFolder(bool *ok = 0);
static bool setGameFolder(QString gameFolder);
static QString getLangFolder();
static QString getPluginsFolder();
// Web Stuff
static QByteArray getUserAgent();
static QUrl getCrewFetchingUrl(QString crewID);
static QUrl getPlayerFetchingUrl(QString crewID, QString pageNumber);
};
#endif // APPENV_H

View File

@ -1,356 +0,0 @@
cmake_minimum_required(VERSION 3.5)
project(gta5view LANGUAGES C CXX)
set(CMAKE_INCLUDE_CURRENT_DIR ON)
set(CMAKE_AUTOUIC ON)
set(CMAKE_AUTOMOC ON)
set(CMAKE_AUTORCC ON)
set(CMAKE_CXX_STANDARD 11)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
find_package(Qt5 COMPONENTS Network Svg Widgets REQUIRED)
find_package(Qt5 COMPONENTS LinguistTools QUIET)
if(WIN32)
find_package(Qt5 COMPONENTS WinExtras REQUIRED)
list(APPEND GTA5VIEW_LIBS
Qt5::WinExtras
)
list(APPEND GTA5VIEW_DEFINES
-DUNICODE
-D_UNICODE
-DWIN32
)
list(APPEND GTA5VIEW_RESOURCES
res/app.rc
)
endif()
list(APPEND GTA5VIEW_DEFINES
-DGTA5SYNC_CMAKE
-DGTA5SYNC_PROJECT
-DSNAPMATIC_NODEFAULT
)
set(GTA5VIEW_SOURCES
main.cpp
AboutDialog.cpp
AppEnv.cpp
CrewDatabase.cpp
DatabaseThread.cpp
ExportDialog.cpp
ExportThread.cpp
GlobalString.cpp
IconLoader.cpp
ImportDialog.cpp
JsonEditorDialog.cpp
MapLocationDialog.cpp
OptionsDialog.cpp
PictureDialog.cpp
PictureExport.cpp
PictureWidget.cpp
PlayerListDialog.cpp
ProfileDatabase.cpp
ProfileInterface.cpp
ProfileLoader.cpp
ProfileWidget.cpp
SavegameCopy.cpp
SavegameData.cpp
SavegameDialog.cpp
SavegameWidget.cpp
SidebarGenerator.cpp
SnapmaticEditor.cpp
SnapmaticPicture.cpp
SnapmaticWidget.cpp
StandardPaths.cpp
StringParser.cpp
TranslationClass.cpp
UserInterface.cpp
anpro/imagecropper.cpp
pcg/pcg_basic.c
uimod/JSHighlighter.cpp
uimod/UiModLabel.cpp
uimod/UiModWidget.cpp
)
set(GTA5VIEW_HEADERS
config.h
AboutDialog.h
AppEnv.h
CrewDatabase.h
DatabaseThread.h
ExportDialog.h
ExportThread.h
GlobalString.h
IconLoader.h
ImportDialog.h
JsonEditorDialog.h
MapLocationDialog.h
OptionsDialog.h
PictureDialog.h
PictureExport.h
PictureWidget.h
PlayerListDialog.h
ProfileDatabase.h
ProfileInterface.h
ProfileLoader.h
ProfileWidget.h
SavegameCopy.h
SavegameData.h
SavegameDialog.h
SavegameWidget.h
SidebarGenerator.h
SnapmaticEditor.h
SnapmaticPicture.h
SnapmaticWidget.h
StandardPaths.h
StringParser.h
TranslationClass.h
UserInterface.h
anpro/imagecropper.h
pcg/pcg_basic.h
uimod/JSHighlighter.h
uimod/UiModLabel.h
uimod/UiModWidget.h
)
set(GTA5VIEW_INCLUDEDIR
anpro
pcg
uimod
)
set(GTA5VIEW_FORMS
AboutDialog.ui
ExportDialog.ui
ImportDialog.ui
JsonEditorDialog.ui
MapLocationDialog.ui
OptionsDialog.ui
PictureDialog.ui
PlayerListDialog.ui
ProfileInterface.ui
SavegameDialog.ui
SavegameWidget.ui
SnapmaticEditor.ui
SnapmaticWidget.ui
UserInterface.ui
)
list(APPEND GTA5VIEW_RESOURCES
res/app.qrc
res/global.qrc
)
set_property(SOURCE res/global.qrc PROPERTY AUTORCC_OPTIONS "-threshold;0;-compress;9")
if(Qt5LinguistTools_FOUND)
qt5_add_translation(GTA5VIEW_TRANSLATIONS
res/gta5sync_de.ts
res/gta5sync_en_US.ts
res/gta5sync_fr.ts
res/gta5sync_ko.ts
res/gta5sync_ru.ts
res/gta5sync_uk.ts
res/gta5sync_zh_TW.ts
res/qtbase_en_GB.ts
)
add_custom_target(translations DEPENDS ${GTA5VIEW_TRANSLATIONS})
else()
set(GTA5VIEW_TRANSLATIONS
res/gta5sync_de.qm
res/gta5sync_en_US.qm
res/gta5sync_fr.qm
res/gta5sync_ko.qm
res/gta5sync_ru.qm
res/gta5sync_uk.qm
res/gta5sync_zh_TW.qm
res/qtbase_en_GB.qm
)
endif()
option(QCONF_BUILD "System installation intended Qconf build" OFF)
if(QCONF_BUILD)
list(APPEND GTA5VIEW_DEFINES
-DGTA5SYNC_QCONF
)
else()
list(APPEND GTA5VIEW_RESOURCES
res/tr_g5p.qrc
res/tr_qt5.qrc
)
endif()
option(FLATPAK_BUILD "Flatpak modifications and identifications" OFF)
if(FLATPAK_BUILD)
list(APPEND GTA5VIEW_DEFINES
"-DGTA5SYNC_BUILDCODE=\"Flatpak\""
"-DGTA5SYNC_BUILDTYPE=\"Flatpak\""
-DGTA5SYNC_FLATPAK
)
endif()
option(WITH_MOTD "Developer message system directed to users" OFF)
if(WITH_MOTD)
list(APPEND GTA5VIEW_HEADERS
MessageThread.h
)
list(APPEND GTA5VIEW_SOURCES
MessageThread.cpp
)
list(APPEND GTA5VIEW_DEFINES
-DGTA5SYNC_MOTD
)
if(MOTD_WEBURL)
list(APPEND GTA5VIEW_DEFINES
"-DGTA5SYNC_MOTD_WEBURL=\"${MOTD_WEBURL}\""
)
endif()
endif()
option(WITH_TELEMETRY "Hardware survey and basic telemetry system" OFF)
if(WITH_TELEMETRY)
list(APPEND GTA5VIEW_HEADERS
TelemetryClass.h
tmext/TelemetryClassAuthenticator.h
)
list(APPEND GTA5VIEW_SOURCES
TelemetryClass.cpp
tmext/TelemetryClassAuthenticator.cpp
)
list(APPEND GTA5VIEW_INCLUDEDIR
tmext
)
list(APPEND GTA5VIEW_DEFINES
-DGTA5SYNC_TELEMETRY
)
if(TELEMETRY_AUTHID AND TELEMETRY_AUTHPW AND TELEMETRY_PUSHURL AND TELEMETRY_REGURL)
list(APPEND GTA5VIEW_DEFINES
"-DGTA5SYNC_TELEMETRY_AUTHID=\"${TELEMETRY_AUTHID}\""
"-DGTA5SYNC_TELEMETRY_AUTHPW=\"${TELEMETRY_AUTHPW}\""
"-DGTA5SYNC_TELEMETRY_PUSHURL=\"${TELEMETRY_PUSHURL}\""
"-DGTA5SYNC_TELEMETRY_REGURL=\"${TELEMETRY_REGURL}\""
)
endif()
if(TELEMETRY_WEBURL)
list(APPEND GTA5VIEW_DEFINES
"-DGTA5SYNC_TELEMETRY_WEBURL=\"${TELEMETRY_WEBURL}\""
)
endif()
if(WIN32)
list(APPEND GTA5VIEW_LIBS
d3d9
)
endif()
endif()
if(GTA5VIEW_APPVER)
list(APPEND GTA5VIEW_DEFINES
"-DGTA5SYNC_APPVER=\"${GTA5VIEW_APPVER}\""
)
endif()
if(GTA5VIEW_BUILDCODE)
list(APPEND GTA5VIEW_DEFINES
"-DGTA5SYNC_BUILDCODE=\"${GTA5VIEW_BUILDCODE}\""
)
endif()
if(GTA5VIEW_BUILDTYPE)
list(APPEND GTA5VIEW_DEFINES
"-DGTA5SYNC_BUILDTYPE=\"${GTA5VIEW_BUILDTYPE}\""
)
else()
if(GTA5VIEW_BUILDTYPE_ALPHA)
list(APPEND GTA5VIEW_DEFINES
-DGTA5SYNC_BUILDTYPE_ALPHA
)
endif()
if(GTA5VIEW_BUILDTYPE_BETA)
list(APPEND GTA5VIEW_DEFINES
-DGTA5SYNC_BUILDTYPE_BETA
)
endif()
if(GTA5VIEW_BUILDTYPE_DEV)
list(APPEND GTA5VIEW_DEFINES
-DGTA5SYNC_BUILDTYPE_DEV
)
endif()
if(GTA5VIEW_BUILDTYPE_DAILY)
list(APPEND GTA5VIEW_DEFINES
-DGTA5SYNC_BUILDTYPE_DAILY
)
endif()
if(GTA5VIEW_BUILDTYPE_RC)
list(APPEND GTA5VIEW_DEFINES
-DGTA5SYNC_BUILDTYPE_RC
)
endif()
if(GTA5VIEW_BUILDTYPE_REL)
list(APPEND GTA5VIEW_DEFINES
-DGTA5SYNC_BUILDTYPE_REL
)
endif()
endif()
if(GTA5VIEW_COMMIT)
list(APPEND GTA5VIEW_DEFINES
"-DGTA5SYNC_COMMIT=\"${GTA5VIEW_COMMIT}\""
)
endif()
if(GTA5VIEW_INLANG)
list(APPEND GTA5VIEW_DEFINES
"-DGTA5SYNC_INLANG=\"${GTA5VIEW_INLANG}\""
)
endif()
if(GTA5VIEW_LANG)
list(APPEND GTA5VIEW_DEFINES
"-DGTA5SYNC_LANG=\"${GTA5VIEW_LANG}\""
)
endif()
if(GTA5VIEW_PLUG)
list(APPEND GTA5VIEW_DEFINES
"-DGTA5SYNC_PLUG=\"${GTA5VIEW_PLUG}\""
)
endif()
add_executable(gta5view
WIN32 MACOSX_BUNDLE
${GTA5VIEW_HEADERS}
${GTA5VIEW_SOURCES}
${GTA5VIEW_FORMS}
${GTA5VIEW_RESOURCES}
)
if(Qt5LinguistTools_FOUND AND QCONF_BUILD)
add_dependencies(gta5view translations)
endif()
if(CMAKE_VERSION VERSION_GREATER_EQUAL "3.16.0")
target_precompile_headers(gta5view PRIVATE config.h)
endif()
if(Qt5Core_VERSION VERSION_GREATER_EQUAL "5.14.0")
qt5_import_plugins(gta5view INCLUDE Qt5::QSvgPlugin)
endif()
target_compile_definitions(gta5view PRIVATE ${GTA5VIEW_DEFINES})
target_include_directories(gta5view PRIVATE ${GTA5VIEW_INCLUDEDIR})
target_link_libraries(gta5view PRIVATE Qt5::Network Qt5::Svg Qt5::Widgets ${GTA5VIEW_LIBS})
install(TARGETS gta5view DESTINATION bin)
install(FILES res/de.syping.gta5view.desktop DESTINATION share/applications)
install(FILES res/de.syping.gta5view.metainfo.xml DESTINATION share/metainfo)
install(FILES res/gta5view-16.png DESTINATION share/icons/hicolor/16x16/apps RENAME de.syping.gta5view.png)
install(FILES res/gta5view-24.png DESTINATION share/icons/hicolor/24x24/apps RENAME de.syping.gta5view.png)
install(FILES res/gta5view-32.png DESTINATION share/icons/hicolor/32x32/apps RENAME de.syping.gta5view.png)
install(FILES res/gta5view-48.png DESTINATION share/icons/hicolor/48x48/apps RENAME de.syping.gta5view.png)
install(FILES res/gta5view-64.png DESTINATION share/icons/hicolor/64x64/apps RENAME de.syping.gta5view.png)
install(FILES res/gta5view-96.png DESTINATION share/icons/hicolor/96x96/apps RENAME de.syping.gta5view.png)
install(FILES res/gta5view-128.png DESTINATION share/icons/hicolor/128x128/apps RENAME de.syping.gta5view.png)
install(FILES res/gta5view-256.png DESTINATION share/icons/hicolor/256x256/apps RENAME de.syping.gta5view.png)
install(FILES res/gta5view-512.png DESTINATION share/icons/hicolor/512x512/apps RENAME de.syping.gta5view.png)
install(FILES res/de.syping.gta5view.png DESTINATION share/pixmaps)
if(QCONF_BUILD)
install(FILES ${GTA5VIEW_TRANSLATIONS} DESTINATION share/gta5view/translations)
endif()

257
CrewDatabase.cpp Normal file → Executable file
View File

@ -1,176 +1,81 @@
/*****************************************************************************
* gta5view Grand Theft Auto V Profile Viewer
* 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 "StandardPaths.h"
#include "CrewDatabase.h"
#include "config.h"
#include <QStringBuilder>
#include <QMutexLocker>
#include <QDebug>
#include <QFile>
#include <QDir>
CrewDatabase::CrewDatabase(QObject *parent) : QObject(parent)
{
QDir dir;
dir.mkpath(StandardPaths::dataLocation());
dir.setPath(StandardPaths::dataLocation());
QString dirPath = dir.absolutePath();
QString defaultConfPath = dirPath % "/crews.ini";
QSettings confPathSettings(GTA5SYNC_APPVENDOR, GTA5SYNC_APPSTR);
confPathSettings.beginGroup("Database");
QString confPathFile = confPathSettings.value("Crews", defaultConfPath).toString();
confPathSettings.endGroup();
crewDB = new QSettings(confPathFile, QSettings::IniFormat);
crewDB->beginGroup("Crews");
addProcess = false;
}
CrewDatabase::~CrewDatabase()
{
crewDB->endGroup();
delete crewDB;
}
QStringList CrewDatabase::getCrews()
{
QMutexLocker locker(&mutex);
#ifdef GTA5SYNC_DEBUG
qDebug() << "getCrews";
#endif
return getCrews_p();
}
QStringList CrewDatabase::getCrews_p()
{
#ifdef GTA5SYNC_DEBUG
qDebug() << "getCrews_p";
#endif
QStringList compatibleCrewList = getCompatibleCrews_p();
crewDB->endGroup();
crewDB->beginGroup("CrewList");
QStringList crewIDs = crewDB->value("IDs", QStringList()).toStringList();
crewIDs += compatibleCrewList;
crewIDs.removeDuplicates();
crewDB->endGroup();
crewDB->beginGroup("Crews");
return crewIDs;
}
QStringList CrewDatabase::getCompatibleCrews()
{
QMutexLocker locker(&mutex);
#ifdef GTA5SYNC_DEBUG
qDebug() << "getCompatibleCrews";
#endif
return getCompatibleCrews_p();
}
QStringList CrewDatabase::getCompatibleCrews_p()
{
#ifdef GTA5SYNC_DEBUG
qDebug() << "getCompatibleCrews_p";
#endif
return crewDB->childKeys();
}
QString CrewDatabase::getCrewName(QString crewID)
{
QMutexLocker locker(&mutex);
#ifdef GTA5SYNC_DEBUG
qDebug() << "getCrewName" << crewID;
#endif
QString crewStr = crewDB->value(crewID, crewID).toString();
if (crewID == "0") crewStr = tr("No Crew", "");
return crewStr;
}
QString CrewDatabase::getCrewName(int crewID)
{
QMutexLocker locker(&mutex);
#ifdef GTA5SYNC_DEBUG
qDebug() << "getCrewName" << crewID;
#endif
QString crewStr = crewDB->value(QString::number(crewID), crewID).toString();
if (crewID == 0) crewStr = tr("No Crew", "");
return crewStr;
}
void CrewDatabase::setCrewName(int crewID, QString crewName)
{
QMutexLocker locker(&mutex);
#ifdef GTA5SYNC_DEBUG
qDebug() << "setCrewName" << crewID << crewName;
#endif
crewDB->setValue(QString::number(crewID), crewName);
}
void CrewDatabase::addCrew(int crewID)
{
QMutexLocker locker(&mutex);
#ifdef GTA5SYNC_DEBUG
qDebug() << "addCrew" << crewID;
#endif
QStringList crews = getCrews_p();
crews += QString::number(crewID);
crews.removeDuplicates();
crewDB->endGroup();
crewDB->beginGroup("CrewList");
crewDB->setValue("IDs", crews);
crewDB->endGroup();
crewDB->beginGroup("Crews");
}
bool CrewDatabase::isCompatibleCrew(QString crewNID)
{
QMutexLocker locker(&mutex);
#ifdef GTA5SYNC_DEBUG
qDebug() << "isCompatibleCrew" << crewNID;
#endif
return crewDB->contains(crewNID);
}
bool CrewDatabase::isCompatibleCrew(int crewID)
{
QMutexLocker locker(&mutex);
#ifdef GTA5SYNC_DEBUG
qDebug() << "isCompatibleCrew" << crewID;
#endif
return crewDB->contains(QString::number(crewID));
}
void CrewDatabase::setAddingCrews(bool addingCrews)
{
QMutexLocker locker(&mutex);
#ifdef GTA5SYNC_DEBUG
qDebug() << "setAddingCrews" << addingCrews;
#endif
addProcess = addingCrews;
}
bool CrewDatabase::isAddingCrews()
{
QMutexLocker locker(&mutex);
#ifdef GTA5SYNC_DEBUG
qDebug() << "isAddingCrews";
#endif
return addProcess;
}
/*****************************************************************************
* 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 "StandardPaths.h"
#include "CrewDatabase.h"
#include "config.h"
#include <QFile>
#include <QDir>
CrewDatabase::CrewDatabase(QObject *parent) : QObject(parent)
{
QDir dir;
dir.mkpath(StandardPaths::dataLocation());
dir.setPath(StandardPaths::dataLocation());
QString dirPath = dir.absolutePath();
QString defaultConfPath = dirPath + QDir::separator() + "crews.ini";
QSettings confPathSettings(GTA5SYNC_APPVENDOR, GTA5SYNC_APPSTR);
confPathSettings.beginGroup("Database");
QString confPathFile = confPathSettings.value("Crews", defaultConfPath).toString();
confPathSettings.endGroup();
crewDB = new QSettings(confPathFile, QSettings::IniFormat);
crewDB->beginGroup("Crews");
}
CrewDatabase::~CrewDatabase()
{
crewDB->endGroup();
delete crewDB;
}
QStringList CrewDatabase::getCrews()
{
QStringList compatibleCrewList = crewDB->childKeys();
crewDB->endGroup();
crewDB->beginGroup("CrewList");
QStringList crewIDs = crewDB->value("IDs", QStringList()).toStringList();
crewIDs.append(compatibleCrewList);
crewIDs.removeDuplicates();
crewDB->endGroup();
crewDB->beginGroup("Crews");
return crewIDs;
}
QString CrewDatabase::getCrewName(int crewID)
{
return crewDB->value(QString::number(crewID), crewID).toString();
}
void CrewDatabase::setCrewName(int crewID, QString crewName)
{
crewDB->setValue(QString::number(crewID), crewName);
}
void CrewDatabase::addCrew(int crewID)
{
QStringList crews = getCrews();
crews.append(QString::number(crewID));
crews.removeDuplicates();
crewDB->endGroup();
crewDB->beginGroup("CrewList");
crewDB->setValue("IDs", crews);
crewDB->endGroup();
crewDB->beginGroup("Crews");
}

97
CrewDatabase.h Normal file → Executable file
View File

@ -1,54 +1,43 @@
/*****************************************************************************
* gta5view Grand Theft Auto V Profile Viewer
* 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 CREWDATABASE_H
#define CREWDATABASE_H
#include <QSettings>
#include <QObject>
#include <QMutex>
#include <QMap>
class CrewDatabase : public QObject
{
Q_OBJECT
public:
explicit CrewDatabase(QObject *parent = 0);
QString getCrewName(QString crewID);
QString getCrewName(int crewID);
QStringList getCompatibleCrews();
QStringList getCrews();
void setAddingCrews(bool addingCrews);
bool isCompatibleCrew(QString crewNID);
bool isCompatibleCrew(int crewID);
bool isAddingCrews();
~CrewDatabase();
private:
mutable QMutex mutex;
bool addProcess;
QSettings *crewDB;
QStringList getCrews_p();
QStringList getCompatibleCrews_p();
public slots:
void setCrewName(int crewID, QString crewName);
void addCrew(int crewID);
};
#endif // CREWDATABASE_H
/*****************************************************************************
* 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 CREWDATABASE_H
#define CREWDATABASE_H
#include <QSettings>
#include <QObject>
#include <QMap>
class CrewDatabase : public QObject
{
Q_OBJECT
public:
explicit CrewDatabase(QObject *parent = 0);
void setCrewName(int crewID, QString crewName);
QString getCrewName(int crewID);
QStringList getCrews();
~CrewDatabase();
private:
QSettings *crewDB;
public slots:
void addCrew(int crewID);
};
#endif // CREWDATABASE_H

541
DatabaseThread.cpp Normal file → Executable file
View File

@ -1,245 +1,296 @@
/*****************************************************************************
* gta5view Grand Theft Auto V Profile Viewer
* Copyright (C) 2016-2020 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 "DatabaseThread.h"
#include "CrewDatabase.h"
#include "AppEnv.h"
#include <QNetworkAccessManager>
#include <QNetworkRequest>
#include <QNetworkReply>
#include <QJsonDocument>
#include <QJsonObject>
#include <QStringList>
#include <QVariantMap>
#include <QEventLoop>
#include <QTimer>
#include <QDebug>
#include <QUrl>
#define crewMaxPages 83
#define maxLoadFails 3
DatabaseThread::DatabaseThread(CrewDatabase *crewDB, QObject *parent) : QThread(parent), crewDB(crewDB)
{
continueLastCrew = true;
threadRunning = true;
}
void DatabaseThread::run()
{
QEventLoop threadLoop;
QObject::connect(this, SIGNAL(threadTerminated()), &threadLoop, SLOT(quit()));
while (threadRunning)
{
QTimer::singleShot(300000, &threadLoop, SLOT(quit()));
threadLoop.exec();
}
}
void DatabaseThread::scanCrewReference(const QStringList &crewList, const int &requestDelay)
{
for (QString crewID : crewList)
{
if (threadRunning && crewID != QLatin1String("0"))
{
QNetworkAccessManager *netManager = new QNetworkAccessManager();
QNetworkRequest netRequest(AppEnv::getCrewFetchingUrl(crewID));
#if QT_VERSION >= 0x050600
#if QT_VERSION < 0x060000
netRequest.setAttribute(QNetworkRequest::FollowRedirectsAttribute, true);
#endif
#endif
netRequest.setRawHeader("User-Agent", AppEnv::getUserAgent());
netRequest.setRawHeader("Accept", "text/html");
netRequest.setRawHeader("Accept-Charset", "utf-8");
netRequest.setRawHeader("Accept-Language", "en-US,en;q=0.9");
netRequest.setRawHeader("Connection", "keep-alive");
QNetworkReply *netReply = netManager->get(netRequest);
QEventLoop *downloadLoop = new QEventLoop();
QObject::connect(netReply, SIGNAL(finished()), downloadLoop, SLOT(quit()));
if (!continueLastCrew) { QObject::connect(this, SIGNAL(threadTerminated()), downloadLoop, SLOT(quit())); }
QTimer::singleShot(30000, downloadLoop, SLOT(quit()));
downloadLoop->exec();
downloadLoop->disconnect();
delete downloadLoop;
if (netReply->isFinished())
{
QString crewName;
QByteArray crewHtml = netReply->readAll();
QStringList crewHtmlSplit1 = QString::fromUtf8(crewHtml).split("<title>Rockstar Games Social Club - Crew : ");
if (crewHtmlSplit1.length() >= 2)
{
QStringList crewHtmlSplit2 = QString(crewHtmlSplit1.at(1)).split("</title>");
if (crewHtmlSplit2.length() >= 1)
{
crewName = crewHtmlSplit2.at(0);
}
}
if (!crewName.isEmpty())
{
emit crewNameFound(crewID.toInt(), crewName);
}
}
else
{
netReply->abort();
}
if (threadRunning)
{
QEventLoop *waitingLoop = new QEventLoop();
QTimer::singleShot(requestDelay, waitingLoop, SLOT(quit()));
if (!continueLastCrew) { QObject::connect(this, SIGNAL(threadTerminated()), waitingLoop, SLOT(quit())); }
waitingLoop->exec();
waitingLoop->disconnect();
delete waitingLoop;
}
delete netReply;
delete netManager;
}
}
}
void DatabaseThread::scanCrewMembersList(const QStringList &crewList, const int &maxPages, const int &requestDelay)
{
for (QString crewID : crewList)
{
if (threadRunning && crewID != QLatin1String("0"))
{
int currentFail = 0;
int currentPage = 0;
int foundPlayers = 0;
int totalPlayers = 1000;
while(foundPlayers < totalPlayers && currentPage < maxPages && (continueLastCrew ? true : threadRunning))
{
QNetworkAccessManager *netManager = new QNetworkAccessManager();
QNetworkRequest netRequest(AppEnv::getPlayerFetchingUrl(crewID, currentPage));
#if QT_VERSION >= 0x050600
#if QT_VERSION < 0x060000
netRequest.setAttribute(QNetworkRequest::FollowRedirectsAttribute, true);
#endif
#endif
netRequest.setRawHeader("User-Agent", AppEnv::getUserAgent());
netRequest.setRawHeader("Accept", "application/json");
netRequest.setRawHeader("Accept-Charset", "utf-8");
netRequest.setRawHeader("Accept-Language", "en-US,en;q=0.9");
netRequest.setRawHeader("Connection", "keep-alive");
QNetworkReply *netReply = netManager->get(netRequest);
QEventLoop *downloadLoop = new QEventLoop();
QObject::connect(netReply, SIGNAL(finished()), downloadLoop, SLOT(quit()));
if (!continueLastCrew) { QObject::connect(this, SIGNAL(threadTerminated()), downloadLoop, SLOT(quit())); }
QTimer::singleShot(30000, downloadLoop, SLOT(quit()));
downloadLoop->exec();
downloadLoop->disconnect();
delete downloadLoop;
if (netReply->isFinished())
{
QByteArray crewJson = netReply->readAll();
QJsonDocument crewDocument = QJsonDocument::fromJson(crewJson);
QJsonObject crewObject = crewDocument.object();
QVariantMap crewMap = crewObject.toVariantMap();
if (crewMap.contains("Total")) { totalPlayers = crewMap["Total"].toInt(); }
if (crewMap.contains("Members"))
{
const QList<QVariant> memberList = crewMap["Members"].toList();
for (QVariant memberVariant : memberList)
{
QMap<QString, QVariant> memberMap = memberVariant.toMap();
if (memberMap.contains("RockstarId") && memberMap.contains("Name"))
{
int RockstarId = memberMap["RockstarId"].toInt();
QString memberName = memberMap["Name"].toString();
if (!memberName.isEmpty() && RockstarId != 0)
{
foundPlayers++;
emit playerNameFound(RockstarId, memberName);
}
}
}
}
currentPage++;
}
else
{
currentFail++;
if (currentFail == maxLoadFails)
{
currentFail = 0;
currentPage++;
}
}
delete netReply;
delete netManager;
if (foundPlayers < totalPlayers && currentPage < maxPages && (continueLastCrew ? true : threadRunning))
{
QEventLoop *waitingLoop = new QEventLoop();
QTimer::singleShot(requestDelay, waitingLoop, SLOT(quit()));
if (!continueLastCrew) { QObject::connect(this, SIGNAL(threadTerminated()), waitingLoop, SLOT(quit())); }
waitingLoop->exec();
waitingLoop->disconnect();
delete waitingLoop;
}
}
}
}
}
void DatabaseThread::deleteCompatibleCrews(QStringList *crewList)
{
for (QString crewNID : *crewList)
{
if (crewDB->isCompatibleCrew(crewNID))
{
crewList->removeAll(crewNID);
}
}
}
QStringList DatabaseThread::deleteCompatibleCrews(const QStringList &crewList)
{
QStringList crewListR = crewList;
for (QString crewNID : crewListR)
{
if (crewDB->isCompatibleCrew(crewNID))
{
crewListR.removeAll(crewNID);
}
}
return crewListR;
}
void DatabaseThread::terminateThread()
{
threadRunning = false;
emit threadTerminated();
}
/*****************************************************************************
* 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 "DatabaseThread.h"
#include "CrewDatabase.h"
#include "AppEnv.h"
#include <QNetworkAccessManager>
#include <QNetworkRequest>
#include <QNetworkReply>
#include <QJsonDocument>
#include <QJsonObject>
#include <QStringList>
#include <QVariantMap>
#include <QEventLoop>
#include <QTimer>
#include <QDebug>
#include <QUrl>
DatabaseThread::DatabaseThread(CrewDatabase *crewDB, QObject *parent) : QThread(parent), crewDB(crewDB)
{
crewMaxPages = 83;
threadRunning = true;
}
void DatabaseThread::run()
{
QEventLoop threadLoop;
QStringList crewList;
// Register thread loop end signal
QObject::connect(this, SIGNAL(threadEndCommited()), &threadLoop, SLOT(quit()));
// Quick time scan
if (crewList.length() <= 3)
{
scanCrewReference(crewList, 2500);
scanCrewMembersList(crewList, 3, 2500);
emit playerNameUpdated();
}
else if (crewList.length() <= 5)
{
scanCrewReference(crewList, 2500);
scanCrewMembersList(crewList, 2, 2500);
emit playerNameUpdated();
}
QEventLoop *waitingLoop = new QEventLoop();
QTimer::singleShot(10000, waitingLoop, SLOT(quit()));
QObject::connect(this, SIGNAL(threadEndCommited()), waitingLoop, SLOT(quit()));
waitingLoop->exec();
delete waitingLoop;
while (threadRunning)
{
crewList = crewDB->getCrews();
// Long time scan
scanCrewReference(crewList, 10000);
scanCrewMembersList(crewList, crewMaxPages, 10000);
emit playerNameUpdated();
if (threadRunning)
{
QTimer::singleShot(300000, &threadLoop, SLOT(quit()));
threadLoop.exec();
}
}
}
// void DatabaseThread::scanCrewReference(QStringList crewList, int requestDelay)
// {
// foreach (const QString &crewID, crewList)
// {
// if (threadRunning && crewID != "0")
// {
// QNetworkAccessManager *netManager = new QNetworkAccessManager();
// QNetworkRequest netRequest(AppEnv::getCrewFetchingUrl(crewID));
// netRequest.setRawHeader("User-Agent", AppEnv::getUserAgent());
// netRequest.setRawHeader("Accept", "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8");
// netRequest.setRawHeader("Accept-Language", "en-US;q=0.5,en;q=0.3");
// netRequest.setRawHeader("Connection", "keep-alive");
// QNetworkReply *netReply = netManager->get(netRequest);
// QEventLoop *downloadLoop = new QEventLoop();
// QObject::connect(netReply, SIGNAL(finished()), downloadLoop, SLOT(quit()));
// QObject::connect(this, SIGNAL(threadEndCommited()), downloadLoop, SLOT(quit()));
// QTimer::singleShot(30000, downloadLoop, SLOT(quit()));
// downloadLoop->exec();
// delete downloadLoop;
// if (netReply->isFinished())
// {
// QByteArray crewJson = netReply->readAll();
// QJsonDocument crewDocument = QJsonDocument::fromJson(crewJson);
// QJsonObject crewObject = crewDocument.object();
// QVariantMap crewMap = crewObject.toVariantMap();
// QString crewName;
// bool isFound = false;
// if (crewMap.contains("activities"))
// {
// QList<QVariant> activitiesList = crewMap["activities"].toList();
// foreach (const QVariant &activitiesVariant, activitiesList)
// {
// QMap<QString, QVariant> activityRootMap = activitiesVariant.toMap();
// foreach(const QVariant &activityRootVariant, activityRootMap)
// {
// QMap<QString, QVariant> activityMap = activityRootVariant.toMap();
// foreach(const QVariant &activityVariant, activityMap)
// {
// QMap<QString, QVariant> activityFinalMap = activityVariant.toMap();
// if (activityFinalMap.contains("id") && activityFinalMap["id"] == crewID)
// {
// if (activityFinalMap.contains("name") && isFound == false)
// {
// isFound = true;
// crewName = activityFinalMap["name"].toString();
// }
// }
// }
// }
// }
// }
// if (!crewName.isNull())
// {
// crewDB->setCrewName(crewID.toInt(), crewName);
// }
// }
// QEventLoop *waitingLoop = new QEventLoop();
// QTimer::singleShot(requestDelay, waitingLoop, SLOT(quit()));
// QObject::connect(this, SIGNAL(threadEndCommited()), waitingLoop, SLOT(quit()));
// waitingLoop->exec();
// delete waitingLoop;
// delete netReply;
// delete netManager;
// }
// }
// }
void DatabaseThread::scanCrewReference(QStringList crewList, int requestDelay)
{
foreach (const QString &crewID, crewList)
{
if (threadRunning && crewID != "0")
{
QNetworkAccessManager *netManager = new QNetworkAccessManager();
QNetworkRequest netRequest(AppEnv::getCrewFetchingUrl(crewID));
#if QT_VERSION >= 0x050600
netRequest.setAttribute(QNetworkRequest::FollowRedirectsAttribute, true);
#endif
netRequest.setRawHeader("User-Agent", AppEnv::getUserAgent());
netRequest.setRawHeader("Accept", "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8");
netRequest.setRawHeader("Accept-Language", "en-US;q=0.5,en;q=0.3");
netRequest.setRawHeader("Connection", "keep-alive");
QNetworkReply *netReply = netManager->get(netRequest);
QEventLoop *downloadLoop = new QEventLoop();
QObject::connect(netReply, SIGNAL(finished()), downloadLoop, SLOT(quit()));
QObject::connect(this, SIGNAL(threadEndCommited()), downloadLoop, SLOT(quit()));
QTimer::singleShot(30000, downloadLoop, SLOT(quit()));
downloadLoop->exec();
delete downloadLoop;
if (netReply->isFinished())
{
QString crewName;
QByteArray crewHtml = netReply->readAll();
QStringList crewHtmlSplit1 = QString::fromUtf8(crewHtml).split("<title>Rockstar Games Social Club - Crew : ");
if (crewHtmlSplit1.length() >= 2)
{
QStringList crewHtmlSplit2 = QString(crewHtmlSplit1.at(1)).split("</title>");
if (crewHtmlSplit2.length() >= 1)
{
crewName = crewHtmlSplit2.at(0);
}
}
if (!crewName.isEmpty())
{
crewDB->setCrewName(crewID.toInt(), crewName);
}
}
QEventLoop *waitingLoop = new QEventLoop();
QTimer::singleShot(requestDelay, waitingLoop, SLOT(quit()));
QObject::connect(this, SIGNAL(threadEndCommited()), waitingLoop, SLOT(quit()));
waitingLoop->exec();
delete waitingLoop;
delete netReply;
delete netManager;
}
}
}
void DatabaseThread::scanCrewMembersList(QStringList crewList, int maxPages, int requestDelay)
{
foreach (const QString &crewID, crewList)
{
if (threadRunning && crewID != "0")
{
int currentPage = 0;
int foundPlayers = 0;
int totalPlayers = 1000;
while(foundPlayers < totalPlayers && currentPage < maxPages)
{
QNetworkAccessManager *netManager = new QNetworkAccessManager();
QNetworkRequest netRequest(AppEnv::getPlayerFetchingUrl(crewID, QString::number(currentPage)));
#if QT_VERSION >= 0x050600
netRequest.setAttribute(QNetworkRequest::FollowRedirectsAttribute, true);
#endif
netRequest.setRawHeader("User-Agent", AppEnv::getUserAgent());
netRequest.setRawHeader("Accept", "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8");
netRequest.setRawHeader("Accept-Language", "en-US;q=0.5,en;q=0.3");
netRequest.setRawHeader("Connection", "keep-alive");
QNetworkReply *netReply = netManager->get(netRequest);
QEventLoop *downloadLoop = new QEventLoop();
QObject::connect(netReply, SIGNAL(finished()), downloadLoop, SLOT(quit()));
QObject::connect(this, SIGNAL(threadEndCommited()), downloadLoop, SLOT(quit()));
QTimer::singleShot(30000, downloadLoop, SLOT(quit()));
downloadLoop->exec();
delete downloadLoop;
if (netReply->isFinished())
{
QByteArray crewJson = netReply->readAll();
QJsonDocument crewDocument = QJsonDocument::fromJson(crewJson);
QJsonObject crewObject = crewDocument.object();
QVariantMap crewMap = crewObject.toVariantMap();
if (crewMap.contains("Total")) { totalPlayers = crewMap["Total"].toInt(); }
if (crewMap.contains("Members"))
{
QList<QVariant> memberList = crewMap["Members"].toList();
foreach (const QVariant &memberVariant, memberList)
{
QMap<QString, QVariant> memberMap = memberVariant.toMap();
foundPlayers++;
if (memberMap.contains("RockstarId") && memberMap.contains("Name"))
{
int RockstarId = memberMap["RockstarId"].toInt();
QString memberName = memberMap["Name"].toString();
if (memberName != "" && RockstarId != 0)
{
emit playerNameFound(RockstarId, memberName);
}
}
}
}
QEventLoop *waitingLoop = new QEventLoop();
QTimer::singleShot(requestDelay, waitingLoop, SLOT(quit()));
QObject::connect(this, SIGNAL(threadEndCommited()), waitingLoop, SLOT(quit()));
waitingLoop->exec();
delete waitingLoop;
currentPage++;
}
delete netReply;
delete netManager;
}
}
}
}
void DatabaseThread::doEndThread()
{
threadRunning = false;
emit threadEndCommited();
}

108
DatabaseThread.h Normal file → Executable file
View File

@ -1,56 +1,52 @@
/*****************************************************************************
* gta5view Grand Theft Auto V Profile Viewer
* 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 DATABASETHREAD_H
#define DATABASETHREAD_H
#include "CrewDatabase.h"
#include <QObject>
#include <QThread>
class DatabaseThread : public QThread
{
Q_OBJECT
public:
explicit DatabaseThread(CrewDatabase *crewDB, QObject *parent = 0);
public slots:
void terminateThread();
private:
CrewDatabase *crewDB;
void scanCrewMembersList(const QStringList &crewList, const int &maxPages, const int &requestDelay);
void scanCrewReference(const QStringList &crewList, const int &requestDelay);
void deleteCompatibleCrews(QStringList *crewList);
QStringList deleteCompatibleCrews(const QStringList &crewList);
bool continueLastCrew;
bool threadRunning;
int plyrPerReq;
protected:
void run();
signals:
void crewNameFound(int crewID, QString crewName);
void crewNameUpdated();
void playerNameFound(int playerID, QString playerName);
void playerNameUpdated();
void threadTerminated();
};
#endif // DATABASETHREAD_H
/*****************************************************************************
* 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 DATABASETHREAD_H
#define DATABASETHREAD_H
#include "CrewDatabase.h"
#include <QObject>
#include <QThread>
class DatabaseThread : public QThread
{
Q_OBJECT
public:
explicit DatabaseThread(CrewDatabase *crewDB, QObject *parent = 0);
public slots:
void doEndThread();
private:
CrewDatabase *crewDB;
void scanCrewMembersList(QStringList crewList, int maxPages, int requestDelay);
void scanCrewReference(QStringList crewList, int requestDelay);
bool threadRunning;
int crewMaxPages;
int plyrPerReq;
protected:
void run();
signals:
void playerNameFound(int playerID, QString playerName);
void playerNameUpdated();
void threadEndCommited();
};
#endif // DATABASETHREAD_H

96
ExportDialog.cpp Normal file → Executable file
View File

@ -1,48 +1,48 @@
/*****************************************************************************
* gta5view Grand Theft Auto V Profile Viewer
* 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 "ExportDialog.h"
#include "ui_ExportDialog.h"
ExportDialog::ExportDialog(QWidget *parent) :
QDialog(parent),
ui(new Ui::ExportDialog)
{
ui->setupUi(this);
success = false;
}
ExportDialog::~ExportDialog()
{
delete ui;
}
bool ExportDialog::isSucceeded()
{
return success;
}
void ExportDialog::on_cmdSnapmaticClose_clicked()
{
this->close();
}
void ExportDialog::setupPictureExport()
{
ui->swExport->setCurrentWidget(ui->pageSnapmatic);
}
/*****************************************************************************
* 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 "ExportDialog.h"
#include "ui_ExportDialog.h"
ExportDialog::ExportDialog(QWidget *parent) :
QDialog(parent),
ui(new Ui::ExportDialog)
{
ui->setupUi(this);
success = false;
}
ExportDialog::~ExportDialog()
{
delete ui;
}
bool ExportDialog::isSucceeded()
{
return success;
}
void ExportDialog::on_cmdSnapmaticClose_clicked()
{
this->close();
}
void ExportDialog::setupPictureExport()
{
ui->swExport->setCurrentWidget(ui->pageSnapmatic);
}

92
ExportDialog.h Normal file → Executable file
View File

@ -1,46 +1,46 @@
/*****************************************************************************
* gta5view Grand Theft Auto V Profile Viewer
* 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 EXPORTDIALOG_H
#define EXPORTDIALOG_H
#include <QDialog>
namespace Ui {
class ExportDialog;
}
class ExportDialog : public QDialog
{
Q_OBJECT
public:
explicit ExportDialog(QWidget *parent = 0);
void setupPictureExport();
bool isSucceeded();
~ExportDialog();
private slots:
void on_cmdSnapmaticClose_clicked();
private:
Ui::ExportDialog *ui;
bool success;
};
#endif // EXPORTDIALOG_H
/*****************************************************************************
* 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 EXPORTDIALOG_H
#define EXPORTDIALOG_H
#include <QDialog>
namespace Ui {
class ExportDialog;
}
class ExportDialog : public QDialog
{
Q_OBJECT
public:
explicit ExportDialog(QWidget *parent = 0);
void setupPictureExport();
bool isSucceeded();
~ExportDialog();
private slots:
void on_cmdSnapmaticClose_clicked();
private:
Ui::ExportDialog *ui;
bool success;
};
#endif // EXPORTDIALOG_H

452
ExportDialog.ui Normal file → Executable file
View File

@ -1,226 +1,226 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>ExportDialog</class>
<widget class="QDialog" name="ExportDialog">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>400</width>
<height>300</height>
</rect>
</property>
<property name="windowTitle">
<string>Dialog</string>
</property>
<property name="modal">
<bool>true</bool>
</property>
<layout class="QVBoxLayout" name="vlExport">
<property name="leftMargin">
<number>0</number>
</property>
<property name="topMargin">
<number>0</number>
</property>
<property name="rightMargin">
<number>0</number>
</property>
<property name="bottomMargin">
<number>0</number>
</property>
<item>
<widget class="QStackedWidget" name="swExport">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Expanding">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<widget class="QWidget" name="pageSnapmatic">
<layout class="QVBoxLayout" name="vlSnapmatic">
<item>
<widget class="QGroupBox" name="gbSnapmaticFormat">
<property name="title">
<string>Export Format</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<widget class="QRadioButton" name="rbSystemPicture">
<property name="text">
<string>&amp;JPEG/PNG format</string>
</property>
</widget>
</item>
<item>
<widget class="QRadioButton" name="rbSnapmaticPicture">
<property name="text">
<string>GTA &amp;Snapmatic format</string>
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item>
<widget class="QGroupBox" name="gbSnapmaticResolution">
<property name="title">
<string>Export Size</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout_2">
<item>
<widget class="QRadioButton" name="rbSnapmaticDefaultSize">
<property name="text">
<string>Default &amp;Size</string>
</property>
</widget>
</item>
<item>
<widget class="QRadioButton" name="rbSnapmaticDesktopSize">
<property name="text">
<string>&amp;Desktop Size</string>
</property>
</widget>
</item>
<item>
<widget class="QRadioButton" name="rbSnapmaticCustomSize">
<property name="text">
<string>&amp;Custom Size</string>
</property>
</widget>
</item>
<item>
<layout class="QHBoxLayout" name="hlSnapmaticResolution">
<item>
<widget class="QLabel" name="labSnapmaticResolutionSize">
<property name="enabled">
<bool>false</bool>
</property>
<property name="text">
<string>Custom Size:</string>
</property>
</widget>
</item>
<item>
<widget class="QSpinBox" name="sbSnapmaticResoulutionWidth">
<property name="enabled">
<bool>false</bool>
</property>
<property name="minimum">
<number>1</number>
</property>
<property name="maximum">
<number>3840</number>
</property>
<property name="value">
<number>960</number>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="labSnapmaticResolutionSizeX">
<property name="text">
<string>x</string>
</property>
</widget>
</item>
<item>
<widget class="QSpinBox" name="sbSnapmaticResoulutionHeight">
<property name="enabled">
<bool>false</bool>
</property>
<property name="minimum">
<number>1</number>
</property>
<property name="maximum">
<number>2160</number>
</property>
<property name="value">
<number>536</number>
</property>
</widget>
</item>
<item>
<spacer name="hsSnapmaticResolution">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>0</width>
<height>0</height>
</size>
</property>
</spacer>
</item>
</layout>
</item>
</layout>
</widget>
</item>
<item>
<spacer name="vsSnapmatic">
<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>
<layout class="QHBoxLayout" name="hlSnapmaticButtons">
<item>
<spacer name="hsSnapmaticButtons">
<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="cmdSnapmaticExport">
<property name="sizePolicy">
<sizepolicy hsizetype="Minimum" vsizetype="Minimum">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>&amp;Export</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="cmdSnapmaticClose">
<property name="sizePolicy">
<sizepolicy hsizetype="Minimum" vsizetype="Minimum">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>&amp;Close</string>
</property>
</widget>
</item>
</layout>
</item>
</layout>
</widget>
<widget class="QWidget" name="pageSavegame"/>
</widget>
</item>
</layout>
</widget>
<resources/>
<connections/>
</ui>
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>ExportDialog</class>
<widget class="QDialog" name="ExportDialog">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>400</width>
<height>300</height>
</rect>
</property>
<property name="windowTitle">
<string>Dialog</string>
</property>
<property name="modal">
<bool>true</bool>
</property>
<layout class="QVBoxLayout" name="vlExport">
<property name="leftMargin">
<number>0</number>
</property>
<property name="topMargin">
<number>0</number>
</property>
<property name="rightMargin">
<number>0</number>
</property>
<property name="bottomMargin">
<number>0</number>
</property>
<item>
<widget class="QStackedWidget" name="swExport">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Expanding">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<widget class="QWidget" name="pageSnapmatic">
<layout class="QVBoxLayout" name="vlSnapmatic">
<item>
<widget class="QGroupBox" name="gbSnapmaticFormat">
<property name="title">
<string>Export Format</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<widget class="QRadioButton" name="rbSystemPicture">
<property name="text">
<string>&amp;JPEG/PNG format</string>
</property>
</widget>
</item>
<item>
<widget class="QRadioButton" name="rbSnapmaticPicture">
<property name="text">
<string>GTA &amp;Snapmatic format</string>
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item>
<widget class="QGroupBox" name="gbSnapmaticResolution">
<property name="title">
<string>Export Size</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout_2">
<item>
<widget class="QRadioButton" name="rbSnapmaticDefaultSize">
<property name="text">
<string>Default &amp;Size</string>
</property>
</widget>
</item>
<item>
<widget class="QRadioButton" name="rbSnapmaticDesktopSize">
<property name="text">
<string>&amp;Desktop Size</string>
</property>
</widget>
</item>
<item>
<widget class="QRadioButton" name="rbSnapmaticCustomSize">
<property name="text">
<string>&amp;Custom Size</string>
</property>
</widget>
</item>
<item>
<layout class="QHBoxLayout" name="hlSnapmaticResolution">
<item>
<widget class="QLabel" name="labSnapmaticResolutionSize">
<property name="enabled">
<bool>false</bool>
</property>
<property name="text">
<string>Custom Size:</string>
</property>
</widget>
</item>
<item>
<widget class="QSpinBox" name="sbSnapmaticResoulutionWidth">
<property name="enabled">
<bool>false</bool>
</property>
<property name="minimum">
<number>1</number>
</property>
<property name="maximum">
<number>3840</number>
</property>
<property name="value">
<number>960</number>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="labSnapmaticResolutionSizeX">
<property name="text">
<string>x</string>
</property>
</widget>
</item>
<item>
<widget class="QSpinBox" name="sbSnapmaticResoulutionHeight">
<property name="enabled">
<bool>false</bool>
</property>
<property name="minimum">
<number>1</number>
</property>
<property name="maximum">
<number>2160</number>
</property>
<property name="value">
<number>536</number>
</property>
</widget>
</item>
<item>
<spacer name="hsSnapmaticResolution">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>0</width>
<height>0</height>
</size>
</property>
</spacer>
</item>
</layout>
</item>
</layout>
</widget>
</item>
<item>
<spacer name="vsSnapmatic">
<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>
<layout class="QHBoxLayout" name="hlSnapmaticButtons">
<item>
<spacer name="hsSnapmaticButtons">
<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="cmdSnapmaticExport">
<property name="sizePolicy">
<sizepolicy hsizetype="Minimum" vsizetype="Minimum">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>&amp;Export</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="cmdSnapmaticClose">
<property name="sizePolicy">
<sizepolicy hsizetype="Minimum" vsizetype="Minimum">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>&amp;Close</string>
</property>
</widget>
</item>
</layout>
</item>
</layout>
</widget>
<widget class="QWidget" name="pageSavegame"/>
</widget>
</item>
</layout>
</widget>
<resources/>
<connections/>
</ui>

383
ExportThread.cpp Normal file → Executable file
View File

@ -1,199 +1,184 @@
/*****************************************************************************
* gta5view Grand Theft Auto V Profile Viewer
* Copyright (C) 2016-2020 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 "SnapmaticPicture.h"
#include "ProfileInterface.h"
#include "PictureExport.h"
#include "ProfileWidget.h"
#include "ExportThread.h"
#include "SavegameData.h"
#include "AppEnv.h"
#include "config.h"
#include <QStringBuilder>
#include <QApplication>
#include <QFileInfo>
#include <QFile>
#if QT_VERSION >= 0x050000
#include <QScreen>
#else
#include <QDesktopWidget>
#endif
ExportThread::ExportThread(QMap<ProfileWidget*,QString> profileMap, QString exportDirectory, bool pictureCopyEnabled, bool pictureExportEnabled, int exportCount, QObject *parent) : QThread(parent),
profileMap(profileMap), exportDirectory(exportDirectory), pictureCopyEnabled(pictureCopyEnabled), pictureExportEnabled(pictureExportEnabled), exportCount(exportCount)
{
}
void ExportThread::run()
{
QSettings settings(GTA5SYNC_APPVENDOR, GTA5SYNC_APPSTR);
// Picture Settings
// Quality Settings
settings.beginGroup("Pictures");
int defaultQuality = 100;
QSize defExportSize = QSize(960, 536);
int customQuality = settings.value("CustomQuality", defaultQuality).toInt();
if (customQuality < 1 || customQuality > 100)
{
customQuality = 100;
}
bool useCustomQuality = settings.value("CustomQualityEnabled", false).toBool();
// Size Settings
QSize cusExportSize = settings.value("CustomSize", defExportSize).toSize();
if (cusExportSize.width() > 3840)
{
cusExportSize.setWidth(3840);
}
else if (cusExportSize.height() > 2160)
{
cusExportSize.setHeight(2160);
}
if (cusExportSize.width() < 1)
{
cusExportSize.setWidth(1);
}
else if (cusExportSize.height() < 1)
{
cusExportSize.setHeight(1);
}
QString sizeMode = settings.value("ExportSizeMode", "Default").toString();
Qt::AspectRatioMode aspectRatio = (Qt::AspectRatioMode)settings.value("AspectRatio", Qt::KeepAspectRatio).toInt();
settings.endGroup();
// End Picture Settings
int intExportProgress = 0;
for (ProfileWidget *widget : profileMap.keys())
{
if (widget->isSelected())
{
if (widget->getWidgetType() == "SnapmaticWidget")
{
SnapmaticWidget *picWidget = qobject_cast<SnapmaticWidget*>(widget);
SnapmaticPicture *picture = picWidget->getPicture();
if (pictureExportEnabled)
{
QString exportFileName = PictureExport::getPictureFileName(picture);
if (exportFileName.right(4) != ".jpg" && exportFileName.right(4) != ".png")
{
exportFileName += ".jpg";
}
intExportProgress++;
emit exportStringUpdate(ProfileInterface::tr("Export file %1 of %2 files").arg(QString::number(intExportProgress), QString::number(exportCount)));
emit exportProgressUpdate(intExportProgress);
// Scale Picture
QImage exportPicture = picture->getImage();
if (sizeMode == "Desktop")
{
#if QT_VERSION >= 0x050000
qreal screenRatioPR = AppEnv::screenRatioPR();
QRect desktopResolution = QApplication::primaryScreen()->geometry();
int desktopSizeWidth = qRound((double)desktopResolution.width() * screenRatioPR);
int desktopSizeHeight = qRound((double)desktopResolution.height() * screenRatioPR);
#else
QRect desktopResolution = QApplication::desktop()->screenGeometry();
int desktopSizeWidth = desktopResolution.width();
int desktopSizeHeight = desktopResolution.height();
#endif
exportPicture = exportPicture.scaled(desktopSizeWidth, desktopSizeHeight, aspectRatio, Qt::SmoothTransformation);
}
else if (sizeMode == "Custom")
{
exportPicture = exportPicture.scaled(cusExportSize, aspectRatio, Qt::SmoothTransformation);
}
bool isSaved;
if (useCustomQuality)
{
isSaved = exportPicture.save(exportDirectory % "/" % exportFileName, "JPEG", customQuality);
}
else
{
isSaved = exportPicture.save(exportDirectory % "/" % exportFileName, "JPEG", 100);
}
if (!isSaved)
{
failedExportPictures += exportFileName;
}
}
if (pictureCopyEnabled)
{
QString exportFileName = PictureExport::getPictureFileName(picture);
if (exportFileName.right(4) != ".g5e")
{
exportFileName += ".g5e";
}
intExportProgress++;
emit exportStringUpdate(ProfileInterface::tr("Export file %1 of %2 files").arg(QString::number(intExportProgress), QString::number(exportCount)));
emit exportProgressUpdate(intExportProgress);
QString exportFilePath = exportDirectory % "/" % exportFileName;
if (QFile::exists(exportFilePath)) {QFile::remove(exportFilePath);}
if (!picture->exportPicture(exportDirectory % "/" % exportFileName, SnapmaticFormat::G5E_Format))
{
failedCopyPictures += exportFileName;
}
}
}
else if (widget->getWidgetType() == "SavegameWidget")
{
SavegameWidget *sgdWidget = qobject_cast<SavegameWidget*>(widget);
SavegameData *savegame = sgdWidget->getSavegame();
QString originalFileName = savegame->getSavegameFileName();
QFileInfo originalFileInfo(originalFileName);
QString exportFileName = originalFileInfo.fileName();
intExportProgress++;
emit exportStringUpdate(ProfileInterface::tr("Export file %1 of %2 files").arg(QString::number(intExportProgress), QString::number(exportCount)));
emit exportProgressUpdate(intExportProgress);
QString exportFilePath = exportDirectory % "/" % exportFileName;
if (QFile::exists(exportFilePath)) {QFile::remove(exportFilePath);}
if (!QFile::copy(originalFileName, exportFilePath))
{
failedSavegames += exportFileName;
}
}
}
}
emit exportFinished();
}
QStringList ExportThread::getFailedCopyPictures()
{
return failedCopyPictures;
}
QStringList ExportThread::getFailedExportPictures()
{
return failedExportPictures;
}
QStringList ExportThread::getFailedSavegames()
{
return failedSavegames;
}
/*****************************************************************************
* 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 "SnapmaticPicture.h"
#include "ProfileInterface.h"
#include "PictureExport.h"
#include "ProfileWidget.h"
#include "ExportThread.h"
#include "SavegameData.h"
#include "config.h"
#include <QDesktopWidget>
#include <QApplication>
#include <QFileInfo>
#include <QDebug>
#include <QFile>
ExportThread::ExportThread(QMap<ProfileWidget*,QString> profileMap, QString exportDirectory, bool pictureCopyEnabled, bool pictureExportEnabled, int exportCount, QObject *parent) : QThread(parent),
profileMap(profileMap), exportDirectory(exportDirectory), pictureCopyEnabled(pictureCopyEnabled), pictureExportEnabled(pictureExportEnabled), exportCount(exportCount)
{
}
void ExportThread::run()
{
QSettings settings(GTA5SYNC_APPVENDOR, GTA5SYNC_APPSTR);
// Picture Settings
// Quality Settings
settings.beginGroup("Pictures");
int defaultQuality = 100;
QSize defExportSize = QSize(960, 536);
int customQuality = settings.value("CustomQuality", defaultQuality).toInt();
if (customQuality < 1 || customQuality > 100)
{
customQuality = 100;
}
bool useCustomQuality = settings.value("CustomQualityEnabled", false).toBool();
// Size Settings
QSize cusExportSize = settings.value("CustomSize", defExportSize).toSize();
if (cusExportSize.width() > 3840)
{
cusExportSize.setWidth(3840);
}
else if (cusExportSize.height() > 2160)
{
cusExportSize.setHeight(2160);
}
if (cusExportSize.width() < 1)
{
cusExportSize.setWidth(1);
}
else if (cusExportSize.height() < 1)
{
cusExportSize.setHeight(1);
}
QString sizeMode = settings.value("ExportSizeMode", "Default").toString();
Qt::AspectRatioMode aspectRatio = (Qt::AspectRatioMode)settings.value("AspectRatio", Qt::KeepAspectRatio).toInt();
settings.endGroup();
// End Picture Settings
int intExportProgress = 0;
foreach(ProfileWidget *widget, profileMap.keys())
{
if (widget->isSelected())
{
if (widget->getWidgetType() == "SnapmaticWidget")
{
SnapmaticWidget *picWidget = (SnapmaticWidget*)widget;
SnapmaticPicture *picture = picWidget->getPicture();
if (pictureExportEnabled)
{
QString exportFileName = PictureExport::getPictureFileName(picture);
if (exportFileName.right(4) != ".jpg" && exportFileName.right(4) != ".png")
{
exportFileName.append(".jpg");
}
intExportProgress++;
emit exportStringUpdate(ProfileInterface::tr("Export file %1 of %2 files").arg(QString::number(intExportProgress), QString::number(exportCount)));
emit exportProgressUpdate(intExportProgress);
// Scale Picture
QImage exportPicture = picture->getImage();
if (sizeMode == "Desktop")
{
QRect desktopResolution = QApplication::desktop()->screenGeometry();
exportPicture = exportPicture.scaled(desktopResolution.width(), desktopResolution.height(), aspectRatio, Qt::SmoothTransformation);
}
else if (sizeMode == "Custom")
{
exportPicture = exportPicture.scaled(cusExportSize, aspectRatio, Qt::SmoothTransformation);
}
bool isSaved;
if (useCustomQuality)
{
isSaved = exportPicture.save(exportDirectory + "/" + exportFileName, "JPEG", customQuality);
}
else
{
isSaved = exportPicture.save(exportDirectory + "/" + exportFileName, "JPEG", 100);
}
if (!isSaved)
{
failedExportPictures.append(exportFileName);
}
}
if (pictureCopyEnabled)
{
QString exportFileName = PictureExport::getPictureFileName(picture);
if (exportFileName.right(4) != ".g5e")
{
exportFileName.append(".g5e");
}
intExportProgress++;
emit exportStringUpdate(ProfileInterface::tr("Export file %1 of %2 files").arg(QString::number(intExportProgress), QString::number(exportCount)));
emit exportProgressUpdate(intExportProgress);
QString exportFilePath = exportDirectory + "/" + exportFileName;
if (QFile::exists(exportFilePath)) {QFile::remove(exportFilePath);}
if (!picture->exportPicture(exportDirectory + "/" + exportFileName, true))
{
failedCopyPictures.append(exportFileName);
}
}
}
else if (widget->getWidgetType() == "SavegameWidget")
{
SavegameWidget *sgdWidget = (SavegameWidget*)widget;
SavegameData *savegame = sgdWidget->getSavegame();
QString originalFileName = savegame->getSavegameFileName();
QFileInfo originalFileInfo(originalFileName);
QString exportFileName = originalFileInfo.fileName();
intExportProgress++;
emit exportStringUpdate(ProfileInterface::tr("Export file %1 of %2 files").arg(QString::number(intExportProgress), QString::number(exportCount)));
emit exportProgressUpdate(intExportProgress);
QString exportFilePath = exportDirectory + "/" + exportFileName;
if (QFile::exists(exportFilePath)) {QFile::remove(exportFilePath);}
if (!QFile::copy(originalFileName, exportFilePath))
{
failedSavegames.append(exportFileName);
}
}
}
}
emit exportFinished();
}
QStringList ExportThread::getFailedCopyPictures()
{
return failedCopyPictures;
}
QStringList ExportThread::getFailedExportPictures()
{
return failedExportPictures;
}
QStringList ExportThread::getFailedSavegames()
{
return failedSavegames;
}

112
ExportThread.h Normal file → Executable file
View File

@ -1,56 +1,56 @@
/*****************************************************************************
* gta5view Grand Theft Auto V Profile Viewer
* 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 EXPORTTHREAD_H
#define EXPORTTHREAD_H
#include "SnapmaticWidget.h"
#include "SavegameWidget.h"
#include "ProfileWidget.h"
#include <QThread>
#include <QMap>
class ExportThread : public QThread
{
Q_OBJECT
public:
explicit ExportThread(QMap<ProfileWidget*,QString> profileMap, QString exportDirectory, bool pictureCopyEnabled, bool pictureExportEnabled, int exportCount, QObject *parent = 0);
QStringList getFailedSavegames();
QStringList getFailedCopyPictures();
QStringList getFailedExportPictures();
protected:
void run();
private:
QMap <ProfileWidget*, QString> profileMap;
QString exportDirectory;
bool pictureCopyEnabled;
bool pictureExportEnabled;
int exportCount;
QStringList failedSavegames;
QStringList failedCopyPictures;
QStringList failedExportPictures;
signals:
void exportStringUpdate(QString currentFileName);
void exportProgressUpdate(int currentProgressValue);
void exportFinished();
};
#endif // EXPORTTHREAD_H
/*****************************************************************************
* 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 EXPORTTHREAD_H
#define EXPORTTHREAD_H
#include "SnapmaticWidget.h"
#include "SavegameWidget.h"
#include "ProfileWidget.h"
#include <QThread>
#include <QMap>
class ExportThread : public QThread
{
Q_OBJECT
public:
explicit ExportThread(QMap<ProfileWidget*,QString> profileMap, QString exportDirectory, bool pictureCopyEnabled, bool pictureExportEnabled, int exportCount, QObject *parent = 0);
QStringList getFailedSavegames();
QStringList getFailedCopyPictures();
QStringList getFailedExportPictures();
protected:
void run();
private:
QMap <ProfileWidget*, QString> profileMap;
QString exportDirectory;
bool pictureCopyEnabled;
bool pictureExportEnabled;
int exportCount;
QStringList failedSavegames;
QStringList failedCopyPictures;
QStringList failedExportPictures;
signals:
void exportStringUpdate(QString currentFileName);
void exportProgressUpdate(int currentProgressValue);
void exportFinished();
};
#endif // EXPORTTHREAD_H

171
GlobalString.cpp Normal file → Executable file
View File

@ -1,82 +1,89 @@
/*****************************************************************************
* gta5view Grand Theft Auto V Profile Viewer
* Copyright (C) 2016-2020 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 "TranslationClass.h"
#include "GlobalString.h"
#include "config.h"
#include <QStringBuilder>
#include <QStringList>
#include <QFileInfo>
#include <QSettings>
#include <QLocale>
#include <QDebug>
GlobalString::GlobalString()
{
}
QMap<QString, QString> GlobalString::getGlobalMap()
{
QMap<QString, QString> globalMap;
QSettings globalFile(getLanguageFile(), QSettings::IniFormat);
#if QT_VERSION < 0x060000
globalFile.setIniCodec("UTF-8");
#endif
globalFile.beginGroup("Global");
for (const QString &globalStr : globalFile.childKeys())
{
globalMap[globalStr] = globalFile.value(globalStr, globalStr).toString();
}
globalFile.endGroup();
return globalMap;
}
QString GlobalString::getString(QString valueStr, bool *ok)
{
QString globalString = valueStr;
QSettings globalFile(getLanguageFile(), QSettings::IniFormat);
#if QT_VERSION < 0x060000
globalFile.setIniCodec("UTF-8");
#endif
globalFile.beginGroup("Global");
QStringList globalStrList = globalFile.childKeys();
if (globalStrList.contains(valueStr))
{
if (ok != nullptr) *ok = true;
globalString = globalFile.value(valueStr, valueStr).toString();
}
globalFile.endGroup();
return globalString;
}
QString GlobalString::getLanguageFile()
{
QString language = getLanguage();
QString languageFile = ":/global/global." % language % ".ini";
if (!QFileInfo(languageFile).exists())
{
languageFile = ":/global/global.en.ini";
}
return languageFile;
}
QString GlobalString::getLanguage()
{
return Translator->getCurrentAreaLanguage();
}
/*****************************************************************************
* 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 <QLocale>
#include <QSettings>
#include <QFileInfo>
#include <QStringList>
#include "GlobalString.h"
#include "config.h"
GlobalString::GlobalString()
{
}
QMap<QString, QString> GlobalString::getGlobalMap()
{
QMap<QString, QString> globalMap;
QSettings globalFile(getLanguageFile(), QSettings::IniFormat);
globalFile.setIniCodec("UTF-8");
globalFile.beginGroup("Global");
QStringList globalStrList = globalFile.childKeys();
foreach(const QString &globalStr, globalStrList)
{
globalMap[globalStr] = globalFile.value(globalStr, globalStr).toString();
}
globalFile.endGroup();
return globalMap;
}
QString GlobalString::getString(QString valueStr, bool *ok)
{
QString globalString = valueStr;
QSettings globalFile(getLanguageFile(), QSettings::IniFormat);
globalFile.setIniCodec("UTF-8");
globalFile.beginGroup("Global");
QStringList globalStrList = globalFile.childKeys();
if (globalStrList.contains(valueStr))
{
if (ok != 0) *ok = true;
globalString = globalFile.value(valueStr, valueStr).toString();
}
globalFile.endGroup();
return globalString;
}
QString GlobalString::getLanguageFile()
{
QString language = getLanguage();
QString languageFile = ":/global/global." + language + ".ini";
if (!QFileInfo(languageFile).exists())
{
languageFile = ":/global/global.en.ini";
}
return languageFile;
}
QString GlobalString::getLanguage()
{
QSettings settings(GTA5SYNC_APPVENDOR, GTA5SYNC_APPSTR);
settings.beginGroup("Interface");
QString language = settings.value("Language","System").toString();
settings.endGroup();
if (language == "System" || language.trimmed() == "")
{
QString languageName = QLocale::system().name();
QStringList langList = languageName.split("_");
if (langList.length() >= 1)
{
language = langList.at(0);
}
}
return language;
}

70
GlobalString.h Normal file → Executable file
View File

@ -1,35 +1,35 @@
/*****************************************************************************
* gta5view Grand Theft Auto V Profile Viewer
* 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 GLOBALSTRING_H
#define GLOBALSTRING_H
#include <QString>
#include <QMap>
class GlobalString
{
public:
GlobalString();
static QString getString(QString valueStr, bool *ok = nullptr);
static QString getLanguageFile();
static QString getLanguage();
static QMap<QString, QString> getGlobalMap();
};
#endif // GLOBALSTRING_H
/*****************************************************************************
* 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 GLOBALSTRING_H
#define GLOBALSTRING_H
#include <QString>
#include <QMap>
class GlobalString
{
public:
GlobalString();
static QString getString(QString valueStr, bool *ok = 0);
static QString getLanguageFile();
static QString getLanguage();
static QMap<QString, QString> getGlobalMap();
};
#endif // GLOBALSTRING_H

90
IconLoader.cpp Normal file → Executable file
View File

@ -1,50 +1,40 @@
/*****************************************************************************
* gta5view Grand Theft Auto V Profile Viewer
* 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 "IconLoader.h"
#include <QIcon>
IconLoader::IconLoader()
{
}
QIcon IconLoader::loadingAppIcon()
{
QIcon appIcon;
appIcon.addFile(":/img/gta5view-16.png", QSize(16, 16));
appIcon.addFile(":/img/gta5view-24.png", QSize(24, 24));
appIcon.addFile(":/img/gta5view-32.png", QSize(32, 32));
appIcon.addFile(":/img/gta5view-40.png", QSize(40, 40));
appIcon.addFile(":/img/gta5view-48.png", QSize(48, 48));
appIcon.addFile(":/img/gta5view-64.png", QSize(64, 64));
appIcon.addFile(":/img/gta5view-96.png", QSize(96, 96));
appIcon.addFile(":/img/gta5view-128.png", QSize(128, 128));
appIcon.addFile(":/img/gta5view-256.png", QSize(256, 256));
return appIcon;
}
QIcon IconLoader::loadingPointmakerIcon()
{
QIcon pointmakerIcon;
pointmakerIcon.addFile(":/img/pointmaker-8.png", QSize(8, 8));
pointmakerIcon.addFile(":/img/pointmaker-16.png", QSize(16, 16));
pointmakerIcon.addFile(":/img/pointmaker-24.png", QSize(24, 24));
pointmakerIcon.addFile(":/img/pointmaker-32.png", QSize(32, 32));
return pointmakerIcon;
}
/*****************************************************************************
* 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 "IconLoader.h"
#include <QIcon>
IconLoader::IconLoader()
{
}
QIcon IconLoader::loadingAppIcon()
{
QIcon appIcon;
appIcon.addFile(":/img/5sync-16.png", QSize(16, 16));
appIcon.addFile(":/img/5sync-24.png", QSize(24, 24));
appIcon.addFile(":/img/5sync-32.png", QSize(32, 32));
appIcon.addFile(":/img/5sync-40.png", QSize(40, 40));
appIcon.addFile(":/img/5sync-48.png", QSize(48, 48));
appIcon.addFile(":/img/5sync-64.png", QSize(64, 64));
appIcon.addFile(":/img/5sync-96.png", QSize(96, 96));
appIcon.addFile(":/img/5sync-128.png", QSize(128, 128));
appIcon.addFile(":/img/5sync-256.png", QSize(256, 256));
return appIcon;
}

63
IconLoader.h Normal file → Executable file
View File

@ -1,32 +1,31 @@
/*****************************************************************************
* gta5view Grand Theft Auto V Profile Viewer
* 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 ICONLOADER_H
#define ICONLOADER_H
#include <QIcon>
class IconLoader
{
public:
IconLoader();
static QIcon loadingAppIcon();
static QIcon loadingPointmakerIcon();
};
#endif // ICONLOADER_H
/*****************************************************************************
* 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 ICONLOADER_H
#define ICONLOADER_H
#include <QIcon>
class IconLoader
{
public:
IconLoader();
static QIcon loadingAppIcon();
};
#endif // ICONLOADER_H

File diff suppressed because it is too large Load Diff

View File

@ -1,87 +1,57 @@
/*****************************************************************************
* gta5view Grand Theft Auto V Profile Viewer
* Copyright (C) 2017-2020 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 IMPORTDIALOG_H
#define IMPORTDIALOG_H
#include <QDialog>
#include <QMenu>
namespace Ui {
class ImportDialog;
}
class ImportDialog : public QDialog
{
Q_OBJECT
public:
explicit ImportDialog(QString profileName, QWidget *parent = 0);
~ImportDialog();
QImage image();
QString getImageTitle();
void setImage(QImage *image);
void lockSettings(bool lock);
void enableOverwriteMode();
bool isImportAgreed();
bool areSettingsLocked();
private slots:
void processImage();
void cropPicture();
void importNewPicture();
void loadImportSettings();
void saveImportSettings();
void on_cbIgnore_toggled(bool checked);
void on_cbAvatar_toggled(bool checked);
void on_cmdCancel_clicked();
void on_cmdOK_clicked();
void on_labPicture_labelPainted();
void on_cmdColourChange_clicked();
void on_cmdBackgroundChange_clicked();
void on_cmdBackgroundWipe_clicked();
void on_cbStretch_toggled(bool checked);
void on_cbForceAvatarColour_toggled(bool checked);
void on_cbWatermark_toggled(bool checked);
private:
QString profileName;
Ui::ImportDialog *ui;
QImage avatarAreaImage;
QString backgroundPath;
QString imageTitle;
QImage backImage;
QImage workImage;
QImage origImage;
QImage newImage;
QColor selectedColour;
QMenu *optionsMenu;
bool insideAvatarZone;
bool watermarkPicture;
bool watermarkAvatar;
bool watermarkBlock;
bool settingsLocked;
bool importAgreed;
int snapmaticResolutionLW;
int snapmaticResolutionLH;
void processWatermark(QPainter *snapmaticPainter);
void processSettings(QString settingsProfile, bool setDefault = false);
void saveSettings(QString settingsProfile);
};
#endif // IMPORTDIALOG_H
/*****************************************************************************
* gta5sync GRAND THEFT AUTO V SYNC
* Copyright (C) 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 IMPORTDIALOG_H
#define IMPORTDIALOG_H
#include <QDialog>
namespace Ui {
class ImportDialog;
}
class ImportDialog : public QDialog
{
Q_OBJECT
public:
explicit ImportDialog(QWidget *parent = 0);
~ImportDialog();
QImage image();
QString getImageTitle();
void setImage(const QImage &image);
bool isDoImport();
private slots:
void processImage();
void on_rbIgnore_clicked();
void on_rbKeep_clicked();
void on_cbAvatar_clicked();
void on_cmdCancel_clicked();
void on_cmdOK_clicked();
private:
Ui::ImportDialog *ui;
QImage avatarAreaImage;
QString imageTitle;
QImage workImage;
QImage newImage;
bool doImport;
};
#endif // IMPORTDIALOG_H

View File

@ -1,382 +1,180 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>ImportDialog</class>
<widget class="QDialog" name="ImportDialog">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>516</width>
<height>512</height>
</rect>
</property>
<property name="minimumSize">
<size>
<width>516</width>
<height>512</height>
</size>
</property>
<property name="windowTitle">
<string>Import...</string>
</property>
<property name="modal">
<bool>true</bool>
</property>
<layout class="QVBoxLayout" name="vlImport">
<property name="leftMargin">
<number>0</number>
</property>
<property name="topMargin">
<number>0</number>
</property>
<property name="rightMargin">
<number>0</number>
</property>
<property name="bottomMargin">
<number>0</number>
</property>
<item>
<widget class="UiModLabel" name="labPicture">
<property name="minimumSize">
<size>
<width>516</width>
<height>288</height>
</size>
</property>
<property name="text">
<string/>
</property>
</widget>
</item>
<item>
<widget class="QFrame" name="buttomFrame">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="MinimumExpanding">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="frameShape">
<enum>QFrame::NoFrame</enum>
</property>
<property name="frameShadow">
<enum>QFrame::Plain</enum>
</property>
<property name="lineWidth">
<number>0</number>
</property>
<layout class="QVBoxLayout" name="vlButtom">
<property name="leftMargin">
<number>9</number>
</property>
<property name="topMargin">
<number>6</number>
</property>
<property name="rightMargin">
<number>9</number>
</property>
<property name="bottomMargin">
<number>9</number>
</property>
<item>
<widget class="QGroupBox" name="gbSettings">
<property name="title">
<string>Picture</string>
</property>
<layout class="QVBoxLayout" name="vlSettings">
<item>
<layout class="QHBoxLayout" name="hlCheckboxesTop">
<item>
<widget class="QCheckBox" name="cbAvatar">
<property name="sizePolicy">
<sizepolicy hsizetype="MinimumExpanding" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>Avatar</string>
</property>
</widget>
</item>
<item>
<widget class="QCheckBox" name="cbIgnore">
<property name="sizePolicy">
<sizepolicy hsizetype="MinimumExpanding" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>Ignore Aspect Ratio</string>
</property>
</widget>
</item>
</layout>
</item>
<item>
<layout class="QHBoxLayout" name="hlCheckboxesButtom">
<item>
<widget class="QCheckBox" name="cbWatermark">
<property name="sizePolicy">
<sizepolicy hsizetype="MinimumExpanding" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>Watermark</string>
</property>
</widget>
</item>
</layout>
</item>
</layout>
</widget>
</item>
<item>
<widget class="QGroupBox" name="gbBackground">
<property name="title">
<string>Background</string>
</property>
<layout class="QVBoxLayout" name="vlBackground">
<item>
<layout class="QHBoxLayout" name="hlColour">
<item>
<layout class="QHBoxLayout" name="hlColourManage">
<item>
<widget class="QLabel" name="labColour">
<property name="text">
<string>Background Colour: &lt;span style=&quot;color: %1&quot;&gt;%1&lt;/span&gt;</string>
</property>
</widget>
</item>
<item>
<layout class="QHBoxLayout" name="hlColourButton">
<property name="spacing">
<number>0</number>
</property>
<property name="leftMargin">
<number>0</number>
</property>
<property name="topMargin">
<number>0</number>
</property>
<property name="rightMargin">
<number>0</number>
</property>
<property name="bottomMargin">
<number>0</number>
</property>
<item>
<widget class="QToolButton" name="cmdColourChange">
<property name="toolTip">
<string>Select background colour</string>
</property>
<property name="text">
<string>...</string>
</property>
</widget>
</item>
</layout>
</item>
<item>
<spacer name="hsColour">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
</layout>
</item>
<item>
<layout class="QHBoxLayout" name="hlBackgroundManage">
<item>
<widget class="QLabel" name="labBackgroundImage">
<property name="text">
<string>Background Image:</string>
</property>
</widget>
</item>
<item>
<layout class="QHBoxLayout" name="hlBackgroundButton">
<property name="spacing">
<number>0</number>
</property>
<property name="leftMargin">
<number>0</number>
</property>
<property name="topMargin">
<number>0</number>
</property>
<property name="rightMargin">
<number>0</number>
</property>
<property name="bottomMargin">
<number>0</number>
</property>
<item>
<widget class="QToolButton" name="cmdBackgroundChange">
<property name="toolTip">
<string>Select background image</string>
</property>
<property name="text">
<string>...</string>
</property>
</widget>
</item>
<item>
<widget class="QToolButton" name="cmdBackgroundWipe">
<property name="toolTip">
<string>Remove background image</string>
</property>
<property name="text">
<string>X</string>
</property>
</widget>
</item>
</layout>
</item>
<item>
<spacer name="hsBackgroundImage">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
</layout>
</item>
</layout>
</item>
<item>
<layout class="QHBoxLayout" name="hlBackground">
<item>
<widget class="QCheckBox" name="cbForceAvatarColour">
<property name="text">
<string>Force Colour in Avatar Zone</string>
</property>
</widget>
</item>
<item>
<widget class="QCheckBox" name="cbStretch">
<property name="enabled">
<bool>true</bool>
</property>
<property name="text">
<string>Ignore Aspect Ratio</string>
</property>
</widget>
</item>
</layout>
</item>
</layout>
</widget>
</item>
<item>
<spacer name="vsInterface">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>0</width>
<height>0</height>
</size>
</property>
</spacer>
</item>
<item>
<layout class="QHBoxLayout" name="hlButtons">
<item>
<widget class="QPushButton" name="cmdOptions">
<property name="toolTip">
<string>Import options</string>
</property>
<property name="text">
<string>&amp;Options</string>
</property>
<property name="autoDefault">
<bool>false</bool>
</property>
</widget>
</item>
<item>
<spacer name="hsButtons">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>0</width>
<height>0</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QPushButton" name="cmdOK">
<property name="sizePolicy">
<sizepolicy hsizetype="Minimum" vsizetype="Minimum">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="toolTip">
<string>Import picture</string>
</property>
<property name="text">
<string>&amp;OK</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="cmdCancel">
<property name="sizePolicy">
<sizepolicy hsizetype="Minimum" vsizetype="Minimum">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="toolTip">
<string>Discard picture</string>
</property>
<property name="text">
<string>&amp;Cancel</string>
</property>
</widget>
</item>
</layout>
</item>
</layout>
</widget>
</item>
</layout>
</widget>
<customwidgets>
<customwidget>
<class>UiModLabel</class>
<extends>QLabel</extends>
<header>uimod/UiModLabel.h</header>
<slots>
<signal>mouseMoved()</signal>
<signal>mouseReleased()</signal>
<signal>mousePressed()</signal>
<signal>mouseDoubleClicked()</signal>
</slots>
</customwidget>
</customwidgets>
<resources/>
<connections/>
</ui>
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>ImportDialog</class>
<widget class="QDialog" name="ImportDialog">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>430</width>
<height>380</height>
</rect>
</property>
<property name="minimumSize">
<size>
<width>430</width>
<height>380</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>430</width>
<height>380</height>
</size>
</property>
<property name="windowTitle">
<string>Import...</string>
</property>
<property name="modal">
<bool>true</bool>
</property>
<layout class="QVBoxLayout" name="vlImport">
<property name="leftMargin">
<number>0</number>
</property>
<property name="topMargin">
<number>0</number>
</property>
<property name="rightMargin">
<number>0</number>
</property>
<property name="bottomMargin">
<number>0</number>
</property>
<item>
<widget class="QLabel" name="labPicture">
<property name="minimumSize">
<size>
<width>430</width>
<height>240</height>
</size>
</property>
<property name="text">
<string/>
</property>
</widget>
</item>
<item>
<widget class="QFrame" name="buttomFrame">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="MinimumExpanding">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="frameShape">
<enum>QFrame::NoFrame</enum>
</property>
<property name="frameShadow">
<enum>QFrame::Plain</enum>
</property>
<property name="lineWidth">
<number>0</number>
</property>
<layout class="QVBoxLayout" name="vlButtom">
<property name="leftMargin">
<number>9</number>
</property>
<property name="topMargin">
<number>6</number>
</property>
<property name="rightMargin">
<number>9</number>
</property>
<property name="bottomMargin">
<number>9</number>
</property>
<item>
<widget class="QGroupBox" name="gbSettings">
<property name="title">
<string>Settings</string>
</property>
<layout class="QGridLayout" name="gdSettings">
<item row="1" column="0">
<widget class="QRadioButton" name="rbKeep">
<property name="text">
<string>&amp;Keep Aspect Ratio</string>
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="QRadioButton" name="rbIgnore">
<property name="text">
<string>&amp;Ignore Aspect Ratio</string>
</property>
</widget>
</item>
<item row="0" column="0">
<widget class="QCheckBox" name="cbAvatar">
<property name="text">
<string>&amp;Avatar</string>
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item>
<spacer name="vsDialog">
<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>
<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="cmdOK">
<property name="sizePolicy">
<sizepolicy hsizetype="Minimum" vsizetype="Minimum">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>&amp;OK</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="cmdCancel">
<property name="sizePolicy">
<sizepolicy hsizetype="Minimum" vsizetype="Minimum">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>&amp;Cancel</string>
</property>
</widget>
</item>
</layout>
</item>
</layout>
</widget>
</item>
</layout>
</widget>
<resources/>
<connections/>
</ui>

View File

@ -1,242 +0,0 @@
/*****************************************************************************
* gta5view Grand Theft Auto V Profile Viewer
* Copyright (C) 2017-2018 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 "JsonEditorDialog.h"
#include "ui_JsonEditorDialog.h"
#include "SnapmaticEditor.h"
#include "AppEnv.h"
#include "config.h"
#include <QStringBuilder>
#include <QJsonDocument>
#include <QJsonObject>
#include <QMessageBox>
#if QT_VERSION >= 0x050200
#include <QFontDatabase>
#include <QDebug>
#endif
#ifdef GTA5SYNC_TELEMETRY
#include "TelemetryClass.h"
#endif
JsonEditorDialog::JsonEditorDialog(SnapmaticPicture *picture, QWidget *parent) :
QDialog(parent), smpic(picture),
ui(new Ui::JsonEditorDialog)
{
// Set Window Flags
setWindowFlags(windowFlags()^Qt::WindowContextHelpButtonHint^Qt::WindowMinMaxButtonsHint);
ui->setupUi(this);
ui->cmdClose->setDefault(true);
ui->cmdClose->setFocus();
// Set Icon for Close Button
if (QIcon::hasThemeIcon("dialog-close"))
{
ui->cmdClose->setIcon(QIcon::fromTheme("dialog-close"));
}
else if (QIcon::hasThemeIcon("gtk-close"))
{
ui->cmdClose->setIcon(QIcon::fromTheme("gtk-close"));
}
// Set Icon for Save Button
if (QIcon::hasThemeIcon("document-save"))
{
ui->cmdSave->setIcon(QIcon::fromTheme("document-save"));
}
else if (QIcon::hasThemeIcon("gtk-save"))
{
ui->cmdSave->setIcon(QIcon::fromTheme("gtk-save"));
}
jsonCode = picture->getJsonStr();
#if QT_VERSION >= 0x050200
ui->txtJSON->setFont(QFontDatabase::systemFont(QFontDatabase::FixedFont));
#else
QFont jsonFont = ui->txtJSON->font();
jsonFont.setStyleHint(QFont::Monospace);
jsonFont.setFixedPitch(true);
ui->txtJSON->setFont(jsonFont);
#endif
QFontMetrics fontMetrics(ui->txtJSON->font());
#if QT_VERSION >= 0x050B00
ui->txtJSON->setTabStopDistance(fontMetrics.horizontalAdvance(" "));
#else
ui->txtJSON->setTabStopWidth(fontMetrics.width(" "));
#endif
QJsonDocument jsonDocument = QJsonDocument::fromJson(jsonCode.toUtf8());
ui->txtJSON->setStyleSheet("QPlainTextEdit{background-color: rgb(46, 47, 48); color: rgb(238, 231, 172);}");
ui->txtJSON->setPlainText(QString::fromUtf8(jsonDocument.toJson(QJsonDocument::Indented)).trimmed());
jsonHl = new JSHighlighter(ui->txtJSON->document());
// 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));
ui->lineJSON->setMaximumHeight(qRound(1 * screenRatio));
ui->lineJSON->setLineWidth(qRound(1 * screenRatio));
}
resize(450 * screenRatio, 550 * screenRatio);
}
JsonEditorDialog::~JsonEditorDialog()
{
delete jsonHl;
delete ui;
}
void JsonEditorDialog::closeEvent(QCloseEvent *ev)
{
QString jsonPatched = QString(ui->txtJSON->toPlainText()).replace("\t", " ");
QJsonDocument jsonNew = QJsonDocument::fromJson(jsonPatched.toUtf8());
QJsonDocument jsonOriginal = QJsonDocument::fromJson(jsonCode.toUtf8());
QString originalCode = QString::fromUtf8(jsonOriginal.toJson(QJsonDocument::Compact));
QString newCode = QString::fromUtf8(jsonNew.toJson(QJsonDocument::Compact));
if (newCode != originalCode)
{
QMessageBox::StandardButton button = QMessageBox::warning(this, SnapmaticEditor::tr("Snapmatic Properties"), SnapmaticEditor::tr("<h4>Unsaved changes detected</h4>You want to save the JSON content before you quit?"), QMessageBox::Yes | QMessageBox::No | QMessageBox::Cancel, QMessageBox::Cancel);
if (button == QMessageBox::Yes)
{
if (saveJsonContent())
{
ev->accept();
}
else
{
ev->ignore();
}
return;
}
else if (button == QMessageBox::No)
{
ev->accept();
return;
}
else
{
ev->ignore();
return;
}
}
}
bool JsonEditorDialog::saveJsonContent()
{
QString jsonPatched = QString(ui->txtJSON->toPlainText()).replace("\t", " ");
QJsonDocument jsonNew = QJsonDocument::fromJson(jsonPatched.toUtf8());
if (!jsonNew.isEmpty())
{
QJsonDocument jsonOriginal = QJsonDocument::fromJson(jsonCode.toUtf8());
QString originalCode = QString::fromUtf8(jsonOriginal.toJson(QJsonDocument::Compact));
QString newCode = QString::fromUtf8(jsonNew.toJson(QJsonDocument::Compact));
if (newCode != originalCode)
{
QString currentFilePath = smpic->getPictureFilePath();
QString originalFilePath = smpic->getOriginalPictureFilePath();
QString backupFileName = originalFilePath % ".bak";
if (!QFile::exists(backupFileName))
{
QFile::copy(currentFilePath, backupFileName);
}
smpic->setJsonStr(newCode, true);
if (!smpic->isJsonOk())
{
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;
}
if (!smpic->exportPicture(currentFilePath))
{
QMessageBox::warning(this, SnapmaticEditor::tr("Snapmatic Properties"), SnapmaticEditor::tr("Patching of Snapmatic Properties failed because of I/O Error"));
smpic->setJsonStr(originalCode, true);
return false;
}
jsonCode = newCode;
smpic->updateStrings();
smpic->emitUpdate();
#ifdef GTA5SYNC_TELEMETRY
QSettings telemetrySettings(GTA5SYNC_APPVENDOR, GTA5SYNC_APPSTR);
telemetrySettings.beginGroup("Telemetry");
bool pushUsageData = telemetrySettings.value("PushUsageData", false).toBool();
telemetrySettings.endGroup();
if (pushUsageData && Telemetry->canPush())
{
QJsonDocument jsonDocument;
QJsonObject jsonObject;
jsonObject["Type"] = "JSONEdited";
jsonObject["EditedSize"] = QString::number(smpic->getContentMaxLength());
jsonObject["EditedTime"] = QString::number(QDateTime::currentDateTimeUtc().toTime_t());
jsonDocument.setObject(jsonObject);
Telemetry->push(TelemetryCategory::PersonalData, jsonDocument);
}
#endif
return true;
}
return true;
}
else
{
QMessageBox::warning(this, SnapmaticEditor::tr("Snapmatic Properties"), SnapmaticEditor::tr("Patching of Snapmatic Properties failed because of JSON Error"));
return false;
}
}
void JsonEditorDialog::on_cmdClose_clicked()
{
close();
}
void JsonEditorDialog::on_cmdSave_clicked()
{
if (saveJsonContent())
{
close();
}
}

View File

@ -1,56 +0,0 @@
/*****************************************************************************
* gta5view Grand Theft Auto V Profile Viewer
* Copyright (C) 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 JSONEDITORDIALOG_H
#define JSONEDITORDIALOG_H
#include "SnapmaticPicture.h"
#include "JSHighlighter.h"
#include <QDialog>
namespace Ui {
class JsonEditorDialog;
}
class JsonEditorDialog : public QDialog
{
Q_OBJECT
public:
explicit JsonEditorDialog(SnapmaticPicture *picture, QWidget *parent = 0);
bool saveJsonContent();
~JsonEditorDialog();
protected:
void closeEvent(QCloseEvent *ev);
private slots:
void on_cmdClose_clicked();
void on_cmdSave_clicked();
signals:
void codeUpdated(QString jsonCode);
private:
QString jsonCode;
JSHighlighter *jsonHl;
SnapmaticPicture *smpic;
Ui::JsonEditorDialog *ui;
};
#endif // JSONEDITORDIALOG_H

View File

@ -1,145 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>JsonEditorDialog</class>
<widget class="QDialog" name="JsonEditorDialog">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>550</width>
<height>450</height>
</rect>
</property>
<property name="windowTitle">
<string>Snapmatic JSON Editor</string>
</property>
<layout class="QVBoxLayout" name="vlInterface">
<property name="leftMargin">
<number>0</number>
</property>
<property name="topMargin">
<number>0</number>
</property>
<property name="rightMargin">
<number>0</number>
</property>
<property name="bottomMargin">
<number>9</number>
</property>
<item>
<layout class="QVBoxLayout" name="vlJSON">
<property name="spacing">
<number>0</number>
</property>
<property name="leftMargin">
<number>0</number>
</property>
<property name="topMargin">
<number>0</number>
</property>
<property name="rightMargin">
<number>0</number>
</property>
<property name="bottomMargin">
<number>0</number>
</property>
<item>
<widget class="QPlainTextEdit" name="txtJSON">
<property name="frameShape">
<enum>QFrame::NoFrame</enum>
</property>
<property name="frameShadow">
<enum>QFrame::Plain</enum>
</property>
<property name="lineWidth">
<number>0</number>
</property>
</widget>
</item>
<item>
<widget class="Line" name="lineJSON">
<property name="minimumSize">
<size>
<width>0</width>
<height>1</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>16777215</width>
<height>1</height>
</size>
</property>
<property name="styleSheet">
<string notr="true">QFrame[frameShape=&quot;4&quot;]
{
color: black;
}</string>
</property>
<property name="frameShadow">
<enum>QFrame::Plain</enum>
</property>
<property name="lineWidth">
<number>1</number>
</property>
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
</widget>
</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="cmdSave">
<property name="sizePolicy">
<sizepolicy hsizetype="Minimum" vsizetype="Minimum">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="toolTip">
<string>Apply changes</string>
</property>
<property name="text">
<string>&amp;Save</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="cmdClose">
<property name="sizePolicy">
<sizepolicy hsizetype="Minimum" vsizetype="Minimum">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="toolTip">
<string>Discard changes</string>
</property>
<property name="text">
<string>&amp;Close</string>
</property>
</widget>
</item>
</layout>
</item>
</layout>
</widget>
<resources/>
<connections/>
</ui>

14
LICENSE
View File

@ -1,7 +1,7 @@
GNU GENERAL PUBLIC LICENSE
Version 3, 29 June 2007
Copyright (C) 2007 Free Software Foundation, Inc. <https://fsf.org/>
Copyright (C) 2007 Free Software Foundation, Inc. <http://fsf.org/>
Everyone is permitted to copy and distribute verbatim copies
of this license document, but changing it is not allowed.
@ -631,8 +631,8 @@ to attach them to the start of each source file to most effectively
state the exclusion of warranty; and each file should have at least
the "copyright" line and a pointer to where the full notice is found.
<one line to give the program's name and a brief idea of what it does.>
Copyright (C) <year> <name of author>
{one line to give the program's name and a brief idea of what it does.}
Copyright (C) {year} {name of author}
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
@ -645,14 +645,14 @@ the "copyright" line and a pointer to where the full notice is found.
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 <https://www.gnu.org/licenses/>.
along with this program. If not, see <http://www.gnu.org/licenses/>.
Also add information on how to contact you by electronic and paper mail.
If the program does terminal interaction, make it output a short
notice like this when it starts in an interactive mode:
<program> Copyright (C) <year> <name of author>
{project} Copyright (C) {year} {fullname}
This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
This is free software, and you are welcome to redistribute it
under certain conditions; type `show c' for details.
@ -664,11 +664,11 @@ might be different; for a GUI interface, you would use an "about box".
You should also get your employer (if you work as a programmer) or school,
if any, to sign a "copyright disclaimer" for the program, if necessary.
For more information on this, and how to apply and follow the GNU GPL, see
<https://www.gnu.org/licenses/>.
<http://www.gnu.org/licenses/>.
The GNU General Public License does not permit incorporating your program
into proprietary programs. If your program is a subroutine library, you
may consider it more useful to permit linking proprietary applications with
the library. If this is what you want to do, use the GNU Lesser General
Public License instead of this License. But first, please read
<https://www.gnu.org/licenses/why-not-lgpl.html>.
<http://www.gnu.org/philosophy/why-not-lgpl.html>.

54
LICENSE.GPL Normal file → Executable file
View File

@ -1,7 +1,7 @@
GNU GENERAL PUBLIC LICENSE
Version 3, 29 June 2007
Copyright (C) 2007 Free Software Foundation, Inc. <https://fsf.org/>
Copyright (C) 2007 Free Software Foundation, Inc. <http://fsf.org/>
Everyone is permitted to copy and distribute verbatim copies
of this license document, but changing it is not allowed.
@ -620,55 +620,3 @@ copy of the Program in return for a fee.
END OF TERMS AND CONDITIONS
How to Apply These Terms to Your New Programs
If you develop a new program, and you want it to be of the greatest
possible use to the public, the best way to achieve this is to make it
free software which everyone can redistribute and change under these terms.
To do so, attach the following notices to the program. It is safest
to attach them to the start of each source file to most effectively
state the exclusion of warranty; and each file should have at least
the "copyright" line and a pointer to where the full notice is found.
<one line to give the program's name and a brief idea of what it does.>
Copyright (C) <year> <name of author>
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 <https://www.gnu.org/licenses/>.
Also add information on how to contact you by electronic and paper mail.
If the program does terminal interaction, make it output a short
notice like this when it starts in an interactive mode:
<program> Copyright (C) <year> <name of author>
This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
This is free software, and you are welcome to redistribute it
under certain conditions; type `show c' for details.
The hypothetical commands `show w' and `show c' should show the appropriate
parts of the General Public License. Of course, your program's commands
might be different; for a GUI interface, you would use an "about box".
You should also get your employer (if you work as a programmer) or school,
if any, to sign a "copyright disclaimer" for the program, if necessary.
For more information on this, and how to apply and follow the GNU GPL, see
<https://www.gnu.org/licenses/>.
The GNU General Public License does not permit incorporating your program
into proprietary programs. If your program is a subroutine library, you
may consider it more useful to permit linking proprietary applications with
the library. If this is what you want to do, use the GNU Lesser General
Public License instead of this License. But first, please read
<https://www.gnu.org/licenses/why-not-lgpl.html>.

624
LICENSE.LGPL Normal file → Executable file
View File

@ -1,165 +1,459 @@
GNU LESSER GENERAL PUBLIC LICENSE
Version 3, 29 June 2007
Copyright (C) 2007 Free Software Foundation, Inc. <https://fsf.org/>
Everyone is permitted to copy and distribute verbatim copies
of this license document, but changing it is not allowed.
This version of the GNU Lesser General Public License incorporates
the terms and conditions of version 3 of the GNU General Public
License, supplemented by the additional permissions listed below.
0. Additional Definitions.
As used herein, "this License" refers to version 3 of the GNU Lesser
General Public License, and the "GNU GPL" refers to version 3 of the GNU
General Public License.
"The Library" refers to a covered work governed by this License,
other than an Application or a Combined Work as defined below.
An "Application" is any work that makes use of an interface provided
by the Library, but which is not otherwise based on the Library.
Defining a subclass of a class defined by the Library is deemed a mode
of using an interface provided by the Library.
A "Combined Work" is a work produced by combining or linking an
Application with the Library. The particular version of the Library
with which the Combined Work was made is also called the "Linked
Version".
The "Minimal Corresponding Source" for a Combined Work means the
Corresponding Source for the Combined Work, excluding any source code
for portions of the Combined Work that, considered in isolation, are
based on the Application, and not on the Linked Version.
The "Corresponding Application Code" for a Combined Work means the
object code and/or source code for the Application, including any data
and utility programs needed for reproducing the Combined Work from the
Application, but excluding the System Libraries of the Combined Work.
1. Exception to Section 3 of the GNU GPL.
You may convey a covered work under sections 3 and 4 of this License
without being bound by section 3 of the GNU GPL.
2. Conveying Modified Versions.
If you modify a copy of the Library, and, in your modifications, a
facility refers to a function or data to be supplied by an Application
that uses the facility (other than as an argument passed when the
facility is invoked), then you may convey a copy of the modified
version:
a) under this License, provided that you make a good faith effort to
ensure that, in the event an Application does not supply the
function or data, the facility still operates, and performs
whatever part of its purpose remains meaningful, or
b) under the GNU GPL, with none of the additional permissions of
this License applicable to that copy.
3. Object Code Incorporating Material from Library Header Files.
The object code form of an Application may incorporate material from
a header file that is part of the Library. You may convey such object
code under terms of your choice, provided that, if the incorporated
material is not limited to numerical parameters, data structure
layouts and accessors, or small macros, inline functions and templates
(ten or fewer lines in length), you do both of the following:
a) Give prominent notice with each copy of the object code that the
Library is used in it and that the Library and its use are
covered by this License.
b) Accompany the object code with a copy of the GNU GPL and this license
document.
4. Combined Works.
You may convey a Combined Work under terms of your choice that,
taken together, effectively do not restrict modification of the
portions of the Library contained in the Combined Work and reverse
engineering for debugging such modifications, if you also do each of
the following:
a) Give prominent notice with each copy of the Combined Work that
the Library is used in it and that the Library and its use are
covered by this License.
b) Accompany the Combined Work with a copy of the GNU GPL and this license
document.
c) For a Combined Work that displays copyright notices during
execution, include the copyright notice for the Library among
these notices, as well as a reference directing the user to the
copies of the GNU GPL and this license document.
d) Do one of the following:
0) Convey the Minimal Corresponding Source under the terms of this
License, and the Corresponding Application Code in a form
suitable for, and under terms that permit, the user to
recombine or relink the Application with a modified version of
the Linked Version to produce a modified Combined Work, in the
manner specified by section 6 of the GNU GPL for conveying
Corresponding Source.
1) Use a suitable shared library mechanism for linking with the
Library. A suitable mechanism is one that (a) uses at run time
a copy of the Library already present on the user's computer
system, and (b) will operate properly with a modified version
of the Library that is interface-compatible with the Linked
Version.
e) Provide Installation Information, but only if you would otherwise
be required to provide such information under section 6 of the
GNU GPL, and only to the extent that such information is
necessary to install and execute a modified version of the
Combined Work produced by recombining or relinking the
Application with a modified version of the Linked Version. (If
you use option 4d0, the Installation Information must accompany
the Minimal Corresponding Source and Corresponding Application
Code. If you use option 4d1, you must provide the Installation
Information in the manner specified by section 6 of the GNU GPL
for conveying Corresponding Source.)
5. Combined Libraries.
You may place library facilities that are a work based on the
Library side by side in a single library together with other library
facilities that are not Applications and are not covered by this
License, and convey such a combined library under terms of your
choice, if you do both of the following:
a) Accompany the combined library with a copy of the same work based
on the Library, uncombined with any other library facilities,
conveyed under the terms of this License.
b) Give prominent notice with the combined library that part of it
is a work based on the Library, and explaining where to find the
accompanying uncombined form of the same work.
6. Revised Versions of the GNU Lesser General Public License.
The Free Software Foundation may publish revised and/or new versions
of the GNU Lesser General Public License from time to time. Such new
versions will be similar in spirit to the present version, but may
differ in detail to address new problems or concerns.
Each version is given a distinguishing version number. If the
Library as you received it specifies that a certain numbered version
of the GNU Lesser General Public License "or any later version"
applies to it, you have the option of following the terms and
conditions either of that published version or of any later version
published by the Free Software Foundation. If the Library as you
received it does not specify a version number of the GNU Lesser
General Public License, you may choose any version of the GNU Lesser
General Public License ever published by the Free Software Foundation.
If the Library as you received it specifies that a proxy can decide
whether future versions of the GNU Lesser General Public License shall
apply, that proxy's public statement of acceptance of any version is
permanent authorization for you to choose that version for the
Library.
GNU LESSER GENERAL PUBLIC LICENSE
Version 2.1, February 1999
Copyright (C) 1991, 1999 Free Software Foundation, Inc.
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
Everyone is permitted to copy and distribute verbatim copies
of this license document, but changing it is not allowed.
[This is the first released version of the Lesser GPL. It also counts
as the successor of the GNU Library Public License, version 2, hence
the version number 2.1.]
Preamble
The licenses for most software are designed to take away your
freedom to share and change it. By contrast, the GNU General Public
Licenses are intended to guarantee your freedom to share and change
free software--to make sure the software is free for all its users.
This license, the Lesser General Public License, applies to some
specially designated software packages--typically libraries--of the
Free Software Foundation and other authors who decide to use it. You
can use it too, but we suggest you first think carefully about whether
this license or the ordinary General Public License is the better
strategy to use in any particular case, based on the explanations below.
When we speak of free software, we are referring to freedom of use,
not price. Our General Public Licenses are designed to make sure that
you have the freedom to distribute copies of free software (and charge
for this service if you wish); that you receive source code or can get
it if you want it; that you can change the software and use pieces of
it in new free programs; and that you are informed that you can do
these things.
To protect your rights, we need to make restrictions that forbid
distributors to deny you these rights or to ask you to surrender these
rights. These restrictions translate to certain responsibilities for
you if you distribute copies of the library or if you modify it.
For example, if you distribute copies of the library, whether gratis
or for a fee, you must give the recipients all the rights that we gave
you. You must make sure that they, too, receive or can get the source
code. If you link other code with the library, you must provide
complete object files to the recipients, so that they can relink them
with the library after making changes to the library and recompiling
it. And you must show them these terms so they know their rights.
We protect your rights with a two-step method: (1) we copyright the
library, and (2) we offer you this license, which gives you legal
permission to copy, distribute and/or modify the library.
To protect each distributor, we want to make it very clear that
there is no warranty for the free library. Also, if the library is
modified by someone else and passed on, the recipients should know
that what they have is not the original version, so that the original
author's reputation will not be affected by problems that might be
introduced by others.
Finally, software patents pose a constant threat to the existence of
any free program. We wish to make sure that a company cannot
effectively restrict the users of a free program by obtaining a
restrictive license from a patent holder. Therefore, we insist that
any patent license obtained for a version of the library must be
consistent with the full freedom of use specified in this license.
Most GNU software, including some libraries, is covered by the
ordinary GNU General Public License. This license, the GNU Lesser
General Public License, applies to certain designated libraries, and
is quite different from the ordinary General Public License. We use
this license for certain libraries in order to permit linking those
libraries into non-free programs.
When a program is linked with a library, whether statically or using
a shared library, the combination of the two is legally speaking a
combined work, a derivative of the original library. The ordinary
General Public License therefore permits such linking only if the
entire combination fits its criteria of freedom. The Lesser General
Public License permits more lax criteria for linking other code with
the library.
We call this license the "Lesser" General Public License because it
does Less to protect the user's freedom than the ordinary General
Public License. It also provides other free software developers Less
of an advantage over competing non-free programs. These disadvantages
are the reason we use the ordinary General Public License for many
libraries. However, the Lesser license provides advantages in certain
special circumstances.
For example, on rare occasions, there may be a special need to
encourage the widest possible use of a certain library, so that it becomes
a de-facto standard. To achieve this, non-free programs must be
allowed to use the library. A more frequent case is that a free
library does the same job as widely used non-free libraries. In this
case, there is little to gain by limiting the free library to free
software only, so we use the Lesser General Public License.
In other cases, permission to use a particular library in non-free
programs enables a greater number of people to use a large body of
free software. For example, permission to use the GNU C Library in
non-free programs enables many more people to use the whole GNU
operating system, as well as its variant, the GNU/Linux operating
system.
Although the Lesser General Public License is Less protective of the
users' freedom, it does ensure that the user of a program that is
linked with the Library has the freedom and the wherewithal to run
that program using a modified version of the Library.
The precise terms and conditions for copying, distribution and
modification follow. Pay close attention to the difference between a
"work based on the library" and a "work that uses the library". The
former contains code derived from the library, whereas the latter must
be combined with the library in order to run.
GNU LESSER GENERAL PUBLIC LICENSE
TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
0. This License Agreement applies to any software library or other
program which contains a notice placed by the copyright holder or
other authorized party saying it may be distributed under the terms of
this Lesser General Public License (also called "this License").
Each licensee is addressed as "you".
A "library" means a collection of software functions and/or data
prepared so as to be conveniently linked with application programs
(which use some of those functions and data) to form executables.
The "Library", below, refers to any such software library or work
which has been distributed under these terms. A "work based on the
Library" means either the Library or any derivative work under
copyright law: that is to say, a work containing the Library or a
portion of it, either verbatim or with modifications and/or translated
straightforwardly into another language. (Hereinafter, translation is
included without limitation in the term "modification".)
"Source code" for a work means the preferred form of the work for
making modifications to it. For a library, complete source code means
all the source code for all modules it contains, plus any associated
interface definition files, plus the scripts used to control compilation
and installation of the library.
Activities other than copying, distribution and modification are not
covered by this License; they are outside its scope. The act of
running a program using the Library is not restricted, and output from
such a program is covered only if its contents constitute a work based
on the Library (independent of the use of the Library in a tool for
writing it). Whether that is true depends on what the Library does
and what the program that uses the Library does.
1. You may copy and distribute verbatim copies of the Library's
complete source code as you receive it, in any medium, provided that
you conspicuously and appropriately publish on each copy an
appropriate copyright notice and disclaimer of warranty; keep intact
all the notices that refer to this License and to the absence of any
warranty; and distribute a copy of this License along with the
Library.
You may charge a fee for the physical act of transferring a copy,
and you may at your option offer warranty protection in exchange for a
fee.
2. You may modify your copy or copies of the Library or any portion
of it, thus forming a work based on the Library, and copy and
distribute such modifications or work under the terms of Section 1
above, provided that you also meet all of these conditions:
a) The modified work must itself be a software library.
b) You must cause the files modified to carry prominent notices
stating that you changed the files and the date of any change.
c) You must cause the whole of the work to be licensed at no
charge to all third parties under the terms of this License.
d) If a facility in the modified Library refers to a function or a
table of data to be supplied by an application program that uses
the facility, other than as an argument passed when the facility
is invoked, then you must make a good faith effort to ensure that,
in the event an application does not supply such function or
table, the facility still operates, and performs whatever part of
its purpose remains meaningful.
(For example, a function in a library to compute square roots has
a purpose that is entirely well-defined independent of the
application. Therefore, Subsection 2d requires that any
application-supplied function or table used by this function must
be optional: if the application does not supply it, the square
root function must still compute square roots.)
These requirements apply to the modified work as a whole. If
identifiable sections of that work are not derived from the Library,
and can be reasonably considered independent and separate works in
themselves, then this License, and its terms, do not apply to those
sections when you distribute them as separate works. But when you
distribute the same sections as part of a whole which is a work based
on the Library, the distribution of the whole must be on the terms of
this License, whose permissions for other licensees extend to the
entire whole, and thus to each and every part regardless of who wrote
it.
Thus, it is not the intent of this section to claim rights or contest
your rights to work written entirely by you; rather, the intent is to
exercise the right to control the distribution of derivative or
collective works based on the Library.
In addition, mere aggregation of another work not based on the Library
with the Library (or with a work based on the Library) on a volume of
a storage or distribution medium does not bring the other work under
the scope of this License.
3. You may opt to apply the terms of the ordinary GNU General Public
License instead of this License to a given copy of the Library. To do
this, you must alter all the notices that refer to this License, so
that they refer to the ordinary GNU General Public License, version 2,
instead of to this License. (If a newer version than version 2 of the
ordinary GNU General Public License has appeared, then you can specify
that version instead if you wish.) Do not make any other change in
these notices.
Once this change is made in a given copy, it is irreversible for
that copy, so the ordinary GNU General Public License applies to all
subsequent copies and derivative works made from that copy.
This option is useful when you wish to copy part of the code of
the Library into a program that is not a library.
4. You may copy and distribute the Library (or a portion or
derivative of it, under Section 2) in object code or executable form
under the terms of Sections 1 and 2 above provided that you accompany
it with the complete corresponding machine-readable source code, which
must be distributed under the terms of Sections 1 and 2 above on a
medium customarily used for software interchange.
If distribution of object code is made by offering access to copy
from a designated place, then offering equivalent access to copy the
source code from the same place satisfies the requirement to
distribute the source code, even though third parties are not
compelled to copy the source along with the object code.
5. A program that contains no derivative of any portion of the
Library, but is designed to work with the Library by being compiled or
linked with it, is called a "work that uses the Library". Such a
work, in isolation, is not a derivative work of the Library, and
therefore falls outside the scope of this License.
However, linking a "work that uses the Library" with the Library
creates an executable that is a derivative of the Library (because it
contains portions of the Library), rather than a "work that uses the
library". The executable is therefore covered by this License.
Section 6 states terms for distribution of such executables.
When a "work that uses the Library" uses material from a header file
that is part of the Library, the object code for the work may be a
derivative work of the Library even though the source code is not.
Whether this is true is especially significant if the work can be
linked without the Library, or if the work is itself a library. The
threshold for this to be true is not precisely defined by law.
If such an object file uses only numerical parameters, data
structure layouts and accessors, and small macros and small inline
functions (ten lines or less in length), then the use of the object
file is unrestricted, regardless of whether it is legally a derivative
work. (Executables containing this object code plus portions of the
Library will still fall under Section 6.)
Otherwise, if the work is a derivative of the Library, you may
distribute the object code for the work under the terms of Section 6.
Any executables containing that work also fall under Section 6,
whether or not they are linked directly with the Library itself.
6. As an exception to the Sections above, you may also combine or
link a "work that uses the Library" with the Library to produce a
work containing portions of the Library, and distribute that work
under terms of your choice, provided that the terms permit
modification of the work for the customer's own use and reverse
engineering for debugging such modifications.
You must give prominent notice with each copy of the work that the
Library is used in it and that the Library and its use are covered by
this License. You must supply a copy of this License. If the work
during execution displays copyright notices, you must include the
copyright notice for the Library among them, as well as a reference
directing the user to the copy of this License. Also, you must do one
of these things:
a) Accompany the work with the complete corresponding
machine-readable source code for the Library including whatever
changes were used in the work (which must be distributed under
Sections 1 and 2 above); and, if the work is an executable linked
with the Library, with the complete machine-readable "work that
uses the Library", as object code and/or source code, so that the
user can modify the Library and then relink to produce a modified
executable containing the modified Library. (It is understood
that the user who changes the contents of definitions files in the
Library will not necessarily be able to recompile the application
to use the modified definitions.)
b) Use a suitable shared library mechanism for linking with the
Library. A suitable mechanism is one that (1) uses at run time a
copy of the library already present on the user's computer system,
rather than copying library functions into the executable, and (2)
will operate properly with a modified version of the library, if
the user installs one, as long as the modified version is
interface-compatible with the version that the work was made with.
c) Accompany the work with a written offer, valid for at
least three years, to give the same user the materials
specified in Subsection 6a, above, for a charge no more
than the cost of performing this distribution.
d) If distribution of the work is made by offering access to copy
from a designated place, offer equivalent access to copy the above
specified materials from the same place.
e) Verify that the user has already received a copy of these
materials or that you have already sent this user a copy.
For an executable, the required form of the "work that uses the
Library" must include any data and utility programs needed for
reproducing the executable from it. However, as a special exception,
the materials to be distributed need not include anything that is
normally distributed (in either source or binary form) with the major
components (compiler, kernel, and so on) of the operating system on
which the executable runs, unless that component itself accompanies
the executable.
It may happen that this requirement contradicts the license
restrictions of other proprietary libraries that do not normally
accompany the operating system. Such a contradiction means you cannot
use both them and the Library together in an executable that you
distribute.
7. You may place library facilities that are a work based on the
Library side-by-side in a single library together with other library
facilities not covered by this License, and distribute such a combined
library, provided that the separate distribution of the work based on
the Library and of the other library facilities is otherwise
permitted, and provided that you do these two things:
a) Accompany the combined library with a copy of the same work
based on the Library, uncombined with any other library
facilities. This must be distributed under the terms of the
Sections above.
b) Give prominent notice with the combined library of the fact
that part of it is a work based on the Library, and explaining
where to find the accompanying uncombined form of the same work.
8. You may not copy, modify, sublicense, link with, or distribute
the Library except as expressly provided under this License. Any
attempt otherwise to copy, modify, sublicense, link with, or
distribute the Library is void, and will automatically terminate your
rights under this License. However, parties who have received copies,
or rights, from you under this License will not have their licenses
terminated so long as such parties remain in full compliance.
9. You are not required to accept this License, since you have not
signed it. However, nothing else grants you permission to modify or
distribute the Library or its derivative works. These actions are
prohibited by law if you do not accept this License. Therefore, by
modifying or distributing the Library (or any work based on the
Library), you indicate your acceptance of this License to do so, and
all its terms and conditions for copying, distributing or modifying
the Library or works based on it.
10. Each time you redistribute the Library (or any work based on the
Library), the recipient automatically receives a license from the
original licensor to copy, distribute, link with or modify the Library
subject to these terms and conditions. You may not impose any further
restrictions on the recipients' exercise of the rights granted herein.
You are not responsible for enforcing compliance by third parties with
this License.
11. If, as a consequence of a court judgment or allegation of patent
infringement or for any other reason (not limited to patent issues),
conditions are imposed on you (whether by court order, agreement or
otherwise) that contradict the conditions of this License, they do not
excuse you from the conditions of this License. If you cannot
distribute so as to satisfy simultaneously your obligations under this
License and any other pertinent obligations, then as a consequence you
may not distribute the Library at all. For example, if a patent
license would not permit royalty-free redistribution of the Library by
all those who receive copies directly or indirectly through you, then
the only way you could satisfy both it and this License would be to
refrain entirely from distribution of the Library.
If any portion of this section is held invalid or unenforceable under any
particular circumstance, the balance of the section is intended to apply,
and the section as a whole is intended to apply in other circumstances.
It is not the purpose of this section to induce you to infringe any
patents or other property right claims or to contest validity of any
such claims; this section has the sole purpose of protecting the
integrity of the free software distribution system which is
implemented by public license practices. Many people have made
generous contributions to the wide range of software distributed
through that system in reliance on consistent application of that
system; it is up to the author/donor to decide if he or she is willing
to distribute software through any other system and a licensee cannot
impose that choice.
This section is intended to make thoroughly clear what is believed to
be a consequence of the rest of this License.
12. If the distribution and/or use of the Library is restricted in
certain countries either by patents or by copyrighted interfaces, the
original copyright holder who places the Library under this License may add
an explicit geographical distribution limitation excluding those countries,
so that distribution is permitted only in or among countries not thus
excluded. In such case, this License incorporates the limitation as if
written in the body of this License.
13. The Free Software Foundation may publish revised and/or new
versions of the Lesser General Public License from time to time.
Such new versions will be similar in spirit to the present version,
but may differ in detail to address new problems or concerns.
Each version is given a distinguishing version number. If the Library
specifies a version number of this License which applies to it and
"any later version", you have the option of following the terms and
conditions either of that version or of any later version published by
the Free Software Foundation. If the Library does not specify a
license version number, you may choose any version ever published by
the Free Software Foundation.
14. If you wish to incorporate parts of the Library into other free
programs whose distribution conditions are incompatible with these,
write to the author to ask for permission. For software which is
copyrighted by the Free Software Foundation, write to the Free
Software Foundation; we sometimes make exceptions for this. Our
decision will be guided by the two goals of preserving the free status
of all derivatives of our free software and of promoting the sharing
and reuse of software generally.
NO WARRANTY
15. BECAUSE THE LIBRARY IS LICENSED FREE OF CHARGE, THERE IS NO
WARRANTY FOR THE LIBRARY, TO THE EXTENT PERMITTED BY APPLICABLE LAW.
EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR
OTHER PARTIES PROVIDE THE LIBRARY "AS IS" WITHOUT WARRANTY OF ANY
KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE
LIBRARY IS WITH YOU. SHOULD THE LIBRARY PROVE DEFECTIVE, YOU ASSUME
THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
16. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN
WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY
AND/OR REDISTRIBUTE THE LIBRARY AS PERMITTED ABOVE, BE LIABLE TO YOU
FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR
CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE
LIBRARY (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING
RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A
FAILURE OF THE LIBRARY TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF
SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH
DAMAGES.
END OF TERMS AND CONDITIONS

View File

@ -1,240 +0,0 @@
/*****************************************************************************
* gta5view Grand Theft Auto V Profile Viewer
* Copyright (C) 2017-2020 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 "MapLocationDialog.h"
#include "ui_MapLocationDialog.h"
#include "IconLoader.h"
#include "AppEnv.h"
#include <QPainter>
#include <QDebug>
#include <QStyle>
MapLocationDialog::MapLocationDialog(double x, double y, QWidget *parent) :
QDialog(parent), xpos_old(x), ypos_old(y),
ui(new Ui::MapLocationDialog)
{
// Set Window Flags
setWindowFlags(windowFlags()^Qt::WindowContextHelpButtonHint);
ui->setupUi(this);
ui->cmdDone->setVisible(false);
ui->cmdApply->setVisible(false);
ui->cmdRevert->setVisible(false);
ui->cmdDone->setCursor(Qt::ArrowCursor);
ui->cmdClose->setCursor(Qt::ArrowCursor);
// DPI calculation
qreal screenRatio = AppEnv::screenRatio();
int widgetMargin = qRound(3 * screenRatio);
ui->hlMapDialog->setContentsMargins(widgetMargin, widgetMargin, widgetMargin, widgetMargin);
ui->vlMapDialog->setSpacing(widgetMargin);
setMinimumSize(500 * screenRatio, 600 * screenRatio);
setMaximumSize(500 * screenRatio, 600 * screenRatio);
setFixedSize(500 * screenRatio, 600 * screenRatio);
setMouseTracking(true);
changeMode = false;
propUpdate = false;
drawPointOnMap(xpos_old, ypos_old);
}
MapLocationDialog::~MapLocationDialog()
{
delete ui;
}
void MapLocationDialog::drawPointOnMap(double xpos_d, double ypos_d)
{
ui->labPos->setText(tr("X: %1\nY: %2", "X and Y position").arg(QString::number(xpos_d), QString::number(ypos_d)));
xpos_new = xpos_d;
ypos_new = ypos_d;
repaint();
}
void MapLocationDialog::on_cmdChange_clicked()
{
qreal screenRatio = AppEnv::screenRatio();
int pointMakerSize = 8 * screenRatio;
QPixmap pointMakerPixmap = IconLoader::loadingPointmakerIcon().pixmap(QSize(pointMakerSize, pointMakerSize));
QCursor pointMakerCursor(pointMakerPixmap);
ui->cmdDone->setVisible(true);
ui->cmdApply->setVisible(false);
ui->cmdChange->setVisible(false);
ui->cmdRevert->setVisible(false);
setCursor(pointMakerCursor);
changeMode = true;
}
void MapLocationDialog::on_cmdDone_clicked()
{
ui->cmdDone->setVisible(false);
ui->cmdChange->setVisible(true);
if (xpos_new != xpos_old || ypos_new != ypos_old)
{
ui->cmdApply->setVisible(true);
ui->cmdRevert->setVisible(true);
}
setCursor(Qt::ArrowCursor);
changeMode = false;
}
#if QT_VERSION >= 0x060000
void MapLocationDialog::updatePosFromEvent(double x, double y)
{
QSize mapPixelSize = size();
double xpos_ad = x;
double ypos_ad = mapPixelSize.height() - y;
double xrat = 10000 / (double)mapPixelSize.width();
double yrat = 12000 / (double)mapPixelSize.height();
double xpos_rv = xrat * xpos_ad;
double ypos_rv = yrat * ypos_ad;
double xpos_fp = xpos_rv - 4000;
double ypos_fp = ypos_rv - 4000;
drawPointOnMap(xpos_fp, ypos_fp);
}
#else
void MapLocationDialog::updatePosFromEvent(int x, int y)
{
QSize mapPixelSize = size();
int xpos_ad = x;
int ypos_ad = mapPixelSize.height() - y;
double xrat = 10000 / (double)mapPixelSize.width();
double yrat = 12000 / (double)mapPixelSize.height();
double xpos_rv = xrat * xpos_ad;
double ypos_rv = yrat * ypos_ad;
double xpos_fp = xpos_rv - 4000;
double ypos_fp = ypos_rv - 4000;
drawPointOnMap(xpos_fp, ypos_fp);
}
#endif
void MapLocationDialog::paintEvent(QPaintEvent *ev)
{
QPainter painter(this);
qreal screenRatio = AppEnv::screenRatio();
qreal screenRatioPR = AppEnv::screenRatioPR();
// Paint Map
QSize mapPixelSize = QSize(width() * screenRatioPR, height() * screenRatioPR);
painter.drawPixmap(0, 0, width(), height(), QPixmap(":/img/mappreview.jpg").scaled(mapPixelSize, Qt::IgnoreAspectRatio, Qt::SmoothTransformation));
// Paint Marker
int pointMarkerSize = 8 * screenRatio;
int pointMarkerHalfSize = pointMarkerSize / 2;
long xpos_ms = qRound(xpos_new);
long ypos_ms = qRound(ypos_new);
double xpos_ma = xpos_ms + 4000;
double ypos_ma = ypos_ms + 4000;
double xrat = (double)width() / 10000;
double yrat = (double)height() / 12000;
long xpos_mp = qRound(xpos_ma * xrat);
long ypos_mp = qRound(ypos_ma * yrat);
long xpos_pr;
long ypos_pr;
if (screenRatioPR != 1) {
#ifdef Q_OS_WIN
xpos_pr = xpos_mp - pointMarkerHalfSize;
ypos_pr = ypos_mp + pointMarkerHalfSize;
#else
xpos_pr = xpos_mp - pointMarkerHalfSize + screenRatioPR;
ypos_pr = ypos_mp + pointMarkerHalfSize - screenRatioPR;
#endif
}
else {
xpos_pr = xpos_mp - pointMarkerHalfSize;
ypos_pr = ypos_mp + pointMarkerHalfSize;
}
QPixmap mapMarkerPixmap = IconLoader::loadingPointmakerIcon().pixmap(QSize(pointMarkerSize, pointMarkerSize));
painter.drawPixmap(xpos_pr, height() - ypos_pr, pointMarkerSize, pointMarkerSize, mapMarkerPixmap);
QDialog::paintEvent(ev);
}
void MapLocationDialog::mouseMoveEvent(QMouseEvent *ev)
{
if (!changeMode) { ev->ignore(); }
else if (ev->buttons() & Qt::LeftButton)
{
#if QT_VERSION >= 0x060000
updatePosFromEvent(ev->position().x(), ev->position().y());
#else
updatePosFromEvent(ev->x(), ev->y());
#endif
ev->accept();
}
else
{
ev->ignore();
}
}
void MapLocationDialog::mouseReleaseEvent(QMouseEvent *ev)
{
if (!changeMode) { ev->ignore(); }
else if (ev->button() == Qt::LeftButton)
{
#if QT_VERSION >= 0x060000
updatePosFromEvent(ev->position().x(), ev->position().y());
#else
updatePosFromEvent(ev->x(), ev->y());
#endif
ev->accept();
}
else
{
ev->ignore();
}
}
void MapLocationDialog::on_cmdApply_clicked()
{
propUpdate = true;
xpos_old = xpos_new;
ypos_old = ypos_new;
ui->cmdApply->setVisible(false);
ui->cmdRevert->setVisible(false);
}
void MapLocationDialog::on_cmdRevert_clicked()
{
drawPointOnMap(xpos_old, ypos_old);
ui->cmdApply->setVisible(false);
ui->cmdRevert->setVisible(false);
}
bool MapLocationDialog::propUpdated()
{
return propUpdate;
}
double MapLocationDialog::getXpos()
{
return xpos_old;
}
double MapLocationDialog::getYpos()
{
return ypos_old;
}
void MapLocationDialog::on_cmdClose_clicked()
{
close();
}

View File

@ -1,68 +0,0 @@
/*****************************************************************************
* gta5view Grand Theft Auto V Profile Viewer
* Copyright (C) 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 MAPLOCATIONDIALOG_H
#define MAPLOCATIONDIALOG_H
#include <QDialog>
#include <QMouseEvent>
namespace Ui {
class MapLocationDialog;
}
class MapLocationDialog : public QDialog
{
Q_OBJECT
public:
explicit MapLocationDialog(double x, double y, QWidget *parent = 0);
void drawPointOnMap(double x, double y);
bool propUpdated();
double getXpos();
double getYpos();
~MapLocationDialog();
protected:
void paintEvent(QPaintEvent *ev);
void mouseMoveEvent(QMouseEvent *ev);
void mouseReleaseEvent(QMouseEvent *ev);
private slots:
void on_cmdDone_clicked();
void on_cmdApply_clicked();
void on_cmdChange_clicked();
void on_cmdRevert_clicked();
#if QT_VERSION >= 0x060000
void updatePosFromEvent(double x, double y);
#else
void updatePosFromEvent(int x, int y);
#endif
void on_cmdClose_clicked();
private:
double xpos_old;
double ypos_old;
double xpos_new;
double ypos_new;
bool propUpdate;
bool changeMode;
Ui::MapLocationDialog *ui;
};
#endif // MAPLOCATIONDIALOG_H

View File

@ -1,238 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>MapLocationDialog</class>
<widget class="QDialog" name="MapLocationDialog">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>500</width>
<height>600</height>
</rect>
</property>
<property name="minimumSize">
<size>
<width>500</width>
<height>600</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>500</width>
<height>600</height>
</size>
</property>
<property name="windowTitle">
<string>Snapmatic Map Viewer</string>
</property>
<property name="styleSheet">
<string notr="true">QDialog#MapLocationDialog {
background-color: transparent;
}</string>
</property>
<layout class="QVBoxLayout" name="vlMapPreview">
<property name="spacing">
<number>0</number>
</property>
<property name="leftMargin">
<number>0</number>
</property>
<property name="topMargin">
<number>0</number>
</property>
<property name="rightMargin">
<number>0</number>
</property>
<property name="bottomMargin">
<number>0</number>
</property>
<item>
<layout class="QHBoxLayout" name="hlMapDialog">
<property name="spacing">
<number>0</number>
</property>
<property name="leftMargin">
<number>3</number>
</property>
<property name="topMargin">
<number>3</number>
</property>
<property name="rightMargin">
<number>3</number>
</property>
<property name="bottomMargin">
<number>3</number>
</property>
<item>
<layout class="QVBoxLayout" name="vlPosLayout">
<property name="spacing">
<number>0</number>
</property>
<property name="leftMargin">
<number>0</number>
</property>
<property name="topMargin">
<number>0</number>
</property>
<property name="rightMargin">
<number>0</number>
</property>
<property name="bottomMargin">
<number>0</number>
</property>
<item>
<widget class="QLabel" name="labPos">
<property name="styleSheet">
<string notr="true">QLabel{
color: rgb(255, 255, 255);
}</string>
</property>
</widget>
</item>
<item>
<spacer name="vsPosSpacer">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>40</height>
</size>
</property>
</spacer>
</item>
</layout>
</item>
<item>
<spacer name="hsMapDialog">
<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>
<layout class="QVBoxLayout" name="vlMapDialog">
<property name="spacing">
<number>3</number>
</property>
<property name="leftMargin">
<number>0</number>
</property>
<property name="topMargin">
<number>0</number>
</property>
<property name="rightMargin">
<number>0</number>
</property>
<property name="bottomMargin">
<number>0</number>
</property>
<item>
<widget class="QPushButton" name="cmdClose">
<property name="focusPolicy">
<enum>Qt::NoFocus</enum>
</property>
<property name="toolTip">
<string>Close viewer</string>
</property>
<property name="text">
<string>&amp;Close</string>
</property>
<property name="autoDefault">
<bool>false</bool>
</property>
</widget>
</item>
<item>
<spacer name="vsMapDialog">
<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="cmdApply">
<property name="focusPolicy">
<enum>Qt::NoFocus</enum>
</property>
<property name="toolTip">
<string>Apply new position</string>
</property>
<property name="text">
<string>&amp;Apply</string>
</property>
<property name="autoDefault">
<bool>false</bool>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="cmdRevert">
<property name="focusPolicy">
<enum>Qt::NoFocus</enum>
</property>
<property name="toolTip">
<string>Revert old position</string>
</property>
<property name="text">
<string>&amp;Revert</string>
</property>
<property name="autoDefault">
<bool>false</bool>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="cmdChange">
<property name="focusPolicy">
<enum>Qt::NoFocus</enum>
</property>
<property name="toolTip">
<string>Select new position</string>
</property>
<property name="text">
<string>&amp;Select</string>
</property>
<property name="autoDefault">
<bool>false</bool>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="cmdDone">
<property name="focusPolicy">
<enum>Qt::NoFocus</enum>
</property>
<property name="toolTip">
<string>Quit select position</string>
</property>
<property name="text">
<string>&amp;Done</string>
</property>
<property name="autoDefault">
<bool>false</bool>
</property>
</widget>
</item>
</layout>
</item>
</layout>
</item>
</layout>
</widget>
<resources/>
<connections/>
</ui>

View File

@ -1,111 +0,0 @@
/*****************************************************************************
* gta5view Grand Theft Auto V Profile Viewer
* Copyright (C) 2020 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 "TranslationClass.h"
#include "MessageThread.h"
#include "AppEnv.h"
#include "config.h"
#include <QNetworkAccessManager>
#include <QNetworkReply>
#include <QJsonDocument>
#include <QEventLoop>
#include <QUrlQuery>
#include <QTimer>
#include <QDebug>
#include <QUrl>
MessageThread::MessageThread(uint cacheId, QObject *parent) : QThread(parent), cacheId(cacheId)
{
threadRunning = true;
}
void MessageThread::run()
{
QEventLoop threadLoop;
QObject::connect(this, SIGNAL(threadTerminated()), &threadLoop, SLOT(quit()));
while (threadRunning) {
{
#ifdef GTA5SYNC_MOTD_WEBURL
QUrl motdWebUrl = QUrl(GTA5SYNC_MOTD_WEBURL);
#else
QUrl motdWebUrl = QUrl("https://motd.syping.de/gta5view-dev/");
#endif
QUrlQuery urlQuery(motdWebUrl);
urlQuery.addQueryItem("code", GTA5SYNC_BUILDCODE);
urlQuery.addQueryItem("cacheid", QString::number(cacheId));
urlQuery.addQueryItem("lang", Translator->getCurrentLanguage());
urlQuery.addQueryItem("version", GTA5SYNC_APPVER);
motdWebUrl.setQuery(urlQuery);
QNetworkAccessManager *netManager = new QNetworkAccessManager();
QNetworkRequest netRequest(motdWebUrl);
netRequest.setRawHeader("User-Agent", AppEnv::getUserAgent());
QNetworkReply *netReply = netManager->get(netRequest);
QEventLoop downloadLoop;
QObject::connect(netManager, SIGNAL(finished(QNetworkReply*)), &downloadLoop, SLOT(quit()));
QObject::connect(this, SIGNAL(threadTerminated()), &threadLoop, SLOT(quit()));
QTimer::singleShot(60000, &downloadLoop, SLOT(quit()));
downloadLoop.exec();
if (netReply->isFinished()) {
QByteArray jsonContent = netReply->readAll();
QString headerData = QString::fromUtf8(netReply->rawHeader("gta5view"));
if (!headerData.isEmpty()) {
QMap<QString,QString> headerMap;
const QStringList headerVarList = headerData.split(';');
for (QString headerVar : headerVarList) {
QStringList varValueList = headerVar.split('=');
if (varValueList.length() >= 2) {
const QString variable = varValueList.at(0).trimmed();
varValueList.removeFirst();
const QString value = varValueList.join('=');
headerMap.insert(variable, value);
}
}
if (headerMap.value("update", "false") == "true") {
QJsonDocument jsonDocument = QJsonDocument::fromJson(jsonContent);
emit messagesArrived(jsonDocument.object());
}
if (headerMap.contains("cache")) {
bool uintOk;
uint cacheVal = headerMap.value("cache").toUInt(&uintOk);
if (uintOk) {
cacheId = cacheVal;
emit updateCacheId(cacheId);
}
}
}
}
delete netReply;
delete netManager;
}
QTimer::singleShot(300000, &threadLoop, SLOT(quit()));
threadLoop.exec();
}
}
void MessageThread::terminateThread()
{
threadRunning = false;
emit threadTerminated();
}

View File

@ -1,48 +0,0 @@
/*****************************************************************************
* gta5view Grand Theft Auto V Profile Viewer
* Copyright (C) 2020 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 MESSAGETHREAD_H
#define MESSAGETHREAD_H
#include <QJsonObject>
#include <QObject>
#include <QThread>
class MessageThread : public QThread
{
Q_OBJECT
public:
explicit MessageThread(uint cacheId, QObject *parent = 0);
public slots:
void terminateThread();
private:
bool threadRunning;
uint cacheId;
protected:
void run();
signals:
void messagesArrived(const QJsonObject &messageObject);
void updateCacheId(uint cacheId);
void threadTerminated();
};
#endif // MESSAGETHREAD_H

1210
OptionsDialog.cpp Normal file → Executable file

File diff suppressed because it is too large Load Diff

165
OptionsDialog.h Normal file → Executable file
View File

@ -1,86 +1,79 @@
/******************************************************************************
* gta5view Grand Theft Auto V Profile Viewer
* 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 OPTIONSDIALOG_H
#define OPTIONSDIALOG_H
#include <QSize>
#include <QList>
#include <QDialog>
#include <QSettings>
#include <QTreeWidgetItem>
#include "ProfileDatabase.h"
namespace Ui {
class OptionsDialog;
}
class OptionsDialog : public QDialog
{
Q_OBJECT
public:
explicit OptionsDialog(ProfileDatabase *profileDB, QWidget *parent = 0);
void commitProfiles(const QStringList &profiles);
~OptionsDialog();
private slots:
void on_cmdOK_clicked();
void on_rbPicCustomRes_toggled(bool checked);
void on_cbPicCustomQuality_toggled(bool checked);
void on_hsPicQuality_valueChanged(int value);
void on_cbIgnoreAspectRatio_toggled(bool checked);
void on_cmdExploreFolder_clicked();
void on_cbDefaultStyle_toggled(bool checked);
void on_cmdCopyStatsID_clicked();
signals:
void settingsApplied(int contentMode, bool languageChanged);
private:
ProfileDatabase *profileDB;
Ui::OptionsDialog *ui;
QList<QTreeWidgetItem*> playerItems;
Qt::AspectRatioMode aspectRatio;
QString currentAreaLanguage;
QString currentLanguage;
QString currentCFolder;
QString defaultProfile;
QString percentString;
QSettings *settings;
bool withoutPlayers;
bool currentFFolder;
int contentMode;
int customQuality;
int defaultQuality;
QSize defExportSize;
QSize cusExportSize;
void setupTreeWidget();
void setupLanguageBox();
void setupRadioButtons();
void setupDefaultProfile();
void setupPictureSettings();
void setupCustomGTAFolder();
void setupInterfaceSettings();
void setupStatisticsSettings();
void setupSnapmaticPictureViewer();
void setupWindowsGameSettings();
void applySettings();
};
#endif // OPTIONSDIALOG_H
/******************************************************************************
* 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 OPTIONSDIALOG_H
#define OPTIONSDIALOG_H
#include <QSize>
#include <QList>
#include <QDialog>
#include <QSettings>
#include <QTreeWidgetItem>
#include "ProfileDatabase.h"
namespace Ui {
class OptionsDialog;
}
class OptionsDialog : public QDialog
{
Q_OBJECT
public:
explicit OptionsDialog(ProfileDatabase *profileDB, QWidget *parent = 0);
void commitProfiles(QStringList profiles);
~OptionsDialog();
private slots:
void on_cmdOK_clicked();
void on_rbPicCustomRes_toggled(bool checked);
void on_cbPicCustomQuality_toggled(bool checked);
void on_hsPicQuality_valueChanged(int value);
void on_cbIgnoreAspectRatio_toggled(bool checked);
void on_cmdExploreFolder_clicked();
signals:
void settingsApplied(int contentMode, QString language);
private:
ProfileDatabase *profileDB;
Ui::OptionsDialog *ui;
QList<QTreeWidgetItem*> playerItems;
Qt::AspectRatioMode aspectRatio;
QString currentLanguage;
QString currentCFolder;
QString defaultProfile;
QString percentString;
QSettings *settings;
bool currentFFolder;
int contentMode;
int customQuality;
int defaultQuality;
QSize defExportSize;
QSize cusExportSize;
void setupTreeWidget();
void setupLanguageBox();
void setupRadioButtons();
void setupDefaultProfile();
void setupPictureSettings();
void setupCustomGTAFolder();
void setupSnapmaticPictureViewer();
void applySettings();
};
#endif // OPTIONSDIALOG_H

1292
OptionsDialog.ui Normal file → Executable file

File diff suppressed because it is too large Load Diff

1653
PictureDialog.cpp Normal file → Executable file

File diff suppressed because it is too large Load Diff

253
PictureDialog.h Normal file → Executable file
View File

@ -1,130 +1,123 @@
/*****************************************************************************
* gta5view Grand Theft Auto V Profile Viewer
* 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 PICTUREDIALOG_H
#define PICTUREDIALOG_H
#include "SnapmaticPicture.h"
#include "ProfileDatabase.h"
#include "CrewDatabase.h"
#include <QResizeEvent>
#include <QMouseEvent>
#include <QToolBar>
#include <QDialog>
#include <QEvent>
#include <QMenu>
namespace Ui {
class PictureDialog;
}
class PictureDialog : public QDialog
{
Q_OBJECT
public:
explicit PictureDialog(ProfileDatabase *profileDB, CrewDatabase *crewDB, QWidget *parent = 0);
explicit PictureDialog(ProfileDatabase *profileDB, CrewDatabase *crewDB, QString profileName, QWidget *parent = 0);
explicit PictureDialog(bool primaryWindow, ProfileDatabase *profileDB, CrewDatabase *crewDB, QWidget *parent = 0);
explicit PictureDialog(bool primaryWindow, ProfileDatabase *profileDB, CrewDatabase *crewDB, QString profileName, QWidget *parent = 0);
void setupPictureDialog();
void setSnapmaticPicture(SnapmaticPicture *picture, bool readOk, bool indexed, int index);
void setSnapmaticPicture(SnapmaticPicture *picture, bool readOk, int index);
void setSnapmaticPicture(SnapmaticPicture *picture, bool readOk);
void setSnapmaticPicture(SnapmaticPicture *picture, int index);
void setSnapmaticPicture(SnapmaticPicture *picture);
void addPreviousNextButtons();
void styliseDialog();
bool isIndexed();
int getIndex();
~PictureDialog();
public slots:
void crewNameUpdated();
void playerNameUpdated();
void dialogNextPictureRequested();
void dialogPreviousPictureRequested();
void adaptNewDialogSize(QSize newLabelSize);
void exportCustomContextMenuRequested(const QPoint &pos);
private slots:
void copySnapmaticPicture();
void exportSnapmaticPicture();
void triggerFullscreenDoubeClick();
void on_labPicture_mouseDoubleClicked(Qt::MouseButton button);
void on_labPicture_customContextMenuRequested(const QPoint &pos);
void exportCustomContextMenuRequestedPrivate(const QPoint &pos, bool fullscreen);
void nextPictureRequestedSlot();
void previousPictureRequestedSlot();
void editSnapmaticProperties();
void editSnapmaticRawJson();
void editSnapmaticImage();
void renderOverlayPicture();
void renderPicture();
void openPreviewMap();
void updated();
void customSignal(QString signal);
signals:
void nextPictureRequested();
void previousPictureRequested();
void newPictureCommited(QImage picture);
void endDatabaseThread();
protected:
void closeEvent(QCloseEvent *ev);
bool eventFilter(QObject *obj, QEvent *ev);
void mousePressEvent(QMouseEvent *ev);
bool event(QEvent *event);
private:
QString generateCrewString();
QString generatePlayersString();
bool primaryWindow;
ProfileDatabase *profileDB;
CrewDatabase *crewDB;
QString profileName;
Ui::PictureDialog *ui;
QMap<QString, QString> globalMap;
SnapmaticPicture *smpic;
QWidget *fullscreenWidget;
QImage avatarAreaPicture;
QImage snapmaticPicture;
QImage overlayTempImage;
QString jsonDrawString;
QString windowTitleStr;
QString picAreaStr;
QString crewStr;
bool overlayEnabled;
bool rqFullscreen;
bool naviEnabled;
bool previewMode;
bool indexed;
int index;
int avatarLocX;
int avatarLocY;
int avatarSize;
QMenu *manageMenu;
#ifdef Q_OS_WIN
#if QT_VERSION >= 0x050200
QPoint dragPosition;
bool dragStart;
#endif
#endif
};
#endif // PICTUREDIALOG_H
/*****************************************************************************
* 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 PICTUREDIALOG_H
#define PICTUREDIALOG_H
#include "SnapmaticPicture.h"
#include "ProfileDatabase.h"
#include "CrewDatabase.h"
#include <QMouseEvent>
#include <QDialog>
#include <QEvent>
#include <QMenu>
namespace Ui {
class PictureDialog;
}
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 setSnapmaticPicture(SnapmaticPicture *picture, bool readOk, bool indexed, int index);
void setSnapmaticPicture(SnapmaticPicture *picture, bool readOk, int index);
void setSnapmaticPicture(SnapmaticPicture *picture, bool readOk);
void setSnapmaticPicture(SnapmaticPicture *picture, int index);
void setSnapmaticPicture(SnapmaticPicture *picture);
void addPreviousNextButtons();
void stylizeDialog();
bool isIndexed();
int getIndex();
~PictureDialog();
public slots:
void playerNameUpdated();
void dialogNextPictureRequested();
void dialogPreviousPictureRequested();
void adaptNewDialogSize(QSize newLabelSize);
void exportCustomContextMenuRequested(const QPoint &pos);
private slots:
void copySnapmaticPicture();
void exportSnapmaticPicture();
void triggerFullscreenDoubeClick();
void on_labPicture_mouseDoubleClicked(Qt::MouseButton button);
void on_labPicture_customContextMenuRequested(const QPoint &pos);
void exportCustomContextMenuRequestedPrivate(const QPoint &pos, bool fullscreen);
void nextPictureRequestedSlot();
void previousPictureRequestedSlot();
void renderOverlayPicture();
void renderPicture();
signals:
void nextPictureRequested();
void previousPictureRequested();
void newPictureCommited(QImage picture);
void endDatabaseThread();
protected:
void closeEvent(QCloseEvent *ev);
bool eventFilter(QObject *obj, QEvent *ev);
void mousePressEvent(QMouseEvent *ev);
bool event(QEvent *event);
private:
bool primaryWindow;
ProfileDatabase *profileDB;
CrewDatabase *crewDB;
Ui::PictureDialog *ui;
QMap<QString, QString> globalMap;
SnapmaticPicture *smpic;
QWidget *fullscreenWidget;
QAction *jpegExportAction;
QAction *pgtaExportAction;
QImage avatarAreaPicture;
QImage snapmaticPicture;
QImage overlayTempImage;
QString jsonDrawString;
QString windowTitleStr;
QStringList plyrsList;
QString picAreaStr;
QString picArea;
QString picTitl;
QString picPath;
QString created;
QString crewID;
QString locX;
QString locY;
QString locZ;
bool overlayEnabled;
bool withDatabase;
bool rqFullscreen;
bool naviEnabled;
bool previewMode;
bool indexed;
int index;
int avatarLocX;
int avatarLocY;
int avatarSize;
QMenu *exportMenu;
};
#endif // PICTUREDIALOG_H

490
PictureDialog.ui Normal file → Executable file
View File

@ -1,249 +1,241 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>PictureDialog</class>
<widget class="QDialog" name="PictureDialog">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>960</width>
<height>618</height>
</rect>
</property>
<property name="windowTitle">
<string>Snapmatic Picture Viewer - %1</string>
</property>
<layout class="QVBoxLayout" name="vlPictureLayout">
<property name="spacing">
<number>0</number>
</property>
<property name="leftMargin">
<number>0</number>
</property>
<property name="topMargin">
<number>0</number>
</property>
<property name="rightMargin">
<number>0</number>
</property>
<property name="bottomMargin">
<number>0</number>
</property>
<item>
<widget class="UiModLabel" name="labPicture">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Expanding">
<horstretch>0</horstretch>
<verstretch>1</verstretch>
</sizepolicy>
</property>
<property name="contextMenuPolicy">
<enum>Qt::CustomContextMenu</enum>
</property>
<property name="text">
<string/>
</property>
<property name="alignment">
<set>Qt::AlignCenter</set>
</property>
</widget>
</item>
<item>
<spacer name="vsJSONUpper">
<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="QFrame" name="jsonFrame">
<property name="frameShape">
<enum>QFrame::NoFrame</enum>
</property>
<property name="frameShadow">
<enum>QFrame::Plain</enum>
</property>
<property name="lineWidth">
<number>0</number>
</property>
<layout class="QHBoxLayout" name="hlJson">
<property name="spacing">
<number>0</number>
</property>
<property name="leftMargin">
<number>0</number>
</property>
<property name="topMargin">
<number>0</number>
</property>
<property name="rightMargin">
<number>0</number>
</property>
<property name="bottomMargin">
<number>0</number>
</property>
<item>
<layout class="QHBoxLayout" name="jsonLayout">
<property name="leftMargin">
<number>4</number>
</property>
<property name="topMargin">
<number>10</number>
</property>
<property name="rightMargin">
<number>4</number>
</property>
<property name="bottomMargin">
<number>4</number>
</property>
<item>
<widget class="UiModLabel" name="labJSON">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>&lt;span style=&quot; font-weight:600;&quot;&gt;Title: &lt;/span&gt;%6&lt;br/&gt;
&lt;span style=&quot; font-weight:600;&quot;&gt;Location: &lt;/span&gt;%7 (%1, %2, %3)&lt;br/&gt;
&lt;span style=&quot; font-weight:600;&quot;&gt;Players: &lt;/span&gt;%4 (Crew %5)&lt;br/&gt;
&lt;span style=&quot; font-weight:600;&quot;&gt;Created: &lt;/span&gt;%8</string>
</property>
<property name="wordWrap">
<bool>true</bool>
</property>
<property name="openExternalLinks">
<bool>true</bool>
</property>
<property name="textInteractionFlags">
<set>Qt::LinksAccessibleByMouse|Qt::TextSelectableByMouse</set>
</property>
</widget>
</item>
<item>
<layout class="QVBoxLayout" name="vlButtons">
<property name="spacing">
<number>6</number>
</property>
<property name="rightMargin">
<number>5</number>
</property>
<property name="bottomMargin">
<number>5</number>
</property>
<item>
<spacer name="vsButtons">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeType">
<enum>QSizePolicy::Expanding</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>0</width>
<height>0</height>
</size>
</property>
</spacer>
</item>
<item>
<layout class="QHBoxLayout" name="hlButtons">
<property name="spacing">
<number>6</number>
</property>
<item>
<widget class="QPushButton" name="cmdManage">
<property name="sizePolicy">
<sizepolicy hsizetype="Minimum" vsizetype="Minimum">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="focusPolicy">
<enum>Qt::NoFocus</enum>
</property>
<property name="toolTip">
<string>Manage picture</string>
</property>
<property name="text">
<string>&amp;Manage</string>
</property>
<property name="autoDefault">
<bool>false</bool>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="cmdClose">
<property name="sizePolicy">
<sizepolicy hsizetype="Minimum" vsizetype="Minimum">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="focusPolicy">
<enum>Qt::NoFocus</enum>
</property>
<property name="toolTip">
<string>Close viewer</string>
</property>
<property name="text">
<string>&amp;Close</string>
</property>
<property name="autoDefault">
<bool>false</bool>
</property>
</widget>
</item>
</layout>
</item>
</layout>
</item>
</layout>
</item>
</layout>
</widget>
</item>
</layout>
</widget>
<customwidgets>
<customwidget>
<class>UiModLabel</class>
<extends>QLabel</extends>
<header>uimod/UiModLabel.h</header>
<slots>
<signal>mouseMoved()</signal>
<signal>mouseReleased()</signal>
<signal>mousePressed()</signal>
<signal>mouseDoubleClicked()</signal>
</slots>
</customwidget>
</customwidgets>
<resources/>
<connections>
<connection>
<sender>cmdClose</sender>
<signal>clicked()</signal>
<receiver>PictureDialog</receiver>
<slot>close()</slot>
<hints>
<hint type="sourcelabel">
<x>912</x>
<y>514</y>
</hint>
<hint type="destinationlabel">
<x>479</x>
<y>267</y>
</hint>
</hints>
</connection>
</connections>
</ui>
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>PictureDialog</class>
<widget class="QDialog" name="PictureDialog">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>960</width>
<height>602</height>
</rect>
</property>
<property name="windowTitle">
<string>%1 - Snapmatic Picture Viewer</string>
</property>
<layout class="QVBoxLayout" name="vlPictureLayout">
<property name="spacing">
<number>0</number>
</property>
<property name="leftMargin">
<number>0</number>
</property>
<property name="topMargin">
<number>0</number>
</property>
<property name="rightMargin">
<number>0</number>
</property>
<property name="bottomMargin">
<number>0</number>
</property>
<item>
<widget class="UiModLabel" name="labPicture">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Expanding">
<horstretch>0</horstretch>
<verstretch>1</verstretch>
</sizepolicy>
</property>
<property name="contextMenuPolicy">
<enum>Qt::CustomContextMenu</enum>
</property>
<property name="text">
<string/>
</property>
<property name="pixmap">
<pixmap resource="res/app.qrc">:/img/960x536.png</pixmap>
</property>
<property name="alignment">
<set>Qt::AlignCenter</set>
</property>
</widget>
</item>
<item>
<widget class="QFrame" name="jsonFrame">
<property name="frameShape">
<enum>QFrame::NoFrame</enum>
</property>
<property name="frameShadow">
<enum>QFrame::Plain</enum>
</property>
<property name="lineWidth">
<number>0</number>
</property>
<layout class="QHBoxLayout" name="hlJson">
<property name="spacing">
<number>0</number>
</property>
<property name="leftMargin">
<number>0</number>
</property>
<property name="topMargin">
<number>0</number>
</property>
<property name="rightMargin">
<number>0</number>
</property>
<property name="bottomMargin">
<number>0</number>
</property>
<item>
<layout class="QHBoxLayout" name="jsonLayout">
<property name="leftMargin">
<number>4</number>
</property>
<property name="topMargin">
<number>10</number>
</property>
<property name="rightMargin">
<number>4</number>
</property>
<property name="bottomMargin">
<number>4</number>
</property>
<item>
<widget class="UiModLabel" name="labJSON">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>&lt;span style=&quot; font-weight:600;&quot;&gt;Title: &lt;/span&gt;%6&lt;br/&gt;
&lt;span style=&quot; font-weight:600;&quot;&gt;Location: &lt;/span&gt;%7 (%1, %2, %3)&lt;br/&gt;
&lt;span style=&quot; font-weight:600;&quot;&gt;Players: &lt;/span&gt;%4 (Crew %5)&lt;br/&gt;
&lt;span style=&quot; font-weight:600;&quot;&gt;Created: &lt;/span&gt;%8</string>
</property>
<property name="wordWrap">
<bool>true</bool>
</property>
<property name="openExternalLinks">
<bool>true</bool>
</property>
<property name="textInteractionFlags">
<set>Qt::LinksAccessibleByMouse|Qt::TextSelectableByMouse</set>
</property>
</widget>
</item>
<item>
<layout class="QVBoxLayout" name="vlButtons">
<property name="spacing">
<number>6</number>
</property>
<property name="rightMargin">
<number>5</number>
</property>
<property name="bottomMargin">
<number>5</number>
</property>
<item>
<spacer name="vsButtons">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeType">
<enum>QSizePolicy::Expanding</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>0</width>
<height>0</height>
</size>
</property>
</spacer>
</item>
<item>
<layout class="QHBoxLayout" name="hlButtons">
<property name="spacing">
<number>6</number>
</property>
<item>
<widget class="QPushButton" name="cmdExport">
<property name="sizePolicy">
<sizepolicy hsizetype="Minimum" vsizetype="Minimum">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="focusPolicy">
<enum>Qt::NoFocus</enum>
</property>
<property name="toolTip">
<string>Export picture</string>
</property>
<property name="text">
<string>&amp;Export</string>
</property>
<property name="autoDefault">
<bool>false</bool>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="cmdClose">
<property name="sizePolicy">
<sizepolicy hsizetype="Minimum" vsizetype="Minimum">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="focusPolicy">
<enum>Qt::NoFocus</enum>
</property>
<property name="toolTip">
<string>Close</string>
</property>
<property name="text">
<string>&amp;Close</string>
</property>
<property name="autoDefault">
<bool>false</bool>
</property>
</widget>
</item>
</layout>
</item>
</layout>
</item>
</layout>
</item>
</layout>
</widget>
</item>
</layout>
</widget>
<customwidgets>
<customwidget>
<class>UiModLabel</class>
<extends>QLabel</extends>
<header>uimod/UiModLabel.h</header>
<slots>
<signal>mouseMoved()</signal>
<signal>mouseReleased()</signal>
<signal>mousePressed()</signal>
<signal>mouseDoubleClicked()</signal>
</slots>
</customwidget>
</customwidgets>
<resources>
<include location="res/app.qrc"/>
</resources>
<connections>
<connection>
<sender>cmdClose</sender>
<signal>clicked()</signal>
<receiver>PictureDialog</receiver>
<slot>close()</slot>
<hints>
<hint type="sourcelabel">
<x>912</x>
<y>514</y>
</hint>
<hint type="destinationlabel">
<x>479</x>
<y>267</y>
</hint>
</hints>
</connection>
</connections>
</ui>

652
PictureExport.cpp Normal file → Executable file
View File

@ -1,342 +1,310 @@
/*****************************************************************************
* gta5view Grand Theft Auto V Profile Viewer
* Copyright (C) 2016-2020 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 "config.h"
#include "AppEnv.h"
#include "PictureExport.h"
#include "PictureDialog.h"
#include "StandardPaths.h"
#include "SidebarGenerator.h"
#include <QStringBuilder>
#include <QApplication>
#include <QMessageBox>
#include <QFileDialog>
#include <QSettings>
#include <QDebug>
#if QT_VERSION < 0x050000
#include <QDesktopWidget>
#endif
#if QT_VERSION >= 0x050000
#include <QSaveFile>
#include <QScreen>
#endif
PictureExport::PictureExport()
{
}
void PictureExport::exportAsPicture(QWidget *parent, SnapmaticPicture *picture)
{
QSettings settings(GTA5SYNC_APPVENDOR, GTA5SYNC_APPSTR);
// Picture Settings
// Quality Settings
settings.beginGroup("Pictures");
int defaultQuality = 100;
QSize defExportSize = QSize(960, 536);
int customQuality = settings.value("CustomQuality", defaultQuality).toInt();
if (customQuality < 1 || customQuality > 100)
{
customQuality = 100;
}
bool useCustomQuality = settings.value("CustomQualityEnabled", false).toBool();
// Size Settings
QSize cusExportSize = settings.value("CustomSize", defExportSize).toSize();
if (cusExportSize.width() > 3840)
{
cusExportSize.setWidth(3840);
}
else if (cusExportSize.height() > 2160)
{
cusExportSize.setHeight(2160);
}
if (cusExportSize.width() < 1)
{
cusExportSize.setWidth(1);
}
else if (cusExportSize.height() < 1)
{
cusExportSize.setHeight(1);
}
QString sizeMode = settings.value("ExportSizeMode", "Default").toString();
Qt::AspectRatioMode aspectRatio = (Qt::AspectRatioMode)settings.value("AspectRatio", Qt::KeepAspectRatio).toInt();
QString defaultExportFormat = settings.value("DefaultExportFormat", ".jpg").toString();
settings.endGroup();
// End Picture Settings
settings.beginGroup("FileDialogs");
bool dontUseNativeDialog = settings.value("DontUseNativeDialog", false).toBool();
settings.beginGroup("ExportAsPicture");
fileDialogPreSave: //Work?
QFileDialog fileDialog(parent);
fileDialog.setFileMode(QFileDialog::AnyFile);
fileDialog.setViewMode(QFileDialog::Detail);
fileDialog.setAcceptMode(QFileDialog::AcceptSave);
fileDialog.setOption(QFileDialog::DontUseNativeDialog, dontUseNativeDialog);
fileDialog.setOption(QFileDialog::DontConfirmOverwrite, true);
fileDialog.setDefaultSuffix("suffix");
fileDialog.setWindowFlags(fileDialog.windowFlags()^Qt::WindowContextHelpButtonHint);
fileDialog.setWindowTitle(PictureDialog::tr("Export as Picture..."));
fileDialog.setLabelText(QFileDialog::Accept, PictureDialog::tr("Export"));
QStringList filters;
filters << PictureDialog::tr("JPEG Graphics (*.jpg *.jpeg)");
filters << PictureDialog::tr("Portable Network Graphics (*.png)");
fileDialog.setNameFilters(filters);
QList<QUrl> sidebarUrls = SidebarGenerator::generateSidebarUrls(fileDialog.sidebarUrls());
fileDialog.setSidebarUrls(sidebarUrls);
fileDialog.setDirectory(settings.value("Directory", StandardPaths::picturesLocation()).toString());
fileDialog.restoreGeometry(settings.value(parent->objectName() % "+Geometry", "").toByteArray());
QString newPictureFileName = getPictureFileName(picture) % defaultExportFormat;
fileDialog.selectFile(newPictureFileName);
if (fileDialog.exec())
{
QStringList selectedFiles = fileDialog.selectedFiles();
if (selectedFiles.length() == 1)
{
QString saveFileFormat;
QString selectedFile = selectedFiles.at(0);
if (selectedFile.right(4) == ".jpg")
{
saveFileFormat = "JPEG";
}
else if (selectedFile.right(4) == ".jpeg")
{
saveFileFormat = "JPEG";
}
else if (selectedFile.right(4) == ".png")
{
saveFileFormat = "PNG";
}
else if (selectedFile.right(7) == ".suffix")
{
if (fileDialog.selectedNameFilter() == "JPEG picture (*.jpg)")
{
selectedFile.replace(".suffix", ".jpg");
}
else if (fileDialog.selectedNameFilter() == "Portable Network Graphics (*.png)")
{
selectedFile.replace(".suffix", ".png");
}
else
{
selectedFile.replace(".suffix", ".jpg");
}
}
if (QFile::exists(selectedFile))
{
if (QMessageBox::No == QMessageBox::warning(parent, PictureDialog::tr("Export as Picture"), PictureDialog::tr("Overwrite %1 with current Snapmatic picture?").arg("\""+selectedFile+"\""), QMessageBox::Yes | QMessageBox::No, QMessageBox::Yes))
{
goto fileDialogPreSave; //Work?
}
}
// Scale Picture
QImage exportPicture = picture->getImage();
if (sizeMode == "Desktop")
{
#if QT_VERSION >= 0x050000
qreal screenRatioPR = AppEnv::screenRatioPR();
QRect desktopResolution = QApplication::primaryScreen()->geometry();
int desktopSizeWidth = qRound((double)desktopResolution.width() * screenRatioPR);
int desktopSizeHeight = qRound((double)desktopResolution.height() * screenRatioPR);
#else
QRect desktopResolution = QApplication::desktop()->screenGeometry();
int desktopSizeWidth = desktopResolution.width();
int desktopSizeHeight = desktopResolution.height();
#endif
exportPicture = exportPicture.scaled(desktopSizeWidth, desktopSizeHeight, aspectRatio, Qt::SmoothTransformation);
}
else if (sizeMode == "Custom")
{
exportPicture = exportPicture.scaled(cusExportSize, aspectRatio, Qt::SmoothTransformation);
}
int errorId = 0;
bool isSaved = false;
#if QT_VERSION >= 0x050000
QSaveFile *picFile = new QSaveFile(selectedFile);
#else
QFile *picFile = new QFile(selectedFile);
#endif
if (picFile->open(QIODevice::WriteOnly))
{
isSaved = exportPicture.save(picFile, saveFileFormat.toStdString().c_str(), useCustomQuality ? customQuality : defaultQuality);
#if QT_VERSION >= 0x050000
if (isSaved)
{
isSaved = picFile->commit();
}
else
{
errorId = 1;
}
#else
picFile->close();
#endif
}
else
{
errorId = 2;
}
delete picFile;
if (!isSaved)
{
switch (errorId)
{
case 0:
QMessageBox::warning(parent, PictureDialog::tr("Export as Picture"), PictureDialog::tr("Failed to export the picture because the system occurred a write failure"));
break;
case 1:
QMessageBox::warning(parent, PictureDialog::tr("Export as Picture"), PictureDialog::tr("Failed to export the picture because the format detection failures"));
break;
case 2:
QMessageBox::warning(parent, PictureDialog::tr("Export as Picture"), PictureDialog::tr("Failed to export the picture because the file can't be written"));
break;
default:
QMessageBox::warning(parent, PictureDialog::tr("Export as Picture"), PictureDialog::tr("Failed to export the picture because of an unknown reason"));
}
goto fileDialogPreSave; //Work?
}
}
else
{
QMessageBox::warning(parent, PictureDialog::tr("Export as Picture"), PictureDialog::tr("No valid file is selected"));
goto fileDialogPreSave; //Work?
}
}
settings.setValue(parent->objectName() % "+Geometry", fileDialog.saveGeometry());
settings.setValue("Directory", fileDialog.directory().absolutePath());
settings.endGroup();
settings.endGroup();
}
void PictureExport::exportAsSnapmatic(QWidget *parent, SnapmaticPicture *picture)
{
QSettings settings(GTA5SYNC_APPVENDOR, GTA5SYNC_APPSTR);
settings.beginGroup("FileDialogs");
bool dontUseNativeDialog = settings.value("DontUseNativeDialog", false).toBool();
settings.beginGroup("ExportAsSnapmatic");
QString adjustedPicPath = picture->getOriginalPictureFileName();
fileDialogPreSave: //Work?
QFileInfo sgdFileInfo(adjustedPicPath);
QFileDialog fileDialog(parent);
fileDialog.setFileMode(QFileDialog::AnyFile);
fileDialog.setViewMode(QFileDialog::Detail);
fileDialog.setAcceptMode(QFileDialog::AcceptSave);
fileDialog.setOption(QFileDialog::DontUseNativeDialog, dontUseNativeDialog);
fileDialog.setOption(QFileDialog::DontConfirmOverwrite, true);
fileDialog.setDefaultSuffix(".rem");
fileDialog.setWindowFlags(fileDialog.windowFlags()^Qt::WindowContextHelpButtonHint);
fileDialog.setWindowTitle(PictureDialog::tr("Export as Snapmatic..."));
fileDialog.setLabelText(QFileDialog::Accept, PictureDialog::tr("Export"));
QStringList filters;
filters << PictureDialog::tr("GTA V Export (*.g5e)");
filters << PictureDialog::tr("GTA V Raw Export (*.auto)");
filters << PictureDialog::tr("Snapmatic pictures (PGTA*)");
fileDialog.setNameFilters(filters);
QList<QUrl> sidebarUrls = SidebarGenerator::generateSidebarUrls(fileDialog.sidebarUrls());
fileDialog.setSidebarUrls(sidebarUrls);
fileDialog.setDirectory(settings.value("Directory", StandardPaths::documentsLocation()).toString());
fileDialog.restoreGeometry(settings.value(parent->objectName() % "+Geometry", "").toByteArray());
fileDialog.selectFile(QString(picture->getExportPictureFileName() % ".g5e"));
if (fileDialog.exec())
{
QStringList selectedFiles = fileDialog.selectedFiles();
if (selectedFiles.length() == 1)
{
QString selectedFile = selectedFiles.at(0);
bool isAutoExt = false;
if (selectedFile.right(5) == ".auto")
{
isAutoExt = true;
QString dirPath = QFileInfo(selectedFile).dir().path();
QString stockFileName = sgdFileInfo.fileName();
selectedFile = dirPath % "/" % stockFileName;
}
else if (selectedFile.right(4) == ".rem")
{
selectedFile.remove(selectedFile.length() - 4, 4);
}
if (QFile::exists(selectedFile))
{
if (QMessageBox::No == QMessageBox::warning(parent, PictureDialog::tr("Export as Snapmatic"), PictureDialog::tr("Overwrite %1 with current Snapmatic picture?").arg("\""+selectedFile+"\""), QMessageBox::Yes | QMessageBox::No, QMessageBox::Yes))
{
goto fileDialogPreSave; //Work?
}
}
if (selectedFile.right(4) == ".g5e")
{
bool isExported = picture->exportPicture(selectedFile, SnapmaticFormat::G5E_Format);
if (!isExported)
{
QMessageBox::warning(parent, PictureDialog::tr("Export as Snapmatic"), PictureDialog::tr("Failed to export current Snapmatic picture"));
goto fileDialogPreSave; //Work?
}
}
else
{
bool isCopied = picture->exportPicture(selectedFile, SnapmaticFormat::PGTA_Format);
if (!isCopied)
{
QMessageBox::warning(parent, PictureDialog::tr("Export as Snapmatic"), PictureDialog::tr("Failed to export current Snapmatic picture"));
goto fileDialogPreSave; //Work?
}
else
{
if (isAutoExt) QMessageBox::information(parent, PictureDialog::tr("Export as Snapmatic"), PictureDialog::tr("Exported Snapmatic to \"%1\" because of using the .auto extension.").arg(selectedFile));
}
}
}
else
{
QMessageBox::warning(parent, PictureDialog::tr("Export as Snapmatic"), PictureDialog::tr("No valid file is selected"));
goto fileDialogPreSave; //Work?
}
}
settings.setValue(parent->objectName() % "+Geometry", fileDialog.saveGeometry());
settings.setValue("Directory", fileDialog.directory().absolutePath());
settings.endGroup();
}
QString PictureExport::getPictureFileName(SnapmaticPicture *picture)
{
return picture->getExportPictureFileName();
}
/*****************************************************************************
* 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 "config.h"
#include "PictureExport.h"
#include "PictureDialog.h"
#include "StandardPaths.h"
#include "SidebarGenerator.h"
#include <QDesktopWidget>
#include <QApplication>
#include <QMessageBox>
#include <QFileDialog>
#include <QSettings>
#include <QDebug>
PictureExport::PictureExport()
{
}
void PictureExport::exportAsPicture(QWidget *parent, SnapmaticPicture *picture)
{
QSettings settings(GTA5SYNC_APPVENDOR, GTA5SYNC_APPSTR);
// Picture Settings
// Quality Settings
settings.beginGroup("Pictures");
int defaultQuality = 100;
QSize defExportSize = QSize(960, 536);
int customQuality = settings.value("CustomQuality", defaultQuality).toInt();
if (customQuality < 1 || customQuality > 100)
{
customQuality = 100;
}
bool useCustomQuality = settings.value("CustomQualityEnabled", false).toBool();
// Size Settings
QSize cusExportSize = settings.value("CustomSize", defExportSize).toSize();
if (cusExportSize.width() > 3840)
{
cusExportSize.setWidth(3840);
}
else if (cusExportSize.height() > 2160)
{
cusExportSize.setHeight(2160);
}
if (cusExportSize.width() < 1)
{
cusExportSize.setWidth(1);
}
else if (cusExportSize.height() < 1)
{
cusExportSize.setHeight(1);
}
QString sizeMode = settings.value("ExportSizeMode", "Default").toString();
Qt::AspectRatioMode aspectRatio = (Qt::AspectRatioMode)settings.value("AspectRatio", Qt::KeepAspectRatio).toInt();
QString defaultExportFormat = settings.value("DefaultExportFormat", ".jpg").toString();
settings.endGroup();
// End Picture Settings
settings.beginGroup("FileDialogs");
settings.beginGroup("ExportAsPicture");
fileDialogPreSave:
QFileDialog fileDialog(parent);
fileDialog.setFileMode(QFileDialog::AnyFile);
fileDialog.setViewMode(QFileDialog::Detail);
fileDialog.setAcceptMode(QFileDialog::AcceptSave);
fileDialog.setOption(QFileDialog::DontUseNativeDialog, false);
fileDialog.setOption(QFileDialog::DontConfirmOverwrite, true);
fileDialog.setDefaultSuffix("suffix");
fileDialog.setWindowFlags(fileDialog.windowFlags()^Qt::WindowContextHelpButtonHint);
fileDialog.setWindowTitle(PictureDialog::tr("Export as JPG picture..."));
fileDialog.setLabelText(QFileDialog::Accept, PictureDialog::tr("Export"));
QStringList filters;
filters << PictureDialog::tr("JPEG picture (*.jpg)");
filters << PictureDialog::tr("Portable Network Graphics (*.png)");
fileDialog.setNameFilters(filters);
QList<QUrl> sidebarUrls = SidebarGenerator::generateSidebarUrls(fileDialog.sidebarUrls());
fileDialog.setSidebarUrls(sidebarUrls);
fileDialog.setDirectory(settings.value("Directory", StandardPaths::picturesLocation()).toString());
fileDialog.restoreGeometry(settings.value(parent->objectName() + "+Geomtery", "").toByteArray());
QString newPictureFileName = getPictureFileName(picture) + defaultExportFormat;
fileDialog.selectFile(newPictureFileName);
if (fileDialog.exec())
{
QStringList selectedFiles = fileDialog.selectedFiles();
if (selectedFiles.length() == 1)
{
QString saveFileFormat;
QString selectedFile = selectedFiles.at(0);
if (selectedFile.right(4) == ".jpg")
{
saveFileFormat = "JPEG";
}
else if (selectedFile.right(4) == ".jpeg")
{
saveFileFormat = "JPEG";
}
else if (selectedFile.right(4) == ".png")
{
saveFileFormat = "PNG";
}
else if (selectedFile.right(7) == ".suffix")
{
if (fileDialog.selectedNameFilter() == "JPEG picture (*.jpg)")
{
selectedFile.replace(".suffix", ".jpg");
}
else if (fileDialog.selectedNameFilter() == "Portable Network Graphics (*.png)")
{
selectedFile.replace(".suffix", ".png");
}
else
{
selectedFile.replace(".suffix", ".jpg");
}
}
if (QFile::exists(selectedFile))
{
if (QMessageBox::Yes == QMessageBox::warning(parent, PictureDialog::tr("Export as JPG picture"), PictureDialog::tr("Overwrite %1 with current Snapmatic picture?").arg("\""+selectedFile+"\""), QMessageBox::Yes | QMessageBox::No, QMessageBox::Yes))
{
if (!QFile::remove(selectedFile))
{
QMessageBox::warning(parent, PictureDialog::tr("Export as JPG picture"), PictureDialog::tr("Failed to overwrite %1 with current Snapmatic picture").arg("\""+selectedFile+"\""));
goto fileDialogPreSave;
}
}
else
{
goto fileDialogPreSave;
}
}
// Scale Picture
QImage exportPicture = picture->getImage();
if (sizeMode == "Desktop")
{
QRect desktopResolution = QApplication::desktop()->screenGeometry();
exportPicture = exportPicture.scaled(desktopResolution.width(), desktopResolution.height(), aspectRatio, Qt::SmoothTransformation);
}
else if (sizeMode == "Custom")
{
exportPicture = exportPicture.scaled(cusExportSize, aspectRatio, Qt::SmoothTransformation);
}
bool isSaved;
if (useCustomQuality)
{
isSaved = exportPicture.save(selectedFile, saveFileFormat.toStdString().c_str(), customQuality);
}
else
{
isSaved = exportPicture.save(selectedFile, saveFileFormat.toStdString().c_str(), 100);
}
if (!isSaved)
{
QMessageBox::warning(parent, PictureDialog::tr("Export as JPG picture"), PictureDialog::tr("Failed to export current Snapmatic picture"));
goto fileDialogPreSave;
}
}
else
{
QMessageBox::warning(parent, PictureDialog::tr("Export as JPG picture"), PictureDialog::tr("No valid file is selected"));
goto fileDialogPreSave;
}
}
settings.setValue(parent->objectName() + "+Geometry", fileDialog.saveGeometry());
settings.setValue("Directory", fileDialog.directory().absolutePath());
settings.endGroup();
settings.endGroup();
}
void PictureExport::exportAsSnapmatic(QWidget *parent, SnapmaticPicture *picture)
{
QSettings settings(GTA5SYNC_APPVENDOR, GTA5SYNC_APPSTR);
settings.beginGroup("FileDialogs");
settings.beginGroup("ExportAsSnapmatic");
QString adjustedPicPath = picture->getPictureFileName();
if (adjustedPicPath.right(7) == ".hidden") // for the hidden file system
{
adjustedPicPath.remove(adjustedPicPath.length() - 7, 7);
}
fileDialogPreSave:
QFileInfo sgdFileInfo(adjustedPicPath);
QFileDialog fileDialog(parent);
fileDialog.setFileMode(QFileDialog::AnyFile);
fileDialog.setViewMode(QFileDialog::Detail);
fileDialog.setAcceptMode(QFileDialog::AcceptSave);
fileDialog.setOption(QFileDialog::DontUseNativeDialog, false);
fileDialog.setOption(QFileDialog::DontConfirmOverwrite, true);
fileDialog.setDefaultSuffix(".rem");
fileDialog.setWindowFlags(fileDialog.windowFlags()^Qt::WindowContextHelpButtonHint);
fileDialog.setWindowTitle(PictureDialog::tr("Export as GTA Snapmatic..."));
fileDialog.setLabelText(QFileDialog::Accept, PictureDialog::tr("&Export"));
QStringList filters;
filters << PictureDialog::tr("GTA V Export (*.g5e)");
filters << PictureDialog::tr("GTA V Raw Export (*.auto)");
filters << PictureDialog::tr("Snapmatic pictures (PGTA*)");
fileDialog.setNameFilters(filters);
QList<QUrl> sidebarUrls = SidebarGenerator::generateSidebarUrls(fileDialog.sidebarUrls());
fileDialog.setSidebarUrls(sidebarUrls);
fileDialog.setDirectory(settings.value("Directory", StandardPaths::documentsLocation()).toString());
fileDialog.selectFile(QString(picture->getExportPictureFileName() + ".g5e"));
fileDialog.restoreGeometry(settings.value(parent->objectName() + "+Geomtery", "").toByteArray());
if (fileDialog.exec())
{
QStringList selectedFiles = fileDialog.selectedFiles();
if (selectedFiles.length() == 1)
{
QString selectedFile = selectedFiles.at(0);
if (QFile::exists(selectedFile))
{
if (QMessageBox::Yes == QMessageBox::warning(parent, PictureDialog::tr("Export as GTA Snapmatic"), PictureDialog::tr("Overwrite %1 with current Snapmatic picture?").arg("\""+selectedFile+"\""), QMessageBox::Yes | QMessageBox::No, QMessageBox::Yes))
{
if (!QFile::remove(selectedFile))
{
QMessageBox::warning(parent, PictureDialog::tr("Export as GTA Snapmatic"), PictureDialog::tr("Failed to overwrite %1 with current Snapmatic picture").arg("\""+selectedFile+"\""));
goto fileDialogPreSave;
}
}
else
{
goto fileDialogPreSave;
}
}
if (selectedFile.right(4) == ".g5e")
{
bool isExported = picture->exportPicture(selectedFile, true);
if (!isExported)
{
QMessageBox::warning(parent, PictureDialog::tr("Export as GTA Snapmatic"), PictureDialog::tr("Failed to export current Snapmatic picture"));
goto fileDialogPreSave;
}
}
else
{
bool isAutoExt = false;
if (selectedFile.right(5) == ".auto")
{
isAutoExt = true;
QString dirPath = QFileInfo(selectedFile).dir().path();
QString stockFileName = sgdFileInfo.fileName();
selectedFile = dirPath + "/" + stockFileName;
}
else if (selectedFile.right(4) == ".rem")
{
selectedFile.remove(".rem");
}
bool isCopied = picture->exportPicture(selectedFile, false);
if (!isCopied)
{
QMessageBox::warning(parent, PictureDialog::tr("Export as GTA Snapmatic"), PictureDialog::tr("Failed to export current Snapmatic picture"));
goto fileDialogPreSave;
}
else
{
if (isAutoExt) QMessageBox::information(parent, PictureDialog::tr("Export as GTA Snapmatic"), PictureDialog::tr("Exported Snapmatic to \"%1\" because of using the .auto extension.").arg(selectedFile));
}
}
}
else
{
QMessageBox::warning(parent, PictureDialog::tr("Export as GTA Snapmatic"), PictureDialog::tr("No valid file is selected"));
goto fileDialogPreSave;
}
}
settings.setValue(parent->objectName() + "+Geometry", fileDialog.saveGeometry());
settings.setValue("Directory", fileDialog.directory().absolutePath());
settings.endGroup();
}
QString PictureExport::getPictureFileName(SnapmaticPicture *picture)
{
return picture->getExportPictureFileName();
}

70
PictureExport.h Normal file → Executable file
View File

@ -1,35 +1,35 @@
/*****************************************************************************
* gta5view Grand Theft Auto V Profile Viewer
* 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 PICTUREEXPORT_H
#define PICTUREEXPORT_H
#include "SnapmaticPicture.h"
#include <QWidget>
#include <QString>
class PictureExport
{
public:
PictureExport();
static void exportAsPicture(QWidget *parent, SnapmaticPicture *picture);
static void exportAsSnapmatic(QWidget *parent, SnapmaticPicture *picture);
static QString getPictureFileName(SnapmaticPicture *picture);
};
#endif // PICTUREEXPORT_H
/*****************************************************************************
* 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 PICTUREEXPORT_H
#define PICTUREEXPORT_H
#include "SnapmaticPicture.h"
#include <QWidget>
#include <QString>
class PictureExport
{
public:
PictureExport();
static void exportAsPicture(QWidget *parent, SnapmaticPicture *picture);
static void exportAsSnapmatic(QWidget *parent, SnapmaticPicture *picture);
static QString getPictureFileName(SnapmaticPicture *picture);
};
#endif // PICTUREEXPORT_H

View File

@ -1,5 +1,5 @@
/*****************************************************************************
* gta5view Grand Theft Auto V Profile Viewer
* gta5sync GRAND THEFT AUTO V SYNC
* Copyright (C) 2016-2017 Syping
*
* This program is free software: you can redistribute it and/or modify
@ -19,6 +19,7 @@
#include "PictureDialog.h"
#include "PictureWidget.h"
#include "UiModLabel.h"
#include <QDesktopWidget>
#include <QApplication>
#include <QHBoxLayout>
#include <QKeyEvent>
@ -26,10 +27,6 @@
#include <QEvent>
#include <QDebug>
#if QT_VERSION < 0x060000
#include <QDesktopWidget>
#endif
PictureWidget::PictureWidget(QWidget *parent) : QDialog(parent)
{
installEventFilter(this);
@ -47,9 +44,7 @@ PictureWidget::PictureWidget(QWidget *parent) : QDialog(parent)
QObject::connect(pictureLabel, SIGNAL(mouseDoubleClicked(Qt::MouseButton)), this, SLOT(pictureDoubleClicked(Qt::MouseButton)));
QObject::connect(pictureLabel, SIGNAL(customContextMenuRequested(QPoint)), parent, SLOT(exportCustomContextMenuRequested(QPoint)));
#if QT_VERSION < 0x060000
QObject::connect(QApplication::desktop(), SIGNAL(resized(int)), this, SLOT(updateWindowSize(int)));
#endif
setLayout(widgetLayout);
}
@ -103,21 +98,12 @@ void PictureWidget::setImage(QImage image_)
void PictureWidget::updateWindowSize(int screenID)
{
#if QT_VERSION >= 0x060000
Q_UNUSED(screenID)
QRect desktopRect = QApplication::screenAt(pos())->geometry();
move(desktopRect.x(), desktopRect.y());
resize(desktopRect.width(), desktopRect.height());
showFullScreen();
pictureLabel->setPixmap(QPixmap::fromImage(image.scaled(desktopRect.width(), desktopRect.height(), Qt::KeepAspectRatio, Qt::SmoothTransformation)));
#else
if (screenID == QApplication::desktop()->screenNumber(this))
{
QRect desktopRect = QApplication::desktop()->screenGeometry(this);
move(desktopRect.x(), desktopRect.y());
resize(desktopRect.width(), desktopRect.height());
showFullScreen();
this->move(desktopRect.x(), desktopRect.y());
this->resize(desktopRect.width(), desktopRect.height());
this->showFullScreen();
pictureLabel->setPixmap(QPixmap::fromImage(image.scaled(desktopRect.width(), desktopRect.height(), Qt::KeepAspectRatio, Qt::SmoothTransformation)));
}
#endif
}

View File

@ -1,5 +1,5 @@
/*****************************************************************************
* gta5view Grand Theft Auto V Profile Viewer
* gta5sync GRAND THEFT AUTO V SYNC
* Copyright (C) 2016-2017 Syping
*
* This program is free software: you can redistribute it and/or modify

View File

@ -1,241 +0,0 @@
/*****************************************************************************
* gta5view Grand Theft Auto V Profile Viewer
* Copyright (C) 2016-2020 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);
listUpdated = false;
ui->setupUi(this);
ui->cmdCancel->setDefault(true);
ui->cmdCancel->setFocus();
// Set Icon for Apply Button
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("gtk-apply"))
{
ui->cmdApply->setIcon(QIcon::fromTheme("gtk-apply"));
}
else if (QIcon::hasThemeIcon("dialog-ok"))
{
ui->cmdApply->setIcon(QIcon::fromTheme("dialog-ok"));
}
else if (QIcon::hasThemeIcon("gtk-ok"))
{
ui->cmdApply->setIcon(QIcon::fromTheme("dialog-ok"));
}
// Set Icon for Cancel Button
if (QIcon::hasThemeIcon("dialog-cancel"))
{
ui->cmdCancel->setIcon(QIcon::fromTheme("dialog-cancel"));
}
else if (QIcon::hasThemeIcon("gtk-cancel"))
{
ui->cmdCancel->setIcon(QIcon::fromTheme("gtk-cancel"));
}
// Set Icon for Manage Buttons
if (QIcon::hasThemeIcon("go-previous") && QIcon::hasThemeIcon("go-next") && QIcon::hasThemeIcon("list-add"))
{
#if QT_VERSION < 0x050600
qreal screenRatio = AppEnv::screenRatio();
if (screenRatio != 1) {
QSize iconSize = ui->cmdMakeAv->iconSize();
iconSize = QSize(iconSize.width() * screenRatio, iconSize.height() * screenRatio);
ui->cmdMakeAv->setIconSize(iconSize);
ui->cmdMakeSe->setIconSize(iconSize);
ui->cmdMakeAd->setIconSize(iconSize);
}
#endif
ui->cmdMakeAv->setIcon(QIcon::fromTheme("go-previous"));
ui->cmdMakeSe->setIcon(QIcon::fromTheme("go-next"));
ui->cmdMakeAd->setIcon(QIcon::fromTheme("list-add"));
}
else
{
#if QT_VERSION < 0x050600
qreal screenRatio = AppEnv::screenRatio();
if (screenRatio != 1) {
QSize iconSize = ui->cmdMakeAv->iconSize();
iconSize = QSize(iconSize.width() * screenRatio, iconSize.height() * screenRatio);
ui->cmdMakeAv->setIconSize(iconSize);
ui->cmdMakeSe->setIconSize(iconSize);
ui->cmdMakeAd->setIconSize(iconSize);
}
#endif
ui->cmdMakeAv->setIcon(QIcon(":/img/back.svgz"));
ui->cmdMakeSe->setIcon(QIcon(":/img/next.svgz"));
ui->cmdMakeAd->setIcon(QIcon(":/img/add.svgz"));
}
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::on_cmdCancel_clicked()
{
close();
}
void PlayerListDialog::buildInterface()
{
const QStringList dbPlayers = profileDB->getPlayers();
for (QString sePlayer : players)
{
QListWidgetItem *playerItem = new QListWidgetItem(profileDB->getPlayerName(sePlayer));
playerItem->setData(Qt::UserRole, sePlayer);
ui->listSePlayers->addItem(playerItem);
}
for (QString dbPlayer : dbPlayers)
{
if (!players.contains(dbPlayer))
{
QListWidgetItem *playerItem = new QListWidgetItem(profileDB->getPlayerName(dbPlayer));
playerItem->setData(Qt::UserRole, dbPlayer);
ui->listAvPlayers->addItem(playerItem);
}
}
ui->listAvPlayers->sortItems(Qt::AscendingOrder);
}
void PlayerListDialog::on_cmdMakeAv_clicked()
{
for (QListWidgetItem *item : ui->listSePlayers->selectedItems())
{
QString playerName = item->text();
int playerID = item->data(Qt::UserRole).toInt();
delete item;
QListWidgetItem *playerItem = new QListWidgetItem(playerName);
playerItem->setData(Qt::UserRole, playerID);
ui->listAvPlayers->addItem(playerItem);
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 playerName = item->text();
int playerID = item->data(Qt::UserRole).toInt();
delete item;
QListWidgetItem *playerItem = new QListWidgetItem(playerName);
playerItem->setData(Qt::UserRole, playerID);
ui->listSePlayers->addItem(playerItem);
}
}
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 itemPlayerName = item->text();
int itemPlayerID = item->data(Qt::UserRole).toInt();
if (itemPlayerID == playerID)
{
delete item;
QListWidgetItem *playerItem = new QListWidgetItem(itemPlayerName);
playerItem->setData(Qt::UserRole, playerID);
ui->listSePlayers->addItem(playerItem);
return;
}
}
for (int i = 0; i < ui->listSePlayers->count(); ++i)
{
QListWidgetItem *item = ui->listSePlayers->item(i);
int itemPlayerID = item->data(Qt::UserRole).toInt();
if (itemPlayerID == playerID)
{
QMessageBox::warning(this, tr("Add Player..."), tr("Failed to add Player %1 because Player %1 is already added!").arg(QString::number(playerID)));
return;
}
}
QListWidgetItem *playerItem = new QListWidgetItem(QString::number(playerID));
playerItem->setData(Qt::UserRole, playerID);
ui->listSePlayers->addItem(playerItem);
}
}
void PlayerListDialog::on_cmdApply_clicked()
{
players.clear();
for (int i = 0; i < ui->listSePlayers->count(); ++i)
{
players += ui->listSePlayers->item(i)->data(Qt::UserRole).toString();
}
emit playerListUpdated(players);
listUpdated = true;
close();
}
QStringList PlayerListDialog::getPlayerList() const
{
return players;
}
bool PlayerListDialog::isListUpdated()
{
return listUpdated;
}

View File

@ -1,57 +0,0 @@
/*****************************************************************************
* gta5view Grand Theft Auto V Profile Viewer
* 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);
QStringList getPlayerList() const;
bool isListUpdated();
~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;
bool listUpdated;
void buildInterface();
signals:
void playerListUpdated(QStringList playerList);
};
#endif // PLAYERLISTDIALOG_H

View File

@ -1,173 +0,0 @@
<?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="focusPolicy">
<enum>Qt::NoFocus</enum>
</property>
<property name="autoDefault">
<bool>false</bool>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="cmdMakeAv">
<property name="focusPolicy">
<enum>Qt::NoFocus</enum>
</property>
<property name="text">
<string/>
</property>
<property name="autoDefault">
<bool>false</bool>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="cmdMakeAd">
<property name="focusPolicy">
<enum>Qt::NoFocus</enum>
</property>
<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="dragDropMode">
<enum>QAbstractItemView::InternalMove</enum>
</property>
<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="sizePolicy">
<sizepolicy hsizetype="Minimum" vsizetype="Minimum">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>&amp;Apply</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="cmdCancel">
<property name="sizePolicy">
<sizepolicy hsizetype="Minimum" vsizetype="Minimum">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>&amp;Cancel</string>
</property>
</widget>
</item>
</layout>
</item>
</layout>
</widget>
<resources/>
<connections/>
</ui>

146
ProfileDatabase.cpp Normal file → Executable file
View File

@ -1,85 +1,61 @@
/*****************************************************************************
* gta5view Grand Theft Auto V Profile Viewer
* 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 "ProfileDatabase.h"
#include "StandardPaths.h"
#include "config.h"
#include <QStringBuilder>
#include <QMutexLocker>
#include <QDebug>
#include <QFile>
#include <QDir>
ProfileDatabase::ProfileDatabase(QObject *parent) : QObject(parent)
{
QDir dir;
dir.mkpath(StandardPaths::dataLocation());
dir.setPath(StandardPaths::dataLocation());
QString dirPath = dir.absolutePath();
QString defaultConfPath = dirPath % "/players.ini";
QSettings confPathSettings(GTA5SYNC_APPVENDOR, GTA5SYNC_APPSTR);
confPathSettings.beginGroup("Database");
QString confPathFile = confPathSettings.value("Players", defaultConfPath).toString();
confPathSettings.endGroup();
profileDB = new QSettings(confPathFile, QSettings::IniFormat);
profileDB->beginGroup("Players");
}
ProfileDatabase::~ProfileDatabase()
{
profileDB->endGroup();
delete profileDB;
}
QStringList ProfileDatabase::getPlayers()
{
QMutexLocker locker(&mutex);
#ifdef GTA5SYNC_DEBUG
qDebug() << "getPlayers";
#endif
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);
#ifdef GTA5SYNC_DEBUG
qDebug() << "getPlayerName" << playerID;
#endif
return profileDB->value(QString::number(playerID), playerID).toString();
}
void ProfileDatabase::setPlayerName(int playerID, QString playerName)
{
QMutexLocker locker(&mutex);
#ifdef GTA5SYNC_DEBUG
qDebug() << "setPlayerName" << playerID << playerName;
#endif
profileDB->setValue(QString::number(playerID), playerName);
}
/*****************************************************************************
* 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 "ProfileDatabase.h"
#include "StandardPaths.h"
#include "config.h"
#include <QFile>
#include <QDir>
ProfileDatabase::ProfileDatabase(QObject *parent) : QObject(parent)
{
QDir dir;
dir.mkpath(StandardPaths::dataLocation());
dir.setPath(StandardPaths::dataLocation());
QString dirPath = dir.absolutePath();
QString defaultConfPath = dirPath + QDir::separator() + "players.ini";
QSettings confPathSettings(GTA5SYNC_APPVENDOR, GTA5SYNC_APPSTR);
confPathSettings.beginGroup("Database");
QString confPathFile = confPathSettings.value("Players", defaultConfPath).toString();
confPathSettings.endGroup();
profileDB = new QSettings(confPathFile, QSettings::IniFormat);
profileDB->beginGroup("Players");
}
ProfileDatabase::~ProfileDatabase()
{
profileDB->endGroup();
delete profileDB;
}
QStringList ProfileDatabase::getPlayers()
{
return profileDB->childKeys();
}
QString ProfileDatabase::getPlayerName(int playerID)
{
return profileDB->value(QString::number(playerID), playerID).toString();
}
void ProfileDatabase::setPlayerName(int playerID, QString playerName)
{
profileDB->setValue(QString::number(playerID), playerName);
}

89
ProfileDatabase.h Normal file → Executable file
View File

@ -1,46 +1,43 @@
/*****************************************************************************
* gta5view Grand Theft Auto V Profile Viewer
* 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 PROFILEDATABASE_H
#define PROFILEDATABASE_H
#include <QSettings>
#include <QObject>
#include <QMutex>
#include <QMap>
class ProfileDatabase : public QObject
{
Q_OBJECT
public:
explicit ProfileDatabase(QObject *parent = 0);
QString getPlayerName(QString playerID);
QString getPlayerName(int playerID);
QStringList getPlayers();
~ProfileDatabase();
private:
mutable QMutex mutex;
QSettings *profileDB;
public slots:
void setPlayerName(int playerID, QString playerName);
};
#endif // PROFILEDATABASE_H
/*****************************************************************************
* 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 PROFILEDATABASE_H
#define PROFILEDATABASE_H
#include <QSettings>
#include <QObject>
#include <QMap>
class ProfileDatabase : public QObject
{
Q_OBJECT
public:
explicit ProfileDatabase(QObject *parent = 0);
QString getPlayerName(int playerID);
QStringList getPlayers();
~ProfileDatabase();
private:
QSettings *profileDB;
public slots:
void setPlayerName(int playerID, QString playerName);
};
#endif // PROFILEDATABASE_H

1747
ProfileInterface.cpp Normal file → Executable file

File diff suppressed because it is too large Load Diff

249
ProfileInterface.h Normal file → Executable file
View File

@ -1,137 +1,112 @@
/*****************************************************************************
* gta5view Grand Theft Auto V Profile Viewer
* 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 PROFILEINTERFACE_H
#define PROFILEINTERFACE_H
#include "SnapmaticPicture.h"
#include "SnapmaticWidget.h"
#include "ProfileDatabase.h"
#include "DatabaseThread.h"
#include "SavegameWidget.h"
#include "ProfileLoader.h"
#include "ProfileWidget.h"
#include "ExportThread.h"
#include "SavegameData.h"
#include "CrewDatabase.h"
#include "pcg_basic.h"
#include <QProgressDialog>
#include <QSpacerItem>
#include <QDateTime>
#include <QWidget>
#include <QList>
#include <QMap>
namespace Ui {
class ProfileInterface;
}
enum class MassTool : int { Qualify = 0, Players = 1, Crew = 2, Title = 3 };
class ProfileInterface : public QWidget
{
Q_OBJECT
public:
explicit ProfileInterface(ProfileDatabase *profileDB, CrewDatabase *crewDB, DatabaseThread *threadDB, QWidget *parent = 0);
void setProfileFolder(QString folder, QString profile);
void settingsApplied(int contentMode, bool languageChanged);
void setupProfileInterface();
void massTool(MassTool tool);
void disableSelected();
void enableSelected();
int selectedWidgets();
void retranslateUi();
~ProfileInterface();
public slots:
void contextMenuTriggeredPIC(QContextMenuEvent* ev);
void contextMenuTriggeredSGD(QContextMenuEvent* ev);
void hoverProfileWidgetCheck();
void selectAllWidgets();
void deselectAllWidgets();
void exportSelected();
void deleteSelected();
void updatePalette();
void importFiles();
private slots:
void on_cmdCloseProfile_clicked();
void on_cmdImport_clicked();
void pictureLoaded_event(SnapmaticPicture *picture);
void pictureFixed_event(SnapmaticPicture *picture);
void savegameLoaded_event(SavegameData *savegame, QString savegamePath);
void loadingProgress(int value, int maximum);
void pictureDeleted_event();
void savegameDeleted_event();
void profileLoaded_p();
void profileWidgetSelected();
void profileWidgetDeselected();
void dialogNextPictureRequested(QWidget *dialog);
void dialogPreviousPictureRequested(QWidget *dialog);
void on_saProfileContent_dropped(const QMimeData *mimeData);
protected:
bool eventFilter(QObject *watched, QEvent *event);
private:
ProfileDatabase *profileDB;
CrewDatabase *crewDB;
DatabaseThread *threadDB;
Ui::ProfileInterface *ui;
ProfileLoader *profileLoader;
ProfileWidget *previousWidget;
QList<SavegameData*> savegames;
QList<SnapmaticPicture*> pictures;
QMap<ProfileWidget*,QString> widgets;
QSpacerItem *saSpacerItem;
QStringList fixedPictures;
QString enabledPicStr;
QString profileFolder;
QString profileName;
QString loadingStr;
QString language;
pcg32_random_t rng;
bool contextMenuOpened;
bool isProfileLoaded;
int selectedWidgts;
int contentMode;
bool isSupportedImageFile(QString selectedFileName);
bool importFile(QString selectedFile, QDateTime importDateTime, bool notMultiple);
bool importUrls(const QMimeData *mimeData);
bool importRemote(QUrl remoteUrl);
bool importImage(QImage *snapmaticImage, QDateTime importDateTime);
bool importFilesProgress(QStringList selectedFiles);
bool importSnapmaticPicture(SnapmaticPicture *picture, bool warn = true);
bool importSavegameData(SavegameData *savegame, QString sgdPath, bool warn = true);
void pictureLoaded(SnapmaticPicture *picture, bool inserted);
void savegameLoaded(SavegameData *savegame, QString savegamePath, bool inserted);
void savegameDeleted(SavegameWidget *sgdWidget, bool isRemoteEmited = false);
void pictureDeleted(SnapmaticWidget *picWidget, bool isRemoteEmited = false);
void insertSnapmaticIPI(QWidget *widget);
void insertSavegameIPI(QWidget *widget);
void sortingProfileInterface();
int getRandomUid();
signals:
void profileLoaded();
void profileClosed();
};
#endif // PROFILEINTERFACE_H
/*****************************************************************************
* 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 PROFILEINTERFACE_H
#define PROFILEINTERFACE_H
#include "SnapmaticPicture.h"
#include "SnapmaticWidget.h"
#include "ProfileDatabase.h"
#include "DatabaseThread.h"
#include "SavegameWidget.h"
#include "ProfileLoader.h"
#include "ProfileWidget.h"
#include "ExportThread.h"
#include "SavegameData.h"
#include "CrewDatabase.h"
#include <QProgressDialog>
#include <QSpacerItem>
#include <QWidget>
#include <QList>
#include <QMap>
namespace Ui {
class ProfileInterface;
}
class ProfileInterface : public QWidget
{
Q_OBJECT
public:
explicit ProfileInterface(ProfileDatabase *profileDB, CrewDatabase *crewDB, DatabaseThread *threadDB, QWidget *parent = 0);
void setProfileFolder(QString folder, QString profile);
void settingsApplied(int contentMode, QString language);
void setupProfileInterface();
void disableSelected();
void enableSelected();
int selectedWidgets();
~ProfileInterface();
public slots:
void contextMenuTriggeredPIC(QContextMenuEvent* ev);
void contextMenuTriggeredSGD(QContextMenuEvent* ev);
void selectAllWidgets();
void deselectAllWidgets();
void exportSelected();
void deleteSelected();
void importFiles();
private slots:
void on_cmdCloseProfile_clicked();
void on_cmdImport_clicked();
void pictureLoaded_event(SnapmaticPicture *picture);
void savegameLoaded_event(SavegameData *savegame, QString savegamePath);
void loadingProgress(int value, int maximum);
void pictureDeleted_event();
void savegameDeleted_event();
void profileLoaded_p();
void profileWidgetSelected();
void profileWidgetDeselected();
void dialogNextPictureRequested(QWidget *dialog);
void dialogPreviousPictureRequested(QWidget *dialog);
private:
ProfileDatabase *profileDB;
CrewDatabase *crewDB;
DatabaseThread *threadDB;
Ui::ProfileInterface *ui;
ProfileLoader *profileLoader;
QList<SavegameData*> savegames;
QList<SnapmaticPicture*> pictures;
QMap<ProfileWidget*,QString> widgets;
QSpacerItem *saSpacerItem;
QString enabledPicStr;
QString profileFolder;
QString profileName;
QString loadingStr;
int selectedWidgts;
int contentMode;
bool importFile(QString selectedFile, bool notMultiple, int currentId);
bool importSnapmaticPicture(SnapmaticPicture *picture, bool warn = true);
bool importSavegameData(SavegameData *savegame, QString sgdPath, bool warn = true);
void pictureLoaded(SnapmaticPicture *picture, bool inserted);
void savegameLoaded(SavegameData *savegame, QString savegamePath, bool inserted);
void savegameDeleted(SavegameWidget *sgdWidget);
void pictureDeleted(SnapmaticWidget *picWidget);
void insertSnapmaticIPI(QWidget *widget);
void insertSavegameIPI(QWidget *widget);
void sortingProfileInterface();
signals:
void profileLoaded();
void profileClosed();
};
#endif // PROFILEINTERFACE_H

474
ProfileInterface.ui Normal file → Executable file
View File

@ -1,244 +1,230 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>ProfileInterface</class>
<widget class="QWidget" name="ProfileInterface">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>400</width>
<height>300</height>
</rect>
</property>
<property name="windowTitle">
<string>Profile Interface</string>
</property>
<layout class="QVBoxLayout" name="vlProfileInterface">
<property name="spacing">
<number>0</number>
</property>
<property name="leftMargin">
<number>0</number>
</property>
<property name="topMargin">
<number>0</number>
</property>
<property name="rightMargin">
<number>0</number>
</property>
<property name="bottomMargin">
<number>0</number>
</property>
<item>
<widget class="QStackedWidget" name="swProfile">
<property name="currentIndex">
<number>0</number>
</property>
<widget class="QWidget" name="pageLoading">
<layout class="QVBoxLayout" name="vlLoadingPage">
<item>
<spacer name="vsLoading1">
<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="QLabel" name="labProfileLoading">
<property name="text">
<string>Loading file %1 of %2 files</string>
</property>
<property name="alignment">
<set>Qt::AlignCenter</set>
</property>
</widget>
</item>
<item>
<widget class="QProgressBar" name="pbPictureLoading">
<property name="value">
<number>0</number>
</property>
<property name="textVisible">
<bool>false</bool>
</property>
</widget>
</item>
<item>
<spacer name="vsLoading2">
<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>
</widget>
<widget class="QWidget" name="pageProfile">
<layout class="QVBoxLayout" name="vlProfilePage">
<property name="leftMargin">
<number>0</number>
</property>
<property name="topMargin">
<number>0</number>
</property>
<property name="rightMargin">
<number>0</number>
</property>
<property name="bottomMargin">
<number>0</number>
</property>
<item>
<widget class="QScrollArea" name="saProfile">
<property name="widgetResizable">
<bool>true</bool>
</property>
<widget class="UiModWidget" name="saProfileContent">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>398</width>
<height>257</height>
</rect>
</property>
<property name="acceptDrops">
<bool>true</bool>
</property>
<layout class="QVBoxLayout" name="vlProfile">
<property name="leftMargin">
<number>0</number>
</property>
<property name="topMargin">
<number>0</number>
</property>
<property name="rightMargin">
<number>0</number>
</property>
<property name="bottomMargin">
<number>0</number>
</property>
<item>
<layout class="QVBoxLayout" name="vlContent">
<property name="spacing">
<number>0</number>
</property>
<item>
<layout class="QVBoxLayout" name="vlSavegame"/>
</item>
<item>
<layout class="QVBoxLayout" name="vlSnapmatic"/>
</item>
</layout>
</item>
</layout>
</widget>
</widget>
</item>
</layout>
</widget>
</widget>
</item>
<item>
<layout class="QHBoxLayout" name="hlButtons">
<property name="spacing">
<number>6</number>
</property>
<property name="leftMargin">
<number>9</number>
</property>
<property name="topMargin">
<number>9</number>
</property>
<property name="rightMargin">
<number>9</number>
</property>
<property name="bottomMargin">
<number>9</number>
</property>
<item>
<widget class="QLabel" name="labVersion">
<property name="text">
<string>%1 %2</string>
</property>
</widget>
</item>
<item>
<spacer name="hsProfile">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QPushButton" name="cmdImport">
<property name="sizePolicy">
<sizepolicy hsizetype="Minimum" vsizetype="Minimum">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="toolTip">
<string>Import file</string>
</property>
<property name="text">
<string>&amp;Import...</string>
</property>
<property name="autoDefault">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="cmdCloseProfile">
<property name="sizePolicy">
<sizepolicy hsizetype="Minimum" vsizetype="Minimum">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="toolTip">
<string>Close profile</string>
</property>
<property name="text">
<string>&amp;Close</string>
</property>
<property name="autoDefault">
<bool>true</bool>
</property>
</widget>
</item>
</layout>
</item>
</layout>
</widget>
<customwidgets>
<customwidget>
<class>UiModWidget</class>
<extends>QWidget</extends>
<header>UiModWidget.h</header>
<container>1</container>
<slots>
<signal>dropped(QMimeData*)</signal>
</slots>
</customwidget>
</customwidgets>
<resources/>
<connections/>
</ui>
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>ProfileInterface</class>
<widget class="QWidget" name="ProfileInterface">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>400</width>
<height>300</height>
</rect>
</property>
<property name="windowTitle">
<string>Profile Interface</string>
</property>
<layout class="QVBoxLayout" name="vlProfileInterface">
<property name="spacing">
<number>0</number>
</property>
<property name="leftMargin">
<number>0</number>
</property>
<property name="topMargin">
<number>0</number>
</property>
<property name="rightMargin">
<number>0</number>
</property>
<property name="bottomMargin">
<number>0</number>
</property>
<item>
<widget class="QStackedWidget" name="swProfile">
<property name="currentIndex">
<number>0</number>
</property>
<widget class="QWidget" name="pageLoading">
<layout class="QVBoxLayout" name="vlLoadingPage">
<item>
<spacer name="vsLoading1">
<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="QLabel" name="labProfileLoading">
<property name="text">
<string>Loading file %1 of %2 files</string>
</property>
<property name="alignment">
<set>Qt::AlignCenter</set>
</property>
</widget>
</item>
<item>
<widget class="QProgressBar" name="pbPictureLoading">
<property name="value">
<number>0</number>
</property>
<property name="textVisible">
<bool>false</bool>
</property>
</widget>
</item>
<item>
<spacer name="vsLoading2">
<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>
</widget>
<widget class="QWidget" name="pageProfile">
<layout class="QVBoxLayout" name="vlProfilePage">
<property name="leftMargin">
<number>0</number>
</property>
<property name="topMargin">
<number>0</number>
</property>
<property name="rightMargin">
<number>0</number>
</property>
<property name="bottomMargin">
<number>0</number>
</property>
<item>
<widget class="QScrollArea" name="saProfile">
<property name="widgetResizable">
<bool>true</bool>
</property>
<widget class="QWidget" name="saProfileContent">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>98</width>
<height>28</height>
</rect>
</property>
<layout class="QVBoxLayout" name="vlProfile">
<property name="leftMargin">
<number>0</number>
</property>
<property name="topMargin">
<number>0</number>
</property>
<property name="rightMargin">
<number>0</number>
</property>
<property name="bottomMargin">
<number>0</number>
</property>
<item>
<layout class="QVBoxLayout" name="vlContent">
<property name="spacing">
<number>0</number>
</property>
<item>
<layout class="QVBoxLayout" name="vlSavegame"/>
</item>
<item>
<layout class="QVBoxLayout" name="vlSnapmatic"/>
</item>
</layout>
</item>
</layout>
</widget>
</widget>
</item>
</layout>
</widget>
</widget>
</item>
<item>
<layout class="QHBoxLayout" name="hlButtons">
<property name="spacing">
<number>6</number>
</property>
<property name="leftMargin">
<number>9</number>
</property>
<property name="topMargin">
<number>9</number>
</property>
<property name="rightMargin">
<number>9</number>
</property>
<property name="bottomMargin">
<number>9</number>
</property>
<item>
<widget class="QLabel" name="labVersion">
<property name="text">
<string>%1 %2</string>
</property>
</widget>
</item>
<item>
<spacer name="hsProfile">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QPushButton" name="cmdImport">
<property name="sizePolicy">
<sizepolicy hsizetype="Minimum" vsizetype="Minimum">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="toolTip">
<string>Import exported file</string>
</property>
<property name="text">
<string>&amp;Import...</string>
</property>
<property name="autoDefault">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="cmdCloseProfile">
<property name="sizePolicy">
<sizepolicy hsizetype="Minimum" vsizetype="Minimum">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="toolTip">
<string>Close profile</string>
</property>
<property name="text">
<string>&amp;Close</string>
</property>
<property name="autoDefault">
<bool>true</bool>
</property>
</widget>
</item>
</layout>
</item>
</layout>
</widget>
<resources/>
<connections/>
</ui>

209
ProfileLoader.cpp Normal file → Executable file
View File

@ -1,116 +1,93 @@
/*****************************************************************************
* gta5view Grand Theft Auto V Profile Viewer
* 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 "ProfileLoader.h"
#include "SnapmaticPicture.h"
#include "SavegameData.h"
#include "CrewDatabase.h"
#include <QStringBuilder>
#include <QStringList>
#include <QString>
#include <QThread>
#include <QList>
#include <QFile>
#include <QDir>
ProfileLoader::ProfileLoader(QString profileFolder, CrewDatabase *crewDB, QObject *parent) : QThread(parent), profileFolder(profileFolder), crewDB(crewDB)
{
}
void ProfileLoader::run()
{
int curFile = 1;
QDir profileDir;
QList<int> crewList;
profileDir.setPath(profileFolder);
// Seek pictures and savegames
profileDir.setNameFilters(QStringList("SGTA*"));
QStringList SavegameFiles = profileDir.entryList(QDir::Files | QDir::NoDot, QDir::NoSort);
QStringList BackupFiles = SavegameFiles.filter(".bak", Qt::CaseInsensitive);
profileDir.setNameFilters(QStringList("PGTA*"));
QStringList SnapmaticPics = profileDir.entryList(QDir::Files | QDir::NoDot, QDir::NoSort);
BackupFiles += SnapmaticPics.filter(".bak", Qt::CaseInsensitive);
SavegameFiles.removeDuplicates();
SnapmaticPics.removeDuplicates();
for (QString BackupFile : BackupFiles)
{
SavegameFiles.removeAll(BackupFile);
SnapmaticPics.removeAll(BackupFile);
}
int maximumV = SavegameFiles.length() + SnapmaticPics.length();
// Loading pictures and savegames
emit loadingProgress(curFile, maximumV);
for (QString SavegameFile : SavegameFiles)
{
emit loadingProgress(curFile, maximumV);
QString sgdPath = profileFolder % "/" % SavegameFile;
SavegameData *savegame = new SavegameData(sgdPath);
if (savegame->readingSavegame())
{
emit savegameLoaded(savegame, sgdPath);
}
curFile++;
}
for (QString SnapmaticPic : SnapmaticPics)
{
emit loadingProgress(curFile, maximumV);
QString picturePath = profileFolder % "/" % SnapmaticPic;
SnapmaticPicture *picture = new SnapmaticPicture(picturePath);
if (picture->readingPicture(true, true, true))
{
if (picture->isFormatSwitched())
{
picture->setSnapmaticFormat(SnapmaticFormat::PGTA_Format);
if (picture->exportPicture(picturePath, SnapmaticFormat::PGTA_Format))
{
emit pictureFixed(picture);
}
}
emit pictureLoaded(picture);
int crewNumber = picture->getSnapmaticProperties().crewID;
if (!crewList.contains(crewNumber))
{
crewList += crewNumber;
}
}
curFile++;
}
// adding found crews
crewDB->setAddingCrews(true);
for (int crewID : crewList)
{
crewDB->addCrew(crewID);
}
crewDB->setAddingCrews(false);
}
void ProfileLoader::preloaded()
{
}
void ProfileLoader::loaded()
{
}
/*****************************************************************************
* 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 "ProfileLoader.h"
#include "SnapmaticPicture.h"
#include "SavegameData.h"
#include "CrewDatabase.h"
#include <QStringList>
#include <QString>
#include <QFile>
#include <QDir>
ProfileLoader::ProfileLoader(QString profileFolder, CrewDatabase *crewDB, QObject *parent) : QThread(parent), profileFolder(profileFolder), crewDB(crewDB)
{
}
void ProfileLoader::run()
{
int curFile = 1;
QDir profileDir;
QList<int> crewList;
profileDir.setPath(profileFolder);
// Seek pictures and savegames
profileDir.setNameFilters(QStringList("SGTA*"));
QStringList SavegameFiles = profileDir.entryList(QDir::Files | QDir::NoDot, QDir::NoSort);
QStringList BackupFiles = SavegameFiles.filter(".bak", Qt::CaseInsensitive);
profileDir.setNameFilters(QStringList("PGTA*"));
QStringList SnapmaticPics = profileDir.entryList(QDir::Files | QDir::NoDot, QDir::NoSort);
BackupFiles.append(SnapmaticPics.filter(".bak", Qt::CaseInsensitive));
SavegameFiles.removeDuplicates();
SnapmaticPics.removeDuplicates();
foreach(const QString &BackupFile, BackupFiles)
{
SavegameFiles.removeAll(BackupFile);
SnapmaticPics.removeAll(BackupFile);
}
int maximumV = SavegameFiles.length() + SnapmaticPics.length();
// Loading pictures and savegames
emit loadingProgress(curFile, maximumV);
foreach(const QString &SavegameFile, SavegameFiles)
{
emit loadingProgress(curFile, maximumV);
QString sgdPath = profileFolder + QDir::separator() + SavegameFile;
SavegameData *savegame = new SavegameData(sgdPath);
if (savegame->readingSavegame())
{
emit savegameLoaded(savegame, sgdPath);
}
curFile++;
}
foreach(const QString &SnapmaticPic, SnapmaticPics)
{
emit loadingProgress(curFile, maximumV);
QString picturePath = profileFolder + QDir::separator() + SnapmaticPic;
SnapmaticPicture *picture = new SnapmaticPicture(picturePath);
if (picture->readingPicture(true, true, true))
{
emit pictureLoaded(picture);
int crewNumber = picture->getSnapmaticProperties().crewID;
if (!crewList.contains(crewNumber))
{
crewList.append(crewNumber);
}
}
curFile++;
}
// adding found crews
foreach(int crewID, crewList)
{
crewDB->addCrew(crewID);
}
}

101
ProfileLoader.h Normal file → Executable file
View File

@ -1,53 +1,48 @@
/*****************************************************************************
* gta5view Grand Theft Auto V Profile Viewer
* 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 PROFILELOADER_H
#define PROFILELOADER_H
#include "SnapmaticPicture.h"
#include "SavegameData.h"
#include "CrewDatabase.h"
#include <QThread>
#include <QDir>
class ProfileLoader : public QThread
{
Q_OBJECT
public:
explicit ProfileLoader(QString profileFolder, CrewDatabase *crewDB, QObject *parent = 0);
protected:
void run();
private:
QString profileFolder;
CrewDatabase *crewDB;
ProfileLoader *profileLoader;
private slots:
void preloaded();
void loaded();
signals:
void pictureLoaded(SnapmaticPicture *picture);
void pictureFixed(SnapmaticPicture *picture);
void savegameLoaded(SavegameData *savegame, QString savegamePath);
void loadingProgress(int value, int maximum);
};
#endif // PROFILELOADER_H
/*****************************************************************************
* 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 PROFILELOADER_H
#define PROFILELOADER_H
#include "SnapmaticPicture.h"
#include "SavegameData.h"
#include "CrewDatabase.h"
#include <QThread>
#include <QDir>
class ProfileLoader : public QThread
{
Q_OBJECT
public:
explicit ProfileLoader(QString profileFolder, CrewDatabase *crewDB, QObject *parent = 0);
protected:
void run();
private:
QString profileFolder;
CrewDatabase *crewDB;
ProfileLoader *profileLoader;
signals:
void pictureLoaded(SnapmaticPicture *picture);
void savegameLoaded(SavegameData *savegame, QString savegamePath);
void loadingProgress(int value, int maximum);
};
#endif // PROFILELOADER_H

127
ProfileWidget.cpp Normal file → Executable file
View File

@ -1,66 +1,61 @@
/*****************************************************************************
* gta5view Grand Theft Auto V Profile Viewer
* 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 "ProfileWidget.h"
#include <QDebug>
ProfileWidget::ProfileWidget(QWidget *parent) : QWidget(parent)
{
contentMode = 0;
}
ProfileWidget::~ProfileWidget()
{
}
void ProfileWidget::retranslate()
{
qDebug() << "ProfileWidget::retranslate got used without overwrite";
}
bool ProfileWidget::isSelected()
{
qDebug() << "ProfileWidget::isSelected got used without overwrite";
return false;
}
void ProfileWidget::setSelected(bool isSelected)
{
qDebug() << "ProfileWidget::setSelected got used without overwrite, result" << isSelected;
}
void ProfileWidget::setSelectionMode(bool selectionMode)
{
qDebug() << "ProfileWidget::setSelectionMode got used without overwrite, result:" << selectionMode;
}
QString ProfileWidget::getWidgetType()
{
qDebug() << "ProfileWidget::getWidgetType got used without overwrite";
return "ProfileWidget";
}
int ProfileWidget::getContentMode()
{
return contentMode;
}
void ProfileWidget::setContentMode(int _contentMode)
{
contentMode = _contentMode;
}
/*****************************************************************************
* 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 "ProfileWidget.h"
#include <QDebug>
ProfileWidget::ProfileWidget(QWidget *parent) : QWidget(parent)
{
contentMode = 0;
}
ProfileWidget::~ProfileWidget()
{
}
bool ProfileWidget::isSelected()
{
qDebug() << "ProfileWidget::isSelected got used without overwrite";
return false;
}
void ProfileWidget::setSelected(bool isSelected)
{
qDebug() << "ProfileWidget::setSelected got used without overwrite, result" << isSelected;
}
void ProfileWidget::setSelectionMode(bool selectionMode)
{
qDebug() << "ProfileWidget::setSelectionMode got used without overwrite, result:" << selectionMode;
}
QString ProfileWidget::getWidgetType()
{
qDebug() << "ProfileWidget::getWidgetType got used without overwrite";
return "ProfileWidget";
}
int ProfileWidget::getContentMode()
{
return contentMode;
}
void ProfileWidget::setContentMode(int _contentMode)
{
contentMode = _contentMode;
}

91
ProfileWidget.h Normal file → Executable file
View File

@ -1,46 +1,45 @@
/*****************************************************************************
* gta5view Grand Theft Auto V Profile Viewer
* 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 PROFILEWIDGET_H
#define PROFILEWIDGET_H
#include <QWidget>
class ProfileWidget : public QWidget
{
Q_OBJECT
public:
explicit ProfileWidget(QWidget *parent = 0);
virtual void setSelectionMode(bool selectionMode);
virtual void setContentMode(int contentMode);
virtual void setSelected(bool isSelected);
virtual bool isSelected();
virtual QString getWidgetType();
virtual int getContentMode();
virtual void retranslate();
~ProfileWidget();
private:
int contentMode;
signals:
public slots:
};
#endif // PROFILEWIDGET_H
/*****************************************************************************
* 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 PROFILEWIDGET_H
#define PROFILEWIDGET_H
#include <QWidget>
class ProfileWidget : public QWidget
{
Q_OBJECT
public:
explicit ProfileWidget(QWidget *parent = 0);
virtual void setSelectionMode(bool selectionMode);
virtual void setContentMode(int contentMode);
virtual void setSelected(bool isSelected);
virtual bool isSelected();
virtual QString getWidgetType();
virtual int getContentMode();
~ProfileWidget();
private:
int contentMode;
signals:
public slots:
};
#endif // PROFILEWIDGET_H

View File

@ -1,53 +1,31 @@
## gta5view
Grand Theft Auto V Savegame and Snapmatic viewer/editor
Grand Theft Auto V Savegame and Snapmatic viewer
- View Snapmatics with the ability to disable them in-game
- Edit Snapmatic pictures and properties in multiple ways
- Import/Export Snapmatics, Savegames and pictures
- Choose between multiple Social Club accounts as GTA V profiles IDs
- Viewing Snapmatics and giving the ability to disable them in-game
- Import/Export Snapmatics and Savegames
- Choosing between multiple Social Club accounts as GTA V profiles IDs
#### Screenshots
![Snapmatic Picture Viewer](res/src/picture.png)
![User Interface](res/src/mainui.png)
![Snapmatic Properties](res/src/prop.png)
<img src="https://i.imgur.com/OaizCYM.png"/>
<img src="https://i.imgur.com/MhkGbRU.png"/>
<img src="https://i.imgur.com/qkCQ26U.png"/>
#### Build gta5view for Windows
#### Build gta5view Debian/Ubuntu
# Note: Install Docker Community Edition and Git before continuing
git clone https://gitlab.com/Syping/gta5view && cd gta5view
docker pull sypingauto/gta5view-build:1.8-static
docker run --rm -v ${PWD}:/gta5view -it sypingauto/gta5view-build:1.8-static
cd /gta5view && mkdir -p build && cd build
mingw64-qt-cmake ../
make -j $(nproc --all)
apt-get install git gcc g++ qtbase5-dev qt5-qmake make checkinstall
git clone https://github.com/SyDevTeam/gta5view
mkdir build && cd build
qmake -qt=5 ../gta5view.pro # or just qmake ../gta5view.pro
make
INSTALL_ROOT=/usr checkinstall --pkgname=gta5view --pkggroup=utility --requires=libqt5core5a,libqt5gui5,libqt5network5,libqt5widgets5
#### Build gta5view for Debian/Ubuntu
#### Build gta5view Windows
sudo apt-get install cmake git gcc g++ libqt5svg5-dev make qtbase5-dev qttranslations5-l10n
git clone https://gitlab.com/Syping/gta5view && cd gta5view
mkdir -p build && cd build
cmake ../
make -j $(nproc --all)
sudo make install
#### Build gta5view for Arch/Manjaro
sudo pacman -S cmake gcc git make qt5-base qt5-svg qt5-tools qt5-translations
git clone https://gitlab.com/Syping/gta5view && cd gta5view
mkdir -p build && cd build
cmake ../
make -j $(nproc --all)
sudo make install
#### Build gta5view for Fedora
sudo dnf install cmake git gcc gcc-c++ make qt5-qtbase-devel qt5-qtsvg-devel qt5-qttranslations
git clone https://gitlab.com/Syping/gta5view && cd gta5view
mkdir -p build && cd build
cmake ../
make -j $(nproc --all)
sudo make install
Downloading <a href="https://www.qt.io/">Qt Framework</a> and install it.<br>
Take the Online Installer and choose the MinGW version or install Microsoft Visual Studio 2013/2015 Community<br>
Downloading Source Code over GitHub or with your Git client.<br>
Open the gta5view.pro file with Qt Creator and build it over Qt Creator.<br>
#### Download Binary Releases
Go to [gta5view release](https://github.com/SyDevTeam/gta5view/releases) and download the .exe file for Windows, .deb file for Debian/Ubuntu and .dmg file for OS X.
Go to <a href="https://github.com/SyDevTeam/gta5view/releases">gta5view release</a> and download the .exe file for Windows, .deb file for Debian/Ubuntu and .rpm file for Red Hat/openSuSE/Fedora.

208
SavegameCopy.cpp Normal file → Executable file
View File

@ -1,108 +1,100 @@
/*****************************************************************************
* gta5view Grand Theft Auto V Profile Viewer
* 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 "SidebarGenerator.h"
#include "SavegameWidget.h"
#include "StandardPaths.h"
#include "SavegameCopy.h"
#include "config.h"
#include <QStringBuilder>
#include <QMessageBox>
#include <QFileDialog>
#include <QSettings>
SavegameCopy::SavegameCopy()
{
}
void SavegameCopy::copySavegame(QWidget *parent, QString sgdPath)
{
QSettings settings(GTA5SYNC_APPVENDOR, GTA5SYNC_APPSTR);
settings.beginGroup("FileDialogs");
bool dontUseNativeDialog = settings.value("DontUseNativeDialog", false).toBool();
settings.beginGroup("SavegameCopy");
fileDialogPreSave: //Work?
QFileInfo sgdFileInfo(sgdPath);
QFileDialog fileDialog(parent);
fileDialog.setFileMode(QFileDialog::AnyFile);
fileDialog.setViewMode(QFileDialog::Detail);
fileDialog.setAcceptMode(QFileDialog::AcceptSave);
fileDialog.setOption(QFileDialog::DontUseNativeDialog, dontUseNativeDialog);
fileDialog.setOption(QFileDialog::DontConfirmOverwrite, true);
fileDialog.setDefaultSuffix("");
fileDialog.setWindowFlags(fileDialog.windowFlags()^Qt::WindowContextHelpButtonHint);
fileDialog.setWindowTitle(SavegameWidget::tr(("Export Savegame...")));
fileDialog.setLabelText(QFileDialog::Accept, SavegameWidget::tr("Export"));
QStringList filters;
filters << SavegameWidget::tr("Savegame files (SGTA*)");
filters << SavegameWidget::tr("All files (**)");
fileDialog.setNameFilters(filters);
QList<QUrl> sidebarUrls = SidebarGenerator::generateSidebarUrls(fileDialog.sidebarUrls());
fileDialog.setSidebarUrls(sidebarUrls);
fileDialog.setDirectory(settings.value("Directory", StandardPaths::picturesLocation()).toString());
fileDialog.restoreGeometry(settings.value(parent->objectName() % "+Geometry", "").toByteArray());
fileDialog.selectFile(sgdFileInfo.fileName());
if (fileDialog.exec())
{
QStringList selectedFiles = fileDialog.selectedFiles();
if (selectedFiles.length() == 1)
{
QString selectedFile = selectedFiles.at(0);
if (QFile::exists(selectedFile))
{
if (QMessageBox::Yes == QMessageBox::warning(parent, SavegameWidget::tr("Export Savegame"), SavegameWidget::tr("Overwrite %1 with current Savegame?").arg("\""+selectedFile+"\""), QMessageBox::Yes | QMessageBox::No, QMessageBox::Yes))
{
if (!QFile::remove(selectedFile))
{
QMessageBox::warning(parent, SavegameWidget::tr("Export Savegame"), SavegameWidget::tr("Failed to overwrite %1 with current Savegame").arg("\""+selectedFile+"\""));
goto fileDialogPreSave; //Work?
}
}
else
{
goto fileDialogPreSave; //Work?
}
}
bool isCopied = QFile::copy(sgdPath, selectedFile);
if (!isCopied)
{
QMessageBox::warning(parent, SavegameWidget::tr("Export Savegame"), SavegameWidget::tr("Failed to export current Savegame"));
goto fileDialogPreSave; //Work?
}
}
else
{
QMessageBox::warning(parent, SavegameWidget::tr("Export Savegame"), SavegameWidget::tr("No valid file is selected"));
goto fileDialogPreSave; //Work?
}
}
settings.setValue(parent->objectName() % "+Geometry", fileDialog.saveGeometry());
settings.setValue("Directory", fileDialog.directory().absolutePath());
settings.endGroup();
settings.endGroup();
}
/*****************************************************************************
* 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 "SidebarGenerator.h"
#include "SavegameWidget.h"
#include "SavegameCopy.h"
#include "config.h"
#include <QMessageBox>
#include <QFileDialog>
#include <QSettings>
SavegameCopy::SavegameCopy()
{
}
void SavegameCopy::copySavegame(QWidget *parent, QString sgdPath)
{
QSettings settings(GTA5SYNC_APPVENDOR, GTA5SYNC_APPSTR);
settings.beginGroup("FileDialogs");
fileDialogPreSave:
QFileInfo sgdFileInfo(sgdPath);
QFileDialog fileDialog(parent);
fileDialog.setFileMode(QFileDialog::AnyFile);
fileDialog.setViewMode(QFileDialog::Detail);
fileDialog.setAcceptMode(QFileDialog::AcceptSave);
fileDialog.setOption(QFileDialog::DontUseNativeDialog, false);
fileDialog.setOption(QFileDialog::DontConfirmOverwrite, true);
fileDialog.setDefaultSuffix("");
fileDialog.setWindowFlags(fileDialog.windowFlags()^Qt::WindowContextHelpButtonHint);
fileDialog.setWindowTitle(SavegameWidget::tr(("Export Savegame...")));
fileDialog.setLabelText(QFileDialog::Accept, SavegameWidget::tr("Export"));
QStringList filters;
filters << SavegameWidget::tr("Savegame files (SGTA*)");
filters << SavegameWidget::tr("All files (**)");
fileDialog.setNameFilters(filters);
QList<QUrl> sidebarUrls = SidebarGenerator::generateSidebarUrls(fileDialog.sidebarUrls());
fileDialog.setSidebarUrls(sidebarUrls);
fileDialog.restoreState(settings.value("CopySavegame","").toByteArray());
fileDialog.selectFile(sgdFileInfo.fileName());
if (fileDialog.exec())
{
QStringList selectedFiles = fileDialog.selectedFiles();
if (selectedFiles.length() == 1)
{
QString selectedFile = selectedFiles.at(0);
if (QFile::exists(selectedFile))
{
if (QMessageBox::Yes == QMessageBox::warning(parent, SavegameWidget::tr("Export Savegame"), SavegameWidget::tr("Overwrite %1 with current Savegame?").arg("\""+selectedFile+"\""), QMessageBox::Yes | QMessageBox::No, QMessageBox::Yes))
{
if (!QFile::remove(selectedFile))
{
QMessageBox::warning(parent, SavegameWidget::tr("Export Savegame"), SavegameWidget::tr("Failed to overwrite %1 with current Savegame").arg("\""+selectedFile+"\""));
goto fileDialogPreSave;
}
}
else
{
goto fileDialogPreSave;
}
}
bool isCopied = QFile::copy(sgdPath, selectedFile);
if (!isCopied)
{
QMessageBox::warning(parent, SavegameWidget::tr("Export Savegame"), SavegameWidget::tr("Failed to export current Savegame"));
goto fileDialogPreSave;
}
}
else
{
QMessageBox::warning(parent, SavegameWidget::tr("Export Savegame"), SavegameWidget::tr("No valid file is selected"));
goto fileDialogPreSave;
}
}
settings.setValue("CopySavegame", fileDialog.saveState());
settings.endGroup();
}

64
SavegameCopy.h Normal file → Executable file
View File

@ -1,32 +1,32 @@
/*****************************************************************************
* gta5view Grand Theft Auto V Profile Viewer
* 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 SAVEGAMECOPY_H
#define SAVEGAMECOPY_H
#include <QWidget>
#include <QString>
class SavegameCopy
{
public:
SavegameCopy();
static void copySavegame(QWidget *parent, QString sgdPath);
};
#endif // SAVEGAMECOPY_H
/*****************************************************************************
* 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 SAVEGAMECOPY_H
#define SAVEGAMECOPY_H
#include <QWidget>
#include <QString>
class SavegameCopy
{
public:
SavegameCopy();
static void copySavegame(QWidget *parent, QString sgdPath);
};
#endif // SAVEGAMECOPY_H

239
SavegameData.cpp Normal file → Executable file
View File

@ -1,120 +1,119 @@
/*****************************************************************************
* gta5view Grand Theft Auto V Profile Viewer
* 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 "SnapmaticPicture.h"
#include "StringParser.h"
#include "SavegameData.h"
#include <QStringBuilder>
#include <QByteArray>
#include <QDebug>
#include <QFile>
#define savegameHeaderLength 260
#define verificationValue QByteArray::fromHex("00000001")
SavegameData::SavegameData(const QString &fileName, QObject *parent) : QObject(parent), savegameFileName(fileName)
{
// INIT SAVEGAME
savegameStr = "";
savegameOk = 0;
}
bool SavegameData::readingSavegame()
{
// Start opening file
// lastStep is like currentStep
QFile *saveFile = new QFile(savegameFileName);
if (!saveFile->open(QFile::ReadOnly))
{
lastStep = "1;/1,OpenFile," % SnapmaticPicture::convertDrawStringForLog(savegameFileName);
saveFile->deleteLater();
delete saveFile;
return false;
}
// Reading Savegame Header
if (!saveFile->isReadable())
{
lastStep = "2;/3,ReadingFile," % SnapmaticPicture::convertDrawStringForLog(savegameFileName) % ",1,NOHEADER";
saveFile->close();
saveFile->deleteLater();
delete saveFile;
return false;
}
QByteArray savegameHeaderLine = saveFile->read(savegameHeaderLength);
if (savegameHeaderLine.left(4) == verificationValue)
{
savegameStr = getSavegameDataString(savegameHeaderLine);
if (savegameStr.length() >= 1)
{
savegameOk = true;
}
}
saveFile->close();
saveFile->deleteLater();
delete saveFile;
return savegameOk;
}
QString SavegameData::getSavegameDataString(const QByteArray &savegameHeader)
{
QByteArray savegameBytes = savegameHeader.left(savegameHeaderLength);
QList<QByteArray> savegameBytesList = savegameBytes.split(char(0x01));
savegameBytes = savegameBytesList.at(1);
savegameBytesList.clear();
return SnapmaticPicture::parseTitleString(savegameBytes, savegameBytes.length());
}
bool SavegameData::readingSavegameFromFile(const QString &fileName)
{
if (fileName != "")
{
savegameFileName = fileName;
return readingSavegame();
}
else
{
return false;
}
}
bool SavegameData::isSavegameOk()
{
return savegameOk;
}
QString SavegameData::getSavegameFileName()
{
return savegameFileName;
}
QString SavegameData::getSavegameStr()
{
return savegameStr;
}
QString SavegameData::getLastStep()
{
return lastStep;
}
void SavegameData::setSavegameFileName(QString savegameFileName_)
{
savegameFileName = savegameFileName_;
}
/*****************************************************************************
* 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 "StringParser.h"
#include "SavegameData.h"
#include <QTextCodec>
#include <QDebug>
#include <QFile>
SavegameData::SavegameData(const QString &fileName, QObject *parent) : QObject(parent), savegameFileName(fileName)
{
// PARSE INT INIT - DO NOT CHANGE THIS VALUES
savegameHeaderLength = 260;
verificationValue = QByteArray::fromHex("00000001");
// INIT SAVEGAME
savegameStr = "";
savegameOk = 0;
}
bool SavegameData::readingSavegame()
{
// Start opening file
// lastStep is like currentStep
QFile *saveFile = new QFile(savegameFileName);
if (!saveFile->open(QFile::ReadOnly))
{
lastStep = "1;/1,OpenFile," + StringParser::convertDrawStringForLog(savegameFileName);
saveFile->deleteLater();
delete saveFile;
return false;
}
// Reading Savegame Header
if (!saveFile->isReadable())
{
lastStep = "2;/3,ReadingFile," + StringParser::convertDrawStringForLog(savegameFileName) + ",1,NOHEADER";
saveFile->close();
saveFile->deleteLater();
delete saveFile;
return false;
}
QByteArray savegameHeaderLine = saveFile->read(savegameHeaderLength);
if (savegameHeaderLine.left(4) == verificationValue)
{
savegameStr = getSavegameDataString(savegameHeaderLine);
if (savegameStr.length() >= 1)
{
savegameOk = true;
}
}
saveFile->close();
saveFile->deleteLater();
delete saveFile;
return savegameOk;
}
QString SavegameData::getSavegameDataString(const QByteArray &savegameHeader)
{
QByteArray savegameBytes = savegameHeader.left(savegameHeaderLength);
QList<QByteArray> savegameBytesList = savegameBytes.split(char(0x01));
savegameBytes = savegameBytesList.at(1);
savegameBytesList.clear();
return StringParser::parseTitleString(savegameBytes, savegameBytes.length());
}
bool SavegameData::readingSavegameFromFile(const QString &fileName)
{
if (fileName != "")
{
savegameFileName = fileName;
return readingSavegame();
}
else
{
return false;
}
}
bool SavegameData::isSavegameOk()
{
return savegameOk;
}
QString SavegameData::getSavegameFileName()
{
return savegameFileName;
}
QString SavegameData::getSavegameStr()
{
return savegameStr;
}
QString SavegameData::getLastStep()
{
return lastStep;
}
void SavegameData::setSavegameFileName(QString savegameFileName_)
{
savegameFileName = savegameFileName_;
}

94
SavegameData.h Normal file → Executable file
View File

@ -1,45 +1,49 @@
/*****************************************************************************
* gta5view Grand Theft Auto V Profile Viewer
* 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 SAVEGAMEDATA_H
#define SAVEGAMEDATA_H
#include <QObject>
class SavegameData : public QObject
{
Q_OBJECT
public:
explicit SavegameData(const QString &fileName = "", QObject *parent = 0);
bool readingSavegameFromFile(const QString &fileName);
bool readingSavegame();
bool isSavegameOk();
QString getLastStep();
QString getSavegameStr();
QString getSavegameFileName();
void setSavegameFileName(QString savegameFileName);
private:
QString getSavegameDataString(const QByteArray &savegameHeader);
QString savegameFileName;
QString savegameStr;
QString lastStep;
bool savegameOk;
};
#endif // SAVEGAMEDATA_H
/*****************************************************************************
* 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 SAVEGAMEDATA_H
#define SAVEGAMEDATA_H
#include <QObject>
class SavegameData : public QObject
{
Q_OBJECT
public:
explicit SavegameData(const QString &fileName = "", QObject *parent = 0);
bool readingSavegameFromFile(const QString &fileName);
bool readingSavegame();
bool isSavegameOk();
QString getLastStep();
QString getSavegameStr();
QString getSavegameFileName();
void setSavegameFileName(QString savegameFileName);
private:
QString getSavegameDataString(const QByteArray &savegameHeader);
QString savegameFileName;
QString savegameStr;
QString lastStep;
bool savegameOk;
// PARSE INT
QByteArray verificationValue;
int savegameHeaderLength;
};
#endif // SAVEGAMEDATA_H

144
SavegameDialog.cpp Normal file → Executable file
View File

@ -1,100 +1,44 @@
/*****************************************************************************
* gta5view Grand Theft Auto V Profile Viewer
* Copyright (C) 2016-2018 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 "SavegameDialog.h"
#include "ui_SavegameDialog.h"
#include "SavegameCopy.h"
#include "AppEnv.h"
#include <QMessageBox>
#include <QDebug>
SavegameDialog::SavegameDialog(QWidget *parent) :
QDialog(parent),
ui(new Ui::SavegameDialog)
{
// Set Window Flags
setWindowFlags(windowFlags()^Qt::WindowContextHelpButtonHint);
// Setup User Interface
ui->setupUi(this);
ui->cmdClose->setFocus();
savegameLabStr = ui->labSavegameText->text();
// Set Icon for Close Button
if (QIcon::hasThemeIcon("dialog-close"))
{
ui->cmdClose->setIcon(QIcon::fromTheme("dialog-close"));
}
else if (QIcon::hasThemeIcon("gtk-close"))
{
ui->cmdClose->setIcon(QIcon::fromTheme("gtk-close"));
}
// Set Icon for Export Button
if (QIcon::hasThemeIcon("document-export"))
{
ui->cmdCopy->setIcon(QIcon::fromTheme("document-export"));
}
else if (QIcon::hasThemeIcon("document-save"))
{
ui->cmdCopy->setIcon(QIcon::fromTheme("document-save"));
}
refreshWindowSize();
}
SavegameDialog::~SavegameDialog()
{
delete ui;
}
void SavegameDialog::refreshWindowSize()
{
// DPI calculation
qreal screenRatio = AppEnv::screenRatio();
int dpiWindowWidth = 400 * screenRatio;
int dpiWindowHeight = 105 * screenRatio;
if (dpiWindowHeight < heightForWidth(dpiWindowWidth))
{
dpiWindowHeight = heightForWidth(dpiWindowWidth);
}
resize(dpiWindowWidth, dpiWindowHeight);
}
void SavegameDialog::setSavegameData(SavegameData *savegame, QString savegamePath, bool readOk)
{
// Showing error if reading error
if (!readOk)
{
QMessageBox::warning(this,tr("Savegame Viewer"),tr("Failed at %1").arg(savegame->getLastStep()));
return;
}
sgdPath = savegamePath;
ui->labSavegameText->setText(savegameLabStr.arg(savegame->getSavegameStr()));
refreshWindowSize();
}
void SavegameDialog::on_cmdClose_clicked()
{
this->close();
}
void SavegameDialog::on_cmdCopy_clicked()
{
SavegameCopy::copySavegame(this, sgdPath);
}
#include "SavegameDialog.h"
#include "ui_SavegameDialog.h"
#include "SavegameCopy.h"
#include <QMessageBox>
SavegameDialog::SavegameDialog(QWidget *parent) :
QDialog(parent),
ui(new Ui::SavegameDialog)
{
ui->setupUi(this);
savegameLabStr = ui->labSavegameText->text();
if (QIcon::hasThemeIcon("dialog-close"))
{
ui->cmdClose->setIcon(QIcon::fromTheme("dialog-close"));
}
}
SavegameDialog::~SavegameDialog()
{
delete ui;
}
void SavegameDialog::setSavegameData(SavegameData *savegame, QString savegamePath, bool readOk)
{
// Showing error if reading error
if (!readOk)
{
QMessageBox::warning(this,tr("Savegame Viewer"),tr("Failed at %1").arg(savegame->getLastStep()));
return;
}
sgdPath = savegamePath;
ui->labSavegameText->setText(savegameLabStr.arg(savegame->getSavegameStr()));
}
void SavegameDialog::on_cmdClose_clicked()
{
this->close();
}
void SavegameDialog::on_cmdCopy_clicked()
{
SavegameCopy::copySavegame(this, sgdPath);
}

77
SavegameDialog.h Normal file → Executable file
View File

@ -1,48 +1,29 @@
/*****************************************************************************
* gta5view Grand Theft Auto V Profile Viewer
* Copyright (C) 2016-2018 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 SAVEGAMEDIALOG_H
#define SAVEGAMEDIALOG_H
#include "SavegameData.h"
#include <QDialog>
namespace Ui {
class SavegameDialog;
}
class SavegameDialog : public QDialog
{
Q_OBJECT
public:
explicit SavegameDialog(QWidget *parent = 0);
void setSavegameData(SavegameData *savegame, QString sgdPath, bool readOk);
~SavegameDialog();
private slots:
void on_cmdClose_clicked();
void on_cmdCopy_clicked();
void refreshWindowSize();
private:
Ui::SavegameDialog *ui;
QString savegameLabStr;
QString sgdPath;
};
#endif // SAVEGAMEDIALOG_H
#ifndef SAVEGAMEDIALOG_H
#define SAVEGAMEDIALOG_H
#include "SavegameData.h"
#include <QDialog>
namespace Ui {
class SavegameDialog;
}
class SavegameDialog : public QDialog
{
Q_OBJECT
public:
explicit SavegameDialog(QWidget *parent = 0);
void setSavegameData(SavegameData *savegame, QString sgdPath, bool readOk);
~SavegameDialog();
private slots:
void on_cmdClose_clicked();
void on_cmdCopy_clicked();
private:
Ui::SavegameDialog *ui;
QString savegameLabStr;
QString sgdPath;
};
#endif // SAVEGAMEDIALOG_H

179
SavegameDialog.ui Normal file → Executable file
View File

@ -1,93 +1,86 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>SavegameDialog</class>
<widget class="QDialog" name="SavegameDialog">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>400</width>
<height>105</height>
</rect>
</property>
<property name="windowTitle">
<string>Savegame Viewer</string>
</property>
<property name="modal">
<bool>true</bool>
</property>
<layout class="QVBoxLayout" name="vlSavegameDialog">
<item>
<widget class="QLabel" name="labSavegameText">
<property name="text">
<string>&lt;span style=&quot; font-weight:600;&quot;&gt;Savegame&lt;/span&gt;&lt;br&gt;&lt;br&gt;%1</string>
</property>
<property name="alignment">
<set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop</set>
</property>
<property name="wordWrap">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<spacer name="vsSavegame">
<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>
<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="cmdCopy">
<property name="sizePolicy">
<sizepolicy hsizetype="Minimum" vsizetype="Minimum">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>&amp;Export</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="cmdClose">
<property name="sizePolicy">
<sizepolicy hsizetype="Minimum" vsizetype="Minimum">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>&amp;Close</string>
</property>
</widget>
</item>
</layout>
</item>
</layout>
</widget>
<resources/>
<connections/>
</ui>
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>SavegameDialog</class>
<widget class="QDialog" name="SavegameDialog">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>400</width>
<height>104</height>
</rect>
</property>
<property name="windowTitle">
<string>Savegame Viewer</string>
</property>
<property name="modal">
<bool>true</bool>
</property>
<layout class="QVBoxLayout" name="vlSavegameDialog">
<item>
<widget class="QLabel" name="labSavegameText">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Expanding">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>&lt;span style=&quot; font-weight:600;&quot;&gt;Savegame&lt;/span&gt;&lt;br&gt;&lt;br&gt;%1</string>
</property>
<property name="alignment">
<set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop</set>
</property>
<property name="wordWrap">
<bool>true</bool>
</property>
</widget>
</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="cmdCopy">
<property name="sizePolicy">
<sizepolicy hsizetype="Minimum" vsizetype="Minimum">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>&amp;Export</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="cmdClose">
<property name="sizePolicy">
<sizepolicy hsizetype="Minimum" vsizetype="Minimum">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>&amp;Close</string>
</property>
</widget>
</item>
</layout>
</item>
</layout>
</widget>
<resources/>
<connections/>
</ui>

553
SavegameWidget.cpp Normal file → Executable file
View File

@ -1,303 +1,250 @@
/*****************************************************************************
* gta5view Grand Theft Auto V Profile Viewer
* Copyright (C) 2016-2018 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 "SavegameWidget.h"
#include "ui_SavegameWidget.h"
#include "SidebarGenerator.h"
#include "SavegameDialog.h"
#include "StandardPaths.h"
#include "SavegameData.h"
#include "SavegameCopy.h"
#include "AppEnv.h"
#include "config.h"
#include <QFileDialog>
#include <QMessageBox>
#include <QSettings>
#include <QFileInfo>
#include <QPalette>
#include <QColor>
#include <QBrush>
#include <QTimer>
#include <QDebug>
#include <QFile>
#include <QMenu>
#include <QUrl>
#ifdef GTA5SYNC_TELEMETRY
#include "TelemetryClass.h"
#include <QJsonDocument>
#include <QJsonObject>
#include <QDateTime>
#endif
SavegameWidget::SavegameWidget(QWidget *parent) :
ProfileWidget(parent),
ui(new Ui::SavegameWidget)
{
ui->setupUi(this);
ui->cmdCopy->setVisible(false);
ui->cmdView->setVisible(false);
ui->cmdDelete->setVisible(false);
ui->cbSelected->setVisible(false);
qreal screenRatio = AppEnv::screenRatio();
ui->labSavegamePic->setFixedSize(48 * screenRatio, 27 * screenRatio);
ui->labSavegamePic->setScaledContents(true);
ui->labSavegamePic->setPixmap(QPixmap(":/img/savegame.svgz"));
QString exportSavegameStr = tr("Export Savegame...");
Q_UNUSED(exportSavegameStr)
labelAutosaveStr = tr("AUTOSAVE - %1\n%2");
labelSaveStr = tr("SAVE %3 - %1\n%2");
ui->SavegameFrame->setMouseTracking(true);
ui->labSavegamePic->setMouseTracking(true);
ui->labSavegameStr->setMouseTracking(true);
ui->cbSelected->setMouseTracking(true);
sgdata = nullptr;
}
SavegameWidget::~SavegameWidget()
{
delete ui;
}
void SavegameWidget::setSavegameData(SavegameData *savegame, QString savegamePath)
{
// BETA CODE
QString savegameString = savegame->getSavegameStr();
QString fileName = QFileInfo(savegame->getSavegameFileName()).fileName();
renderString(savegameString, fileName);
sgdStr = savegameString;
sgdPath = savegamePath;
sgdata = savegame;
}
void SavegameWidget::renderString(const QString &savegameString, const QString &fileName)
{
bool validNumber;
QString savegameName = tr("WRONG FORMAT");
QString savegameDate = tr("WRONG FORMAT");
QStringList savegameNDL = QString(savegameString).split(" - ");
if (savegameNDL.length() >= 2)
{
savegameDate = savegameNDL.at(savegameNDL.length() - 1);
savegameName = QString(savegameString).remove(savegameString.length() - savegameDate.length() - 3, savegameDate.length() + 3);
}
int savegameNumber = QString(fileName).remove(0,5).toInt(&validNumber) + 1;
if (validNumber)
{
if (savegameNumber == 16)
{
ui->labSavegameStr->setText(labelAutosaveStr.arg(savegameDate, savegameName));
}
else
{
ui->labSavegameStr->setText(labelSaveStr.arg(savegameDate, savegameName, QString::number(savegameNumber)));
}
}
else
{
ui->labSavegameStr->setText(labelSaveStr.arg(savegameDate, savegameName, tr("UNKNOWN")));
}
}
void SavegameWidget::retranslate()
{
labelAutosaveStr = tr("AUTOSAVE - %1\n%2");
labelSaveStr = tr("SAVE %3 - %1\n%2");
QString fileName = QFileInfo(sgdata->getSavegameFileName()).fileName();
renderString(sgdStr, fileName);
}
void SavegameWidget::on_cmdCopy_clicked()
{
SavegameCopy::copySavegame(this, sgdPath);
}
void SavegameWidget::on_cmdDelete_clicked()
{
int uchoice = QMessageBox::question(this, tr("Delete Savegame"), tr("Are you sure to delete %1 from your savegames?").arg("\""+sgdStr+"\""), QMessageBox::No | QMessageBox::Yes, QMessageBox::No);
if (uchoice == QMessageBox::Yes)
{
if (!QFile::exists(sgdPath))
{
emit savegameDeleted();
#ifdef GTA5SYNC_TELEMETRY
QSettings telemetrySettings(GTA5SYNC_APPVENDOR, GTA5SYNC_APPSTR);
telemetrySettings.beginGroup("Telemetry");
bool pushUsageData = telemetrySettings.value("PushUsageData", false).toBool();
telemetrySettings.endGroup();
if (pushUsageData && Telemetry->canPush())
{
QJsonDocument jsonDocument;
QJsonObject jsonObject;
jsonObject["Type"] = "DeleteSuccess";
jsonObject["ExtraFlags"] = "Savegame";
jsonObject["DeletedTime"] = QString::number(QDateTime::currentDateTimeUtc().toTime_t());
jsonDocument.setObject(jsonObject);
Telemetry->push(TelemetryCategory::PersonalData, jsonDocument);
}
#endif
}
else if (QFile::remove(sgdPath))
{
#ifdef GTA5SYNC_TELEMETRY
QSettings telemetrySettings(GTA5SYNC_APPVENDOR, GTA5SYNC_APPSTR);
telemetrySettings.beginGroup("Telemetry");
bool pushUsageData = telemetrySettings.value("PushUsageData", false).toBool();
telemetrySettings.endGroup();
if (pushUsageData && Telemetry->canPush())
{
QJsonDocument jsonDocument;
QJsonObject jsonObject;
jsonObject["Type"] = "DeleteSuccess";
jsonObject["ExtraFlags"] = "Savegame";
jsonObject["DeletedTime"] = QString::number(QDateTime::currentDateTimeUtc().toTime_t());
jsonDocument.setObject(jsonObject);
Telemetry->push(TelemetryCategory::PersonalData, jsonDocument);
}
#endif
emit savegameDeleted();
}
else
{
QMessageBox::warning(this, tr("Delete Savegame"), tr("Failed at deleting %1 from your savegames").arg("\""+sgdStr+"\""));
}
}
}
void SavegameWidget::on_cmdView_clicked()
{
SavegameDialog *savegameDialog = new SavegameDialog(this);
savegameDialog->setSavegameData(sgdata, sgdPath, true);
savegameDialog->setModal(true);
#ifdef Q_OS_ANDROID
// Android ...
savegameDialog->showMaximized();
#else
savegameDialog->show();
#endif
savegameDialog->exec();
delete savegameDialog;
}
void SavegameWidget::mousePressEvent(QMouseEvent *ev)
{
ProfileWidget::mousePressEvent(ev);
}
void SavegameWidget::mouseReleaseEvent(QMouseEvent *ev)
{
ProfileWidget::mouseReleaseEvent(ev);
if (ui->cbSelected->isVisible())
{
if (rect().contains(ev->pos()) && ev->button() == Qt::LeftButton)
{
ui->cbSelected->setChecked(!ui->cbSelected->isChecked());
}
}
else
{
if (getContentMode() == 0 && rect().contains(ev->pos()) && ev->button() == Qt::LeftButton)
{
if (ev->modifiers().testFlag(Qt::ShiftModifier))
{
ui->cbSelected->setChecked(!ui->cbSelected->isChecked());
}
else
{
on_cmdView_clicked();
}
}
else if (!ui->cbSelected->isVisible() && getContentMode() == 1 && ev->button() == Qt::LeftButton && ev->modifiers().testFlag(Qt::ShiftModifier))
{
ui->cbSelected->setChecked(!ui->cbSelected->isChecked());
}
}
}
void SavegameWidget::mouseDoubleClickEvent(QMouseEvent *ev)
{
ProfileWidget::mouseDoubleClickEvent(ev);
if (!ui->cbSelected->isVisible() && getContentMode() == 1 && ev->button() == Qt::LeftButton)
{
on_cmdView_clicked();
}
}
void SavegameWidget::setSelected(bool isSelected)
{
ui->cbSelected->setChecked(isSelected);
}
void SavegameWidget::savegameSelected()
{
setSelected(!ui->cbSelected->isChecked());
}
void SavegameWidget::contextMenuEvent(QContextMenuEvent *ev)
{
emit contextMenuTriggered(ev);
}
void SavegameWidget::on_cbSelected_stateChanged(int arg1)
{
if (arg1 == Qt::Checked)
{
emit widgetSelected();
}
else if (arg1 == Qt::Unchecked)
{
emit widgetDeselected();
}
}
bool SavegameWidget::isSelected()
{
return ui->cbSelected->isChecked();
}
void SavegameWidget::setSelectionMode(bool selectionMode)
{
ui->cbSelected->setVisible(selectionMode);
}
void SavegameWidget::selectAllWidgets()
{
emit allWidgetsSelected();
}
void SavegameWidget::deselectAllWidgets()
{
emit allWidgetsDeselected();
}
SavegameData* SavegameWidget::getSavegame()
{
return sgdata;
}
QString SavegameWidget::getWidgetType()
{
return "SavegameWidget";
}
/*****************************************************************************
* 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 "SavegameWidget.h"
#include "ui_SavegameWidget.h"
#include "SidebarGenerator.h"
#include "SavegameDialog.h"
#include "StandardPaths.h"
#include "SavegameData.h"
#include "SavegameCopy.h"
#include <QFileDialog>
#include <QMessageBox>
#include <QSettings>
#include <QFileInfo>
#include <QPalette>
#include <QColor>
#include <QBrush>
#include <QTimer>
#include <QDebug>
#include <QFile>
#include <QMenu>
#include <QUrl>
SavegameWidget::SavegameWidget(QWidget *parent) :
ProfileWidget(parent),
ui(new Ui::SavegameWidget)
{
ui->setupUi(this);
ui->cmdCopy->setVisible(false);
ui->cmdView->setVisible(false);
ui->cmdDelete->setVisible(false);
ui->cbSelected->setVisible(false);
QString exportSavegameStr = tr("Export Savegame...");
Q_UNUSED(exportSavegameStr)
QPalette palette;
highlightBackColor = palette.highlight().color();
highlightTextColor = palette.highlightedText().color();
labelAutosaveStr = tr("AUTOSAVE - %1\n%2");
labelSaveStr = tr("SAVE %3 - %1\n%2");
snwgt = parent;
sgdPath = "";
sgdStr = "";
sgdata = 0;
installEventFilter(this);
}
SavegameWidget::~SavegameWidget()
{
delete ui;
}
bool SavegameWidget::eventFilter(QObject *obj, QEvent *ev)
{
if (obj == this)
{
if (ev->type() == QEvent::Enter)
{
setStyleSheet(QString("QFrame#SavegameFrame{background-color: rgb(%1, %2, %3)}QLabel#labSavegameStr{color: rgb(%4, %5, %6)}").arg(QString::number(highlightBackColor.red()), QString::number(highlightBackColor.green()), QString::number(highlightBackColor.blue()), QString::number(highlightTextColor.red()), QString::number(highlightTextColor.green()), QString::number(highlightTextColor.blue())));
return true;
}
else if(ev->type() == QEvent::Leave)
{
setStyleSheet("");
return true;
}
}
return false;
}
void SavegameWidget::setSavegameData(SavegameData *savegame, QString savegamePath)
{
// BETA CODE
bool validNumber;
QString savegameName = tr("WRONG FORMAT");
QString savegameDate = tr("WRONG FORMAT");
QString savegameString = savegame->getSavegameStr();
QString fileName = QFileInfo(savegame->getSavegameFileName()).fileName();
QStringList savegameNDL = QString(savegameString).split(" - ");
if (savegameNDL.length() >= 2)
{
savegameDate = savegameNDL.at(savegameNDL.length() - 1);
savegameName = QString(savegameString).remove(savegameString.length() - savegameDate.length() - 3, savegameDate.length() + 3);
}
int savegameNumber = QString(fileName).remove(0,5).toInt(&validNumber) + 1;
if (validNumber)
{
if (savegameNumber == 16)
{
ui->labSavegameStr->setText(labelAutosaveStr.arg(savegameDate, savegameName));
}
else
{
ui->labSavegameStr->setText(labelSaveStr.arg(savegameDate, savegameName, QString::number(savegameNumber)));
}
}
else
{
ui->labSavegameStr->setText(labelSaveStr.arg(savegameDate, savegameName, tr("UNKNOWN")));
}
sgdStr = savegameString;
sgdPath = savegamePath;
sgdata = savegame;
}
void SavegameWidget::on_cmdCopy_clicked()
{
SavegameCopy::copySavegame(this, sgdPath);
}
void SavegameWidget::on_cmdDelete_clicked()
{
int uchoice = QMessageBox::question(this, tr("Delete savegame"), tr("Are you sure to delete %1 from your savegames?").arg("\""+sgdStr+"\""), QMessageBox::No | QMessageBox::Yes, QMessageBox::No);
if (uchoice == QMessageBox::Yes)
{
if (!QFile::exists(sgdPath))
{
emit savegameDeleted();
}
else if(QFile::remove(sgdPath))
{
emit savegameDeleted();
}
else
{
QMessageBox::warning(this, tr("Delete savegame"), tr("Failed at deleting %1 from your savegames").arg("\""+sgdStr+"\""));
}
}
}
void SavegameWidget::on_cmdView_clicked()
{
SavegameDialog *savegameDialog = new SavegameDialog(this);
savegameDialog->setWindowFlags(savegameDialog->windowFlags()^Qt::WindowContextHelpButtonHint);
savegameDialog->setSavegameData(sgdata, sgdPath, true);
savegameDialog->setModal(true);
savegameDialog->show();
savegameDialog->exec();
savegameDialog->deleteLater();
delete savegameDialog;
}
void SavegameWidget::mousePressEvent(QMouseEvent *ev)
{
ProfileWidget::mousePressEvent(ev);
}
void SavegameWidget::mouseReleaseEvent(QMouseEvent *ev)
{
ProfileWidget::mouseReleaseEvent(ev);
if (ui->cbSelected->isVisible())
{
if (rect().contains(ev->pos()) && ev->button() == Qt::LeftButton)
{
ui->cbSelected->setChecked(!ui->cbSelected->isChecked());
}
}
else
{
if (getContentMode() == 0 && rect().contains(ev->pos()) && ev->button() == Qt::LeftButton)
{
on_cmdView_clicked();
}
}
}
void SavegameWidget::mouseDoubleClickEvent(QMouseEvent *ev)
{
ProfileWidget::mouseDoubleClickEvent(ev);
if (!ui->cbSelected->isVisible() && getContentMode() == 1 && ev->button() == Qt::LeftButton)
{
on_cmdView_clicked();
}
}
void SavegameWidget::setSelected(bool isSelected)
{
ui->cbSelected->setChecked(isSelected);
}
void SavegameWidget::savegameSelected()
{
setSelected(!ui->cbSelected->isChecked());
}
void SavegameWidget::contextMenuEvent(QContextMenuEvent *ev)
{
emit contextMenuTriggered(ev);
}
void SavegameWidget::on_cbSelected_stateChanged(int arg1)
{
if (arg1 == Qt::Checked)
{
emit widgetSelected();
}
else if (arg1 == Qt::Unchecked)
{
emit widgetDeselected();
}
}
bool SavegameWidget::isSelected()
{
return ui->cbSelected->isChecked();
}
void SavegameWidget::setSelectionMode(bool selectionMode)
{
ui->cbSelected->setVisible(selectionMode);
}
void SavegameWidget::selectAllWidgets()
{
emit allWidgetsSelected();
}
void SavegameWidget::deselectAllWidgets()
{
emit allWidgetsDeselected();
}
SavegameData* SavegameWidget::getSavegame()
{
return sgdata;
}
QString SavegameWidget::getWidgetType()
{
return "SavegameWidget";
}

162
SavegameWidget.h Normal file → Executable file
View File

@ -1,80 +1,82 @@
/*****************************************************************************
* gta5view Grand Theft Auto V Profile Viewer
* 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 SAVEGAMEWIDGET_H
#define SAVEGAMEWIDGET_H
#include "ProfileWidget.h"
#include "SavegameData.h"
#include <QContextMenuEvent>
#include <QMouseEvent>
#include <QWidget>
#include <QColor>
namespace Ui {
class SavegameWidget;
}
class SavegameWidget : public ProfileWidget
{
Q_OBJECT
public:
SavegameWidget(QWidget *parent = 0);
void setSavegameData(SavegameData *savegame, QString savegamePath);
void setSelectionMode(bool selectionMode);
void setSelected(bool isSelected);
SavegameData* getSavegame();
QString getWidgetType();
bool isSelected();
void retranslate();
~SavegameWidget();
private slots:
void on_cmdView_clicked();
void on_cmdCopy_clicked();
void on_cmdDelete_clicked();
void on_cbSelected_stateChanged(int arg1);
void savegameSelected();
void selectAllWidgets();
void deselectAllWidgets();
protected:
void mouseDoubleClickEvent(QMouseEvent *ev);
void mouseReleaseEvent(QMouseEvent *ev);
void mousePressEvent(QMouseEvent *ev);
void contextMenuEvent(QContextMenuEvent *ev);
private:
Ui::SavegameWidget *ui;
SavegameData *sgdata;
QString labelAutosaveStr;
QString labelSaveStr;
QString sgdPath;
QString sgdStr;
void renderString(const QString &savegameString, const QString &fileName);
signals:
void savegameDeleted();
void widgetSelected();
void widgetDeselected();
void allWidgetsSelected();
void allWidgetsDeselected();
void contextMenuTriggered(QContextMenuEvent *ev);
};
#endif // SAVEGAMEWIDGET_H
/*****************************************************************************
* 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 SAVEGAMEWIDGET_H
#define SAVEGAMEWIDGET_H
#include "ProfileWidget.h"
#include "SavegameData.h"
#include <QContextMenuEvent>
#include <QMouseEvent>
#include <QWidget>
#include <QColor>
namespace Ui {
class SavegameWidget;
}
class SavegameWidget : public ProfileWidget
{
Q_OBJECT
public:
SavegameWidget(QWidget *parent = 0);
void setSavegameData(SavegameData *savegame, QString savegamePath);
void setSelectionMode(bool selectionMode);
void setSelected(bool isSelected);
SavegameData* getSavegame();
QString getWidgetType();
bool isSelected();
~SavegameWidget();
private slots:
void on_cmdView_clicked();
void on_cmdCopy_clicked();
void on_cmdDelete_clicked();
void on_cbSelected_stateChanged(int arg1);
void savegameSelected();
void selectAllWidgets();
void deselectAllWidgets();
protected:
bool eventFilter(QObject *obj, QEvent *ev);
void mouseDoubleClickEvent(QMouseEvent *ev);
void mouseReleaseEvent(QMouseEvent *ev);
void mousePressEvent(QMouseEvent *ev);
void contextMenuEvent(QContextMenuEvent *ev);
private:
Ui::SavegameWidget *ui;
SavegameData *sgdata;
QColor highlightBackColor;
QColor highlightTextColor;
QString labelAutosaveStr;
QString labelSaveStr;
QString sgdPath;
QString sgdStr;
QWidget *snwgt;
signals:
void savegameDeleted();
void widgetSelected();
void widgetDeselected();
void allWidgetsSelected();
void allWidgetsDeselected();
void contextMenuTriggered(QContextMenuEvent *ev);
};
#endif // SAVEGAMEWIDGET_H

272
SavegameWidget.ui Normal file → Executable file
View File

@ -1,135 +1,137 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>SavegameWidget</class>
<widget class="QWidget" name="SavegameWidget">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>405</width>
<height>46</height>
</rect>
</property>
<property name="windowTitle">
<string>Savegame Widget</string>
</property>
<layout class="QHBoxLayout" name="hlSavegameContent">
<property name="leftMargin">
<number>0</number>
</property>
<property name="topMargin">
<number>0</number>
</property>
<property name="rightMargin">
<number>0</number>
</property>
<property name="bottomMargin">
<number>0</number>
</property>
<item>
<widget class="QFrame" name="SavegameFrame">
<property name="frameShape">
<enum>QFrame::NoFrame</enum>
</property>
<property name="frameShadow">
<enum>QFrame::Plain</enum>
</property>
<property name="lineWidth">
<number>0</number>
</property>
<layout class="QHBoxLayout" name="hlSavegame">
<item>
<widget class="QCheckBox" name="cbSelected">
<property name="focusPolicy">
<enum>Qt::NoFocus</enum>
</property>
<property name="text">
<string/>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="labSavegamePic">
<property name="text">
<string/>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="labSavegameStr">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>SAVE %3 - %1&lt;br&gt;%2</string>
</property>
<property name="wordWrap">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="cmdView">
<property name="sizePolicy">
<sizepolicy hsizetype="Minimum" vsizetype="Minimum">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="toolTip">
<string>View savegame</string>
</property>
<property name="text">
<string>View</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="cmdCopy">
<property name="sizePolicy">
<sizepolicy hsizetype="Minimum" vsizetype="Minimum">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="toolTip">
<string>Copy savegame</string>
</property>
<property name="text">
<string>Export</string>
</property>
<property name="autoDefault">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="cmdDelete">
<property name="sizePolicy">
<sizepolicy hsizetype="Minimum" vsizetype="Minimum">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="toolTip">
<string>Delete savegame</string>
</property>
<property name="text">
<string>Delete</string>
</property>
<property name="autoDefault">
<bool>true</bool>
</property>
</widget>
</item>
</layout>
</widget>
</item>
</layout>
</widget>
<resources/>
<connections/>
</ui>
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>SavegameWidget</class>
<widget class="QWidget" name="SavegameWidget">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>405</width>
<height>46</height>
</rect>
</property>
<property name="windowTitle">
<string>Savegame Widget</string>
</property>
<layout class="QHBoxLayout" name="hlSavegameContent">
<property name="leftMargin">
<number>0</number>
</property>
<property name="topMargin">
<number>0</number>
</property>
<property name="rightMargin">
<number>0</number>
</property>
<property name="bottomMargin">
<number>0</number>
</property>
<item>
<widget class="QFrame" name="SavegameFrame">
<property name="frameShape">
<enum>QFrame::NoFrame</enum>
</property>
<property name="frameShadow">
<enum>QFrame::Plain</enum>
</property>
<property name="lineWidth">
<number>0</number>
</property>
<layout class="QHBoxLayout" name="hlSavegame">
<item>
<widget class="QCheckBox" name="cbSelected">
<property name="text">
<string/>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="labSavegamePic">
<property name="text">
<string/>
</property>
<property name="pixmap">
<pixmap resource="res/app.qrc">:/img/savegame.png</pixmap>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="labSavegameStr">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>SAVE %3 - %1&lt;br&gt;%2</string>
</property>
<property name="wordWrap">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="cmdView">
<property name="sizePolicy">
<sizepolicy hsizetype="Minimum" vsizetype="Minimum">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="toolTip">
<string>View savegame</string>
</property>
<property name="text">
<string>View</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="cmdCopy">
<property name="sizePolicy">
<sizepolicy hsizetype="Minimum" vsizetype="Minimum">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="toolTip">
<string>Copy savegame</string>
</property>
<property name="text">
<string>Export</string>
</property>
<property name="autoDefault">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="cmdDelete">
<property name="sizePolicy">
<sizepolicy hsizetype="Minimum" vsizetype="Minimum">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="toolTip">
<string>Delete savegame</string>
</property>
<property name="text">
<string>Delete</string>
</property>
<property name="autoDefault">
<bool>true</bool>
</property>
</widget>
</item>
</layout>
</widget>
</item>
</layout>
</widget>
<resources>
<include location="res/app.qrc"/>
</resources>
<connections/>
</ui>

122
SidebarGenerator.cpp Normal file → Executable file
View File

@ -1,61 +1,61 @@
/*****************************************************************************
* gta5view Grand Theft Auto V Profile Viewer
* 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 "SidebarGenerator.h"
#include "StandardPaths.h"
#include "AppEnv.h"
#include <QList>
#include <QUrl>
#include <QDir>
SidebarGenerator::SidebarGenerator()
{
}
QList<QUrl> SidebarGenerator::generateSidebarUrls(QList<QUrl> sidebarUrls)
{
QDir dir;
dir.setPath(StandardPaths::picturesLocation());
if (dir.exists())
{
sidebarUrls += QUrl::fromLocalFile(dir.absolutePath());
}
dir.setPath(StandardPaths::documentsLocation());
if (dir.exists())
{
sidebarUrls += QUrl::fromLocalFile(dir.absolutePath());
}
bool gameFolderExists;
QString gameFolder = AppEnv::getGameFolder(&gameFolderExists);
if (gameFolderExists)
{
sidebarUrls += QUrl::fromLocalFile(gameFolder);
}
dir.setPath(StandardPaths::desktopLocation());
if (dir.exists())
{
sidebarUrls += QUrl::fromLocalFile(dir.absolutePath());
}
return sidebarUrls;
}
/*****************************************************************************
* 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 "SidebarGenerator.h"
#include "StandardPaths.h"
#include "AppEnv.h"
#include <QList>
#include <QUrl>
#include <QDir>
SidebarGenerator::SidebarGenerator()
{
}
QList<QUrl> SidebarGenerator::generateSidebarUrls(QList<QUrl> sidebarUrls)
{
QDir dir;
dir.setPath(StandardPaths::picturesLocation());
if (dir.exists())
{
sidebarUrls << QUrl::fromLocalFile(dir.absolutePath());
}
dir.setPath(StandardPaths::documentsLocation());
if (dir.exists())
{
sidebarUrls << QUrl::fromLocalFile(dir.absolutePath());
}
bool gameFolderExists;
QString gameFolder = AppEnv::getGameFolder(&gameFolderExists);
if (gameFolderExists)
{
sidebarUrls << QUrl::fromLocalFile(gameFolder);
}
dir.setPath(StandardPaths::desktopLocation());
if (dir.exists())
{
sidebarUrls << QUrl::fromLocalFile(dir.absolutePath());
}
return sidebarUrls;
}

64
SidebarGenerator.h Normal file → Executable file
View File

@ -1,32 +1,32 @@
/*****************************************************************************
* gta5view Grand Theft Auto V Profile Viewer
* 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 SIDEBARGENERATOR_H
#define SIDEBARGENERATOR_H
#include <QList>
#include <QUrl>
class SidebarGenerator
{
public:
SidebarGenerator();
static QList<QUrl> generateSidebarUrls(QList<QUrl> sidebarUrls);
};
#endif // SIDEBARGENERATOR_H
/*****************************************************************************
* 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 SIDEBARGENERATOR_H
#define SIDEBARGENERATOR_H
#include <QList>
#include <QUrl>
class SidebarGenerator
{
public:
SidebarGenerator();
static QList<QUrl> generateSidebarUrls(QList<QUrl> sidebarUrls);
};
#endif // SIDEBARGENERATOR_H

View File

@ -1,468 +1,253 @@
/*****************************************************************************
* gta5view Grand Theft Auto V Profile Viewer
* Copyright (C) 2016-2018 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 "SnapmaticEditor.h"
#include "ui_SnapmaticEditor.h"
#include "SnapmaticPicture.h"
#include "PlayerListDialog.h"
#include "StringParser.h"
#include "AppEnv.h"
#include "config.h"
#include <QStringBuilder>
#include <QTextDocument>
#include <QInputDialog>
#include <QMessageBox>
#include <QDebug>
#include <QFile>
#ifdef GTA5SYNC_TELEMETRY
#include "TelemetryClass.h"
#include <QJsonDocument>
#include <QJsonObject>
#endif
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);
ui->setupUi(this);
ui->cmdCancel->setDefault(true);
ui->cmdCancel->setFocus();
// Set Icon for Apply Button
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("gtk-apply"))
{
ui->cmdApply->setIcon(QIcon::fromTheme("gtk-apply"));
}
else if (QIcon::hasThemeIcon("dialog-ok"))
{
ui->cmdApply->setIcon(QIcon::fromTheme("dialog-ok"));
}
else if (QIcon::hasThemeIcon("gtk-ok"))
{
ui->cmdApply->setIcon(QIcon::fromTheme("dialog-ok"));
}
// Set Icon for Cancel Button
if (QIcon::hasThemeIcon("dialog-cancel"))
{
ui->cmdCancel->setIcon(QIcon::fromTheme("dialog-cancel"));
}
else if (QIcon::hasThemeIcon("gtk-cancel"))
{
ui->cmdCancel->setIcon(QIcon::fromTheme("gtk-cancel"));
}
snapmaticTitle = QString();
smpic = 0;
#ifndef Q_OS_ANDROID
// DPI calculation
qreal screenRatio = AppEnv::screenRatio();
resize(400 * screenRatio, 360 * screenRatio);
#endif
}
SnapmaticEditor::~SnapmaticEditor()
{
delete ui;
}
void SnapmaticEditor::selfie_toggled(bool checked)
{
if (checked)
{
isSelfie = true;
}
else
{
isSelfie = false;
}
}
void SnapmaticEditor::mugshot_toggled(bool checked)
{
if (checked)
{
isMugshot = true;
ui->cbDirector->setEnabled(false);
ui->cbDirector->setChecked(false);
}
else
{
isMugshot = false;
ui->cbDirector->setEnabled(true);
}
}
void SnapmaticEditor::editor_toggled(bool checked)
{
if (checked)
{
isEditor = true;
ui->cbDirector->setEnabled(false);
ui->cbDirector->setChecked(false);
}
else
{
isEditor = false;
ui->cbDirector->setEnabled(true);
}
}
void SnapmaticEditor::on_rbSelfie_toggled(bool checked)
{
if (checked)
{
mugshot_toggled(false);
editor_toggled(false);
selfie_toggled(true);
}
}
void SnapmaticEditor::on_rbMugshot_toggled(bool checked)
{
if (checked)
{
selfie_toggled(false);
editor_toggled(false);
mugshot_toggled(true);
}
}
void SnapmaticEditor::on_rbEditor_toggled(bool checked)
{
if (checked)
{
selfie_toggled(false);
mugshot_toggled(false);
editor_toggled(true);
}
}
void SnapmaticEditor::on_rbCustom_toggled(bool checked)
{
if (checked)
{
selfie_toggled(false);
mugshot_toggled(false);
editor_toggled(false);
}
}
void SnapmaticEditor::setSnapmaticPicture(SnapmaticPicture *picture)
{
smpic = picture;
snapmaticProperties = smpic->getSnapmaticProperties();
ui->rbCustom->setChecked(true);
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);
}
else if (isMugshot)
{
ui->rbMugshot->setChecked(true);
}
else if (isEditor)
{
ui->rbEditor->setChecked(true);
}
else
{
ui->rbCustom->setChecked(true);
}
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));
}
#ifndef Q_OS_ANDROID
ui->gbValues->resize(ui->gbValues->width(), ui->gbValues->heightForWidth(ui->gbValues->width()));
ui->frameWidget->resize(ui->gbValues->width(), ui->frameWidget->heightForWidth(ui->frameWidget->width()));
if (heightForWidth(width()) > height()) { resize(width(), heightForWidth(width())); }
#endif
}
void SnapmaticEditor::setSnapmaticTitle(const QString &title)
{
if (title.length() > 39)
{
snapmaticTitle = title.left(39);
}
else
{
snapmaticTitle = title;
}
QString editStr = QString("<a href=\"g5e://edittitle\" style=\"text-decoration: none;\">%1</a>").arg(tr("Edit"));
QString titleStr = tr("Title: %1 (%2)").arg(StringParser::escapeString(snapmaticTitle), editStr);
ui->labTitle->setText(titleStr);
if (SnapmaticPicture::verifyTitle(snapmaticTitle))
{
ui->labAppropriate->setText(tr("Appropriate: %1").arg(QString("<span style=\"color: green\">%1</span>").arg(tr("Yes", "Yes, should work fine"))));
}
else
{
ui->labAppropriate->setText(tr("Appropriate: %1").arg(QString("<span style=\"color: red\">%1</span>").arg(tr("No", "No, could lead to issues"))));
}
#ifndef Q_OS_ANDROID
ui->gbValues->resize(ui->gbValues->width(), ui->gbValues->heightForWidth(ui->gbValues->width()));
ui->frameWidget->resize(ui->gbValues->width(), ui->frameWidget->heightForWidth(ui->frameWidget->width()));
if (heightForWidth(width()) > height()) { resize(width(), heightForWidth(width())); }
#endif
}
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);
#ifndef Q_OS_ANDROID
ui->gbValues->resize(ui->gbValues->width(), ui->gbValues->heightForWidth(ui->gbValues->width()));
ui->frameWidget->resize(ui->gbValues->width(), ui->frameWidget->heightForWidth(ui->frameWidget->width()));
if (heightForWidth(width()) > height()) { resize(width(), heightForWidth(width())); }
#endif
}
QString SnapmaticEditor::returnCrewName(int crewID_)
{
return crewDB->getCrewName(crewID_);
}
void SnapmaticEditor::on_cmdCancel_clicked()
{
close();
}
void SnapmaticEditor::on_cmdApply_clicked()
{
if (ui->cbQualify->isChecked())
{
qualifyAvatar();
}
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();
QString originalFilePath = smpic->getOriginalPictureFilePath();
QString backupFileName = originalFilePath % ".bak";
if (!QFile::exists(backupFileName))
{
QFile::copy(currentFilePath, backupFileName);
}
SnapmaticProperties fallbackProperties = smpic->getSnapmaticProperties();
QString fallbackTitle = smpic->getPictureTitle();
smpic->setSnapmaticProperties(snapmaticProperties);
smpic->setPictureTitle(snapmaticTitle);
if (!smpic->exportPicture(currentFilePath))
{
QMessageBox::warning(this, tr("Snapmatic Properties"), tr("Patching of Snapmatic Properties failed because of I/O Error"));
smpic->setSnapmaticProperties(fallbackProperties);
smpic->setPictureTitle(fallbackTitle);
}
else
{
smpic->updateStrings();
smpic->emitUpdate();
#ifdef GTA5SYNC_TELEMETRY
QSettings telemetrySettings(GTA5SYNC_APPVENDOR, GTA5SYNC_APPSTR);
telemetrySettings.beginGroup("Telemetry");
bool pushUsageData = telemetrySettings.value("PushUsageData", false).toBool();
telemetrySettings.endGroup();
if (pushUsageData && Telemetry->canPush())
{
QJsonDocument jsonDocument;
QJsonObject jsonObject;
jsonObject["Type"] = "PropertyEdited";
jsonObject["EditedSize"] = QString::number(smpic->getContentMaxLength());
jsonObject["EditedTime"] = QString::number(QDateTime::currentDateTimeUtc().toTime_t());
jsonDocument.setObject(jsonObject);
Telemetry->push(TelemetryCategory::PersonalData, jsonDocument);
}
#endif
}
}
close();
}
void SnapmaticEditor::qualifyAvatar()
{
ui->rbSelfie->setChecked(true);
ui->cbDirector->setChecked(false);
ui->cbMeme->setChecked(false);
ui->cmdApply->setDefault(true);
}
void SnapmaticEditor::on_cbQualify_toggled(bool checked)
{
if (checked)
{
ui->cbMeme->setEnabled(false);
ui->cbDirector->setEnabled(false);
ui->rbCustom->setEnabled(false);
ui->rbSelfie->setEnabled(false);
ui->rbEditor->setEnabled(false);
ui->rbMugshot->setEnabled(false);
}
else
{
ui->cbMeme->setEnabled(true);
ui->rbCustom->setEnabled(true);
ui->rbSelfie->setEnabled(true);
ui->rbEditor->setEnabled(true);
ui->rbMugshot->setEnabled(true);
if (ui->rbSelfie->isChecked() || ui->rbCustom->isChecked())
{
ui->cbDirector->setEnabled(true);
}
}
}
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->setModal(true);
playerListDialog->show();
playerListDialog->exec();
delete playerListDialog;
}
}
void SnapmaticEditor::on_labTitle_linkActivated(const QString &link)
{
if (link == "g5e://edittitle")
{
bool ok;
QString newTitle = QInputDialog::getText(this, tr("Snapmatic Title"), tr("New Snapmatic title:"), QLineEdit::Normal, snapmaticTitle, &ok, windowFlags());
if (ok && !newTitle.isEmpty())
{
setSnapmaticTitle(newTitle);
}
}
}
void SnapmaticEditor::on_labCrew_linkActivated(const QString &link)
{
if (link == "g5e://editcrew")
{
bool ok;
int indexNum = 0;
QStringList itemList;
QStringList crewList = crewDB->getCrews();
if (!crewList.contains(QLatin1String("0")))
{
crewList += QLatin1String("0");
}
crewList.sort();
for (QString crew : crewList)
{
itemList += QString("%1 (%2)").arg(crew, returnCrewName(crew.toInt()));
}
if (crewList.contains(QString::number(crewID)))
{
indexNum = crewList.indexOf(QString::number(crewID));
}
QString newCrew = QInputDialog::getItem(this, tr("Snapmatic Crew"), tr("New Snapmatic crew:"), itemList, indexNum, true, &ok, windowFlags());
if (ok && !newCrew.isEmpty())
{
if (newCrew.contains(" ")) newCrew = newCrew.split(" ").at(0);
if (newCrew.length() > 10) return;
for (QChar crewChar : newCrew)
{
if (!crewChar.isNumber())
{
return;
}
}
if (!crewList.contains(newCrew))
{
crewDB->addCrew(crewID);
}
crewID = newCrew.toInt();
setSnapmaticCrew(returnCrewName(crewID));
}
}
}
void SnapmaticEditor::playerListUpdated(QStringList playerList)
{
playersList = playerList;
setSnapmaticPlayers(insertPlayerNames(playerList));
}
/*****************************************************************************
* 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 "SnapmaticEditor.h"
#include "ui_SnapmaticEditor.h"
#include "SnapmaticPicture.h"
#include <QMessageBox>
#include <QDebug>
#include <QFile>
SnapmaticEditor::SnapmaticEditor(QWidget *parent) :
QDialog(parent),
ui(new Ui::SnapmaticEditor)
{
ui->setupUi(this);
ui->cbSelfie->setVisible(false);
ui->cbMugshot->setVisible(false);
ui->cbEditor->setVisible(false);
ui->cmdApply->setDefault(true);
if (QIcon::hasThemeIcon("dialog-apply"))
{
ui->cmdApply->setIcon(QIcon::fromTheme("dialog-apply"));
}
if (QIcon::hasThemeIcon("dialog-cancel"))
{
ui->cmdCancel->setIcon(QIcon::fromTheme("dialog-cancel"));
}
smpic = 0;
}
SnapmaticEditor::~SnapmaticEditor()
{
delete ui;
}
void SnapmaticEditor::on_cbSelfie_toggled(bool checked)
{
if (checked)
{
ui->cbMugshot->setEnabled(false);
ui->cbEditor->setEnabled(false);
}
else if (!ui->cbDirector->isChecked())
{
ui->cbMugshot->setEnabled(true);
ui->cbEditor->setEnabled(true);
}
}
void SnapmaticEditor::on_cbMugshot_toggled(bool checked)
{
if (checked)
{
ui->cbSelfie->setEnabled(false);
ui->cbEditor->setEnabled(false);
ui->cbDirector->setEnabled(false);
}
else
{
ui->cbSelfie->setEnabled(true);
ui->cbEditor->setEnabled(true);
ui->cbDirector->setEnabled(true);
}
}
void SnapmaticEditor::on_cbDirector_toggled(bool checked)
{
if (checked)
{
ui->cbMugshot->setEnabled(false);
ui->cbEditor->setEnabled(false);
}
else if (!ui->cbSelfie->isChecked())
{
ui->cbMugshot->setEnabled(true);
ui->cbEditor->setEnabled(true);
}
}
void SnapmaticEditor::on_cbEditor_toggled(bool checked)
{
if (checked)
{
ui->cbSelfie->setEnabled(false);
ui->cbMugshot->setEnabled(false);
ui->cbDirector->setEnabled(false);
}
else
{
ui->cbSelfie->setEnabled(true);
ui->cbMugshot->setEnabled(true);
ui->cbDirector->setEnabled(true);
}
}
void SnapmaticEditor::on_rbSelfie_toggled(bool checked)
{
if (checked)
{
ui->cbMugshot->setChecked(false);
ui->cbEditor->setChecked(false);
ui->cbSelfie->setChecked(true);
}
}
void SnapmaticEditor::on_rbMugshot_toggled(bool checked)
{
if (checked)
{
ui->cbSelfie->setChecked(false);
ui->cbEditor->setChecked(false);
ui->cbDirector->setChecked(false);
ui->cbMugshot->setChecked(true);
}
}
void SnapmaticEditor::on_rbEditor_toggled(bool checked)
{
if (checked)
{
ui->cbSelfie->setChecked(false);
ui->cbMugshot->setChecked(false);
ui->cbDirector->setChecked(false);
ui->cbEditor->setChecked(true);
}
}
void SnapmaticEditor::on_rbCustom_toggled(bool checked)
{
if (checked)
{
ui->cbSelfie->setChecked(false);
ui->cbMugshot->setChecked(false);
ui->cbEditor->setChecked(false);
}
}
void SnapmaticEditor::setSnapmaticPicture(SnapmaticPicture *picture)
{
smpic = picture;
localSpJson = smpic->getSnapmaticProperties();
ui->rbCustom->setChecked(true);
ui->cbSelfie->setChecked(localSpJson.isSelfie);
ui->cbMugshot->setChecked(localSpJson.isMug);
ui->cbEditor->setChecked(localSpJson.isFromRSEditor);
ui->cbDirector->setChecked(localSpJson.isFromDirector);
ui->cbMeme->setChecked(localSpJson.isMeme);
if (ui->cbSelfie->isChecked())
{
ui->rbSelfie->setChecked(true);
}
else if (ui->cbMugshot->isChecked())
{
ui->rbMugshot->setChecked(true);
}
else if (ui->cbEditor->isChecked())
{
ui->rbEditor->setChecked(true);
}
else
{
ui->rbCustom->setChecked(true);
}
}
void SnapmaticEditor::on_cmdCancel_clicked()
{
close();
}
void SnapmaticEditor::on_cmdApply_clicked()
{
if (ui->cbQualify->isChecked())
{
qualifyAvatar();
}
localSpJson.isSelfie = ui->cbSelfie->isChecked();
localSpJson.isMug = ui->cbMugshot->isChecked();
localSpJson.isFromRSEditor = ui->cbEditor->isChecked();
localSpJson.isFromDirector = ui->cbDirector->isChecked();
localSpJson.isMeme = ui->cbMeme->isChecked();
if (smpic)
{
QString originalFileName = smpic->getPictureFilePath();
QString adjustedFileName = originalFileName;
if (adjustedFileName.right(7) == ".hidden") // for the hidden file system
{
adjustedFileName.remove(adjustedFileName.length() - 7, 7);
}
QString backupFileName = adjustedFileName + ".bak";
if (!QFile::exists(backupFileName))
{
QFile::copy(adjustedFileName, backupFileName);
}
smpic->setSnapmaticProperties(localSpJson);
if (!smpic->exportPicture(originalFileName))
{
QMessageBox::warning(this, tr("Snapmatic Properties"), tr("Patching of Snapmatic Properties failed because of I/O Error"));
}
}
close();
}
void SnapmaticEditor::qualifyAvatar()
{
ui->rbSelfie->setChecked(true);
ui->cbDirector->setChecked(false);
ui->cbMeme->setChecked(false);
ui->cmdApply->setDefault(true);
}
void SnapmaticEditor::on_cbQualify_toggled(bool checked)
{
if (checked)
{
ui->cbMeme->setEnabled(false);
ui->cbDirector->setEnabled(false);
ui->rbCustom->setEnabled(false);
ui->rbSelfie->setEnabled(false);
ui->rbEditor->setEnabled(false);
ui->rbMugshot->setEnabled(false);
}
else
{
ui->cbMeme->setEnabled(true);
ui->rbCustom->setEnabled(true);
ui->rbSelfie->setEnabled(true);
ui->rbEditor->setEnabled(true);
ui->rbMugshot->setEnabled(true);
if (ui->rbSelfie->isChecked() || ui->rbCustom->isChecked())
{
ui->cbDirector->setEnabled(true);
}
}
}

View File

@ -1,77 +1,58 @@
/*****************************************************************************
* gta5view Grand Theft Auto V Profile Viewer
* 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 SNAPMATICEDITOR_H
#define SNAPMATICEDITOR_H
#include <QDialog>
#include "CrewDatabase.h"
#include "ProfileDatabase.h"
#include "SnapmaticPicture.h"
namespace Ui {
class SnapmaticEditor;
}
class SnapmaticEditor : public QDialog
{
Q_OBJECT
public:
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);
~SnapmaticEditor();
private slots:
void on_rbSelfie_toggled(bool checked);
void on_rbMugshot_toggled(bool checked);
void on_rbEditor_toggled(bool checked);
void on_rbCustom_toggled(bool checked);
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 snapmaticProperties;
SnapmaticPicture *smpic;
QStringList playersList;
QString snapmaticTitle;
int crewID;
bool isSelfie;
bool isMugshot;
bool isEditor;
void selfie_toggled(bool checked);
void mugshot_toggled(bool checked);
void editor_toggled(bool checked);
void qualifyAvatar();
void insertPlayerNames(QStringList *players);
QStringList insertPlayerNames(const QStringList &players);
};
#endif // SNAPMATICEDITOR_H
/*****************************************************************************
* 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 SNAPMATICEDITOR_H
#define SNAPMATICEDITOR_H
#include <QDialog>
#include "SnapmaticPicture.h"
namespace Ui {
class SnapmaticEditor;
}
class SnapmaticEditor : public QDialog
{
Q_OBJECT
public:
explicit SnapmaticEditor(QWidget *parent = 0);
void setSnapmaticPicture(SnapmaticPicture *picture);
~SnapmaticEditor();
private slots:
void on_cbSelfie_toggled(bool checked);
void on_cbMugshot_toggled(bool checked);
void on_cbDirector_toggled(bool checked);
void on_cbEditor_toggled(bool checked);
void on_rbSelfie_toggled(bool checked);
void on_rbMugshot_toggled(bool checked);
void on_rbEditor_toggled(bool checked);
void on_rbCustom_toggled(bool checked);
void on_cmdCancel_clicked();
void on_cmdApply_clicked();
void on_cbQualify_toggled(bool checked);
private:
Ui::SnapmaticEditor *ui;
SnapmaticProperties localSpJson;
SnapmaticPicture *smpic;
void qualifyAvatar();
};
#endif // SNAPMATICEDITOR_H

Some files were not shown because too many files have changed in this diff Show More