Compare commits

...

179 Commits

Author SHA1 Message Date
Rafael 20de3627d5
fix manifest release year
continuous-integration/drone/push Build is passing Details
2023-03-15 09:19:24 +01:00
Syping 13b6d614fc gta5view 1.10.2 release
continuous-integration/drone/push Build is passing Details
continuous-integration/drone/tag Build is passing Details
- fix crash bug and upload issue
2023-03-15 07:10:50 +01:00
Syping d7b28c2468 fix Content Mode options and few other changes
continuous-integration/drone/push Build is passing Details
- fix setupRadioButtons (Content Mode options)
- update integrated qtbase_de.qm from Qt 6.4
- bump copyright year and some version numbers (again)
2022-12-25 22:11:51 +01:00
Syping 5e6c4e6ad1 fix Qt 6.4 build and few other changes
continuous-integration/drone/push Build is passing Details
- include QStringEncoder and QStringDecoder for Qt 6.4
- update integrated qtbase_de.qm from Qt 6.3
- fix macOS theme detection on Qt 6
- bump copyright year and some version numbers
- remove ZEC donation
- rework README.md
2022-08-21 21:39:19 +02:00
Syping 3cd6cc903d gta5view 1.10.1 release
continuous-integration/drone/push Build is passing Details
continuous-integration/drone/tag Build is passing Details
2021-06-17 06:14:35 +02:00
Syping c42cc1dc26 Add Korean strings for Desktop and Metainfo files
continuous-integration/drone/push Build is passing Details
2021-05-28 15:21:07 +02:00
Syping 204f55a11d gta5view 1.10.0 release
continuous-integration/drone/push Build is passing Details
continuous-integration/drone/tag Build is passing Details
2021-05-27 05:42:05 +02:00
Syping de17747c38 gta5view 1.10.0 release
continuous-integration/drone/push Build is passing Details
continuous-integration/drone/tag Build is passing Details
2021-05-27 05:23:49 +02:00
Syping aa83221db2 gta5view 1.10.0 release
continuous-integration/drone/push Build is passing Details
continuous-integration/drone/tag Build is passing Details
2021-05-27 05:03:27 +02:00
Syping b6241a8ff5 gta5view 1.10.0 release
continuous-integration/drone/push Build is passing Details
continuous-integration/drone/tag Build is passing Details
2021-05-27 04:08:37 +02:00
Syping 4a293b6acd Minor changes and MimeType support
continuous-integration/drone/push Build is passing Details
2021-05-27 02:28:41 +02:00
Syping f4b4450f69 Fix Qt4 builds
continuous-integration/drone/push Build is passing Details
2021-05-23 07:20:20 +02:00
Syping 268e8d3468 Feature: Auto-detect new files in Profile folder
continuous-integration/drone/push Build is passing Details
2021-05-23 07:12:56 +02:00
Syping b47a0119a5 SnapmaticPicture: define default PhotoBuffer
continuous-integration/drone/push Build is passing Details
2021-05-23 05:06:32 +02:00
Syping 1770ec23e0 Improve ImportDialog layouts
continuous-integration/drone/push Build is passing Details
2021-05-22 20:22:02 +02:00
Syping cbe92af194 Force Borderless -> Crop to Aspect Ratio (more clear)
continuous-integration/drone/push Build is passing Details
2021-05-22 19:47:06 +02:00
Syping 35924c4696 MapLocationDialog zoom is now experimental (incomplete)
continuous-integration/drone/push Build is passing Details
2021-05-09 07:42:14 +02:00
Syping 9c937ff270 rework donation UI
continuous-integration/drone/push Build is passing Details
2021-04-25 16:47:27 +02:00
Syping fc08d29fe8 add QR codes for donation addresses
continuous-integration/drone/push Build is passing Details
2021-04-25 13:24:05 +02:00
VenJam1n bdf2c35f35 Update Ukrainian translation
continuous-integration/drone/push Build is passing Details
2021-04-08 20:42:27 +02:00
Syping a952eff26d Fix donate icon
continuous-integration/drone/push Build is passing Details
2021-04-02 20:06:58 +02:00
Syping 955f015de3 Fix Windows resource folder
continuous-integration/drone/push Build is passing Details
2021-04-02 20:02:35 +02:00
Syping 7013ade1b5 fix IconLoader typo
continuous-integration/drone/push Build is passing Details
2021-04-02 19:54:07 +02:00
Syping 5244f72ec2 QCONF build separates images
continuous-integration/drone/push Build is passing Details
2021-04-02 19:51:05 +02:00
Syping 522cb469b7 ProfileLoader check if regular file
continuous-integration/drone/push Build is passing Details
2021-04-02 03:05:54 +02:00
Syping 2f135cd373 optimise ProfileLoader
continuous-integration/drone/push Build is passing Details
2021-04-02 02:54:28 +02:00
Syping 3c673beed1 Update Korean translation
continuous-integration/drone/push Build is passing Details
2021-03-27 11:08:46 +01:00
Syping e572c9c60e code cleanup and improvements
continuous-integration/drone/push Build is passing Details
2021-03-27 08:23:05 +01:00
VADemon 6fdab04c05 Update Russian translation
continuous-integration/drone/push Build is passing Details
2021-03-26 19:05:48 +01:00
Syping 1c02c37e9c improve donate icon
continuous-integration/drone/push Build is passing Details
2021-03-26 18:44:01 +01:00
Syping 8a24060fb2 add donate icon
continuous-integration/drone/push Build is passing Details
2021-03-26 18:08:30 +01:00
Ray 694ebc030a Updated Taiwanese translation
continuous-integration/drone/push Build is passing Details
2021-03-26 15:34:37 +01:00
Syping 817f356b33 add donation system
continuous-integration/drone/push Build is passing Details
2021-03-26 14:58:54 +01:00
Syping 04603af8ff Fix Qt4 qAsConst
continuous-integration/drone/push Build is passing Details
2021-03-26 10:59:34 +01:00
Syping 44ab5caedf small RagePhoto cleanup
continuous-integration/drone/push Build is passing Details
2021-03-26 09:51:39 +01:00
Syping b747f7cda5 add RAGEPHOTO_BENCHMARK for parser benchmarks
continuous-integration/drone/push Build is passing Details
2021-03-26 09:40:30 +01:00
Syping 23e9c48248 macOS CI script update, ProfileLoader debug code removal
continuous-integration/drone/push Build is passing Details
2021-03-22 07:12:37 +01:00
Syping a4bc9a3b75 Fix RagePhoto runtime crashes, const improvements
continuous-integration/drone/push Build is passing Details
2021-03-22 05:40:30 +01:00
Syping 4e004b1d68 unfinished zoom support
continuous-integration/drone/push Build is passing Details
2021-02-26 19:59:05 +01:00
Syping b0f95d1cae Fix default font loading
continuous-integration/drone/push Build is passing Details
2021-02-17 23:31:26 +01:00
Syping 962b1c82c3 Build system update, minor fix
continuous-integration/drone/push Build is passing Details
2021-02-17 23:16:00 +01:00
Syping 0686b9a65d Add Cayo Perico Map, optimisations
continuous-integration/drone/push Build is passing Details
2021-02-15 23:12:44 +01:00
Syping 3ed26d4f9d CMake: Fix gta5view.icns location
continuous-integration/drone/push Build is passing Details
2021-02-11 23:34:42 +01:00
Syping 263e714022 Fix Qt6 Windows build, improve build success consistency
continuous-integration/drone/push Build is passing Details
2021-02-11 23:09:49 +01:00
Syping dd9c4a7f16 Improve DWM code, remove WinExtras dependency
continuous-integration/drone/push Build is passing Details
2021-02-11 20:20:52 +01:00
Syping c1b0053ac8 Force Borderless mode added
continuous-integration/drone/push Build is passing Details
2021-02-03 20:22:00 +01:00
Syping 5fd4b48538 Improved PictureDialog resizing
continuous-integration/drone/push Build is passing Details
2021-01-30 12:02:55 +01:00
Syping 929d341826 code cleanup, remove first start prompt
continuous-integration/drone/push Build is passing Details
2021-01-29 19:46:01 +01:00
Syping fd5006e70f CMake: Full macOS Support, macOS CI uses CMake
continuous-integration/drone/push Build is passing Details
2021-01-28 18:39:42 +01:00
Syping 2f7e4a154d Qt6 telemetry build fix, PictureDialog crash fix
continuous-integration/drone/push Build is passing Details
2021-01-27 14:35:42 +01:00
Syping d4a6db068b CI: Add Debian backports before updating
continuous-integration/drone/push Build is passing Details
2021-01-24 02:35:53 +01:00
Syping 01ad3fd04e Debian Buster target, CI script update
continuous-integration/drone/push Build is passing Details
2021-01-22 06:35:35 +01:00
Syping 03f696877e Fix -Wstring-compare warning
continuous-integration/drone/push Build is passing Details
2021-01-21 23:11:50 +01:00
Syping bcbe69491b CMake: Support Qt6 translation build 2021-01-21 22:44:10 +01:00
Syping 056ef79aff Fix wrong placed const 2021-01-21 21:54:15 +01:00
Syping 013bfeb8ed CMake and build type recognition improvements 2021-01-21 21:50:18 +01:00
Syping d9eb8d5f95 Year 2021, 1.10 initial dev branch 2021-01-21 18:48:19 +01:00
Syping dd7667b9f7 Build fix Qt6 ifdef
continuous-integration/drone/push Build is passing Details
2021-01-10 01:33:18 +01:00
Syping 7adf8f2c90 1.9.1: Cayo Perico DLC update, Multi-select bugfix
continuous-integration/drone/push Build is passing Details
continuous-integration/drone/tag Build is passing Details
2020-12-16 13:02:11 +01:00
Syping 5dbc06f393 gta5view 1.9.0 release
continuous-integration/drone/push Build is passing Details
continuous-integration/drone/tag Build is passing Details
2020-11-30 13:19:42 +01:00
Syping 9adc8d9650 Aspect Ratio fixes, HiDPI fullscreen fix
continuous-integration/drone/push Build is passing Details
2020-11-25 00:36:12 +01:00
VenJam1n 0fcd4615cd Fix Ukrainian translation template
continuous-integration/drone/push Build is passing Details
2020-11-23 16:27:20 +01:00
VenJam1n 47fdacc8bf Ukrainian translation updated
continuous-integration/drone/push Build is passing Details
2020-11-23 04:55:54 +01:00
Syping e448bd4f63 content mode now in options
continuous-integration/drone/push Build is passing Details
2020-11-23 03:47:17 +01:00
Syping 099400b439 added new content modes
continuous-integration/drone/push Build is passing Details
2020-11-23 03:13:07 +01:00
Syping 563b09e060 CMake dependency correction, Russian strings for App
continuous-integration/drone/push Build is passing Details
2020-11-21 14:25:22 +01:00
Syping f432ae068e Improve watermark placing
continuous-integration/drone/push Build is passing Details
2020-11-17 16:38:30 +01:00
VADemon 48c4aa4a97 Update Russian translation
continuous-integration/drone/push Build is passing Details
2020-11-17 11:02:45 +01:00
Syping e82cec5fd5 Add Font Dialog for Font changing
continuous-integration/drone/push Build is passing Details
2020-11-17 10:46:37 +01:00
Syping 070b82d530 Qt6: Fix QVariant::Type deprecated warning
continuous-integration/drone/push Build is passing Details
2020-11-17 10:20:50 +01:00
Syping 25ec67ec8b Fix resources and Qt4 build
continuous-integration/drone/push Build is passing Details
2020-11-17 06:58:29 +01:00
Ray 4a699f2f56 update taiwanese translation
continuous-integration/drone/push Build is passing Details
2020-11-17 06:04:58 +01:00
Syping 8c6e609ecc add custom font feature
continuous-integration/drone/push Build is passing Details
2020-11-17 04:43:04 +01:00
Syping 40e1b288c3 updated korean translation
continuous-integration/drone/push Build is passing Details
2020-11-17 03:46:07 +01:00
Ray b50170645c update taiwanese translation
continuous-integration/drone/push Build is passing Details
2020-11-17 03:31:12 +01:00
VADemon 1b8aea96d7 update russian translation 2020-11-17 03:29:33 +01:00
Syping 5a34dd7b05 [skip ci] fix ImportDialog string, update translations 2020-11-17 03:25:30 +01:00
Syping 2b2cfc210f add unlimited buffer and import as-is
continuous-integration/drone/push Build is passing Details
2020-11-16 15:29:31 +01:00
Syping f6f75c1f89 [skip ci] add FileTools to desktop file 2020-11-16 05:37:28 +01:00
Syping 94a263f501 SnapmaticPicture: fix eXtend bug
continuous-integration/drone/push Build is passing Details
2020-11-15 13:55:06 +01:00
Syping 1b6cb511be SnapmaticPicture: add eXtendMode
continuous-integration/drone/push Build is passing Details
2020-11-15 13:15:16 +01:00
Syping c0a3e08527 RagePhoto: add setPhotoBuffer
continuous-integration/drone/push Build is passing Details
2020-11-15 12:29:33 +01:00
Syping 2cf9119c54 RagePhoto: Improve casting
continuous-integration/drone/push Build is passing Details
2020-11-12 00:24:21 +01:00
Syping 05ccdc6689 RagePhoto: Fix Qt4 build
continuous-integration/drone/push Build is passing Details
2020-11-11 19:43:54 +01:00
Syping 0c6c6ca9fb RagePhoto: Qt < 5.10 build fix
continuous-integration/drone/push Build is passing Details
2020-11-11 18:14:50 +01:00
Syping 6befe33596 RagePhoto: Qt6 support added
continuous-integration/drone/push Build is passing Details
2020-11-11 17:58:15 +01:00
Syping e34ee22ed9 RagePhoto: Add saving and fix few issues
continuous-integration/drone/push Build is passing Details
2020-11-11 07:04:39 +01:00
Syping 2c725c796e RagePhoto: added save for GTA
continuous-integration/drone/push Build is passing Details
2020-11-09 03:43:46 +01:00
Syping 3cf6aedc85 RagePhoto: add G5E1P parser, fix G5E2P
continuous-integration/drone/push Build is passing Details
2020-11-09 02:13:06 +01:00
Syping 2bb3f7f62d SnapmaticPicture: wrap getContentMaxLength
continuous-integration/drone/push Build is passing Details
2020-11-09 01:42:11 +01:00
Syping 18083a3b0f SnapmaticPicture: fix IO memleak
continuous-integration/drone/push Build is failing Details
2020-11-09 01:23:01 +01:00
Syping 186df05cea WIP: SnapmaticPicture using RagePhoto now
continuous-integration/drone/push Build is failing Details
2020-11-09 01:08:51 +01:00
Syping b3e1520a8f RagePhoto: add int to char
continuous-integration/drone/push Build is passing Details
2020-11-08 20:53:43 +01:00
Syping b70396f77e RagePhoto: G5E2P and G5E3P parser added
continuous-integration/drone/push Build is passing Details
2020-11-08 18:05:44 +01:00
Syping a798be0b53 RagePhoto: Load parser added
continuous-integration/drone/push Build is passing Details
2020-11-08 03:50:06 +01:00
Syping 4d9cd2d9ff Qt6: Avoid timestamp string conversion
continuous-integration/drone/push Build is passing Details
2020-11-05 18:32:20 +01:00
Syping 699f5b8f55 NSIS: Bump version to 1.9.0
continuous-integration/drone/push Build is passing Details
2020-11-05 16:29:00 +01:00
Syping d55ea46b47 NSIS: Fix Qt5 translation path
continuous-integration/drone/push Build is passing Details
2020-11-05 16:28:11 +01:00
Syping 6af5f94d70 CMake: Support Qt6 build
continuous-integration/drone/push Build is failing Details
2020-11-05 16:21:33 +01:00
Syping fcbe264d63 Small Flatpak fixes, Qt6 beta build fix
continuous-integration/drone/push Build is passing Details
2020-10-21 19:14:20 +02:00
Syping f8049c8178 add metainfo
continuous-integration/drone/push Build is passing Details
2020-10-20 09:31:22 +02:00
Syping d0899623ad README: add Arch/Manjaro build instruction
continuous-integration/drone/push Build is passing Details
2020-10-13 22:35:17 +02:00
Syping 547922329a gta5view 1.8.0 release
continuous-integration/drone/push Build is passing Details
continuous-integration/drone/tag Build is passing Details
2020-10-11 17:53:45 +02:00
Syping 1fbe4d9e67 gta5view 1.8.0 release
continuous-integration/drone/push Build is passing Details
2020-10-11 17:46:45 +02:00
Syping 678425a7c5 Ported now to Qt 6
continuous-integration/drone/push Build is passing Details
2020-09-28 05:33:04 +02:00
Syping f9129f8364 CI: Strip binaries to smaller size
continuous-integration/drone/push Build is passing Details
2020-09-26 21:18:55 +02:00
Syping 4e5592566a CMake build improved and does now Windows build
continuous-integration/drone/push Build is failing Details
2020-09-26 18:52:05 +02:00
Syping 39436a6dbf CMake improvements, deprecate QMake for Qt5, GTA5SYNC_WIN -> Q_OS_WIN,
continuous-integration/drone/push Build is passing Details
APV removed
2020-09-26 16:12:55 +02:00
Syping 15dfc2c84b added motd message system
continuous-integration/drone/push Build is passing Details
2020-09-13 02:10:15 +02:00
Syping 57c32eea58 QMake: No need for 'make depend' anymore
continuous-integration/drone/push Build is passing Details
2020-09-03 00:03:04 +02:00
Syping 90744ced60 correct GTA5VIEW_COMMIT in debian_build.sh
continuous-integration/drone/push Build is passing Details
2020-08-30 18:56:26 +02:00
Syping 90846e6fb6 install CMake to fix CI build
continuous-integration/drone/push Build is passing Details
2020-08-30 18:52:41 +02:00
Syping 2735325f4c use CMake for Qt5 Linux build
continuous-integration/drone/push Build is passing Details
2020-08-30 18:48:33 +02:00
Syping 8b8e22c958 [skip ci] make flatpak-builder using local directory 2020-08-30 17:57:04 +02:00
Syping 91ccdca77a [skip ci] update translation templates 2020-08-30 17:47:09 +02:00
Syping ae0c7c2905 CMake: Build variables and telemetry support added
continuous-integration/drone/push Build is passing Details
2020-08-30 17:39:10 +02:00
Syping 4a026640e3 Fix icon naming and desktop entry file
continuous-integration/drone/push Build is passing Details
2020-08-28 22:11:52 +02:00
Syping 8be9fd6d5e CMake: Installing icons to hicolor directory
continuous-integration/drone/push Build is passing Details
2020-08-28 17:11:04 +02:00
Syping 8295e38ab4 fix CI builds
continuous-integration/drone/push Build is passing Details
2020-08-28 13:37:59 +02:00
Syping 24cd9a16f9 updated gta5view icon naming
continuous-integration/drone/push Build is passing Details
2020-08-28 13:33:35 +02:00
Syping aa142c9ec9 QMake: fix desktop entry installation, minor desktop entry fixes
continuous-integration/drone/push Build is passing Details
2020-08-28 13:06:27 +02:00
Syping 4c42f06b39 added Flatpak manifest and CMake support for Flatpak
continuous-integration/drone/push Build is passing Details
2020-08-28 12:54:39 +02:00
Syping 94fb78c59a CMake: add QCONF_BUILD, missing Qt translation in binary fixed
continuous-integration/drone/push Build is passing Details
2020-08-28 00:26:30 +02:00
Syping 3f910c16b0 update Qt translations 2020-08-28 00:24:36 +02:00
Syping bbf7f08980 cmake improvements, default *nix user build to CMake
continuous-integration/drone/push Build is passing Details
2020-08-27 18:14:30 +02:00
Syping ec93fa8ce0 add basic CMakeLists.txt (*nix only)
continuous-integration/drone/push Build is passing Details
2020-08-26 20:51:01 +02:00
Syping d37fbdf055 [skip ci] update translation templates 2020-08-25 20:50:41 +02:00
Syping 1c00871e80 [skip ci] add correct version number to gta5view.desktop 2020-08-25 20:11:45 +02:00
Syping a74e7847b2 change the way how MapLocationDialog sets marker on Windows
continuous-integration/drone/push Build is passing Details
2020-08-25 19:17:30 +02:00
Syping e41d4946f8 autoupdate app.rc on CI builds
continuous-integration/drone/push Build is passing Details
2020-08-25 19:09:56 +02:00
Syping 28fedfdd0b fix some deprecations, more compatibility
continuous-integration/drone/push Build is passing Details
2020-08-25 17:29:41 +02:00
Syping a882738735 [skip ci] fix indent spelling 2020-08-25 15:47:08 +02:00
Syping 23245a3324 [skip ci] make font fixed for Qt below than 5.2 2020-08-25 15:32:32 +02:00
Syping af86e70f4b [skip ci] prettify qjson4 output aswell 2020-08-25 15:18:23 +02:00
Syping 2bf6bb5630 options players tab only show now when filled
continuous-integration/drone/push Build is passing Details
2020-08-25 14:07:42 +02:00
Syping 6b2b18ed16 improved more manual DPI scaling
continuous-integration/drone/push Build is passing Details
2020-08-25 12:53:21 +02:00
Syping c936fed2f8 fix broken Map drawing on some platforms 2020-08-25 12:52:45 +02:00
Syping cb8793f3b3 make performance improvements for Windows aswell
continuous-integration/drone/push Build is passing Details
2020-08-24 17:48:09 +02:00
Syping 1038f000f7 more performance improvements
continuous-integration/drone/push Build is passing Details
2020-08-24 17:44:32 +02:00
Syping 3c124f9f27 improve hover detection performance
continuous-integration/drone/push Build is passing Details
2020-08-24 17:23:10 +02:00
Syping 27075778c6 enable NavigationBar for non-Windows systems
continuous-integration/drone/push Build is passing Details
2020-08-24 16:35:52 +02:00
Syping 2b0455e2ff fix Qt 5.15 build
continuous-integration/drone/push Build is passing Details
2020-08-03 17:23:39 +02:00
Syping ab248413ea drone cleanup previous build
continuous-integration/drone/push Build is passing Details
2020-06-07 21:50:26 +02:00
Syping 279cd5ac3b fix .drone.yml steps
continuous-integration/drone/push Build is failing Details
2020-06-07 21:42:49 +02:00
Syping 1f62f6fe48 fix drone.sh permission
continuous-integration/drone/push Build is passing Details
2020-06-07 20:38:43 +02:00
Syping c8a955e8de remove unused translation files
continuous-integration/drone/push Build is failing Details
2020-06-07 20:37:31 +02:00
Syping 5250bad4b6 add drone build 2020-06-07 20:30:53 +02:00
Syping 9121987142 fix Qt plugins in NSIS script 2020-04-24 05:45:18 +02:00
Syping cabd44f066 fix dumb NSIS mistake 2020-04-24 05:42:57 +02:00
Syping 01fb80fdd1 fix NSIS script 2020-04-24 05:41:20 +02:00
Syping f63645a1fb 1.8 bump, fix res regression from 1.7, other fixes. 2020-04-24 05:36:11 +02:00
Syping 8732b9d64d 1.7.1 release, fix installation
continuous-integration/drone/push Build is failing Details
2019-08-04 15:56:16 +02:00
Syping bb4a9b484c 1.7.1 release, korean translation added 2019-08-04 15:49:32 +02:00
Syping c79c8dbe6e 1.7.0 release 2019-07-24 20:23:40 +02:00
Syping 4e31d159fa 1.7.0 release 2019-07-24 20:16:48 +02:00
Syping 0633d14d6b install Lua, change buildtype to Release 2019-07-24 20:12:26 +02:00
Syping c6b39546ba remove function to click numbers (don't work anymore) 2019-07-24 20:05:34 +02:00
Syping eac9caa2c6 fix compatibility issue 2019-07-24 19:47:08 +02:00
Syping a80b5843a7 fix build script 2019-07-24 19:10:14 +02:00
Syping 07797f6e60 remove upx compression step 2019-07-24 18:57:00 +02:00
Syping 55186e8b88 improve MapLocationDialog 2019-07-24 18:35:32 +02:00
Syping eee9100d8b remove OpenSSL changes 2019-04-22 20:39:18 +02:00
Syping b73719ed4e add WindowsVista style 2019-04-22 05:25:28 +02:00
Syping a143b43d15 fix uninstallation 2019-04-22 05:10:39 +02:00
Syping 032475ddfd remove audio 2019-04-22 05:07:04 +02:00
Syping bdde72573b gta5view.nsi now UTF-8 2019-04-22 05:05:12 +02:00
Syping 827676768a update Qt to 5.12.3 2019-04-22 04:59:26 +02:00
Syping 0c02c3ce98 use icons for PlayerListDialog buttons 2019-01-16 02:11:42 +01:00
Syping 6063803d5e improve PlayerListDialog 2019-01-13 14:56:35 +01:00
Syping 1f3c036b47 navigation bar fixed 2019-01-13 14:40:16 +01:00
Syping ea0526ae9d massive DPI improvements 2019-01-13 14:32:12 +01:00
Syping aeae6c9311 fix DPI scaling in PictureDialog 2018-12-25 21:05:09 +01:00
Syping c39c3a3e9f always scale savegame graphic 2018-12-02 18:10:34 +01:00
Syping 9989d9d869 replace savegame.png with scaleable savegame.svgz 2018-12-01 17:47:28 +01:00
Syping fa86e8f8a7 fix Windows installer build 2018-11-22 21:54:16 +01:00
Syping f9880fff70 update toolchain 2018-11-22 21:50:53 +01:00
Syping 7ba5322643 fix CI script SVG module installation 2018-11-18 20:39:32 +01:00
Syping 1f409b0f25 Scaleable navigation bar icons 2018-11-18 18:08:18 +01:00
Syping dea33f8ab0 1.7 development 2018-09-09 19:25:28 +02:00
206 changed files with 14490 additions and 27720 deletions

33
.ci/app.rc Normal file
View File

@ -0,0 +1,33 @@
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-2023 Syping"
VALUE "OriginalFilename", "gta5view.exe"
VALUE "ProductName", "gta5view"
VALUE "ProductVersion", "MAJOR_VER.MINOR_VER.PATCH_VERSTR_BUILD_VER"
END
END
END

View File

@ -1,4 +1,4 @@
#!/bin/bash #!/usr/bin/env bash
if [ $(git name-rev --tags --name-only $(git rev-parse HEAD)) == "undefined" ]; then 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') 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')
@ -9,34 +9,62 @@ export PACKAGE_VERSION=$(grep -oE '^[^\-]*' <<< $APPLICATION_VERSION)
export PACKAGE_BUILD=$(grep -oP '\-\K.+' <<< $APPLICATION_VERSION) export PACKAGE_BUILD=$(grep -oP '\-\K.+' <<< $APPLICATION_VERSION)
export EXECUTABLE_VERSION=${PACKAGE_VERSION}${PACKAGE_BUILD}${EXECUTABLE_TAG} 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 if [ "${PACKAGE_BUILD}" == "" ]; then
export PACKAGE_BUILD=1; export PACKAGE_BUILD=1
else
export APPLICATION_BUILD_INT_VERSION=$(grep -oE '[1-9]*$' <<< $PACKAGE_BUILD)
export APPLICATION_BUILD_STR_VERSION=-${PACKAGE_BUILD}
fi 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 if [ "${BUILD_TYPE}" == "ALPHA" ]; then
export QMAKE_BUILD_TYPE="DEFINES+=GTA5SYNC_BUILDTYPE_ALPHA" export CMAKE_BUILD_TYPE="-DGTA5VIEW_BUILDTYPE=Alpha"
export QMAKE_BUILD_TYPE="DEFINES+=GTA5SYNC_BUILDTYPE=\\\\\\\"Alpha\\\\\\\""
elif [ "${BUILD_TYPE}" == "Alpha" ]; then elif [ "${BUILD_TYPE}" == "Alpha" ]; then
export QMAKE_BUILD_TYPE="DEFINES+=GTA5SYNC_BUILDTYPE_ALPHA" export CMAKE_BUILD_TYPE="-DGTA5VIEW_BUILDTYPE=Alpha"
export QMAKE_BUILD_TYPE="DEFINES+=GTA5SYNC_BUILDTYPE=\\\\\\\"Alpha\\\\\\\""
elif [ "${BUILD_TYPE}" == "BETA" ]; then elif [ "${BUILD_TYPE}" == "BETA" ]; then
export QMAKE_BUILD_TYPE="DEFINES+=GTA5SYNC_BUILDTYPE_BETA" export CMAKE_BUILD_TYPE="-DGTA5VIEW_BUILDTYPE=Beta"
export QMAKE_BUILD_TYPE="DEFINES+=GTA5SYNC_BUILDTYPE=\\\\\\\"Beta\\\\\\\""
elif [ "${BUILD_TYPE}" == "Beta" ]; then elif [ "${BUILD_TYPE}" == "Beta" ]; then
export QMAKE_BUILD_TYPE="DEFINES+=GTA5SYNC_BUILDTYPE_BETA" export CMAKE_BUILD_TYPE="-DGTA5VIEW_BUILDTYPE=Beta"
export QMAKE_BUILD_TYPE="DEFINES+=GTA5SYNC_BUILDTYPE=\\\\\\\"Beta\\\\\\\""
elif [ "${BUILD_TYPE}" == "DEV" ]; then elif [ "${BUILD_TYPE}" == "DEV" ]; then
export QMAKE_BUILD_TYPE="DEFINES+=GTA5SYNC_BUILDTYPE_DEV" export CMAKE_BUILD_TYPE="-DGTA5VIEW_BUILDTYPE=Developer"
export QMAKE_BUILD_TYPE="DEFINES+=GTA5SYNC_BUILDTYPE=\\\\\\\"Developer\\\\\\\""
elif [ "${BUILD_TYPE}" == "Development" ]; then elif [ "${BUILD_TYPE}" == "Development" ]; then
export QMAKE_BUILD_TYPE="DEFINES+=GTA5SYNC_BUILDTYPE_DEV" export CMAKE_BUILD_TYPE="-DGTA5VIEW_BUILDTYPE=Developer"
export QMAKE_BUILD_TYPE="DEFINES+=GTA5SYNC_BUILDTYPE=\\\\\\\"Developer\\\\\\\""
elif [ "${BUILD_TYPE}" == "DAILY" ]; then elif [ "${BUILD_TYPE}" == "DAILY" ]; then
export QMAKE_BUILD_TYPE="DEFINES+=GTA5SYNC_BUILDTYPE_DAILY" export CMAKE_BUILD_TYPE="-DGTA5VIEW_BUILDTYPE=Daily Build"
export QMAKE_BUILD_TYPE="DEFINES+=GTA5SYNC_BUILDTYPE=\\\\\\\"Daily Build\\\\\\\""
elif [ "${BUILD_TYPE}" == "Daily" ]; then elif [ "${BUILD_TYPE}" == "Daily" ]; then
export QMAKE_BUILD_TYPE="DEFINES+=GTA5SYNC_BUILDTYPE_DAILY" export CMAKE_BUILD_TYPE="-DGTA5VIEW_BUILDTYPE=Daily Build"
export QMAKE_BUILD_TYPE="DEFINES+=GTA5SYNC_BUILDTYPE=\\\\\\\"Daily Build\\\\\\\""
elif [ "${BUILD_TYPE}" == "RC" ]; then elif [ "${BUILD_TYPE}" == "RC" ]; then
export QMAKE_BUILD_TYPE="DEFINES+=GTA5SYNC_BUILDTYPE_RC" export CMAKE_BUILD_TYPE="-DGTA5VIEW_BUILDTYPE=Release Candidate"
export QMAKE_BUILD_TYPE="DEFINES+=GTA5SYNC_BUILDTYPE=\\\\\\\"Release Candidate\\\\\\\""
elif [ "${BUILD_TYPE}" == "Release Candidate" ]; then elif [ "${BUILD_TYPE}" == "Release Candidate" ]; then
export QMAKE_BUILD_TYPE="DEFINES+=GTA5SYNC_BUILDTYPE_RC" export CMAKE_BUILD_TYPE="-DGTA5VIEW_BUILDTYPE=Release Candidate"
export QMAKE_BUILD_TYPE="DEFINES+=GTA5SYNC_BUILDTYPE=\\\\\\\"Release Candidate\\\\\\\""
elif [ "${BUILD_TYPE}" == "REL" ]; then elif [ "${BUILD_TYPE}" == "REL" ]; then
export QMAKE_BUILD_TYPE="DEFINES+=GTA5SYNC_BUILDTYPE_REL" export CMAKE_BUILD_TYPE="-DGTA5VIEW_BUILDTYPE=Release"
export QMAKE_BUILD_TYPE="DEFINES+=GTA5SYNC_BUILDTYPE=\\\\\\\"Release\\\\\\\""
elif [ "${BUILD_TYPE}" == "Release" ]; then elif [ "${BUILD_TYPE}" == "Release" ]; then
export QMAKE_BUILD_TYPE="DEFINES+=GTA5SYNC_BUILDTYPE_REL" export CMAKE_BUILD_TYPE="-DGTA5VIEW_BUILDTYPE=Release"
export QMAKE_BUILD_TYPE="DEFINES+=GTA5SYNC_BUILDTYPE=\\\\\\\"Release\\\\\\\""
fi fi
export PROJECT_DIR=$(pwd) export PROJECT_DIR=$(pwd)

View File

@ -1,33 +1,38 @@
#!/bin/bash #!/usr/bin/env bash
# Creating folders # Creating folders
cd ${PROJECT_DIR} && \ cd ${PROJECT_DIR} && \
echo "gta5view build version is ${APPLICATION_VERSION}" && \ echo "gta5view build version is ${APPLICATION_VERSION}" && \
mkdir -p build && \ mkdir -p build && \
mkdir -p assets && \ mkdir -p assets && \
chmod -x res/gta5sync_*.qm res/gta5view.desktop res/gta5view.png && \ chmod -x res/gta5sync_*.qm res/*.desktop res/*gta5view*.png && \
cd build && \ cd build && \
mkdir -p qt4 && \
cd qt4 && \
echo "Grand Theft Auto V Snapmatic and Savegame viewer/editor" > ./description-pak && \
cd .. && \
mkdir -p qt5 && \ mkdir -p qt5 && \
cd qt5 && \ cd qt5 && \
echo "Grand Theft Auto V Snapmatic and Savegame viewer/editor" > ./description-pak && \ echo "Grand Theft Auto V Snapmatic and Savegame viewer/editor" > ./description-pak && \
cd .. && \ cd .. && \
# Set compiler
export CC=clang && \
export CXX=clang++ && \
# Prepare checkinstall step # Prepare checkinstall step
mkdir -p /usr/share/gta5view && \ mkdir -p /usr/share/gta5view && \
# Starting build # Starting build
cd qt5 && \ cd qt5 && \
qmake -qt=5 -spec linux-clang GTA5SYNC_PREFIX=/usr QMAKE_CXXFLAGS+=-std=gnu++11 ${QMAKE_FLAGS_QT5} ${QMAKE_BUILD_TYPE} "DEFINES+=GTA5SYNC_BUILDCODE=\\\\\\\"${PACKAGE_CODE}\\\\\\\"" "DEFINES+=GTA5SYNC_APPVER=\\\\\\\"${APPLICATION_VERSION}\\\\\\\"" "DEFINES+=GTA5SYNC_COMMIT=\\\\\\\"${APPLICATION_COMMIT}\\\\\\\"" DEFINES+=GTA5SYNC_QCONF DEFINES+=GTA5SYNC_TELEMETRY "DEFINES+=GTA5SYNC_TELEMETRY_WEBURL=\\\\\\\"https://dev.syping.de/gta5view-userstats/\\\\\\\"" ../../gta5view.pro && \ cmake \
make depend && \ "-DCMAKE_INSTALL_PREFIX=/usr" \
"${CMAKE_BUILD_TYPE}" \
"-DFORCE_QT_VERSION=5" \
"-DGTA5VIEW_BUILDCODE=${PACKAGE_CODE}" \
"-DGTA5VIEW_APPVER=${APPLICATION_VERSION}" \
"-DGTA5VIEW_COMMIT=${APPLICATION_COMMIT}" \
"-DWITH_DONATE=ON" \
"-DWITH_TELEMETRY=ON" \
"-DDONATE_ADDRESSES=$(cat ${PROJECT_DIR}/.ci/donate.txt)" \
"-DTELEMETRY_WEBURL=https://dev.syping.de/gta5view-userstats/" \
"-DQCONF_BUILD=ON" \
../../ && \
make -j 4 && \ 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,libqt5widgets5,qttranslations5-l10n --conflicts=gta5view,gta5view-qt4 --replaces=gta5view,gta5view-qt4 --pakdir=${PROJECT_DIR}/assets && \ checkinstall -D --default --nodoc --install=no --pkgname=gta5view --pkgversion=${PACKAGE_VERSION} --pkgrelease=${PACKAGE_BUILD} --pkggroup=utility --maintainer="Syping \<dpkg@syping.de\>" --requires=libqt5core5a,libqt5gui5,libqt5network5,libqt5svg5,libqt5widgets5,qttranslations5-l10n --conflicts=gta5view-qt4,gta5view-qt5 --replaces=gta5view-qt4,gta5view-qt5 --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 depend && \
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,qtcore4-l10n --conflicts=gta5view,gta5view-qt5 --replaces=gta5view,gta5view-qt5 --pakdir=${PROJECT_DIR}/assets

View File

@ -1,4 +1,4 @@
#!/bin/bash #!/usr/bin/env bash
# Install packages # Install packages
.ci/debian_install.sh && \ .ci/debian_install.sh && \

View File

@ -1,15 +1,15 @@
#!/bin/bash #!/usr/bin/env bash
if [ "${DOCKER_USER}" != "" ]; then if [ "${DOCKER_USER}" != "" ]; then
DOCKER_IMAGE=${DOCKER_USER}/debian:${DEBIAN_VERSION} DOCKER_IMAGE=${DOCKER_USER}/debian:${DEBIAN_VERSION}
else else
DOCKER_IMAGE=debian:${DEBIAN_VERSION} DOCKER_IMAGE=debian:${DEBIAN_VERSION}
fi fi
PROJECT_DIR_DOCKER=/gta5view PROJECT_DIR_DOCKER=/gta5view
cd ${PROJECT_DIR} && \ cd ${PROJECT_DIR} && \
docker pull ${DOCKER_IMAGE} && \ docker pull ${DOCKER_IMAGE} && \
docker run --rm \ docker run --rm \
-v "${PROJECT_DIR}:${PROJECT_DIR_DOCKER}" \ -v "${PROJECT_DIR}:${PROJECT_DIR_DOCKER}" \
${DOCKER_IMAGE} \ ${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 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" /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 +1,13 @@
#!/bin/bash #!/usr/bin/env bash
# Source OS Release
source /etc/os-release
# When Debian add backports
if [ "${ID}" == "debian" ]; then
echo "deb http://deb.debian.org/debian ${VERSION_CODENAME}-backports main" >> /etc/apt/sources.list
fi
# Install packages # Install packages
apt-get update -qq && \ apt-get update -qq && \
apt-get install -qq ${APT_INSTALL} checkinstall dpkg-dev fakeroot g++ gcc qtbase5-dev qt5-qmake qttranslations5-l10n libqt4-dev apt-get install -qq ${APT_INSTALL} checkinstall cmake dpkg-dev fakeroot g++ gcc qtbase5-dev qt5-qmake qttranslations5-l10n libqt5svg5-dev

1
.ci/donate.txt Normal file
View File

@ -0,0 +1 @@
btc:187NSQSPzdMpQDGhxZAuw4AhZ7LgoAPV7D,eth:0x19d71DfCa86104d37a13D3c5d419936421CDC569,ltc:LKr6yvBoMMGmcxViS8Kc1A2sDjVSWTXn4m,xmr:43TB3ZMP5nk1pu5EQXRGPzdTKvmFEBGgccX3tNhRknLLiUYQ7z7dNedVHEA6WrWdByZv1isvFmjSGhCF7ddx3eRxFdm5Fzz

View File

@ -1,11 +1,12 @@
###################################################################### ######################################################################
!define APP_NAME "gta5view" !define APP_NAME "gta5view"
!define APP_EXT ".g5e"
!define COMP_NAME "Syping" !define COMP_NAME "Syping"
!define WEB_SITE "https://gta5view.syping.de/" !define WEB_SITE "https://gta5view.syping.de/"
!define VERSION "1.6.0.0" !define VERSION "1.10.2.0"
!define COPYRIGHT "Copyright © 2016-2018 Syping" !define COPYRIGHT "Copyright © 2016-2022 Syping"
!define DESCRIPTION "Grand Theft Auto V Savegame and Snapmatic Viewer/Editor" !define DESCRIPTION "Open Source Snapmatic and Savegame viewer/editor for GTA V"
!define INSTALLER_NAME "gta5view_setup.exe" !define INSTALLER_NAME "gta5view_setup.exe"
!define MAIN_APP_EXE "gta5view.exe" !define MAIN_APP_EXE "gta5view.exe"
!define INSTALL_TYPE "SetShellVarContext all" !define INSTALL_TYPE "SetShellVarContext all"
@ -33,6 +34,7 @@ Caption "${APP_NAME}"
OutFile "${INSTALLER_NAME}" OutFile "${INSTALLER_NAME}"
#BrandingText "${APP_NAME}" #BrandingText "${APP_NAME}"
XPStyle on XPStyle on
Unicode true
InstallDirRegKey "${REG_ROOT}" "${REG_APP_PATH}" "" InstallDirRegKey "${REG_ROOT}" "${REG_APP_PATH}" ""
InstallDir "$PROGRAMFILES64\Syping\gta5view" InstallDir "$PROGRAMFILES64\Syping\gta5view"
@ -78,6 +80,7 @@ InstallDir "$PROGRAMFILES64\Syping\gta5view"
!insertmacro MUI_LANGUAGE "English" !insertmacro MUI_LANGUAGE "English"
!insertmacro MUI_LANGUAGE "French" !insertmacro MUI_LANGUAGE "French"
!insertmacro MUI_LANGUAGE "German" !insertmacro MUI_LANGUAGE "German"
!insertmacro MUI_LANGUAGE "Korean"
!insertmacro MUI_LANGUAGE "Russian" !insertmacro MUI_LANGUAGE "Russian"
!insertmacro MUI_LANGUAGE "Ukrainian" !insertmacro MUI_LANGUAGE "Ukrainian"
!insertmacro MUI_LANGUAGE "TradChinese" !insertmacro MUI_LANGUAGE "TradChinese"
@ -101,48 +104,80 @@ Section -MainProgram
${INSTALL_TYPE} ${INSTALL_TYPE}
SetOverwrite ifnewer SetOverwrite ifnewer
SetOutPath "$INSTDIR" SetOutPath "$INSTDIR"
File "../build/release/gta5view.exe" File "../build/gta5view.exe"
File "/usr/lib/gcc/x86_64-w64-mingw32/6.3-win32/libgcc_s_seh-1.dll" File "/opt/llvm-mingw/x86_64-w64-mingw32/bin/libc++.dll"
File "/usr/lib/gcc/x86_64-w64-mingw32/6.3-win32/libstdc++-6.dll" File "/opt/llvm-mingw/x86_64-w64-mingw32/bin/libunwind.dll"
File "/opt/windev/libressl-latest_qt64d/bin/libcrypto-43.dll" File "/usr/local/lib/x86_64-w64-mingw32/openssl/bin/libcrypto-1_1-x64.dll"
File "/opt/windev/libressl-latest_qt64d/bin/libssl-45.dll" File "/usr/local/lib/x86_64-w64-mingw32/openssl/bin/libssl-1_1-x64.dll"
File "/opt/windev/libjpeg-turbo-latest_qt64d/bin/libjpeg-62.dll" File "/usr/local/lib/x86_64-w64-mingw32/qt5/bin/Qt5Core.dll"
File "/opt/windev/qt64d-latest/bin/Qt5Core.dll" File "/usr/local/lib/x86_64-w64-mingw32/qt5/bin/Qt5Gui.dll"
File "/opt/windev/qt64d-latest/bin/Qt5Gui.dll" File "/usr/local/lib/x86_64-w64-mingw32/qt5/bin/Qt5Network.dll"
File "/opt/windev/qt64d-latest/bin/Qt5Network.dll" File "/usr/local/lib/x86_64-w64-mingw32/qt5/bin/Qt5Svg.dll"
File "/opt/windev/qt64d-latest/bin/Qt5Svg.dll" File "/usr/local/lib/x86_64-w64-mingw32/qt5/bin/Qt5Widgets.dll"
File "/opt/windev/qt64d-latest/bin/Qt5Widgets.dll"
File "/opt/windev/qt64d-latest/bin/Qt5WinExtras.dll"
SetOutPath "$INSTDIR\lang" SetOutPath "$INSTDIR\lang"
File "../res/gta5sync_en_US.qm" File "../build/gta5sync_en_US.qm"
File "../res/gta5sync_de.qm" File "../build/gta5sync_de.qm"
File "../res/gta5sync_fr.qm" File "../build/gta5sync_fr.qm"
File "../res/gta5sync_ru.qm" File "../build/gta5sync_ko.qm"
File "../res/gta5sync_uk.qm" File "../build/gta5sync_ru.qm"
File "../res/gta5sync_zh_TW.qm" File "../build/gta5sync_uk.qm"
File "../res/qtbase_en_GB.qm" File "../build/gta5sync_zh_TW.qm"
File "../res/qtbase_de.qm" File "../build/qtbase_en_GB.qm"
File "../res/qtbase_fr.qm" File "../res/qt5/qtbase_de.qm"
File "../res/qtbase_ru.qm" File "../res/qt5/qtbase_fr.qm"
File "../res/qtbase_uk.qm" File "../res/qt5/qtbase_ko.qm"
File "../res/qtbase_zh_TW.qm" File "../res/qt5/qtbase_ru.qm"
SetOutPath "$INSTDIR\audio" File "../res/qt5/qtbase_uk.qm"
File "/opt/windev/qt64d-latest/plugins/audio/qtaudio_windows.dll" File "../res/qt5/qtbase_zh_TW.qm"
SetOutPath "$INSTDIR\resources"
File "../res/add.svgz"
File "../res/avatararea.png"
File "../res/avatarareaimport.png"
File "../res/back.svgz"
File "../res/flag-de.png"
File "../res/flag-fr.png"
File "../res/flag-gb.png"
File "../res/flag-kr.png"
File "../res/flag-ru.png"
File "../res/flag-tw.png"
File "../res/flag-ua.png"
File "../res/flag-us.png"
File "../res/gta5view-16.png"
File "../res/gta5view-24.png"
File "../res/gta5view-32.png"
File "../res/gta5view-40.png"
File "../res/gta5view-48.png"
File "../res/gta5view-64.png"
File "../res/gta5view-96.png"
File "../res/gta5view-128.png"
File "../res/gta5view-256.png"
File "../res/mapcayoperico.jpg"
File "../res/mappreview.jpg"
File "../res/next.svgz"
File "../res/pointmaker-8.png"
File "../res/pointmaker-16.png"
File "../res/pointmaker-24.png"
File "../res/pointmaker-32.png"
File "../res/savegame.svgz"
File "../res/watermark_1b.png"
File "../res/watermark_2b.png"
File "../res/watermark_2r.png"
SetOutPath "$INSTDIR\imageformats" SetOutPath "$INSTDIR\imageformats"
File "/opt/windev/qt64d-latest/plugins/imageformats/qgif.dll" File "/usr/local/lib/x86_64-w64-mingw32/qt5/plugins/imageformats/qgif.dll"
File "/opt/windev/qt64d-latest/plugins/imageformats/qicns.dll" File "/usr/local/lib/x86_64-w64-mingw32/qt5/plugins/imageformats/qicns.dll"
File "/opt/windev/qt64d-latest/plugins/imageformats/qico.dll" File "/usr/local/lib/x86_64-w64-mingw32/qt5/plugins/imageformats/qico.dll"
File "/opt/windev/qt64d-latest/plugins/imageformats/qjpeg.dll" File "/usr/local/lib/x86_64-w64-mingw32/qt5/plugins/imageformats/qjpeg.dll"
File "/opt/windev/qt64d-latest/plugins/imageformats/qsvg.dll" File "/usr/local/lib/x86_64-w64-mingw32/qt5/plugins/imageformats/qsvg.dll"
File "/opt/windev/qt64d-latest/plugins/imageformats/qtga.dll" File "/usr/local/lib/x86_64-w64-mingw32/qt5/plugins/imageformats/qtga.dll"
File "/opt/windev/qt64d-latest/plugins/imageformats/qtiff.dll" File "/usr/local/lib/x86_64-w64-mingw32/qt5/plugins/imageformats/qtiff.dll"
File "/opt/windev/qt64d-latest/plugins/imageformats/qwbmp.dll" File "/usr/local/lib/x86_64-w64-mingw32/qt5/plugins/imageformats/qwbmp.dll"
File "/opt/windev/qt64d-latest/plugins/imageformats/qwebp.dll" File "/usr/local/lib/x86_64-w64-mingw32/qt5/plugins/imageformats/qwebp.dll"
SetOutPath "$INSTDIR\platforms" SetOutPath "$INSTDIR\platforms"
File "/opt/windev/qt64d-latest/plugins/platforms/qwindows.dll" File "/usr/local/lib/x86_64-w64-mingw32/qt5/plugins/platforms/qwindows.dll"
SetOutPath "$INSTDIR\styles" SetOutPath "$INSTDIR\styles"
File "/opt/windev/qt64d-latest/plugins/styles/qcleanlooksstyle.dll" File "/usr/local/lib/x86_64-w64-mingw32/qt5/plugins/styles/qcleanlooksstyle.dll"
File "/opt/windev/qt64d-latest/plugins/styles/qplastiquestyle.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 SectionEnd
###################################################################### ######################################################################
@ -189,33 +224,88 @@ SectionEnd
###################################################################### ######################################################################
Section -ShellAssoc
WriteRegStr ${REG_ROOT} "Software\Classes\${APP_NAME}\DefaultIcon" "" "$INSTDIR\${MAIN_APP_EXE},0"
WriteRegStr ${REG_ROOT} "Software\Classes\${APP_NAME}\shell\open\command" "" '"$INSTDIR\${MAIN_APP_EXE}" "%1"'
WriteRegStr ${REG_ROOT} "Software\Classes\${APP_EXT}" "" "${APP_NAME}"
WriteRegStr ${REG_ROOT} "Software\Classes\${APP_EXT}" "Content Type" "application/x-gta5view-export"
System::Call 'SHELL32::SHChangeNotify(i0x8000000,i0,p0,p0)'
SectionEnd
######################################################################
Section -un.ShellAssoc
ClearErrors
ReadRegStr $0 ${REG_ROOT} "Software\Classes\${APP_EXT}" ""
DeleteRegKey ${REG_ROOT} "Software\Classes\${APP_NAME}"
${IfNot} ${Errors}
${AndIf} $0 == "${APP_NAME}"
DeleteRegValue ${REG_ROOT} "Software\Classes\${APP_EXT}" ""
DeleteRegKey /IfEmpty ${REG_ROOT} "Software\Classes\${APP_EXT}"
${EndIf}
System::Call 'SHELL32::SHChangeNotify(i0x8000000,i0,p0,p0)'
SectionEnd
######################################################################
Section Uninstall Section Uninstall
${INSTALL_TYPE} ${INSTALL_TYPE}
Delete "$INSTDIR\gta5view.exe" Delete "$INSTDIR\gta5view.exe"
Delete "$INSTDIR\libgcc_s_seh-1.dll" Delete "$INSTDIR\libc++.dll"
Delete "$INSTDIR\libstdc++-6.dll" Delete "$INSTDIR\libunwind.dll"
Delete "$INSTDIR\libcrypto-43.dll" Delete "$INSTDIR\libcrypto-1_1-x64.dll"
Delete "$INSTDIR\libssl-45.dll" Delete "$INSTDIR\libssl-1_1-x64.dll"
Delete "$INSTDIR\libjpeg-62.dll"
Delete "$INSTDIR\Qt5Core.dll" Delete "$INSTDIR\Qt5Core.dll"
Delete "$INSTDIR\Qt5Gui.dll" Delete "$INSTDIR\Qt5Gui.dll"
Delete "$INSTDIR\Qt5Network.dll" Delete "$INSTDIR\Qt5Network.dll"
Delete "$INSTDIR\Qt5Svg.dll" Delete "$INSTDIR\Qt5Svg.dll"
Delete "$INSTDIR\Qt5Widgets.dll" Delete "$INSTDIR\Qt5Widgets.dll"
Delete "$INSTDIR\Qt5WinExtras.dll"
Delete "$INSTDIR\lang\gta5sync_en_US.qm" Delete "$INSTDIR\lang\gta5sync_en_US.qm"
Delete "$INSTDIR\lang\gta5sync_de.qm" Delete "$INSTDIR\lang\gta5sync_de.qm"
Delete "$INSTDIR\lang\gta5sync_fr.qm" Delete "$INSTDIR\lang\gta5sync_fr.qm"
Delete "$INSTDIR\lang\gta5sync_ko.qm"
Delete "$INSTDIR\lang\gta5sync_ru.qm" Delete "$INSTDIR\lang\gta5sync_ru.qm"
Delete "$INSTDIR\lang\gta5sync_uk.qm" Delete "$INSTDIR\lang\gta5sync_uk.qm"
Delete "$INSTDIR\lang\gta5sync_zh_TW.qm" Delete "$INSTDIR\lang\gta5sync_zh_TW.qm"
Delete "$INSTDIR\lang\qtbase_en_GB.qm" Delete "$INSTDIR\lang\qtbase_en_GB.qm"
Delete "$INSTDIR\lang\qtbase_de.qm" Delete "$INSTDIR\lang\qtbase_de.qm"
Delete "$INSTDIR\lang\qtbase_fr.qm" Delete "$INSTDIR\lang\qtbase_fr.qm"
Delete "$INSTDIR\lang\qtbase_ko.qm"
Delete "$INSTDIR\lang\qtbase_ru.qm" Delete "$INSTDIR\lang\qtbase_ru.qm"
Delete "$INSTDIR\lang\qtbase_uk.qm" Delete "$INSTDIR\lang\qtbase_uk.qm"
Delete "$INSTDIR\lang\qtbase_zh_TW.qm" Delete "$INSTDIR\lang\qtbase_zh_TW.qm"
Delete "$INSTDIR\audio\qtaudio_windows.dll" Delete "$INSTDIR\resources\add.svgz"
Delete "$INSTDIR\resources\avatararea.png"
Delete "$INSTDIR\resources\avatarareaimport.png"
Delete "$INSTDIR\resources\back.svgz"
Delete "$INSTDIR\resources\flag-de.png"
Delete "$INSTDIR\resources\flag-fr.png"
Delete "$INSTDIR\resources\flag-gb.png"
Delete "$INSTDIR\resources\flag-kr.png"
Delete "$INSTDIR\resources\flag-ru.png"
Delete "$INSTDIR\resources\flag-tw.png"
Delete "$INSTDIR\resources\flag-ua.png"
Delete "$INSTDIR\resources\flag-us.png"
Delete "$INSTDIR\resources\gta5view-16.png"
Delete "$INSTDIR\resources\gta5view-24.png"
Delete "$INSTDIR\resources\gta5view-32.png"
Delete "$INSTDIR\resources\gta5view-40.png"
Delete "$INSTDIR\resources\gta5view-48.png"
Delete "$INSTDIR\resources\gta5view-64.png"
Delete "$INSTDIR\resources\gta5view-96.png"
Delete "$INSTDIR\resources\gta5view-128.png"
Delete "$INSTDIR\resources\gta5view-256.png"
Delete "$INSTDIR\resources\mapcayoperico.jpg"
Delete "$INSTDIR\resources\mappreview.jpg"
Delete "$INSTDIR\resources\next.svgz"
Delete "$INSTDIR\resources\pointmaker-8.png"
Delete "$INSTDIR\resources\pointmaker-16.png"
Delete "$INSTDIR\resources\pointmaker-24.png"
Delete "$INSTDIR\resources\pointmaker-32.png"
Delete "$INSTDIR\resources\savegame.svgz"
Delete "$INSTDIR\resources\watermark_1b.png"
Delete "$INSTDIR\resources\watermark_2b.png"
Delete "$INSTDIR\resources\watermark_2r.png"
Delete "$INSTDIR\imageformats\qgif.dll" Delete "$INSTDIR\imageformats\qgif.dll"
Delete "$INSTDIR\imageformats\qicns.dll" Delete "$INSTDIR\imageformats\qicns.dll"
Delete "$INSTDIR\imageformats\qico.dll" Delete "$INSTDIR\imageformats\qico.dll"
@ -228,8 +318,8 @@ Delete "$INSTDIR\imageformats\qwebp.dll"
Delete "$INSTDIR\platforms\qwindows.dll" Delete "$INSTDIR\platforms\qwindows.dll"
Delete "$INSTDIR\styles\qcleanlooksstyle.dll" Delete "$INSTDIR\styles\qcleanlooksstyle.dll"
Delete "$INSTDIR\styles\qplastiquestyle.dll" Delete "$INSTDIR\styles\qplastiquestyle.dll"
Delete "$INSTDIR\styles\qwindowsvistastyle.dll"
RmDir "$INSTDIR\lang" RmDir "$INSTDIR\lang"
RmDir "$INSTDIR\audio"
RmDir "$INSTDIR\imageformats" RmDir "$INSTDIR\imageformats"
RmDir "$INSTDIR\platforms" RmDir "$INSTDIR\platforms"
RmDir "$INSTDIR\styles" RmDir "$INSTDIR\styles"

View File

@ -1,4 +1,4 @@
#!/bin/bash #!/usr/bin/env bash
# Creating folders # Creating folders
cd ${PROJECT_DIR} && \ cd ${PROJECT_DIR} && \
@ -8,8 +8,17 @@ mkdir -p build && \
mkdir -p assets && \ mkdir -p assets && \
cd build && \ 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 && \ /usr/local/bin/cmake \
make depend && \ "-DCMAKE_PREFIX_PATH=/usr/local/opt/qt" \
"${CMAKE_BUILD_TYPE}" \
"-DGTA5VIEW_BUILDCODE=${PACKAGE_CODE}" \
"-DGTA5VIEW_APPVER=${APPLICATION_VERSION}" \
"-DGTA5VIEW_COMMIT=${APPLICATION_COMMIT}" \
"-DWITH_DONATE=ON" \
"-DWITH_TELEMETRY=ON" \
"-DDONATE_ADDRESSES=$(cat ${PROJECT_DIR}/.ci/donate.txt)" \
"-DTELEMETRY_WEBURL=https://dev.syping.de/gta5view-userstats/" \
../ && \
make -j 4 && \ make -j 4 && \
/usr/local/opt/qt/bin/macdeployqt gta5view.app -dmg && \ /usr/local/opt/qt/bin/macdeployqt gta5view.app -dmg && \
cp -Rf gta5view.dmg ../assets/gta5view-osx_${APPLICATION_VERSION}.dmg cp -Rf gta5view.dmg ../assets/gta5view-osx_${APPLICATION_VERSION}.dmg

View File

@ -1,4 +1,4 @@
#!/bin/bash #!/usr/bin/env bash
# Install packages # Install packages
.ci/osx_install.sh && \ .ci/osx_install.sh && \

View File

@ -1,4 +1,4 @@
#!/bin/bash #!/usr/bin/env bash
# Install packages # Install packages
brew install qt brew upgrade cmake qt

View File

@ -1,4 +1,4 @@
#!/bin/bash #!/usr/bin/env bash
# Prepare environment variable # Prepare environment variable
export GTA5VIEW_EXECUTABLE=gta5view-${EXECUTABLE_VERSION}${EXECUTABLE_ARCH}.exe && \ export GTA5VIEW_EXECUTABLE=gta5view-${EXECUTABLE_VERSION}${EXECUTABLE_ARCH}.exe && \
@ -12,9 +12,17 @@ mkdir -p assets && \
# Starting build # Starting build
cd build && \ cd build && \
qmake-static ${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 && \ mingw64-qt-cmake \
make depend && \ "${CMAKE_BUILD_TYPE}" \
"-DGTA5VIEW_BUILDCODE=${PACKAGE_CODE}" \
"-DGTA5VIEW_APPVER=${APPLICATION_VERSION}" \
"-DGTA5VIEW_COMMIT=${APPLICATION_COMMIT}" \
"-DWITH_DONATE=ON" \
"-DWITH_TELEMETRY=ON" \
"-DDONATE_ADDRESSES=$(cat ${PROJECT_DIR}/.ci/donate.txt)" \
"-DTELEMETRY_WEBURL=https://dev.syping.de/gta5view-userstats/" \
.. && \
make -j 4 && \ make -j 4 && \
cp -Rf release/*.exe ${PROJECT_DIR}/assets/${GTA5VIEW_EXECUTABLE} && \ x86_64-w64-mingw32-strip -s gta5view.exe && \
cd ${PROJECT_DIR}/assets && \ cp -Rf *.exe ${PROJECT_DIR}/assets/${GTA5VIEW_EXECUTABLE} && \
upx --best ${GTA5VIEW_EXECUTABLE} cd ${PROJECT_DIR}/assets

View File

@ -1,22 +1,25 @@
#!/bin/bash #!/usr/bin/env bash
QT_VERSION=5.9.6 DOCKER_IMAGE=sypingauto/gta5view-build:1.10-static
DOCKER_IMAGE=syping/qt5-static-mingw:${QT_VERSION}
PROJECT_DIR_DOCKER=/gta5view PROJECT_DIR_DOCKER=/gta5view
cd ${PROJECT_DIR} && \ cd ${PROJECT_DIR} && \
docker pull ${DOCKER_IMAGE} && \ docker pull ${DOCKER_IMAGE} && \
docker run --rm \ docker run --rm \
-v "${PROJECT_DIR}:${PROJECT_DIR_DOCKER}" \ -v "${PROJECT_DIR}:${PROJECT_DIR_DOCKER}" \
${DOCKER_IMAGE} \ ${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 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" && \ /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 # Prepare environment variable
export GTA5VIEW_EXECUTABLE=gta5view-${EXECUTABLE_VERSION}${EXECUTABLE_ARCH}.exe && \ export GTA5VIEW_EXECUTABLE=gta5view-${EXECUTABLE_VERSION}${EXECUTABLE_ARCH}.exe && \
# Upload Assets to Dropbox # Upload Assets to Dropbox
if [ "${PACKAGE_CODE}" == "gta5-mods" ]; then if [ "${PACKAGE_CODE}" == "gta5-mods" ]; then
${PROJECT_DIR}/.ci/dropbox_uploader.sh mkdir gta5-mods/${PACKAGE_VERSION} ${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} && \ ${PROJECT_DIR}/.ci/dropbox_uploader.sh upload ${PROJECT_DIR}/assets/${GTA5VIEW_EXECUTABLE} gta5-mods/${PACKAGE_VERSION}/${GTA5VIEW_EXECUTABLE} && \
rm -rf ${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 fi

View File

@ -1,8 +1,4 @@
#!/bin/bash #!/usr/bin/env bash
# Install nsis
apt-get update -qq && \
apt-get install -qq nsis && \
# Creating folders # Creating folders
cd ${PROJECT_DIR} && \ cd ${PROJECT_DIR} && \
@ -12,9 +8,22 @@ mkdir -p assets && \
# Starting build # Starting build
cd build && \ cd build && \
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/\\\\\\\"" DEFINES+=GTA5SYNC_QCONF DEFINES+=GTA5SYNC_INLANG='\\\"RUNDIR:SEPARATOR:lang\\\"' DEFINES+=GTA5SYNC_LANG='\\\"RUNDIR:SEPARATOR:lang\\\"' DEFINES+=GTA5SYNC_PLUG='\\\"RUNDIR:SEPARATOR:plugins\\\"' ../gta5view.pro && \ mingw64-qt-cmake \
make depend && \ "${CMAKE_BUILD_TYPE}" \
"-DGTA5VIEW_BUILDCODE=${PACKAGE_CODE}" \
"-DGTA5VIEW_APPVER=${APPLICATION_VERSION}" \
"-DGTA5VIEW_COMMIT=${APPLICATION_COMMIT}" \
"-DWITH_DONATE=ON" \
"-DWITH_TELEMETRY=ON" \
"-DDONATE_ADDRESSES=$(cat ${PROJECT_DIR}/.ci/donate.txt)" \
"-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 && \ make -j 4 && \
x86_64-w64-mingw32-strip -s gta5view.exe && \
cd ${PROJECT_DIR}/assets && \ cd ${PROJECT_DIR}/assets && \
makensis -NOCD ${PROJECT_DIR}/.ci/gta5view.nsi && \ makensis "-XTarget amd64-unicode" -NOCD ${PROJECT_DIR}/.ci/gta5view.nsi && \
mv -f gta5view_setup.exe gta5view-${EXECUTABLE_VERSION}_setup.exe mv -f gta5view_setup.exe gta5view-${EXECUTABLE_VERSION}_setup.exe

View File

@ -1,12 +1,11 @@
#!/bin/bash #!/usr/bin/env bash
QT_VERSION=5.9.6 DOCKER_IMAGE=sypingauto/gta5view-build:1.10-shared
DOCKER_IMAGE=syping/qt5-shared-mingw:${QT_VERSION}
PROJECT_DIR_DOCKER=/gta5view PROJECT_DIR_DOCKER=/gta5view
cd ${PROJECT_DIR} && \ cd ${PROJECT_DIR} && \
docker pull ${DOCKER_IMAGE} && \ docker pull ${DOCKER_IMAGE} && \
docker run --rm \ docker run --rm \
-v "${PROJECT_DIR}:${PROJECT_DIR_DOCKER}" \ -v "${PROJECT_DIR}:${PROJECT_DIR_DOCKER}" \
${DOCKER_IMAGE} \ ${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 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" /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"

36
.drone.yml Normal file
View File

@ -0,0 +1,36 @@
kind: pipeline
type: docker
environment:
BUILD_TYPE: "REL"
steps:
- name: Windows Installer
image: sypingauto/gta5view-build:1.10-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.10-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

Binary file not shown.

33
.drone/drone.sh Executable file
View File

@ -0,0 +1,33 @@
#!/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

@ -0,0 +1,22 @@
app-id: de.syping.gta5view
runtime: org.kde.Platform
runtime-version: '5.15-21.08'
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
- -DGTA5VIEW_BUILDCODE=Flatpak
- -DGTA5VIEW_BUILDTYPE=Release
sources:
- type: dir
path: ../

View File

@ -6,7 +6,7 @@ variables:
Windows Installer: Windows Installer:
stage: build stage: build
image: syping/qt5-shared-mingw:5.9.6 image: sypingauto/gta5view-build:1.10-shared
variables: variables:
BUILD_SCRIPT: "wininstall_build.sh" BUILD_SCRIPT: "wininstall_build.sh"
QT_SELECT: "qt5-x86_64-w64-mingw32" QT_SELECT: "qt5-x86_64-w64-mingw32"
@ -19,7 +19,7 @@ Windows Installer:
Windows Portable: Windows Portable:
stage: build stage: build
image: syping/qt5-static-mingw:5.9.6 image: sypingauto/gta5view-build:1.10-static
variables: variables:
BUILD_SCRIPT: "windows_build.sh" BUILD_SCRIPT: "windows_build.sh"
QT_SELECT: "qt5-x86_64-w64-mingw32" QT_SELECT: "qt5-x86_64-w64-mingw32"

View File

@ -1,12 +1,8 @@
#!/bin/bash #!/bin/bash
# Install curl, git, lua, nsis and openssl
apt-get update -qq && \
apt-get install -qq curl git lua5.2 nsis openssl
# Decrypt Telemetry Authenticator # Decrypt Telemetry Authenticator
rm -rf tmext/TelemetryClassAuthenticator.cpp && \ rm -rf tmext/TelemetryClassAuthenticator.cpp && \
openssl aes-256-cbc -k $tca_pass -in .gitlab/TelemetryClassAuthenticator.cpp.enc -out tmext/TelemetryClassAuthenticator.cpp -d openssl aes-256-cbc -k ${tca_pass} -in .gitlab/TelemetryClassAuthenticator.cpp.enc -out tmext/TelemetryClassAuthenticator.cpp -d
# Check if build is not tagged # Check if build is not tagged
if [ "${CI_COMMIT_TAG}" == "" ]; then if [ "${CI_COMMIT_TAG}" == "" ]; then

View File

@ -1,11 +1,11 @@
dist: trusty dist: bionic
sudo: required sudo: required
language: cpp language: cpp
service: services:
- docker - docker
env: env:
global: global:
- BUILD_TYPE=REL - BUILD_TYPE=REL
@ -15,23 +15,19 @@ matrix:
- env: - env:
- BUILD_SCRIPT=debian_docker.sh - BUILD_SCRIPT=debian_docker.sh
- RELEASE_LABEL="Debian 64-Bit Package" - RELEASE_LABEL="Debian 64-Bit Package"
- DEBIAN_VERSION=stretch - DEBIAN_VERSION=buster
- DOCKER_USER=amd64 - DOCKER_USER=amd64
- APT_INSTALL=clang - APT_INSTALL=clang
- env: - env:
- BUILD_SCRIPT=windows_docker.sh - BUILD_SCRIPT=windows_docker.sh
- QT_SELECT=qt5-x86_64-w64-mingw32 - QT_SELECT=qt5-x86_64-w64-mingw32
- RELEASE_LABEL="Windows 64-Bit Portable" - 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: - env:
- BUILD_SCRIPT=wininstall_docker.sh - BUILD_SCRIPT=wininstall_docker.sh
- QT_SELECT=qt5-x86_64-w64-mingw32 - QT_SELECT=qt5-x86_64-w64-mingw32
- RELEASE_LABEL="Windows 64-Bit Installer" - RELEASE_LABEL="Windows 64-Bit Installer"
- os: osx - os: osx
osx_image: xcode14.2
env: env:
- BUILD_SCRIPT=osx_ci.sh - BUILD_SCRIPT=osx_ci.sh
- RELEASE_LABEL="Mac OS X 64-Bit Disk Image" - RELEASE_LABEL="Mac OS X 64-Bit Disk Image"

View File

@ -1,11 +1,11 @@
#!/bin/bash #!/bin/bash
# Install curl and lua # Install lua
if [ "${TRAVIS_OS_NAME}" == "linux" ]; then if [ "${TRAVIS_OS_NAME}" == "osx" ]; then
sudo apt-get update -qq && \
sudo apt-get install -qq curl lua5.2
elif [ "${TRAVIS_OS_NAME}" == "osx" ]; then
brew install lua brew install lua
else
sudo apt-get update -qq && \
sudo apt-get install -qq lua5.2
fi fi
# Check if build is not tagged # Check if build is not tagged

View File

@ -1,6 +1,6 @@
/***************************************************************************** /*****************************************************************************
* gta5view Grand Theft Auto V Profile Viewer * gta5view Grand Theft Auto V Profile Viewer
* Copyright (C) 2016-2018 Syping * Copyright (C) 2016-2021 Syping
* *
* This program is free software: you can redistribute it and/or modify * This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by * it under the terms of the GNU General Public License as published by
@ -29,48 +29,47 @@ AboutDialog::AboutDialog(QWidget *parent) :
ui(new Ui::AboutDialog) ui(new Ui::AboutDialog)
{ {
// Set Window Flags // Set Window Flags
#if QT_VERSION >= 0x050900
setWindowFlag(Qt::WindowContextHelpButtonHint, false);
#else
setWindowFlags(windowFlags()^Qt::WindowContextHelpButtonHint); setWindowFlags(windowFlags()^Qt::WindowContextHelpButtonHint);
#endif
// Build Strings // Build Strings
QString appVersion = qApp->applicationVersion(); QString appVersion = QApplication::applicationVersion();
QString buildType = tr(GTA5SYNC_BUILDTYPE); const char* literalBuildType = GTA5SYNC_BUILDTYPE;
buildType.replace("_", " "); const QString buildType = tr(literalBuildType);
QString projectBuild = AppEnv::getBuildDateTime(); const QString projectBuild = AppEnv::getBuildDateTime();
QString buildStr = GTA5SYNC_BUILDSTRING; const QString buildStr = GTA5SYNC_BUILDSTRING;
#ifndef GTA5SYNC_BUILDTYPE_REL
#ifdef GTA5SYNC_COMMIT #ifdef GTA5SYNC_COMMIT
if (!appVersion.contains("-")) { appVersion = appVersion % "-" % GTA5SYNC_COMMIT; } if ((strcmp(literalBuildType, REL_BUILDTYPE) != 0) && !appVersion.contains("-"))
#endif appVersion = appVersion % "-" % GTA5SYNC_COMMIT;
#endif #endif
// Translator Comments // Translator Comments
//: Translated by translator, example Translated by Syping //: Translated by translator, example Translated by Syping
QString translatedByStr = tr("Translated by %1"); const 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 //: Insert your name here and profile here in following scheme, First Translator,First Profile\\nSecond Translator\\nThird Translator,Second Profile
QString translatorVal = tr("TRANSLATOR"); const QString translatorVal = tr("TRANSLATOR");
QStringList translatorContent; QStringList translatorContent;
if (translatorVal != "TRANSLATOR") if (translatorVal != "TRANSLATOR") {
{
const QStringList translatorList = translatorVal.split('\n'); const QStringList translatorList = translatorVal.split('\n');
for (const QString &translatorStr : translatorList) for (const QString &translatorStr : translatorList) {
{
QStringList translatorStrList = translatorStr.split(','); QStringList translatorStrList = translatorStr.split(',');
QString translatorName = translatorStrList.at(0); const QString translatorName = translatorStrList.at(0);
translatorStrList.removeFirst(); translatorStrList.removeFirst();
QString translatorProfile = translatorStrList.join(QString()); QString translatorProfile = translatorStrList.join(QString());
if (!translatorProfile.isEmpty()) if (!translatorProfile.isEmpty()) {
{
translatorContent += QString("<a href=\"%1\">%2</a>").arg(translatorProfile, translatorName); translatorContent += QString("<a href=\"%1\">%2</a>").arg(translatorProfile, translatorName);
} }
else else {
{
translatorContent += translatorName; translatorContent += translatorName;
} }
} }
} }
// Project Description // Project Description
QString projectDes = tr("A project for viewing Grand Theft Auto V Snapmatic<br/>\nPictures and Savegames"); const QString projectDes = tr("A project for viewing Grand Theft Auto V Snapmatic<br/>\nPictures and Savegames");
// Copyright Description // Copyright Description
QString copyrightDes1 = tr("Copyright &copy; <a href=\"%1\">%2</a> %3"); QString copyrightDes1 = tr("Copyright &copy; <a href=\"%1\">%2</a> %3");
@ -78,40 +77,34 @@ AboutDialog::AboutDialog(QWidget *parent) :
QString copyrightDes2 = tr("%1 is licensed under <a href=\"https://www.gnu.org/licenses/gpl-3.0.html#content\">GNU GPLv3</a>"); 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); copyrightDes2 = copyrightDes2.arg(GTA5SYNC_APPSTR);
QString copyrightDesA; QString copyrightDesA;
if (!translatorContent.isEmpty()) if (!translatorContent.isEmpty()) {
{
copyrightDesA = copyrightDes1 % "<br/>" % translatedByStr.arg(translatorContent.join(", ")) % "<br/>" % copyrightDes2; copyrightDesA = copyrightDes1 % "<br/>" % translatedByStr.arg(translatorContent.join(", ")) % "<br/>" % copyrightDes2;
} }
else else {
{
copyrightDesA = copyrightDes1 % "<br/>" % copyrightDes2; copyrightDesA = copyrightDes1 % "<br/>" % copyrightDes2;
} }
// Setup User Interface // Setup User Interface
ui->setupUi(this); ui->setupUi(this);
aboutStr = ui->labAbout->text(); aboutStr = ui->labAbout->text();
titleStr = this->windowTitle(); titleStr = windowTitle();
ui->labAbout->setText(aboutStr.arg(GTA5SYNC_APPSTR, projectDes, appVersion % " (" % buildType % ")", projectBuild, buildStr, qVersion(), copyrightDesA)); ui->labAbout->setText(aboutStr.arg(GTA5SYNC_APPSTR, projectDes, appVersion % " (" % buildType % ")", projectBuild, buildStr, qVersion(), copyrightDesA));
this->setWindowTitle(titleStr.arg(GTA5SYNC_APPSTR)); setWindowTitle(titleStr.arg(GTA5SYNC_APPSTR));
// Set Icon for Close Button // Set Icon for Close Button
if (QIcon::hasThemeIcon("dialog-close")) if (QIcon::hasThemeIcon("dialog-close")) {
{
ui->cmdClose->setIcon(QIcon::fromTheme("dialog-close")); ui->cmdClose->setIcon(QIcon::fromTheme("dialog-close"));
} }
else if (QIcon::hasThemeIcon("gtk-close")) else if (QIcon::hasThemeIcon("gtk-close")) {
{
ui->cmdClose->setIcon(QIcon::fromTheme("gtk-close")); ui->cmdClose->setIcon(QIcon::fromTheme("gtk-close"));
} }
// DPI calculation // DPI calculation
qreal screenRatio = AppEnv::screenRatio(); qreal screenRatio = AppEnv::screenRatio();
if (!translatorContent.isEmpty()) if (!translatorContent.isEmpty()) {
{
resize(375 * screenRatio, 270 * screenRatio); resize(375 * screenRatio, 270 * screenRatio);
} }
else else {
{
resize(375 * screenRatio, 260 * screenRatio); resize(375 * screenRatio, 260 * screenRatio);
} }
} }
@ -123,13 +116,11 @@ AboutDialog::~AboutDialog()
void AboutDialog::on_labAbout_linkActivated(const QString &link) void AboutDialog::on_labAbout_linkActivated(const QString &link)
{ {
if (link.left(12) == "g5e://about?") if (link.left(12) == "g5e://about?") {
{
QStringList aboutStrList = QString(link).remove(0, 12).split(":"); 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()))); QMessageBox::information(this, QString::fromUtf8(QByteArray::fromBase64(aboutStrList.at(0).toUtf8())), QString::fromUtf8(QByteArray::fromBase64(aboutStrList.at(1).toUtf8())));
} }
else else {
{
QDesktopServices::openUrl(QUrl(link)); QDesktopServices::openUrl(QUrl(link));
} }
} }

View File

@ -1,6 +1,6 @@
/***************************************************************************** /*****************************************************************************
* gta5view Grand Theft Auto V Profile Viewer * gta5view Grand Theft Auto V Profile Viewer
* Copyright (C) 2016-2017 Syping * Copyright (C) 2016-2021 Syping
* *
* This program is free software: you can redistribute it and/or modify * This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by * it under the terms of the GNU General Public License as published by
@ -28,7 +28,6 @@ class AboutDialog;
class AboutDialog : public QDialog class AboutDialog : public QDialog
{ {
Q_OBJECT Q_OBJECT
public: public:
explicit AboutDialog(QWidget *parent = 0); explicit AboutDialog(QWidget *parent = 0);
~AboutDialog(); ~AboutDialog();

View File

@ -26,7 +26,7 @@
</sizepolicy> </sizepolicy>
</property> </property>
<property name="text"> <property name="text">
<string>&lt;span style=&quot; font-weight:600;&quot;&gt;%1&lt;/span&gt;&lt;br/&gt; <string>&lt;span style=&quot;font-weight:600&quot;&gt;%1&lt;/span&gt;&lt;br/&gt;
&lt;br/&gt; &lt;br/&gt;
%2&lt;br/&gt; %2&lt;br/&gt;
&lt;br/&gt; &lt;br/&gt;

View File

@ -1,6 +1,6 @@
/***************************************************************************** /*****************************************************************************
* gta5view Grand Theft Auto V Profile Viewer * gta5view Grand Theft Auto V Profile Viewer
* Copyright (C) 2016-2017 Syping * Copyright (C) 2016-2021 Syping
* *
* This program is free software: you can redistribute it and/or modify * This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by * it under the terms of the GNU General Public License as published by
@ -22,19 +22,19 @@
#include "StandardPaths.h" #include "StandardPaths.h"
#include <QtGlobal> #include <QtGlobal>
#include <QStringBuilder> #include <QStringBuilder>
#include <QDesktopWidget>
#include <QApplication> #include <QApplication>
#include <QSettings> #include <QSettings>
#include <QScreen> #include <QScreen>
#include <QDebug> #include <QDebug>
#include <QRect> #include <QRect>
#include <QDir> #include <QDir>
#include <iostream>
using namespace std; #if QT_VERSION < 0x050000
#include <QDesktopWidget>
#endif
AppEnv::AppEnv() AppEnv::AppEnv()
{ {
} }
// Build Stuff // Build Stuff
@ -55,18 +55,17 @@ QString AppEnv::getGameFolder(bool *ok)
{ {
QDir dir; QDir dir;
QString GTAV_FOLDER = QString::fromUtf8(qgetenv("GTAV_FOLDER")); QString GTAV_FOLDER = QString::fromUtf8(qgetenv("GTAV_FOLDER"));
if (GTAV_FOLDER != "") if (GTAV_FOLDER != "") {
{
dir.setPath(GTAV_FOLDER); dir.setPath(GTAV_FOLDER);
if (dir.exists()) if (dir.exists()) {
{ if (ok != NULL)
if (ok != NULL) *ok = true; *ok = true;
qputenv("GTAV_FOLDER", dir.absolutePath().toUtf8()); qputenv("GTAV_FOLDER", dir.absolutePath().toUtf8());
return dir.absolutePath(); return dir.absolutePath();
} }
} }
QString GTAV_defaultFolder = StandardPaths::documentsLocation() % QDir::separator() % "Rockstar Games" % QDir::separator() % "GTA V"; const QString GTAV_defaultFolder = StandardPaths::documentsLocation() % "/Rockstar Games/GTA V";
QString GTAV_returnFolder = GTAV_defaultFolder; QString GTAV_returnFolder = GTAV_defaultFolder;
QSettings settings(GTA5SYNC_APPVENDOR, GTA5SYNC_APPSTR); QSettings settings(GTA5SYNC_APPVENDOR, GTA5SYNC_APPSTR);
@ -75,46 +74,44 @@ QString AppEnv::getGameFolder(bool *ok)
GTAV_returnFolder = settings.value("dir", GTAV_defaultFolder).toString(); GTAV_returnFolder = settings.value("dir", GTAV_defaultFolder).toString();
settings.endGroup(); settings.endGroup();
if (forceDir) if (forceDir) {
{
dir.setPath(GTAV_returnFolder); dir.setPath(GTAV_returnFolder);
if (dir.exists()) if (dir.exists()) {
{ if (ok != 0)
if (ok != 0) *ok = true; *ok = true;
qputenv("GTAV_FOLDER", dir.absolutePath().toUtf8()); qputenv("GTAV_FOLDER", dir.absolutePath().toUtf8());
return dir.absolutePath(); return dir.absolutePath();
} }
} }
dir.setPath(GTAV_defaultFolder); dir.setPath(GTAV_defaultFolder);
if (dir.exists()) if (dir.exists()) {
{ if (ok != 0)
if (ok != 0) *ok = true; *ok = true;
qputenv("GTAV_FOLDER", dir.absolutePath().toUtf8()); qputenv("GTAV_FOLDER", dir.absolutePath().toUtf8());
return dir.absolutePath(); return dir.absolutePath();
} }
if (!forceDir) if (!forceDir) {
{
dir.setPath(GTAV_returnFolder); dir.setPath(GTAV_returnFolder);
if (dir.exists()) if (dir.exists()) {
{ if (ok != 0)
if (ok != 0) *ok = true; *ok = true;
qputenv("GTAV_FOLDER", dir.absolutePath().toUtf8()); qputenv("GTAV_FOLDER", dir.absolutePath().toUtf8());
return dir.absolutePath(); return dir.absolutePath();
} }
} }
if (ok != 0) *ok = false; if (ok != 0)
return ""; *ok = false;
return QString();
} }
bool AppEnv::setGameFolder(QString gameFolder) bool AppEnv::setGameFolder(QString gameFolder)
{ {
QDir dir; QDir dir;
dir.setPath(gameFolder); dir.setPath(gameFolder);
if (dir.exists()) if (dir.exists()) {
{
qputenv("GTAV_FOLDER", dir.absolutePath().toUtf8()); qputenv("GTAV_FOLDER", dir.absolutePath().toUtf8());
return true; return true;
} }
@ -132,13 +129,13 @@ QString AppEnv::getInLangFolder()
#ifdef GTA5SYNC_INLANG #ifdef GTA5SYNC_INLANG
return StringParser::convertBuildedString(GTA5SYNC_INLANG); return StringParser::convertBuildedString(GTA5SYNC_INLANG);
#else #else
return StringParser::convertBuildedString(GTA5SYNC_SHARE % QLatin1String("SEPARATOR:APPNAME:SEPARATOR:translations")); return StringParser::convertBuildedString(GTA5SYNC_SHARE % QLatin1String("/APPNAME:/translations"));
#endif #endif
#else #else
#ifdef GTA5SYNC_INLANG #ifdef GTA5SYNC_INLANG
return StringParser::convertBuildedString(GTA5SYNC_INLANG); return StringParser::convertBuildedString(GTA5SYNC_INLANG);
#else #else
return QString(":/tr"); return QLatin1String(":/tr");
#endif #endif
#endif #endif
} }
@ -148,32 +145,45 @@ QString AppEnv::getPluginsFolder()
return StringParser::convertBuildedString(GTA5SYNC_PLUG); return StringParser::convertBuildedString(GTA5SYNC_PLUG);
} }
QString AppEnv::getImagesFolder()
{
#if defined(GTA5SYNC_QCONF) && defined(GTA5SYNC_CMAKE)
#ifdef Q_OS_WIN
return StringParser::convertBuildedString(GTA5SYNC_SHARE % QLatin1String("/resources"));
#else
return StringParser::convertBuildedString(GTA5SYNC_SHARE % QLatin1String("/APPNAME:/resources"));
#endif
#else
return QLatin1String(":/img");
#endif
}
QString AppEnv::getShareFolder()
{
return StringParser::convertBuildedString(GTA5SYNC_SHARE);
}
// Web Stuff // Web Stuff
QByteArray AppEnv::getUserAgent() QByteArray AppEnv::getUserAgent()
{ {
#if QT_VERSION >= 0x050400 #if QT_VERSION >= 0x050400
#ifdef GTA5SYNC_WIN #ifdef Q_OS_WIN
QString kernelVersion = QSysInfo::kernelVersion(); QString kernelVersion = QSysInfo::kernelVersion();
const QStringList &kernelVersionList = kernelVersion.split("."); const QStringList &kernelVersionList = kernelVersion.split(".");
if (kernelVersionList.length() > 2) if (kernelVersionList.length() > 2) {
{
kernelVersion = kernelVersionList.at(0) % "." % kernelVersionList.at(1); kernelVersion = kernelVersionList.at(0) % "." % kernelVersionList.at(1);
} }
QString runArch = QSysInfo::buildCpuArchitecture(); QString runArch = QSysInfo::buildCpuArchitecture();
if (runArch == "x86_64") if (runArch == "x86_64") {
{
runArch = "Win64; x64"; runArch = "Win64; x64";
} }
else if (runArch == "i686") else if (runArch == "i686") {
{
const QString &curArch = QSysInfo::currentCpuArchitecture(); const QString &curArch = QSysInfo::currentCpuArchitecture();
if (curArch == "x86_64") if (curArch == "x86_64") {
{
runArch = "WOW64"; runArch = "WOW64";
} }
else if (curArch == "i686") else if (curArch == "i686") {
{
runArch = "Win32; x86"; runArch = "Win32; x86";
} }
} }
@ -186,11 +196,6 @@ QByteArray AppEnv::getUserAgent()
#endif #endif
} }
// QUrl AppEnv::getCrewFetchingUrl(QString crewID)
// {
// return QUrl(QString("https://socialclub.rockstargames.com/reference/crewfeed/%1").arg(crewID));
// }
QUrl AppEnv::getCrewFetchingUrl(QString crewID) QUrl AppEnv::getCrewFetchingUrl(QString crewID)
{ {
return QUrl(QString("https://socialclub.rockstargames.com/crew/%1/%1").arg(crewID)); return QUrl(QString("https://socialclub.rockstargames.com/crew/%1/%1").arg(crewID));
@ -210,7 +215,7 @@ QUrl AppEnv::getPlayerFetchingUrl(QString crewID, int pageNumber)
GameVersion AppEnv::getGameVersion() GameVersion AppEnv::getGameVersion()
{ {
#ifdef GTA5SYNC_WIN #ifdef Q_OS_WIN
QString argumentValue; QString argumentValue;
#ifdef _WIN64 #ifdef _WIN64
argumentValue = "\\WOW6432Node"; argumentValue = "\\WOW6432Node";
@ -219,8 +224,7 @@ GameVersion AppEnv::getGameVersion()
QString installFolderSc = registrySettingsSc.value("InstallFolder", "").toString(); QString installFolderSc = registrySettingsSc.value("InstallFolder", "").toString();
QDir installFolderScDir(installFolderSc); QDir installFolderScDir(installFolderSc);
bool scVersionInstalled = false; bool scVersionInstalled = false;
if (!installFolderSc.isEmpty() && installFolderScDir.exists()) if (!installFolderSc.isEmpty() && installFolderScDir.exists()) {
{
#ifdef GTA5SYNC_DEBUG #ifdef GTA5SYNC_DEBUG
qDebug() << "gameVersionFoundSocialClubVersion"; qDebug() << "gameVersionFoundSocialClubVersion";
#endif #endif
@ -229,34 +233,28 @@ GameVersion AppEnv::getGameVersion()
QSettings registrySettingsSteam(QString("HKEY_LOCAL_MACHINE\\SOFTWARE%1\\Rockstar Games\\GTAV").arg(argumentValue), QSettings::NativeFormat); QSettings registrySettingsSteam(QString("HKEY_LOCAL_MACHINE\\SOFTWARE%1\\Rockstar Games\\GTAV").arg(argumentValue), QSettings::NativeFormat);
QString installFolderSteam = registrySettingsSteam.value("installfoldersteam", "").toString(); QString installFolderSteam = registrySettingsSteam.value("installfoldersteam", "").toString();
if (installFolderSteam.right(5) == "\\GTAV") if (installFolderSteam.right(5) == "\\GTAV") {
{
installFolderSteam = installFolderSteam.remove(installFolderSteam.length() - 5, 5); installFolderSteam = installFolderSteam.remove(installFolderSteam.length() - 5, 5);
} }
QDir installFolderSteamDir(installFolderSteam); QDir installFolderSteamDir(installFolderSteam);
bool steamVersionInstalled = false; bool steamVersionInstalled = false;
if (!installFolderSteam.isEmpty() && installFolderSteamDir.exists()) if (!installFolderSteam.isEmpty() && installFolderSteamDir.exists()) {
{
#ifdef GTA5SYNC_DEBUG #ifdef GTA5SYNC_DEBUG
qDebug() << "gameVersionFoundSteamVersion"; qDebug() << "gameVersionFoundSteamVersion";
#endif #endif
steamVersionInstalled = true; steamVersionInstalled = true;
} }
if (scVersionInstalled && steamVersionInstalled) if (scVersionInstalled && steamVersionInstalled) {
{
return GameVersion::BothVersions; return GameVersion::BothVersions;
} }
else if (scVersionInstalled) else if (scVersionInstalled) {
{
return GameVersion::SocialClubVersion; return GameVersion::SocialClubVersion;
} }
else if (steamVersionInstalled) else if (steamVersionInstalled) {
{
return GameVersion::SteamVersion; return GameVersion::SteamVersion;
} }
else else {
{
return GameVersion::NoVersion; return GameVersion::NoVersion;
} }
#else #else
@ -266,9 +264,8 @@ GameVersion AppEnv::getGameVersion()
GameLanguage AppEnv::getGameLanguage(GameVersion gameVersion) GameLanguage AppEnv::getGameLanguage(GameVersion gameVersion)
{ {
if (gameVersion == GameVersion::SocialClubVersion) if (gameVersion == GameVersion::SocialClubVersion) {
{ #ifdef Q_OS_WIN
#ifdef GTA5SYNC_WIN
QString argumentValue; QString argumentValue;
#ifdef _WIN64 #ifdef _WIN64
argumentValue = "\\WOW6432Node"; argumentValue = "\\WOW6432Node";
@ -280,9 +277,8 @@ GameLanguage AppEnv::getGameLanguage(GameVersion gameVersion)
return GameLanguage::Undefined; return GameLanguage::Undefined;
#endif #endif
} }
else if (gameVersion == GameVersion::SteamVersion) else if (gameVersion == GameVersion::SteamVersion) {
{ #ifdef Q_OS_WIN
#ifdef GTA5SYNC_WIN
QString argumentValue; QString argumentValue;
#ifdef _WIN64 #ifdef _WIN64
argumentValue = "\\WOW6432Node"; argumentValue = "\\WOW6432Node";
@ -294,128 +290,81 @@ GameLanguage AppEnv::getGameLanguage(GameVersion gameVersion)
return GameLanguage::Undefined; return GameLanguage::Undefined;
#endif #endif
} }
else return GameLanguage::Undefined;
{
return GameLanguage::Undefined;
}
} }
GameLanguage AppEnv::gameLanguageFromString(QString gameLanguage) GameLanguage AppEnv::gameLanguageFromString(QString gameLanguage)
{ {
if (gameLanguage == "en-US") if (gameLanguage == "en-US") {
{
return GameLanguage::English; return GameLanguage::English;
} }
else if (gameLanguage == "fr-FR") else if (gameLanguage == "fr-FR") {
{
return GameLanguage::French; return GameLanguage::French;
} }
else if (gameLanguage == "it-IT") else if (gameLanguage == "it-IT") {
{
return GameLanguage::Italian; return GameLanguage::Italian;
} }
else if (gameLanguage == "de-DE") else if (gameLanguage == "de-DE") {
{
return GameLanguage::German; return GameLanguage::German;
} }
else if (gameLanguage == "es-ES") else if (gameLanguage == "es-ES") {
{
return GameLanguage::Spanish; return GameLanguage::Spanish;
} }
else if (gameLanguage == "es-MX") else if (gameLanguage == "es-MX") {
{
return GameLanguage::Mexican; return GameLanguage::Mexican;
} }
else if (gameLanguage == "pt-BR") else if (gameLanguage == "pt-BR") {
{
return GameLanguage::Brasilian; return GameLanguage::Brasilian;
} }
else if (gameLanguage == "ru-RU") else if (gameLanguage == "ru-RU") {
{
return GameLanguage::Russian; return GameLanguage::Russian;
} }
else if (gameLanguage == "pl-PL") else if (gameLanguage == "pl-PL") {
{
return GameLanguage::Polish; return GameLanguage::Polish;
} }
else if (gameLanguage == "ja-JP") else if (gameLanguage == "ja-JP") {
{
return GameLanguage::Japanese; return GameLanguage::Japanese;
} }
else if (gameLanguage == "zh-CHS") else if (gameLanguage == "zh-CHS") {
{
return GameLanguage::SChinese; return GameLanguage::SChinese;
} }
else if (gameLanguage == "zh-CHT") else if (gameLanguage == "zh-CHT") {
{
return GameLanguage::TChinese; return GameLanguage::TChinese;
} }
else if (gameLanguage == "ko-KR") else if (gameLanguage == "ko-KR") {
{ return GameLanguage::Korean;
return GameLanguage::Koreana;
}
else
{
return GameLanguage::Undefined;
} }
return GameLanguage::Undefined;
} }
QString AppEnv::gameLanguageToString(GameLanguage gameLanguage) QString AppEnv::gameLanguageToString(GameLanguage gameLanguage)
{ {
if (gameLanguage == GameLanguage::English) switch (gameLanguage) {
{ case GameLanguage::English:
return "en-US"; return "en-US";
} case GameLanguage::French:
else if (gameLanguage == GameLanguage::French)
{
return "fr-FR"; return "fr-FR";
} case GameLanguage::Italian:
else if (gameLanguage == GameLanguage::Italian)
{
return "it-IT"; return "it-IT";
} case GameLanguage::German:
else if (gameLanguage == GameLanguage::German)
{
return "de-DE"; return "de-DE";
} case GameLanguage::Spanish:
else if (gameLanguage == GameLanguage::Spanish)
{
return "es-ES"; return "es-ES";
} case GameLanguage::Mexican:
else if (gameLanguage == GameLanguage::Mexican)
{
return "es-MX"; return "es-MX";
} case GameLanguage::Brasilian:
else if (gameLanguage == GameLanguage::Brasilian)
{
return "pt-BR"; return "pt-BR";
} case GameLanguage::Polish:
else if (gameLanguage == GameLanguage::Russian)
{
return "ru-RU";
}
else if (gameLanguage == GameLanguage::Polish)
{
return "pl-PL"; return "pl-PL";
} case GameLanguage::Japanese:
else if (gameLanguage == GameLanguage::Japanese)
{
return "ja-JP"; return "ja-JP";
} case GameLanguage::SChinese:
else if (gameLanguage == GameLanguage::SChinese)
{
return "zh-CHS"; return "zh-CHS";
} case GameLanguage::TChinese:
else if (gameLanguage == GameLanguage::TChinese)
{
return "zh-CHT"; return "zh-CHT";
} case GameLanguage::Korean:
else if (gameLanguage == GameLanguage::Koreana)
{
return "ko-KR"; return "ko-KR";
} default:
else
{
return "Undefinied"; return "Undefinied";
} }
} }
@ -424,67 +373,55 @@ bool AppEnv::setGameLanguage(GameVersion gameVersion, GameLanguage gameLanguage)
{ {
bool socialClubVersion = false; bool socialClubVersion = false;
bool steamVersion = false; bool steamVersion = false;
if (gameVersion == GameVersion::SocialClubVersion) if (gameVersion == GameVersion::SocialClubVersion) {
{
socialClubVersion = true; socialClubVersion = true;
} }
else if (gameVersion == GameVersion::SteamVersion) else if (gameVersion == GameVersion::SteamVersion) {
{
steamVersion = true; steamVersion = true;
} }
else if (gameVersion == GameVersion::BothVersions) else if (gameVersion == GameVersion::BothVersions) {
{
socialClubVersion = true; socialClubVersion = true;
steamVersion = true; steamVersion = true;
} }
else else {
{
return false; return false;
} }
if (socialClubVersion) if (socialClubVersion) {
{ #ifdef Q_OS_WIN
#ifdef GTA5SYNC_WIN
QString argumentValue; QString argumentValue;
#ifdef _WIN64 #ifdef _WIN64
argumentValue = "\\WOW6432Node"; argumentValue = "\\WOW6432Node";
#endif #endif
QSettings registrySettingsSc(QString("HKEY_LOCAL_MACHINE\\SOFTWARE%1\\Rockstar Games\\Grand Theft Auto V").arg(argumentValue), QSettings::NativeFormat); QSettings registrySettingsSc(QString("HKEY_LOCAL_MACHINE\\SOFTWARE%1\\Rockstar Games\\Grand Theft Auto V").arg(argumentValue), QSettings::NativeFormat);
if (gameLanguage != GameLanguage::Undefined) if (gameLanguage != GameLanguage::Undefined) {
{
registrySettingsSc.setValue("Language", gameLanguageToString(gameLanguage)); registrySettingsSc.setValue("Language", gameLanguageToString(gameLanguage));
} }
else else {
{
registrySettingsSc.remove("Language"); registrySettingsSc.remove("Language");
} }
registrySettingsSc.sync(); registrySettingsSc.sync();
if (registrySettingsSc.status() != QSettings::NoError) if (registrySettingsSc.status() != QSettings::NoError) {
{
return false; return false;
} }
#else #else
Q_UNUSED(gameLanguage) Q_UNUSED(gameLanguage)
#endif #endif
} }
if (steamVersion) if (steamVersion) {
{ #ifdef Q_OS_WIN
#ifdef GTA5SYNC_WIN
QString argumentValue; QString argumentValue;
#ifdef _WIN64 #ifdef _WIN64
argumentValue = "\\WOW6432Node"; argumentValue = "\\WOW6432Node";
#endif #endif
QSettings registrySettingsSteam(QString("HKEY_LOCAL_MACHINE\\SOFTWARE%1\\Rockstar Games\\Grand Theft Auto V Steam").arg(argumentValue), QSettings::NativeFormat); QSettings registrySettingsSteam(QString("HKEY_LOCAL_MACHINE\\SOFTWARE%1\\Rockstar Games\\Grand Theft Auto V Steam").arg(argumentValue), QSettings::NativeFormat);
if (gameLanguage != GameLanguage::Undefined) if (gameLanguage != GameLanguage::Undefined) {
{
registrySettingsSteam.setValue("Language", gameLanguageToString(gameLanguage)); registrySettingsSteam.setValue("Language", gameLanguageToString(gameLanguage));
} }
else else {
{
registrySettingsSteam.remove("Language"); registrySettingsSteam.remove("Language");
} }
registrySettingsSteam.sync(); registrySettingsSteam.sync();
if (registrySettingsSteam.status() != QSettings::NoError) if (registrySettingsSteam.status() != QSettings::NoError) {
{
return false; return false;
} }
#else #else
@ -499,9 +436,9 @@ bool AppEnv::setGameLanguage(GameVersion gameVersion, GameLanguage gameLanguage)
qreal AppEnv::screenRatio() qreal AppEnv::screenRatio()
{ {
#if QT_VERSION >= 0x050000 #if QT_VERSION >= 0x050000
qreal dpi = QGuiApplication::primaryScreen()->logicalDotsPerInch(); qreal dpi = QApplication::primaryScreen()->logicalDotsPerInch();
#else #else
qreal dpi = qApp->desktop()->logicalDpiX(); qreal dpi = QApplication::desktop()->logicalDpiX();
#endif #endif
#ifdef Q_OS_MAC #ifdef Q_OS_MAC
return (dpi / 72); return (dpi / 72);
@ -509,3 +446,12 @@ qreal AppEnv::screenRatio()
return (dpi / 96); return (dpi / 96);
#endif #endif
} }
qreal AppEnv::screenRatioPR()
{
#if QT_VERSION >= 0x050600
return QApplication::primaryScreen()->devicePixelRatio();
#else
return 1;
#endif
}

View File

@ -1,6 +1,6 @@
/***************************************************************************** /*****************************************************************************
* gta5view Grand Theft Auto V Profile Viewer * gta5view Grand Theft Auto V Profile Viewer
* Copyright (C) 2016-2018 Syping * Copyright (C) 2016-2021 Syping
* *
* This program is free software: you can redistribute it and/or modify * This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by * it under the terms of the GNU General Public License as published by
@ -23,7 +23,7 @@
#include <QUrl> #include <QUrl>
enum class GameVersion : int { NoVersion = 0, SocialClubVersion = 1, SteamVersion = 2, BothVersions = 3 }; 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 }; 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, Korean = 13 };
class AppEnv class AppEnv
{ {
@ -39,7 +39,9 @@ public:
static bool setGameFolder(QString gameFolder); static bool setGameFolder(QString gameFolder);
static QString getExLangFolder(); static QString getExLangFolder();
static QString getInLangFolder(); static QString getInLangFolder();
static QString getImagesFolder();
static QString getPluginsFolder(); static QString getPluginsFolder();
static QString getShareFolder();
// Web Stuff // Web Stuff
static QByteArray getUserAgent(); static QByteArray getUserAgent();
@ -56,6 +58,7 @@ public:
// Screen Stuff // Screen Stuff
static qreal screenRatio(); static qreal screenRatio();
static qreal screenRatioPR();
}; };
#endif // APPENV_H #endif // APPENV_H

382
CMakeLists.txt Normal file
View File

@ -0,0 +1,382 @@
cmake_minimum_required(VERSION 3.7)
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)
set(FORCE_QT_VERSION "" CACHE STRING "Force Qt Version")
if(FORCE_QT_VERSION)
set(QT_VERSION_MAJOR ${FORCE_QT_VERSION})
else()
find_package(QT NAMES Qt6 Qt5 COMPONENTS Core REQUIRED)
endif()
find_package(Qt${QT_VERSION_MAJOR} COMPONENTS Network Svg Widgets REQUIRED)
find_package(Qt${QT_VERSION_MAJOR} COMPONENTS LinguistTools QUIET)
if(WIN32)
list(APPEND GTA5VIEW_LIBS
dwmapi
)
list(APPEND GTA5VIEW_DEFINES
-DUNICODE
-D_UNICODE
-DWIN32
)
list(APPEND GTA5VIEW_RESOURCES
res/app.rc
)
endif()
if(APPLE)
list(APPEND GTA5VIEW_RESOURCES
res/gta5view.icns
)
set(MACOSX_BUNDLE_BUNDLE_NAME gta5view)
set(MACOSX_BUNDLE_BUNDLE_VERSION 1.10.2)
set(MACOSX_BUNDLE_ICON_FILE gta5view.icns)
set(MACOSX_BUNDLE_GUI_IDENTIFIER de.syping.gta5view)
set_source_files_properties(res/gta5view.icns PROPERTIES MACOSX_PACKAGE_LOCATION "Resources")
endif()
list(APPEND GTA5VIEW_DEFINES
-DGTA5SYNC_CMAKE
-DGTA5SYNC_PROJECT
)
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
RagePhoto.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
wrapper.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
RagePhoto.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
)
set(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
)
list(APPEND GTA5VIEW_RESOURCES
res/global.qrc
res/template.qrc
)
set_property(SOURCE res/global.qrc PROPERTY AUTORCC_OPTIONS "-threshold;0;-compress;9")
if(Qt5LinguistTools_FOUND)
qt5_add_translation(GTA5VIEW_QMFILES
${GTA5VIEW_TRANSLATIONS}
res/qt5/qtbase_en_GB.ts
)
set(LINGUIST_FOUND TRUE)
elseif(Qt6LinguistTools_FOUND)
qt6_add_translation(GTA5VIEW_QMFILES
${GTA5VIEW_TRANSLATIONS}
res/qt6/qtbase_en_GB.ts
)
set(LINGUIST_FOUND TRUE)
else()
set(GTA5VIEW_QMFILES
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/qt${QT_VERSION_MAJOR}/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/img.qrc
res/tr_g5p.qrc
res/qt${QT_VERSION_MAJOR}/tr_qt.qrc
)
endif()
option(FLATPAK_BUILD "Flatpak modifications and optimisations" OFF)
if(FLATPAK_BUILD)
list(APPEND GTA5VIEW_DEFINES
-DGTA5SYNC_FLATPAK
)
endif()
option(WITH_DONATE "Donate menu option and donation dialog" OFF)
if(WITH_DONATE)
set(DONATE_ADDRESSES "" CACHE STRING "Donation addresses")
list(APPEND GTA5VIEW_HEADERS
anpro/QrCode.h
)
list(APPEND GTA5VIEW_SOURCES
anpro/QrCode.cpp
)
list(APPEND GTA5VIEW_DEFINES
-DGTA5SYNC_DONATE
)
list(APPEND GTA5VIEW_RESOURCES
res/donate.qrc
)
if(DONATE_ADDRESSES)
list(APPEND GTA5VIEW_DEFINES
"-DGTA5SYNC_DONATE_ADDRESSES=\"${DONATE_ADDRESSES}\""
)
endif()
endif()
option(WITH_MOTD "Developer message system directed to users" OFF)
if(WITH_MOTD)
set(MOTD_WEBURL "" CACHE STRING "Messages WebURL")
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)
set(TELEMETRY_AUTHID "" CACHE STRING "Telemetry AuthID")
set(TELEMETRY_AUTHPW "" CACHE STRING "Telemetry AuthPW")
set(TELEMETRY_PUSHURL "" CACHE STRING "Telemetry PushURL")
set(TELEMETRY_REGURL "" CACHE STRING "Telemetry RegURL")
set(TELEMETRY_WEBURL "" CACHE STRING "Telemetry WebURL")
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}\""
)
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(LINGUIST_FOUND AND QCONF_BUILD)
add_custom_target(translations DEPENDS ${GTA5VIEW_QMFILES})
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 Qt${QT_VERSION_MAJOR}::Network Qt${QT_VERSION_MAJOR}::Svg Qt${QT_VERSION_MAJOR}::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/de.syping.gta5view.xml DESTINATION share/mime/packages)
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)
if(QCONF_BUILD)
include(res/img.cmake)
install(FILES ${GTA5VIEW_IMGFILES} DESTINATION share/gta5view/resources)
install(FILES ${GTA5VIEW_QMFILES} DESTINATION share/gta5view/translations)
endif()

View File

@ -1,6 +1,6 @@
/***************************************************************************** /*****************************************************************************
* gta5view Grand Theft Auto V Profile Viewer * gta5view Grand Theft Auto V Profile Viewer
* Copyright (C) 2016-2017 Syping * Copyright (C) 2016-2021 Syping
* *
* This program is free software: you can redistribute it and/or modify * This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by * it under the terms of the GNU General Public License as published by
@ -44,97 +44,24 @@ void DatabaseThread::run()
{ {
QEventLoop threadLoop; QEventLoop threadLoop;
QStringList crewList;
QStringList crewListR;
// Register thread loop end signal
QObject::connect(this, SIGNAL(threadTerminated()), &threadLoop, SLOT(quit())); QObject::connect(this, SIGNAL(threadTerminated()), &threadLoop, SLOT(quit()));
// Setup crewList for Quick time scan while (threadRunning) {
crewList = crewDB->getCrews(); QTimer::singleShot(300000, &threadLoop, SLOT(quit()));
if (!crewList.isEmpty()) threadLoop.exec();
{
crewListR = deleteCompatibleCrews(crewList);
}
else
{
while (crewList.isEmpty() && threadRunning)
{
QTimer::singleShot(1000, &threadLoop, SLOT(quit()));
threadLoop.exec();
if (!crewDB->isAddingCrews())
{
crewList = crewDB->getCrews();
}
}
if (threadRunning)
{
crewListR = deleteCompatibleCrews(crewList);
}
}
// Only do QTS when Thread should be run
if (threadRunning)
{
// Quick time scan
#ifdef GTA5SYNC_DEBUG
qDebug() << "Start QTS";
#endif
if (crewListR.length() <= 5)
{
scanCrewReference(crewListR, 2500);
emit crewNameUpdated();
}
if (crewList.length() <= 3)
{
scanCrewMembersList(crewList, 3, 2500);
emit playerNameUpdated();
}
else if (crewList.length() <= 5)
{
scanCrewMembersList(crewList, 2, 2500);
emit playerNameUpdated();
}
if (threadRunning)
{
QTimer::singleShot(10000, &threadLoop, SLOT(quit()));
threadLoop.exec();
}
}
while (threadRunning)
{
crewList = crewDB->getCrews();
crewListR = deleteCompatibleCrews(crewList);
// Long time scan
#ifdef GTA5SYNC_DEBUG
qDebug() << "Start LTS";
#endif
scanCrewReference(crewListR, 10000);
emit crewNameUpdated();
scanCrewMembersList(crewList, crewMaxPages, 10000);
emit playerNameUpdated();
if (threadRunning)
{
QTimer::singleShot(300000, &threadLoop, SLOT(quit()));
threadLoop.exec();
}
} }
} }
void DatabaseThread::scanCrewReference(const QStringList &crewList, const int &requestDelay) void DatabaseThread::scanCrewReference(const QStringList &crewList, const int &requestDelay)
{ {
for (QString crewID : crewList) for (const QString &crewID : crewList) {
{ if (threadRunning && crewID != QLatin1String("0")) {
if (threadRunning && crewID != QLatin1String("0"))
{
QNetworkAccessManager *netManager = new QNetworkAccessManager(); QNetworkAccessManager *netManager = new QNetworkAccessManager();
QNetworkRequest netRequest(AppEnv::getCrewFetchingUrl(crewID)); QNetworkRequest netRequest(AppEnv::getCrewFetchingUrl(crewID));
#if QT_VERSION >= 0x050600 #if QT_VERSION >= 0x050600
#if QT_VERSION < 0x060000
netRequest.setAttribute(QNetworkRequest::FollowRedirectsAttribute, true); netRequest.setAttribute(QNetworkRequest::FollowRedirectsAttribute, true);
#endif
#endif #endif
netRequest.setRawHeader("User-Agent", AppEnv::getUserAgent()); netRequest.setRawHeader("User-Agent", AppEnv::getUserAgent());
netRequest.setRawHeader("Accept", "text/html"); netRequest.setRawHeader("Accept", "text/html");
@ -146,40 +73,36 @@ void DatabaseThread::scanCrewReference(const QStringList &crewList, const int &r
QEventLoop *downloadLoop = new QEventLoop(); QEventLoop *downloadLoop = new QEventLoop();
QObject::connect(netReply, SIGNAL(finished()), downloadLoop, SLOT(quit())); QObject::connect(netReply, SIGNAL(finished()), downloadLoop, SLOT(quit()));
if (!continueLastCrew) { QObject::connect(this, SIGNAL(threadTerminated()), downloadLoop, SLOT(quit())); } if (!continueLastCrew)
QObject::connect(this, SIGNAL(threadTerminated()), downloadLoop, SLOT(quit()));
QTimer::singleShot(30000, downloadLoop, SLOT(quit())); QTimer::singleShot(30000, downloadLoop, SLOT(quit()));
downloadLoop->exec(); downloadLoop->exec();
downloadLoop->disconnect(); downloadLoop->disconnect();
delete downloadLoop; delete downloadLoop;
if (netReply->isFinished()) if (netReply->isFinished()) {
{
QString crewName; QString crewName;
QByteArray crewHtml = netReply->readAll(); QByteArray crewHtml = netReply->readAll();
QStringList crewHtmlSplit1 = QString::fromUtf8(crewHtml).split("<title>Rockstar Games Social Club - Crew : "); QStringList crewHtmlSplit1 = QString::fromUtf8(crewHtml).split("<title>Rockstar Games Social Club - Crew : ");
if (crewHtmlSplit1.length() >= 2) if (crewHtmlSplit1.length() >= 2) {
{
QStringList crewHtmlSplit2 = QString(crewHtmlSplit1.at(1)).split("</title>"); QStringList crewHtmlSplit2 = QString(crewHtmlSplit1.at(1)).split("</title>");
if (crewHtmlSplit2.length() >= 1) if (crewHtmlSplit2.length() >= 1) {
{
crewName = crewHtmlSplit2.at(0); crewName = crewHtmlSplit2.at(0);
} }
} }
if (!crewName.isEmpty()) if (!crewName.isEmpty()) {
{
emit crewNameFound(crewID.toInt(), crewName); emit crewNameFound(crewID.toInt(), crewName);
} }
} }
else else {
{
netReply->abort(); netReply->abort();
} }
if (threadRunning) if (threadRunning) {
{
QEventLoop *waitingLoop = new QEventLoop(); QEventLoop *waitingLoop = new QEventLoop();
QTimer::singleShot(requestDelay, waitingLoop, SLOT(quit())); QTimer::singleShot(requestDelay, waitingLoop, SLOT(quit()));
if (!continueLastCrew) { QObject::connect(this, SIGNAL(threadTerminated()), waitingLoop, SLOT(quit())); } if (!continueLastCrew)
QObject::connect(this, SIGNAL(threadTerminated()), waitingLoop, SLOT(quit()));
waitingLoop->exec(); waitingLoop->exec();
waitingLoop->disconnect(); waitingLoop->disconnect();
delete waitingLoop; delete waitingLoop;
@ -193,21 +116,20 @@ void DatabaseThread::scanCrewReference(const QStringList &crewList, const int &r
void DatabaseThread::scanCrewMembersList(const QStringList &crewList, const int &maxPages, const int &requestDelay) void DatabaseThread::scanCrewMembersList(const QStringList &crewList, const int &maxPages, const int &requestDelay)
{ {
for (QString crewID : crewList) for (const QString &crewID : crewList) {
{ if (threadRunning && crewID != QLatin1String("0")) {
if (threadRunning && crewID != QLatin1String("0"))
{
int currentFail = 0; int currentFail = 0;
int currentPage = 0; int currentPage = 0;
int foundPlayers = 0; int foundPlayers = 0;
int totalPlayers = 1000; int totalPlayers = 1000;
while(foundPlayers < totalPlayers && currentPage < maxPages && (continueLastCrew ? true : threadRunning)) while(foundPlayers < totalPlayers && currentPage < maxPages && (continueLastCrew ? true : threadRunning)) {
{
QNetworkAccessManager *netManager = new QNetworkAccessManager(); QNetworkAccessManager *netManager = new QNetworkAccessManager();
QNetworkRequest netRequest(AppEnv::getPlayerFetchingUrl(crewID, currentPage)); QNetworkRequest netRequest(AppEnv::getPlayerFetchingUrl(crewID, currentPage));
#if QT_VERSION >= 0x050600 #if QT_VERSION >= 0x050600
#if QT_VERSION < 0x060000
netRequest.setAttribute(QNetworkRequest::FollowRedirectsAttribute, true); netRequest.setAttribute(QNetworkRequest::FollowRedirectsAttribute, true);
#endif
#endif #endif
netRequest.setRawHeader("User-Agent", AppEnv::getUserAgent()); netRequest.setRawHeader("User-Agent", AppEnv::getUserAgent());
netRequest.setRawHeader("Accept", "application/json"); netRequest.setRawHeader("Accept", "application/json");
@ -219,14 +141,14 @@ void DatabaseThread::scanCrewMembersList(const QStringList &crewList, const int
QEventLoop *downloadLoop = new QEventLoop(); QEventLoop *downloadLoop = new QEventLoop();
QObject::connect(netReply, SIGNAL(finished()), downloadLoop, SLOT(quit())); QObject::connect(netReply, SIGNAL(finished()), downloadLoop, SLOT(quit()));
if (!continueLastCrew) { QObject::connect(this, SIGNAL(threadTerminated()), downloadLoop, SLOT(quit())); } if (!continueLastCrew)
QObject::connect(this, SIGNAL(threadTerminated()), downloadLoop, SLOT(quit()));
QTimer::singleShot(30000, downloadLoop, SLOT(quit())); QTimer::singleShot(30000, downloadLoop, SLOT(quit()));
downloadLoop->exec(); downloadLoop->exec();
downloadLoop->disconnect(); downloadLoop->disconnect();
delete downloadLoop; delete downloadLoop;
if (netReply->isFinished()) if (netReply->isFinished()) {
{
QByteArray crewJson = netReply->readAll(); QByteArray crewJson = netReply->readAll();
QJsonDocument crewDocument = QJsonDocument::fromJson(crewJson); QJsonDocument crewDocument = QJsonDocument::fromJson(crewJson);
QJsonObject crewObject = crewDocument.object(); QJsonObject crewObject = crewDocument.object();
@ -234,32 +156,25 @@ void DatabaseThread::scanCrewMembersList(const QStringList &crewList, const int
if (crewMap.contains("Total")) { totalPlayers = crewMap["Total"].toInt(); } if (crewMap.contains("Total")) { totalPlayers = crewMap["Total"].toInt(); }
if (crewMap.contains("Members")) if (crewMap.contains("Members")) {
{
const QList<QVariant> memberList = crewMap["Members"].toList(); const QList<QVariant> memberList = crewMap["Members"].toList();
for (QVariant memberVariant : memberList) for (const QVariant &memberVariant : memberList) {
{
QMap<QString, QVariant> memberMap = memberVariant.toMap(); QMap<QString, QVariant> memberMap = memberVariant.toMap();
if (memberMap.contains("RockstarId") && memberMap.contains("Name")) if (memberMap.contains("RockstarId") && memberMap.contains("Name")) {
{
int RockstarId = memberMap["RockstarId"].toInt(); int RockstarId = memberMap["RockstarId"].toInt();
QString memberName = memberMap["Name"].toString(); QString memberName = memberMap["Name"].toString();
if (!memberName.isEmpty() && RockstarId != 0) if (!memberName.isEmpty() && RockstarId != 0) {
{
foundPlayers++; foundPlayers++;
emit playerNameFound(RockstarId, memberName); emit playerNameFound(RockstarId, memberName);
} }
} }
} }
} }
currentPage++; currentPage++;
} }
else else {
{
currentFail++; currentFail++;
if (currentFail == maxLoadFails) if (currentFail == maxLoadFails) {
{
currentFail = 0; currentFail = 0;
currentPage++; currentPage++;
} }
@ -268,8 +183,7 @@ void DatabaseThread::scanCrewMembersList(const QStringList &crewList, const int
delete netReply; delete netReply;
delete netManager; delete netManager;
if (foundPlayers < totalPlayers && currentPage < maxPages && (continueLastCrew ? true : threadRunning)) if (foundPlayers < totalPlayers && currentPage < maxPages && (continueLastCrew ? true : threadRunning)) {
{
QEventLoop *waitingLoop = new QEventLoop(); QEventLoop *waitingLoop = new QEventLoop();
QTimer::singleShot(requestDelay, waitingLoop, SLOT(quit())); QTimer::singleShot(requestDelay, waitingLoop, SLOT(quit()));
if (!continueLastCrew) { QObject::connect(this, SIGNAL(threadTerminated()), waitingLoop, SLOT(quit())); } if (!continueLastCrew) { QObject::connect(this, SIGNAL(threadTerminated()), waitingLoop, SLOT(quit())); }
@ -284,10 +198,8 @@ void DatabaseThread::scanCrewMembersList(const QStringList &crewList, const int
void DatabaseThread::deleteCompatibleCrews(QStringList *crewList) void DatabaseThread::deleteCompatibleCrews(QStringList *crewList)
{ {
for (QString crewNID : *crewList) for (const QString &crewNID : *crewList) {
{ if (crewDB->isCompatibleCrew(crewNID)) {
if (crewDB->isCompatibleCrew(crewNID))
{
crewList->removeAll(crewNID); crewList->removeAll(crewNID);
} }
} }
@ -296,10 +208,8 @@ void DatabaseThread::deleteCompatibleCrews(QStringList *crewList)
QStringList DatabaseThread::deleteCompatibleCrews(const QStringList &crewList) QStringList DatabaseThread::deleteCompatibleCrews(const QStringList &crewList)
{ {
QStringList crewListR = crewList; QStringList crewListR = crewList;
for (QString crewNID : crewListR) for (const QString &crewNID : crewListR) {
{ if (crewDB->isCompatibleCrew(crewNID)) {
if (crewDB->isCompatibleCrew(crewNID))
{
crewListR.removeAll(crewNID); crewListR.removeAll(crewNID);
} }
} }

View File

@ -1,6 +1,6 @@
/***************************************************************************** /*****************************************************************************
* gta5view Grand Theft Auto V Profile Viewer * gta5view Grand Theft Auto V Profile Viewer
* Copyright (C) 2016-2017 Syping * Copyright (C) 2016-2020 Syping
* *
* This program is free software: you can redistribute it and/or modify * This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by * it under the terms of the GNU General Public License as published by
@ -22,14 +22,19 @@
#include "ProfileWidget.h" #include "ProfileWidget.h"
#include "ExportThread.h" #include "ExportThread.h"
#include "SavegameData.h" #include "SavegameData.h"
#include "AppEnv.h"
#include "config.h" #include "config.h"
#include <QStringBuilder> #include <QStringBuilder>
#include <QDesktopWidget>
#include <QApplication> #include <QApplication>
#include <QFileInfo> #include <QFileInfo>
#include <QDebug>
#include <QFile> #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), 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) profileMap(profileMap), exportDirectory(exportDirectory), pictureCopyEnabled(pictureCopyEnabled), pictureExportEnabled(pictureExportEnabled), exportCount(exportCount)
{ {
@ -44,7 +49,7 @@ void ExportThread::run()
// Quality Settings // Quality Settings
settings.beginGroup("Pictures"); settings.beginGroup("Pictures");
int defaultQuality = 100; int defaultQuality = 100;
QSize defExportSize = QSize(960, 536); QSize defExportSize = SnapmaticPicture::getSnapmaticResolution();
int customQuality = settings.value("CustomQuality", defaultQuality).toInt(); int customQuality = settings.value("CustomQuality", defaultQuality).toInt();
if (customQuality < 1 || customQuality > 100) if (customQuality < 1 || customQuality > 100)
{ {
@ -101,8 +106,17 @@ void ExportThread::run()
QImage exportPicture = picture->getImage(); QImage exportPicture = picture->getImage();
if (sizeMode == "Desktop") if (sizeMode == "Desktop")
{ {
QRect desktopResolution = qApp->desktop()->screenGeometry(); #if QT_VERSION >= 0x050000
exportPicture = exportPicture.scaled(desktopResolution.width(), desktopResolution.height(), aspectRatio, Qt::SmoothTransformation); 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") else if (sizeMode == "Custom")
{ {

View File

@ -1,6 +1,6 @@
/***************************************************************************** /*****************************************************************************
* gta5view Grand Theft Auto V Profile Viewer * gta5view Grand Theft Auto V Profile Viewer
* Copyright (C) 2016-2018 Syping * Copyright (C) 2016-2021 Syping
* *
* This program is free software: you can redistribute it and/or modify * This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by * it under the terms of the GNU General Public License as published by
@ -28,17 +28,17 @@
GlobalString::GlobalString() GlobalString::GlobalString()
{ {
} }
QMap<QString, QString> GlobalString::getGlobalMap() QMap<QString, QString> GlobalString::getGlobalMap()
{ {
QMap<QString, QString> globalMap; QMap<QString, QString> globalMap;
QSettings globalFile(getLanguageFile(), QSettings::IniFormat); QSettings globalFile(getLanguageFile(), QSettings::IniFormat);
#if QT_VERSION < 0x060000
globalFile.setIniCodec("UTF-8"); globalFile.setIniCodec("UTF-8");
#endif
globalFile.beginGroup("Global"); globalFile.beginGroup("Global");
for (QString globalStr : globalFile.childKeys()) for (const QString &globalStr : globalFile.childKeys()) {
{
globalMap[globalStr] = globalFile.value(globalStr, globalStr).toString(); globalMap[globalStr] = globalFile.value(globalStr, globalStr).toString();
} }
globalFile.endGroup(); globalFile.endGroup();
@ -49,12 +49,14 @@ QString GlobalString::getString(QString valueStr, bool *ok)
{ {
QString globalString = valueStr; QString globalString = valueStr;
QSettings globalFile(getLanguageFile(), QSettings::IniFormat); QSettings globalFile(getLanguageFile(), QSettings::IniFormat);
#if QT_VERSION < 0x060000
globalFile.setIniCodec("UTF-8"); globalFile.setIniCodec("UTF-8");
#endif
globalFile.beginGroup("Global"); globalFile.beginGroup("Global");
QStringList globalStrList = globalFile.childKeys(); QStringList globalStrList = globalFile.childKeys();
if (globalStrList.contains(valueStr)) if (globalStrList.contains(valueStr)) {
{ if (ok != nullptr)
if (ok != nullptr) *ok = true; *ok = true;
globalString = globalFile.value(valueStr, valueStr).toString(); globalString = globalFile.value(valueStr, valueStr).toString();
} }
globalFile.endGroup(); globalFile.endGroup();
@ -65,10 +67,14 @@ QString GlobalString::getLanguageFile()
{ {
QString language = getLanguage(); QString language = getLanguage();
QString languageFile = ":/global/global." % language % ".ini"; QString languageFile = ":/global/global." % language % ".ini";
if (!QFileInfo(languageFile).exists()) #if QT_VERSION >= 0x050200
{ if (!QFileInfo::exists(languageFile))
languageFile = ":/global/global.en.ini"; languageFile = ":/global/global.en.ini";
} #else
if (!QFileInfo(languageFile).exists())
languageFile = ":/global/global.en.ini";
#endif
return languageFile; return languageFile;
} }

View File

@ -1,6 +1,6 @@
/***************************************************************************** /*****************************************************************************
* gta5view Grand Theft Auto V Profile Viewer * gta5view Grand Theft Auto V Profile Viewer
* Copyright (C) 2016-2017 Syping * Copyright (C) 2016-2021 Syping
* *
* This program is free software: you can redistribute it and/or modify * This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by * it under the terms of the GNU General Public License as published by
@ -17,34 +17,45 @@
*****************************************************************************/ *****************************************************************************/
#include "IconLoader.h" #include "IconLoader.h"
#include "AppEnv.h"
#include <QStringBuilder>
#include <QIcon> #include <QIcon>
IconLoader::IconLoader() IconLoader::IconLoader()
{ {
} }
QIcon IconLoader::loadingAppIcon() QIcon IconLoader::loadingAppIcon()
{ {
QIcon appIcon; QIcon appIcon;
appIcon.addFile(":/img/5sync-16.png", QSize(16, 16)); #if defined(GTA5SYNC_QCONF) && defined(GTA5SYNC_CMAKE)
appIcon.addFile(":/img/5sync-24.png", QSize(24, 24)); #ifdef Q_OS_WIN
appIcon.addFile(":/img/5sync-32.png", QSize(32, 32)); const QString pattern = AppEnv::getImagesFolder() % QLatin1String("/gta5view-%1.png");
appIcon.addFile(":/img/5sync-40.png", QSize(40, 40)); #else
appIcon.addFile(":/img/5sync-48.png", QSize(48, 48)); const QString pattern = AppEnv::getShareFolder() % QLatin1String("/icons/hicolor/%1x%1/apps/de.syping.gta5view.png");
appIcon.addFile(":/img/5sync-64.png", QSize(64, 64)); #endif
appIcon.addFile(":/img/5sync-96.png", QSize(96, 96)); #else
appIcon.addFile(":/img/5sync-128.png", QSize(128, 128)); const QString pattern = AppEnv::getImagesFolder() % QLatin1String("/gta5view-%1.png");
appIcon.addFile(":/img/5sync-256.png", QSize(256, 256)); #endif
appIcon.addFile(pattern.arg("16"), QSize(16, 16));
appIcon.addFile(pattern.arg("24"), QSize(24, 24));
appIcon.addFile(pattern.arg("32"), QSize(32, 32));
appIcon.addFile(pattern.arg("40"), QSize(40, 40));
appIcon.addFile(pattern.arg("48"), QSize(48, 48));
appIcon.addFile(pattern.arg("64"), QSize(64, 64));
appIcon.addFile(pattern.arg("96"), QSize(96, 96));
appIcon.addFile(pattern.arg("128"), QSize(128, 128));
appIcon.addFile(pattern.arg("256"), QSize(256, 256));
return appIcon; return appIcon;
} }
QIcon IconLoader::loadingPointmakerIcon() QIcon IconLoader::loadingPointmakerIcon()
{ {
QIcon pointmakerIcon; QIcon pointmakerIcon;
pointmakerIcon.addFile(":/img/pointmaker-8.png", QSize(8, 8)); const QString pattern = AppEnv::getImagesFolder() % QLatin1String("/pointmaker-%1.png");
pointmakerIcon.addFile(":/img/pointmaker-16.png", QSize(16, 16)); pointmakerIcon.addFile(pattern.arg("8"), QSize(8, 8));
pointmakerIcon.addFile(":/img/pointmaker-24.png", QSize(24, 24)); pointmakerIcon.addFile(pattern.arg("16"), QSize(16, 16));
pointmakerIcon.addFile(":/img/pointmaker-32.png", QSize(32, 32)); pointmakerIcon.addFile(pattern.arg("24"), QSize(24, 24));
pointmakerIcon.addFile(pattern.arg("32"), QSize(32, 32));
return pointmakerIcon; return pointmakerIcon;
} }

View File

@ -1,205 +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 "ImageEditorDialog.h"
#include "ui_ImageEditorDialog.h"
#include "ProfileInterface.h"
#include "SidebarGenerator.h"
#include "StandardPaths.h"
#include "ImportDialog.h"
#include "AppEnv.h"
#include "config.h"
#include <QStringBuilder>
#include <QImageReader>
#include <QFileDialog>
#include <QMessageBox>
ImageEditorDialog::ImageEditorDialog(SnapmaticPicture *picture, QString profileName, QWidget *parent) :
QDialog(parent), smpic(picture), profileName(profileName),
ui(new Ui::ImageEditorDialog)
{
// Set Window Flags
setWindowFlags(windowFlags()^Qt::WindowContextHelpButtonHint);
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 Import Button
if (QIcon::hasThemeIcon("document-import"))
{
ui->cmdReplace->setIcon(QIcon::fromTheme("document-import"));
}
// Set Icon for Overwrite 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"));
}
// DPI calculation
qreal screenRatio = AppEnv::screenRatio();
snapmaticResolutionLW = 516 * screenRatio; // 430
snapmaticResolutionLH = 288 * screenRatio; // 240
ui->labPicture->setMinimumSize(snapmaticResolutionLW, snapmaticResolutionLH);
imageIsChanged = false;
pictureCache = picture->getImage();
ui->labPicture->setPixmap(QPixmap::fromImage(pictureCache).scaled(snapmaticResolutionLW, snapmaticResolutionLH, Qt::IgnoreAspectRatio, Qt::SmoothTransformation));
setMaximumSize(sizeHint());
setMinimumSize(sizeHint());
setFixedSize(sizeHint());
}
ImageEditorDialog::~ImageEditorDialog()
{
delete ui;
}
void ImageEditorDialog::on_cmdClose_clicked()
{
close();
}
void ImageEditorDialog::on_cmdReplace_clicked()
{
QSettings settings(GTA5SYNC_APPVENDOR, GTA5SYNC_APPSTR);
settings.beginGroup("FileDialogs");
bool dontUseNativeDialog = settings.value("DontUseNativeDialog", false).toBool();
settings.beginGroup("ImportReplace");
fileDialogPreOpen: //Work?
QFileDialog fileDialog(this);
fileDialog.setFileMode(QFileDialog::ExistingFile);
fileDialog.setViewMode(QFileDialog::Detail);
fileDialog.setAcceptMode(QFileDialog::AcceptOpen);
fileDialog.setOption(QFileDialog::DontUseNativeDialog, dontUseNativeDialog);
fileDialog.setWindowFlags(fileDialog.windowFlags()^Qt::WindowContextHelpButtonHint);
fileDialog.setWindowTitle(ProfileInterface::tr("Import..."));
fileDialog.setLabelText(QFileDialog::Accept, ProfileInterface::tr("Import"));
// Getting readable Image formats
QString imageFormatsStr = " ";
for (QByteArray imageFormat : QImageReader::supportedImageFormats())
{
imageFormatsStr += QString("*.") % QString::fromUtf8(imageFormat).toLower() % " ";
}
QStringList filters;
filters << ProfileInterface::tr("All image files (%1)").arg(imageFormatsStr.trimmed());
filters << ProfileInterface::tr("All files (**)");
fileDialog.setNameFilters(filters);
QList<QUrl> sidebarUrls = SidebarGenerator::generateSidebarUrls(fileDialog.sidebarUrls());
fileDialog.setSidebarUrls(sidebarUrls);
fileDialog.setDirectory(settings.value(profileName % "+Directory", StandardPaths::documentsLocation()).toString());
fileDialog.restoreGeometry(settings.value(profileName % "+Geometry", "").toByteArray());
if (fileDialog.exec())
{
QStringList selectedFiles = fileDialog.selectedFiles();
if (selectedFiles.length() == 1)
{
QString selectedFile = selectedFiles.at(0);
QString selectedFileName = QFileInfo(selectedFile).fileName();
QFile snapmaticFile(selectedFile);
if (!snapmaticFile.open(QFile::ReadOnly))
{
QMessageBox::warning(this, ProfileInterface::tr("Import"), ProfileInterface::tr("Can't import %1 because file can't be open").arg("\""+selectedFileName+"\""));
goto fileDialogPreOpen;
}
QImage *importImage = new QImage();
QImageReader snapmaticImageReader;
snapmaticImageReader.setDecideFormatFromContent(true);
snapmaticImageReader.setDevice(&snapmaticFile);
if (!snapmaticImageReader.read(importImage))
{
QMessageBox::warning(this, ProfileInterface::tr("Import"), ProfileInterface::tr("Can't import %1 because file can't be parsed properly").arg("\""+selectedFileName+"\""));
delete importImage;
goto fileDialogPreOpen;
}
ImportDialog *importDialog = new ImportDialog(profileName, this);
importDialog->setImage(importImage);
importDialog->setModal(true);
importDialog->show();
importDialog->exec();
if (importDialog->isImportAgreed())
{
pictureCache = importDialog->image();
ui->labPicture->setPixmap(QPixmap::fromImage(pictureCache).scaled(snapmaticResolutionLW, snapmaticResolutionLH, Qt::KeepAspectRatio, Qt::SmoothTransformation));
imageIsChanged = true;
}
delete importDialog;
}
}
settings.setValue(profileName % "+Geometry", fileDialog.saveGeometry());
settings.setValue(profileName % "+Directory", fileDialog.directory().absolutePath());
settings.endGroup();
settings.endGroup();
}
void ImageEditorDialog::on_cmdSave_clicked()
{
if (imageIsChanged)
{
const QByteArray previousPicture = smpic->getPictureStream();
bool success = smpic->setImage(pictureCache);
if (success)
{
QString currentFilePath = smpic->getPictureFilePath();
QString originalFilePath = smpic->getOriginalPictureFilePath();
QString backupFileName = originalFilePath % ".bak";
if (!QFile::exists(backupFileName))
{
QFile::copy(currentFilePath, backupFileName);
}
if (!smpic->exportPicture(currentFilePath))
{
smpic->setPictureStream(previousPicture);
QMessageBox::warning(this, tr("Snapmatic Image Editor"), tr("Patching of Snapmatic Image failed because of I/O Error"));
return;
}
smpic->emitCustomSignal("PictureUpdated");
}
else
{
QMessageBox::warning(this, tr("Snapmatic Image Editor"), tr("Patching of Snapmatic Image failed because of Image Error"));
return;
}
}
close();
}

View File

@ -1,108 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>ImageEditorDialog</class>
<widget class="QDialog" name="ImageEditorDialog">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>516</width>
<height>337</height>
</rect>
</property>
<property name="windowTitle">
<string>Overwrite Image...</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>0</number>
</property>
<item>
<widget class="QLabel" 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="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="vlButtons">
<item>
<layout class="QHBoxLayout" name="hlButtons">
<item>
<widget class="QPushButton" name="cmdReplace">
<property name="toolTip">
<string>Import picture</string>
</property>
<property name="text">
<string>&amp;Import...</string>
</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="cmdSave">
<property name="toolTip">
<string>Apply changes</string>
</property>
<property name="text">
<string>&amp;Overwrite</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="cmdClose">
<property name="toolTip">
<string>Discard changes</string>
</property>
<property name="text">
<string>&amp;Close</string>
</property>
</widget>
</item>
</layout>
</item>
</layout>
</widget>
</item>
</layout>
</widget>
<resources/>
<connections/>
</ui>

View File

@ -1,6 +1,6 @@
/***************************************************************************** /*****************************************************************************
* gta5view Grand Theft Auto V Profile Viewer * gta5view Grand Theft Auto V Profile Viewer
* Copyright (C) 2017-2018 Syping * Copyright (C) 2017-2022 Syping
* *
* This program is free software: you can redistribute it and/or modify * This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by * it under the terms of the GNU General Public License as published by
@ -16,10 +16,11 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>. * along with this program. If not, see <http://www.gnu.org/licenses/>.
*****************************************************************************/ *****************************************************************************/
#include "ImportDialog.h"
#include "ui_ImportDialog.h" #include "ui_ImportDialog.h"
#include "SnapmaticPicture.h"
#include "SidebarGenerator.h" #include "SidebarGenerator.h"
#include "StandardPaths.h" #include "StandardPaths.h"
#include "ImportDialog.h"
#include "imagecropper.h" #include "imagecropper.h"
#include "AppEnv.h" #include "AppEnv.h"
#include "config.h" #include "config.h"
@ -39,8 +40,6 @@
#include <QRgb> #include <QRgb>
// IMAGES VALUES // IMAGES VALUES
#define snapmaticResolutionW 960
#define snapmaticResolutionH 536
#define snapmaticAvatarResolution 470 #define snapmaticAvatarResolution 470
#define snapmaticAvatarPlacementW 145 #define snapmaticAvatarPlacementW 145
#define snapmaticAvatarPlacementH 66 #define snapmaticAvatarPlacementH 66
@ -50,7 +49,11 @@ ImportDialog::ImportDialog(QString profileName, QWidget *parent) :
ui(new Ui::ImportDialog) ui(new Ui::ImportDialog)
{ {
// Set Window Flags // Set Window Flags
#if QT_VERSION >= 0x050900
setWindowFlag(Qt::WindowContextHelpButtonHint, false);
#else
setWindowFlags(windowFlags()^Qt::WindowContextHelpButtonHint); setWindowFlags(windowFlags()^Qt::WindowContextHelpButtonHint);
#endif
ui->setupUi(this); ui->setupUi(this);
ui->cmdOK->setDefault(true); ui->cmdOK->setDefault(true);
@ -60,26 +63,22 @@ ImportDialog::ImportDialog(QString profileName, QWidget *parent) :
watermarkAvatar = true; watermarkAvatar = true;
watermarkPicture = false; watermarkPicture = false;
insideAvatarZone = false; insideAvatarZone = false;
avatarAreaImage = QImage(":/img/avatarareaimport.png"); avatarAreaImage = QImage(AppEnv::getImagesFolder() % "/avatarareaimport.png");
selectedColour = QColor::fromRgb(0, 0, 0, 255); selectedColour = QColor::fromRgb(0, 0, 0, 255);
// Set Icon for OK Button // Set Icon for OK Button
if (QIcon::hasThemeIcon("dialog-ok")) if (QIcon::hasThemeIcon("dialog-ok")) {
{
ui->cmdOK->setIcon(QIcon::fromTheme("dialog-ok")); ui->cmdOK->setIcon(QIcon::fromTheme("dialog-ok"));
} }
else if (QIcon::hasThemeIcon("gtk-ok")) else if (QIcon::hasThemeIcon("gtk-ok")) {
{
ui->cmdOK->setIcon(QIcon::fromTheme("gtk-ok")); ui->cmdOK->setIcon(QIcon::fromTheme("gtk-ok"));
} }
// Set Icon for Cancel Button // Set Icon for Cancel Button
if (QIcon::hasThemeIcon("dialog-cancel")) if (QIcon::hasThemeIcon("dialog-cancel")) {
{
ui->cmdCancel->setIcon(QIcon::fromTheme("dialog-cancel")); ui->cmdCancel->setIcon(QIcon::fromTheme("dialog-cancel"));
} }
else if (QIcon::hasThemeIcon("gtk-cancel")) else if (QIcon::hasThemeIcon("gtk-cancel")) {
{
ui->cmdCancel->setIcon(QIcon::fromTheme("gtk-cancel")); ui->cmdCancel->setIcon(QIcon::fromTheme("gtk-cancel"));
} }
@ -88,6 +87,14 @@ ImportDialog::ImportDialog(QString profileName, QWidget *parent) :
ui->labBackgroundImage->setText(tr("Background Image:")); ui->labBackgroundImage->setText(tr("Background Image:"));
ui->cmdBackgroundWipe->setVisible(false); ui->cmdBackgroundWipe->setVisible(false);
// Snapmatic Resolution
snapmaticResolution = SnapmaticPicture::getSnapmaticResolution();
ui->cbResolution->addItem("GTA V", snapmaticResolution);
ui->cbResolution->addItem("FiveM", QSize(1920, 1072));
ui->cbResolution->addItem("1280x720", QSize(1280, 720));
ui->cbResolution->addItem("1920x1080", QSize(1920, 1080));
ui->cbResolution->addItem("2560x1440", QSize(2560, 1440));
// Set Import Settings // Set Import Settings
QSettings settings(GTA5SYNC_APPVENDOR, GTA5SYNC_APPSTR); QSettings settings(GTA5SYNC_APPVENDOR, GTA5SYNC_APPSTR);
settings.beginGroup("Import"); settings.beginGroup("Import");
@ -105,217 +112,297 @@ ImportDialog::ImportDialog(QString profileName, QWidget *parent) :
#ifndef Q_OS_MAC #ifndef Q_OS_MAC
ui->vlButtom->setContentsMargins(9 * screenRatio, 6 * screenRatio, 9 * screenRatio, 9 * screenRatio); ui->vlButtom->setContentsMargins(9 * screenRatio, 6 * screenRatio, 9 * screenRatio, 9 * screenRatio);
#else #else
if (QApplication::style()->objectName() == "macintosh") #if QT_VERSION >= 0x060000
{ if (QApplication::style()->objectName() == "macos") {
#else
if (QApplication::style()->objectName() == "macintosh") {
#endif
ui->vlButtom->setContentsMargins(9 * screenRatio, 9 * screenRatio, 9 * screenRatio, 9 * screenRatio); ui->vlButtom->setContentsMargins(9 * screenRatio, 9 * screenRatio, 9 * screenRatio, 9 * screenRatio);
} }
else else {
{
ui->vlButtom->setContentsMargins(9 * screenRatio, 6 * screenRatio, 9 * screenRatio, 9 * screenRatio); ui->vlButtom->setContentsMargins(9 * screenRatio, 6 * screenRatio, 9 * screenRatio, 9 * screenRatio);
} }
#endif #endif
// Options menu // Options menu
optionsMenu = new QMenu(this); optionsMenu.addAction(tr("&Import new Picture..."), this, SLOT(importNewPicture()));
optionsMenu->addAction(tr("&Import new Picture..."), this, SLOT(importNewPicture())); optionsMenu.addAction(tr("&Crop Picture..."), this, SLOT(cropPicture()));
optionsMenu->addAction(tr("&Crop Picture..."), this, SLOT(cropPicture())); optionsMenu.addSeparator();
optionsMenu->addSeparator(); optionsMenu.addAction(tr("&Load Settings..."), this, SLOT(loadImportSettings()));
optionsMenu->addAction(tr("&Load Settings..."), this, SLOT(loadImportSettings())); optionsMenu.addAction(tr("&Save Settings..."), this, SLOT(saveImportSettings()));
optionsMenu->addAction(tr("&Save Settings..."), this, SLOT(saveImportSettings())); ui->cmdOptions->setMenu(&optionsMenu);
ui->cmdOptions->setMenu(optionsMenu);
setMaximumSize(sizeHint()); const QSize windowSize = sizeHint();
setMinimumSize(sizeHint()); setMinimumSize(windowSize);
setFixedSize(sizeHint()); setMaximumSize(windowSize);
} }
ImportDialog::~ImportDialog() ImportDialog::~ImportDialog()
{ {
delete optionsMenu;
delete ui; delete ui;
} }
void ImportDialog::processImage() void ImportDialog::processImage()
{ {
if (workImage.isNull()) return; if (workImage.isNull())
return;
QImage snapmaticImage = workImage; QImage snapmaticImage = workImage;
QPixmap snapmaticPixmap(snapmaticResolutionW, snapmaticResolutionH); QPixmap snapmaticPixmap(snapmaticResolution);
snapmaticPixmap.fill(selectedColour); snapmaticPixmap.fill(selectedColour);
QPainter snapmaticPainter(&snapmaticPixmap); QPainter snapmaticPainter(&snapmaticPixmap);
if (!backImage.isNull()) qreal screenRatioPR = AppEnv::screenRatioPR();
{ if (!backImage.isNull()) {
if (!ui->cbStretch->isChecked()) if (!ui->cbStretch->isChecked()) {
{
int diffWidth = 0; int diffWidth = 0;
int diffHeight = 0; int diffHeight = 0;
if (backImage.width() != snapmaticResolutionW) if (backImage.width() != snapmaticResolution.width()) {
{ diffWidth = snapmaticResolution.width() - backImage.width();
diffWidth = snapmaticResolutionW - backImage.width();
diffWidth = diffWidth / 2; diffWidth = diffWidth / 2;
} }
else if (backImage.height() != snapmaticResolutionH) else if (backImage.height() != snapmaticResolution.height()) {
{ diffHeight = snapmaticResolution.height() - backImage.height();
diffHeight = snapmaticResolutionH - backImage.height();
diffHeight = diffHeight / 2; diffHeight = diffHeight / 2;
} }
snapmaticPainter.drawImage(0 + diffWidth, 0 + diffHeight, backImage); snapmaticPainter.drawImage(0 + diffWidth, 0 + diffHeight, backImage);
} }
else else {
{ snapmaticPainter.drawImage(0, 0, QImage(backImage).scaled(snapmaticResolution, Qt::IgnoreAspectRatio, Qt::SmoothTransformation));
snapmaticPainter.drawImage(0, 0, QImage(backImage).scaled(snapmaticResolutionW, snapmaticResolutionH, Qt::IgnoreAspectRatio, Qt::SmoothTransformation));
} }
if (ui->cbAvatar->isChecked() && ui->cbForceAvatarColour->isChecked()) if (ui->cbAvatar->isChecked() && ui->cbForceAvatarColour->isChecked()) {
{
snapmaticPainter.fillRect(snapmaticAvatarPlacementW, snapmaticAvatarPlacementH, snapmaticAvatarResolution, snapmaticAvatarResolution, selectedColour); snapmaticPainter.fillRect(snapmaticAvatarPlacementW, snapmaticAvatarPlacementH, snapmaticAvatarResolution, snapmaticAvatarResolution, selectedColour);
} }
} }
if (insideAvatarZone) if (insideAvatarZone) {
{
// Avatar mode // Avatar mode
int diffWidth = 0; int diffWidth = 0;
int diffHeight = 0; int diffHeight = 0;
if (!ui->cbIgnore->isChecked()) if (ui->cbIgnore->isChecked()) {
{ snapmaticImage = snapmaticImage.scaled(snapmaticAvatarResolution, snapmaticAvatarResolution, Qt::IgnoreAspectRatio, Qt::SmoothTransformation);
}
else if (ui->cbBorderless->isChecked()) {
snapmaticImage = snapmaticImage.scaled(snapmaticAvatarResolution, snapmaticAvatarResolution, Qt::KeepAspectRatioByExpanding, Qt::SmoothTransformation);
if (snapmaticImage.width() > snapmaticAvatarResolution) {
int diffWidth = snapmaticImage.width() - snapmaticAvatarResolution;
diffWidth = diffWidth / 2;
QImage croppedImage(snapmaticAvatarResolution, snapmaticAvatarResolution, QImage::Format_ARGB32);
croppedImage.fill(Qt::transparent);
QPainter croppedPainter(&croppedImage);
croppedPainter.drawImage(0 - diffWidth, 0, snapmaticImage);
croppedPainter.end();
snapmaticImage = croppedImage;
}
else if (snapmaticImage.height() > snapmaticAvatarResolution) {
int diffHeight = snapmaticImage.height() - snapmaticAvatarResolution;
diffHeight = diffHeight / 2;
QImage croppedImage(snapmaticAvatarResolution, snapmaticAvatarResolution, QImage::Format_ARGB32);
croppedImage.fill(Qt::transparent);
QPainter croppedPainter(&croppedImage);
croppedPainter.drawImage(0, 0 - diffHeight, snapmaticImage);
croppedPainter.end();
snapmaticImage = croppedImage;
}
}
else {
snapmaticImage = snapmaticImage.scaled(snapmaticAvatarResolution, snapmaticAvatarResolution, Qt::KeepAspectRatio, Qt::SmoothTransformation); snapmaticImage = snapmaticImage.scaled(snapmaticAvatarResolution, snapmaticAvatarResolution, Qt::KeepAspectRatio, Qt::SmoothTransformation);
if (snapmaticImage.width() > snapmaticImage.height()) if (snapmaticImage.width() > snapmaticImage.height()) {
{
diffHeight = snapmaticAvatarResolution - snapmaticImage.height(); diffHeight = snapmaticAvatarResolution - snapmaticImage.height();
diffHeight = diffHeight / 2; diffHeight = diffHeight / 2;
} }
else if (snapmaticImage.width() < snapmaticImage.height()) else if (snapmaticImage.width() < snapmaticImage.height()) {
{
diffWidth = snapmaticAvatarResolution - snapmaticImage.width(); diffWidth = snapmaticAvatarResolution - snapmaticImage.width();
diffWidth = diffWidth / 2; diffWidth = diffWidth / 2;
} }
} }
else
{
snapmaticImage = snapmaticImage.scaled(snapmaticAvatarResolution, snapmaticAvatarResolution, Qt::IgnoreAspectRatio, Qt::SmoothTransformation);
}
snapmaticPainter.drawImage(snapmaticAvatarPlacementW + diffWidth, snapmaticAvatarPlacementH + diffHeight, snapmaticImage); snapmaticPainter.drawImage(snapmaticAvatarPlacementW + diffWidth, snapmaticAvatarPlacementH + diffHeight, snapmaticImage);
if (ui->cbWatermark->isChecked()) { processWatermark(&snapmaticPainter); } if (ui->cbWatermark->isChecked())
processWatermark(&snapmaticPainter);
imageTitle = tr("Custom Avatar", "Custom Avatar Description in SC, don't use Special Character!"); imageTitle = tr("Custom Avatar", "Custom Avatar Description in SC, don't use Special Character!");
} }
else else {
{
// Picture mode // Picture mode
int diffWidth = 0; int diffWidth = 0;
int diffHeight = 0; int diffHeight = 0;
if (!ui->cbIgnore->isChecked()) if (ui->cbIgnore->isChecked()) {
{ snapmaticImage = snapmaticImage.scaled(snapmaticResolution, Qt::IgnoreAspectRatio, Qt::SmoothTransformation);
snapmaticImage = snapmaticImage.scaled(snapmaticResolutionW, snapmaticResolutionH, Qt::KeepAspectRatio, Qt::SmoothTransformation); }
if (snapmaticImage.width() != snapmaticResolutionW) else if (ui->cbBorderless->isChecked()) {
{ snapmaticImage = snapmaticImage.scaled(snapmaticResolution, Qt::KeepAspectRatioByExpanding, Qt::SmoothTransformation);
diffWidth = snapmaticResolutionW - snapmaticImage.width(); if (snapmaticImage.width() > snapmaticResolution.width()) {
int diffWidth = snapmaticImage.width() - snapmaticResolution.width();
diffWidth = diffWidth / 2;
QImage croppedImage(snapmaticResolution, QImage::Format_ARGB32);
croppedImage.fill(Qt::transparent);
QPainter croppedPainter(&croppedImage);
croppedPainter.drawImage(0 - diffWidth, 0, snapmaticImage);
croppedPainter.end();
snapmaticImage = croppedImage;
}
else if (snapmaticImage.height() > snapmaticResolution.height()) {
int diffHeight = snapmaticImage.height() - snapmaticResolution.height();
diffHeight = diffHeight / 2;
QImage croppedImage(snapmaticResolution, QImage::Format_ARGB32);
croppedImage.fill(Qt::transparent);
QPainter croppedPainter(&croppedImage);
croppedPainter.drawImage(0, 0 - diffHeight, snapmaticImage);
croppedPainter.end();
snapmaticImage = croppedImage;
}
}
else {
snapmaticImage = snapmaticImage.scaled(snapmaticResolution, Qt::KeepAspectRatio, Qt::SmoothTransformation);
if (snapmaticImage.width() != snapmaticResolution.width()) {
diffWidth = snapmaticResolution.width() - snapmaticImage.width();
diffWidth = diffWidth / 2; diffWidth = diffWidth / 2;
} }
else if (snapmaticImage.height() != snapmaticResolutionH) else if (snapmaticImage.height() != snapmaticResolution.height()) {
{ diffHeight = snapmaticResolution.height() - snapmaticImage.height();
diffHeight = snapmaticResolutionH - snapmaticImage.height();
diffHeight = diffHeight / 2; diffHeight = diffHeight / 2;
} }
} }
else
{
snapmaticImage = snapmaticImage.scaled(snapmaticResolutionW, snapmaticResolutionH, Qt::IgnoreAspectRatio, Qt::SmoothTransformation);
}
snapmaticPainter.drawImage(0 + diffWidth, 0 + diffHeight, snapmaticImage); snapmaticPainter.drawImage(0 + diffWidth, 0 + diffHeight, snapmaticImage);
if (ui->cbWatermark->isChecked()) { processWatermark(&snapmaticPainter); } if (ui->cbWatermark->isChecked())
processWatermark(&snapmaticPainter);
imageTitle = tr("Custom Picture", "Custom Picture Description in SC, don't use Special Character!"); imageTitle = tr("Custom Picture", "Custom Picture Description in SC, don't use Special Character!");
} }
snapmaticPainter.end(); snapmaticPainter.end();
newImage = snapmaticPixmap.toImage(); newImage = snapmaticPixmap.toImage();
ui->labPicture->setPixmap(snapmaticPixmap.scaled(snapmaticResolutionLW, snapmaticResolutionLH, Qt::IgnoreAspectRatio, Qt::SmoothTransformation)); #if QT_VERSION >= 0x050600
snapmaticPixmap.setDevicePixelRatio(screenRatioPR);
#endif
ui->labPicture->setPixmap(snapmaticPixmap.scaled(snapmaticResolutionLW * screenRatioPR, snapmaticResolutionLH * screenRatioPR, Qt::IgnoreAspectRatio, Qt::SmoothTransformation));
}
void ImportDialog::reworkImage()
{
workImage = QImage();
if (origImage.width() == origImage.height()) {
if (ui->cbResolution->currentIndex() == 0) {
insideAvatarZone = true;
ui->cbAvatar->setChecked(true);
}
else {
insideAvatarZone = false;
ui->cbAvatar->setChecked(false);
}
if (origImage.height() > snapmaticResolution.height()) {
workImage = origImage.scaled(snapmaticResolution.height(), snapmaticResolution.height(), Qt::IgnoreAspectRatio, Qt::SmoothTransformation);
}
else {
workImage = origImage;
}
}
else if (origImage.width() > snapmaticResolution.width() && origImage.width() > origImage.height()) {
insideAvatarZone = false;
ui->cbAvatar->setChecked(false);
workImage = origImage.scaledToWidth(snapmaticResolution.width(), Qt::SmoothTransformation);
}
else if (origImage.height() > snapmaticResolution.height() && origImage.height() > origImage.width()) {
insideAvatarZone = false;
ui->cbAvatar->setChecked(false);
workImage = origImage.scaledToHeight(snapmaticResolution.height(), Qt::SmoothTransformation);
}
else {
insideAvatarZone = false;
ui->cbAvatar->setChecked(false);
workImage = origImage;
}
processImage();
} }
void ImportDialog::processWatermark(QPainter *snapmaticPainter) void ImportDialog::processWatermark(QPainter *snapmaticPainter)
{ {
bool blackWatermark = false; bool blackWatermark = false;
bool redWatermark = false; bool redWatermark = false;
if (selectedColour.red() > 127) if (selectedColour.red() > 127) {
{ if (selectedColour.green() > 127 || selectedColour.blue() > 127) {
if (selectedColour.green() > 127 || selectedColour.blue() > 127)
{
redWatermark = true; redWatermark = true;
} }
} }
else else {
{
redWatermark = true; redWatermark = true;
} }
if (selectedColour.lightness() > 127) if (selectedColour.lightness() > 127) {
{
blackWatermark = true; blackWatermark = true;
} }
// draw watermark // draw watermark
if (redWatermark) if (redWatermark) {
{ const QImage viewWatermark = QImage(AppEnv::getImagesFolder() % "/watermark_2r.png");
snapmaticPainter->drawImage(0, 0, QImage(":/img/watermark_2r.png")); snapmaticPainter->drawImage(snapmaticResolution.width() - viewWatermark.width(), 0, viewWatermark);
} }
else else
{ {
QImage viewWatermark = QImage(":/img/watermark_2b.png"); QImage viewWatermark = QImage(AppEnv::getImagesFolder() % "/watermark_2b.png");
if (!blackWatermark) if (!blackWatermark) {
{
viewWatermark.invertPixels(QImage::InvertRgb); viewWatermark.invertPixels(QImage::InvertRgb);
} }
snapmaticPainter->drawImage(0, 0, viewWatermark); snapmaticPainter->drawImage(snapmaticResolution.width() - viewWatermark.width(), 0, viewWatermark);
} }
QImage textWatermark = QImage(":/img/watermark_1b.png"); QImage textWatermark = QImage(AppEnv::getImagesFolder() % "/watermark_1b.png");
if (!blackWatermark) if (!blackWatermark) {
{
textWatermark.invertPixels(QImage::InvertRgb); textWatermark.invertPixels(QImage::InvertRgb);
} }
snapmaticPainter->drawImage(0, 0, textWatermark); snapmaticPainter->drawImage(snapmaticResolution.width() - textWatermark.width(), 0, textWatermark);
} }
void ImportDialog::processSettings(QString settingsProfile, bool setDefault) void ImportDialog::processSettings(QString settingsProfile, bool setDefault)
{ {
QSettings settings(GTA5SYNC_APPVENDOR, GTA5SYNC_APPSTR); QSettings settings(GTA5SYNC_APPVENDOR, GTA5SYNC_APPSTR);
settings.beginGroup("Import"); settings.beginGroup("Import");
if (setDefault) if (setDefault) {
{
settings.setValue("Profile", settingsProfile); settings.setValue("Profile", settingsProfile);
} }
if (settingsProfile == "Default") if (settingsProfile == "Default") {
{
watermarkAvatar = true; watermarkAvatar = true;
watermarkPicture = false; watermarkPicture = false;
selectedColour = QColor::fromRgb(0, 0, 0, 255); selectedColour = QColor::fromRgb(0, 0, 0, 255);
backImage = QImage(); backImage = QImage();
ui->cbBorderless->setChecked(false);
ui->cbStretch->setChecked(false); ui->cbStretch->setChecked(false);
ui->cbForceAvatarColour->setChecked(false); ui->cbForceAvatarColour->setChecked(false);
ui->cbUnlimited->setChecked(false);
ui->cbImportAsIs->setChecked(false);
ui->cbResolution->setCurrentIndex(0);
} }
else else {
{
settings.beginGroup(settingsProfile); settings.beginGroup(settingsProfile);
watermarkAvatar = settings.value("WatermarkAvatar", true).toBool(); watermarkAvatar = settings.value("WatermarkAvatar", true).toBool();
watermarkPicture = settings.value("WatermarkPicture", false).toBool(); watermarkPicture = settings.value("WatermarkPicture", false).toBool();
backImage = qvariant_cast<QImage>(settings.value("BackgroundImage", QImage())); backImage = qvariant_cast<QImage>(settings.value("BackgroundImage", QImage()));
selectedColour = qvariant_cast<QColor>(settings.value("SelectedColour", QColor::fromRgb(0, 0, 0, 255))); selectedColour = qvariant_cast<QColor>(settings.value("SelectedColour", QColor::fromRgb(0, 0, 0, 255)));
ui->cbBorderless->setChecked(settings.value("BorderlessImage", false).toBool());
ui->cbStretch->setChecked(settings.value("BackgroundStretch", false).toBool()); ui->cbStretch->setChecked(settings.value("BackgroundStretch", false).toBool());
ui->cbForceAvatarColour->setChecked(settings.value("ForceAvatarColour", false).toBool()); ui->cbForceAvatarColour->setChecked(settings.value("ForceAvatarColour", false).toBool());
ui->cbUnlimited->setChecked(settings.value("UnlimitedBuffer", false).toBool());
ui->cbImportAsIs->setChecked(settings.value("ImportAsIs", false).toBool());
const QVariant data = settings.value("Resolution", SnapmaticPicture::getSnapmaticResolution());
#if QT_VERSION >= 0x060000
if (data.typeId() == QMetaType::QSize)
#else
if (data.type() == QVariant::Size)
#endif
{
int index = ui->cbResolution->findData(data);
if (index != -1) {
ui->cbResolution->setCurrentIndex(index);
}
}
settings.endGroup(); settings.endGroup();
} }
if (!workImage.isNull()) if (!workImage.isNull()) {
{ if (ui->cbAvatar->isChecked()) {
if (ui->cbAvatar->isChecked())
{
ui->cbWatermark->setChecked(watermarkAvatar); ui->cbWatermark->setChecked(watermarkAvatar);
} }
else else {
{
ui->cbWatermark->setChecked(watermarkPicture); ui->cbWatermark->setChecked(watermarkPicture);
} }
} }
ui->labColour->setText(tr("Background Colour: <span style=\"color: %1\">%1</span>").arg(selectedColour.name())); ui->labColour->setText(tr("Background Colour: <span style=\"color: %1\">%1</span>").arg(selectedColour.name()));
if (!backImage.isNull()) if (!backImage.isNull()) {
{
ui->labBackgroundImage->setText(tr("Background Image: %1").arg(tr("Storage", "Background Image: Storage"))); ui->labBackgroundImage->setText(tr("Background Image: %1").arg(tr("Storage", "Background Image: Storage")));
ui->cmdBackgroundWipe->setVisible(true); ui->cmdBackgroundWipe->setVisible(true);
} }
else else {
{
ui->labBackgroundImage->setText(tr("Background Image:")); ui->labBackgroundImage->setText(tr("Background Image:"));
ui->cmdBackgroundWipe->setVisible(false); ui->cmdBackgroundWipe->setVisible(false);
} }
@ -331,8 +418,27 @@ void ImportDialog::saveSettings(QString settingsProfile)
settings.setValue("WatermarkPicture", watermarkPicture); settings.setValue("WatermarkPicture", watermarkPicture);
settings.setValue("BackgroundImage", backImage); settings.setValue("BackgroundImage", backImage);
settings.setValue("SelectedColour", selectedColour); settings.setValue("SelectedColour", selectedColour);
settings.setValue("BorderlessImage", ui->cbBorderless->isChecked());
settings.setValue("BackgroundStretch", ui->cbStretch->isChecked()); settings.setValue("BackgroundStretch", ui->cbStretch->isChecked());
settings.setValue("ForceAvatarColour", ui->cbForceAvatarColour->isChecked()); settings.setValue("ForceAvatarColour", ui->cbForceAvatarColour->isChecked());
#if QT_VERSION >= 0x050000
const QVariant data = ui->cbResolution->currentData();
#else
const QVariant data = ui->cbResolution->itemData(ui->cbResolution->currentIndex());
#endif
#if QT_VERSION >= 0x060000
if (data.typeId() == QMetaType::QSize)
#else
if (data.type() == QVariant::Size)
#endif
{
settings.setValue("Resolution", data);
}
else {
settings.setValue("Resolution", SnapmaticPicture::getSnapmaticResolution());
}
settings.setValue("UnlimitedBuffer", ui->cbUnlimited->isChecked());
settings.setValue("ImportAsIs", ui->cbImportAsIs->isChecked());
settings.endGroup(); settings.endGroup();
settings.setValue("Profile", settingsProfile); settings.setValue("Profile", settingsProfile);
settings.endGroup(); settings.endGroup();
@ -370,7 +476,7 @@ void ImportDialog::cropPicture()
#endif #endif
imageCropper.setBackgroundColor(Qt::black); imageCropper.setBackgroundColor(Qt::black);
imageCropper.setCroppingRectBorderColor(QColor(255, 255, 255, 127)); imageCropper.setCroppingRectBorderColor(QColor(255, 255, 255, 127));
imageCropper.setImage(QPixmap::fromImage(workImage, Qt::AutoColor)); imageCropper.setImage(QPixmap::fromImage(origImage, Qt::AutoColor));
imageCropper.setProportion(QSize(1, 1)); imageCropper.setProportion(QSize(1, 1));
imageCropper.setFixedSize(workImage.size()); imageCropper.setFixedSize(workImage.size());
cropLayout.addWidget(&imageCropper); cropLayout.addWidget(&imageCropper);
@ -398,8 +504,7 @@ void ImportDialog::cropPicture()
cropDialog.show(); cropDialog.show();
cropDialog.setFixedSize(cropDialog.sizeHint()); cropDialog.setFixedSize(cropDialog.sizeHint());
if (cropDialog.exec() == QDialog::Accepted) if (cropDialog.exec() == QDialog::Accepted) {
{
QImage *croppedImage = new QImage(imageCropper.cropImage().toImage()); QImage *croppedImage = new QImage(imageCropper.cropImage().toImage());
setImage(croppedImage); setImage(croppedImage);
} }
@ -424,8 +529,7 @@ fileDialogPreOpen: //Work?
// Getting readable Image formats // Getting readable Image formats
QString imageFormatsStr = " "; QString imageFormatsStr = " ";
for (QByteArray imageFormat : QImageReader::supportedImageFormats()) for (const QByteArray &imageFormat : QImageReader::supportedImageFormats()) {
{
imageFormatsStr += QString("*.") % QString::fromUtf8(imageFormat).toLower() % " "; imageFormatsStr += QString("*.") % QString::fromUtf8(imageFormat).toLower() % " ";
} }
@ -440,17 +544,14 @@ fileDialogPreOpen: //Work?
fileDialog.setDirectory(settings.value(profileName % "+Directory", StandardPaths::documentsLocation()).toString()); fileDialog.setDirectory(settings.value(profileName % "+Directory", StandardPaths::documentsLocation()).toString());
fileDialog.restoreGeometry(settings.value(profileName % "+Geometry", "").toByteArray()); fileDialog.restoreGeometry(settings.value(profileName % "+Geometry", "").toByteArray());
if (fileDialog.exec()) if (fileDialog.exec()) {
{
QStringList selectedFiles = fileDialog.selectedFiles(); QStringList selectedFiles = fileDialog.selectedFiles();
if (selectedFiles.length() == 1) if (selectedFiles.length() == 1) {
{
QString selectedFile = selectedFiles.at(0); QString selectedFile = selectedFiles.at(0);
QString selectedFileName = QFileInfo(selectedFile).fileName(); QString selectedFileName = QFileInfo(selectedFile).fileName();
QFile snapmaticFile(selectedFile); QFile snapmaticFile(selectedFile);
if (!snapmaticFile.open(QFile::ReadOnly)) if (!snapmaticFile.open(QFile::ReadOnly)) {
{
QMessageBox::warning(this, QApplication::translate("ProfileInterface", "Import"), QApplication::translate("ProfileInterface", "Can't import %1 because file can't be open").arg("\""+selectedFileName+"\"")); QMessageBox::warning(this, QApplication::translate("ProfileInterface", "Import"), QApplication::translate("ProfileInterface", "Can't import %1 because file can't be open").arg("\""+selectedFileName+"\""));
goto fileDialogPreOpen; goto fileDialogPreOpen;
} }
@ -458,8 +559,7 @@ fileDialogPreOpen: //Work?
QImageReader snapmaticImageReader; QImageReader snapmaticImageReader;
snapmaticImageReader.setDecideFormatFromContent(true); snapmaticImageReader.setDecideFormatFromContent(true);
snapmaticImageReader.setDevice(&snapmaticFile); snapmaticImageReader.setDevice(&snapmaticFile);
if (!snapmaticImageReader.read(importImage)) if (!snapmaticImageReader.read(importImage)) {
{
QMessageBox::warning(this, QApplication::translate("ProfileInterface", "Import"), QApplication::translate("ProfileInterface", "Can't import %1 because file can't be parsed properly").arg("\""+selectedFileName+"\"")); QMessageBox::warning(this, QApplication::translate("ProfileInterface", "Import"), QApplication::translate("ProfileInterface", "Can't import %1 because file can't be parsed properly").arg("\""+selectedFileName+"\""));
delete importImage; delete importImage;
goto fileDialogPreOpen; goto fileDialogPreOpen;
@ -476,45 +576,38 @@ fileDialogPreOpen: //Work?
void ImportDialog::loadImportSettings() void ImportDialog::loadImportSettings()
{ {
if (settingsLocked) if (settingsLocked) {
{
QMessageBox::information(this, tr("Load Settings..."), tr("Please import a new picture first")); QMessageBox::information(this, tr("Load Settings..."), tr("Please import a new picture first"));
return; return;
} }
bool ok; bool ok;
QStringList profileList; QStringList profileList;
profileList << tr("Default", "Default as Default Profile") profileList << tr("Default", "Default as Default Profile")
<< tr("Profile %1", "Profile %1 as Profile 1").arg("1") << tr("Profile %1", "Profile %1 as Profile 1").arg("1")
<< tr("Profile %1", "Profile %1 as Profile 1").arg("2") << tr("Profile %1", "Profile %1 as Profile 1").arg("2")
<< tr("Profile %1", "Profile %1 as Profile 1").arg("3") << tr("Profile %1", "Profile %1 as Profile 1").arg("3")
<< tr("Profile %1", "Profile %1 as Profile 1").arg("4") << tr("Profile %1", "Profile %1 as Profile 1").arg("4")
<< tr("Profile %1", "Profile %1 as Profile 1").arg("5"); << tr("Profile %1", "Profile %1 as Profile 1").arg("5");
QString sProfile = QInputDialog::getItem(this, tr("Load Settings..."), tr("Please select your settings profile"), profileList, 0, false, &ok, windowFlags()); QString sProfile = QInputDialog::getItem(this, tr("Load Settings..."), tr("Please select your settings profile"), profileList, 0, false, &ok, windowFlags());
if (ok) if (ok) {
{
QString pProfile; QString pProfile;
if (sProfile == tr("Default", "Default as Default Profile")) if (sProfile == tr("Default", "Default as Default Profile")) {
{
pProfile = "Default"; pProfile = "Default";
} }
else if (sProfile == tr("Profile %1", "Profile %1 as Profile 1").arg("1")) else if (sProfile == tr("Profile %1", "Profile %1 as Profile 1").arg("1")) {
{
pProfile = "Profile 1"; pProfile = "Profile 1";
} }
else if (sProfile == tr("Profile %1", "Profile %1 as Profile 1").arg("2")) else if (sProfile == tr("Profile %1", "Profile %1 as Profile 1").arg("2")) {
{
pProfile = "Profile 2"; pProfile = "Profile 2";
} }
else if (sProfile == tr("Profile %1", "Profile %1 as Profile 1").arg("3")) else if (sProfile == tr("Profile %1", "Profile %1 as Profile 1").arg("3")) {
{
pProfile = "Profile 3"; pProfile = "Profile 3";
} }
else if (sProfile == tr("Profile %1", "Profile %1 as Profile 1").arg("4")) else if (sProfile == tr("Profile %1", "Profile %1 as Profile 1").arg("4"))
{ {
pProfile = "Profile 4"; pProfile = "Profile 4";
} }
else if (sProfile == tr("Profile %1", "Profile %1 as Profile 1").arg("5")) else if (sProfile == tr("Profile %1", "Profile %1 as Profile 1").arg("5")) {
{
pProfile = "Profile 5"; pProfile = "Profile 5";
} }
processSettings(pProfile, true); processSettings(pProfile, true);
@ -524,40 +617,33 @@ void ImportDialog::loadImportSettings()
void ImportDialog::saveImportSettings() void ImportDialog::saveImportSettings()
{ {
if (settingsLocked) if (settingsLocked) {
{
QMessageBox::information(this, tr("Save Settings..."), tr("Please import a new picture first")); QMessageBox::information(this, tr("Save Settings..."), tr("Please import a new picture first"));
return; return;
} }
bool ok; bool ok;
QStringList profileList; QStringList profileList;
profileList << tr("Profile %1", "Profile %1 as Profile 1").arg("1") profileList << tr("Profile %1", "Profile %1 as Profile 1").arg("1")
<< tr("Profile %1", "Profile %1 as Profile 1").arg("2") << tr("Profile %1", "Profile %1 as Profile 1").arg("2")
<< tr("Profile %1", "Profile %1 as Profile 1").arg("3") << tr("Profile %1", "Profile %1 as Profile 1").arg("3")
<< tr("Profile %1", "Profile %1 as Profile 1").arg("4") << tr("Profile %1", "Profile %1 as Profile 1").arg("4")
<< tr("Profile %1", "Profile %1 as Profile 1").arg("5"); << tr("Profile %1", "Profile %1 as Profile 1").arg("5");
QString sProfile = QInputDialog::getItem(this, tr("Save Settings..."), tr("Please select your settings profile"), profileList, 0, false, &ok, windowFlags()); QString sProfile = QInputDialog::getItem(this, tr("Save Settings..."), tr("Please select your settings profile"), profileList, 0, false, &ok, windowFlags());
if (ok) if (ok) {
{
QString pProfile; QString pProfile;
if (sProfile == tr("Profile %1", "Profile %1 as Profile 1").arg("1")) if (sProfile == tr("Profile %1", "Profile %1 as Profile 1").arg("1")) {
{
pProfile = "Profile 1"; pProfile = "Profile 1";
} }
else if (sProfile == tr("Profile %1", "Profile %1 as Profile 1").arg("2")) else if (sProfile == tr("Profile %1", "Profile %1 as Profile 1").arg("2")) {
{
pProfile = "Profile 2"; pProfile = "Profile 2";
} }
else if (sProfile == tr("Profile %1", "Profile %1 as Profile 1").arg("3")) else if (sProfile == tr("Profile %1", "Profile %1 as Profile 1").arg("3")) {
{
pProfile = "Profile 3"; pProfile = "Profile 3";
} }
else if (sProfile == tr("Profile %1", "Profile %1 as Profile 1").arg("4")) else if (sProfile == tr("Profile %1", "Profile %1 as Profile 1").arg("4")) {
{
pProfile = "Profile 4"; pProfile = "Profile 4";
} }
else if (sProfile == tr("Profile %1", "Profile %1 as Profile 1").arg("5")) else if (sProfile == tr("Profile %1", "Profile %1 as Profile 1").arg("5")) {
{
pProfile = "Profile 5"; pProfile = "Profile 5";
} }
saveSettings(pProfile); saveSettings(pProfile);
@ -566,43 +652,49 @@ void ImportDialog::saveImportSettings()
QImage ImportDialog::image() QImage ImportDialog::image()
{ {
return newImage; if (ui->cbImportAsIs->isChecked()) {
return origImage;
}
else {
return newImage;
}
} }
void ImportDialog::setImage(QImage *image_) void ImportDialog::setImage(QImage *image_)
{ {
origImage = *image_;
workImage = QImage(); workImage = QImage();
if (image_->width() == image_->height()) if (image_->width() == image_->height()) {
{ if (ui->cbResolution->currentIndex() == 0) {
insideAvatarZone = true; insideAvatarZone = true;
ui->cbAvatar->setChecked(true); ui->cbAvatar->setChecked(true);
if (image_->height() > snapmaticResolutionH) }
{ else {
workImage = image_->scaled(snapmaticResolutionH, snapmaticResolutionH, Qt::IgnoreAspectRatio, Qt::SmoothTransformation); insideAvatarZone = false;
ui->cbAvatar->setChecked(false);
}
if (image_->height() > snapmaticResolution.height()) {
workImage = image_->scaled(snapmaticResolution.height(), snapmaticResolution.height(), Qt::IgnoreAspectRatio, Qt::SmoothTransformation);
delete image_; delete image_;
} }
else else {
{
workImage = *image_; workImage = *image_;
delete image_; delete image_;
} }
} }
else if (image_->width() > snapmaticResolutionW && image_->width() > image_->height()) else if (image_->width() > snapmaticResolution.width() && image_->width() > image_->height()) {
{
insideAvatarZone = false; insideAvatarZone = false;
ui->cbAvatar->setChecked(false); ui->cbAvatar->setChecked(false);
workImage = image_->scaledToWidth(snapmaticResolutionW, Qt::SmoothTransformation); workImage = image_->scaledToWidth(snapmaticResolution.width(), Qt::SmoothTransformation);
delete image_; delete image_;
} }
else if (image_->height() > snapmaticResolutionH && image_->height() > image_->width()) else if (image_->height() > snapmaticResolution.height() && image_->height() > image_->width()) {
{
insideAvatarZone = false; insideAvatarZone = false;
ui->cbAvatar->setChecked(false); ui->cbAvatar->setChecked(false);
workImage = image_->scaledToHeight(snapmaticResolutionH, Qt::SmoothTransformation); workImage = image_->scaledToHeight(snapmaticResolution.height(), Qt::SmoothTransformation);
delete image_; delete image_;
} }
else else {
{
insideAvatarZone = false; insideAvatarZone = false;
ui->cbAvatar->setChecked(false); ui->cbAvatar->setChecked(false);
workImage = *image_; workImage = *image_;
@ -614,18 +706,15 @@ void ImportDialog::setImage(QImage *image_)
void ImportDialog::lockSettings(bool lock) void ImportDialog::lockSettings(bool lock)
{ {
ui->cbAvatar->setDisabled(lock); ui->gbAdvanced->setDisabled(lock);
ui->cbForceAvatarColour->setDisabled(lock); if (ui->cbImportAsIs->isChecked()) {
ui->cbIgnore->setDisabled(lock); ui->gbBackground->setDisabled(true);
ui->cbStretch->setDisabled(lock); ui->gbSettings->setDisabled(true);
ui->cbWatermark->setDisabled(lock); }
ui->cmdBackgroundChange->setDisabled(lock); else {
ui->cmdBackgroundWipe->setDisabled(lock); ui->gbBackground->setDisabled(lock);
ui->cmdColourChange->setDisabled(lock); ui->gbSettings->setDisabled(lock);
ui->labBackgroundImage->setDisabled(lock); }
ui->labColour->setDisabled(lock);
ui->gbSettings->setDisabled(lock);
ui->gbBackground->setDisabled(lock);
ui->cmdOK->setDisabled(lock); ui->cmdOK->setDisabled(lock);
settingsLocked = lock; settingsLocked = lock;
} }
@ -647,6 +736,11 @@ bool ImportDialog::isImportAgreed()
return importAgreed; return importAgreed;
} }
bool ImportDialog::isUnlimitedBuffer()
{
return ui->cbUnlimited->isChecked();
}
bool ImportDialog::areSettingsLocked() bool ImportDialog::areSettingsLocked()
{ {
return settingsLocked; return settingsLocked;
@ -654,21 +748,27 @@ bool ImportDialog::areSettingsLocked()
QString ImportDialog::getImageTitle() QString ImportDialog::getImageTitle()
{ {
return imageTitle; if (ui->cbImportAsIs->isChecked()) {
return tr("Custom Picture", "Custom Picture Description in SC, don't use Special Character!");
}
else {
return imageTitle;
}
} }
void ImportDialog::on_cbIgnore_toggled(bool checked) void ImportDialog::on_cbIgnore_toggled(bool checked)
{ {
Q_UNUSED(checked) ui->cbBorderless->setDisabled(checked);
processImage(); processImage();
} }
void ImportDialog::on_cbAvatar_toggled(bool checked) void ImportDialog::on_cbAvatar_toggled(bool checked)
{ {
if (!workImage.isNull() && workImage.width() == workImage.height() && !checked) if (ui->cbResolution->currentIndex() != 0)
{ return;
if (QMessageBox::No == QMessageBox::warning(this, tr("Snapmatic Avatar Zone"), tr("Are you sure to use a square image outside of the Avatar Zone?\nWhen you want to use it as Avatar the image will be detached!"), QMessageBox::Yes | QMessageBox::No, QMessageBox::No))
{ if (!workImage.isNull() && workImage.width() == workImage.height() && !checked) {
if (QMessageBox::No == QMessageBox::warning(this, tr("Snapmatic Avatar Zone"), tr("Are you sure to use a square image outside of the Avatar Zone?\nWhen you want to use it as Avatar the image will be detached!"), QMessageBox::Yes | QMessageBox::No, QMessageBox::No)) {
ui->cbAvatar->setChecked(true); ui->cbAvatar->setChecked(true);
insideAvatarZone = true; insideAvatarZone = true;
return; return;
@ -676,12 +776,10 @@ void ImportDialog::on_cbAvatar_toggled(bool checked)
} }
insideAvatarZone = ui->cbAvatar->isChecked(); insideAvatarZone = ui->cbAvatar->isChecked();
watermarkBlock = true; watermarkBlock = true;
if (insideAvatarZone) if (insideAvatarZone) {
{
ui->cbWatermark->setChecked(watermarkAvatar); ui->cbWatermark->setChecked(watermarkAvatar);
} }
else else {
{
ui->cbWatermark->setChecked(watermarkPicture); ui->cbWatermark->setChecked(watermarkPicture);
} }
watermarkBlock = false; watermarkBlock = false;
@ -701,11 +799,9 @@ void ImportDialog::on_cmdOK_clicked()
void ImportDialog::on_labPicture_labelPainted() void ImportDialog::on_labPicture_labelPainted()
{ {
if (insideAvatarZone) if (insideAvatarZone) {
{
QImage avatarAreaFinalImage(avatarAreaImage); QImage avatarAreaFinalImage(avatarAreaImage);
if (selectedColour.lightness() > 127) if (selectedColour.lightness() > 127) {
{
avatarAreaFinalImage.setColor(1, qRgb(0, 0, 0)); avatarAreaFinalImage.setColor(1, qRgb(0, 0, 0));
} }
QPainter labelPainter(ui->labPicture); QPainter labelPainter(ui->labPicture);
@ -717,8 +813,7 @@ void ImportDialog::on_labPicture_labelPainted()
void ImportDialog::on_cmdColourChange_clicked() void ImportDialog::on_cmdColourChange_clicked()
{ {
QColor newSelectedColour = QColorDialog::getColor(selectedColour, this, tr("Select Colour...")); QColor newSelectedColour = QColorDialog::getColor(selectedColour, this, tr("Select Colour..."));
if (newSelectedColour.isValid()) if (newSelectedColour.isValid()) {
{
selectedColour = newSelectedColour; selectedColour = newSelectedColour;
ui->labColour->setText(tr("Background Colour: <span style=\"color: %1\">%1</span>").arg(selectedColour.name())); ui->labColour->setText(tr("Background Colour: <span style=\"color: %1\">%1</span>").arg(selectedColour.name()));
processImage(); processImage();
@ -744,8 +839,7 @@ fileDialogPreOpen:
// Getting readable Image formats // Getting readable Image formats
QString imageFormatsStr = " "; QString imageFormatsStr = " ";
for (QByteArray imageFormat : QImageReader::supportedImageFormats()) for (const QByteArray &imageFormat : QImageReader::supportedImageFormats()) {
{
imageFormatsStr += QString("*.") % QString::fromUtf8(imageFormat).toLower() % " "; imageFormatsStr += QString("*.") % QString::fromUtf8(imageFormat).toLower() % " ";
} }
@ -760,17 +854,14 @@ fileDialogPreOpen:
fileDialog.setDirectory(settings.value("Directory", StandardPaths::documentsLocation()).toString()); fileDialog.setDirectory(settings.value("Directory", StandardPaths::documentsLocation()).toString());
fileDialog.restoreGeometry(settings.value("Geometry", "").toByteArray()); fileDialog.restoreGeometry(settings.value("Geometry", "").toByteArray());
if (fileDialog.exec()) if (fileDialog.exec()) {
{
QStringList selectedFiles = fileDialog.selectedFiles(); QStringList selectedFiles = fileDialog.selectedFiles();
if (selectedFiles.length() == 1) if (selectedFiles.length() == 1) {
{
QString selectedFile = selectedFiles.at(0); QString selectedFile = selectedFiles.at(0);
QString selectedFileName = QFileInfo(selectedFile).fileName(); QString selectedFileName = QFileInfo(selectedFile).fileName();
QFile snapmaticFile(selectedFile); QFile snapmaticFile(selectedFile);
if (!snapmaticFile.open(QFile::ReadOnly)) if (!snapmaticFile.open(QFile::ReadOnly)) {
{
QMessageBox::warning(this, QApplication::translate("ProfileInterface", "Import"), QApplication::translate("ProfileInterface", "Can't import %1 because file can't be open").arg("\""+selectedFileName+"\"")); QMessageBox::warning(this, QApplication::translate("ProfileInterface", "Import"), QApplication::translate("ProfileInterface", "Can't import %1 because file can't be open").arg("\""+selectedFileName+"\""));
goto fileDialogPreOpen; goto fileDialogPreOpen;
} }
@ -778,12 +869,11 @@ fileDialogPreOpen:
QImageReader snapmaticImageReader; QImageReader snapmaticImageReader;
snapmaticImageReader.setDecideFormatFromContent(true); snapmaticImageReader.setDecideFormatFromContent(true);
snapmaticImageReader.setDevice(&snapmaticFile); snapmaticImageReader.setDevice(&snapmaticFile);
if (!snapmaticImageReader.read(&importImage)) if (!snapmaticImageReader.read(&importImage)) {
{
QMessageBox::warning(this, QApplication::translate("ProfileInterface", "Import"), QApplication::translate("ProfileInterface", "Can't import %1 because file can't be parsed properly").arg("\""+selectedFileName+"\"")); QMessageBox::warning(this, QApplication::translate("ProfileInterface", "Import"), QApplication::translate("ProfileInterface", "Can't import %1 because file can't be parsed properly").arg("\""+selectedFileName+"\""));
goto fileDialogPreOpen; goto fileDialogPreOpen;
} }
backImage = importImage.scaled(snapmaticResolutionW, snapmaticResolutionH, Qt::KeepAspectRatio, Qt::SmoothTransformation); backImage = importImage.scaled(snapmaticResolution, Qt::KeepAspectRatio, Qt::SmoothTransformation);
backgroundPath = selectedFile; backgroundPath = selectedFile;
ui->labBackgroundImage->setText(tr("Background Image: %1").arg(tr("File", "Background Image: File"))); ui->labBackgroundImage->setText(tr("Background Image: %1").arg(tr("File", "Background Image: File")));
ui->cmdBackgroundWipe->setVisible(true); ui->cmdBackgroundWipe->setVisible(true);
@ -819,16 +909,66 @@ void ImportDialog::on_cbForceAvatarColour_toggled(bool checked)
void ImportDialog::on_cbWatermark_toggled(bool checked) void ImportDialog::on_cbWatermark_toggled(bool checked)
{ {
if (!watermarkBlock) if (!watermarkBlock) {
{ if (insideAvatarZone) {
if (insideAvatarZone)
{
watermarkAvatar = checked; watermarkAvatar = checked;
} }
else else {
{
watermarkPicture = checked; watermarkPicture = checked;
} }
processImage(); processImage();
} }
} }
void ImportDialog::on_cbBorderless_toggled(bool checked)
{
ui->cbIgnore->setDisabled(checked);
processImage();
}
void ImportDialog::on_cbImportAsIs_toggled(bool checked)
{
ui->cbResolution->setDisabled(checked);
ui->labResolution->setDisabled(checked);
ui->gbBackground->setDisabled(checked);
ui->gbSettings->setDisabled(checked);
}
void ImportDialog::on_cbResolution_currentIndexChanged(int index)
{
Q_UNUSED(index)
#if QT_VERSION >= 0x050000
const QVariant data = ui->cbResolution->currentData();
#else
const QVariant data = ui->cbResolution->itemData(ui->cbResolution->currentIndex());
#endif
#if QT_VERSION >= 0x060000
if (data.typeId() == QMetaType::QSize)
#else
if (data.type() == QVariant::Size)
#endif
{
const QSize dataSize = data.toSize();
if (dataSize == SnapmaticPicture::getSnapmaticResolution()) {
ui->cbAvatar->setEnabled(true);
snapmaticResolution = dataSize;
reworkImage();
}
else {
if (!workImage.isNull() && workImage.width() == workImage.height() && ui->cbAvatar->isChecked()) {
if (QMessageBox::No == QMessageBox::warning(this, tr("Snapmatic Avatar Zone"), tr("Are you sure to use a square image outside of the Avatar Zone?\nWhen you want to use it as Avatar the image will be detached!"), QMessageBox::Yes | QMessageBox::No, QMessageBox::No)) {
ui->cbResolution->setCurrentIndex(0);
ui->cbAvatar->setChecked(true);
insideAvatarZone = true;
return;
}
}
ui->cbAvatar->setChecked(false);
ui->cbAvatar->setDisabled(true);
insideAvatarZone = false;
ui->cbWatermark->setChecked(watermarkPicture);
snapmaticResolution = dataSize;
reworkImage();
}
}
}

View File

@ -1,6 +1,6 @@
/***************************************************************************** /*****************************************************************************
* gta5view Grand Theft Auto V Profile Viewer * gta5view Grand Theft Auto V Profile Viewer
* Copyright (C) 2017 Syping * Copyright (C) 2017-2021 Syping
* *
* This program is free software: you can redistribute it and/or modify * This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by * it under the terms of the GNU General Public License as published by
@ -39,10 +39,12 @@ public:
void lockSettings(bool lock); void lockSettings(bool lock);
void enableOverwriteMode(); void enableOverwriteMode();
bool isImportAgreed(); bool isImportAgreed();
bool isUnlimitedBuffer();
bool areSettingsLocked(); bool areSettingsLocked();
private slots: private slots:
void processImage(); void processImage();
void reworkImage();
void cropPicture(); void cropPicture();
void importNewPicture(); void importNewPicture();
void loadImportSettings(); void loadImportSettings();
@ -58,6 +60,9 @@ private slots:
void on_cbStretch_toggled(bool checked); void on_cbStretch_toggled(bool checked);
void on_cbForceAvatarColour_toggled(bool checked); void on_cbForceAvatarColour_toggled(bool checked);
void on_cbWatermark_toggled(bool checked); void on_cbWatermark_toggled(bool checked);
void on_cbBorderless_toggled(bool checked);
void on_cbImportAsIs_toggled(bool checked);
void on_cbResolution_currentIndexChanged(int index);
private: private:
QString profileName; QString profileName;
@ -67,9 +72,11 @@ private:
QString imageTitle; QString imageTitle;
QImage backImage; QImage backImage;
QImage workImage; QImage workImage;
QImage origImage;
QImage newImage; QImage newImage;
QColor selectedColour; QColor selectedColour;
QMenu *optionsMenu; QMenu optionsMenu;
QSize snapmaticResolution;
bool insideAvatarZone; bool insideAvatarZone;
bool watermarkPicture; bool watermarkPicture;
bool watermarkAvatar; bool watermarkAvatar;

View File

@ -7,7 +7,7 @@
<x>0</x> <x>0</x>
<y>0</y> <y>0</y>
<width>516</width> <width>516</width>
<height>512</height> <height>673</height>
</rect> </rect>
</property> </property>
<property name="minimumSize"> <property name="minimumSize">
@ -85,50 +85,35 @@
</property> </property>
<layout class="QVBoxLayout" name="vlSettings"> <layout class="QVBoxLayout" name="vlSettings">
<item> <item>
<layout class="QHBoxLayout" name="hlCheckboxesTop"> <layout class="QGridLayout" name="glPicture">
<item> <item row="0" column="1">
<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"> <widget class="QCheckBox" name="cbIgnore">
<property name="sizePolicy">
<sizepolicy hsizetype="MinimumExpanding" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text"> <property name="text">
<string>Ignore Aspect Ratio</string> <string>Ignore Aspect Ratio</string>
</property> </property>
</widget> </widget>
</item> </item>
</layout> <item row="0" column="0">
</item> <widget class="QCheckBox" name="cbAvatar">
<item> <property name="text">
<layout class="QHBoxLayout" name="hlCheckboxesButtom"> <string>Avatar</string>
<item>
<widget class="QCheckBox" name="cbWatermark">
<property name="sizePolicy">
<sizepolicy hsizetype="MinimumExpanding" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property> </property>
</widget>
</item>
<item row="1" column="0">
<widget class="QCheckBox" name="cbWatermark">
<property name="text"> <property name="text">
<string>Watermark</string> <string>Watermark</string>
</property> </property>
</widget> </widget>
</item> </item>
<item row="1" column="1">
<widget class="QCheckBox" name="cbBorderless">
<property name="text">
<string>Crop to Aspect Ratio</string>
</property>
</widget>
</item>
</layout> </layout>
</item> </item>
</layout> </layout>
@ -141,8 +126,8 @@
</property> </property>
<layout class="QVBoxLayout" name="vlBackground"> <layout class="QVBoxLayout" name="vlBackground">
<item> <item>
<layout class="QHBoxLayout" name="hlColour"> <layout class="QGridLayout" name="glBackground">
<item> <item row="0" column="0">
<layout class="QHBoxLayout" name="hlColourManage"> <layout class="QHBoxLayout" name="hlColourManage">
<item> <item>
<widget class="QLabel" name="labColour"> <widget class="QLabel" name="labColour">
@ -174,7 +159,7 @@
<string>Select background colour</string> <string>Select background colour</string>
</property> </property>
<property name="text"> <property name="text">
<string>...</string> <string notr="true">...</string>
</property> </property>
</widget> </widget>
</item> </item>
@ -195,7 +180,24 @@
</item> </item>
</layout> </layout>
</item> </item>
<item> <item row="2" column="1">
<widget class="QCheckBox" name="cbStretch">
<property name="enabled">
<bool>true</bool>
</property>
<property name="text">
<string>Ignore Aspect Ratio</string>
</property>
</widget>
</item>
<item row="2" column="0">
<widget class="QCheckBox" name="cbForceAvatarColour">
<property name="text">
<string>Force Colour in Avatar Zone</string>
</property>
</widget>
</item>
<item row="0" column="1">
<layout class="QHBoxLayout" name="hlBackgroundManage"> <layout class="QHBoxLayout" name="hlBackgroundManage">
<item> <item>
<widget class="QLabel" name="labBackgroundImage"> <widget class="QLabel" name="labBackgroundImage">
@ -227,7 +229,7 @@
<string>Select background image</string> <string>Select background image</string>
</property> </property>
<property name="text"> <property name="text">
<string>...</string> <string notr="true">...</string>
</property> </property>
</widget> </widget>
</item> </item>
@ -237,7 +239,7 @@
<string>Remove background image</string> <string>Remove background image</string>
</property> </property>
<property name="text"> <property name="text">
<string>X</string> <string notr="true">X</string>
</property> </property>
</widget> </widget>
</item> </item>
@ -260,25 +262,61 @@
</item> </item>
</layout> </layout>
</item> </item>
</layout>
</widget>
</item>
<item>
<widget class="QGroupBox" name="gbAdvanced">
<property name="title">
<string>Advanced</string>
</property>
<layout class="QVBoxLayout" name="vlAdvanced">
<item> <item>
<layout class="QHBoxLayout" name="hlBackground"> <layout class="QGridLayout" name="glAdvanced">
<item> <item row="1" column="0">
<widget class="QCheckBox" name="cbForceAvatarColour"> <widget class="QCheckBox" name="cbUnlimited">
<property name="toolTip">
<string>Avoid compression and expand buffer instead, improves picture quality, but may break Snapmatic</string>
</property>
<property name="text"> <property name="text">
<string>Force Colour in Avatar Zone</string> <string>Unlimited Buffer</string>
</property> </property>
</widget> </widget>
</item> </item>
<item> <item row="1" column="1">
<widget class="QCheckBox" name="cbStretch"> <widget class="QCheckBox" name="cbImportAsIs">
<property name="enabled"> <property name="toolTip">
<bool>true</bool> <string>Import as-is, don't change the picture at all, guaranteed to break Snapmatic unless you know what you doing</string>
</property> </property>
<property name="text"> <property name="text">
<string>Ignore Aspect Ratio</string> <string>Import as-is</string>
</property> </property>
</widget> </widget>
</item> </item>
<item row="0" column="0" colspan="2">
<layout class="QHBoxLayout" name="hlResolution">
<item>
<widget class="QLabel" name="labResolution">
<property name="text">
<string>Resolution:</string>
</property>
</widget>
</item>
<item>
<widget class="QComboBox" name="cbResolution">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="toolTip">
<string>Snapmatic resolution</string>
</property>
</widget>
</item>
</layout>
</item>
</layout> </layout>
</item> </item>
</layout> </layout>

View File

@ -1,6 +1,6 @@
/***************************************************************************** /*****************************************************************************
* gta5view Grand Theft Auto V Profile Viewer * gta5view Grand Theft Auto V Profile Viewer
* Copyright (C) 2017-2018 Syping * Copyright (C) 2017-2021 Syping
* *
* This program is free software: you can redistribute it and/or modify * This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by * it under the terms of the GNU General Public License as published by
@ -28,7 +28,6 @@
#if QT_VERSION >= 0x050200 #if QT_VERSION >= 0x050200
#include <QFontDatabase> #include <QFontDatabase>
#include <QDebug>
#endif #endif
#ifdef GTA5SYNC_TELEMETRY #ifdef GTA5SYNC_TELEMETRY
@ -40,29 +39,30 @@ JsonEditorDialog::JsonEditorDialog(SnapmaticPicture *picture, QWidget *parent) :
ui(new Ui::JsonEditorDialog) ui(new Ui::JsonEditorDialog)
{ {
// Set Window Flags // Set Window Flags
#if QT_VERSION >= 0x050900
setWindowFlag(Qt::WindowContextHelpButtonHint, false);
setWindowFlag(Qt::WindowMinMaxButtonsHint, true);
#else
setWindowFlags(windowFlags()^Qt::WindowContextHelpButtonHint^Qt::WindowMinMaxButtonsHint); setWindowFlags(windowFlags()^Qt::WindowContextHelpButtonHint^Qt::WindowMinMaxButtonsHint);
#endif
ui->setupUi(this); ui->setupUi(this);
ui->cmdClose->setDefault(true); ui->cmdClose->setDefault(true);
ui->cmdClose->setFocus(); ui->cmdClose->setFocus();
// Set Icon for Close Button // Set Icon for Close Button
if (QIcon::hasThemeIcon("dialog-close")) if (QIcon::hasThemeIcon("dialog-close")) {
{
ui->cmdClose->setIcon(QIcon::fromTheme("dialog-close")); ui->cmdClose->setIcon(QIcon::fromTheme("dialog-close"));
} }
else if (QIcon::hasThemeIcon("gtk-close")) else if (QIcon::hasThemeIcon("gtk-close")) {
{
ui->cmdClose->setIcon(QIcon::fromTheme("gtk-close")); ui->cmdClose->setIcon(QIcon::fromTheme("gtk-close"));
} }
// Set Icon for Save Button // Set Icon for Save Button
if (QIcon::hasThemeIcon("document-save")) if (QIcon::hasThemeIcon("document-save")) {
{
ui->cmdSave->setIcon(QIcon::fromTheme("document-save")); ui->cmdSave->setIcon(QIcon::fromTheme("document-save"));
} }
else if (QIcon::hasThemeIcon("gtk-save")) else if (QIcon::hasThemeIcon("gtk-save")) {
{
ui->cmdSave->setIcon(QIcon::fromTheme("gtk-save")); ui->cmdSave->setIcon(QIcon::fromTheme("gtk-save"));
} }
@ -70,9 +70,18 @@ JsonEditorDialog::JsonEditorDialog(SnapmaticPicture *picture, QWidget *parent) :
#if QT_VERSION >= 0x050200 #if QT_VERSION >= 0x050200
ui->txtJSON->setFont(QFontDatabase::systemFont(QFontDatabase::FixedFont)); 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 #endif
QFontMetrics fontMetrics(ui->txtJSON->font()); QFontMetrics fontMetrics(ui->txtJSON->font());
#if QT_VERSION >= 0x050B00
ui->txtJSON->setTabStopDistance(fontMetrics.horizontalAdvance(" "));
#else
ui->txtJSON->setTabStopWidth(fontMetrics.width(" ")); ui->txtJSON->setTabStopWidth(fontMetrics.width(" "));
#endif
QJsonDocument jsonDocument = QJsonDocument::fromJson(jsonCode.toUtf8()); QJsonDocument jsonDocument = QJsonDocument::fromJson(jsonCode.toUtf8());
ui->txtJSON->setStyleSheet("QPlainTextEdit{background-color: rgb(46, 47, 48); color: rgb(238, 231, 172);}"); ui->txtJSON->setStyleSheet("QPlainTextEdit{background-color: rgb(46, 47, 48); color: rgb(238, 231, 172);}");
@ -90,10 +99,10 @@ JsonEditorDialog::JsonEditorDialog(SnapmaticPicture *picture, QWidget *parent) :
ui->hlButtons->setContentsMargins(9 * screenRatio, 0, 9 * screenRatio, 0); ui->hlButtons->setContentsMargins(9 * screenRatio, 0, 9 * screenRatio, 0);
ui->vlInterface->setContentsMargins(0, 0, 0, 9 * screenRatio); ui->vlInterface->setContentsMargins(0, 0, 0, 9 * screenRatio);
#endif #endif
if (screenRatio > 1) if (screenRatio > 1) {
{
ui->lineJSON->setMinimumHeight(qRound(1 * screenRatio)); ui->lineJSON->setMinimumHeight(qRound(1 * screenRatio));
ui->lineJSON->setMaximumHeight(qRound(1 * screenRatio)); ui->lineJSON->setMaximumHeight(qRound(1 * screenRatio));
ui->lineJSON->setLineWidth(qRound(1 * screenRatio));
} }
resize(450 * screenRatio, 550 * screenRatio); resize(450 * screenRatio, 550 * screenRatio);
} }
@ -111,28 +120,22 @@ void JsonEditorDialog::closeEvent(QCloseEvent *ev)
QJsonDocument jsonOriginal = QJsonDocument::fromJson(jsonCode.toUtf8()); QJsonDocument jsonOriginal = QJsonDocument::fromJson(jsonCode.toUtf8());
QString originalCode = QString::fromUtf8(jsonOriginal.toJson(QJsonDocument::Compact)); QString originalCode = QString::fromUtf8(jsonOriginal.toJson(QJsonDocument::Compact));
QString newCode = QString::fromUtf8(jsonNew.toJson(QJsonDocument::Compact)); QString newCode = QString::fromUtf8(jsonNew.toJson(QJsonDocument::Compact));
if (newCode != originalCode) 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); 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 (button == QMessageBox::Yes) {
{ if (saveJsonContent()) {
if (saveJsonContent())
{
ev->accept(); ev->accept();
} }
else else {
{
ev->ignore(); ev->ignore();
} }
return; return;
} }
else if (button == QMessageBox::No) else if (button == QMessageBox::No) {
{
ev->accept(); ev->accept();
return; return;
} }
else else {
{
ev->ignore(); ev->ignore();
return; return;
} }
@ -143,47 +146,38 @@ bool JsonEditorDialog::saveJsonContent()
{ {
QString jsonPatched = QString(ui->txtJSON->toPlainText()).replace("\t", " "); QString jsonPatched = QString(ui->txtJSON->toPlainText()).replace("\t", " ");
QJsonDocument jsonNew = QJsonDocument::fromJson(jsonPatched.toUtf8()); QJsonDocument jsonNew = QJsonDocument::fromJson(jsonPatched.toUtf8());
if (!jsonNew.isEmpty()) if (!jsonNew.isEmpty()) {
{
QJsonDocument jsonOriginal = QJsonDocument::fromJson(jsonCode.toUtf8()); QJsonDocument jsonOriginal = QJsonDocument::fromJson(jsonCode.toUtf8());
QString originalCode = QString::fromUtf8(jsonOriginal.toJson(QJsonDocument::Compact)); QString originalCode = QString::fromUtf8(jsonOriginal.toJson(QJsonDocument::Compact));
QString newCode = QString::fromUtf8(jsonNew.toJson(QJsonDocument::Compact)); QString newCode = QString::fromUtf8(jsonNew.toJson(QJsonDocument::Compact));
if (newCode != originalCode) if (newCode != originalCode) {
{
QString currentFilePath = smpic->getPictureFilePath(); QString currentFilePath = smpic->getPictureFilePath();
QString originalFilePath = smpic->getOriginalPictureFilePath(); QString originalFilePath = smpic->getOriginalPictureFilePath();
QString backupFileName = originalFilePath % ".bak"; QString backupFileName = originalFilePath % ".bak";
if (!QFile::exists(backupFileName)) if (!QFile::exists(backupFileName)) {
{
QFile::copy(currentFilePath, backupFileName); QFile::copy(currentFilePath, backupFileName);
} }
smpic->setJsonStr(newCode, true); smpic->setJsonStr(newCode, true);
if (!smpic->isJsonOk()) if (!smpic->isJsonOk()) {
{
QString lastStep = smpic->getLastStep(false); QString lastStep = smpic->getLastStep(false);
QString readableError; QString readableError;
if (lastStep.contains("JSONINCOMPLETE") && lastStep.contains("JSONERROR")) if (lastStep.contains("JSONINCOMPLETE") && lastStep.contains("JSONERROR")) {
{
readableError = SnapmaticPicture::tr("JSON is incomplete and malformed"); readableError = SnapmaticPicture::tr("JSON is incomplete and malformed");
} }
else if (lastStep.contains("JSONINCOMPLETE")) else if (lastStep.contains("JSONINCOMPLETE")) {
{
readableError = SnapmaticPicture::tr("JSON is incomplete"); readableError = SnapmaticPicture::tr("JSON is incomplete");
} }
else if (lastStep.contains("JSONERROR")) else if (lastStep.contains("JSONERROR")) {
{
readableError = SnapmaticPicture::tr("JSON is malformed"); readableError = SnapmaticPicture::tr("JSON is malformed");
} }
else else {
{
readableError = tr("JSON Error"); readableError = tr("JSON Error");
} }
QMessageBox::warning(this, SnapmaticEditor::tr("Snapmatic Properties"), SnapmaticEditor::tr("Patching of Snapmatic Properties failed because of %1").arg(readableError)); QMessageBox::warning(this, SnapmaticEditor::tr("Snapmatic Properties"), SnapmaticEditor::tr("Patching of Snapmatic Properties failed because of %1").arg(readableError));
smpic->setJsonStr(originalCode, true); smpic->setJsonStr(originalCode, true);
return false; return false;
} }
if (!smpic->exportPicture(currentFilePath)) if (!smpic->exportPicture(currentFilePath)) {
{
QMessageBox::warning(this, SnapmaticEditor::tr("Snapmatic Properties"), SnapmaticEditor::tr("Patching of Snapmatic Properties failed because of I/O Error")); QMessageBox::warning(this, SnapmaticEditor::tr("Snapmatic Properties"), SnapmaticEditor::tr("Patching of Snapmatic Properties failed because of I/O Error"));
smpic->setJsonStr(originalCode, true); smpic->setJsonStr(originalCode, true);
return false; return false;
@ -196,13 +190,16 @@ bool JsonEditorDialog::saveJsonContent()
telemetrySettings.beginGroup("Telemetry"); telemetrySettings.beginGroup("Telemetry");
bool pushUsageData = telemetrySettings.value("PushUsageData", false).toBool(); bool pushUsageData = telemetrySettings.value("PushUsageData", false).toBool();
telemetrySettings.endGroup(); telemetrySettings.endGroup();
if (pushUsageData && Telemetry->canPush()) if (pushUsageData && Telemetry->canPush()) {
{
QJsonDocument jsonDocument; QJsonDocument jsonDocument;
QJsonObject jsonObject; QJsonObject jsonObject;
jsonObject["Type"] = "JSONEdited"; jsonObject["Type"] = "JSONEdited";
jsonObject["EditedSize"] = QString::number(smpic->getContentMaxLength()); jsonObject["EditedSize"] = QString::number(smpic->getContentMaxLength());
#if QT_VERSION >= 0x060000
jsonObject["EditedTime"] = QString::number(QDateTime::currentDateTimeUtc().toSecsSinceEpoch());
#else
jsonObject["EditedTime"] = QString::number(QDateTime::currentDateTimeUtc().toTime_t()); jsonObject["EditedTime"] = QString::number(QDateTime::currentDateTimeUtc().toTime_t());
#endif
jsonDocument.setObject(jsonObject); jsonDocument.setObject(jsonObject);
Telemetry->push(TelemetryCategory::PersonalData, jsonDocument); Telemetry->push(TelemetryCategory::PersonalData, jsonDocument);
} }
@ -211,8 +208,7 @@ bool JsonEditorDialog::saveJsonContent()
} }
return true; return true;
} }
else else {
{
QMessageBox::warning(this, SnapmaticEditor::tr("Snapmatic Properties"), SnapmaticEditor::tr("Patching of Snapmatic Properties failed because of JSON Error")); QMessageBox::warning(this, SnapmaticEditor::tr("Snapmatic Properties"), SnapmaticEditor::tr("Patching of Snapmatic Properties failed because of JSON Error"));
return false; return false;
} }
@ -226,7 +222,5 @@ void JsonEditorDialog::on_cmdClose_clicked()
void JsonEditorDialog::on_cmdSave_clicked() void JsonEditorDialog::on_cmdSave_clicked()
{ {
if (saveJsonContent()) if (saveJsonContent())
{
close(); close();
}
} }

View File

@ -1,6 +1,6 @@
/***************************************************************************** /*****************************************************************************
* gta5view Grand Theft Auto V Profile Viewer * gta5view Grand Theft Auto V Profile Viewer
* Copyright (C) 2017 Syping * Copyright (C) 2017-2021 Syping
* *
* This program is free software: you can redistribute it and/or modify * This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by * it under the terms of the GNU General Public License as published by
@ -20,8 +20,8 @@
#include "ui_MapLocationDialog.h" #include "ui_MapLocationDialog.h"
#include "IconLoader.h" #include "IconLoader.h"
#include "AppEnv.h" #include "AppEnv.h"
#include <QStringBuilder>
#include <QPainter> #include <QPainter>
#include <QDebug>
#include <QStyle> #include <QStyle>
MapLocationDialog::MapLocationDialog(double x, double y, QWidget *parent) : MapLocationDialog::MapLocationDialog(double x, double y, QWidget *parent) :
@ -29,7 +29,11 @@ MapLocationDialog::MapLocationDialog(double x, double y, QWidget *parent) :
ui(new Ui::MapLocationDialog) ui(new Ui::MapLocationDialog)
{ {
// Set Window Flags // Set Window Flags
#if QT_VERSION >= 0x050900
setWindowFlag(Qt::WindowContextHelpButtonHint, false);
#else
setWindowFlags(windowFlags()^Qt::WindowContextHelpButtonHint); setWindowFlags(windowFlags()^Qt::WindowContextHelpButtonHint);
#endif
ui->setupUi(this); ui->setupUi(this);
ui->cmdDone->setVisible(false); ui->cmdDone->setVisible(false);
@ -45,12 +49,10 @@ MapLocationDialog::MapLocationDialog(double x, double y, QWidget *parent) :
ui->vlMapDialog->setSpacing(widgetMargin); ui->vlMapDialog->setSpacing(widgetMargin);
setMinimumSize(500 * screenRatio, 600 * screenRatio); setMinimumSize(500 * screenRatio, 600 * screenRatio);
setMaximumSize(500 * screenRatio, 600 * screenRatio); setMaximumSize(500 * screenRatio, 600 * screenRatio);
setFixedSize(500 * screenRatio, 600 * screenRatio);
setMouseTracking(true);
zoomPercent = 100;
changeMode = false; changeMode = false;
propUpdate = false; propUpdate = false;
drawPointOnMap(xpos_old, ypos_old);
} }
MapLocationDialog::~MapLocationDialog() MapLocationDialog::~MapLocationDialog()
@ -60,36 +62,224 @@ MapLocationDialog::~MapLocationDialog()
void MapLocationDialog::drawPointOnMap(double xpos_d, double ypos_d) void MapLocationDialog::drawPointOnMap(double xpos_d, double ypos_d)
{ {
qreal screenRatio = AppEnv::screenRatio(); ui->labPos->setText(tr("X: %1\nY: %2", "X and Y position").arg(QString::number(xpos_d), QString::number(ypos_d)));
int pointMakerSize = 8 * screenRatio;
QPixmap pointMakerPixmap = IconLoader::loadingPointmakerIcon().pixmap(QSize(pointMakerSize, pointMakerSize));
QSize mapPixelSize = size();
int pointMakerHalfSize = pointMakerSize / 2;
long xpos_ms = qRound(xpos_d);
long ypos_ms = qRound(ypos_d);
double xpos_ma = xpos_ms + 4000;
double ypos_ma = ypos_ms + 4000;
double xrat = (double)mapPixelSize.width() / 10000;
double yrat = (double)mapPixelSize.height() / 12000;
long xpos_mp = qRound(xpos_ma * xrat);
long ypos_mp = qRound(ypos_ma * yrat);
long xpos_pr = xpos_mp - pointMakerHalfSize;
long ypos_pr = ypos_mp + pointMakerHalfSize;
QPixmap mapPixmap(mapPixelSize);
QPainter mapPainter(&mapPixmap);
mapPainter.drawPixmap(0, 0, mapPixelSize.width(), mapPixelSize.height(), QPixmap(":/img/mappreview.jpg").scaled(mapPixelSize, Qt::IgnoreAspectRatio, Qt::SmoothTransformation));
mapPainter.drawPixmap(xpos_pr, mapPixelSize.height() - ypos_pr, pointMakerSize, pointMakerSize, pointMakerPixmap);
mapPainter.end();
QPalette backgroundPalette;
backgroundPalette.setBrush(backgroundRole(), QBrush(mapPixmap));
setPalette(backgroundPalette);
xpos_new = xpos_d; xpos_new = xpos_d;
ypos_new = ypos_d; ypos_new = ypos_d;
ui->labPos->setText(tr("X: %1\nY: %2", "X and Y position").arg(QString::number(xpos_d), QString::number(ypos_d))); repaint();
}
void MapLocationDialog::setCayoPerico(bool isCayoPerico)
{
qreal screenRatio = AppEnv::screenRatio();
p_isCayoPerico = isCayoPerico;
if (isCayoPerico) {
setMinimumSize(500 * screenRatio, 500 * screenRatio);
setMaximumSize(500 * screenRatio, 500 * screenRatio);
ui->hlMapDialog->removeItem(ui->vlMapDialog);
ui->hlMapDialog->insertLayout(0, ui->vlMapDialog);
ui->hlMapDialog->removeItem(ui->vlPosLayout);
ui->hlMapDialog->addLayout(ui->vlPosLayout);
ui->labPos->setAlignment(Qt::AlignRight);
mapImage = QImage(AppEnv::getImagesFolder() % "/mapcayoperico.jpg");
}
else {
mapImage = QImage(AppEnv::getImagesFolder() % "/mappreview.jpg");
}
drawPointOnMap(xpos_old, ypos_old);
}
void MapLocationDialog::updatePosFromEvent(double x, double y)
{
QSize mapPixelSize = size();
double x_per = x / mapPixelSize.width(); // get X %
double y_per = y / mapPixelSize.height(); // get Y %
double x_pos, y_pos;
if (p_isCayoPerico) {
x_pos = x_per * 2340; // 2340 is 100% for X (Cayo Perico)
y_pos = y_per * -2340; // -2340 is 100% for Y (Cayo Perico)
x_pos = x_pos + 3560; // +3560 gets corrected for X (Cayo Perico)
y_pos = y_pos - 3980; // -3980 gets corrected for Y (Cayo Perico)
}
else {
x_pos = x_per * 10000; // 10000 is 100% for X (Los Santos)
y_pos = y_per * -12000; // -12000 is 100% for Y (Los Santos)
x_pos = x_pos - 4000; // -4000 gets corrected for X (Los Santos)
y_pos = y_pos + 8000; // +8000 gets corrected for Y (Los Santos)
}
drawPointOnMap(x_pos, y_pos);
}
void MapLocationDialog::paintEvent(QPaintEvent *ev)
{
QPainter painter(this);
painter.setRenderHint(QPainter::SmoothPixmapTransform, true);
// Screen Ratio
qreal screenRatio = AppEnv::screenRatio();
qreal screenRatioPR = AppEnv::screenRatioPR();
// Paint Map
const double zoomLevel = static_cast<double>(zoomPercent) / 100;
const QSize mapImageSize = mapImage.size();
const QPointF mapImageMid(static_cast<double>(mapImageSize.width()) / 2, static_cast<double>(mapImageSize.height()) / 2);
const QSizeF srcImageSize(static_cast<double>(mapImageSize.width()) / zoomLevel , static_cast<double>(mapImageSize.height()) / zoomLevel);
const QPointF mapImageTopLeft(mapImageMid.x() - (srcImageSize.width() / 2), mapImageMid.y() - (srcImageSize.height() / 2));
const QPointF mapImageBottomRight(mapImageMid.x() + (srcImageSize.width() / 2), mapImageMid.y() + (srcImageSize.height() / 2));
painter.drawImage(QRect(QPoint(0, 0), size()), mapImage, QRectF(mapImageTopLeft, mapImageBottomRight));
// Paint Marker
QSize mapPixelSize = size();
int pointMarkerSize = 8 * screenRatio;
int pointMarkerHalfSize = pointMarkerSize / 2;
double xpos_mp, ypos_mp;
if (p_isCayoPerico) {
double xpos_per = xpos_new - 3560; // correct X in reserve
double ypos_per = ypos_new + 3980; // correct y in reserve
xpos_per = xpos_per / 2340; // divide 100% for X
ypos_per = ypos_per / -2340; // divide 100% for Y
xpos_mp = xpos_per * mapPixelSize.width(); // locate window width pos
ypos_mp = ypos_per * mapPixelSize.height(); // locate window height pos
}
else {
double xpos_per = xpos_new + 4000; // correct X in reserve
double ypos_per = ypos_new - 8000; // correct y in reserve
xpos_per = xpos_per / 10000; // divide 100% for X
ypos_per = ypos_per / -12000; // divide 100% for Y
xpos_mp = xpos_per * mapPixelSize.width(); // locate window width pos
ypos_mp = ypos_per * mapPixelSize.height(); // locate window height pos
}
QPointF pointMarkerPos(xpos_mp, ypos_mp);
if (screenRatioPR != 1) {
pointMarkerPos.setX(pointMarkerPos.x() - pointMarkerHalfSize + screenRatioPR);
pointMarkerPos.setY(pointMarkerPos.y() - pointMarkerHalfSize + screenRatioPR);
}
else {
pointMarkerPos.setX(pointMarkerPos.x() - pointMarkerHalfSize);
pointMarkerPos.setY(pointMarkerPos.y() - pointMarkerHalfSize);
}
QPixmap mapMarkerPixmap = IconLoader::loadingPointmakerIcon().pixmap(QSize(pointMarkerSize, pointMarkerSize));
painter.drawPixmap(pointMarkerPos, mapMarkerPixmap);
QDialog::paintEvent(ev);
}
void MapLocationDialog::mouseMoveEvent(QMouseEvent *ev)
{
if (changeMode && ev->buttons() & Qt::LeftButton) {
#if QT_VERSION >= 0x060000
const QPointF localPos = ev->position();
#elif QT_VERSION >= 0x050000
const QPointF localPos = ev->localPos();
#else
const QPointF localPos = ev->posF();
#endif
#ifdef Q_OS_WIN
qreal screenRatioPR = AppEnv::screenRatioPR();
if (screenRatioPR != 1) {
updatePosFromEvent(localPos.x() - screenRatioPR, localPos.y() - screenRatioPR);
}
else {
updatePosFromEvent(localPos.x(), localPos.y());
}
#else
updatePosFromEvent(localPos.x(), localPos.y());
#endif
}
else if (dragStart && ev->buttons() & Qt::LeftButton) {
#if QT_VERSION >= 0x060000
const QPointF dragNewPosition = ev->position();
#elif QT_VERSION >= 0x050000
const QPointF dragNewPosition = ev->localPos();
#else
const QPointF dragNewPosition = ev->posF();
#endif
mapDiffPosition = dragNewPosition - dragPosition + mapDiffPosition;
dragPosition = dragNewPosition;
}
}
void MapLocationDialog::mousePressEvent(QMouseEvent *ev)
{
if (!changeMode && ev->button() == Qt::LeftButton) {
#if QT_VERSION >= 0x060000
dragPosition = ev->position();
#elif QT_VERSION >= 0x050000
dragPosition = ev->localPos();
#else
dragPosition = ev->posF();
#endif
dragStart = true;
}
}
void MapLocationDialog::mouseReleaseEvent(QMouseEvent *ev)
{
if (changeMode && ev->button() == Qt::LeftButton) {
#if QT_VERSION >= 0x060000
const QPointF localPos = ev->position();
#elif QT_VERSION >= 0x050000
const QPointF localPos = ev->localPos();
#else
const QPointF localPos = ev->posF();
#endif
#ifdef Q_OS_WIN
qreal screenRatioPR = AppEnv::screenRatioPR();
if (screenRatioPR != 1) {
updatePosFromEvent(localPos.x() - screenRatioPR, localPos.y() - screenRatioPR);
}
else {
updatePosFromEvent(localPos.x(), localPos.y());
}
#else
updatePosFromEvent(localPos.x(), localPos.y());
#endif
}
else if (dragStart && ev->button() == Qt::LeftButton) {
dragStart = false;
}
}
void MapLocationDialog::wheelEvent(QWheelEvent *ev)
{
#ifdef GTA5SYNC_EXPERIMENTAL
#if QT_VERSION >= 0x050000
const QPoint numPixels = ev->pixelDelta();
const QPoint numDegrees = ev->angleDelta();
#else
QPoint numDegrees;
if (ev->orientation() == Qt::Horizontal) {
numDegrees.setX(ev->delta());
}
else {
numDegrees.setY(ev->delta());
}
#endif
#if QT_VERSION >= 0x050000
if (!numPixels.isNull()) {
if (numPixels.y() < 0 && zoomPercent != 100) {
zoomPercent = zoomPercent - 10;
repaint();
}
else if (numPixels.y() > 0 && zoomPercent != 400) {
zoomPercent = zoomPercent + 10;
repaint();
}
return;
}
#endif
if (!numDegrees.isNull()) {
if (numDegrees.y() < 0 && zoomPercent != 100) {
zoomPercent = zoomPercent - 10;
repaint();
}
else if (numDegrees.y() > 0 && zoomPercent != 400) {
zoomPercent = zoomPercent + 10;
repaint();
}
}
#else
Q_UNUSED(ev)
#endif
} }
void MapLocationDialog::on_cmdChange_clicked() void MapLocationDialog::on_cmdChange_clicked()
@ -111,58 +301,14 @@ void MapLocationDialog::on_cmdDone_clicked()
{ {
ui->cmdDone->setVisible(false); ui->cmdDone->setVisible(false);
ui->cmdChange->setVisible(true); ui->cmdChange->setVisible(true);
if (xpos_new != xpos_old || ypos_new != ypos_old) if (xpos_new != xpos_old || ypos_new != ypos_old) {
{
ui->cmdApply->setVisible(true); ui->cmdApply->setVisible(true);
ui->cmdRevert->setVisible(true); ui->cmdRevert->setVisible(true);
} }
setCursor(Qt::ArrowCursor); setCursor(Qt::ArrowCursor);
changeMode = false; changeMode = false;
} }
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);
}
void MapLocationDialog::mouseMoveEvent(QMouseEvent *ev)
{
if (!changeMode) { ev->ignore(); }
else if (ev->buttons() & Qt::LeftButton)
{
updatePosFromEvent(ev->x(), ev->y());
ev->accept();
}
else
{
ev->ignore();
}
}
void MapLocationDialog::mouseReleaseEvent(QMouseEvent *ev)
{
if (!changeMode) { ev->ignore(); }
else if (ev->button() == Qt::LeftButton)
{
updatePosFromEvent(ev->x(), ev->y());
ev->accept();
}
else
{
ev->ignore();
}
}
void MapLocationDialog::on_cmdApply_clicked() void MapLocationDialog::on_cmdApply_clicked()
{ {
propUpdate = true; propUpdate = true;

View File

@ -1,6 +1,6 @@
/***************************************************************************** /*****************************************************************************
* gta5view Grand Theft Auto V Profile Viewer * gta5view Grand Theft Auto V Profile Viewer
* Copyright (C) 2017 Syping * Copyright (C) 2017-2021 Syping
* *
* This program is free software: you can redistribute it and/or modify * This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by * it under the terms of the GNU General Public License as published by
@ -33,30 +33,40 @@ class MapLocationDialog : public QDialog
public: public:
explicit MapLocationDialog(double x, double y, QWidget *parent = 0); explicit MapLocationDialog(double x, double y, QWidget *parent = 0);
void drawPointOnMap(double x, double y); void drawPointOnMap(double x, double y);
void setCayoPerico(bool isCayoPerico);
bool propUpdated(); bool propUpdated();
double getXpos(); double getXpos();
double getYpos(); double getYpos();
~MapLocationDialog(); ~MapLocationDialog();
protected: protected:
void paintEvent(QPaintEvent *ev);
void mouseMoveEvent(QMouseEvent *ev); void mouseMoveEvent(QMouseEvent *ev);
void mousePressEvent(QMouseEvent *ev);
void mouseReleaseEvent(QMouseEvent *ev); void mouseReleaseEvent(QMouseEvent *ev);
void wheelEvent(QWheelEvent *ev);
private slots: private slots:
void on_cmdDone_clicked();
void on_cmdApply_clicked(); void on_cmdApply_clicked();
void on_cmdDone_clicked();
void on_cmdClose_clicked();
void on_cmdChange_clicked(); void on_cmdChange_clicked();
void on_cmdRevert_clicked(); void on_cmdRevert_clicked();
void updatePosFromEvent(int x, int y); void updatePosFromEvent(double x, double y);
void on_cmdClose_clicked();
private: private:
int zoomPercent;
double xpos_old; double xpos_old;
double ypos_old; double ypos_old;
double xpos_new; double xpos_new;
double ypos_new; double ypos_new;
bool dragStart;
bool propUpdate; bool propUpdate;
bool changeMode; bool changeMode;
bool p_isCayoPerico;
QImage mapImage;
QPointF dragPosition;
QPointF mapDiffPosition;
Ui::MapLocationDialog *ui; Ui::MapLocationDialog *ui;
}; };

View File

@ -25,6 +25,11 @@
<property name="windowTitle"> <property name="windowTitle">
<string>Snapmatic Map Viewer</string> <string>Snapmatic Map Viewer</string>
</property> </property>
<property name="styleSheet">
<string notr="true">QDialog#MapLocationDialog {
background-color: transparent;
}</string>
</property>
<layout class="QVBoxLayout" name="vlMapPreview"> <layout class="QVBoxLayout" name="vlMapPreview">
<property name="spacing"> <property name="spacing">
<number>0</number> <number>0</number>

111
MessageThread.cpp Normal file
View File

@ -0,0 +1,111 @@
/*****************************************************************************
* 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,6 +1,6 @@
/***************************************************************************** /*****************************************************************************
* gta5view Grand Theft Auto V Profile Viewer * gta5view Grand Theft Auto V Profile Viewer
* Copyright (C) 2016-2017 Syping * Copyright (C) 2020 Syping
* *
* This program is free software: you can redistribute it and/or modify * This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by * it under the terms of the GNU General Public License as published by
@ -16,37 +16,33 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>. * along with this program. If not, see <http://www.gnu.org/licenses/>.
*****************************************************************************/ *****************************************************************************/
#ifndef IMAGEEDITORDIALOG_H #ifndef MESSAGETHREAD_H
#define IMAGEEDITORDIALOG_H #define MESSAGETHREAD_H
#include "SnapmaticPicture.h" #include <QJsonObject>
#include <QDialog> #include <QObject>
#include <QThread>
namespace Ui { class MessageThread : public QThread
class ImageEditorDialog;
}
class ImageEditorDialog : public QDialog
{ {
Q_OBJECT Q_OBJECT
public: public:
explicit ImageEditorDialog(SnapmaticPicture *picture, QString profileName, QWidget *parent = 0); explicit MessageThread(uint cacheId, QObject *parent = 0);
~ImageEditorDialog();
private slots: public slots:
void on_cmdClose_clicked(); void terminateThread();
void on_cmdReplace_clicked();
void on_cmdSave_clicked();
private: private:
SnapmaticPicture *smpic; bool threadRunning;
QString profileName; uint cacheId;
Ui::ImageEditorDialog *ui;
int snapmaticResolutionLW; protected:
int snapmaticResolutionLH; void run();
bool imageIsChanged;
QImage pictureCache; signals:
void messagesArrived(const QJsonObject &messageObject);
void updateCacheId(uint cacheId);
void threadTerminated();
}; };
#endif // IMAGEEDITORDIALOG_H #endif // MESSAGETHREAD_H

View File

@ -1,6 +1,6 @@
/***************************************************************************** /*****************************************************************************
* gta5view Grand Theft Auto V Profile Viewer * gta5view Grand Theft Auto V Profile Viewer
* Copyright (C) 2016-2018 Syping * Copyright (C) 2016-2021 Syping
* *
* This program is free software: you can redistribute it and/or modify * This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by * it under the terms of the GNU General Public License as published by
@ -21,15 +21,16 @@
#include "TranslationClass.h" #include "TranslationClass.h"
#include "StandardPaths.h" #include "StandardPaths.h"
#include "UserInterface.h" #include "UserInterface.h"
#include "wrapper.h"
#include "AppEnv.h" #include "AppEnv.h"
#include "config.h" #include "config.h"
#include <QStringBuilder> #include <QStringBuilder>
#include <QDesktopWidget>
#include <QJsonDocument> #include <QJsonDocument>
#include <QStyleFactory> #include <QStyleFactory>
#include <QApplication> #include <QApplication>
#include <QJsonObject> #include <QJsonObject>
#include <QFileDialog> #include <QFileDialog>
#include <QFontDialog>
#include <QMessageBox> #include <QMessageBox>
#include <QStringList> #include <QStringList>
#include <QClipboard> #include <QClipboard>
@ -40,6 +41,12 @@
#include <QList> #include <QList>
#include <QDir> #include <QDir>
#if QT_VERSION >= 0x050000
#include <QScreen>
#else
#include <QDesktopWidget>
#endif
#ifdef GTA5SYNC_TELEMETRY #ifdef GTA5SYNC_TELEMETRY
#include "TelemetryClass.h" #include "TelemetryClass.h"
#endif #endif
@ -49,7 +56,11 @@ OptionsDialog::OptionsDialog(ProfileDatabase *profileDB, QWidget *parent) :
ui(new Ui::OptionsDialog) ui(new Ui::OptionsDialog)
{ {
// Set Window Flags // Set Window Flags
#if QT_VERSION >= 0x050900
setWindowFlag(Qt::WindowContextHelpButtonHint, false);
#else
setWindowFlags(windowFlags()^Qt::WindowContextHelpButtonHint); setWindowFlags(windowFlags()^Qt::WindowContextHelpButtonHint);
#endif
// Setup User Interface // Setup User Interface
ui->setupUi(this); ui->setupUi(this);
@ -58,11 +69,18 @@ OptionsDialog::OptionsDialog(ProfileDatabase *profileDB, QWidget *parent) :
ui->cmdCancel->setDefault(true); ui->cmdCancel->setDefault(true);
ui->cmdCancel->setFocus(); ui->cmdCancel->setFocus();
#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(this); QRect desktopResolution = QApplication::desktop()->screenGeometry(this);
int desktopSizeWidth = desktopResolution.width(); int desktopSizeWidth = desktopResolution.width();
int desktopSizeHeight = desktopResolution.height(); int desktopSizeHeight = desktopResolution.height();
#endif
aspectRatio = Qt::KeepAspectRatio; aspectRatio = Qt::KeepAspectRatio;
defExportSize = QSize(960, 536); defExportSize = SnapmaticPicture::getSnapmaticResolution();
cusExportSize = defExportSize; cusExportSize = defExportSize;
defaultQuality = 100; defaultQuality = 100;
customQuality = 100; customQuality = 100;
@ -75,25 +93,26 @@ OptionsDialog::OptionsDialog(ProfileDatabase *profileDB, QWidget *parent) :
ui->rbPicDefaultRes->setText(ui->rbPicDefaultRes->text().arg(QString::number(defExportSize.width()), QString::number(defExportSize.height()))); ui->rbPicDefaultRes->setText(ui->rbPicDefaultRes->text().arg(QString::number(defExportSize.width()), QString::number(defExportSize.height())));
// Set Icon for OK Button // Set Icon for OK Button
if (QIcon::hasThemeIcon("dialog-ok")) if (QIcon::hasThemeIcon("dialog-ok")) {
{
ui->cmdOK->setIcon(QIcon::fromTheme("dialog-ok")); ui->cmdOK->setIcon(QIcon::fromTheme("dialog-ok"));
} }
else if (QIcon::hasThemeIcon("gtk-ok")) else if (QIcon::hasThemeIcon("gtk-ok")) {
{
ui->cmdOK->setIcon(QIcon::fromTheme("gtk-ok")); ui->cmdOK->setIcon(QIcon::fromTheme("gtk-ok"));
} }
// Set Icon for Cancel Button // Set Icon for Cancel Button
if (QIcon::hasThemeIcon("dialog-cancel")) if (QIcon::hasThemeIcon("dialog-cancel")) {
{
ui->cmdCancel->setIcon(QIcon::fromTheme("dialog-cancel")); ui->cmdCancel->setIcon(QIcon::fromTheme("dialog-cancel"));
} }
else if (QIcon::hasThemeIcon("gtk-cancel")) else if (QIcon::hasThemeIcon("gtk-cancel")) {
{
ui->cmdCancel->setIcon(QIcon::fromTheme("gtk-cancel")); ui->cmdCancel->setIcon(QIcon::fromTheme("gtk-cancel"));
} }
// Set Icon for Copy Button
if (QIcon::hasThemeIcon("edit-copy")) {
ui->cmdCopyStatsID->setIcon(QIcon::fromTheme("edit-copy"));
}
setupTreeWidget(); setupTreeWidget();
setupLanguageBox(); setupLanguageBox();
setupRadioButtons(); setupRadioButtons();
@ -111,6 +130,8 @@ OptionsDialog::OptionsDialog(ProfileDatabase *profileDB, QWidget *parent) :
resize(435 * screenRatio, 405 * screenRatio); resize(435 * screenRatio, 405 * screenRatio);
#endif #endif
ui->rbModern->setText(ui->rbModern->text().arg(GTA5SYNC_APPSTR));
ui->rbClassic->setText(ui->rbClassic->text().arg(GTA5SYNC_APPSTR));
setWindowTitle(windowTitle().arg(GTA5SYNC_APPSTR)); setWindowTitle(windowTitle().arg(GTA5SYNC_APPSTR));
} }
@ -124,24 +145,28 @@ OptionsDialog::~OptionsDialog()
void OptionsDialog::setupTreeWidget() void OptionsDialog::setupTreeWidget()
{ {
for (QString playerIDStr : profileDB->getPlayers()) const QStringList players = profileDB->getPlayers();
{ if (players.length() != 0) {
bool ok; for (auto it = players.constBegin(); it != players.constEnd(); it++) {
int playerID = playerIDStr.toInt(&ok); bool ok;
if (ok) int playerID = it->toInt(&ok);
{ if (ok) {
QString playerName = profileDB->getPlayerName(playerID); const QString playerName = profileDB->getPlayerName(playerID);
QStringList playerTreeViewList; QStringList playerTreeViewList;
playerTreeViewList += playerIDStr; playerTreeViewList += *it;
playerTreeViewList += playerName; playerTreeViewList += playerName;
QTreeWidgetItem *playerItem = new QTreeWidgetItem(playerTreeViewList); QTreeWidgetItem *playerItem = new QTreeWidgetItem(playerTreeViewList);
ui->twPlayers->addTopLevelItem(playerItem); ui->twPlayers->addTopLevelItem(playerItem);
playerItems += playerItem; playerItems += playerItem;
}
} }
ui->twPlayers->sortItems(1, Qt::AscendingOrder);
}
else {
ui->tabWidget->removeTab(ui->tabWidget->indexOf(ui->tabPlayers));
} }
ui->twPlayers->sortItems(1, Qt::AscendingOrder);
} }
void OptionsDialog::setupLanguageBox() void OptionsDialog::setupLanguageBox()
@ -151,20 +176,18 @@ void OptionsDialog::setupLanguageBox()
currentAreaLanguage = settings->value("AreaLanguage", "Auto").toString(); currentAreaLanguage = settings->value("AreaLanguage", "Auto").toString();
settings->endGroup(); settings->endGroup();
QString cbSysStr = tr("%1 (Language priority)", "First language a person can talk with a different person/application. \"Native\" or \"Not Native\".").arg(tr("System", const QString cbSysStr = tr("%1 (Language priority)", "First language a person can talk with a different person/application. \"Native\" or \"Not Native\".").arg(tr("System",
"System in context of System default")); "System in context of System default"));
#ifdef GTA5SYNC_WIN #ifdef Q_OS_WIN
QString cbAutoStr; QString cbAutoStr;
if (AppEnv::getGameLanguage(AppEnv::getGameVersion()) != GameLanguage::Undefined) if (AppEnv::getGameLanguage(AppEnv::getGameVersion()) != GameLanguage::Undefined) {
{
cbAutoStr = tr("%1 (Game language)", "Next closest language compared to the Game settings").arg(tr("Auto", "Automatic language choice.")); cbAutoStr = tr("%1 (Game language)", "Next closest language compared to the Game settings").arg(tr("Auto", "Automatic language choice."));
} }
else else {
{
cbAutoStr = tr("%1 (Closest to Interface)", "Next closest language compared to the Interface").arg(tr("Auto", "Automatic language choice.")); cbAutoStr = tr("%1 (Closest to Interface)", "Next closest language compared to the Interface").arg(tr("Auto", "Automatic language choice."));
} }
#else #else
QString cbAutoStr = tr("%1 (Closest to Interface)", "Next closest language compared to the Interface").arg(tr("Auto", "Automatic language choice.")); const QString cbAutoStr = tr("%1 (Closest to Interface)", "Next closest language compared to the Interface").arg(tr("Auto", "Automatic language choice."));
#endif #endif
ui->cbLanguage->addItem(cbSysStr, "System"); ui->cbLanguage->addItem(cbSysStr, "System");
ui->cbAreaLanguage->addItem(cbAutoStr, "Auto"); ui->cbAreaLanguage->addItem(cbAutoStr, "Auto");
@ -178,15 +201,18 @@ void OptionsDialog::setupLanguageBox()
availableLanguages.removeDuplicates(); availableLanguages.removeDuplicates();
availableLanguages.sort(); availableLanguages.sort();
for (QString lang : availableLanguages) for (const QString &lang : qAsConst(availableLanguages)) {
{
QLocale langLocale(lang); QLocale langLocale(lang);
QString cbLangStr = langLocale.nativeLanguageName() % " (" % langLocale.nativeCountryName() % ") [" % lang % "]"; const QString cbLangStr = langLocale.nativeLanguageName() % " (" % langLocale.nativeCountryName() % ") [" % lang % "]";
QString langIconStr = "flag-" % TranslationClass::getCountryCode(langLocale); const QString langIconPath = AppEnv::getImagesFolder() % "/flag-" % TranslationClass::getCountryCode(langLocale) % ".png";
ui->cbLanguage->addItem(QIcon::fromTheme(langIconStr), cbLangStr, lang); if (QFile::exists(langIconPath)) {
if (currentLanguage == lang) ui->cbLanguage->addItem(QIcon(langIconPath), cbLangStr, lang);
{ }
else {
ui->cbLanguage->addItem(cbLangStr, lang);
}
if (currentLanguage == lang) {
#if QT_VERSION >= 0x050000 #if QT_VERSION >= 0x050000
ui->cbLanguage->setCurrentText(cbLangStr); ui->cbLanguage->setCurrentText(cbLangStr);
#else #else
@ -197,7 +223,8 @@ void OptionsDialog::setupLanguageBox()
} }
QString aCurrentLanguage = QString("en_GB"); QString aCurrentLanguage = QString("en_GB");
if (Translator->isLanguageLoaded()) { aCurrentLanguage = Translator->getCurrentLanguage(); } if (Translator->isLanguageLoaded())
aCurrentLanguage = Translator->getCurrentLanguage();
QLocale currentLocale = QLocale(aCurrentLanguage); QLocale currentLocale = QLocale(aCurrentLanguage);
ui->labCurrentLanguage->setText(tr("Current: %1").arg(currentLocale.nativeLanguageName() % " (" % currentLocale.nativeCountryName() % ") [" % aCurrentLanguage % "]")); ui->labCurrentLanguage->setText(tr("Current: %1").arg(currentLocale.nativeLanguageName() % " (" % currentLocale.nativeCountryName() % ") [" % aCurrentLanguage % "]"));
@ -206,27 +233,21 @@ void OptionsDialog::setupLanguageBox()
availableLanguages.removeDuplicates(); availableLanguages.removeDuplicates();
availableLanguages.sort(); availableLanguages.sort();
for (QString lang : availableLanguages) for (const QString &lang : qAsConst(availableLanguages)) {
{
// correcting Language Location if possible // correcting Language Location if possible
QString aLang = lang; QString aLang = lang;
if (QFile::exists(":/global/global." % lang % ".loc")) if (QFile::exists(":/global/global." % lang % ".loc")) {
{
QFile locFile(":/global/global." % lang % ".loc"); QFile locFile(":/global/global." % lang % ".loc");
if (locFile.open(QFile::ReadOnly)) if (locFile.open(QFile::ReadOnly)) {
{
aLang = QString::fromUtf8(locFile.readLine()).trimmed(); aLang = QString::fromUtf8(locFile.readLine()).trimmed();
locFile.close(); locFile.close();
} }
} }
QLocale langLocale(aLang); QLocale langLocale(aLang);
QString cbLangStr = langLocale.nativeLanguageName() % " (" % langLocale.nativeCountryName() % ") [" % aLang % "]"; const QString cbLangStr = langLocale.nativeLanguageName() % " (" % langLocale.nativeCountryName() % ") [" % aLang % "]";
QString langIconStr = "flag-" % TranslationClass::getCountryCode(langLocale); ui->cbAreaLanguage->addItem(cbLangStr, lang);
if (currentAreaLanguage == lang) {
ui->cbAreaLanguage->addItem(QIcon::fromTheme(langIconStr), cbLangStr, lang);
if (currentAreaLanguage == lang)
{
#if QT_VERSION >= 0x050000 #if QT_VERSION >= 0x050000
ui->cbAreaLanguage->setCurrentText(cbLangStr); ui->cbAreaLanguage->setCurrentText(cbLangStr);
#else #else
@ -237,12 +258,10 @@ void OptionsDialog::setupLanguageBox()
} }
QString aCurrentAreaLanguage = Translator->getCurrentAreaLanguage(); QString aCurrentAreaLanguage = Translator->getCurrentAreaLanguage();
if (QFile::exists(":/global/global." % aCurrentAreaLanguage % ".loc")) if (QFile::exists(":/global/global." % aCurrentAreaLanguage % ".loc")) {
{
qDebug() << "locFile found"; qDebug() << "locFile found";
QFile locFile(":/global/global." % aCurrentAreaLanguage % ".loc"); QFile locFile(":/global/global." % aCurrentAreaLanguage % ".loc");
if (locFile.open(QFile::ReadOnly)) if (locFile.open(QFile::ReadOnly)) {
{
aCurrentAreaLanguage = QString::fromUtf8(locFile.readLine()).trimmed(); aCurrentAreaLanguage = QString::fromUtf8(locFile.readLine()).trimmed();
locFile.close(); locFile.close();
} }
@ -258,18 +277,26 @@ void OptionsDialog::setupRadioButtons()
contentMode = settings->value("ContentMode", 0).toInt(&contentModeOk); contentMode = settings->value("ContentMode", 0).toInt(&contentModeOk);
settings->endGroup(); settings->endGroup();
if (contentModeOk) if (contentModeOk) {
{ switch (contentMode) {
switch (contentMode)
{
case 0: case 0:
ui->rbOpenWithSC->setChecked(true); case 20:
ui->rbModern->setChecked(true);
ui->cbDoubleclick->setChecked(false);
break; break;
case 1: case 1:
ui->rbOpenWithDC->setChecked(true);
break;
case 2: case 2:
ui->rbSelectWithSC->setChecked(true); case 21:
ui->rbModern->setChecked(true);
ui->cbDoubleclick->setChecked(true);
break;
case 10:
ui->rbClassic->setChecked(true);
ui->cbDoubleclick->setChecked(false);
break;
case 11:
ui->rbClassic->setChecked(true);
ui->cbDoubleclick->setChecked(true);
break; break;
} }
} }
@ -278,55 +305,40 @@ void OptionsDialog::setupRadioButtons()
void OptionsDialog::setupInterfaceSettings() void OptionsDialog::setupInterfaceSettings()
{ {
settings->beginGroup("Startup"); settings->beginGroup("Startup");
bool alwaysUseMessageFont = settings->value("AlwaysUseMessageFont", false).toBool(); const QString currentStyle = QApplication::style()->objectName();
ui->cbAlwaysUseMessageFont->setChecked(alwaysUseMessageFont); const QString appStyle = settings->value("AppStyle", currentStyle).toString();
#ifdef GTA5SYNC_WIN
if (QSysInfo::windowsVersion() >= 0x0080)
{
ui->gbFont->setVisible(false);
ui->cbAlwaysUseMessageFont->setVisible(false);
}
#else
ui->gbFont->setVisible(false);
ui->cbAlwaysUseMessageFont->setVisible(false);
#endif
QString currentStyle = QApplication::style()->objectName();
QString appStyle = settings->value("AppStyle", currentStyle).toString();
bool customStyle = settings->value("CustomStyle", false).toBool(); bool customStyle = settings->value("CustomStyle", false).toBool();
const QStringList availableStyles = QStyleFactory::keys(); const QStringList availableStyles = QStyleFactory::keys();
ui->cbStyleList->addItems(availableStyles); ui->cbStyleList->addItems(availableStyles);
if (availableStyles.contains(appStyle, Qt::CaseInsensitive)) if (availableStyles.contains(appStyle, Qt::CaseInsensitive)) {
{
// use 'for' for select to be sure it's case insensitive // use 'for' for select to be sure it's case insensitive
int currentIndex = 0; int currentIndex = 0;
for (QString currentStyleFF : availableStyles) for (const QString &currentStyleFF : availableStyles) {
{ if (currentStyleFF.toLower() == appStyle.toLower()) {
if (currentStyleFF.toLower() == appStyle.toLower())
{
ui->cbStyleList->setCurrentIndex(currentIndex); ui->cbStyleList->setCurrentIndex(currentIndex);
} }
currentIndex++; currentIndex++;
} }
} }
else else {
{ if (availableStyles.contains(currentStyle, Qt::CaseInsensitive)) {
if (availableStyles.contains(currentStyle, Qt::CaseInsensitive))
{
int currentIndex = 0; int currentIndex = 0;
for (QString currentStyleFF : availableStyles) for (const QString &currentStyleFF : availableStyles) {
{ if (currentStyleFF.toLower() == currentStyle.toLower()) {
if (currentStyleFF.toLower() == currentStyle.toLower())
{
ui->cbStyleList->setCurrentIndex(currentIndex); ui->cbStyleList->setCurrentIndex(currentIndex);
} }
currentIndex++; currentIndex++;
} }
} }
} }
if (customStyle) ui->cbDefaultStyle->setChecked(!customStyle);
{ ui->cbStyleList->setEnabled(customStyle);
ui->cbDefaultStyle->setChecked(false); const QFont currentFont = QApplication::font();
} const QFont appFont = qvariant_cast<QFont>(settings->value("AppFont", currentFont));
bool customFont = settings->value("CustomFont", false).toBool();
ui->cbDefaultFont->setChecked(!customFont);
ui->cbFont->setEnabled(customFont);
ui->cbFont->setCurrentFont(appFont);
settings->endGroup(); settings->endGroup();
} }
@ -346,26 +358,25 @@ void OptionsDialog::applySettings()
settings->setValue("Language", ui->cbLanguage->itemData(ui->cbLanguage->currentIndex())); settings->setValue("Language", ui->cbLanguage->itemData(ui->cbLanguage->currentIndex()));
settings->setValue("AreaLanguage", ui->cbAreaLanguage->itemData(ui->cbAreaLanguage->currentIndex())); settings->setValue("AreaLanguage", ui->cbAreaLanguage->itemData(ui->cbAreaLanguage->currentIndex()));
#endif #endif
#ifdef GTA5SYNC_WIN #ifdef Q_OS_WIN
#if QT_VERSION >= 0x050200 #if QT_VERSION >= 0x050200
settings->setValue("NavigationBar", ui->cbSnapmaticNavigationBar->isChecked()); settings->setValue("NavigationBar", ui->cbSnapmaticNavigationBar->isChecked());
#endif #endif
#else
settings->setValue("NavigationBar", ui->cbSnapmaticNavigationBar->isChecked());
#endif #endif
settings->endGroup(); settings->endGroup();
settings->beginGroup("Profile"); settings->beginGroup("Profile");
int newContentMode = 0; int newContentMode = 20;
if (ui->rbOpenWithSC->isChecked()) if (ui->rbModern->isChecked()) {
{ newContentMode = 20;
newContentMode = 0;
} }
else if (ui->rbOpenWithDC->isChecked()) else if (ui->rbClassic->isChecked()) {
{ newContentMode = 10;
newContentMode = 1;
} }
else if (ui->rbSelectWithSC->isChecked()) if (ui->cbDoubleclick->isChecked()) {
{ newContentMode++;
newContentMode = 2;
} }
settings->setValue("ContentMode", newContentMode); settings->setValue("ContentMode", newContentMode);
#if QT_VERSION >= 0x050000 #if QT_VERSION >= 0x050000
@ -376,18 +387,15 @@ void OptionsDialog::applySettings()
settings->endGroup(); settings->endGroup();
settings->beginGroup("Pictures"); settings->beginGroup("Pictures");
if (ui->cbPicCustomQuality->isChecked()) if (ui->cbPicCustomQuality->isChecked()) {
{
settings->setValue("CustomQuality", ui->hsPicQuality->value()); settings->setValue("CustomQuality", ui->hsPicQuality->value());
} }
settings->setValue("CustomQualityEnabled", ui->cbPicCustomQuality->isChecked()); settings->setValue("CustomQualityEnabled", ui->cbPicCustomQuality->isChecked());
QString sizeMode = "Default"; QString sizeMode = "Default";
if (ui->rbPicDesktopRes->isChecked()) if (ui->rbPicDesktopRes->isChecked()) {
{
sizeMode = "Desktop"; sizeMode = "Desktop";
} }
else if (ui->rbPicCustomRes->isChecked()) else if (ui->rbPicCustomRes->isChecked()) {
{
sizeMode = "Custom"; sizeMode = "Custom";
settings->setValue("CustomSize", QSize(ui->sbPicExportWidth->value(), ui->sbPicExportHeight->value())); settings->setValue("CustomSize", QSize(ui->sbPicExportWidth->value(), ui->sbPicExportHeight->value()));
} }
@ -403,18 +411,25 @@ void OptionsDialog::applySettings()
bool defaultStyle = ui->cbDefaultStyle->isChecked(); bool defaultStyle = ui->cbDefaultStyle->isChecked();
settings->beginGroup("Startup"); settings->beginGroup("Startup");
if (!defaultStyle) if (!defaultStyle) {
{
QString newStyle = ui->cbStyleList->currentText(); QString newStyle = ui->cbStyleList->currentText();
settings->setValue("CustomStyle", true); settings->setValue("CustomStyle", true);
settings->setValue("AppStyle", newStyle); settings->setValue("AppStyle", newStyle);
QApplication::setStyle(QStyleFactory::create(newStyle)); QApplication::setStyle(QStyleFactory::create(newStyle));
} }
else else {
{
settings->setValue("CustomStyle", false); settings->setValue("CustomStyle", false);
} }
settings->setValue("AlwaysUseMessageFont", ui->cbAlwaysUseMessageFont->isChecked()); bool defaultFont = ui->cbDefaultFont->isChecked();
if (!defaultFont) {
QFont newFont = ui->cbFont->currentFont();
settings->setValue("CustomFont", true);
settings->setValue("AppFont", newFont);
QApplication::setFont(newFont);
}
else {
settings->setValue("CustomFont", false);
}
settings->endGroup(); settings->endGroup();
#ifdef GTA5SYNC_TELEMETRY #ifdef GTA5SYNC_TELEMETRY
@ -425,12 +440,15 @@ void OptionsDialog::applySettings()
settings->endGroup(); settings->endGroup();
Telemetry->refresh(); Telemetry->refresh();
Telemetry->work(); Telemetry->work();
if (ui->cbUsageData->isChecked() && Telemetry->canPush()) if (ui->cbUsageData->isChecked() && Telemetry->canPush()) {
{
QJsonDocument jsonDocument; QJsonDocument jsonDocument;
QJsonObject jsonObject; QJsonObject jsonObject;
jsonObject["Type"] = "SettingsUpdated"; jsonObject["Type"] = "SettingsUpdated";
#if QT_VERSION >= 0x060000
jsonObject["UpdateTime"] = QString::number(QDateTime::currentDateTimeUtc().toSecsSinceEpoch());
#else
jsonObject["UpdateTime"] = QString::number(QDateTime::currentDateTimeUtc().toTime_t()); jsonObject["UpdateTime"] = QString::number(QDateTime::currentDateTimeUtc().toTime_t());
#endif
jsonDocument.setObject(jsonObject); jsonDocument.setObject(jsonObject);
Telemetry->push(TelemetryCategory::PersonalData, jsonDocument); Telemetry->push(TelemetryCategory::PersonalData, jsonDocument);
} }
@ -443,22 +461,19 @@ void OptionsDialog::applySettings()
bool languageChanged = ui->cbLanguage->itemData(ui->cbLanguage->currentIndex()).toString() != currentLanguage; bool languageChanged = ui->cbLanguage->itemData(ui->cbLanguage->currentIndex()).toString() != currentLanguage;
bool languageAreaChanged = ui->cbAreaLanguage->itemData(ui->cbLanguage->currentIndex()).toString() != currentAreaLanguage; bool languageAreaChanged = ui->cbAreaLanguage->itemData(ui->cbLanguage->currentIndex()).toString() != currentAreaLanguage;
#endif #endif
if (languageChanged) if (languageChanged) {
{
Translator->unloadTranslation(qApp); Translator->unloadTranslation(qApp);
Translator->initUserLanguage(); Translator->initUserLanguage();
Translator->loadTranslation(qApp); Translator->loadTranslation(qApp);
} }
else if (languageAreaChanged) else if (languageAreaChanged) {
{
Translator->initUserLanguage(); Translator->initUserLanguage();
} }
settings->sync(); settings->sync();
emit settingsApplied(newContentMode, languageChanged); emit settingsApplied(newContentMode, languageChanged);
if ((forceCustomFolder && ui->txtFolder->text() != currentCFolder) || (forceCustomFolder != currentFFolder && forceCustomFolder)) if ((forceCustomFolder && ui->txtFolder->text() != currentCFolder) || (forceCustomFolder != currentFFolder && forceCustomFolder)) {
{
QMessageBox::information(this, tr("%1", "%1").arg(GTA5SYNC_APPSTR), tr("The new Custom Folder will initialise after you restart %1.").arg(GTA5SYNC_APPSTR)); QMessageBox::information(this, tr("%1", "%1").arg(GTA5SYNC_APPSTR), tr("The new Custom Folder will initialise after you restart %1.").arg(GTA5SYNC_APPSTR));
} }
} }
@ -475,11 +490,9 @@ void OptionsDialog::setupDefaultProfile()
void OptionsDialog::commitProfiles(const QStringList &profiles) void OptionsDialog::commitProfiles(const QStringList &profiles)
{ {
for (QString profile : profiles) for (const QString &profile : profiles) {
{
ui->cbProfiles->addItem(tr("Profile: %1").arg(profile), profile); ui->cbProfiles->addItem(tr("Profile: %1").arg(profile), profile);
if (defaultProfile == profile) if (defaultProfile == profile) {
{
#if QT_VERSION >= 0x050000 #if QT_VERSION >= 0x050000
ui->cbProfiles->setCurrentText(tr("Profile: %1").arg(profile)); ui->cbProfiles->setCurrentText(tr("Profile: %1").arg(profile));
#else #else
@ -517,8 +530,7 @@ void OptionsDialog::setupPictureSettings()
// Quality Settings // Quality Settings
customQuality = settings->value("CustomQuality", defaultQuality).toInt(); customQuality = settings->value("CustomQuality", defaultQuality).toInt();
if (customQuality < 1 || customQuality > 100) if (customQuality < 1 || customQuality > 100) {
{
customQuality = 100; customQuality = 100;
} }
ui->hsPicQuality->setValue(customQuality); ui->hsPicQuality->setValue(customQuality);
@ -526,42 +538,34 @@ void OptionsDialog::setupPictureSettings()
// Size Settings // Size Settings
cusExportSize = settings->value("CustomSize", defExportSize).toSize(); cusExportSize = settings->value("CustomSize", defExportSize).toSize();
if (cusExportSize.width() > 3840) if (cusExportSize.width() > 3840) {
{
cusExportSize.setWidth(3840); cusExportSize.setWidth(3840);
} }
else if (cusExportSize.height() > 2160) else if (cusExportSize.height() > 2160) {
{
cusExportSize.setHeight(2160); cusExportSize.setHeight(2160);
} }
if (cusExportSize.width() < 1) if (cusExportSize.width() < 1) {
{
cusExportSize.setWidth(1); cusExportSize.setWidth(1);
} }
else if (cusExportSize.height() < 1) else if (cusExportSize.height() < 1) {
{
cusExportSize.setHeight(1); cusExportSize.setHeight(1);
} }
ui->sbPicExportWidth->setValue(cusExportSize.width()); ui->sbPicExportWidth->setValue(cusExportSize.width());
ui->sbPicExportHeight->setValue(cusExportSize.height()); ui->sbPicExportHeight->setValue(cusExportSize.height());
QString sizeMode = settings->value("ExportSizeMode", "Default").toString(); QString sizeMode = settings->value("ExportSizeMode", "Default").toString();
if (sizeMode == "Desktop") if (sizeMode == "Desktop") {
{
ui->rbPicDesktopRes->setChecked(true); ui->rbPicDesktopRes->setChecked(true);
} }
else if (sizeMode == "Custom") else if (sizeMode == "Custom") {
{
ui->rbPicCustomRes->setChecked(true); ui->rbPicCustomRes->setChecked(true);
} }
else else {
{
ui->rbPicDefaultRes->setChecked(true); ui->rbPicDefaultRes->setChecked(true);
} }
aspectRatio = (Qt::AspectRatioMode)settings->value("AspectRatio", Qt::KeepAspectRatio).toInt(); aspectRatio = (Qt::AspectRatioMode)settings->value("AspectRatio", Qt::KeepAspectRatio).toInt();
if (aspectRatio == Qt::IgnoreAspectRatio) if (aspectRatio == Qt::IgnoreAspectRatio) {
{
ui->cbIgnoreAspectRatio->setChecked(true); ui->cbIgnoreAspectRatio->setChecked(true);
} }
@ -580,17 +584,14 @@ void OptionsDialog::setupStatisticsSettings()
ui->cbUsageData->setChecked(settings->value("PushUsageData", false).toBool()); ui->cbUsageData->setChecked(settings->value("PushUsageData", false).toBool());
settings->endGroup(); settings->endGroup();
if (Telemetry->isStateForced()) if (Telemetry->isStateForced()) {
{
ui->cbParticipateStats->setEnabled(false); ui->cbParticipateStats->setEnabled(false);
} }
if (Telemetry->isRegistered()) if (Telemetry->isRegistered()) {
{
ui->labParticipationID->setText(tr("Participation ID: %1").arg(Telemetry->getRegisteredID())); ui->labParticipationID->setText(tr("Participation ID: %1").arg(Telemetry->getRegisteredID()));
} }
else else {
{
ui->labParticipationID->setText(tr("Participation ID: %1").arg(tr("Not registered"))); ui->labParticipationID->setText(tr("Participation ID: %1").arg(tr("Not registered")));
ui->cmdCopyStatsID->setVisible(false); ui->cmdCopyStatsID->setVisible(false);
} }
@ -603,63 +604,50 @@ void OptionsDialog::setupWindowsGameSettings()
{ {
#ifdef GTA5SYNC_GAME #ifdef GTA5SYNC_GAME
GameVersion gameVersion = AppEnv::getGameVersion(); GameVersion gameVersion = AppEnv::getGameVersion();
#ifdef GTA5SYNC_WIN #ifdef Q_OS_WIN
if (gameVersion != GameVersion::NoVersion) if (gameVersion != GameVersion::NoVersion) {
{ if (gameVersion == GameVersion::SocialClubVersion) {
if (gameVersion == GameVersion::SocialClubVersion)
{
ui->gbSteam->setDisabled(true); ui->gbSteam->setDisabled(true);
ui->labSocialClubFound->setText(tr("Found: %1").arg(QString("<span style=\"color: green\">%1</span>").arg(tr("Yes")))); ui->labSocialClubFound->setText(tr("Found: %1").arg(QString("<span style=\"color: green\">%1</span>").arg(tr("Yes"))));
ui->labSteamFound->setText(tr("Found: %1").arg(QString("<span style=\"color: red\">%1</span>").arg(tr("No")))); ui->labSteamFound->setText(tr("Found: %1").arg(QString("<span style=\"color: red\">%1</span>").arg(tr("No"))));
if (AppEnv::getGameLanguage(GameVersion::SocialClubVersion) != GameLanguage::Undefined) if (AppEnv::getGameLanguage(GameVersion::SocialClubVersion) != GameLanguage::Undefined) {
{
ui->labSocialClubLanguage->setText(tr("Language: %1").arg(QLocale(AppEnv::gameLanguageToString(AppEnv::getGameLanguage(GameVersion::SocialClubVersion))).nativeLanguageName())); ui->labSocialClubLanguage->setText(tr("Language: %1").arg(QLocale(AppEnv::gameLanguageToString(AppEnv::getGameLanguage(GameVersion::SocialClubVersion))).nativeLanguageName()));
} }
else else {
{
ui->labSocialClubLanguage->setText(tr("Language: %1").arg(tr("OS defined"))); ui->labSocialClubLanguage->setText(tr("Language: %1").arg(tr("OS defined")));
} }
ui->labSteamLanguage->setVisible(false); ui->labSteamLanguage->setVisible(false);
} }
else if (gameVersion == GameVersion::SteamVersion) else if (gameVersion == GameVersion::SteamVersion) {
{
ui->gbSocialClub->setDisabled(true); ui->gbSocialClub->setDisabled(true);
ui->labSocialClubFound->setText(tr("Found: %1").arg(QString("<span style=\"color: red\">%1</span>").arg(tr("No")))); ui->labSocialClubFound->setText(tr("Found: %1").arg(QString("<span style=\"color: red\">%1</span>").arg(tr("No"))));
ui->labSteamFound->setText(tr("Found: %1").arg(QString("<span style=\"color: green\">%1</span>").arg(tr("Yes")))); ui->labSteamFound->setText(tr("Found: %1").arg(QString("<span style=\"color: green\">%1</span>").arg(tr("Yes"))));
ui->labSocialClubLanguage->setVisible(false); ui->labSocialClubLanguage->setVisible(false);
if (AppEnv::getGameLanguage(GameVersion::SteamVersion) != GameLanguage::Undefined) if (AppEnv::getGameLanguage(GameVersion::SteamVersion) != GameLanguage::Undefined) {
{
ui->labSteamLanguage->setText(tr("Language: %1").arg(QLocale(AppEnv::gameLanguageToString(AppEnv::getGameLanguage(GameVersion::SteamVersion))).nativeLanguageName())); ui->labSteamLanguage->setText(tr("Language: %1").arg(QLocale(AppEnv::gameLanguageToString(AppEnv::getGameLanguage(GameVersion::SteamVersion))).nativeLanguageName()));
} }
else else {
{
ui->labSteamLanguage->setText(tr("Language: %1").arg(tr("Steam defined"))); ui->labSteamLanguage->setText(tr("Language: %1").arg(tr("Steam defined")));
} }
} }
else else {
{
ui->labSocialClubFound->setText(tr("Found: %1").arg(QString("<span style=\"color: green\">%1</span>").arg(tr("Yes")))); ui->labSocialClubFound->setText(tr("Found: %1").arg(QString("<span style=\"color: green\">%1</span>").arg(tr("Yes"))));
ui->labSteamFound->setText(tr("Found: %1").arg(QString("<span style=\"color: green\">%1</span>").arg(tr("Yes")))); ui->labSteamFound->setText(tr("Found: %1").arg(QString("<span style=\"color: green\">%1</span>").arg(tr("Yes"))));
if (AppEnv::getGameLanguage(GameVersion::SocialClubVersion) != GameLanguage::Undefined) if (AppEnv::getGameLanguage(GameVersion::SocialClubVersion) != GameLanguage::Undefined) {
{
ui->labSocialClubLanguage->setText(tr("Language: %1").arg(QLocale(AppEnv::gameLanguageToString(AppEnv::getGameLanguage(GameVersion::SocialClubVersion))).nativeLanguageName())); ui->labSocialClubLanguage->setText(tr("Language: %1").arg(QLocale(AppEnv::gameLanguageToString(AppEnv::getGameLanguage(GameVersion::SocialClubVersion))).nativeLanguageName()));
} }
else else {
{
ui->labSocialClubLanguage->setText(tr("Language: %1").arg(tr("OS defined"))); ui->labSocialClubLanguage->setText(tr("Language: %1").arg(tr("OS defined")));
} }
if (AppEnv::getGameLanguage(GameVersion::SteamVersion) != GameLanguage::Undefined) if (AppEnv::getGameLanguage(GameVersion::SteamVersion) != GameLanguage::Undefined) {
{
ui->labSteamLanguage->setText(tr("Language: %1").arg(QLocale(AppEnv::gameLanguageToString(AppEnv::getGameLanguage(GameVersion::SteamVersion))).nativeLanguageName())); ui->labSteamLanguage->setText(tr("Language: %1").arg(QLocale(AppEnv::gameLanguageToString(AppEnv::getGameLanguage(GameVersion::SteamVersion))).nativeLanguageName()));
} }
else else {
{
ui->labSteamLanguage->setText(tr("Language: %1").arg(tr("Steam defined"))); ui->labSteamLanguage->setText(tr("Language: %1").arg(tr("Steam defined")));
} }
} }
} }
else else {
{
ui->tabWidget->removeTab(ui->tabWidget->indexOf(ui->tabGame)); ui->tabWidget->removeTab(ui->tabWidget->indexOf(ui->tabGame));
} }
#else #else
@ -672,12 +660,10 @@ void OptionsDialog::setupWindowsGameSettings()
void OptionsDialog::on_cbIgnoreAspectRatio_toggled(bool checked) void OptionsDialog::on_cbIgnoreAspectRatio_toggled(bool checked)
{ {
if (checked) if (checked) {
{
aspectRatio = Qt::IgnoreAspectRatio; aspectRatio = Qt::IgnoreAspectRatio;
} }
else else {
{
aspectRatio = Qt::KeepAspectRatio; aspectRatio = Qt::KeepAspectRatio;
} }
} }
@ -689,8 +675,7 @@ void OptionsDialog::setupCustomGTAFolder()
settings->beginGroup("dir"); settings->beginGroup("dir");
currentCFolder = settings->value("dir", "").toString(); currentCFolder = settings->value("dir", "").toString();
currentFFolder = settings->value("force", false).toBool(); currentFFolder = settings->value("force", false).toBool();
if (currentCFolder == "" && ok) if (currentCFolder == "" && ok) {
{
currentCFolder = defaultGameFolder; currentCFolder = defaultGameFolder;
} }
ui->txtFolder->setText(currentCFolder); ui->txtFolder->setText(currentCFolder);
@ -700,26 +685,26 @@ void OptionsDialog::setupCustomGTAFolder()
void OptionsDialog::setupSnapmaticPictureViewer() void OptionsDialog::setupSnapmaticPictureViewer()
{ {
#ifdef GTA5SYNC_WIN #ifdef Q_OS_WIN
#if QT_VERSION >= 0x050200 #if QT_VERSION >= 0x050200
settings->beginGroup("Interface"); settings->beginGroup("Interface");
ui->cbSnapmaticNavigationBar->setChecked(settings->value("NavigationBar", false).toBool()); ui->cbSnapmaticNavigationBar->setChecked(settings->value("NavigationBar", true).toBool());
settings->endGroup(); settings->endGroup();
#else #else
ui->cbSnapmaticNavigationBar->setVisible(false); ui->cbSnapmaticNavigationBar->setVisible(false);
ui->gbSnapmaticPictureViewer->setVisible(false); ui->gbSnapmaticPictureViewer->setVisible(false);
#endif #endif
#else #else
ui->cbSnapmaticNavigationBar->setVisible(false); settings->beginGroup("Interface");
ui->gbSnapmaticPictureViewer->setVisible(false); ui->cbSnapmaticNavigationBar->setChecked(settings->value("NavigationBar", true).toBool());
settings->endGroup();
#endif #endif
} }
void OptionsDialog::on_cmdExploreFolder_clicked() void OptionsDialog::on_cmdExploreFolder_clicked()
{ {
QString GTAV_Folder = QFileDialog::getExistingDirectory(this, UserInterface::tr("Select GTA V Folder..."), StandardPaths::documentsLocation(), QFileDialog::ShowDirsOnly); const QString GTAV_Folder = QFileDialog::getExistingDirectory(this, UserInterface::tr("Select GTA V Folder..."), StandardPaths::documentsLocation(), QFileDialog::ShowDirsOnly);
if (QFileInfo(GTAV_Folder).exists()) if (QDir(GTAV_Folder).exists()) {
{
ui->txtFolder->setText(GTAV_Folder); ui->txtFolder->setText(GTAV_Folder);
} }
} }
@ -727,6 +712,14 @@ void OptionsDialog::on_cmdExploreFolder_clicked()
void OptionsDialog::on_cbDefaultStyle_toggled(bool checked) void OptionsDialog::on_cbDefaultStyle_toggled(bool checked)
{ {
ui->cbStyleList->setDisabled(checked); ui->cbStyleList->setDisabled(checked);
ui->labStyle->setDisabled(checked);
}
void OptionsDialog::on_cbDefaultFont_toggled(bool checked)
{
ui->cbFont->setDisabled(checked);
ui->cmdFont->setDisabled(checked);
ui->labFont->setDisabled(checked);
} }
void OptionsDialog::on_cmdCopyStatsID_clicked() void OptionsDialog::on_cmdCopyStatsID_clicked()
@ -735,3 +728,18 @@ void OptionsDialog::on_cmdCopyStatsID_clicked()
QApplication::clipboard()->setText(Telemetry->getRegisteredID()); QApplication::clipboard()->setText(Telemetry->getRegisteredID());
#endif #endif
} }
void OptionsDialog::on_cbFont_currentFontChanged(const QFont &font)
{
ui->cbFont->setFont(font);
}
void OptionsDialog::on_cmdFont_clicked()
{
bool ok;
const QFont font = QFontDialog::getFont(&ok, ui->cbFont->currentFont(), this);
if (ok) {
ui->cbFont->setCurrentFont(font);
ui->cbFont->setFont(font);
}
}

View File

@ -47,7 +47,10 @@ private slots:
void on_cbIgnoreAspectRatio_toggled(bool checked); void on_cbIgnoreAspectRatio_toggled(bool checked);
void on_cmdExploreFolder_clicked(); void on_cmdExploreFolder_clicked();
void on_cbDefaultStyle_toggled(bool checked); void on_cbDefaultStyle_toggled(bool checked);
void on_cbDefaultFont_toggled(bool checked);
void on_cmdCopyStatsID_clicked(); void on_cmdCopyStatsID_clicked();
void on_cbFont_currentFontChanged(const QFont &font);
void on_cmdFont_clicked();
signals: signals:
void settingsApplied(int contentMode, bool languageChanged); void settingsApplied(int contentMode, bool languageChanged);

View File

@ -7,7 +7,7 @@
<x>0</x> <x>0</x>
<y>0</y> <y>0</y>
<width>435</width> <width>435</width>
<height>474</height> <height>524</height>
</rect> </rect>
</property> </property>
<property name="windowTitle"> <property name="windowTitle">
@ -34,9 +34,9 @@
</property> </property>
<layout class="QVBoxLayout" name="vlProfileContentMode"> <layout class="QVBoxLayout" name="vlProfileContentMode">
<item> <item>
<widget class="QRadioButton" name="rbOpenWithSC"> <widget class="QRadioButton" name="rbModern">
<property name="text"> <property name="text">
<string>Open with Singleclick</string> <string notr="true">%1 1.9+</string>
</property> </property>
<property name="checked"> <property name="checked">
<bool>true</bool> <bool>true</bool>
@ -44,16 +44,16 @@
</widget> </widget>
</item> </item>
<item> <item>
<widget class="QRadioButton" name="rbOpenWithDC"> <widget class="QRadioButton" name="rbClassic">
<property name="text"> <property name="text">
<string>Open with Doubleclick</string> <string notr="true">%1 1.0-1.8</string>
</property> </property>
</widget> </widget>
</item> </item>
<item> <item>
<widget class="QRadioButton" name="rbSelectWithSC"> <widget class="QCheckBox" name="cbDoubleclick">
<property name="text"> <property name="text">
<string>Select with Singleclick</string> <string>Open with Doubleclick</string>
</property> </property>
</widget> </widget>
</item> </item>
@ -660,6 +660,9 @@
<layout class="QHBoxLayout" name="hlStyle"> <layout class="QHBoxLayout" name="hlStyle">
<item> <item>
<widget class="QLabel" name="labStyle"> <widget class="QLabel" name="labStyle">
<property name="enabled">
<bool>false</bool>
</property>
<property name="text"> <property name="text">
<string>Style:</string> <string>Style:</string>
</property> </property>
@ -690,12 +693,52 @@
</property> </property>
<layout class="QVBoxLayout" name="vlFont"> <layout class="QVBoxLayout" name="vlFont">
<item> <item>
<widget class="QCheckBox" name="cbAlwaysUseMessageFont"> <widget class="QCheckBox" name="cbDefaultFont">
<property name="text"> <property name="text">
<string>Always use Message Font (Windows 2003 and earlier)</string> <string>Use Default Font (Restart)</string>
</property>
<property name="checked">
<bool>true</bool>
</property> </property>
</widget> </widget>
</item> </item>
<item>
<layout class="QHBoxLayout" name="hlFont">
<item>
<widget class="QLabel" name="labFont">
<property name="enabled">
<bool>false</bool>
</property>
<property name="text">
<string>Font:</string>
</property>
</widget>
</item>
<item>
<widget class="QFontComboBox" name="cbFont">
<property name="enabled">
<bool>false</bool>
</property>
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
</widget>
</item>
<item>
<widget class="QToolButton" name="cmdFont">
<property name="enabled">
<bool>false</bool>
</property>
<property name="text">
<string notr="true">...</string>
</property>
</widget>
</item>
</layout>
</item>
</layout> </layout>
</widget> </widget>
</item> </item>

File diff suppressed because it is too large Load Diff

View File

@ -1,6 +1,6 @@
/***************************************************************************** /*****************************************************************************
* gta5view Grand Theft Auto V Profile Viewer * gta5view Grand Theft Auto V Profile Viewer
* Copyright (C) 2016-2017 Syping * Copyright (C) 2016-2021 Syping
* *
* This program is free software: you can redistribute it and/or modify * This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by * it under the terms of the GNU General Public License as published by
@ -29,14 +29,6 @@
#include <QEvent> #include <QEvent>
#include <QMenu> #include <QMenu>
#ifdef GTA5SYNC_WIN
#if QT_VERSION >= 0x050200
#ifdef GTA5SYNC_APV
#include <dwmapi.h>
#endif
#endif
#endif
namespace Ui { namespace Ui {
class PictureDialog; class PictureDialog;
} }
@ -56,17 +48,17 @@ public:
void setSnapmaticPicture(SnapmaticPicture *picture, int index); void setSnapmaticPicture(SnapmaticPicture *picture, int index);
void setSnapmaticPicture(SnapmaticPicture *picture); void setSnapmaticPicture(SnapmaticPicture *picture);
void addPreviousNextButtons(); void addPreviousNextButtons();
void stylizeDialog(); void styliseDialog();
bool isIndexed(); bool isIndexed();
int getIndex(); int getIndex();
~PictureDialog(); ~PictureDialog();
public slots: public slots:
void adaptDialogSize();
void crewNameUpdated(); void crewNameUpdated();
void playerNameUpdated(); void playerNameUpdated();
void dialogNextPictureRequested(); void dialogNextPictureRequested();
void dialogPreviousPictureRequested(); void dialogPreviousPictureRequested();
void adaptNewDialogSize(QSize newLabelSize);
void exportCustomContextMenuRequested(const QPoint &pos); void exportCustomContextMenuRequested(const QPoint &pos);
private slots: private slots:
@ -97,14 +89,11 @@ protected:
void closeEvent(QCloseEvent *ev); void closeEvent(QCloseEvent *ev);
bool eventFilter(QObject *obj, QEvent *ev); bool eventFilter(QObject *obj, QEvent *ev);
void mousePressEvent(QMouseEvent *ev); void mousePressEvent(QMouseEvent *ev);
bool event(QEvent *event); #ifdef Q_OS_WIN
#ifdef GTA5SYNC_WIN #if QT_VERSION >= 0x060000
#if QT_VERSION >= 0x050200 bool nativeEvent(const QByteArray &eventType, void *message, qintptr *result);
#ifdef GTA5SYNC_APV #elif QT_VERSION >= 0x050000
bool nativeEvent(const QByteArray &eventType, void *message, long *result); bool nativeEvent(const QByteArray &eventType, void *message, long *result);
LRESULT HitTestNCA(HWND hWnd, LPARAM lParam);
void resizeEvent(QResizeEvent *event);
#endif
#endif #endif
#endif #endif
@ -136,8 +125,8 @@ private:
int avatarLocY; int avatarLocY;
int avatarSize; int avatarSize;
QMenu *manageMenu; QMenu *manageMenu;
#ifdef GTA5SYNC_WIN #ifdef Q_OS_WIN
#if QT_VERSION >= 0x050200 #if QT_VERSION >= 0x050000
QPoint dragPosition; QPoint dragPosition;
bool dragStart; bool dragStart;
#endif #endif

View File

@ -48,19 +48,6 @@
</property> </property>
</widget> </widget>
</item> </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> <item>
<widget class="QFrame" name="jsonFrame"> <widget class="QFrame" name="jsonFrame">
<property name="frameShape"> <property name="frameShape">
@ -111,10 +98,10 @@
</sizepolicy> </sizepolicy>
</property> </property>
<property name="text"> <property name="text">
<string>&lt;span style=&quot; font-weight:600;&quot;&gt;Title: &lt;/span&gt;%6&lt;br/&gt; <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;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;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> &lt;span style=&quot;font-weight:600&quot;&gt;Created: &lt;/span&gt;%8</string>
</property> </property>
<property name="wordWrap"> <property name="wordWrap">
<bool>true</bool> <bool>true</bool>

View File

@ -1,6 +1,6 @@
/***************************************************************************** /*****************************************************************************
* gta5view Grand Theft Auto V Profile Viewer * gta5view Grand Theft Auto V Profile Viewer
* Copyright (C) 2016-2017 Syping * Copyright (C) 2016-2020 Syping
* *
* This program is free software: you can redistribute it and/or modify * This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by * it under the terms of the GNU General Public License as published by
@ -17,26 +17,29 @@
*****************************************************************************/ *****************************************************************************/
#include "config.h" #include "config.h"
#include "AppEnv.h"
#include "PictureExport.h" #include "PictureExport.h"
#include "PictureDialog.h" #include "PictureDialog.h"
#include "StandardPaths.h" #include "StandardPaths.h"
#include "SidebarGenerator.h" #include "SidebarGenerator.h"
#include <QStringBuilder> #include <QStringBuilder>
#include <QDesktopWidget>
#include <QApplication> #include <QApplication>
#include <QMessageBox> #include <QMessageBox>
#include <QFileDialog> #include <QFileDialog>
#include <QSettings> #include <QSettings>
#include <QRegExp>
#include <QDebug> #include <QDebug>
#if QT_VERSION < 0x050000
#include <QDesktopWidget>
#endif
#if QT_VERSION >= 0x050000 #if QT_VERSION >= 0x050000
#include <QSaveFile> #include <QSaveFile>
#include <QScreen>
#endif #endif
PictureExport::PictureExport() PictureExport::PictureExport()
{ {
} }
void PictureExport::exportAsPicture(QWidget *parent, SnapmaticPicture *picture) void PictureExport::exportAsPicture(QWidget *parent, SnapmaticPicture *picture)
@ -47,30 +50,25 @@ void PictureExport::exportAsPicture(QWidget *parent, SnapmaticPicture *picture)
// Quality Settings // Quality Settings
settings.beginGroup("Pictures"); settings.beginGroup("Pictures");
int defaultQuality = 100; int defaultQuality = 100;
QSize defExportSize = QSize(960, 536); QSize defExportSize = SnapmaticPicture::getSnapmaticResolution();
int customQuality = settings.value("CustomQuality", defaultQuality).toInt(); int customQuality = settings.value("CustomQuality", defaultQuality).toInt();
if (customQuality < 1 || customQuality > 100) if (customQuality < 1 || customQuality > 100) {
{
customQuality = 100; customQuality = 100;
} }
bool useCustomQuality = settings.value("CustomQualityEnabled", false).toBool(); bool useCustomQuality = settings.value("CustomQualityEnabled", false).toBool();
// Size Settings // Size Settings
QSize cusExportSize = settings.value("CustomSize", defExportSize).toSize(); QSize cusExportSize = settings.value("CustomSize", defExportSize).toSize();
if (cusExportSize.width() > 3840) if (cusExportSize.width() > 3840) {
{
cusExportSize.setWidth(3840); cusExportSize.setWidth(3840);
} }
else if (cusExportSize.height() > 2160) else if (cusExportSize.height() > 2160) {
{
cusExportSize.setHeight(2160); cusExportSize.setHeight(2160);
} }
if (cusExportSize.width() < 1) if (cusExportSize.width() < 1) {
{
cusExportSize.setWidth(1); cusExportSize.setWidth(1);
} }
else if (cusExportSize.height() < 1) else if (cusExportSize.height() < 1) {
{
cusExportSize.setHeight(1); cusExportSize.setHeight(1);
} }
QString sizeMode = settings.value("ExportSizeMode", "Default").toString(); QString sizeMode = settings.value("ExportSizeMode", "Default").toString();
@ -109,59 +107,55 @@ fileDialogPreSave: //Work?
QString newPictureFileName = getPictureFileName(picture) % defaultExportFormat; QString newPictureFileName = getPictureFileName(picture) % defaultExportFormat;
fileDialog.selectFile(newPictureFileName); fileDialog.selectFile(newPictureFileName);
if (fileDialog.exec()) if (fileDialog.exec()) {
{
QStringList selectedFiles = fileDialog.selectedFiles(); QStringList selectedFiles = fileDialog.selectedFiles();
if (selectedFiles.length() == 1) if (selectedFiles.length() == 1) {
{
QString saveFileFormat; QString saveFileFormat;
QString selectedFile = selectedFiles.at(0); QString selectedFile = selectedFiles.at(0);
if (selectedFile.right(4) == ".jpg") if (selectedFile.right(4) == ".jpg") {
{
saveFileFormat = "JPEG"; saveFileFormat = "JPEG";
} }
else if (selectedFile.right(4) == ".jpeg") else if (selectedFile.right(4) == ".jpeg") {
{
saveFileFormat = "JPEG"; saveFileFormat = "JPEG";
} }
else if (selectedFile.right(4) == ".png") else if (selectedFile.right(4) == ".png") {
{
saveFileFormat = "PNG"; saveFileFormat = "PNG";
} }
else if (selectedFile.right(7) == ".suffix") else if (selectedFile.right(7) == ".suffix") {
{ if (fileDialog.selectedNameFilter() == "JPEG picture (*.jpg)") {
if (fileDialog.selectedNameFilter() == "JPEG picture (*.jpg)")
{
selectedFile.replace(".suffix", ".jpg"); selectedFile.replace(".suffix", ".jpg");
} }
else if (fileDialog.selectedNameFilter() == "Portable Network Graphics (*.png)") else if (fileDialog.selectedNameFilter() == "Portable Network Graphics (*.png)") {
{
selectedFile.replace(".suffix", ".png"); selectedFile.replace(".suffix", ".png");
} }
else else {
{
selectedFile.replace(".suffix", ".jpg"); selectedFile.replace(".suffix", ".jpg");
} }
} }
if (QFile::exists(selectedFile)) 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)) {
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? goto fileDialogPreSave; //Work?
} }
} }
// Scale Picture // Scale Picture
QImage exportPicture = picture->getImage(); QImage exportPicture = picture->getImage();
if (sizeMode == "Desktop") 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(); QRect desktopResolution = QApplication::desktop()->screenGeometry();
exportPicture = exportPicture.scaled(desktopResolution.width(), desktopResolution.height(), aspectRatio, Qt::SmoothTransformation); int desktopSizeWidth = desktopResolution.width();
int desktopSizeHeight = desktopResolution.height();
#endif
exportPicture = exportPicture.scaled(desktopSizeWidth, desktopSizeHeight, aspectRatio, Qt::SmoothTransformation);
} }
else if (sizeMode == "Custom") else if (sizeMode == "Custom") {
{
exportPicture = exportPicture.scaled(cusExportSize, aspectRatio, Qt::SmoothTransformation); exportPicture = exportPicture.scaled(cusExportSize, aspectRatio, Qt::SmoothTransformation);
} }
@ -172,32 +166,26 @@ fileDialogPreSave: //Work?
#else #else
QFile *picFile = new QFile(selectedFile); QFile *picFile = new QFile(selectedFile);
#endif #endif
if (picFile->open(QIODevice::WriteOnly)) if (picFile->open(QIODevice::WriteOnly)) {
{
isSaved = exportPicture.save(picFile, saveFileFormat.toStdString().c_str(), useCustomQuality ? customQuality : defaultQuality); isSaved = exportPicture.save(picFile, saveFileFormat.toStdString().c_str(), useCustomQuality ? customQuality : defaultQuality);
#if QT_VERSION >= 0x050000 #if QT_VERSION >= 0x050000
if (isSaved) if (isSaved) {
{
isSaved = picFile->commit(); isSaved = picFile->commit();
} }
else else {
{
errorId = 1; errorId = 1;
} }
#else #else
picFile->close(); picFile->close();
#endif #endif
} }
else else {
{
errorId = 2; errorId = 2;
} }
delete picFile; delete picFile;
if (!isSaved) if (!isSaved) {
{ switch (errorId) {
switch (errorId)
{
case 0: case 0:
QMessageBox::warning(parent, PictureDialog::tr("Export as Picture"), PictureDialog::tr("Failed to export the picture because the system occurred a write failure")); QMessageBox::warning(parent, PictureDialog::tr("Export as Picture"), PictureDialog::tr("Failed to export the picture because the system occurred a write failure"));
break; break;
@ -213,8 +201,7 @@ fileDialogPreSave: //Work?
goto fileDialogPreSave; //Work? goto fileDialogPreSave; //Work?
} }
} }
else else {
{
QMessageBox::warning(parent, PictureDialog::tr("Export as Picture"), PictureDialog::tr("No valid file is selected")); QMessageBox::warning(parent, PictureDialog::tr("Export as Picture"), PictureDialog::tr("No valid file is selected"));
goto fileDialogPreSave; //Work? goto fileDialogPreSave; //Work?
} }
@ -250,7 +237,9 @@ fileDialogPreSave: //Work?
QStringList filters; QStringList filters;
filters << PictureDialog::tr("GTA V Export (*.g5e)"); filters << PictureDialog::tr("GTA V Export (*.g5e)");
#ifndef GTA5SYNC_FLATPAK
filters << PictureDialog::tr("GTA V Raw Export (*.auto)"); filters << PictureDialog::tr("GTA V Raw Export (*.auto)");
#endif
filters << PictureDialog::tr("Snapmatic pictures (PGTA*)"); filters << PictureDialog::tr("Snapmatic pictures (PGTA*)");
fileDialog.setNameFilters(filters); fileDialog.setNameFilters(filters);
@ -261,58 +250,48 @@ fileDialogPreSave: //Work?
fileDialog.restoreGeometry(settings.value(parent->objectName() % "+Geometry", "").toByteArray()); fileDialog.restoreGeometry(settings.value(parent->objectName() % "+Geometry", "").toByteArray());
fileDialog.selectFile(QString(picture->getExportPictureFileName() % ".g5e")); fileDialog.selectFile(QString(picture->getExportPictureFileName() % ".g5e"));
if (fileDialog.exec()) if (fileDialog.exec()) {
{
QStringList selectedFiles = fileDialog.selectedFiles(); QStringList selectedFiles = fileDialog.selectedFiles();
if (selectedFiles.length() == 1) if (selectedFiles.length() == 1) {
{
QString selectedFile = selectedFiles.at(0); QString selectedFile = selectedFiles.at(0);
bool isAutoExt = false; bool isAutoExt = false;
if (selectedFile.right(5) == ".auto") #ifndef GTA5SYNC_FLATPAK
{ if (selectedFile.right(5) == ".auto") {
isAutoExt = true; isAutoExt = true;
QString dirPath = QFileInfo(selectedFile).dir().path(); QString dirPath = QFileInfo(selectedFile).dir().path();
QString stockFileName = sgdFileInfo.fileName(); QString stockFileName = sgdFileInfo.fileName();
selectedFile = dirPath % "/" % stockFileName; selectedFile = dirPath % "/" % stockFileName;
} }
else if (selectedFile.right(4) == ".rem") #endif
{ if (selectedFile.right(4) == ".rem") {
selectedFile.remove(selectedFile.length() - 4, 4); selectedFile.remove(selectedFile.length() - 4, 4);
} }
if (QFile::exists(selectedFile)) 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)) {
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? goto fileDialogPreSave; //Work?
} }
} }
if (selectedFile.right(4) == ".g5e") if (selectedFile.right(4) == ".g5e") {
{
bool isExported = picture->exportPicture(selectedFile, SnapmaticFormat::G5E_Format); bool isExported = picture->exportPicture(selectedFile, SnapmaticFormat::G5E_Format);
if (!isExported) if (!isExported) {
{
QMessageBox::warning(parent, PictureDialog::tr("Export as Snapmatic"), PictureDialog::tr("Failed to export current Snapmatic picture")); QMessageBox::warning(parent, PictureDialog::tr("Export as Snapmatic"), PictureDialog::tr("Failed to export current Snapmatic picture"));
goto fileDialogPreSave; //Work? goto fileDialogPreSave; //Work?
} }
} }
else else {
{
bool isCopied = picture->exportPicture(selectedFile, SnapmaticFormat::PGTA_Format); bool isCopied = picture->exportPicture(selectedFile, SnapmaticFormat::PGTA_Format);
if (!isCopied) if (!isCopied) {
{
QMessageBox::warning(parent, PictureDialog::tr("Export as Snapmatic"), PictureDialog::tr("Failed to export current Snapmatic picture")); QMessageBox::warning(parent, PictureDialog::tr("Export as Snapmatic"), PictureDialog::tr("Failed to export current Snapmatic picture"));
goto fileDialogPreSave; //Work? goto fileDialogPreSave; //Work?
} }
else 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)); 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 else {
{
QMessageBox::warning(parent, PictureDialog::tr("Export as Snapmatic"), PictureDialog::tr("No valid file is selected")); QMessageBox::warning(parent, PictureDialog::tr("Export as Snapmatic"), PictureDialog::tr("No valid file is selected"));
goto fileDialogPreSave; //Work? goto fileDialogPreSave; //Work?
} }

View File

@ -1,6 +1,6 @@
/***************************************************************************** /*****************************************************************************
* gta5view Grand Theft Auto V Profile Viewer * gta5view Grand Theft Auto V Profile Viewer
* Copyright (C) 2016-2017 Syping * Copyright (C) 2016-2020 Syping
* *
* This program is free software: you can redistribute it and/or modify * This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by * it under the terms of the GNU General Public License as published by
@ -19,13 +19,12 @@
#include "PictureDialog.h" #include "PictureDialog.h"
#include "PictureWidget.h" #include "PictureWidget.h"
#include "UiModLabel.h" #include "UiModLabel.h"
#include <QDesktopWidget> #include "AppEnv.h"
#include <QApplication> #include <QApplication>
#include <QHBoxLayout> #include <QHBoxLayout>
#include <QKeyEvent> #include <QKeyEvent>
#include <QPixmap> #include <QPixmap>
#include <QEvent> #include <QEvent>
#include <QDebug>
PictureWidget::PictureWidget(QWidget *parent) : QDialog(parent) PictureWidget::PictureWidget(QWidget *parent) : QDialog(parent)
{ {
@ -44,7 +43,6 @@ PictureWidget::PictureWidget(QWidget *parent) : QDialog(parent)
QObject::connect(pictureLabel, SIGNAL(mouseDoubleClicked(Qt::MouseButton)), this, SLOT(pictureDoubleClicked(Qt::MouseButton))); QObject::connect(pictureLabel, SIGNAL(mouseDoubleClicked(Qt::MouseButton)), this, SLOT(pictureDoubleClicked(Qt::MouseButton)));
QObject::connect(pictureLabel, SIGNAL(customContextMenuRequested(QPoint)), parent, SLOT(exportCustomContextMenuRequested(QPoint))); QObject::connect(pictureLabel, SIGNAL(customContextMenuRequested(QPoint)), parent, SLOT(exportCustomContextMenuRequested(QPoint)));
QObject::connect(QApplication::desktop(), SIGNAL(resized(int)), this, SLOT(updateWindowSize(int)));
setLayout(widgetLayout); setLayout(widgetLayout);
} }
@ -58,12 +56,10 @@ PictureWidget::~PictureWidget()
bool PictureWidget::eventFilter(QObject *obj, QEvent *ev) bool PictureWidget::eventFilter(QObject *obj, QEvent *ev)
{ {
if (obj == this) if (obj == this) {
{ if (ev->type() == QEvent::KeyPress) {
if (ev->type() == QEvent::KeyPress)
{
QKeyEvent *keyEvent = (QKeyEvent*)ev; QKeyEvent *keyEvent = (QKeyEvent*)ev;
switch (keyEvent->key()){ switch (keyEvent->key()) {
case Qt::Key_Left: case Qt::Key_Left:
emit previousPictureRequested(); emit previousPictureRequested();
break; break;
@ -78,32 +74,29 @@ bool PictureWidget::eventFilter(QObject *obj, QEvent *ev)
void PictureWidget::pictureDoubleClicked(Qt::MouseButton button) void PictureWidget::pictureDoubleClicked(Qt::MouseButton button)
{ {
if (button == Qt::LeftButton) if (button == Qt::LeftButton) {
{
close(); close();
} }
} }
void PictureWidget::setImage(QImage image_, QRect rec) void PictureWidget::setImage(QImage image_, QRect rec)
{ {
const qreal screenRatioPR = AppEnv::screenRatioPR();
image = image_; image = image_;
pictureLabel->setPixmap(QPixmap::fromImage(image.scaled(rec.width(), rec.height(), Qt::KeepAspectRatio, Qt::SmoothTransformation))); QPixmap pixmap = QPixmap::fromImage(image.scaled(rec.width() * screenRatioPR, rec.height() * screenRatioPR, Qt::KeepAspectRatio, Qt::SmoothTransformation));
#if QT_VERSION >= 0x050600
pixmap.setDevicePixelRatio(AppEnv::screenRatioPR());
#endif
pictureLabel->setPixmap(pixmap);
} }
void PictureWidget::setImage(QImage image_) void PictureWidget::setImage(QImage image_)
{ {
const qreal screenRatioPR = AppEnv::screenRatioPR();
image = image_; image = image_;
pictureLabel->setPixmap(QPixmap::fromImage(image.scaled(geometry().width(), geometry().height(), Qt::KeepAspectRatio, Qt::SmoothTransformation))); QPixmap pixmap = QPixmap::fromImage(image.scaled(geometry().width() * screenRatioPR, geometry().height() * screenRatioPR, Qt::KeepAspectRatio, Qt::SmoothTransformation));
} #if QT_VERSION >= 0x050600
pixmap.setDevicePixelRatio(screenRatioPR);
void PictureWidget::updateWindowSize(int screenID) #endif
{ pictureLabel->setPixmap(pixmap);
if (screenID == QApplication::desktop()->screenNumber(this))
{
QRect desktopRect = QApplication::desktop()->screenGeometry(this);
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)));
}
} }

View File

@ -46,7 +46,6 @@ private:
private slots: private slots:
void pictureDoubleClicked(Qt::MouseButton button); void pictureDoubleClicked(Qt::MouseButton button);
void updateWindowSize(int screenID);
signals: signals:
void nextPictureRequested(); void nextPictureRequested();

View File

@ -1,6 +1,6 @@
/***************************************************************************** /*****************************************************************************
* gta5view Grand Theft Auto V Profile Viewer * gta5view Grand Theft Auto V Profile Viewer
* Copyright (C) 2016-2018 Syping * Copyright (C) 2016-2021 Syping
* *
* This program is free software: you can redistribute it and/or modify * This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by * it under the terms of the GNU General Public License as published by
@ -18,7 +18,9 @@
#include "PlayerListDialog.h" #include "PlayerListDialog.h"
#include "ui_PlayerListDialog.h" #include "ui_PlayerListDialog.h"
#include "wrapper.h"
#include "AppEnv.h" #include "AppEnv.h"
#include <QStringBuilder>
#include <QFontMetrics> #include <QFontMetrics>
#include <QInputDialog> #include <QInputDialog>
#include <QMessageBox> #include <QMessageBox>
@ -31,7 +33,11 @@ PlayerListDialog::PlayerListDialog(QStringList players, ProfileDatabase *profile
ui(new Ui::PlayerListDialog) ui(new Ui::PlayerListDialog)
{ {
// Set Window Flags // Set Window Flags
#if QT_VERSION >= 0x050900
setWindowFlag(Qt::WindowContextHelpButtonHint, false);
#else
setWindowFlags(windowFlags()^Qt::WindowContextHelpButtonHint); setWindowFlags(windowFlags()^Qt::WindowContextHelpButtonHint);
#endif
listUpdated = false; listUpdated = false;
ui->setupUi(this); ui->setupUi(this);
@ -39,47 +45,60 @@ PlayerListDialog::PlayerListDialog(QStringList players, ProfileDatabase *profile
ui->cmdCancel->setFocus(); ui->cmdCancel->setFocus();
// Set Icon for Apply Button // Set Icon for Apply Button
if (QIcon::hasThemeIcon("dialog-ok-apply")) if (QIcon::hasThemeIcon("dialog-ok-apply")) {
{
ui->cmdApply->setIcon(QIcon::fromTheme("dialog-ok-apply")); ui->cmdApply->setIcon(QIcon::fromTheme("dialog-ok-apply"));
} }
else if (QIcon::hasThemeIcon("dialog-apply")) else if (QIcon::hasThemeIcon("dialog-apply")) {
{
ui->cmdApply->setIcon(QIcon::fromTheme("dialog-apply")); ui->cmdApply->setIcon(QIcon::fromTheme("dialog-apply"));
} }
else if (QIcon::hasThemeIcon("gtk-apply")) else if (QIcon::hasThemeIcon("gtk-apply")) {
{
ui->cmdApply->setIcon(QIcon::fromTheme("gtk-apply")); ui->cmdApply->setIcon(QIcon::fromTheme("gtk-apply"));
} }
else if (QIcon::hasThemeIcon("dialog-ok")) else if (QIcon::hasThemeIcon("dialog-ok")) {
{
ui->cmdApply->setIcon(QIcon::fromTheme("dialog-ok")); ui->cmdApply->setIcon(QIcon::fromTheme("dialog-ok"));
} }
else if (QIcon::hasThemeIcon("gtk-ok")) else if (QIcon::hasThemeIcon("gtk-ok")) {
{
ui->cmdApply->setIcon(QIcon::fromTheme("dialog-ok")); ui->cmdApply->setIcon(QIcon::fromTheme("dialog-ok"));
} }
// Set Icon for Cancel Button // Set Icon for Cancel Button
if (QIcon::hasThemeIcon("dialog-cancel")) if (QIcon::hasThemeIcon("dialog-cancel")) {
{
ui->cmdCancel->setIcon(QIcon::fromTheme("dialog-cancel")); ui->cmdCancel->setIcon(QIcon::fromTheme("dialog-cancel"));
} }
else if (QIcon::hasThemeIcon("gtk-cancel")) else if (QIcon::hasThemeIcon("gtk-cancel")) {
{
ui->cmdCancel->setIcon(QIcon::fromTheme("gtk-cancel")); ui->cmdCancel->setIcon(QIcon::fromTheme("gtk-cancel"));
} }
// Set Icon for Manage Buttons // Set Icon for Manage Buttons
if (QIcon::hasThemeIcon("go-previous") && QIcon::hasThemeIcon("go-next") && QIcon::hasThemeIcon("list-add")) 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->cmdMakeAv->setIcon(QIcon::fromTheme("go-previous"));
ui->cmdMakeSe->setIcon(QIcon::fromTheme("go-next")); ui->cmdMakeSe->setIcon(QIcon::fromTheme("go-next"));
ui->cmdMakeAd->setIcon(QIcon::fromTheme("list-add")); ui->cmdMakeAd->setIcon(QIcon::fromTheme("list-add"));
} }
else else {
{ #if QT_VERSION < 0x050600
drawSwitchButtons(); 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(AppEnv::getImagesFolder() % "/back.svgz"));
ui->cmdMakeSe->setIcon(QIcon(AppEnv::getImagesFolder() % "/next.svgz"));
ui->cmdMakeAd->setIcon(QIcon(AppEnv::getImagesFolder() % "/add.svgz"));
} }
buildInterface(); buildInterface();
@ -90,90 +109,15 @@ PlayerListDialog::PlayerListDialog(QStringList players, ProfileDatabase *profile
PlayerListDialog::~PlayerListDialog() PlayerListDialog::~PlayerListDialog()
{ {
for (QObject *object : ui->listAvPlayers->children()) for (QObject *object : ui->listAvPlayers->children()) {
{
delete object; delete object;
} }
for (QObject *object : ui->listSePlayers->children()) for (QObject *object : ui->listSePlayers->children()) {
{
delete object; delete object;
} }
delete ui; delete ui;
} }
void PlayerListDialog::drawSwitchButtons()
{
QFont painterFont = ui->cmdApply->font();
QPalette palette;
QFontMetrics fontMetrics(painterFont);
QRect makeAvRect = fontMetrics.boundingRect(QRect(0, 0, 0, 0), Qt::AlignCenter | Qt::TextDontClip, "<");
QRect makeSeRect = fontMetrics.boundingRect(QRect(0, 0, 0, 0), Qt::AlignCenter | Qt::TextDontClip, ">");
QRect makeAdRect = fontMetrics.boundingRect(QRect(0, 0, 0, 0), Qt::AlignCenter | Qt::TextDontClip, "+");
int makeAvSize;
if (makeAvRect.height() > makeAvRect.width())
{
makeAvSize = makeAvRect.height();
}
else
{
makeAvSize = makeAvRect.width();
}
int makeSeSize;
if (makeSeRect.height() > makeSeRect.width())
{
makeSeSize = makeSeRect.height();
}
else
{
makeSeSize = makeSeRect.width();
}
int makeAdSize;
if (makeAdRect.height() > makeAdRect.width())
{
makeAdSize = makeAdRect.height();
}
else
{
makeAdSize = makeAdRect.width();
}
QImage avImage(makeAvSize, makeAvSize, QImage::Format_ARGB32_Premultiplied);
avImage.fill(Qt::transparent);
QImage seImage(makeSeSize, makeSeSize, QImage::Format_ARGB32_Premultiplied);
seImage.fill(Qt::transparent);
QImage adImage(makeAdSize, makeAdSize, QImage::Format_ARGB32_Premultiplied);
adImage.fill(Qt::transparent);
QPainter avPainter(&avImage);
avPainter.setFont(painterFont);
avPainter.setBrush(palette.buttonText());
avPainter.setPen(palette.buttonText().color());
avPainter.drawText(0, 0, makeAvSize, makeAvSize, Qt::AlignCenter | Qt::TextDontClip, "<");
avPainter.end();
QPainter sePainter(&seImage);
sePainter.setFont(painterFont);
sePainter.setBrush(palette.buttonText());
sePainter.setPen(palette.buttonText().color());
sePainter.drawText(0, 0, makeSeSize, makeSeSize, Qt::AlignCenter | Qt::TextDontClip, ">");
sePainter.end();
QPainter adPainter(&adImage);
adPainter.setFont(painterFont);
adPainter.setBrush(palette.buttonText());
adPainter.setPen(palette.buttonText().color());
adPainter.drawText(0, 0, makeAdSize, makeAdSize, Qt::AlignCenter | Qt::TextDontClip, "+");
adPainter.end();
ui->cmdMakeAv->setIconSize(avImage.size());
ui->cmdMakeSe->setIconSize(seImage.size());
ui->cmdMakeAd->setIconSize(adImage.size());
ui->cmdMakeAv->setIcon(QIcon(QPixmap::fromImage(avImage)));
ui->cmdMakeSe->setIcon(QIcon(QPixmap::fromImage(seImage)));
ui->cmdMakeAd->setIcon(QIcon(QPixmap::fromImage(adImage)));
}
void PlayerListDialog::on_cmdCancel_clicked() void PlayerListDialog::on_cmdCancel_clicked()
{ {
close(); close();
@ -182,16 +126,13 @@ void PlayerListDialog::on_cmdCancel_clicked()
void PlayerListDialog::buildInterface() void PlayerListDialog::buildInterface()
{ {
const QStringList dbPlayers = profileDB->getPlayers(); const QStringList dbPlayers = profileDB->getPlayers();
for (QString sePlayer : players) for (const QString &sePlayer : qAsConst(players)) {
{
QListWidgetItem *playerItem = new QListWidgetItem(profileDB->getPlayerName(sePlayer)); QListWidgetItem *playerItem = new QListWidgetItem(profileDB->getPlayerName(sePlayer));
playerItem->setData(Qt::UserRole, sePlayer); playerItem->setData(Qt::UserRole, sePlayer);
ui->listSePlayers->addItem(playerItem); ui->listSePlayers->addItem(playerItem);
} }
for (QString dbPlayer : dbPlayers) for (const QString &dbPlayer : dbPlayers) {
{ if (!players.contains(dbPlayer)) {
if (!players.contains(dbPlayer))
{
QListWidgetItem *playerItem = new QListWidgetItem(profileDB->getPlayerName(dbPlayer)); QListWidgetItem *playerItem = new QListWidgetItem(profileDB->getPlayerName(dbPlayer));
playerItem->setData(Qt::UserRole, dbPlayer); playerItem->setData(Qt::UserRole, dbPlayer);
ui->listAvPlayers->addItem(playerItem); ui->listAvPlayers->addItem(playerItem);
@ -202,8 +143,7 @@ void PlayerListDialog::buildInterface()
void PlayerListDialog::on_cmdMakeAv_clicked() void PlayerListDialog::on_cmdMakeAv_clicked()
{ {
for (QListWidgetItem *item : ui->listSePlayers->selectedItems()) for (QListWidgetItem *item : ui->listSePlayers->selectedItems()) {
{
QString playerName = item->text(); QString playerName = item->text();
int playerID = item->data(Qt::UserRole).toInt(); int playerID = item->data(Qt::UserRole).toInt();
delete item; delete item;
@ -217,13 +157,11 @@ void PlayerListDialog::on_cmdMakeAv_clicked()
void PlayerListDialog::on_cmdMakeSe_clicked() void PlayerListDialog::on_cmdMakeSe_clicked()
{ {
int maxPlayers = 30; int maxPlayers = 30;
if (maxPlayers < ui->listSePlayers->count() + ui->listAvPlayers->selectedItems().count()) 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))); QMessageBox::warning(this, tr("Add Players..."), tr("Failed to add more Players because the limit of Players are %1!").arg(QString::number(maxPlayers)));
return; return;
} }
for (QListWidgetItem *item : ui->listAvPlayers->selectedItems()) for (QListWidgetItem *item : ui->listAvPlayers->selectedItems()) {
{
QString playerName = item->text(); QString playerName = item->text();
int playerID = item->data(Qt::UserRole).toInt(); int playerID = item->data(Qt::UserRole).toInt();
delete item; delete item;
@ -237,15 +175,12 @@ void PlayerListDialog::on_cmdMakeAd_clicked()
{ {
bool playerOk; bool playerOk;
int playerID = QInputDialog::getInt(this, tr("Add Player..."), tr("Enter Social Club Player ID"), 1, 1, 214783647, 1, &playerOk, windowFlags()); int playerID = QInputDialog::getInt(this, tr("Add Player..."), tr("Enter Social Club Player ID"), 1, 1, 214783647, 1, &playerOk, windowFlags());
if (playerOk) if (playerOk) {
{ for (int i = 0; i < ui->listAvPlayers->count(); ++i) {
for (int i = 0; i < ui->listAvPlayers->count(); ++i)
{
QListWidgetItem *item = ui->listAvPlayers->item(i); QListWidgetItem *item = ui->listAvPlayers->item(i);
QString itemPlayerName = item->text(); QString itemPlayerName = item->text();
int itemPlayerID = item->data(Qt::UserRole).toInt(); int itemPlayerID = item->data(Qt::UserRole).toInt();
if (itemPlayerID == playerID) if (itemPlayerID == playerID) {
{
delete item; delete item;
QListWidgetItem *playerItem = new QListWidgetItem(itemPlayerName); QListWidgetItem *playerItem = new QListWidgetItem(itemPlayerName);
playerItem->setData(Qt::UserRole, playerID); playerItem->setData(Qt::UserRole, playerID);
@ -253,8 +188,7 @@ void PlayerListDialog::on_cmdMakeAd_clicked()
return; return;
} }
} }
for (int i = 0; i < ui->listSePlayers->count(); ++i) for (int i = 0; i < ui->listSePlayers->count(); ++i) {
{
QListWidgetItem *item = ui->listSePlayers->item(i); QListWidgetItem *item = ui->listSePlayers->item(i);
int itemPlayerID = item->data(Qt::UserRole).toInt(); int itemPlayerID = item->data(Qt::UserRole).toInt();
if (itemPlayerID == playerID) if (itemPlayerID == playerID)
@ -272,8 +206,7 @@ void PlayerListDialog::on_cmdMakeAd_clicked()
void PlayerListDialog::on_cmdApply_clicked() void PlayerListDialog::on_cmdApply_clicked()
{ {
players.clear(); players.clear();
for (int i = 0; i < ui->listSePlayers->count(); ++i) for (int i = 0; i < ui->listSePlayers->count(); ++i) {
{
players += ui->listSePlayers->item(i)->data(Qt::UserRole).toString(); players += ui->listSePlayers->item(i)->data(Qt::UserRole).toString();
} }
emit playerListUpdated(players); emit playerListUpdated(players);

View File

@ -48,7 +48,6 @@ private:
ProfileDatabase *profileDB; ProfileDatabase *profileDB;
Ui::PlayerListDialog *ui; Ui::PlayerListDialog *ui;
bool listUpdated; bool listUpdated;
void drawSwitchButtons();
void buildInterface(); void buildInterface();
signals: signals:

View File

@ -51,8 +51,8 @@
</item> </item>
<item> <item>
<widget class="QPushButton" name="cmdMakeSe"> <widget class="QPushButton" name="cmdMakeSe">
<property name="text"> <property name="focusPolicy">
<string/> <enum>Qt::NoFocus</enum>
</property> </property>
<property name="autoDefault"> <property name="autoDefault">
<bool>false</bool> <bool>false</bool>
@ -61,6 +61,9 @@
</item> </item>
<item> <item>
<widget class="QPushButton" name="cmdMakeAv"> <widget class="QPushButton" name="cmdMakeAv">
<property name="focusPolicy">
<enum>Qt::NoFocus</enum>
</property>
<property name="text"> <property name="text">
<string/> <string/>
</property> </property>
@ -71,6 +74,9 @@
</item> </item>
<item> <item>
<widget class="QPushButton" name="cmdMakeAd"> <widget class="QPushButton" name="cmdMakeAd">
<property name="focusPolicy">
<enum>Qt::NoFocus</enum>
</property>
<property name="text"> <property name="text">
<string/> <string/>
</property> </property>

File diff suppressed because it is too large Load Diff

View File

@ -1,6 +1,6 @@
/***************************************************************************** /*****************************************************************************
* gta5view Grand Theft Auto V Profile Viewer * gta5view Grand Theft Auto V Profile Viewer
* Copyright (C) 2016-2017 Syping * Copyright (C) 2016-2021 Syping
* *
* This program is free software: you can redistribute it and/or modify * This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by * it under the terms of the GNU General Public License as published by
@ -30,6 +30,7 @@
#include "SavegameData.h" #include "SavegameData.h"
#include "CrewDatabase.h" #include "CrewDatabase.h"
#include "pcg_basic.h" #include "pcg_basic.h"
#include <QFileSystemWatcher>
#include <QProgressDialog> #include <QProgressDialog>
#include <QSpacerItem> #include <QSpacerItem>
#include <QDateTime> #include <QDateTime>
@ -52,8 +53,6 @@ public:
void settingsApplied(int contentMode, bool languageChanged); void settingsApplied(int contentMode, bool languageChanged);
void setupProfileInterface(); void setupProfileInterface();
void massTool(MassTool tool); void massTool(MassTool tool);
void disableSelected();
void enableSelected();
int selectedWidgets(); int selectedWidgets();
void retranslateUi(); void retranslateUi();
~ProfileInterface(); ~ProfileInterface();
@ -64,8 +63,11 @@ public slots:
void hoverProfileWidgetCheck(); void hoverProfileWidgetCheck();
void selectAllWidgets(); void selectAllWidgets();
void deselectAllWidgets(); void deselectAllWidgets();
void disableSelected();
void enableSelected();
void exportSelected(); void exportSelected();
void deleteSelected(); void deleteSelected();
void deleteSelectedR();
void updatePalette(); void updatePalette();
void importFiles(); void importFiles();
@ -81,9 +83,17 @@ private slots:
void profileLoaded_p(); void profileLoaded_p();
void profileWidgetSelected(); void profileWidgetSelected();
void profileWidgetDeselected(); void profileWidgetDeselected();
void massToolQualify();
void massToolPlayers();
void massToolCrew();
void massToolTitle();
void dialogNextPictureRequested(QWidget *dialog); void dialogNextPictureRequested(QWidget *dialog);
void dialogPreviousPictureRequested(QWidget *dialog); void dialogPreviousPictureRequested(QWidget *dialog);
void on_saProfileContent_dropped(const QMimeData *mimeData); void on_saProfileContent_dropped(const QMimeData *mimeData);
#if QT_VERSION >= 0x050000
void directoryChanged(const QString &path);
void directoryScanned(QVector<QString> savegameFiles, QVector<QString> snapmaticPics);
#endif
protected: protected:
bool eventFilter(QObject *watched, QEvent *event); bool eventFilter(QObject *watched, QEvent *event);
@ -99,10 +109,13 @@ private:
QList<SavegameData*> savegames; QList<SavegameData*> savegames;
QList<SnapmaticPicture*> pictures; QList<SnapmaticPicture*> pictures;
QMap<ProfileWidget*,QString> widgets; QMap<ProfileWidget*,QString> widgets;
#if QT_VERSION >= 0x050000
QFileSystemWatcher fileSystemWatcher;
QVector<QString> savegameFiles;
QVector<QString> snapmaticPics;
#endif
QSpacerItem *saSpacerItem; QSpacerItem *saSpacerItem;
QStringList fixedPictures; QStringList fixedPictures;
QColor highlightBackColor;
QColor highlightTextColor;
QString enabledPicStr; QString enabledPicStr;
QString profileFolder; QString profileFolder;
QString profileName; QString profileName;
@ -126,6 +139,7 @@ private:
void savegameLoaded(SavegameData *savegame, QString savegamePath, bool inserted); void savegameLoaded(SavegameData *savegame, QString savegamePath, bool inserted);
void savegameDeleted(SavegameWidget *sgdWidget, bool isRemoteEmited = false); void savegameDeleted(SavegameWidget *sgdWidget, bool isRemoteEmited = false);
void pictureDeleted(SnapmaticWidget *picWidget, bool isRemoteEmited = false); void pictureDeleted(SnapmaticWidget *picWidget, bool isRemoteEmited = false);
void deleteSelectedL(bool isRemoteEmited = false);
void insertSnapmaticIPI(QWidget *widget); void insertSnapmaticIPI(QWidget *widget);
void insertSavegameIPI(QWidget *widget); void insertSavegameIPI(QWidget *widget);
void sortingProfileInterface(); void sortingProfileInterface();

View File

@ -1,6 +1,6 @@
/***************************************************************************** /*****************************************************************************
* gta5view Grand Theft Auto V Profile Viewer * gta5view Grand Theft Auto V Profile Viewer
* Copyright (C) 2016-2017 Syping * Copyright (C) 2016-2021 Syping
* *
* This program is free software: you can redistribute it and/or modify * This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by * it under the terms of the GNU General Public License as published by
@ -16,80 +16,99 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>. * along with this program. If not, see <http://www.gnu.org/licenses/>.
*****************************************************************************/ *****************************************************************************/
#include "ProfileLoader.h"
#include "SnapmaticPicture.h" #include "SnapmaticPicture.h"
#include "ProfileLoader.h"
#include "SavegameData.h" #include "SavegameData.h"
#include "CrewDatabase.h" #include "CrewDatabase.h"
#include "wrapper.h"
#include <QStringBuilder> #include <QStringBuilder>
#include <QStringList> #include <QVector>
#include <QString> #include <QString>
#include <QThread>
#include <QList>
#include <QFile> #include <QFile>
#ifdef Q_OS_WIN
#include <QDir> #include <QDir>
#include <QList>
#else
#include "sys/types.h"
#include "sys/stat.h"
#include "dirent.h"
#endif
ProfileLoader::ProfileLoader(QString profileFolder, CrewDatabase *crewDB, QObject *parent) : QThread(parent), profileFolder(profileFolder), crewDB(crewDB) ProfileLoader::ProfileLoader(QString profileFolder, CrewDatabase *crewDB, QObject *parent) : QThread(parent), profileFolder(profileFolder), crewDB(crewDB)
{ {
} }
void ProfileLoader::run() void ProfileLoader::run()
{ {
int curFile = 1; int curFile = 1;
QDir profileDir; int maximumV = 0;
QList<int> crewList; QVector<int> crewList;
profileDir.setPath(profileFolder); QVector<QString> savegameFiles;
QVector<QString> snapmaticPics;
// Seek pictures and savegames #ifdef Q_OS_WIN
profileDir.setNameFilters(QStringList("SGTA*")); QDir dir(profileFolder);
QStringList SavegameFiles = profileDir.entryList(QDir::Files | QDir::NoDot, QDir::NoSort); const QStringList files = dir.entryList(QDir::Files);
QStringList BackupFiles = SavegameFiles.filter(".bak", Qt::CaseInsensitive); for (const QString &fileName : files) {
profileDir.setNameFilters(QStringList("PGTA*")); if (fileName.startsWith("SGTA5") && !fileName.endsWith(".bak")) {
QStringList SnapmaticPics = profileDir.entryList(QDir::Files | QDir::NoDot, QDir::NoSort); savegameFiles << fileName;
BackupFiles += SnapmaticPics.filter(".bak", Qt::CaseInsensitive); maximumV++;
}
SavegameFiles.removeDuplicates(); if (fileName.startsWith("PGTA5") && !fileName.endsWith(".bak")) {
SnapmaticPics.removeDuplicates(); snapmaticPics << fileName;
for (QString BackupFile : BackupFiles) maximumV++;
{ }
SavegameFiles.removeAll(BackupFile);
SnapmaticPics.removeAll(BackupFile);
} }
#else
DIR *dirp = opendir(profileFolder.toUtf8().constData());
struct dirent *dp;
while ((dp = readdir(dirp)) != 0) {
const QString fileName = QString::fromUtf8(dp->d_name);
const QString filePath = profileFolder % "/" % fileName;
struct stat fileStat;
stat(filePath.toUtf8().constData(), &fileStat);
if (S_ISREG(fileStat.st_mode) != 0) {
if (fileName.startsWith("SGTA5") && !fileName.endsWith(".bak")) {
savegameFiles << fileName;
maximumV++;
}
if (fileName.startsWith("PGTA5") && !fileName.endsWith(".bak")) {
snapmaticPics << fileName;
maximumV++;
}
}
}
closedir(dirp);
#endif
int maximumV = SavegameFiles.length() + SnapmaticPics.length(); // Directory successfully scanned
emit directoryScanned(savegameFiles, snapmaticPics);
// Loading pictures and savegames // Loading pictures and savegames
emit loadingProgress(curFile, maximumV); emit loadingProgress(curFile, maximumV);
for (QString SavegameFile : SavegameFiles) for (const QString &SavegameFile : qAsConst(savegameFiles)) {
{
emit loadingProgress(curFile, maximumV); emit loadingProgress(curFile, maximumV);
QString sgdPath = profileFolder % "/" % SavegameFile; const QString sgdPath = profileFolder % "/" % SavegameFile;
SavegameData *savegame = new SavegameData(sgdPath); SavegameData *savegame = new SavegameData(sgdPath);
if (savegame->readingSavegame()) if (savegame->readingSavegame()) {
{
emit savegameLoaded(savegame, sgdPath); emit savegameLoaded(savegame, sgdPath);
} }
curFile++; curFile++;
} }
for (QString SnapmaticPic : SnapmaticPics) for (const QString &SnapmaticPic : qAsConst(snapmaticPics)) {
{
emit loadingProgress(curFile, maximumV); emit loadingProgress(curFile, maximumV);
QString picturePath = profileFolder % "/" % SnapmaticPic; const QString picturePath = profileFolder % "/" % SnapmaticPic;
SnapmaticPicture *picture = new SnapmaticPicture(picturePath); SnapmaticPicture *picture = new SnapmaticPicture(picturePath);
if (picture->readingPicture(true, true, true)) if (picture->readingPicture(true)) {
{ if (picture->isFormatSwitched()) {
if (picture->isFormatSwitched())
{
picture->setSnapmaticFormat(SnapmaticFormat::PGTA_Format); picture->setSnapmaticFormat(SnapmaticFormat::PGTA_Format);
if (picture->exportPicture(picturePath, SnapmaticFormat::PGTA_Format)) if (picture->exportPicture(picturePath, SnapmaticFormat::PGTA_Format)) {
{
emit pictureFixed(picture); emit pictureFixed(picture);
} }
} }
emit pictureLoaded(picture); emit pictureLoaded(picture);
int crewNumber = picture->getSnapmaticProperties().crewID; int crewNumber = picture->getSnapmaticProperties().crewID;
if (!crewList.contains(crewNumber)) if (!crewList.contains(crewNumber)) {
{
crewList += crewNumber; crewList += crewNumber;
} }
} }
@ -98,8 +117,7 @@ void ProfileLoader::run()
// adding found crews // adding found crews
crewDB->setAddingCrews(true); crewDB->setAddingCrews(true);
for (int crewID : crewList) for (int crewID : qAsConst(crewList)) {
{
crewDB->addCrew(crewID); crewDB->addCrew(crewID);
} }
crewDB->setAddingCrews(false); crewDB->setAddingCrews(false);
@ -107,10 +125,9 @@ void ProfileLoader::run()
void ProfileLoader::preloaded() void ProfileLoader::preloaded()
{ {
} }
void ProfileLoader::loaded() void ProfileLoader::loaded()
{ {
} }

View File

@ -1,6 +1,6 @@
/***************************************************************************** /*****************************************************************************
* gta5view Grand Theft Auto V Profile Viewer * gta5view Grand Theft Auto V Profile Viewer
* Copyright (C) 2016-2017 Syping * Copyright (C) 2016-2021 Syping
* *
* This program is free software: you can redistribute it and/or modify * This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by * it under the terms of the GNU General Public License as published by
@ -48,6 +48,7 @@ signals:
void pictureFixed(SnapmaticPicture *picture); void pictureFixed(SnapmaticPicture *picture);
void savegameLoaded(SavegameData *savegame, QString savegamePath); void savegameLoaded(SavegameData *savegame, QString savegamePath);
void loadingProgress(int value, int maximum); void loadingProgress(int value, int maximum);
void directoryScanned(QVector<QString> savegameFiles, QVector<QString> snapmaticPics);
}; };
#endif // PROFILELOADER_H #endif // PROFILELOADER_H

View File

@ -1,10 +1,10 @@
## gta5view ## gta5view
Grand Theft Auto V Savegame and Snapmatic viewer/editor Open Source Snapmatic and Savegame viewer/editor for GTA V
- View Snapmatics with the ability to disable them in-game - View Snapmatics with the ability to disable them in-game
- Edit Snapmatic pictures and properties in multiple ways - Edit Snapmatic pictures and properties in multiple ways
- Import/Export Snapmatics, Savegames and pictures - Import/Export Snapmatics, Savegames and pictures
- Let choose between multiple Social Club accounts as GTA V profiles IDs - Choose between multiple Social Club accounts as GTA V profiles IDs
#### Screenshots #### Screenshots
![Snapmatic Picture Viewer](res/src/picture.png) ![Snapmatic Picture Viewer](res/src/picture.png)
@ -14,40 +14,32 @@ Grand Theft Auto V Savegame and Snapmatic viewer/editor
#### Build gta5view for Windows #### Build gta5view for Windows
# Note: Install Docker Community Edition and Git before continuing # Note: Install Docker Community Edition and Git before continuing
git clone https://gitlab.com/Syping/gta5view && cd gta5view docker pull sypingauto/gta5view-build:1.10-static
docker pull syping/qt5-static-mingw git clone https://gitlab.com/Syping/gta5view
docker run --rm -v ${PWD}:/gta5view -it syping/qt5-static-mingw docker run --rm -v "$PWD/gta5view:/gta5view" -it sypingauto/gta5view-build:1.10-static
cd /gta5view && mkdir -p build && cd build mingw64-qt-cmake -B /gta5view/build /gta5view
qmake-static ../gta5view.pro cmake --build /gta5view/build
make depend
make -j $(nproc --all)
#### Build gta5view for Debian/Ubuntu #### Build gta5view for Debian/Ubuntu
sudo apt-get install git gcc g++ qtbase5-dev qttranslations5-l10n qt5-qmake make sudo apt-get install cmake git gcc g++ libqt5svg5-dev make qtbase5-dev qttranslations5-l10n
git clone https://gitlab.com/Syping/gta5view && cd gta5view git clone https://gitlab.com/Syping/gta5view
mkdir -p build && cd build cmake -B gta5view-build gta5view
../configure --prefix=/opt/gta5view cmake --build gta5view-build
make depend sudo cmake --install gta5view-build
make -j $(nproc --all)
sudo make install
#### Build gta5view for Fedora #### Build gta5view for Arch/Manjaro
sudo dnf install git gcc gcc-c++ qt5-qtbase-devel qt5-qttranslations make sudo pacman -S cmake gcc git make qt5-base qt5-svg qt5-tools qt5-translations
git clone https://gitlab.com/Syping/gta5view && cd gta5view git clone https://gitlab.com/Syping/gta5view
mkdir -p build && cd build cmake -B gta5view-build gta5view
../configure --prefix=/opt/gta5view cmake --build gta5view-build
make depend sudo cmake --install gta5view-build
make -j $(nproc --all)
sudo make install
#### Build gta5view for Windows (Beginner) #### Build gta5view for Fedora/RHEL
Download the [Qt Framework](https://www.qt.io/) and install the MinGW version. sudo dnf install cmake git gcc gcc-c++ make qt5-qtbase-devel qt5-qtsvg-devel qt5-qttranslations
Download the Source Code over the Repository or with your Git client. git clone https://gitlab.com/Syping/gta5view
Open the gta5view.pro Project file with Qt Creator and build it over Qt Creator. cmake -B gta5view-build gta5view
cmake --build gta5view-build
#### Download Binary Releases sudo cmake --install gta5view-build
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.

893
RagePhoto.cpp Normal file
View File

@ -0,0 +1,893 @@
/*****************************************************************************
* gta5view Grand Theft Auto V Profile Viewer
* Copyright (C) 2020-2022 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 "RagePhoto.h"
#include <QJsonDocument>
#include <QBuffer>
#include <QFile>
#if QT_VERSION < 0x060000
#include <QTextCodec>
#else
#include <QStringEncoder>
#include <QStringDecoder>
#endif
#ifdef RAGEPHOTO_BENCHMARK
#include <QFileInfo>
#include <chrono>
#endif
inline quint32 joaatFromSI(const char *data, size_t size)
{
quint32 val = 0xE47AB81CUL;
for (size_t i = 0; i != size; i++) {
val += data[i];
val += (val << 10);
val ^= (val >> 6);
}
val += (val << 3);
val ^= (val >> 11);
val += (val << 15);
return val;
}
RagePhoto::RagePhoto()
{
p_photoFormat = PhotoFormat::Undefined;
p_isLoaded = false;
p_inputMode = -1;
}
RagePhoto::RagePhoto(const QByteArray &data) : p_fileData(data)
{
p_photoFormat = PhotoFormat::Undefined;
p_isLoaded = false;
p_inputMode = 0;
}
RagePhoto::RagePhoto(const QString &filePath) : p_filePath(filePath)
{
p_photoFormat = PhotoFormat::Undefined;
p_isLoaded = false;
p_inputMode = 1;
}
RagePhoto::RagePhoto(QIODevice *ioDevice) : p_ioDevice(ioDevice)
{
p_photoFormat = PhotoFormat::Undefined;
p_isLoaded = false;
p_inputMode = 2;
}
bool RagePhoto::isLoaded()
{
return p_isLoaded;
}
bool RagePhoto::load()
{
if (p_inputMode == -1)
return false;
if (p_isLoaded)
clear();
if (p_inputMode == 1) {
QFile pictureFile(p_filePath);
if (pictureFile.open(QIODevice::ReadOnly)) {
p_fileData = pictureFile.readAll();
}
pictureFile.close();
}
else if (p_inputMode == 2) {
if (!p_ioDevice->isOpen()) {
if (!p_ioDevice->open(QIODevice::ReadOnly))
return false;
}
p_fileData = p_ioDevice->readAll();
}
QBuffer dataBuffer(&p_fileData);
dataBuffer.open(QIODevice::ReadOnly);
#ifdef RAGEPHOTO_BENCHMARK
auto benchmark_parse_start = std::chrono::high_resolution_clock::now();
#endif
char uInt32Buffer[4];
qint64 size = dataBuffer.read(uInt32Buffer, 4);
if (size != 4)
return false;
quint32 format = charToUInt32LE(uInt32Buffer);
if (format == static_cast<quint32>(PhotoFormat::GTA5)) {
char photoHeader[256];
size = dataBuffer.read(photoHeader, 256);
if (size != 256) {
return false;
}
for (const QChar &photoChar : utf16LEToString(photoHeader, 256)) {
if (photoChar.isNull())
break;
p_photoString += photoChar;
}
size = dataBuffer.read(uInt32Buffer, 4);
if (size != 4)
return false;
p_headerSum = charToUInt32LE(uInt32Buffer);
size = dataBuffer.read(uInt32Buffer, 4);
if (size != 4)
return false;
p_endOfFile = charToUInt32LE(uInt32Buffer);
size = dataBuffer.read(uInt32Buffer, 4);
if (size != 4)
return false;
p_jsonOffset = charToUInt32LE(uInt32Buffer);
size = dataBuffer.read(uInt32Buffer, 4);
if (size != 4)
return false;
p_titlOffset = charToUInt32LE(uInt32Buffer);
size = dataBuffer.read(uInt32Buffer, 4);
if (size != 4)
return false;
p_descOffset = charToUInt32LE(uInt32Buffer);
char markerBuffer[4];
size = dataBuffer.read(markerBuffer, 4);
if (size != 4)
return false;
if (strncmp(markerBuffer, "JPEG", 4) != 0)
return false;
size = dataBuffer.read(uInt32Buffer, 4);
if (size != 4)
return false;
p_photoBuffer = charToUInt32LE(uInt32Buffer);
size = dataBuffer.read(uInt32Buffer, 4);
if (size != 4)
return false;
quint32 t_photoSize = charToUInt32LE(uInt32Buffer);
char *photoData = static_cast<char*>(malloc(t_photoSize));
if (!photoData)
return false;
size = dataBuffer.read(photoData, t_photoSize);
if (size != t_photoSize) {
free(photoData);
return false;
}
p_photoData = QByteArray(photoData, t_photoSize);
free(photoData);
dataBuffer.seek(p_jsonOffset + 264);
size = dataBuffer.read(markerBuffer, 4);
if (size != 4)
return false;
if (strncmp(markerBuffer, "JSON", 4) != 0)
return false;
size = dataBuffer.read(uInt32Buffer, 4);
if (size != 4)
return false;
p_jsonBuffer = charToUInt32LE(uInt32Buffer);
char *jsonBytes = static_cast<char*>(malloc(p_jsonBuffer));
if (!jsonBytes)
return false;
size = dataBuffer.read(jsonBytes, p_jsonBuffer);
if (size != p_jsonBuffer) {
free(jsonBytes);
return false;
}
quint32 i;
for (i = 0; i != p_jsonBuffer; i++) {
if (jsonBytes[i] == '\x00')
break;
}
p_jsonData = QByteArray(jsonBytes, i);
free(jsonBytes);
QJsonDocument t_jsonDocument = QJsonDocument::fromJson(p_jsonData);
if (t_jsonDocument.isNull())
return false;
p_jsonObject = t_jsonDocument.object();
dataBuffer.seek(p_titlOffset + 264);
size = dataBuffer.read(markerBuffer, 4);
if (size != 4)
return false;
if (strncmp(markerBuffer, "TITL", 4) != 0)
return false;
size = dataBuffer.read(uInt32Buffer, 4);
if (size != 4)
return false;
p_titlBuffer = charToUInt32LE(uInt32Buffer);
char *titlBytes = static_cast<char*>(malloc(p_titlBuffer));
if (!titlBytes)
return false;
size = dataBuffer.read(titlBytes, p_titlBuffer);
if (size != p_titlBuffer){
free(titlBytes);
return false;
}
for (i = 0; i != p_titlBuffer; i++) {
if (titlBytes[i] == '\x00')
break;
}
p_titleString = QString::fromUtf8(titlBytes, i);
free(titlBytes);
dataBuffer.seek(p_descOffset + 264);
size = dataBuffer.read(markerBuffer, 4);
if (size != 4)
return false;
if (strncmp(markerBuffer, "DESC", 4) != 0)
return false;
size = dataBuffer.read(uInt32Buffer, 4);
if (size != 4)
return false;
p_descBuffer = charToUInt32LE(uInt32Buffer);
char *descBytes = static_cast<char*>(malloc(p_descBuffer));
if (!descBytes)
return false;
size = dataBuffer.read(descBytes, p_descBuffer);
if (size != p_descBuffer) {
free(descBytes);
return false;
}
for (i = 0; i != p_descBuffer; i++) {
if (descBytes[i] == '\x00')
break;
}
p_descriptionString = QString::fromUtf8(descBytes, i);
free(descBytes);
dataBuffer.seek(p_endOfFile + 260);
size = dataBuffer.read(markerBuffer, 4);
if (size != 4)
return false;
if (strncmp(markerBuffer, "JEND", 4) != 0)
return false;
#ifdef RAGEPHOTO_BENCHMARK
auto benchmark_parse_end = std::chrono::high_resolution_clock::now();
auto benchmark_ns = std::chrono::duration_cast<std::chrono::nanoseconds>(benchmark_parse_end - benchmark_parse_start);
if (p_inputMode == 1) {
QTextStream(stdout) << QFileInfo(p_filePath).fileName() << ": " << benchmark_ns.count() << "ns" << Qt::endl;
}
else {
QTextStream(stdout) << "PGTA5" << p_jsonObject.value("uid").toInt() << ": " << benchmark_ns.count() << "ns" << Qt::endl;
}
#endif
if (p_photoFormat != PhotoFormat::G5EX)
p_photoFormat = PhotoFormat::GTA5;
p_fileData.clear();
p_isLoaded = true;
return true;
}
else if (format == static_cast<quint32>(PhotoFormat::G5EX)) {
size = dataBuffer.read(uInt32Buffer, 4);
if (size != 4)
return false;
format = charToUInt32LE(uInt32Buffer);
if (format == static_cast<quint32>(ExportFormat::G5E3P)) {
size = dataBuffer.read(uInt32Buffer, 4);
if (size != 4)
return false;
quint32 compressedSize = charToUInt32LE(uInt32Buffer);
char *compressedPhotoHeader = static_cast<char*>(malloc(compressedSize));
if (!compressedPhotoHeader)
return false;
size = dataBuffer.read(compressedPhotoHeader, compressedSize);
if (size != compressedSize) {
free(compressedPhotoHeader);
return false;
}
QByteArray t_photoHeader = QByteArray::fromRawData(compressedPhotoHeader, compressedSize);
t_photoHeader = qUncompress(t_photoHeader);
free(compressedPhotoHeader);
if (t_photoHeader.isEmpty())
return false;
p_photoString = QString::fromUtf8(t_photoHeader);
size = dataBuffer.read(uInt32Buffer, 4);
if (size != 4)
return false;
p_headerSum = charToUInt32LE(uInt32Buffer);
size = dataBuffer.read(uInt32Buffer, 4);
if (size != 4)
return false;
p_photoBuffer = charToUInt32LE(uInt32Buffer);
size = dataBuffer.read(uInt32Buffer, 4);
if (size != 4)
return false;
compressedSize = charToUInt32LE(uInt32Buffer);
char *compressedPhoto = static_cast<char*>(malloc(compressedSize));
if (!compressedPhoto)
return false;
size = dataBuffer.read(compressedPhoto, compressedSize);
if (size != compressedSize) {
free(compressedPhoto);
return false;
}
QByteArray t_photoData = QByteArray::fromRawData(compressedPhoto, compressedSize);
p_photoData = qUncompress(t_photoData);
free(compressedPhoto);
size = dataBuffer.read(uInt32Buffer, 4);
if (size != 4)
return false;
p_jsonOffset = charToUInt32LE(uInt32Buffer);
size = dataBuffer.read(uInt32Buffer, 4);
if (size != 4)
return false;
p_jsonBuffer = charToUInt32LE(uInt32Buffer);
size = dataBuffer.read(uInt32Buffer, 4);
if (size != 4)
return false;
compressedSize = charToUInt32LE(uInt32Buffer);
char *compressedJson = static_cast<char*>(malloc(compressedSize));
if (!compressedJson)
return false;
size = dataBuffer.read(compressedJson, compressedSize);
if (size != compressedSize) {
free(compressedJson);
return false;
}
QByteArray t_jsonBytes = QByteArray::fromRawData(compressedJson, compressedSize);
p_jsonData = qUncompress(t_jsonBytes);
free(compressedJson);
if (p_jsonData.isEmpty())
return false;
QJsonDocument t_jsonDocument = QJsonDocument::fromJson(p_jsonData);
if (t_jsonDocument.isNull())
return false;
p_jsonObject = t_jsonDocument.object();
size = dataBuffer.read(uInt32Buffer, 4);
if (size != 4)
return false;
p_titlOffset = charToUInt32LE(uInt32Buffer);
size = dataBuffer.read(uInt32Buffer, 4);
if (size != 4)
return false;
p_titlBuffer = charToUInt32LE(uInt32Buffer);
size = dataBuffer.read(uInt32Buffer, 4);
if (size != 4)
return false;
compressedSize = charToUInt32LE(uInt32Buffer);
char *compressedTitl = static_cast<char*>(malloc(compressedSize));
if (!compressedTitl)
return false;
size = dataBuffer.read(compressedTitl, compressedSize);
if (size != compressedSize) {
free(compressedTitl);
return false;
}
QByteArray t_titlBytes = QByteArray::fromRawData(compressedTitl, compressedSize);
t_titlBytes = qUncompress(t_titlBytes);
free(compressedTitl);
p_titleString = QString::fromUtf8(t_titlBytes);
size = dataBuffer.read(uInt32Buffer, 4);
if (size != 4)
return false;
p_descOffset = charToUInt32LE(uInt32Buffer);
size = dataBuffer.read(uInt32Buffer, 4);
if (size != 4)
return false;
p_descBuffer = charToUInt32LE(uInt32Buffer);
size = dataBuffer.read(uInt32Buffer, 4);
if (size != 4)
return false;
compressedSize = charToUInt32LE(uInt32Buffer);
char *compressedDesc = static_cast<char*>(malloc(compressedSize));
if (!compressedDesc)
return false;
size = dataBuffer.read(compressedDesc, compressedSize);
if (size != compressedSize) {
free(compressedDesc);
return false;
}
QByteArray t_descBytes = QByteArray::fromRawData(compressedDesc, compressedSize);
t_descBytes = qUncompress(t_descBytes);
free(compressedDesc);
p_descriptionString = QString::fromUtf8(t_descBytes);
size = dataBuffer.read(uInt32Buffer, 4);
if (size != 4)
return false;
p_endOfFile = charToUInt32LE(uInt32Buffer);
#ifdef RAGEPHOTO_BENCHMARK
auto benchmark_parse_end = std::chrono::high_resolution_clock::now();
auto benchmark_ns = std::chrono::duration_cast<std::chrono::nanoseconds>(benchmark_parse_end - benchmark_parse_start);
if (p_inputMode == 1) {
QTextStream(stdout) << QFileInfo(p_filePath).fileName() << ": " << benchmark_ns.count() << "ns" << Qt::endl;
}
else {
QTextStream(stdout) << "PGTA5" << p_jsonObject.value("uid").toInt() << ": " << benchmark_ns.count() << "ns" << Qt::endl;
}
#endif
p_photoFormat = PhotoFormat::G5EX;
p_fileData.clear();
p_isLoaded = true;
return true;
}
else if (format == static_cast<quint32>(ExportFormat::G5E2P)) {
p_photoFormat = PhotoFormat::G5EX;
p_fileData = qUncompress(dataBuffer.readAll());
if (p_fileData.isEmpty())
return false;
p_inputMode = 0;
return load();
}
else if (format == static_cast<quint32>(ExportFormat::G5E1P)) {
#if QT_VERSION >= 0x050A00
size = dataBuffer.skip(1);
if (size != 1)
return false;
#else
if (!dataBuffer.seek(dataBuffer.pos() + 1))
return false;
#endif
char length[1];
size = dataBuffer.read(length, 1);
if (size != 1)
return false;
int i_length = QByteArray::number(static_cast<int>(length[0]), 16).toInt() + 6;
#if QT_VERSION >= 0x050A00
size = dataBuffer.skip(i_length);
if (size != i_length)
return false;
#else
if (!dataBuffer.seek(dataBuffer.pos() + i_length))
return false;
#endif
p_photoFormat = PhotoFormat::G5EX;
p_fileData = qUncompress(dataBuffer.readAll());
if (p_fileData.isEmpty())
return false;
p_inputMode = 0;
return load();
}
else {
return false;
}
}
else {
return false;
}
}
void RagePhoto::clear()
{
p_photoFormat = PhotoFormat::Undefined;
p_jsonObject = QJsonObject();
p_descriptionString.clear();
p_jsonData.clear();
p_photoData.clear();
p_photoString.clear();
p_titleString.clear();
p_headerSum = 0;
p_isLoaded = false;
}
void RagePhoto::setDescription(const QString &description)
{
p_descriptionString = description;
}
void RagePhoto::setFileData(const QByteArray &data)
{
p_fileData = data;
p_inputMode = 0;
}
void RagePhoto::setFilePath(const QString &filePath)
{
p_filePath = filePath;
p_inputMode = 1;
}
void RagePhoto::setIODevice(QIODevice *ioDevice)
{
p_ioDevice = ioDevice;
p_inputMode = 2;
}
bool RagePhoto::setJsonData(const QByteArray &data)
{
QJsonDocument t_jsonDocument = QJsonDocument::fromJson(data);
if (t_jsonDocument.isNull())
return false;
p_jsonObject = t_jsonDocument.object();
// serializer band-aid
QJsonObject t_jsonObject = p_jsonObject;
t_jsonObject["sign"] = "__gta5view.sign";
t_jsonDocument.setObject(t_jsonObject);
p_jsonData = t_jsonDocument.toJson(QJsonDocument::Compact);
char sign_char[24];
sprintf(sign_char, "%llu", (0x100000000000000ULL | joaatFromSI(p_photoData.constData(), p_photoData.size())));
p_jsonData.replace("\"__gta5view.sign\"", sign_char);
return true;
}
bool RagePhoto::setPhotoBuffer(quint32 size, bool moveOffsets)
{
if (size < static_cast<quint32>(p_photoData.size()))
return false;
p_photoBuffer = size;
if (moveOffsets) {
p_jsonOffset = size + 28;
p_titlOffset = p_jsonOffset + p_jsonBuffer + 8;
p_descOffset = p_titlOffset + p_titlBuffer + 8;
p_endOfFile = p_descOffset + p_descBuffer + 12;
}
return true;
}
bool RagePhoto::setPhotoData(const QByteArray &data)
{
quint32 size = data.size();
if (size > p_photoBuffer)
return false;
p_photoData = data;
// serializer band-aid
setJsonData(p_jsonData);
return true;
}
bool RagePhoto::setPhotoData(const char *data, int size)
{
if (static_cast<quint32>(size) > p_photoBuffer)
return false;
p_photoData = QByteArray(data, size);
// serializer band-aid
setJsonData(p_jsonData);
return true;
}
void RagePhoto::setPhotoFormat(PhotoFormat photoFormat)
{
p_photoFormat = photoFormat;
}
void RagePhoto::setTitle(const QString &title)
{
p_titleString = title;
}
const QByteArray RagePhoto::jsonData(JsonFormat jsonFormat)
{
if (jsonFormat == JsonFormat::Compact) {
return QJsonDocument(p_jsonObject).toJson(QJsonDocument::Compact);
}
else if (jsonFormat == JsonFormat::Indented) {
return QJsonDocument(p_jsonObject).toJson(QJsonDocument::Indented);
}
else {
return p_jsonData;
}
}
const QJsonObject RagePhoto::jsonObject()
{
return p_jsonObject;
}
const QByteArray RagePhoto::photoData()
{
return p_photoData;
}
const QString RagePhoto::description()
{
return p_descriptionString;
}
const QString RagePhoto::photoString()
{
return p_photoString;
}
const QString RagePhoto::title()
{
return p_titleString;
}
quint32 RagePhoto::photoBuffer()
{
return p_photoBuffer;
}
quint32 RagePhoto::photoSize()
{
return p_photoData.size();
}
RagePhoto::PhotoFormat RagePhoto::photoFormat()
{
return p_photoFormat;
}
QByteArray RagePhoto::save(PhotoFormat photoFormat)
{
QByteArray data;
QBuffer dataBuffer(&data);
dataBuffer.open(QIODevice::WriteOnly);
save(&dataBuffer, photoFormat);
return data;
}
void RagePhoto::save(QIODevice *ioDevice, PhotoFormat photoFormat)
{
// serializer band-aid
setJsonData(p_jsonData);
if (photoFormat == PhotoFormat::G5EX) {
char uInt32Buffer[4];
quint32 format = static_cast<quint32>(PhotoFormat::G5EX);
uInt32ToCharLE(format, uInt32Buffer);
ioDevice->write(uInt32Buffer, 4);
format = static_cast<quint32>(ExportFormat::G5E3P);
uInt32ToCharLE(format, uInt32Buffer);
ioDevice->write(uInt32Buffer, 4);
QByteArray compressedData = qCompress(p_photoString.toUtf8(), 9);
quint32 compressedSize = compressedData.size();
uInt32ToCharLE(compressedSize, uInt32Buffer);
ioDevice->write(uInt32Buffer, 4);
ioDevice->write(compressedData);
uInt32ToCharLE(p_headerSum, uInt32Buffer);
ioDevice->write(uInt32Buffer, 4);
uInt32ToCharLE(p_photoBuffer, uInt32Buffer);
ioDevice->write(uInt32Buffer, 4);
compressedData = qCompress(p_photoData, 9);
compressedSize = compressedData.size();
uInt32ToCharLE(compressedSize, uInt32Buffer);
ioDevice->write(uInt32Buffer, 4);
ioDevice->write(compressedData);
uInt32ToCharLE(p_jsonOffset, uInt32Buffer);
ioDevice->write(uInt32Buffer, 4);
uInt32ToCharLE(p_jsonBuffer, uInt32Buffer);
ioDevice->write(uInt32Buffer, 4);
compressedData = qCompress(p_jsonData, 9);
compressedSize = compressedData.size();
uInt32ToCharLE(compressedSize, uInt32Buffer);
ioDevice->write(uInt32Buffer, 4);
ioDevice->write(compressedData);
uInt32ToCharLE(p_titlOffset, uInt32Buffer);
ioDevice->write(uInt32Buffer, 4);
uInt32ToCharLE(p_titlBuffer, uInt32Buffer);
ioDevice->write(uInt32Buffer, 4);
compressedData = qCompress(p_titleString.toUtf8(), 9);
compressedSize = compressedData.size();
uInt32ToCharLE(compressedSize, uInt32Buffer);
ioDevice->write(uInt32Buffer, 4);
ioDevice->write(compressedData);
uInt32ToCharLE(p_descOffset, uInt32Buffer);
ioDevice->write(uInt32Buffer, 4);
uInt32ToCharLE(p_descBuffer, uInt32Buffer);
ioDevice->write(uInt32Buffer, 4);
compressedData = qCompress(p_descriptionString.toUtf8(), 9);
compressedSize = compressedData.size();
uInt32ToCharLE(compressedSize, uInt32Buffer);
ioDevice->write(uInt32Buffer, 4);
ioDevice->write(compressedData);
uInt32ToCharLE(p_endOfFile, uInt32Buffer);
ioDevice->write(uInt32Buffer, 4);
}
else if (photoFormat == PhotoFormat::GTA5) {
char uInt32Buffer[4];
quint32 format = static_cast<quint32>(PhotoFormat::GTA5);
uInt32ToCharLE(format, uInt32Buffer);
ioDevice->write(uInt32Buffer, 4);
QByteArray photoHeader = stringToUtf16LE(p_photoString);
if (photoHeader.startsWith("\xFF\xFE")) {
photoHeader.remove(0, 2);
}
qint64 photoHeaderSize = photoHeader.size();
if (photoHeaderSize > 256) {
photoHeader = photoHeader.left(256);
photoHeaderSize = 256;
}
ioDevice->write(photoHeader);
for (qint64 size = photoHeaderSize; size < 256; size++) {
ioDevice->write("\x00", 1);
}
uInt32ToCharLE(p_headerSum, uInt32Buffer);
ioDevice->write(uInt32Buffer, 4);
uInt32ToCharLE(p_endOfFile, uInt32Buffer);
ioDevice->write(uInt32Buffer, 4);
uInt32ToCharLE(p_jsonOffset, uInt32Buffer);
ioDevice->write(uInt32Buffer, 4);
uInt32ToCharLE(p_titlOffset, uInt32Buffer);
ioDevice->write(uInt32Buffer, 4);
uInt32ToCharLE(p_descOffset, uInt32Buffer);
ioDevice->write(uInt32Buffer, 4);
ioDevice->write("JPEG", 4);
uInt32ToCharLE(p_photoBuffer, uInt32Buffer);
ioDevice->write(uInt32Buffer, 4);
quint32 t_photoSize = p_photoData.size();
uInt32ToCharLE(t_photoSize, uInt32Buffer);
ioDevice->write(uInt32Buffer, 4);
ioDevice->write(p_photoData);
for (qint64 size = t_photoSize; size < p_photoBuffer; size++) {
ioDevice->write("\x00", 1);
}
ioDevice->seek(p_jsonOffset + 264);
ioDevice->write("JSON", 4);
uInt32ToCharLE(p_jsonBuffer, uInt32Buffer);
ioDevice->write(uInt32Buffer, 4);
qint64 dataSize = p_jsonData.size();
ioDevice->write(p_jsonData);
for (qint64 size = dataSize; size < p_jsonBuffer; size++) {
ioDevice->write("\x00", 1);
}
ioDevice->seek(p_titlOffset + 264);
ioDevice->write("TITL", 4);
uInt32ToCharLE(p_titlBuffer, uInt32Buffer);
ioDevice->write(uInt32Buffer, 4);
QByteArray data = p_titleString.toUtf8();
dataSize = data.size();
ioDevice->write(data);
for (qint64 size = dataSize; size < p_titlBuffer; size++) {
ioDevice->write("\x00", 1);
}
ioDevice->seek(p_descOffset + 264);
ioDevice->write("DESC", 4);
uInt32ToCharLE(p_descBuffer, uInt32Buffer);
ioDevice->write(uInt32Buffer, 4);
data = p_descriptionString.toUtf8();
dataSize = data.size();
ioDevice->write(data);
for (qint64 size = dataSize; size < p_descBuffer; size++) {
ioDevice->write("\x00", 1);
}
ioDevice->seek(p_endOfFile + 260);
ioDevice->write("JEND", 4);
}
}
RagePhoto* RagePhoto::loadFile(const QString &filePath)
{
RagePhoto *ragePhoto = new RagePhoto(filePath);
ragePhoto->load();
return ragePhoto;
}
quint32 RagePhoto::charToUInt32BE(char *x)
{
return (static_cast<unsigned char>(x[0]) << 24 |
static_cast<unsigned char>(x[1]) << 16 |
static_cast<unsigned char>(x[2]) << 8 |
static_cast<unsigned char>(x[3]));
}
quint32 RagePhoto::charToUInt32LE(char *x)
{
return (static_cast<unsigned char>(x[3]) << 24 |
static_cast<unsigned char>(x[2]) << 16 |
static_cast<unsigned char>(x[1]) << 8 |
static_cast<unsigned char>(x[0]));
}
void RagePhoto::uInt32ToCharBE(quint32 x, char *y)
{
y[0] = x >> 24;
y[1] = x >> 16;
y[2] = x >> 8;
y[3] = x;
}
void RagePhoto::uInt32ToCharLE(quint32 x, char *y)
{
y[0] = x;
y[1] = x >> 8;
y[2] = x >> 16;
y[3] = x >> 24;
}
const QByteArray RagePhoto::stringToUtf16LE(const QString &string)
{
#if QT_VERSION >= 0x060000
return QStringEncoder(QStringEncoder::Utf16LE)(string);
#else
return QTextCodec::codecForName("UTF-16LE")->fromUnicode(string);
#endif
}
const QString RagePhoto::utf16LEToString(const QByteArray &data)
{
#if QT_VERSION >= 0x060000
return QStringDecoder(QStringDecoder::Utf16LE)(data);
#else
return QTextCodec::codecForName("UTF-16LE")->toUnicode(data);
#endif
}
const QString RagePhoto::utf16LEToString(const char *data, int size)
{
#if QT_VERSION >= 0x060000
return QStringDecoder(QStringDecoder::Utf16LE)(QByteArray::fromRawData(data, size));
#else
return QTextCodec::codecForName("UTF-16LE")->toUnicode(data, size);
#endif
}

110
RagePhoto.h Normal file
View File

@ -0,0 +1,110 @@
/*****************************************************************************
* 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 RAGEPHOTO_H
#define RAGEPHOTO_H
#include <QJsonObject>
#include <QIODevice>
#include <QObject>
class RagePhoto : public QObject
{
Q_OBJECT
public:
enum class JsonFormat : quint8 {
Original = 0,
Compact = 1,
Indented = 2,
};
enum class ExportFormat : quint32 {
G5E1P = 0x454C0010U,
G5E2P = 0x01000032U,
G5E2S = 0x02000032U,
G5E3P = 0x01000033U,
G5E3S = 0x02000033U,
Undefined = 0,
};
enum class PhotoFormat : quint32 {
G5EX = 0x45354700U,
GTA5 = 0x01000000U,
RDR2 = 0x04000000U,
Undefined = 0,
};
explicit RagePhoto();
explicit RagePhoto(const QByteArray &data);
explicit RagePhoto(const QString &filePath);
explicit RagePhoto(QIODevice *ioDevice);
bool isLoaded();
bool load();
void clear();
void setDescription(const QString &description);
void setFileData(const QByteArray &data);
void setFilePath(const QString &filePath);
void setIODevice(QIODevice *ioDevice);
bool setJsonData(const QByteArray &data);
bool setPhotoBuffer(quint32 size, bool moveOffsets = true);
bool setPhotoData(const QByteArray &data);
bool setPhotoData(const char *data, int size);
void setPhotoFormat(PhotoFormat photoFormat);
void setTitle(const QString &title);
const QJsonObject jsonObject();
const QByteArray jsonData(JsonFormat jsonFormat = JsonFormat::Original);
const QByteArray photoData();
const QString description();
const QString photoString();
const QString title();
quint32 photoBuffer();
quint32 photoSize();
PhotoFormat photoFormat();
QByteArray save(PhotoFormat photoFormat);
void save(QIODevice *ioDevice, PhotoFormat photoFormat);
static RagePhoto* loadFile(const QString &filePath);
private:
inline quint32 charToUInt32BE(char *x);
inline quint32 charToUInt32LE(char *x);
inline void uInt32ToCharBE(quint32 x, char *y);
inline void uInt32ToCharLE(quint32 x, char *y);
inline const QByteArray stringToUtf16LE(const QString &string);
inline const QString utf16LEToString(const QByteArray &data);
inline const QString utf16LEToString(const char *data, int size);
PhotoFormat p_photoFormat;
QJsonObject p_jsonObject;
QByteArray p_fileData;
QByteArray p_jsonData;
QByteArray p_photoData;
QIODevice *p_ioDevice;
QString p_descriptionString;
QString p_filePath;
QString p_photoString;
QString p_titleString;
quint32 p_descBuffer;
quint32 p_descOffset;
quint32 p_endOfFile;
quint32 p_headerSum;
quint32 p_jsonBuffer;
quint32 p_jsonOffset;
quint32 p_photoBuffer;
quint32 p_titlBuffer;
quint32 p_titlOffset;
bool p_isLoaded;
int p_inputMode;
};
#endif // RAGEPHOTO_H

View File

@ -20,7 +20,6 @@
#include "StringParser.h" #include "StringParser.h"
#include "SavegameData.h" #include "SavegameData.h"
#include <QStringBuilder> #include <QStringBuilder>
#include <QTextCodec>
#include <QByteArray> #include <QByteArray>
#include <QDebug> #include <QDebug>
#include <QFile> #include <QFile>

View File

@ -28,7 +28,11 @@ SavegameDialog::SavegameDialog(QWidget *parent) :
ui(new Ui::SavegameDialog) ui(new Ui::SavegameDialog)
{ {
// Set Window Flags // Set Window Flags
#if QT_VERSION >= 0x050900
setWindowFlag(Qt::WindowContextHelpButtonHint, false);
#else
setWindowFlags(windowFlags()^Qt::WindowContextHelpButtonHint); setWindowFlags(windowFlags()^Qt::WindowContextHelpButtonHint);
#endif
// Setup User Interface // Setup User Interface
ui->setupUi(this); ui->setupUi(this);

View File

@ -7,7 +7,7 @@
<x>0</x> <x>0</x>
<y>0</y> <y>0</y>
<width>400</width> <width>400</width>
<height>105</height> <height>112</height>
</rect> </rect>
</property> </property>
<property name="windowTitle"> <property name="windowTitle">
@ -20,7 +20,7 @@
<item> <item>
<widget class="QLabel" name="labSavegameText"> <widget class="QLabel" name="labSavegameText">
<property name="text"> <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> <string>&lt;span style=&quot;font-weight:600&quot;&gt;Savegame&lt;/span&gt;&lt;br&gt;&lt;br&gt;%1</string>
</property> </property>
<property name="alignment"> <property name="alignment">
<set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop</set> <set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop</set>

View File

@ -1,6 +1,6 @@
/***************************************************************************** /*****************************************************************************
* gta5view Grand Theft Auto V Profile Viewer * gta5view Grand Theft Auto V Profile Viewer
* Copyright (C) 2016-2018 Syping * Copyright (C) 2016-2021 Syping
* *
* This program is free software: you can redistribute it and/or modify * This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by * it under the terms of the GNU General Public License as published by
@ -25,6 +25,7 @@
#include "SavegameCopy.h" #include "SavegameCopy.h"
#include "AppEnv.h" #include "AppEnv.h"
#include "config.h" #include "config.h"
#include <QStringBuilder>
#include <QFileDialog> #include <QFileDialog>
#include <QMessageBox> #include <QMessageBox>
#include <QSettings> #include <QSettings>
@ -58,9 +59,8 @@ SavegameWidget::SavegameWidget(QWidget *parent) :
qreal screenRatio = AppEnv::screenRatio(); qreal screenRatio = AppEnv::screenRatio();
ui->labSavegamePic->setFixedSize(48 * screenRatio, 27 * screenRatio); ui->labSavegamePic->setFixedSize(48 * screenRatio, 27 * screenRatio);
QPixmap savegamePixmap(":/img/savegame.png"); ui->labSavegamePic->setScaledContents(true);
if (screenRatio != 1) savegamePixmap = savegamePixmap.scaledToHeight(ui->labSavegamePic->height(), Qt::SmoothTransformation); ui->labSavegamePic->setPixmap(QPixmap(AppEnv::getImagesFolder() % "/savegame.svgz"));
ui->labSavegamePic->setPixmap(savegamePixmap);
QString exportSavegameStr = tr("Export Savegame..."); QString exportSavegameStr = tr("Export Savegame...");
Q_UNUSED(exportSavegameStr) Q_UNUSED(exportSavegameStr)
@ -153,7 +153,11 @@ void SavegameWidget::on_cmdDelete_clicked()
QJsonObject jsonObject; QJsonObject jsonObject;
jsonObject["Type"] = "DeleteSuccess"; jsonObject["Type"] = "DeleteSuccess";
jsonObject["ExtraFlags"] = "Savegame"; jsonObject["ExtraFlags"] = "Savegame";
#if QT_VERSION >= 0x060000
jsonObject["DeletedTime"] = QString::number(QDateTime::currentDateTimeUtc().toSecsSinceEpoch());
#else
jsonObject["DeletedTime"] = QString::number(QDateTime::currentDateTimeUtc().toTime_t()); jsonObject["DeletedTime"] = QString::number(QDateTime::currentDateTimeUtc().toTime_t());
#endif
jsonDocument.setObject(jsonObject); jsonDocument.setObject(jsonObject);
Telemetry->push(TelemetryCategory::PersonalData, jsonDocument); Telemetry->push(TelemetryCategory::PersonalData, jsonDocument);
} }
@ -172,7 +176,11 @@ void SavegameWidget::on_cmdDelete_clicked()
QJsonObject jsonObject; QJsonObject jsonObject;
jsonObject["Type"] = "DeleteSuccess"; jsonObject["Type"] = "DeleteSuccess";
jsonObject["ExtraFlags"] = "Savegame"; jsonObject["ExtraFlags"] = "Savegame";
#if QT_VERSION >= 0x060000
jsonObject["DeletedTime"] = QString::number(QDateTime::currentDateTimeUtc().toSecsSinceEpoch());
#else
jsonObject["DeletedTime"] = QString::number(QDateTime::currentDateTimeUtc().toTime_t()); jsonObject["DeletedTime"] = QString::number(QDateTime::currentDateTimeUtc().toTime_t());
#endif
jsonDocument.setObject(jsonObject); jsonDocument.setObject(jsonObject);
Telemetry->push(TelemetryCategory::PersonalData, jsonDocument); Telemetry->push(TelemetryCategory::PersonalData, jsonDocument);
} }
@ -218,7 +226,8 @@ void SavegameWidget::mouseReleaseEvent(QMouseEvent *ev)
} }
else else
{ {
if (getContentMode() == 0 && rect().contains(ev->pos()) && ev->button() == Qt::LeftButton) const int contentMode = getContentMode();
if ((contentMode == 0 || contentMode == 10 || contentMode == 20) && rect().contains(ev->pos()) && ev->button() == Qt::LeftButton)
{ {
if (ev->modifiers().testFlag(Qt::ShiftModifier)) if (ev->modifiers().testFlag(Qt::ShiftModifier))
{ {
@ -229,7 +238,7 @@ void SavegameWidget::mouseReleaseEvent(QMouseEvent *ev)
on_cmdView_clicked(); on_cmdView_clicked();
} }
} }
else if (!ui->cbSelected->isVisible() && getContentMode() == 1 && ev->button() == Qt::LeftButton && ev->modifiers().testFlag(Qt::ShiftModifier)) else if (!ui->cbSelected->isVisible() && (contentMode == 1 || contentMode == 11 || contentMode == 21) && ev->button() == Qt::LeftButton && ev->modifiers().testFlag(Qt::ShiftModifier))
{ {
ui->cbSelected->setChecked(!ui->cbSelected->isChecked()); ui->cbSelected->setChecked(!ui->cbSelected->isChecked());
} }
@ -240,7 +249,8 @@ void SavegameWidget::mouseDoubleClickEvent(QMouseEvent *ev)
{ {
ProfileWidget::mouseDoubleClickEvent(ev); ProfileWidget::mouseDoubleClickEvent(ev);
if (!ui->cbSelected->isVisible() && getContentMode() == 1 && ev->button() == Qt::LeftButton) const int contentMode = getContentMode();
if (!ui->cbSelected->isVisible() && (contentMode == 1 || contentMode == 11 || contentMode == 21) && ev->button() == Qt::LeftButton)
{ {
on_cmdView_clicked(); on_cmdView_clicked();
} }

View File

@ -1,6 +1,6 @@
/***************************************************************************** /*****************************************************************************
* gta5view Grand Theft Auto V Profile Viewer * gta5view Grand Theft Auto V Profile Viewer
* Copyright (C) 2016-2018 Syping * Copyright (C) 2016-2021 Syping
* *
* This program is free software: you can redistribute it and/or modify * This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by * it under the terms of the GNU General Public License as published by
@ -21,9 +21,9 @@
#include "SnapmaticPicture.h" #include "SnapmaticPicture.h"
#include "PlayerListDialog.h" #include "PlayerListDialog.h"
#include "StringParser.h" #include "StringParser.h"
#include "wrapper.h"
#include "AppEnv.h" #include "AppEnv.h"
#include "config.h" #include "config.h"
#include <QStringListIterator>
#include <QStringBuilder> #include <QStringBuilder>
#include <QTextDocument> #include <QTextDocument>
#include <QInputDialog> #include <QInputDialog>
@ -42,41 +42,38 @@ SnapmaticEditor::SnapmaticEditor(CrewDatabase *crewDB, ProfileDatabase *profileD
ui(new Ui::SnapmaticEditor) ui(new Ui::SnapmaticEditor)
{ {
// Set Window Flags // Set Window Flags
#if QT_VERSION >= 0x050900
setWindowFlag(Qt::WindowContextHelpButtonHint, false);
#else
setWindowFlags(windowFlags()^Qt::WindowContextHelpButtonHint); setWindowFlags(windowFlags()^Qt::WindowContextHelpButtonHint);
#endif
ui->setupUi(this); ui->setupUi(this);
ui->cmdCancel->setDefault(true); ui->cmdCancel->setDefault(true);
ui->cmdCancel->setFocus(); ui->cmdCancel->setFocus();
// Set Icon for Apply Button // Set Icon for Apply Button
if (QIcon::hasThemeIcon("dialog-ok-apply")) if (QIcon::hasThemeIcon("dialog-ok-apply")) {
{
ui->cmdApply->setIcon(QIcon::fromTheme("dialog-ok-apply")); ui->cmdApply->setIcon(QIcon::fromTheme("dialog-ok-apply"));
} }
else if (QIcon::hasThemeIcon("dialog-apply")) else if (QIcon::hasThemeIcon("dialog-apply")) {
{
ui->cmdApply->setIcon(QIcon::fromTheme("dialog-apply")); ui->cmdApply->setIcon(QIcon::fromTheme("dialog-apply"));
} }
else if (QIcon::hasThemeIcon("gtk-apply")) else if (QIcon::hasThemeIcon("gtk-apply")) {
{
ui->cmdApply->setIcon(QIcon::fromTheme("gtk-apply")); ui->cmdApply->setIcon(QIcon::fromTheme("gtk-apply"));
} }
else if (QIcon::hasThemeIcon("dialog-ok")) else if (QIcon::hasThemeIcon("dialog-ok")) {
{
ui->cmdApply->setIcon(QIcon::fromTheme("dialog-ok")); ui->cmdApply->setIcon(QIcon::fromTheme("dialog-ok"));
} }
else if (QIcon::hasThemeIcon("gtk-ok")) else if (QIcon::hasThemeIcon("gtk-ok")) {
{
ui->cmdApply->setIcon(QIcon::fromTheme("dialog-ok")); ui->cmdApply->setIcon(QIcon::fromTheme("dialog-ok"));
} }
// Set Icon for Cancel Button // Set Icon for Cancel Button
if (QIcon::hasThemeIcon("dialog-cancel")) if (QIcon::hasThemeIcon("dialog-cancel")) {
{
ui->cmdCancel->setIcon(QIcon::fromTheme("dialog-cancel")); ui->cmdCancel->setIcon(QIcon::fromTheme("dialog-cancel"));
} }
else if (QIcon::hasThemeIcon("gtk-cancel")) else if (QIcon::hasThemeIcon("gtk-cancel")) {
{
ui->cmdCancel->setIcon(QIcon::fromTheme("gtk-cancel")); ui->cmdCancel->setIcon(QIcon::fromTheme("gtk-cancel"));
} }
@ -97,27 +94,18 @@ SnapmaticEditor::~SnapmaticEditor()
void SnapmaticEditor::selfie_toggled(bool checked) void SnapmaticEditor::selfie_toggled(bool checked)
{ {
if (checked) isSelfie = checked;
{
isSelfie = true;
}
else
{
isSelfie = false;
}
} }
void SnapmaticEditor::mugshot_toggled(bool checked) void SnapmaticEditor::mugshot_toggled(bool checked)
{ {
if (checked) if (checked) {
{
isMugshot = true; isMugshot = true;
ui->cbDirector->setEnabled(false); ui->cbDirector->setEnabled(false);
ui->cbDirector->setChecked(false); ui->cbDirector->setChecked(false);
} }
else else {
{
isMugshot = false; isMugshot = false;
ui->cbDirector->setEnabled(true); ui->cbDirector->setEnabled(true);
} }
@ -125,14 +113,12 @@ void SnapmaticEditor::mugshot_toggled(bool checked)
void SnapmaticEditor::editor_toggled(bool checked) void SnapmaticEditor::editor_toggled(bool checked)
{ {
if (checked) if (checked) {
{
isEditor = true; isEditor = true;
ui->cbDirector->setEnabled(false); ui->cbDirector->setEnabled(false);
ui->cbDirector->setChecked(false); ui->cbDirector->setChecked(false);
} }
else else {
{
isEditor = false; isEditor = false;
ui->cbDirector->setEnabled(true); ui->cbDirector->setEnabled(true);
} }
@ -140,8 +126,7 @@ void SnapmaticEditor::editor_toggled(bool checked)
void SnapmaticEditor::on_rbSelfie_toggled(bool checked) void SnapmaticEditor::on_rbSelfie_toggled(bool checked)
{ {
if (checked) if (checked) {
{
mugshot_toggled(false); mugshot_toggled(false);
editor_toggled(false); editor_toggled(false);
selfie_toggled(true); selfie_toggled(true);
@ -150,8 +135,7 @@ void SnapmaticEditor::on_rbSelfie_toggled(bool checked)
void SnapmaticEditor::on_rbMugshot_toggled(bool checked) void SnapmaticEditor::on_rbMugshot_toggled(bool checked)
{ {
if (checked) if (checked) {
{
selfie_toggled(false); selfie_toggled(false);
editor_toggled(false); editor_toggled(false);
mugshot_toggled(true); mugshot_toggled(true);
@ -160,8 +144,7 @@ void SnapmaticEditor::on_rbMugshot_toggled(bool checked)
void SnapmaticEditor::on_rbEditor_toggled(bool checked) void SnapmaticEditor::on_rbEditor_toggled(bool checked)
{ {
if (checked) if (checked) {
{
selfie_toggled(false); selfie_toggled(false);
mugshot_toggled(false); mugshot_toggled(false);
editor_toggled(true); editor_toggled(true);
@ -170,8 +153,7 @@ void SnapmaticEditor::on_rbEditor_toggled(bool checked)
void SnapmaticEditor::on_rbCustom_toggled(bool checked) void SnapmaticEditor::on_rbCustom_toggled(bool checked)
{ {
if (checked) if (checked) {
{
selfie_toggled(false); selfie_toggled(false);
mugshot_toggled(false); mugshot_toggled(false);
editor_toggled(false); editor_toggled(false);
@ -190,20 +172,16 @@ void SnapmaticEditor::setSnapmaticPicture(SnapmaticPicture *picture)
playersList = snapmaticProperties.playersList; playersList = snapmaticProperties.playersList;
ui->cbDirector->setChecked(snapmaticProperties.isFromDirector); ui->cbDirector->setChecked(snapmaticProperties.isFromDirector);
ui->cbMeme->setChecked(snapmaticProperties.isMeme); ui->cbMeme->setChecked(snapmaticProperties.isMeme);
if (isSelfie) if (isSelfie) {
{
ui->rbSelfie->setChecked(true); ui->rbSelfie->setChecked(true);
} }
else if (isMugshot) else if (isMugshot) {
{
ui->rbMugshot->setChecked(true); ui->rbMugshot->setChecked(true);
} }
else if (isEditor) else if (isEditor) {
{
ui->rbEditor->setChecked(true); ui->rbEditor->setChecked(true);
} }
else else {
{
ui->rbCustom->setChecked(true); ui->rbCustom->setChecked(true);
} }
setSnapmaticCrew(returnCrewName(crewID)); setSnapmaticCrew(returnCrewName(crewID));
@ -213,8 +191,7 @@ void SnapmaticEditor::setSnapmaticPicture(SnapmaticPicture *picture)
void SnapmaticEditor::insertPlayerNames(QStringList *players) void SnapmaticEditor::insertPlayerNames(QStringList *players)
{ {
for (int i = 0; i < players->size(); ++i) for (int i = 0; i < players->size(); ++i) {
{
players->replace(i, profileDB->getPlayerName(players->at(i))); players->replace(i, profileDB->getPlayerName(players->at(i)));
} }
} }
@ -230,54 +207,48 @@ void SnapmaticEditor::setSnapmaticPlayers(const QStringList &players)
{ {
QString editStr = QString("<a href=\"g5e://editplayers\" style=\"text-decoration: none;\">%1</a>").arg(tr("Edit")); QString editStr = QString("<a href=\"g5e://editplayers\" style=\"text-decoration: none;\">%1</a>").arg(tr("Edit"));
QString playersStr; QString playersStr;
if (players.length() != 1) if (players.length() != 1) {
{
playersStr = tr("Players: %1 (%2)", "Multiple Player are inserted here"); playersStr = tr("Players: %1 (%2)", "Multiple Player are inserted here");
} }
else else {
{
playersStr = tr("Player: %1 (%2)", "One Player is inserted here"); playersStr = tr("Player: %1 (%2)", "One Player is inserted here");
} }
if (players.length() != 0) if (players.length() != 0) {
{
ui->labPlayers->setText(playersStr.arg(players.join(", "), editStr)); ui->labPlayers->setText(playersStr.arg(players.join(", "), editStr));
} }
else else {
{
ui->labPlayers->setText(playersStr.arg(QApplication::translate("PictureDialog", "No Players"), editStr)); ui->labPlayers->setText(playersStr.arg(QApplication::translate("PictureDialog", "No Players"), editStr));
} }
#ifndef Q_OS_ANDROID #ifndef Q_OS_ANDROID
ui->gbValues->resize(ui->gbValues->width(), ui->gbValues->heightForWidth(ui->gbValues->width())); ui->gbValues->resize(ui->gbValues->width(), ui->gbValues->heightForWidth(ui->gbValues->width()));
ui->frameWidget->resize(ui->gbValues->width(), ui->frameWidget->heightForWidth(ui->frameWidget->width())); ui->frameWidget->resize(ui->gbValues->width(), ui->frameWidget->heightForWidth(ui->frameWidget->width()));
if (heightForWidth(width()) > height()) { resize(width(), heightForWidth(width())); } if (heightForWidth(width()) > height())
resize(width(), heightForWidth(width()));
#endif #endif
} }
void SnapmaticEditor::setSnapmaticTitle(const QString &title) void SnapmaticEditor::setSnapmaticTitle(const QString &title)
{ {
if (title.length() > 39) if (title.length() > 39) {
{
snapmaticTitle = title.left(39); snapmaticTitle = title.left(39);
} }
else else {
{
snapmaticTitle = title; snapmaticTitle = title;
} }
QString editStr = QString("<a href=\"g5e://edittitle\" style=\"text-decoration: none;\">%1</a>").arg(tr("Edit")); 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); QString titleStr = tr("Title: %1 (%2)").arg(StringParser::escapeString(snapmaticTitle), editStr);
ui->labTitle->setText(titleStr); ui->labTitle->setText(titleStr);
if (SnapmaticPicture::verifyTitle(snapmaticTitle)) 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")))); ui->labAppropriate->setText(tr("Appropriate: %1").arg(QString("<span style=\"color: green\">%1</span>").arg(tr("Yes", "Yes, should work fine"))));
} }
else else {
{
ui->labAppropriate->setText(tr("Appropriate: %1").arg(QString("<span style=\"color: red\">%1</span>").arg(tr("No", "No, could lead to issues")))); 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 #ifndef Q_OS_ANDROID
ui->gbValues->resize(ui->gbValues->width(), ui->gbValues->heightForWidth(ui->gbValues->width())); ui->gbValues->resize(ui->gbValues->width(), ui->gbValues->heightForWidth(ui->gbValues->width()));
ui->frameWidget->resize(ui->gbValues->width(), ui->frameWidget->heightForWidth(ui->frameWidget->width())); ui->frameWidget->resize(ui->gbValues->width(), ui->frameWidget->heightForWidth(ui->frameWidget->width()));
if (heightForWidth(width()) > height()) { resize(width(), heightForWidth(width())); } if (heightForWidth(width()) > height())
resize(width(), heightForWidth(width()));
#endif #endif
} }
@ -289,7 +260,8 @@ void SnapmaticEditor::setSnapmaticCrew(const QString &crew)
#ifndef Q_OS_ANDROID #ifndef Q_OS_ANDROID
ui->gbValues->resize(ui->gbValues->width(), ui->gbValues->heightForWidth(ui->gbValues->width())); ui->gbValues->resize(ui->gbValues->width(), ui->gbValues->heightForWidth(ui->gbValues->width()));
ui->frameWidget->resize(ui->gbValues->width(), ui->frameWidget->heightForWidth(ui->frameWidget->width())); ui->frameWidget->resize(ui->gbValues->width(), ui->frameWidget->heightForWidth(ui->frameWidget->width()));
if (heightForWidth(width()) > height()) { resize(width(), heightForWidth(width())); } if (heightForWidth(width()) > height())
resize(width(), heightForWidth(width()));
#endif #endif
} }
@ -305,8 +277,7 @@ void SnapmaticEditor::on_cmdCancel_clicked()
void SnapmaticEditor::on_cmdApply_clicked() void SnapmaticEditor::on_cmdApply_clicked()
{ {
if (ui->cbQualify->isChecked()) if (ui->cbQualify->isChecked()) {
{
qualifyAvatar(); qualifyAvatar();
} }
snapmaticProperties.crewID = crewID; snapmaticProperties.crewID = crewID;
@ -316,27 +287,23 @@ void SnapmaticEditor::on_cmdApply_clicked()
snapmaticProperties.isFromDirector = ui->cbDirector->isChecked(); snapmaticProperties.isFromDirector = ui->cbDirector->isChecked();
snapmaticProperties.isMeme = ui->cbMeme->isChecked(); snapmaticProperties.isMeme = ui->cbMeme->isChecked();
snapmaticProperties.playersList = playersList; snapmaticProperties.playersList = playersList;
if (smpic) if (smpic) {
{
QString currentFilePath = smpic->getPictureFilePath(); QString currentFilePath = smpic->getPictureFilePath();
QString originalFilePath = smpic->getOriginalPictureFilePath(); QString originalFilePath = smpic->getOriginalPictureFilePath();
QString backupFileName = originalFilePath % ".bak"; QString backupFileName = originalFilePath % ".bak";
if (!QFile::exists(backupFileName)) if (!QFile::exists(backupFileName)) {
{
QFile::copy(currentFilePath, backupFileName); QFile::copy(currentFilePath, backupFileName);
} }
SnapmaticProperties fallbackProperties = smpic->getSnapmaticProperties(); SnapmaticProperties fallbackProperties = smpic->getSnapmaticProperties();
QString fallbackTitle = smpic->getPictureTitle(); QString fallbackTitle = smpic->getPictureTitle();
smpic->setSnapmaticProperties(snapmaticProperties); smpic->setSnapmaticProperties(snapmaticProperties);
smpic->setPictureTitle(snapmaticTitle); smpic->setPictureTitle(snapmaticTitle);
if (!smpic->exportPicture(currentFilePath)) if (!smpic->exportPicture(currentFilePath)) {
{
QMessageBox::warning(this, tr("Snapmatic Properties"), tr("Patching of Snapmatic Properties failed because of I/O Error")); QMessageBox::warning(this, tr("Snapmatic Properties"), tr("Patching of Snapmatic Properties failed because of I/O Error"));
smpic->setSnapmaticProperties(fallbackProperties); smpic->setSnapmaticProperties(fallbackProperties);
smpic->setPictureTitle(fallbackTitle); smpic->setPictureTitle(fallbackTitle);
} }
else else {
{
smpic->updateStrings(); smpic->updateStrings();
smpic->emitUpdate(); smpic->emitUpdate();
#ifdef GTA5SYNC_TELEMETRY #ifdef GTA5SYNC_TELEMETRY
@ -344,13 +311,16 @@ void SnapmaticEditor::on_cmdApply_clicked()
telemetrySettings.beginGroup("Telemetry"); telemetrySettings.beginGroup("Telemetry");
bool pushUsageData = telemetrySettings.value("PushUsageData", false).toBool(); bool pushUsageData = telemetrySettings.value("PushUsageData", false).toBool();
telemetrySettings.endGroup(); telemetrySettings.endGroup();
if (pushUsageData && Telemetry->canPush()) if (pushUsageData && Telemetry->canPush()) {
{
QJsonDocument jsonDocument; QJsonDocument jsonDocument;
QJsonObject jsonObject; QJsonObject jsonObject;
jsonObject["Type"] = "PropertyEdited"; jsonObject["Type"] = "PropertyEdited";
jsonObject["EditedSize"] = QString::number(smpic->getContentMaxLength()); jsonObject["EditedSize"] = QString::number(smpic->getContentMaxLength());
#if QT_VERSION >= 0x060000
jsonObject["EditedTime"] = QString::number(QDateTime::currentDateTimeUtc().toSecsSinceEpoch());
#else
jsonObject["EditedTime"] = QString::number(QDateTime::currentDateTimeUtc().toTime_t()); jsonObject["EditedTime"] = QString::number(QDateTime::currentDateTimeUtc().toTime_t());
#endif
jsonDocument.setObject(jsonObject); jsonDocument.setObject(jsonObject);
Telemetry->push(TelemetryCategory::PersonalData, jsonDocument); Telemetry->push(TelemetryCategory::PersonalData, jsonDocument);
} }
@ -370,8 +340,7 @@ void SnapmaticEditor::qualifyAvatar()
void SnapmaticEditor::on_cbQualify_toggled(bool checked) void SnapmaticEditor::on_cbQualify_toggled(bool checked)
{ {
if (checked) if (checked) {
{
ui->cbMeme->setEnabled(false); ui->cbMeme->setEnabled(false);
ui->cbDirector->setEnabled(false); ui->cbDirector->setEnabled(false);
ui->rbCustom->setEnabled(false); ui->rbCustom->setEnabled(false);
@ -379,15 +348,13 @@ void SnapmaticEditor::on_cbQualify_toggled(bool checked)
ui->rbEditor->setEnabled(false); ui->rbEditor->setEnabled(false);
ui->rbMugshot->setEnabled(false); ui->rbMugshot->setEnabled(false);
} }
else else {
{
ui->cbMeme->setEnabled(true); ui->cbMeme->setEnabled(true);
ui->rbCustom->setEnabled(true); ui->rbCustom->setEnabled(true);
ui->rbSelfie->setEnabled(true); ui->rbSelfie->setEnabled(true);
ui->rbEditor->setEnabled(true); ui->rbEditor->setEnabled(true);
ui->rbMugshot->setEnabled(true); ui->rbMugshot->setEnabled(true);
if (ui->rbSelfie->isChecked() || ui->rbCustom->isChecked()) if (ui->rbSelfie->isChecked() || ui->rbCustom->isChecked()) {
{
ui->cbDirector->setEnabled(true); ui->cbDirector->setEnabled(true);
} }
} }
@ -395,8 +362,7 @@ void SnapmaticEditor::on_cbQualify_toggled(bool checked)
void SnapmaticEditor::on_labPlayers_linkActivated(const QString &link) void SnapmaticEditor::on_labPlayers_linkActivated(const QString &link)
{ {
if (link == "g5e://editplayers") if (link == "g5e://editplayers") {
{
PlayerListDialog *playerListDialog = new PlayerListDialog(playersList, profileDB, this); PlayerListDialog *playerListDialog = new PlayerListDialog(playersList, profileDB, this);
connect(playerListDialog, SIGNAL(playerListUpdated(QStringList)), this, SLOT(playerListUpdated(QStringList))); connect(playerListDialog, SIGNAL(playerListUpdated(QStringList)), this, SLOT(playerListUpdated(QStringList)));
playerListDialog->setModal(true); playerListDialog->setModal(true);
@ -408,12 +374,10 @@ void SnapmaticEditor::on_labPlayers_linkActivated(const QString &link)
void SnapmaticEditor::on_labTitle_linkActivated(const QString &link) void SnapmaticEditor::on_labTitle_linkActivated(const QString &link)
{ {
if (link == "g5e://edittitle") if (link == "g5e://edittitle") {
{
bool ok; bool ok;
QString newTitle = QInputDialog::getText(this, tr("Snapmatic Title"), tr("New Snapmatic title:"), QLineEdit::Normal, snapmaticTitle, &ok, windowFlags()); QString newTitle = QInputDialog::getText(this, tr("Snapmatic Title"), tr("New Snapmatic title:"), QLineEdit::Normal, snapmaticTitle, &ok, windowFlags());
if (ok && !newTitle.isEmpty()) if (ok && !newTitle.isEmpty()) {
{
setSnapmaticTitle(newTitle); setSnapmaticTitle(newTitle);
} }
} }
@ -421,39 +385,33 @@ void SnapmaticEditor::on_labTitle_linkActivated(const QString &link)
void SnapmaticEditor::on_labCrew_linkActivated(const QString &link) void SnapmaticEditor::on_labCrew_linkActivated(const QString &link)
{ {
if (link == "g5e://editcrew") if (link == "g5e://editcrew") {
{
bool ok; bool ok;
int indexNum = 0; int indexNum = 0;
QStringList itemList; QStringList itemList;
QStringList crewList = crewDB->getCrews(); QStringList crewList = crewDB->getCrews();
if (!crewList.contains(QLatin1String("0"))) if (!crewList.contains(QLatin1String("0"))) {
{
crewList += QLatin1String("0"); crewList += QLatin1String("0");
} }
crewList.sort(); crewList.sort();
for (QString crew : crewList) for (const QString &crew : crewList) {
{
itemList += QString("%1 (%2)").arg(crew, returnCrewName(crew.toInt())); itemList += QString("%1 (%2)").arg(crew, returnCrewName(crew.toInt()));
} }
if (crewList.contains(QString::number(crewID))) if (crewList.contains(QString::number(crewID))) {
{ indexNum = crewList.indexOf(QString::number(crewID));
indexNum = crewList.indexOf(QRegExp(QString::number(crewID)));
} }
QString newCrew = QInputDialog::getItem(this, tr("Snapmatic Crew"), tr("New Snapmatic crew:"), itemList, indexNum, true, &ok, windowFlags()); QString newCrew = QInputDialog::getItem(this, tr("Snapmatic Crew"), tr("New Snapmatic crew:"), itemList, indexNum, true, &ok, windowFlags());
if (ok && !newCrew.isEmpty()) if (ok && !newCrew.isEmpty()) {
{ if (newCrew.contains(" "))
if (newCrew.contains(" ")) newCrew = newCrew.split(" ").at(0); newCrew = newCrew.split(" ").at(0);
if (newCrew.length() > 10) return; if (newCrew.length() > 10)
for (QChar crewChar : newCrew) return;
{ for (const QChar &crewChar : qAsConst(newCrew)) {
if (!crewChar.isNumber()) if (!crewChar.isNumber()) {
{
return; return;
} }
} }
if (!crewList.contains(newCrew)) if (!crewList.contains(newCrew)) {
{
crewDB->addCrew(crewID); crewDB->addCrew(crewID);
} }
crewID = newCrew.toInt(); crewID = newCrew.toInt();

File diff suppressed because it is too large Load Diff

View File

@ -1,6 +1,6 @@
/***************************************************************************** /*****************************************************************************
* gta5spv Grand Theft Auto Snapmatic Picture Viewer * gta5spv Grand Theft Auto Snapmatic Picture Viewer
* Copyright (C) 2016-2018 Syping * Copyright (C) 2016-2020 Syping
* *
* This program is free software: you can redistribute it and/or modify * This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by * it under the terms of the GNU General Public License as published by
@ -19,6 +19,7 @@
#ifndef SNAPMATICPICTURE_H #ifndef SNAPMATICPICTURE_H
#define SNAPMATICPICTURE_H #define SNAPMATICPICTURE_H
#include "RagePhoto.h"
#include <QStringList> #include <QStringList>
#include <QDateTime> #include <QDateTime>
#include <QObject> #include <QObject>
@ -34,6 +35,7 @@ struct SnapmaticProperties {
double x; double x;
double y; double y;
double z; double z;
bool isCayoPerico;
}; };
int uid; int uid;
int crewID; int crewID;
@ -57,17 +59,15 @@ public:
~SnapmaticPicture(); ~SnapmaticPicture();
void reset(); void reset();
bool preloadFile(); bool preloadFile();
bool readingPictureFromFile(const QString &fileName, bool writeEnabled = true, bool cacheEnabled = false, bool fastLoad = true, bool lowRamMode = false); bool readingPictureFromFile(const QString &fileName, bool cacheEnabled = false);
bool readingPicture(bool writeEnabled = true, bool cacheEnabled = false, bool fastLoad = true, bool lowRamMode = false); bool readingPicture(bool cacheEnabled = false);
bool isPicOk(); // Please use isPictureOk instead bool isPicOk(); // Please use isPictureOk instead
void clearCache(); void clearCache();
QImage getImage(bool fastLoad = false); QImage getImage();
QByteArray getPictureStream(); QByteArray getPictureStream();
QString getLastStep(bool readable = true); QString getLastStep(bool readable = true);
QString getPictureStr(); QString getPictureStr();
QString getPictureHead();
QString getPictureTitl(); QString getPictureTitl();
QString getPictureDesc();
QString getPictureSortStr(); QString getPictureSortStr();
QString getPictureFileName(); QString getPictureFileName();
QString getPictureFilePath(); QString getPictureFilePath();
@ -75,7 +75,7 @@ public:
QString getOriginalPictureFileName(); QString getOriginalPictureFileName();
QString getOriginalPictureFilePath(); QString getOriginalPictureFilePath();
int getContentMaxLength(); int getContentMaxLength();
bool setImage(const QImage &picture); bool setImage(const QImage &picture, bool eXtendMode = false);
bool setPictureTitl(const QString &newTitle); // Please use setPictureTitle instead bool setPictureTitl(const QString &newTitle); // Please use setPictureTitle instead
bool setPictureStream(const QByteArray &streamArray); bool setPictureStream(const QByteArray &streamArray);
void updateStrings(); void updateStrings();
@ -106,7 +106,6 @@ public:
QString getPictureJson() { return getJsonStr(); } QString getPictureJson() { return getJsonStr(); }
QString getPictureTitle() { return getPictureTitl(); } QString getPictureTitle() { return getPictureTitl(); }
QString getPictureString() { return getPictureStr(); } QString getPictureString() { return getPictureStr(); }
QString getPictureDescription() { return getPictureDesc(); }
bool setJsonString(const QString &jsonString, bool updateProperties = false) { return setJsonStr(jsonString, updateProperties); } // Please use setPictureJson instead bool setJsonString(const QString &jsonString, bool updateProperties = false) { return setJsonStr(jsonString, updateProperties); } // Please use setPictureJson instead
bool setPictureJson(const QString &json, bool updateProperties = false) { return setJsonStr(json, updateProperties); } bool setPictureJson(const QString &json, bool updateProperties = false) { return setJsonStr(json, updateProperties); }
bool setPictureTitle(const QString &title) { return setPictureTitl(title); } bool setPictureTitle(const QString &title) { return setPictureTitl(title); }
@ -120,11 +119,7 @@ public:
bool setVisible() { return setPictureVisible(); } // Please use setPictureVisible instead bool setVisible() { return setPictureVisible(); } // Please use setPictureVisible instead
// PREDEFINED PROPERTIES // PREDEFINED PROPERTIES
QSize getSnapmaticResolution(); static QSize getSnapmaticResolution();
// SNAPMATIC DEFAULTS
bool isSnapmaticDefaultsEnforced();
void setSnapmaticDefaultsEnforced(bool enforced);
// SNAPMATIC FORMAT // SNAPMATIC FORMAT
SnapmaticFormat getSnapmaticFormat(); SnapmaticFormat getSnapmaticFormat();
@ -139,44 +134,32 @@ public:
static QString convertDrawStringForLog(const QString &inputStr); static QString convertDrawStringForLog(const QString &inputStr);
static QString convertLogStringForDraw(const QString &inputStr); static QString convertLogStringForDraw(const QString &inputStr);
// RAGEPHOTO
RagePhoto* ragePhoto();
private: private:
QString getSnapmaticHeaderString(const QByteArray &snapmaticHeader);
QString getSnapmaticJSONString(const QByteArray &jsonBytes);
QString getSnapmaticTIDEString(const QByteArray &tideBytes);
QImage cachePicture; QImage cachePicture;
QString picExportFileName; QString picExportFileName;
QString picFileName; QString picFileName;
QString picFilePath; QString picFilePath;
QString pictureHead;
QString pictureStr; QString pictureStr;
QString lastStep; QString lastStep;
QString sortStr; QString sortStr;
QString titlStr;
QString descStr;
bool picOk; bool picOk;
bool lowRamMode;
bool writeEnabled;
bool cacheEnabled; bool cacheEnabled;
bool isLoadedInRAM;
bool isCustomFormat;
bool isFormatSwitch; bool isFormatSwitch;
bool isModernFormat;
bool careSnapDefault;
int jpegRawContentSize;
int jpegRawContentSizeE;
// PICTURE STREAM
QByteArray rawPicContent;
// JSON // JSON
void parseJsonContent(); void parseJsonContent();
bool jsonOk; bool jsonOk;
QString jsonStr;
SnapmaticProperties localProperties; SnapmaticProperties localProperties;
// VERIFY CONTENT // VERIFY CONTENT
static bool verifyTitleChar(const QChar &titleChar); static bool verifyTitleChar(const QChar &titleChar);
// RAGEPHOTO
RagePhoto p_ragePhoto;
signals: signals:
void customSignal(QString signal); void customSignal(QString signal);
void preloaded(); void preloaded();

View File

@ -1,6 +1,6 @@
/***************************************************************************** /*****************************************************************************
* gta5view Grand Theft Auto V Profile Viewer * gta5view Grand Theft Auto V Profile Viewer
* Copyright (C) 2016-2018 Syping * Copyright (C) 2016-2021 Syping
* *
* This program is free software: you can redistribute it and/or modify * This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by * it under the terms of the GNU General Public License as published by
@ -18,7 +18,6 @@
#include "SnapmaticWidget.h" #include "SnapmaticWidget.h"
#include "ui_SnapmaticWidget.h" #include "ui_SnapmaticWidget.h"
#include "ImageEditorDialog.h"
#include "MapLocationDialog.h" #include "MapLocationDialog.h"
#include "JsonEditorDialog.h" #include "JsonEditorDialog.h"
#include "SnapmaticPicture.h" #include "SnapmaticPicture.h"
@ -32,9 +31,9 @@
#include "config.h" #include "config.h"
#include <QStringBuilder> #include <QStringBuilder>
#include <QMessageBox> #include <QMessageBox>
#include <QPainter>
#include <QPixmap> #include <QPixmap>
#include <QTimer> #include <QTimer>
#include <QDebug>
#include <QMenu> #include <QMenu>
#include <QFile> #include <QFile>
@ -77,12 +76,33 @@ void SnapmaticWidget::setSnapmaticPicture(SnapmaticPicture *picture)
QObject::connect(picture, SIGNAL(updated()), this, SLOT(snapmaticUpdated())); QObject::connect(picture, SIGNAL(updated()), this, SLOT(snapmaticUpdated()));
QObject::connect(picture, SIGNAL(customSignal(QString)), this, SLOT(customSignal(QString))); QObject::connect(picture, SIGNAL(customSignal(QString)), this, SLOT(customSignal(QString)));
qreal screenRatio = AppEnv::screenRatio(); const qreal screenRatio = AppEnv::screenRatio();
const qreal screenRatioPR = AppEnv::screenRatioPR();
const QSize renderResolution(48 * screenRatio * screenRatioPR, 27 * screenRatio * screenRatioPR);
ui->labPicture->setFixedSize(48 * screenRatio, 27 * screenRatio); ui->labPicture->setFixedSize(48 * screenRatio, 27 * screenRatio);
ui->labPicture->setScaledContents(true);
QPixmap renderPixmap(renderResolution);
renderPixmap.fill(Qt::transparent);
QPainter renderPainter(&renderPixmap);
const QImage originalImage = picture->getImage();
const QImage renderImage = originalImage.scaled(renderResolution, Qt::KeepAspectRatio, Qt::SmoothTransformation); // Stack smash
if (renderImage.width() < renderResolution.width()) {
renderPainter.drawImage((renderResolution.width() - renderImage.width()) / 2, 0, renderImage, Qt::AutoColor);
}
else if (renderImage.height() < renderResolution.height()) {
renderPainter.drawImage(0, (renderResolution.height() - renderImage.height()) / 2, renderImage, Qt::AutoColor);
}
else {
renderPainter.drawImage(0, 0, renderImage, Qt::AutoColor);
}
renderPainter.end();
#if QT_VERSION >= 0x050600
renderPixmap.setDevicePixelRatio(screenRatioPR);
#endif
QPixmap SnapmaticPixmap = QPixmap::fromImage(picture->getImage().scaled(ui->labPicture->width(), ui->labPicture->height(), Qt::IgnoreAspectRatio, Qt::SmoothTransformation), Qt::AutoColor);
ui->labPicStr->setText(smpic->getPictureStr() % "\n" % smpic->getPictureTitl()); ui->labPicStr->setText(smpic->getPictureStr() % "\n" % smpic->getPictureTitl());
ui->labPicture->setPixmap(SnapmaticPixmap); ui->labPicture->setPixmap(renderPixmap);
picture->clearCache(); picture->clearCache();
@ -96,8 +116,7 @@ void SnapmaticWidget::snapmaticUpdated()
void SnapmaticWidget::customSignal(QString signal) void SnapmaticWidget::customSignal(QString signal)
{ {
if (signal == "PictureUpdated") if (signal == "PictureUpdated") {
{
QPixmap SnapmaticPixmap = QPixmap::fromImage(smpic->getImage().scaled(ui->labPicture->width(), ui->labPicture->height(), Qt::IgnoreAspectRatio, Qt::SmoothTransformation), Qt::AutoColor); QPixmap SnapmaticPixmap = QPixmap::fromImage(smpic->getImage().scaled(ui->labPicture->width(), ui->labPicture->height(), Qt::IgnoreAspectRatio, Qt::SmoothTransformation), Qt::AutoColor);
ui->labPicture->setPixmap(SnapmaticPixmap); ui->labPicture->setPixmap(SnapmaticPixmap);
} }
@ -113,7 +132,7 @@ void SnapmaticWidget::on_cmdView_clicked()
{ {
QSettings settings(GTA5SYNC_APPVENDOR, GTA5SYNC_APPSTR); QSettings settings(GTA5SYNC_APPVENDOR, GTA5SYNC_APPSTR);
settings.beginGroup("Interface"); settings.beginGroup("Interface");
bool navigationBar = settings.value("NavigationBar", false).toBool(); bool navigationBar = settings.value("NavigationBar", true).toBool();
settings.endGroup(); settings.endGroup();
PictureDialog *picDialog = new PictureDialog(profileDB, crewDB, profileName, this); PictureDialog *picDialog = new PictureDialog(profileDB, crewDB, profileName, this);
@ -127,7 +146,8 @@ void SnapmaticWidget::on_cmdView_clicked()
QObject::connect(picDialog, SIGNAL(previousPictureRequested()), this, SLOT(dialogPreviousPictureRequested())); QObject::connect(picDialog, SIGNAL(previousPictureRequested()), this, SLOT(dialogPreviousPictureRequested()));
// add previous next buttons // add previous next buttons
if (navigationBar) picDialog->addPreviousNextButtons(); if (navigationBar)
picDialog->addPreviousNextButtons();
// show picture dialog // show picture dialog
#ifdef Q_OS_ANDROID #ifdef Q_OS_ANDROID
@ -135,7 +155,7 @@ void SnapmaticWidget::on_cmdView_clicked()
picDialog->showMaximized(); picDialog->showMaximized();
#else #else
picDialog->show(); picDialog->show();
if (navigationBar) picDialog->stylizeDialog(); if (navigationBar) picDialog->styliseDialog();
//picDialog->adaptNewDialogSize(); //picDialog->adaptNewDialogSize();
picDialog->setMinimumSize(picDialog->size()); picDialog->setMinimumSize(picDialog->size());
picDialog->setMaximumSize(picDialog->size()); picDialog->setMaximumSize(picDialog->size());
@ -156,37 +176,38 @@ void SnapmaticWidget::on_cmdExport_clicked()
void SnapmaticWidget::on_cmdDelete_clicked() void SnapmaticWidget::on_cmdDelete_clicked()
{ {
if (deletePicture()) emit pictureDeleted(); if (deletePicture())
emit pictureDeleted();
} }
bool SnapmaticWidget::deletePicture() bool SnapmaticWidget::deletePicture()
{ {
int uchoice = QMessageBox::question(this, tr("Delete picture"), tr("Are you sure to delete %1 from your Snapmatic pictures?").arg("\""+smpic->getPictureTitle()+"\""), QMessageBox::Yes | QMessageBox::No, QMessageBox::No); int uchoice = QMessageBox::question(this, tr("Delete picture"), tr("Are you sure to delete %1 from your Snapmatic pictures?").arg("\""+smpic->getPictureTitle()+"\""), QMessageBox::Yes | QMessageBox::No, QMessageBox::No);
if (uchoice == QMessageBox::Yes) if (uchoice == QMessageBox::Yes) {
{ if (smpic->deletePictureFile()) {
if (smpic->deletePictureFile())
{
#ifdef GTA5SYNC_TELEMETRY #ifdef GTA5SYNC_TELEMETRY
QSettings telemetrySettings(GTA5SYNC_APPVENDOR, GTA5SYNC_APPSTR); QSettings telemetrySettings(GTA5SYNC_APPVENDOR, GTA5SYNC_APPSTR);
telemetrySettings.beginGroup("Telemetry"); telemetrySettings.beginGroup("Telemetry");
bool pushUsageData = telemetrySettings.value("PushUsageData", false).toBool(); bool pushUsageData = telemetrySettings.value("PushUsageData", false).toBool();
telemetrySettings.endGroup(); telemetrySettings.endGroup();
if (pushUsageData && Telemetry->canPush()) if (pushUsageData && Telemetry->canPush()) {
{
QJsonDocument jsonDocument; QJsonDocument jsonDocument;
QJsonObject jsonObject; QJsonObject jsonObject;
jsonObject["Type"] = "DeleteSuccess"; jsonObject["Type"] = "DeleteSuccess";
jsonObject["ExtraFlags"] = "Snapmatic"; jsonObject["ExtraFlags"] = "Snapmatic";
jsonObject["DeletedSize"] = QString::number(smpic->getContentMaxLength()); jsonObject["DeletedSize"] = QString::number(smpic->getContentMaxLength());
#if QT_VERSION >= 0x060000
jsonObject["DeletedTime"] = QString::number(QDateTime::currentDateTimeUtc().toSecsSinceEpoch());
#else
jsonObject["DeletedTime"] = QString::number(QDateTime::currentDateTimeUtc().toTime_t()); jsonObject["DeletedTime"] = QString::number(QDateTime::currentDateTimeUtc().toTime_t());
#endif
jsonDocument.setObject(jsonObject); jsonDocument.setObject(jsonObject);
Telemetry->push(TelemetryCategory::PersonalData, jsonDocument); Telemetry->push(TelemetryCategory::PersonalData, jsonDocument);
} }
#endif #endif
return true; return true;
} }
else else {
{
QMessageBox::warning(this, tr("Delete picture"), tr("Failed at deleting %1 from your Snapmatic pictures").arg("\""+smpic->getPictureTitle()+"\"")); QMessageBox::warning(this, tr("Delete picture"), tr("Failed at deleting %1 from your Snapmatic pictures").arg("\""+smpic->getPictureTitle()+"\""));
} }
} }
@ -201,28 +222,22 @@ void SnapmaticWidget::mousePressEvent(QMouseEvent *ev)
void SnapmaticWidget::mouseReleaseEvent(QMouseEvent *ev) void SnapmaticWidget::mouseReleaseEvent(QMouseEvent *ev)
{ {
ProfileWidget::mouseReleaseEvent(ev); ProfileWidget::mouseReleaseEvent(ev);
if (ui->cbSelected->isVisible()) if (ui->cbSelected->isVisible()) {
{ if (rect().contains(ev->pos()) && ev->button() == Qt::LeftButton) {
if (rect().contains(ev->pos()) && ev->button() == Qt::LeftButton)
{
ui->cbSelected->setChecked(!ui->cbSelected->isChecked()); ui->cbSelected->setChecked(!ui->cbSelected->isChecked());
} }
} }
else else {
{ const int contentMode = getContentMode();
if (getContentMode() == 0 && rect().contains(ev->pos()) && ev->button() == Qt::LeftButton) if ((contentMode == 0 || contentMode == 10 || contentMode == 20) && rect().contains(ev->pos()) && ev->button() == Qt::LeftButton) {
{ if (ev->modifiers().testFlag(Qt::ShiftModifier)) {
if (ev->modifiers().testFlag(Qt::ShiftModifier))
{
ui->cbSelected->setChecked(!ui->cbSelected->isChecked()); ui->cbSelected->setChecked(!ui->cbSelected->isChecked());
} }
else else {
{
on_cmdView_clicked(); on_cmdView_clicked();
} }
} }
else if (!ui->cbSelected->isVisible() && getContentMode() == 1 && ev->button() == Qt::LeftButton && ev->modifiers().testFlag(Qt::ShiftModifier)) else if (!ui->cbSelected->isVisible() && (contentMode == 1 || contentMode == 11 || contentMode == 21) && ev->button() == Qt::LeftButton && ev->modifiers().testFlag(Qt::ShiftModifier)) {
{
ui->cbSelected->setChecked(!ui->cbSelected->isChecked()); ui->cbSelected->setChecked(!ui->cbSelected->isChecked());
} }
} }
@ -232,8 +247,8 @@ void SnapmaticWidget::mouseDoubleClickEvent(QMouseEvent *ev)
{ {
ProfileWidget::mouseDoubleClickEvent(ev); ProfileWidget::mouseDoubleClickEvent(ev);
if (!ui->cbSelected->isVisible() && getContentMode() == 1 && ev->button() == Qt::LeftButton) const int contentMode = getContentMode();
{ if (!ui->cbSelected->isVisible() && (contentMode == 1 || contentMode == 11 || contentMode == 21) && ev->button() == Qt::LeftButton) {
on_cmdView_clicked(); on_cmdView_clicked();
} }
} }
@ -265,32 +280,27 @@ void SnapmaticWidget::dialogPreviousPictureRequested()
void SnapmaticWidget::on_cbSelected_stateChanged(int arg1) void SnapmaticWidget::on_cbSelected_stateChanged(int arg1)
{ {
if (arg1 == Qt::Checked) if (arg1 == Qt::Checked) {
{
emit widgetSelected(); emit widgetSelected();
} }
else if (arg1 == Qt::Unchecked) else if (arg1 == Qt::Unchecked) {
{
emit widgetDeselected(); emit widgetDeselected();
} }
} }
void SnapmaticWidget::adjustTextColor() void SnapmaticWidget::adjustTextColor()
{ {
if (isHidden()) if (isHidden()) {
{
ui->labPicStr->setStyleSheet(QString("QLabel{color: rgb(%1, %2, %3);}").arg(QString::number(highlightHiddenColor.red()), QString::number(highlightHiddenColor.green()), QString::number(highlightHiddenColor.blue()))); ui->labPicStr->setStyleSheet(QString("QLabel{color: rgb(%1, %2, %3);}").arg(QString::number(highlightHiddenColor.red()), QString::number(highlightHiddenColor.green()), QString::number(highlightHiddenColor.blue())));
} }
else else {
{
ui->labPicStr->setStyleSheet(""); ui->labPicStr->setStyleSheet("");
} }
} }
bool SnapmaticWidget::makePictureHidden() bool SnapmaticWidget::makePictureHidden()
{ {
if (smpic->setPictureHidden()) if (smpic->setPictureHidden()) {
{
adjustTextColor(); adjustTextColor();
return true; return true;
} }
@ -299,8 +309,7 @@ bool SnapmaticWidget::makePictureHidden()
bool SnapmaticWidget::makePictureVisible() bool SnapmaticWidget::makePictureVisible()
{ {
if (smpic->setPictureVisible()) if (smpic->setPictureVisible()) {
{
adjustTextColor(); adjustTextColor();
return true; return true;
} }
@ -310,17 +319,13 @@ bool SnapmaticWidget::makePictureVisible()
void SnapmaticWidget::makePictureHiddenSlot() void SnapmaticWidget::makePictureHiddenSlot()
{ {
if (!makePictureHidden()) if (!makePictureHidden())
{
QMessageBox::warning(this, QApplication::translate("UserInterface", "Hide In-game"), QApplication::translate("SnapmaticWidget", "Failed to hide %1 In-game from your Snapmatic pictures").arg("\""+smpic->getPictureTitle()+"\"")); QMessageBox::warning(this, QApplication::translate("UserInterface", "Hide In-game"), QApplication::translate("SnapmaticWidget", "Failed to hide %1 In-game from your Snapmatic pictures").arg("\""+smpic->getPictureTitle()+"\""));
}
} }
void SnapmaticWidget::makePictureVisibleSlot() void SnapmaticWidget::makePictureVisibleSlot()
{ {
if (!makePictureVisible()) if (!makePictureVisible())
{
QMessageBox::warning(this, QApplication::translate("UserInterface", "Show In-game"), QApplication::translate("SnapmaticWidget", "Failed to show %1 In-game from your Snapmatic pictures").arg("\""+smpic->getPictureTitle()+"\"")); QMessageBox::warning(this, QApplication::translate("UserInterface", "Show In-game"), QApplication::translate("SnapmaticWidget", "Failed to show %1 In-game from your Snapmatic pictures").arg("\""+smpic->getPictureTitle()+"\""));
}
} }
void SnapmaticWidget::editSnapmaticProperties() void SnapmaticWidget::editSnapmaticProperties()
@ -350,21 +355,17 @@ void SnapmaticWidget::editSnapmaticImage()
importDialog->enableOverwriteMode(); importDialog->enableOverwriteMode();
importDialog->setModal(true); importDialog->setModal(true);
importDialog->exec(); importDialog->exec();
if (importDialog->isImportAgreed()) if (importDialog->isImportAgreed()) {
{
const QByteArray previousPicture = smpic->getPictureStream(); const QByteArray previousPicture = smpic->getPictureStream();
bool success = smpic->setImage(importDialog->image()); bool success = smpic->setImage(importDialog->image(), importDialog->isUnlimitedBuffer());
if (success) if (success) {
{
QString currentFilePath = smpic->getPictureFilePath(); QString currentFilePath = smpic->getPictureFilePath();
QString originalFilePath = smpic->getOriginalPictureFilePath(); QString originalFilePath = smpic->getOriginalPictureFilePath();
QString backupFileName = originalFilePath % ".bak"; QString backupFileName = originalFilePath % ".bak";
if (!QFile::exists(backupFileName)) if (!QFile::exists(backupFileName)) {
{
QFile::copy(currentFilePath, backupFileName); QFile::copy(currentFilePath, backupFileName);
} }
if (!smpic->exportPicture(currentFilePath)) if (!smpic->exportPicture(currentFilePath)) {
{
smpic->setPictureStream(previousPicture); smpic->setPictureStream(previousPicture);
QMessageBox::warning(this, QApplication::translate("ImageEditorDialog", "Snapmatic Image Editor"), QApplication::translate("ImageEditorDialog", "Patching of Snapmatic Image failed because of I/O Error")); QMessageBox::warning(this, QApplication::translate("ImageEditorDialog", "Snapmatic Image Editor"), QApplication::translate("ImageEditorDialog", "Patching of Snapmatic Image failed because of I/O Error"));
return; return;
@ -375,21 +376,23 @@ void SnapmaticWidget::editSnapmaticImage()
telemetrySettings.beginGroup("Telemetry"); telemetrySettings.beginGroup("Telemetry");
bool pushUsageData = telemetrySettings.value("PushUsageData", false).toBool(); bool pushUsageData = telemetrySettings.value("PushUsageData", false).toBool();
telemetrySettings.endGroup(); telemetrySettings.endGroup();
if (pushUsageData && Telemetry->canPush()) if (pushUsageData && Telemetry->canPush()) {
{
QJsonDocument jsonDocument; QJsonDocument jsonDocument;
QJsonObject jsonObject; QJsonObject jsonObject;
jsonObject["Type"] = "ImageEdited"; jsonObject["Type"] = "ImageEdited";
jsonObject["ExtraFlags"] = "Interface"; jsonObject["ExtraFlags"] = "Interface";
jsonObject["EditedSize"] = QString::number(smpic->getContentMaxLength()); jsonObject["EditedSize"] = QString::number(smpic->getContentMaxLength());
#if QT_VERSION >= 0x060000
jsonObject["EditedTime"] = QString::number(QDateTime::currentDateTimeUtc().toSecsSinceEpoch());
#else
jsonObject["EditedTime"] = QString::number(QDateTime::currentDateTimeUtc().toTime_t()); jsonObject["EditedTime"] = QString::number(QDateTime::currentDateTimeUtc().toTime_t());
#endif
jsonDocument.setObject(jsonObject); jsonDocument.setObject(jsonObject);
Telemetry->push(TelemetryCategory::PersonalData, jsonDocument); Telemetry->push(TelemetryCategory::PersonalData, jsonDocument);
} }
#endif #endif
} }
else else {
{
QMessageBox::warning(this, QApplication::translate("ImageEditorDialog", "Snapmatic Image Editor"), QApplication::translate("ImageEditorDialog", "Patching of Snapmatic Image failed because of Image Error")); QMessageBox::warning(this, QApplication::translate("ImageEditorDialog", "Snapmatic Image Editor"), QApplication::translate("ImageEditorDialog", "Patching of Snapmatic Image failed because of Image Error"));
return; return;
} }
@ -400,48 +403,48 @@ void SnapmaticWidget::editSnapmaticImage()
void SnapmaticWidget::openMapViewer() void SnapmaticWidget::openMapViewer()
{ {
SnapmaticPicture *picture = smpic; SnapmaticPicture *picture = smpic;
MapLocationDialog *mapLocDialog = new MapLocationDialog(picture->getSnapmaticProperties().location.x, picture->getSnapmaticProperties().location.y, this); SnapmaticProperties currentProperties = picture->getSnapmaticProperties();
MapLocationDialog *mapLocDialog = new MapLocationDialog(currentProperties.location.x, currentProperties.location.y, this);
mapLocDialog->setCayoPerico(currentProperties.location.isCayoPerico);
mapLocDialog->setModal(true); mapLocDialog->setModal(true);
mapLocDialog->show(); mapLocDialog->show();
mapLocDialog->exec(); mapLocDialog->exec();
if (mapLocDialog->propUpdated()) if (mapLocDialog->propUpdated()) {
{
// Update Snapmatic Properties // Update Snapmatic Properties
SnapmaticProperties localSpJson = picture->getSnapmaticProperties(); currentProperties.location.x = mapLocDialog->getXpos();
localSpJson.location.x = mapLocDialog->getXpos(); currentProperties.location.y = mapLocDialog->getYpos();
localSpJson.location.y = mapLocDialog->getYpos(); currentProperties.location.z = 0;
localSpJson.location.z = 0;
// Update Snapmatic Picture // Update Snapmatic Picture
QString currentFilePath = picture->getPictureFilePath(); QString currentFilePath = picture->getPictureFilePath();
QString originalFilePath = picture->getOriginalPictureFilePath(); QString originalFilePath = picture->getOriginalPictureFilePath();
QString backupFileName = originalFilePath % ".bak"; QString backupFileName = originalFilePath % ".bak";
if (!QFile::exists(backupFileName)) if (!QFile::exists(backupFileName)) {
{
QFile::copy(currentFilePath, backupFileName); QFile::copy(currentFilePath, backupFileName);
} }
SnapmaticProperties fallbackProperties = picture->getSnapmaticProperties(); SnapmaticProperties fallbackProperties = picture->getSnapmaticProperties();
picture->setSnapmaticProperties(localSpJson); picture->setSnapmaticProperties(currentProperties);
if (!picture->exportPicture(currentFilePath)) if (!picture->exportPicture(currentFilePath)) {
{
QMessageBox::warning(this, SnapmaticEditor::tr("Snapmatic Properties"), SnapmaticEditor::tr("Patching of Snapmatic Properties failed because of I/O Error")); QMessageBox::warning(this, SnapmaticEditor::tr("Snapmatic Properties"), SnapmaticEditor::tr("Patching of Snapmatic Properties failed because of I/O Error"));
picture->setSnapmaticProperties(fallbackProperties); picture->setSnapmaticProperties(fallbackProperties);
} }
#ifdef GTA5SYNC_TELEMETRY #ifdef GTA5SYNC_TELEMETRY
else else {
{
QSettings telemetrySettings(GTA5SYNC_APPVENDOR, GTA5SYNC_APPSTR); QSettings telemetrySettings(GTA5SYNC_APPVENDOR, GTA5SYNC_APPSTR);
telemetrySettings.beginGroup("Telemetry"); telemetrySettings.beginGroup("Telemetry");
bool pushUsageData = telemetrySettings.value("PushUsageData", false).toBool(); bool pushUsageData = telemetrySettings.value("PushUsageData", false).toBool();
telemetrySettings.endGroup(); telemetrySettings.endGroup();
if (pushUsageData && Telemetry->canPush()) if (pushUsageData && Telemetry->canPush()) {
{
QJsonDocument jsonDocument; QJsonDocument jsonDocument;
QJsonObject jsonObject; QJsonObject jsonObject;
jsonObject["Type"] = "LocationEdited"; jsonObject["Type"] = "LocationEdited";
jsonObject["ExtraFlags"] = "Interface"; jsonObject["ExtraFlags"] = "Interface";
jsonObject["EditedSize"] = QString::number(picture->getContentMaxLength()); jsonObject["EditedSize"] = QString::number(picture->getContentMaxLength());
#if QT_VERSION >= 0x060000
jsonObject["EditedTime"] = QString::number(QDateTime::currentDateTimeUtc().toSecsSinceEpoch());
#else
jsonObject["EditedTime"] = QString::number(QDateTime::currentDateTimeUtc().toTime_t()); jsonObject["EditedTime"] = QString::number(QDateTime::currentDateTimeUtc().toTime_t());
#endif
jsonDocument.setObject(jsonObject); jsonDocument.setObject(jsonObject);
Telemetry->push(TelemetryCategory::PersonalData, jsonDocument); Telemetry->push(TelemetryCategory::PersonalData, jsonDocument);
} }

View File

@ -1,6 +1,6 @@
/***************************************************************************** /*****************************************************************************
* gta5view Grand Theft Auto V Profile Viewer * gta5view Grand Theft Auto V Profile Viewer
* Copyright (C) 2016-2017 Syping * Copyright (C) 2016-2021 Syping
* *
* This program is free software: you can redistribute it and/or modify * This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by * it under the terms of the GNU General Public License as published by
@ -23,11 +23,6 @@
#include <QDesktopServices> #include <QDesktopServices>
#endif #endif
StandardPaths::StandardPaths()
{
}
QString StandardPaths::applicationsLocation() QString StandardPaths::applicationsLocation()
{ {
#if QT_VERSION >= 0x050000 #if QT_VERSION >= 0x050000
@ -48,7 +43,9 @@ QString StandardPaths::cacheLocation()
QString StandardPaths::dataLocation() QString StandardPaths::dataLocation()
{ {
#if QT_VERSION >= 0x050000 #if QT_VERSION >= 0x060000
return QStandardPaths::writableLocation(QStandardPaths::AppLocalDataLocation);
#elif QT_VERSION >= 0x050000
return QStandardPaths::writableLocation(QStandardPaths::DataLocation); return QStandardPaths::writableLocation(QStandardPaths::DataLocation);
#else #else
return QDesktopServices::storageLocation(QDesktopServices::DataLocation); return QDesktopServices::storageLocation(QDesktopServices::DataLocation);

View File

@ -1,6 +1,6 @@
/***************************************************************************** /*****************************************************************************
* gta5view Grand Theft Auto V Profile Viewer * gta5view Grand Theft Auto V Profile Viewer
* Copyright (C) 2016-2017 Syping * Copyright (C) 2016-2021 Syping
* *
* This program is free software: you can redistribute it and/or modify * This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by * it under the terms of the GNU General Public License as published by
@ -24,7 +24,6 @@
class StandardPaths class StandardPaths
{ {
public: public:
StandardPaths();
static QString applicationsLocation(); static QString applicationsLocation();
static QString cacheLocation(); static QString cacheLocation();
static QString dataLocation(); static QString dataLocation();

View File

@ -1,6 +1,6 @@
/***************************************************************************** /*****************************************************************************
* gta5view Grand Theft Auto V Profile Viewer * gta5view Grand Theft Auto V Profile Viewer
* Copyright (C) 2016-2017 Syping * Copyright (C) 2016-2021 Syping
* *
* This program is free software: you can redistribute it and/or modify * This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by * it under the terms of the GNU General Public License as published by
@ -17,25 +17,16 @@
*****************************************************************************/ *****************************************************************************/
#include "StringParser.h" #include "StringParser.h"
#include "config.h"
#include <QTextDocument> #include <QTextDocument>
#include <QApplication>
#include <QLibraryInfo> #include <QLibraryInfo>
#include <QTextCodec>
#include <QByteArray> #include <QByteArray>
#include <QFileInfo> #include <QFileInfo>
#include <QString> #include <QString>
#include <QList> #include <QList>
#include <QDir> #include <QDir>
#ifdef GTA5SYNC_PROJECT
#include <QApplication>
#include "config.h"
#endif
StringParser::StringParser()
{
}
QString StringParser::escapeString(const QString &toEscape) QString StringParser::escapeString(const QString &toEscape)
{ {
#if QT_VERSION >= 0x050000 #if QT_VERSION >= 0x050000
@ -45,17 +36,19 @@ QString StringParser::escapeString(const QString &toEscape)
#endif #endif
} }
#ifdef GTA5SYNC_PROJECT
QString StringParser::convertBuildedString(const QString &buildedStr) QString StringParser::convertBuildedString(const QString &buildedStr)
{ {
QString outputStr = buildedStr; QString outputStr = buildedStr;
QByteArray sharePath = GTA5SYNC_SHARE; outputStr.replace("APPNAME:", QString::fromUtf8(GTA5SYNC_APPSTR));
outputStr.replace("APPNAME:", GTA5SYNC_APPSTR); outputStr.replace("SHAREDDIR:", QString::fromUtf8(GTA5SYNC_SHARE));
outputStr.replace("SHAREDDIR:", QString::fromUtf8(sharePath)); outputStr.replace("RUNDIR:", QFileInfo(QApplication::applicationFilePath()).canonicalPath());
outputStr.replace("RUNDIR:", QFileInfo(qApp->applicationFilePath()).absoluteDir().absolutePath()); #if QT_VERSION >= 0x060000
outputStr.replace("QCONFLANG:", QLibraryInfo::path(QLibraryInfo::TranslationsPath));
outputStr.replace("QCONFPLUG:", QLibraryInfo::path(QLibraryInfo::PluginsPath));
#else
outputStr.replace("QCONFLANG:", QLibraryInfo::location(QLibraryInfo::TranslationsPath)); outputStr.replace("QCONFLANG:", QLibraryInfo::location(QLibraryInfo::TranslationsPath));
outputStr.replace("QCONFPLUG:", QLibraryInfo::location(QLibraryInfo::PluginsPath)); outputStr.replace("QCONFPLUG:", QLibraryInfo::location(QLibraryInfo::PluginsPath));
#endif
outputStr.replace("SEPARATOR:", QDir::separator()); outputStr.replace("SEPARATOR:", QDir::separator());
return outputStr; return outputStr;
} }
#endif

View File

@ -1,6 +1,6 @@
/***************************************************************************** /*****************************************************************************
* gta5view Grand Theft Auto V Profile Viewer * gta5view Grand Theft Auto V Profile Viewer
* Copyright (C) 2016-2017 Syping * Copyright (C) 2016-2021 Syping
* *
* This program is free software: you can redistribute it and/or modify * This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by * it under the terms of the GNU General Public License as published by
@ -25,11 +25,8 @@
class StringParser class StringParser
{ {
public: public:
StringParser();
static QString escapeString(const QString &toEscape); static QString escapeString(const QString &toEscape);
#ifdef GTA5SYNC_PROJECT
static QString convertBuildedString(const QString &buildedStr); static QString convertBuildedString(const QString &buildedStr);
#endif
}; };
#endif // STRINGPARSER_H #endif // STRINGPARSER_H

View File

@ -41,7 +41,7 @@
#define GTA5SYNC_TELEMETRY_WEBURL "" #define GTA5SYNC_TELEMETRY_WEBURL ""
#endif #endif
#ifdef GTA5SYNC_WIN #ifdef Q_OS_WIN
#include "windows.h" #include "windows.h"
#include "intrin.h" #include "intrin.h"
#include "d3d9.h" #include "d3d9.h"
@ -228,7 +228,7 @@ QJsonDocument TelemetryClass::getSystemHardware()
{ {
QJsonDocument jsonDocument; QJsonDocument jsonDocument;
QJsonObject jsonObject; QJsonObject jsonObject;
#ifdef GTA5SYNC_WIN #ifdef Q_OS_WIN
{ {
int CPUInfo[4] = {-1}; int CPUInfo[4] = {-1};
unsigned nExIds, ic = 0; unsigned nExIds, ic = 0;

View File

@ -1,6 +1,6 @@
/***************************************************************************** /*****************************************************************************
* gta5view Grand Theft Auto V Profile Viewer * gta5view Grand Theft Auto V Profile Viewer
* Copyright (C) 2017 Syping * Copyright (C) 2017-2021 Syping
* *
* This program is free software: you can redistribute it and/or modify * This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by * it under the terms of the GNU General Public License as published by
@ -48,22 +48,27 @@ void TranslationClass::initUserLanguage()
void TranslationClass::loadTranslation(QApplication *app) void TranslationClass::loadTranslation(QApplication *app)
{ {
if (isLangLoaded) { unloadTranslation(app); } if (isLangLoaded) {
else { currentLangIndex = 0; } unloadTranslation(app);
QString exLangPath = AppEnv::getExLangFolder(); }
QString inLangPath = AppEnv::getInLangFolder(); else {
if (userLanguage == "en" || userLanguage == "en_GB") currentLangIndex = 0;
{ }
const QString exLangPath = AppEnv::getExLangFolder();
const QString inLangPath = AppEnv::getInLangFolder();
if (userLanguage == "en" || userLanguage == "en_GB") {
currentLanguage = "en_GB"; currentLanguage = "en_GB";
if (loadQtTranslation_p(exLangPath, &exQtTranslator)) if (loadQtTranslation_p(exLangPath, &exQtTranslator)) {
{
app->installTranslator(&exQtTranslator); app->installTranslator(&exQtTranslator);
} }
else if (loadQtTranslation_p(inLangPath, &inQtTranslator)) else if (loadQtTranslation_p(inLangPath, &inQtTranslator)) {
{
app->installTranslator(&inQtTranslator); app->installTranslator(&inQtTranslator);
} }
#if QT_VERSION >= 0x060000
QLocale::setDefault(QLocale(currentLanguage));
#else
QLocale::setDefault(currentLanguage); QLocale::setDefault(currentLanguage);
#endif
isLangLoaded = true; isLangLoaded = true;
return; return;
} }
@ -73,33 +78,28 @@ void TranslationClass::loadTranslation(QApplication *app)
bool externalEnglishMode = false; bool externalEnglishMode = false;
bool loadInternalLang = false; bool loadInternalLang = false;
bool trLoadSuccess = false; bool trLoadSuccess = false;
if (isUserLanguageSystem_p()) if (isUserLanguageSystem_p()) {
{
#ifdef GTA5SYNC_DEBUG #ifdef GTA5SYNC_DEBUG
qDebug() << "loadExSystemLanguage"; qDebug() << "loadExSystemLanguage";
#endif #endif
trLoadSuccess = loadSystemTranslation_p(exLangPath, &exAppTranslator); trLoadSuccess = loadSystemTranslation_p(exLangPath, &exAppTranslator);
} }
else else {
{
#ifdef GTA5SYNC_DEBUG #ifdef GTA5SYNC_DEBUG
qDebug() << "loadExUserLanguage"; qDebug() << "loadExUserLanguage";
#endif #endif
trLoadSuccess = loadUserTranslation_p(exLangPath, &exAppTranslator); trLoadSuccess = loadUserTranslation_p(exLangPath, &exAppTranslator);
if (!trLoadSuccess) if (!trLoadSuccess) {
{
#ifdef GTA5SYNC_DEBUG #ifdef GTA5SYNC_DEBUG
qDebug() << "loadInUserLanguage"; qDebug() << "loadInUserLanguage";
#endif #endif
trLoadSuccess = loadUserTranslation_p(inLangPath, &inAppTranslator); trLoadSuccess = loadUserTranslation_p(inLangPath, &inAppTranslator);
if (!trLoadSuccess) if (!trLoadSuccess) {
{
#ifdef GTA5SYNC_DEBUG #ifdef GTA5SYNC_DEBUG
qDebug() << "loadUserLanguageFailed"; qDebug() << "loadUserLanguageFailed";
#endif #endif
} }
else else {
{
#ifdef GTA5SYNC_DEBUG #ifdef GTA5SYNC_DEBUG
qDebug() << "loadUserLanguageSuccess"; qDebug() << "loadUserLanguageSuccess";
#endif #endif
@ -107,18 +107,16 @@ void TranslationClass::loadTranslation(QApplication *app)
isLangLoaded = true; isLangLoaded = true;
} }
} }
else else {
{
#ifdef GTA5SYNC_DEBUG #ifdef GTA5SYNC_DEBUG
qDebug() << "loadUserLanguageSuccess"; qDebug() << "loadUserLanguageSuccess";
#endif #endif
isLangLoaded = true; isLangLoaded = true;
} }
} }
if (trLoadSuccess) if (trLoadSuccess) {
{ // Don't install the language until we know we not have a better language for the user
if (currentLangIndex != 0 || isEnglishMode) // Don't install the language until we know we not have a better language for the user if (currentLangIndex != 0 || isEnglishMode) {
{
#ifdef GTA5SYNC_DEBUG #ifdef GTA5SYNC_DEBUG
qDebug() << "externalLanguageReady" << currentLanguage; qDebug() << "externalLanguageReady" << currentLanguage;
#endif #endif
@ -126,33 +124,31 @@ void TranslationClass::loadTranslation(QApplication *app)
externalLanguageStr = currentLanguage; externalLanguageStr = currentLanguage;
externalLanguageReady = true; externalLanguageReady = true;
} }
else else {
{
#ifdef GTA5SYNC_DEBUG #ifdef GTA5SYNC_DEBUG
qDebug() << "installTranslation"; qDebug() << "installTranslation";
#endif #endif
if (loadInternalLang) if (loadInternalLang) {
{
app->installTranslator(&inAppTranslator); app->installTranslator(&inAppTranslator);
} }
else else {
{
app->installTranslator(&exAppTranslator); app->installTranslator(&exAppTranslator);
} }
if (loadQtTranslation_p(exLangPath, &exQtTranslator)) if (loadQtTranslation_p(exLangPath, &exQtTranslator)) {
{
app->installTranslator(&exQtTranslator); app->installTranslator(&exQtTranslator);
} }
else if (loadQtTranslation_p(inLangPath, &inQtTranslator)) else if (loadQtTranslation_p(inLangPath, &inQtTranslator)) {
{
app->installTranslator(&inQtTranslator); app->installTranslator(&inQtTranslator);
} }
#if QT_VERSION >= 0x060000
QLocale::setDefault(QLocale(currentLanguage));
#else
QLocale::setDefault(currentLanguage); QLocale::setDefault(currentLanguage);
#endif
isLangLoaded = true; isLangLoaded = true;
} }
} }
if (externalLanguageReady) if (externalLanguageReady) {
{
#ifdef GTA5SYNC_DEBUG #ifdef GTA5SYNC_DEBUG
qDebug() << "loadInSystemLanguage"; qDebug() << "loadInSystemLanguage";
#endif #endif
@ -162,113 +158,114 @@ void TranslationClass::loadTranslation(QApplication *app)
qDebug() << "externalLangIndex" << externalLangIndex << "internalLangIndex" << currentLangIndex; qDebug() << "externalLangIndex" << externalLangIndex << "internalLangIndex" << currentLangIndex;
qDebug() << "externalEnglishMode" << externalEnglishMode << "internalEnglishMode" << isEnglishMode; qDebug() << "externalEnglishMode" << externalEnglishMode << "internalEnglishMode" << isEnglishMode;
#endif #endif
if ((trLoadSuccess && externalLangIndex > currentLangIndex) || (trLoadSuccess && externalEnglishMode && !isEnglishMode)) if ((trLoadSuccess && externalLangIndex > currentLangIndex) || (trLoadSuccess && externalEnglishMode && !isEnglishMode)) {
{
#ifdef GTA5SYNC_DEBUG #ifdef GTA5SYNC_DEBUG
qDebug() << "installInternalTranslation"; qDebug() << "installInternalTranslation";
#endif #endif
app->installTranslator(&inAppTranslator); app->installTranslator(&inAppTranslator);
if (loadQtTranslation_p(exLangPath, &exQtTranslator)) if (loadQtTranslation_p(exLangPath, &exQtTranslator)) {
{
app->installTranslator(&exQtTranslator); app->installTranslator(&exQtTranslator);
} }
else if (loadQtTranslation_p(inLangPath, &inQtTranslator)) else if (loadQtTranslation_p(inLangPath, &inQtTranslator)) {
{
app->installTranslator(&inQtTranslator); app->installTranslator(&inQtTranslator);
} }
#if QT_VERSION >= 0x060000
QLocale::setDefault(QLocale(currentLanguage));
#else
QLocale::setDefault(currentLanguage); QLocale::setDefault(currentLanguage);
#endif
isLangLoaded = true; isLangLoaded = true;
} }
else else {
{
#ifdef GTA5SYNC_DEBUG #ifdef GTA5SYNC_DEBUG
qDebug() << "installExternalTranslation"; qDebug() << "installExternalTranslation";
#endif #endif
isEnglishMode = externalEnglishMode; isEnglishMode = externalEnglishMode;
currentLanguage = externalLanguageStr; currentLanguage = externalLanguageStr;
app->installTranslator(&exAppTranslator); app->installTranslator(&exAppTranslator);
if (loadQtTranslation_p(exLangPath, &exQtTranslator)) if (loadQtTranslation_p(exLangPath, &exQtTranslator)) {
{
app->installTranslator(&exQtTranslator); app->installTranslator(&exQtTranslator);
} }
else if (loadQtTranslation_p(inLangPath, &inQtTranslator)) else if (loadQtTranslation_p(inLangPath, &inQtTranslator)) {
{
app->installTranslator(&inQtTranslator); app->installTranslator(&inQtTranslator);
} }
#if QT_VERSION >= 0x060000
QLocale::setDefault(QLocale(currentLanguage));
#else
QLocale::setDefault(currentLanguage); QLocale::setDefault(currentLanguage);
#endif
isLangLoaded = true; isLangLoaded = true;
} }
} }
else if (!isLangLoaded) else if (!isLangLoaded) {
{
#ifdef GTA5SYNC_DEBUG #ifdef GTA5SYNC_DEBUG
qDebug() << "loadInSystemLanguage"; qDebug() << "loadInSystemLanguage";
#endif #endif
trLoadSuccess = loadSystemTranslation_p(inLangPath, &inAppTranslator); trLoadSuccess = loadSystemTranslation_p(inLangPath, &inAppTranslator);
if (trLoadSuccess) if (trLoadSuccess) {
{
#ifdef GTA5SYNC_DEBUG #ifdef GTA5SYNC_DEBUG
qDebug() << "installInternalTranslation"; qDebug() << "installInternalTranslation";
#endif #endif
app->installTranslator(&inAppTranslator); app->installTranslator(&inAppTranslator);
if (loadQtTranslation_p(exLangPath, &exQtTranslator)) if (loadQtTranslation_p(exLangPath, &exQtTranslator)) {
{
app->installTranslator(&exQtTranslator); app->installTranslator(&exQtTranslator);
} }
else if (loadQtTranslation_p(inLangPath, &inQtTranslator)) else if (loadQtTranslation_p(inLangPath, &inQtTranslator)) {
{
app->installTranslator(&inQtTranslator); app->installTranslator(&inQtTranslator);
} }
#if QT_VERSION >= 0x060000
QLocale::setDefault(QLocale(currentLanguage));
#else
QLocale::setDefault(currentLanguage); QLocale::setDefault(currentLanguage);
#endif
isLangLoaded = true; isLangLoaded = true;
} }
else if (!trLoadSuccess) else if (!trLoadSuccess) {
{
#ifdef GTA5SYNC_DEBUG #ifdef GTA5SYNC_DEBUG
qDebug() << "fallbackToDefaultApplicationLanguage"; qDebug() << "fallbackToDefaultApplicationLanguage";
#endif #endif
currentLanguage = "en_GB"; currentLanguage = "en_GB";
if (loadQtTranslation_p(exLangPath, &exQtTranslator)) if (loadQtTranslation_p(exLangPath, &exQtTranslator)) {
{
app->installTranslator(&exQtTranslator); app->installTranslator(&exQtTranslator);
} }
else if (loadQtTranslation_p(inLangPath, &inQtTranslator)) else if (loadQtTranslation_p(inLangPath, &inQtTranslator)) {
{
app->installTranslator(&inQtTranslator); app->installTranslator(&inQtTranslator);
} }
#if QT_VERSION >= 0x060000
QLocale::setDefault(QLocale(currentLanguage));
#else
QLocale::setDefault(currentLanguage); QLocale::setDefault(currentLanguage);
#endif
isLangLoaded = true; isLangLoaded = true;
} }
} }
#else // New qconf loading method #else // New qconf loading method
bool trLoadSuccess; bool trLoadSuccess;
if (isUserLanguageSystem_p()) if (isUserLanguageSystem_p()) {
{
trLoadSuccess = loadSystemTranslation_p(inLangPath, &inAppTranslator); trLoadSuccess = loadSystemTranslation_p(inLangPath, &inAppTranslator);
} }
else else {
{
trLoadSuccess = loadUserTranslation_p(inLangPath, &inAppTranslator); trLoadSuccess = loadUserTranslation_p(inLangPath, &inAppTranslator);
} }
if (!trLoadSuccess && !isUserLanguageSystem_p()) if (!trLoadSuccess && !isUserLanguageSystem_p()) {
{
trLoadSuccess = loadSystemTranslation_p(inLangPath, &inAppTranslator); trLoadSuccess = loadSystemTranslation_p(inLangPath, &inAppTranslator);
} }
if (trLoadSuccess) if (trLoadSuccess) {
{
#ifdef GTA5SYNC_DEBUG #ifdef GTA5SYNC_DEBUG
qDebug() << "installTranslation" << currentLanguage; qDebug() << "installTranslation" << currentLanguage;
#endif #endif
app->installTranslator(&inAppTranslator); app->installTranslator(&inAppTranslator);
if (loadQtTranslation_p(exLangPath, &exQtTranslator)) if (loadQtTranslation_p(exLangPath, &exQtTranslator)) {
{
app->installTranslator(&exQtTranslator); app->installTranslator(&exQtTranslator);
} }
else if (loadQtTranslation_p(inLangPath, &inQtTranslator)) else if (loadQtTranslation_p(inLangPath, &inQtTranslator)) {
{
app->installTranslator(&inQtTranslator); app->installTranslator(&inQtTranslator);
} }
#if QT_VERSION >= 0x060000
QLocale::setDefault(QLocale(currentLanguage));
#else
QLocale::setDefault(currentLanguage); QLocale::setDefault(currentLanguage);
#endif
isLangLoaded = true; isLangLoaded = true;
} }
#endif #endif
@ -280,8 +277,7 @@ QStringList TranslationClass::listTranslations(const QString &langPath)
langDir.setNameFilters(QStringList("gta5sync_*.qm")); langDir.setNameFilters(QStringList("gta5sync_*.qm"));
langDir.setPath(langPath); langDir.setPath(langPath);
QStringList availableLanguages; QStringList availableLanguages;
for (QString lang : langDir.entryList(QDir::Files | QDir::NoDotAndDotDot, QDir::NoSort)) for (const QString &lang : langDir.entryList(QDir::Files | QDir::NoDotAndDotDot, QDir::NoSort)) {
{
availableLanguages << QString(lang).remove("gta5sync_").remove(".qm"); availableLanguages << QString(lang).remove("gta5sync_").remove(".qm");
} }
return availableLanguages; return availableLanguages;
@ -293,8 +289,7 @@ QStringList TranslationClass::listAreaTranslations()
langDir.setNameFilters(QStringList("global.*.ini")); langDir.setNameFilters(QStringList("global.*.ini"));
langDir.setPath(":/global"); langDir.setPath(":/global");
QStringList availableLanguages; QStringList availableLanguages;
for (QString lang : langDir.entryList(QDir::Files | QDir::NoDotAndDotDot, QDir::NoSort)) for (const QString &lang : langDir.entryList(QDir::Files | QDir::NoDotAndDotDot, QDir::NoSort)) {
{
availableLanguages << QString(lang).remove("global.").remove(".ini"); availableLanguages << QString(lang).remove("global.").remove(".ini");
} }
return availableLanguages; return availableLanguages;
@ -306,21 +301,17 @@ bool TranslationClass::loadSystemTranslation_p(const QString &langPath, QTransla
qDebug() << "loadSystemTranslation_p"; qDebug() << "loadSystemTranslation_p";
#endif #endif
int currentLangCounter = 0; int currentLangCounter = 0;
for (QString languageName : QLocale::system().uiLanguages()) for (const QString &languageName : QLocale::system().uiLanguages()) {
{
#ifdef GTA5SYNC_DEBUG #ifdef GTA5SYNC_DEBUG
qDebug() << "loadLanguage" << languageName; qDebug() << "loadLanguage" << languageName;
#endif #endif
QStringList langList = QString(languageName).replace("-","_").split("_"); const QStringList langList = QString(languageName).replace("-","_").split("_");
if (langList.length() == 2) if (langList.length() == 2) {
{
#ifdef GTA5SYNC_DEBUG #ifdef GTA5SYNC_DEBUG
qDebug() << "loadLanguageFile" << QString(langPath % "/gta5sync_" % langList.at(0) % "_" % langList.at(1) % ".qm"); qDebug() << "loadLanguageFile" << QString(langPath % "/gta5sync_" % langList.at(0) % "_" % langList.at(1) % ".qm");
#endif #endif
if (QFile::exists(langPath % "/gta5sync_" % langList.at(0) % "_" % langList.at(1) % ".qm")) if (QFile::exists(langPath % "/gta5sync_" % langList.at(0) % "_" % langList.at(1) % ".qm")) {
{ if (appTranslator->load(langPath % "/gta5sync_" % langList.at(0) % "_" % langList.at(1) % ".qm")) {
if (appTranslator->load(langPath % "/gta5sync_" % langList.at(0) % "_" % langList.at(1) % ".qm"))
{
#ifdef GTA5SYNC_DEBUG #ifdef GTA5SYNC_DEBUG
qDebug() << "loadLanguageFileSuccess" << QString(langPath % "/gta5sync_" % langList.at(0) % "_" % langList.at(1) % ".qm"); qDebug() << "loadLanguageFileSuccess" << QString(langPath % "/gta5sync_" % langList.at(0) % "_" % langList.at(1) % ".qm");
#endif #endif
@ -333,10 +324,8 @@ bool TranslationClass::loadSystemTranslation_p(const QString &langPath, QTransla
#ifdef GTA5SYNC_DEBUG #ifdef GTA5SYNC_DEBUG
qDebug() << "loadLanguageFile" << QString(langPath % "/gta5sync_" % langList.at(0) % ".qm"); qDebug() << "loadLanguageFile" << QString(langPath % "/gta5sync_" % langList.at(0) % ".qm");
#endif #endif
if (QFile::exists(langPath % "/gta5sync_" % langList.at(0) % ".qm")) if (QFile::exists(langPath % "/gta5sync_" % langList.at(0) % ".qm")) {
{ if (appTranslator->load(langPath % "/gta5sync_" % langList.at(0) % ".qm")) {
if (appTranslator->load(langPath % "/gta5sync_" % langList.at(0) % ".qm"))
{
#ifdef GTA5SYNC_DEBUG #ifdef GTA5SYNC_DEBUG
qDebug() << "loadLanguageFileSuccess" << QString(langPath % "/gta5sync_" % langList.at(0) % ".qm"); qDebug() << "loadLanguageFileSuccess" << QString(langPath % "/gta5sync_" % langList.at(0) % ".qm");
#endif #endif
@ -345,8 +334,7 @@ bool TranslationClass::loadSystemTranslation_p(const QString &langPath, QTransla
currentLangIndex = currentLangCounter; currentLangIndex = currentLangCounter;
return true; return true;
} }
else if (langList.at(0) == "en") else if (langList.at(0) == "en") {
{
#ifdef GTA5SYNC_DEBUG #ifdef GTA5SYNC_DEBUG
qDebug() << "languageEnglishMode index" << currentLangCounter; qDebug() << "languageEnglishMode index" << currentLangCounter;
#endif #endif
@ -356,8 +344,7 @@ bool TranslationClass::loadSystemTranslation_p(const QString &langPath, QTransla
return true; return true;
} }
} }
else if (langList.at(0) == "en") else if (langList.at(0) == "en") {
{
#ifdef GTA5SYNC_DEBUG #ifdef GTA5SYNC_DEBUG
qDebug() << "languageEnglishMode index" << currentLangCounter; qDebug() << "languageEnglishMode index" << currentLangCounter;
#endif #endif
@ -367,15 +354,12 @@ bool TranslationClass::loadSystemTranslation_p(const QString &langPath, QTransla
return true; return true;
} }
} }
else if (langList.length() == 1) else if (langList.length() == 1) {
{
#ifdef GTA5SYNC_DEBUG #ifdef GTA5SYNC_DEBUG
qDebug() << "loadLanguageFile" << QString(langPath % "/gta5sync_" % langList.at(0) % ".qm"); qDebug() << "loadLanguageFile" << QString(langPath % "/gta5sync_" % langList.at(0) % ".qm");
#endif #endif
if (QFile::exists(langPath % "/gta5sync_" % langList.at(0) % ".qm")) if (QFile::exists(langPath % "/gta5sync_" % langList.at(0) % ".qm")) {
{ if (appTranslator->load(langPath % "/gta5sync_" % langList.at(0) % ".qm")) {
if (appTranslator->load(langPath % "/gta5sync_" % langList.at(0) % ".qm"))
{
#ifdef GTA5SYNC_DEBUG #ifdef GTA5SYNC_DEBUG
qDebug() << "loadLanguageFileSuccess" << QString(langPath % "/gta5sync_" % langList.at(0) % ".qm"); qDebug() << "loadLanguageFileSuccess" << QString(langPath % "/gta5sync_" % langList.at(0) % ".qm");
#endif #endif
@ -399,17 +383,14 @@ bool TranslationClass::loadUserTranslation_p(const QString &langPath, QTranslato
#ifdef GTA5SYNC_DEBUG #ifdef GTA5SYNC_DEBUG
qDebug() << "loadUserTranslation_p"; qDebug() << "loadUserTranslation_p";
#endif #endif
QString languageName = userLanguage; const QString languageName = userLanguage;
QStringList langList = QString(languageName).replace("-","_").split("_"); const QStringList langList = QString(languageName).replace("-","_").split("_");
if (langList.length() == 2) if (langList.length() == 2) {
{
#ifdef GTA5SYNC_DEBUG #ifdef GTA5SYNC_DEBUG
qDebug() << "loadLanguageFile" << QString(langPath % "/gta5sync_" % langList.at(0) % "_" % langList.at(1) % ".qm"); qDebug() << "loadLanguageFile" << QString(langPath % "/gta5sync_" % langList.at(0) % "_" % langList.at(1) % ".qm");
#endif #endif
if (QFile::exists(langPath % "/gta5sync_" % langList.at(0) % "_" % langList.at(1) % ".qm")) if (QFile::exists(langPath % "/gta5sync_" % langList.at(0) % "_" % langList.at(1) % ".qm")) {
{ if (appTranslator->load(langPath % "/gta5sync_" % langList.at(0) % "_" % langList.at(1) % ".qm")) {
if (appTranslator->load(langPath % "/gta5sync_" % langList.at(0) % "_" % langList.at(1) % ".qm"))
{
#ifdef GTA5SYNC_DEBUG #ifdef GTA5SYNC_DEBUG
qDebug() << "loadLanguageFileSuccess" << QString(langPath % "/gta5sync_" % langList.at(0) % "_" % langList.at(1) % ".qm"); qDebug() << "loadLanguageFileSuccess" << QString(langPath % "/gta5sync_" % langList.at(0) % "_" % langList.at(1) % ".qm");
#endif #endif
@ -420,10 +401,8 @@ bool TranslationClass::loadUserTranslation_p(const QString &langPath, QTranslato
#ifdef GTA5SYNC_DEBUG #ifdef GTA5SYNC_DEBUG
qDebug() << "loadLanguageFile" << QString(langPath % "/gta5sync_" % langList.at(0) % ".qm"); qDebug() << "loadLanguageFile" << QString(langPath % "/gta5sync_" % langList.at(0) % ".qm");
#endif #endif
if (QFile::exists(langPath % "/gta5sync_" % langList.at(0) % ".qm")) if (QFile::exists(langPath % "/gta5sync_" % langList.at(0) % ".qm")) {
{ if (appTranslator->load(langPath % "/gta5sync_" % langList.at(0) % ".qm")) {
if (appTranslator->load(langPath % "/gta5sync_" % langList.at(0) % ".qm"))
{
#ifdef GTA5SYNC_DEBUG #ifdef GTA5SYNC_DEBUG
qDebug() << "loadLanguageFileSuccess" << QString(langPath % "/gta5sync_" % langList.at(0) % ".qm"); qDebug() << "loadLanguageFileSuccess" << QString(langPath % "/gta5sync_" % langList.at(0) % ".qm");
#endif #endif
@ -432,15 +411,12 @@ bool TranslationClass::loadUserTranslation_p(const QString &langPath, QTranslato
} }
} }
} }
else if (langList.length() == 1) else if (langList.length() == 1) {
{
#ifdef GTA5SYNC_DEBUG #ifdef GTA5SYNC_DEBUG
qDebug() << "loadLanguageFile" << QString(langPath % "/gta5sync_" % langList.at(0) % ".qm"); qDebug() << "loadLanguageFile" << QString(langPath % "/gta5sync_" % langList.at(0) % ".qm");
#endif #endif
if (QFile::exists(langPath % "/gta5sync_" % langList.at(0) % ".qm")) if (QFile::exists(langPath % "/gta5sync_" % langList.at(0) % ".qm")) {
{ if (appTranslator->load(langPath % "/gta5sync_" % langList.at(0) % ".qm")) {
if (appTranslator->load(langPath % "/gta5sync_" % langList.at(0) % ".qm"))
{
#ifdef GTA5SYNC_DEBUG #ifdef GTA5SYNC_DEBUG
qDebug() << "loadLanguageFileSuccess" << QString(langPath % "/gta5sync_" % langList.at(0) % ".qm"); qDebug() << "loadLanguageFileSuccess" << QString(langPath % "/gta5sync_" % langList.at(0) % ".qm");
#endif #endif
@ -457,17 +433,14 @@ bool TranslationClass::loadQtTranslation_p(const QString &langPath, QTranslator
#ifdef GTA5SYNC_DEBUG #ifdef GTA5SYNC_DEBUG
qDebug() << "loadQtTranslation_p" << currentLanguage; qDebug() << "loadQtTranslation_p" << currentLanguage;
#endif #endif
QString languageName = currentLanguage; const QString languageName = currentLanguage;
QStringList langList = QString(languageName).replace("-","_").split("_"); const QStringList langList = QString(languageName).replace("-","_").split("_");
if (langList.length() == 2) if (langList.length() == 2) {
{
#ifdef GTA5SYNC_DEBUG #ifdef GTA5SYNC_DEBUG
qDebug() << "loadLanguageFile" << QString(langPath % QDir::separator() % QtBaseTranslationFormat % langList.at(0) % "_" % langList.at(1) % ".qm"); qDebug() << "loadLanguageFile" << QString(langPath % QDir::separator() % QtBaseTranslationFormat % langList.at(0) % "_" % langList.at(1) % ".qm");
#endif #endif
if (QFile::exists(langPath % QDir::separator() % QtBaseTranslationFormat % langList.at(0) % "_" % langList.at(1) % ".qm")) if (QFile::exists(langPath % QDir::separator() % QtBaseTranslationFormat % langList.at(0) % "_" % langList.at(1) % ".qm")) {
{ if (qtTranslator->load(langPath % QDir::separator() % QtBaseTranslationFormat % langList.at(0) % "_" % langList.at(1) % ".qm")) {
if (qtTranslator->load(langPath % QDir::separator() % QtBaseTranslationFormat % langList.at(0) % "_" % langList.at(1) % ".qm"))
{
#ifdef GTA5SYNC_DEBUG #ifdef GTA5SYNC_DEBUG
qDebug() << "loadLanguageFileSuccess" << QString(langPath % QDir::separator() % QtBaseTranslationFormat % langList.at(0) % "_" % langList.at(1) % ".qm"); qDebug() << "loadLanguageFileSuccess" << QString(langPath % QDir::separator() % QtBaseTranslationFormat % langList.at(0) % "_" % langList.at(1) % ".qm");
#endif #endif
@ -477,10 +450,8 @@ bool TranslationClass::loadQtTranslation_p(const QString &langPath, QTranslator
#ifdef GTA5SYNC_DEBUG #ifdef GTA5SYNC_DEBUG
qDebug() << "loadLanguageFile" << QString(langPath % QDir::separator() % QtBaseTranslationFormat % langList.at(0) % ".qm"); qDebug() << "loadLanguageFile" << QString(langPath % QDir::separator() % QtBaseTranslationFormat % langList.at(0) % ".qm");
#endif #endif
if (QFile::exists(langPath % QDir::separator() % QtBaseTranslationFormat % langList.at(0) % ".qm")) if (QFile::exists(langPath % QDir::separator() % QtBaseTranslationFormat % langList.at(0) % ".qm")) {
{ if (qtTranslator->load(langPath % QDir::separator() % QtBaseTranslationFormat % langList.at(0) % ".qm")) {
if (qtTranslator->load(langPath % QDir::separator() % QtBaseTranslationFormat % langList.at(0) % ".qm"))
{
#ifdef GTA5SYNC_DEBUG #ifdef GTA5SYNC_DEBUG
qDebug() << "loadLanguageFileSuccess" << QString(langPath % QDir::separator() % QtBaseTranslationFormat % langList.at(0) % ".qm"); qDebug() << "loadLanguageFileSuccess" << QString(langPath % QDir::separator() % QtBaseTranslationFormat % langList.at(0) % ".qm");
#endif #endif
@ -488,15 +459,12 @@ bool TranslationClass::loadQtTranslation_p(const QString &langPath, QTranslator
} }
} }
} }
else if (langList.length() == 1) else if (langList.length() == 1) {
{
#ifdef GTA5SYNC_DEBUG #ifdef GTA5SYNC_DEBUG
qDebug() << "loadLanguageFile" << QString(langPath % QDir::separator() % QtBaseTranslationFormat % langList.at(0) % ".qm"); qDebug() << "loadLanguageFile" << QString(langPath % QDir::separator() % QtBaseTranslationFormat % langList.at(0) % ".qm");
#endif #endif
if (QFile::exists(langPath % QDir::separator() % QtBaseTranslationFormat % langList.at(0) % ".qm")) if (QFile::exists(langPath % QDir::separator() % QtBaseTranslationFormat % langList.at(0) % ".qm")) {
{ if (qtTranslator->load(langPath % QDir::separator() % QtBaseTranslationFormat % langList.at(0) % ".qm")) {
if (qtTranslator->load(langPath % QDir::separator() % QtBaseTranslationFormat % langList.at(0) % ".qm"))
{
#ifdef GTA5SYNC_DEBUG #ifdef GTA5SYNC_DEBUG
qDebug() << "loadLanguageFileSuccess" << QString(langPath % QDir::separator() % QtBaseTranslationFormat % langList.at(0) % ".qm"); qDebug() << "loadLanguageFileSuccess" << QString(langPath % QDir::separator() % QtBaseTranslationFormat % langList.at(0) % ".qm");
#endif #endif
@ -515,49 +483,44 @@ bool TranslationClass::isUserLanguageSystem_p()
QString TranslationClass::getCurrentAreaLanguage() QString TranslationClass::getCurrentAreaLanguage()
{ {
const QStringList areaTranslations = listAreaTranslations(); const QStringList areaTranslations = listAreaTranslations();
if (userAreaLanguage == "Auto" || userAreaLanguage.trimmed().isEmpty()) if (userAreaLanguage == "Auto" || userAreaLanguage.trimmed().isEmpty()) {
{ const GameLanguage gameLanguage = AppEnv::getGameLanguage(AppEnv::getGameVersion());
GameLanguage gameLanguage = AppEnv::getGameLanguage(AppEnv::getGameVersion()); if (gameLanguage == GameLanguage::Undefined) {
if (gameLanguage == GameLanguage::Undefined)
{
#ifdef GTA5SYNC_DEBUG #ifdef GTA5SYNC_DEBUG
qDebug() << "autoAreaLanguageModeInterface"; qDebug() << "autoAreaLanguageModeInterface";
#endif #endif
QString langCode = QString(currentLanguage).replace("-", "_"); QString langCode = QString(currentLanguage).replace("-", "_");
if (areaTranslations.contains(langCode)) if (areaTranslations.contains(langCode)) {
{
#ifdef GTA5SYNC_DEBUG #ifdef GTA5SYNC_DEBUG
qDebug() << "autoAreaLanguageSelected" << langCode; qDebug() << "autoAreaLanguageSelected" << langCode;
#endif #endif
return langCode; return langCode;
} }
else if (langCode.contains("_")) else if (langCode.contains("_")) {
{
langCode = langCode.split("_").at(0); langCode = langCode.split("_").at(0);
if (!areaTranslations.contains(langCode)) goto outputDefaultLanguage; if (!areaTranslations.contains(langCode))
goto outputDefaultLanguage;
#ifdef GTA5SYNC_DEBUG #ifdef GTA5SYNC_DEBUG
qDebug() << "autoAreaLanguageSelected" << langCode; qDebug() << "autoAreaLanguageSelected" << langCode;
#endif #endif
return langCode; return langCode;
} }
} }
else else {
{
#ifdef GTA5SYNC_DEBUG #ifdef GTA5SYNC_DEBUG
qDebug() << "autoAreaLanguageModeGame"; qDebug() << "autoAreaLanguageModeGame";
#endif #endif
QString langCode = AppEnv::gameLanguageToString(gameLanguage).replace("-", "_"); QString langCode = AppEnv::gameLanguageToString(gameLanguage).replace("-", "_");
if (areaTranslations.contains(langCode)) if (areaTranslations.contains(langCode)) {
{
#ifdef GTA5SYNC_DEBUG #ifdef GTA5SYNC_DEBUG
qDebug() << "autoAreaLanguageSelected" << langCode; qDebug() << "autoAreaLanguageSelected" << langCode;
#endif #endif
return langCode; return langCode;
} }
else if (langCode.contains("_")) else if (langCode.contains("_")) {
{
langCode = langCode.split("_").at(0); langCode = langCode.split("_").at(0);
if (!areaTranslations.contains(langCode)) goto outputDefaultLanguage; if (!areaTranslations.contains(langCode))
goto outputDefaultLanguage;
#ifdef GTA5SYNC_DEBUG #ifdef GTA5SYNC_DEBUG
qDebug() << "autoAreaLanguageSelected" << langCode; qDebug() << "autoAreaLanguageSelected" << langCode;
#endif #endif
@ -565,17 +528,16 @@ QString TranslationClass::getCurrentAreaLanguage()
} }
} }
} }
else if (areaTranslations.contains(userAreaLanguage)) else if (areaTranslations.contains(userAreaLanguage)) {
{
#ifdef GTA5SYNC_DEBUG #ifdef GTA5SYNC_DEBUG
qDebug() << "userAreaLanguageSelected" << userAreaLanguage; qDebug() << "userAreaLanguageSelected" << userAreaLanguage;
#endif #endif
return userAreaLanguage; return userAreaLanguage;
} }
else if (userAreaLanguage.contains("_")) else if (userAreaLanguage.contains("_")) {
{ const QString langCode = QString(userAreaLanguage).replace("-", "_").split("_").at(0);
QString langCode = QString(userAreaLanguage).replace("-", "_").split("_").at(0); if (!areaTranslations.contains(langCode))
if (!areaTranslations.contains(langCode)) goto outputDefaultLanguage; goto outputDefaultLanguage;
#ifdef GTA5SYNC_DEBUG #ifdef GTA5SYNC_DEBUG
qDebug() << "userAreaLanguageSelected" << langCode; qDebug() << "userAreaLanguageSelected" << langCode;
#endif #endif
@ -600,8 +562,7 @@ bool TranslationClass::isLanguageLoaded()
void TranslationClass::unloadTranslation(QApplication *app) void TranslationClass::unloadTranslation(QApplication *app)
{ {
if (isLangLoaded) if (isLangLoaded) {
{
#ifndef GTA5SYNC_QCONF #ifndef GTA5SYNC_QCONF
app->removeTranslator(&exAppTranslator); app->removeTranslator(&exAppTranslator);
app->removeTranslator(&exQtTranslator); app->removeTranslator(&exQtTranslator);
@ -624,30 +585,21 @@ void TranslationClass::unloadTranslation(QApplication *app)
QString TranslationClass::getCountryCode(QLocale::Country country) QString TranslationClass::getCountryCode(QLocale::Country country)
{ {
QList<QLocale> locales = QLocale::matchingLocales(QLocale::AnyLanguage, const QList<QLocale> locales = QLocale::matchingLocales(QLocale::AnyLanguage, QLocale::AnyScript, country);
QLocale::AnyScript, if (!locales.isEmpty()) {
country); const QStringList localeStrList = locales.at(0).name().split("_");
if (locales.isEmpty()) return QString(); if (localeStrList.length() >= 2) {
QStringList localeStrList = locales.at(0).name().split("_"); return localeStrList.at(1).toLower();
if (localeStrList.length() >= 2) }
{
return localeStrList.at(1).toLower();
}
else
{
return QString();
} }
return QString();
} }
QString TranslationClass::getCountryCode(QLocale locale) QString TranslationClass::getCountryCode(QLocale locale)
{ {
QStringList localeStrList = locale.name().split("_"); QStringList localeStrList = locale.name().split("_");
if (localeStrList.length() >= 2) if (localeStrList.length() >= 2) {
{
return localeStrList.at(1).toLower(); return localeStrList.at(1).toLower();
} }
else return QString();
{
return QString();
}
} }

View File

@ -1,6 +1,6 @@
/***************************************************************************** /*****************************************************************************
* gta5view Grand Theft Auto V Profile Viewer * gta5view Grand Theft Auto V Profile Viewer
* Copyright (C) 2016-2018 Syping * Copyright (C) 2016-2021 Syping
* *
* This program is free software: you can redistribute it and/or modify * This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by * it under the terms of the GNU General Public License as published by
@ -40,14 +40,31 @@
#include <QMessageBox> #include <QMessageBox>
#include <QSettings> #include <QSettings>
#include <QFileInfo> #include <QFileInfo>
#include <QTimer>
#include <QDebug> #include <QDebug>
#include <QFile> #include <QFile>
#include <QDir> #include <QDir>
#include <QMap> #include <QMap>
#ifdef GTA5SYNC_DONATE
#ifdef GTA5SYNC_DONATE_ADDRESSES
#include <QSvgRenderer>
#include <QClipboard>
#include <QPainter>
#include "QrCode.h"
using namespace qrcodegen;
#endif
#endif
#ifdef GTA5SYNC_MOTD
UserInterface::UserInterface(ProfileDatabase *profileDB, CrewDatabase *crewDB, DatabaseThread *threadDB, MessageThread *threadMessage, QWidget *parent) :
QMainWindow(parent), profileDB(profileDB), crewDB(crewDB), threadDB(threadDB), threadMessage(threadMessage),
ui(new Ui::UserInterface)
#else
UserInterface::UserInterface(ProfileDatabase *profileDB, CrewDatabase *crewDB, DatabaseThread *threadDB, QWidget *parent) : UserInterface::UserInterface(ProfileDatabase *profileDB, CrewDatabase *crewDB, DatabaseThread *threadDB, QWidget *parent) :
QMainWindow(parent), profileDB(profileDB), crewDB(crewDB), threadDB(threadDB), QMainWindow(parent), profileDB(profileDB), crewDB(crewDB), threadDB(threadDB),
ui(new Ui::UserInterface) ui(new Ui::UserInterface)
#endif
{ {
ui->setupUi(this); ui->setupUi(this);
contentMode = 0; contentMode = 0;
@ -56,113 +73,244 @@ UserInterface::UserInterface(ProfileDatabase *profileDB, CrewDatabase *crewDB, D
ui->menuProfile->setEnabled(false); ui->menuProfile->setEnabled(false);
ui->actionSelect_profile->setEnabled(false); ui->actionSelect_profile->setEnabled(false);
ui->actionAbout_gta5sync->setIcon(IconLoader::loadingAppIcon()); ui->actionAbout_gta5sync->setIcon(IconLoader::loadingAppIcon());
#ifdef Q_OS_MAC
ui->actionAbout_gta5sync->setText(QApplication::translate("MAC_APPLICATION_MENU", "About %1").arg(GTA5SYNC_APPSTR));
ui->actionOptions->setText(QApplication::translate("MAC_APPLICATION_MENU", "Preferences..."));
#else
ui->actionAbout_gta5sync->setText(tr("&About %1").arg(GTA5SYNC_APPSTR)); ui->actionAbout_gta5sync->setText(tr("&About %1").arg(GTA5SYNC_APPSTR));
#endif
ui->cmdClose->setToolTip(ui->cmdClose->toolTip().arg(GTA5SYNC_APPSTR)); ui->cmdClose->setToolTip(ui->cmdClose->toolTip().arg(GTA5SYNC_APPSTR));
defaultWindowTitle = tr("%2 - %1").arg("%1", GTA5SYNC_APPSTR); defaultWindowTitle = tr("%2 - %1").arg("%1", GTA5SYNC_APPSTR);
this->setWindowTitle(defaultWindowTitle.arg(tr("Select Profile"))); setWindowTitle(defaultWindowTitle.arg(tr("Select Profile")));
QString appVersion = GTA5SYNC_APPVER; QString appVersion = QApplication::applicationVersion();
#ifndef GTA5SYNC_BUILDTYPE_REL const char* literalBuildType = GTA5SYNC_BUILDTYPE;
#ifdef GTA5SYNC_COMMIT #ifdef GTA5SYNC_COMMIT
if (!appVersion.contains("-")) { appVersion = appVersion % "-" % GTA5SYNC_COMMIT; } if ((strcmp(literalBuildType, REL_BUILDTYPE) != 0) && !appVersion.contains("-"))
#endif appVersion = appVersion % "-" % GTA5SYNC_COMMIT;
#endif #endif
ui->labVersion->setText(QString("%1 %2").arg(GTA5SYNC_APPSTR, appVersion)); ui->labVersion->setText(QString("%1 %2").arg(GTA5SYNC_APPSTR, appVersion));
// Set Icon for Close Button // Set Icon for Close Button
if (QIcon::hasThemeIcon("dialog-close")) if (QIcon::hasThemeIcon("dialog-close")) {
{
ui->cmdClose->setIcon(QIcon::fromTheme("dialog-close")); ui->cmdClose->setIcon(QIcon::fromTheme("dialog-close"));
} }
else if (QIcon::hasThemeIcon("gtk-close")) else if (QIcon::hasThemeIcon("gtk-close")) {
{
ui->cmdClose->setIcon(QIcon::fromTheme("gtk-close")); ui->cmdClose->setIcon(QIcon::fromTheme("gtk-close"));
} }
// Set Icon for Reload Button // Set Icon for Reload Button
if (QIcon::hasThemeIcon("view-refresh")) if (QIcon::hasThemeIcon("view-refresh")) {
{
ui->cmdReload->setIcon(QIcon::fromTheme("view-refresh")); ui->cmdReload->setIcon(QIcon::fromTheme("view-refresh"));
} }
else if (QIcon::hasThemeIcon("reload")) else if (QIcon::hasThemeIcon("reload")) {
{
ui->cmdReload->setIcon(QIcon::fromTheme("reload")); ui->cmdReload->setIcon(QIcon::fromTheme("reload"));
} }
// Set Icon for Choose GTA V Folder Menu Item // Set Icon for Choose GTA V Folder Menu Item
if (QIcon::hasThemeIcon("document-open-folder")) if (QIcon::hasThemeIcon("document-open-folder")) {
{
ui->actionSelect_GTA_Folder->setIcon(QIcon::fromTheme("document-open-folder")); ui->actionSelect_GTA_Folder->setIcon(QIcon::fromTheme("document-open-folder"));
} }
else if (QIcon::hasThemeIcon("gtk-directory")) else if (QIcon::hasThemeIcon("gtk-directory")) {
{
ui->actionSelect_GTA_Folder->setIcon(QIcon::fromTheme("gtk-directory")); ui->actionSelect_GTA_Folder->setIcon(QIcon::fromTheme("gtk-directory"));
} }
// Set Icon for Open File Menu Item // Set Icon for Open File Menu Item
if (QIcon::hasThemeIcon("document-open")) if (QIcon::hasThemeIcon("document-open")) {
{
ui->actionOpen_File->setIcon(QIcon::fromTheme("document-open")); ui->actionOpen_File->setIcon(QIcon::fromTheme("document-open"));
} }
// Set Icon for Close Profile Menu Item // Set Icon for Close Profile Menu Item
if (QIcon::hasThemeIcon("dialog-close")) if (QIcon::hasThemeIcon("dialog-close")) {
{
ui->actionSelect_profile->setIcon(QIcon::fromTheme("dialog-close")); ui->actionSelect_profile->setIcon(QIcon::fromTheme("dialog-close"));
} }
else if (QIcon::hasThemeIcon("gtk-close")) else if (QIcon::hasThemeIcon("gtk-close")) {
{
ui->actionSelect_profile->setIcon(QIcon::fromTheme("gtk-close")); ui->actionSelect_profile->setIcon(QIcon::fromTheme("gtk-close"));
} }
// Set Icon for Exit Menu Item // Set Icon for Exit Menu Item
if (QIcon::hasThemeIcon("application-exit")) if (QIcon::hasThemeIcon("application-exit")) {
{
#ifndef Q_OS_MACOS // Setting icon for exit/quit lead to a crash in Mac OS X #ifndef Q_OS_MACOS // Setting icon for exit/quit lead to a crash in Mac OS X
ui->actionExit->setIcon(QIcon::fromTheme("application-exit")); ui->actionExit->setIcon(QIcon::fromTheme("application-exit"));
#endif #endif
} }
// Set Icon for Preferences Menu Item // Set Icon for Preferences Menu Item
if (QIcon::hasThemeIcon("preferences-system")) if (QIcon::hasThemeIcon("preferences-system")) {
{
#ifndef Q_OS_MACOS // Setting icon for preferences/settings/options lead to a crash in Mac OS X #ifndef Q_OS_MACOS // Setting icon for preferences/settings/options lead to a crash in Mac OS X
ui->actionOptions->setIcon(QIcon::fromTheme("preferences-system")); ui->actionOptions->setIcon(QIcon::fromTheme("preferences-system"));
#endif #endif
} }
else if (QIcon::hasThemeIcon("configure")) else if (QIcon::hasThemeIcon("configure")) {
{
#ifndef Q_OS_MACOS // Setting icon for preferences/settings/options lead to a crash in Mac OS X #ifndef Q_OS_MACOS // Setting icon for preferences/settings/options lead to a crash in Mac OS X
ui->actionOptions->setIcon(QIcon::fromTheme("configure")); ui->actionOptions->setIcon(QIcon::fromTheme("configure"));
#endif #endif
} }
// Set Icon for Profile Import Menu Item // Set Icon for Profile Import Menu Item
if (QIcon::hasThemeIcon("document-import")) if (QIcon::hasThemeIcon("document-import")) {
{
ui->action_Import->setIcon(QIcon::fromTheme("document-import")); ui->action_Import->setIcon(QIcon::fromTheme("document-import"));
} }
else if (QIcon::hasThemeIcon("document-open")) else if (QIcon::hasThemeIcon("document-open")) {
{
ui->action_Import->setIcon(QIcon::fromTheme("document-open")); ui->action_Import->setIcon(QIcon::fromTheme("document-open"));
} }
// Set Icon for Profile Export Menu Item // Set Icon for Profile Export Menu Item
if (QIcon::hasThemeIcon("document-export")) if (QIcon::hasThemeIcon("document-export")) {
{
ui->actionExport_selected->setIcon(QIcon::fromTheme("document-export")); ui->actionExport_selected->setIcon(QIcon::fromTheme("document-export"));
} }
else if (QIcon::hasThemeIcon("document-save")) else if (QIcon::hasThemeIcon("document-save")) {
{
ui->actionExport_selected->setIcon(QIcon::fromTheme("document-save")); ui->actionExport_selected->setIcon(QIcon::fromTheme("document-save"));
} }
// Set Icon for Profile Remove Menu Item // Set Icon for Profile Remove Menu Item
if (QIcon::hasThemeIcon("remove")) if (QIcon::hasThemeIcon("remove")) {
{
ui->actionDelete_selected->setIcon(QIcon::fromTheme("remove")); ui->actionDelete_selected->setIcon(QIcon::fromTheme("remove"));
} }
#ifdef GTA5SYNC_DONATE
#ifdef GTA5SYNC_DONATE_ADDRESSES
donateAction = new QAction(tr("&Donate"), this);
if (QIcon::hasThemeIcon("help-donate")) {
donateAction->setIcon(QIcon::fromTheme("help-donate"));
}
else if (QIcon::hasThemeIcon("taxes-finances")) {
donateAction->setIcon(QIcon::fromTheme("taxes-finances"));
}
else {
donateAction->setIcon(QIcon(":/img/donate.svgz"));
}
ui->menuHelp->insertAction(ui->actionAbout_gta5sync, donateAction);
QObject::connect(donateAction, &QAction::triggered, this, [=](){
QDialog *donateDialog = new QDialog(this);
donateDialog->setWindowTitle(QString("%1 - %2").arg(GTA5SYNC_APPSTR, tr("Donate")));
#if QT_VERSION >= 0x050900
donateDialog->setWindowFlag(Qt::WindowContextHelpButtonHint, false);
#else
donateDialog->setWindowFlags(donateDialog->windowFlags()^Qt::WindowContextHelpButtonHint);
#endif
QVBoxLayout *donateLayout = new QVBoxLayout;
donateDialog->setLayout(donateLayout);
QLabel *methodsLabel = new QLabel(QString("<b>%1</b>").arg(tr("Donation methods").toHtmlEscaped()), donateDialog);
methodsLabel->setWordWrap(true);
donateLayout->addWidget(methodsLabel);
QHBoxLayout *currencyLayout = new QHBoxLayout;
donateLayout->addLayout(currencyLayout);
const QStringList addressList = QString::fromUtf8(GTA5SYNC_DONATE_ADDRESSES).split(',');
for (const QString &address : addressList) {
const QStringList addressList = address.split(':');
if (addressList.length() == 2) {
const QString currency = addressList.at(0);
const QString address = addressList.at(1);
QString currencyStr = currency;
const QString strPath = QString(":/donate/%1.str").arg(currency);
if (QFile::exists(strPath)) {
QFile strFile(strPath);
if (strFile.open(QIODevice::ReadOnly)) {
currencyStr = QString::fromUtf8(strFile.readAll());
strFile.close();
}
}
const QString iconPath = QString(":/donate/%1.svgz").arg(currency);
QPushButton *currencyButton = new QPushButton(currencyStr, donateDialog);
currencyButton->setToolTip(currencyStr);
if (QFile::exists(iconPath)) {
currencyButton->setIconSize(QSize(32, 32));
currencyButton->setIcon(QIcon(iconPath));
}
currencyLayout->addWidget(currencyButton);
QObject::connect(currencyButton, &QPushButton::pressed, donateDialog, [=](){
QDialog *addressDialog = new QDialog(donateDialog);
addressDialog->setWindowTitle(currencyStr);
#if QT_VERSION >= 0x050900
addressDialog->setWindowFlag(Qt::WindowContextHelpButtonHint, false);
#else
addressDialog->setWindowFlags(donateDialog->windowFlags()^Qt::WindowContextHelpButtonHint);
#endif
QVBoxLayout *addressLayout = new QVBoxLayout;
addressDialog->setLayout(addressLayout);
QLabel *addressLabel = new QLabel(address, addressDialog);
addressLabel->setAlignment(Qt::AlignCenter);
addressLabel->setTextFormat(Qt::PlainText);
addressLabel->setTextInteractionFlags(Qt::TextSelectableByMouse);
addressLayout->addWidget(addressLabel);
QHBoxLayout *qrLayout = new QHBoxLayout;
qrLayout->addSpacerItem(new QSpacerItem(0, 0, QSizePolicy::Expanding, QSizePolicy::Minimum));
QrCode qr = QrCode::encodeText(address.toUtf8().constData(), QrCode::Ecc::MEDIUM);
const std::string svgString = qr.toSvgString(0);
QSvgRenderer svgRenderer(QByteArray::fromRawData(svgString.c_str(), svgString.size()));
qreal screenRatioPR = AppEnv::screenRatioPR();
const QSize widgetSize = QSize(200, 200);
const QSize pixmapSize = widgetSize * screenRatioPR;
QPixmap qrPixmap(pixmapSize);
qrPixmap.fill(Qt::white);
QPainter qrPainter(&qrPixmap);
svgRenderer.render(&qrPainter, QRectF(QPointF(0, 0), pixmapSize));
qrPainter.end();
#if QT_VERSION >= 0x050600
qrPixmap.setDevicePixelRatio(screenRatioPR);
#endif
QLabel *qrLabel = new QLabel(addressDialog);
qrLabel->setFixedSize(widgetSize);
qrLabel->setPixmap(qrPixmap);
qrLayout->addWidget(qrLabel);
qrLayout->addSpacerItem(new QSpacerItem(0, 0, QSizePolicy::Expanding, QSizePolicy::Minimum));
addressLayout->addLayout(qrLayout);
QHBoxLayout *buttonLayout = new QHBoxLayout;
buttonLayout->addSpacerItem(new QSpacerItem(0, 0, QSizePolicy::Expanding, QSizePolicy::Minimum));
QPushButton *copyAddressButton = new QPushButton(tr("&Copy"), addressDialog);
if (QIcon::hasThemeIcon("edit-copy")) {
copyAddressButton->setIcon(QIcon::fromTheme("edit-copy"));
}
QObject::connect(copyAddressButton, &QPushButton::pressed, addressDialog, [=](){
QApplication::clipboard()->setText(address);
});
buttonLayout->addWidget(copyAddressButton);
QPushButton *closeButton = new QPushButton(tr("&Close"), addressDialog);
if (QIcon::hasThemeIcon("dialog-close")) {
closeButton->setIcon(QIcon::fromTheme("dialog-close"));
}
else if (QIcon::hasThemeIcon("gtk-close")) {
closeButton->setIcon(QIcon::fromTheme("gtk-close"));
}
closeButton->setDefault(true);
buttonLayout->addWidget(closeButton);
buttonLayout->addSpacerItem(new QSpacerItem(0, 0, QSizePolicy::Expanding, QSizePolicy::Minimum));
addressLayout->addLayout(buttonLayout);
QObject::connect(closeButton, &QPushButton::clicked, addressDialog, &QDialog::accept);
QObject::connect(addressDialog, &QDialog::finished, addressDialog, &QDialog::deleteLater);
QTimer::singleShot(0, addressDialog, [=](){
addressDialog->setFocus();
});
addressDialog->open();
addressDialog->setFixedSize(addressDialog->size());
});
}
}
QHBoxLayout *buttonLayout = new QHBoxLayout;
buttonLayout->addSpacerItem(new QSpacerItem(0, 0, QSizePolicy::Expanding, QSizePolicy::Minimum));
QPushButton *closeButton = new QPushButton(donateDialog);
closeButton->setText(tr("&Close"));
if (QIcon::hasThemeIcon("dialog-close")) {
closeButton->setIcon(QIcon::fromTheme("dialog-close"));
}
else if (QIcon::hasThemeIcon("gtk-close")) {
closeButton->setIcon(QIcon::fromTheme("gtk-close"));
}
closeButton->setDefault(true);
buttonLayout->addWidget(closeButton);
donateLayout->addLayout(buttonLayout);
QObject::connect(closeButton, &QPushButton::clicked, donateDialog, &QDialog::accept);
QObject::connect(donateDialog, &QDialog::finished, donateDialog, &QDialog::deleteLater);
QTimer::singleShot(0, donateDialog, [=](){
donateDialog->setFocus();
});
donateDialog->open();
donateDialog->setFixedSize(donateDialog->size());
});
#endif
#endif
// DPI calculation // DPI calculation
qreal screenRatio = AppEnv::screenRatio(); qreal screenRatio = AppEnv::screenRatio();
#ifndef Q_QS_ANDROID #ifndef Q_QS_ANDROID
@ -172,30 +320,26 @@ UserInterface::UserInterface(ProfileDatabase *profileDB, CrewDatabase *crewDB, D
ui->vlUserInterface->setContentsMargins(9 * screenRatio, 9 * screenRatio, 9 * screenRatio, 9 * screenRatio); ui->vlUserInterface->setContentsMargins(9 * screenRatio, 9 * screenRatio, 9 * screenRatio, 9 * screenRatio);
} }
void UserInterface::setupDirEnv() void UserInterface::setupDirEnv(bool showFolderDialog)
{ {
// settings init // settings init
QSettings settings(GTA5SYNC_APPVENDOR, GTA5SYNC_APPSTR); QSettings settings(GTA5SYNC_APPVENDOR, GTA5SYNC_APPSTR);
bool folderExists; bool folderExists;
GTAV_Folder = AppEnv::getGameFolder(&folderExists); GTAV_Folder = AppEnv::getGameFolder(&folderExists);
if (folderExists) if (folderExists) {
{
QDir::setCurrent(GTAV_Folder); QDir::setCurrent(GTAV_Folder);
} }
else else if (showFolderDialog) {
{
GTAV_Folder = QFileDialog::getExistingDirectory(this, tr("Select GTA V Folder..."), StandardPaths::documentsLocation(), QFileDialog::ShowDirsOnly); GTAV_Folder = QFileDialog::getExistingDirectory(this, tr("Select GTA V Folder..."), StandardPaths::documentsLocation(), QFileDialog::ShowDirsOnly);
if (QFileInfo(GTAV_Folder).exists()) if (QDir(GTAV_Folder).exists()) {
{
folderExists = true; folderExists = true;
QDir::setCurrent(GTAV_Folder); QDir::setCurrent(GTAV_Folder);
AppEnv::setGameFolder(GTAV_Folder); AppEnv::setGameFolder(GTAV_Folder);
// First time folder selection save // First time folder selection save
settings.beginGroup("dir"); settings.beginGroup("dir");
if (settings.value("dir", "").toString().isEmpty()) if (settings.value("dir", "").toString().isEmpty()) {
{
settings.setValue("dir", GTAV_Folder); settings.setValue("dir", GTAV_Folder);
} }
settings.endGroup(); settings.endGroup();
@ -206,15 +350,15 @@ void UserInterface::setupDirEnv()
settings.beginGroup("Profile"); settings.beginGroup("Profile");
QString defaultProfile = settings.value("Default", "").toString(); QString defaultProfile = settings.value("Default", "").toString();
bool contentModeOk; contentMode = settings.value("ContentMode", 0).toInt();
contentMode = settings.value("ContentMode", 0).toInt(&contentModeOk); if (contentMode == 1) {
if (contentMode != 0 && contentMode != 1 && contentMode != 2) contentMode = 21;
{ }
contentMode = 0; else if (contentMode != 10 && contentMode != 11 && contentMode != 20 && contentMode != 21) {
contentMode = 20;
} }
if (folderExists) if (folderExists) {
{
QDir GTAV_ProfilesDir; QDir GTAV_ProfilesDir;
GTAV_ProfilesFolder = GTAV_Folder % "/Profiles"; GTAV_ProfilesFolder = GTAV_Folder % "/Profiles";
GTAV_ProfilesDir.setPath(GTAV_ProfilesFolder); GTAV_ProfilesDir.setPath(GTAV_ProfilesFolder);
@ -222,17 +366,14 @@ void UserInterface::setupDirEnv()
GTAV_Profiles = GTAV_ProfilesDir.entryList(QDir::Dirs | QDir::NoDotAndDotDot, QDir::NoSort); GTAV_Profiles = GTAV_ProfilesDir.entryList(QDir::Dirs | QDir::NoDotAndDotDot, QDir::NoSort);
setupProfileUi(); setupProfileUi();
if (GTAV_Profiles.length() == 1) if (GTAV_Profiles.length() == 1) {
{
openProfile(GTAV_Profiles.at(0)); openProfile(GTAV_Profiles.at(0));
} }
else if(GTAV_Profiles.contains(defaultProfile)) else if(GTAV_Profiles.contains(defaultProfile)) {
{
openProfile(defaultProfile); openProfile(defaultProfile);
} }
} }
else else {
{
GTAV_Profiles = QStringList(); GTAV_Profiles = QStringList();
setupProfileUi(); setupProfileUi();
} }
@ -242,8 +383,7 @@ void UserInterface::setupDirEnv()
void UserInterface::setupProfileUi() void UserInterface::setupProfileUi()
{ {
qreal screenRatio = AppEnv::screenRatio(); qreal screenRatio = AppEnv::screenRatio();
if (GTAV_Profiles.isEmpty()) if (GTAV_Profiles.isEmpty()) {
{
QPushButton *changeDirBtn = new QPushButton(tr("Select &GTA V Folder..."), ui->swSelection); QPushButton *changeDirBtn = new QPushButton(tr("Select &GTA V Folder..."), ui->swSelection);
changeDirBtn->setObjectName("cmdChangeDir"); changeDirBtn->setObjectName("cmdChangeDir");
changeDirBtn->setMinimumSize(0, 40 * screenRatio); changeDirBtn->setMinimumSize(0, 40 * screenRatio);
@ -253,8 +393,7 @@ void UserInterface::setupProfileUi()
QObject::connect(changeDirBtn, SIGNAL(clicked(bool)), this, SLOT(changeFolder_clicked())); QObject::connect(changeDirBtn, SIGNAL(clicked(bool)), this, SLOT(changeFolder_clicked()));
} }
else for (QString GTAV_Profile : GTAV_Profiles) else for (const QString &GTAV_Profile : GTAV_Profiles) {
{
QPushButton *profileBtn = new QPushButton(GTAV_Profile, ui->swSelection); QPushButton *profileBtn = new QPushButton(GTAV_Profile, ui->swSelection);
profileBtn->setObjectName(GTAV_Profile); profileBtn->setObjectName(GTAV_Profile);
profileBtn->setMinimumSize(0, 40 * screenRatio); profileBtn->setMinimumSize(0, 40 * screenRatio);
@ -274,8 +413,7 @@ void UserInterface::changeFolder_clicked()
void UserInterface::on_cmdReload_clicked() void UserInterface::on_cmdReload_clicked()
{ {
for (QPushButton *profileBtn : profileBtns) for (QPushButton *profileBtn : profileBtns) {
{
ui->vlButtons->removeWidget(profileBtn); ui->vlButtons->removeWidget(profileBtn);
delete profileBtn; delete profileBtn;
} }
@ -301,16 +439,15 @@ void UserInterface::openProfile(const QString &profileName_)
profileUI->setupProfileInterface(); profileUI->setupProfileInterface();
QObject::connect(profileUI, SIGNAL(profileClosed()), this, SLOT(closeProfile())); QObject::connect(profileUI, SIGNAL(profileClosed()), this, SLOT(closeProfile()));
QObject::connect(profileUI, SIGNAL(profileLoaded()), this, SLOT(profileLoaded())); QObject::connect(profileUI, SIGNAL(profileLoaded()), this, SLOT(profileLoaded()));
this->setWindowTitle(defaultWindowTitle.arg(profileName)); setWindowTitle(defaultWindowTitle.arg(profileName));
} }
void UserInterface::closeProfile() void UserInterface::closeProfile()
{ {
if (profileOpen) if (profileOpen) {
{
closeProfile_p(); closeProfile_p();
} }
this->setWindowTitle(defaultWindowTitle.arg(tr("Select Profile"))); setWindowTitle(defaultWindowTitle.arg(tr("Select Profile")));
} }
void UserInterface::closeProfile_p() void UserInterface::closeProfile_p()
@ -328,17 +465,18 @@ void UserInterface::closeProfile_p()
void UserInterface::closeEvent(QCloseEvent *ev) void UserInterface::closeEvent(QCloseEvent *ev)
{ {
Q_UNUSED(ev) Q_UNUSED(ev)
#ifdef GTA5SYNC_MOTD
threadMessage->terminateThread();
#else
threadDB->terminateThread(); threadDB->terminateThread();
#endif
} }
UserInterface::~UserInterface() UserInterface::~UserInterface()
{ {
if (profileOpen) if (profileOpen)
{
closeProfile_p(); closeProfile_p();
} for (QPushButton *profileBtn : profileBtns) {
for (QPushButton *profileBtn : profileBtns)
{
delete profileBtn; delete profileBtn;
} }
profileBtns.clear(); profileBtns.clear();
@ -347,7 +485,7 @@ UserInterface::~UserInterface()
void UserInterface::on_actionExit_triggered() void UserInterface::on_actionExit_triggered()
{ {
this->close(); close();
} }
void UserInterface::on_actionSelect_profile_triggered() void UserInterface::on_actionSelect_profile_triggered()
@ -385,33 +523,25 @@ void UserInterface::profileLoaded()
void UserInterface::on_actionSelect_all_triggered() void UserInterface::on_actionSelect_all_triggered()
{ {
if (profileOpen) if (profileOpen)
{
profileUI->selectAllWidgets(); profileUI->selectAllWidgets();
}
} }
void UserInterface::on_actionDeselect_all_triggered() void UserInterface::on_actionDeselect_all_triggered()
{ {
if (profileOpen) if (profileOpen)
{
profileUI->deselectAllWidgets(); profileUI->deselectAllWidgets();
}
} }
void UserInterface::on_actionExport_selected_triggered() void UserInterface::on_actionExport_selected_triggered()
{ {
if (profileOpen) if (profileOpen)
{
profileUI->exportSelected(); profileUI->exportSelected();
}
} }
void UserInterface::on_actionDelete_selected_triggered() void UserInterface::on_actionDelete_selected_triggered()
{ {
if (profileOpen) if (profileOpen)
{
profileUI->deleteSelected(); profileUI->deleteSelected();
}
} }
void UserInterface::on_actionOptions_triggered() void UserInterface::on_actionOptions_triggered()
@ -436,9 +566,7 @@ void UserInterface::on_actionOptions_triggered()
void UserInterface::on_action_Import_triggered() void UserInterface::on_action_Import_triggered()
{ {
if (profileOpen) if (profileOpen)
{
profileUI->importFiles(); profileUI->importFiles();
}
} }
void UserInterface::on_actionOpen_File_triggered() void UserInterface::on_actionOpen_File_triggered()
@ -452,7 +580,11 @@ fileDialogPreOpen:
fileDialog.setViewMode(QFileDialog::Detail); fileDialog.setViewMode(QFileDialog::Detail);
fileDialog.setAcceptMode(QFileDialog::AcceptOpen); fileDialog.setAcceptMode(QFileDialog::AcceptOpen);
fileDialog.setOption(QFileDialog::DontUseNativeDialog, false); fileDialog.setOption(QFileDialog::DontUseNativeDialog, false);
#if QT_VERSION >= 0x050900
fileDialog.setWindowFlag(Qt::WindowContextHelpButtonHint, false);
#else
fileDialog.setWindowFlags(fileDialog.windowFlags()^Qt::WindowContextHelpButtonHint); fileDialog.setWindowFlags(fileDialog.windowFlags()^Qt::WindowContextHelpButtonHint);
#endif
fileDialog.setWindowTitle(tr("Open File...")); fileDialog.setWindowTitle(tr("Open File..."));
QStringList filters; QStringList filters;
@ -469,11 +601,9 @@ fileDialogPreOpen:
fileDialog.setDirectory(settings.value("OpenDialogDirectory", StandardPaths::documentsLocation()).toString()); fileDialog.setDirectory(settings.value("OpenDialogDirectory", StandardPaths::documentsLocation()).toString());
fileDialog.restoreGeometry(settings.value("OpenDialogGeometry","").toByteArray()); fileDialog.restoreGeometry(settings.value("OpenDialogGeometry","").toByteArray());
if (fileDialog.exec()) if (fileDialog.exec()) {
{
QStringList selectedFiles = fileDialog.selectedFiles(); QStringList selectedFiles = fileDialog.selectedFiles();
if (selectedFiles.length() == 1) if (selectedFiles.length() == 1) {
{
QString selectedFile = selectedFiles.at(0); QString selectedFile = selectedFiles.at(0);
if (!openFile(selectedFile, true)) goto fileDialogPreOpen; if (!openFile(selectedFile, true)) goto fileDialogPreOpen;
} }
@ -487,68 +617,61 @@ fileDialogPreOpen:
bool UserInterface::openFile(QString selectedFile, bool warn) bool UserInterface::openFile(QString selectedFile, bool warn)
{ {
QString selectedFileName = QFileInfo(selectedFile).fileName(); QString selectedFileName = QFileInfo(selectedFile).fileName();
if (QFile::exists(selectedFile)) if (QFile::exists(selectedFile)) {
{ if (selectedFileName.left(4) == "PGTA" || selectedFileName.right(4) == ".g5e") {
if (selectedFileName.left(4) == "PGTA" || selectedFileName.right(4) == ".g5e")
{
SnapmaticPicture *picture = new SnapmaticPicture(selectedFile); SnapmaticPicture *picture = new SnapmaticPicture(selectedFile);
if (picture->readingPicture()) if (picture->readingPicture()) {
{
openSnapmaticFile(picture); openSnapmaticFile(picture);
delete picture; delete picture;
return true; return true;
} }
else else {
{ if (warn)
if (warn) QMessageBox::warning(this, tr("Open File"), ProfileInterface::tr("Failed to read Snapmatic picture")); QMessageBox::warning(this, tr("Open File"), ProfileInterface::tr("Failed to read Snapmatic picture"));
delete picture; delete picture;
return false; return false;
} }
} }
else if (selectedFileName.left(4) == "SGTA") else if (selectedFileName.left(4) == "SGTA") {
{
SavegameData *savegame = new SavegameData(selectedFile); SavegameData *savegame = new SavegameData(selectedFile);
if (savegame->readingSavegame()) if (savegame->readingSavegame()) {
{
openSavegameFile(savegame); openSavegameFile(savegame);
delete savegame; delete savegame;
return true; return true;
} }
else else {
{ if (warn)
if (warn) QMessageBox::warning(this, tr("Open File"), ProfileInterface::tr("Failed to read Savegame file")); QMessageBox::warning(this, tr("Open File"), ProfileInterface::tr("Failed to read Savegame file"));
delete savegame; delete savegame;
return false; return false;
} }
} }
else else {
{
SnapmaticPicture *picture = new SnapmaticPicture(selectedFile); SnapmaticPicture *picture = new SnapmaticPicture(selectedFile);
SavegameData *savegame = new SavegameData(selectedFile); SavegameData *savegame = new SavegameData(selectedFile);
if (picture->readingPicture()) if (picture->readingPicture()) {
{
delete savegame; delete savegame;
openSnapmaticFile(picture); openSnapmaticFile(picture);
delete picture; delete picture;
return true; return true;
} }
else if (savegame->readingSavegame()) else if (savegame->readingSavegame()) {
{
delete picture; delete picture;
openSavegameFile(savegame); openSavegameFile(savegame);
delete savegame; delete savegame;
return true; return true;
} }
else else {
{
delete savegame; delete savegame;
delete picture; delete picture;
if (warn) QMessageBox::warning(this, tr("Open File"), tr("Can't open %1 because of not valid file format").arg("\""+selectedFileName+"\"")); if (warn)
QMessageBox::warning(this, tr("Open File"), tr("Can't open %1 because of not valid file format").arg("\""+selectedFileName+"\""));
return false; return false;
} }
} }
} }
if (warn) QMessageBox::warning(this, tr("Open File"), ProfileInterface::tr("No valid file is selected")); if (warn)
QMessageBox::warning(this, tr("Open File"), ProfileInterface::tr("No valid file is selected"));
return false; return false;
} }
@ -559,7 +682,8 @@ void UserInterface::openSnapmaticFile(SnapmaticPicture *picture)
picDialog.setModal(true); picDialog.setModal(true);
int crewID = picture->getSnapmaticProperties().crewID; int crewID = picture->getSnapmaticProperties().crewID;
if (crewID != 0) { crewDB->addCrew(crewID); } if (crewID != 0)
crewDB->addCrew(crewID);
QObject::connect(threadDB, SIGNAL(crewNameUpdated()), &picDialog, SLOT(crewNameUpdated())); QObject::connect(threadDB, SIGNAL(crewNameUpdated()), &picDialog, SLOT(crewNameUpdated()));
QObject::connect(threadDB, SIGNAL(playerNameUpdated()), &picDialog, SLOT(playerNameUpdated())); QObject::connect(threadDB, SIGNAL(playerNameUpdated()), &picDialog, SLOT(playerNameUpdated()));
@ -592,24 +716,139 @@ void UserInterface::openSavegameFile(SavegameData *savegame)
void UserInterface::settingsApplied(int _contentMode, bool languageChanged) void UserInterface::settingsApplied(int _contentMode, bool languageChanged)
{ {
if (languageChanged) if (languageChanged) {
{
retranslateUi(); retranslateUi();
} }
contentMode = _contentMode; contentMode = _contentMode;
if (profileOpen) if (profileOpen) {
{
profileUI->settingsApplied(contentMode, languageChanged); profileUI->settingsApplied(contentMode, languageChanged);
} }
} }
#ifdef GTA5SYNC_MOTD
void UserInterface::messagesArrived(const QJsonObject &object)
{
QSettings settings(GTA5SYNC_APPVENDOR, GTA5SYNC_APPSTR);
settings.beginGroup("Messages");
QJsonObject::const_iterator it = object.constBegin();
QJsonObject::const_iterator end = object.constEnd();
QStringList messages;
while (it != end) {
const QString key = it.key();
const QJsonValue value = it.value();
bool uintOk;
uint messageId = key.toUInt(&uintOk);
if (uintOk && value.isString()) {
const QString valueStr = value.toString();
settings.setValue(QString::number(messageId), valueStr);
messages << valueStr;
}
it++;
}
settings.endGroup();
if (!messages.isEmpty())
showMessages(messages);
}
void UserInterface::showMessages(const QStringList messages)
{
QDialog *messageDialog = new QDialog(this);
messageDialog->setWindowTitle(tr("%1 - Messages").arg(GTA5SYNC_APPSTR));
#if QT_VERSION >= 0x050900
messageDialog->setWindowFlag(Qt::WindowContextHelpButtonHint, false);
#else
messageDialog->setWindowFlags(messageDialog->windowFlags()^Qt::WindowContextHelpButtonHint);
#endif
QVBoxLayout *messageLayout = new QVBoxLayout;
messageDialog->setLayout(messageLayout);
QStackedWidget *stackWidget = new QStackedWidget(messageDialog);
for (const QString message : messages) {
QLabel *messageLabel = new QLabel(messageDialog);
messageLabel->setText(message);
messageLabel->setWordWrap(true);
stackWidget->addWidget(messageLabel);
}
messageLayout->addWidget(stackWidget);
QHBoxLayout *buttonLayout = new QHBoxLayout;
QPushButton *backButton = new QPushButton(messageDialog);
QPushButton *nextButton = new QPushButton(messageDialog);
if (QIcon::hasThemeIcon("go-previous") && QIcon::hasThemeIcon("go-next") && QIcon::hasThemeIcon("list-add")) {
backButton->setIcon(QIcon::fromTheme("go-previous"));
nextButton->setIcon(QIcon::fromTheme("go-next"));
}
else {
backButton->setIcon(QIcon(AppEnv::getImagesFolder() % "/back.svgz"));
nextButton->setIcon(QIcon(AppEnv::getImagesFolder() % "/next.svgz"));
}
backButton->setEnabled(false);
if (stackWidget->count() <= 1) {
nextButton->setEnabled(false);
}
buttonLayout->addWidget(backButton);
buttonLayout->addWidget(nextButton);
buttonLayout->addSpacerItem(new QSpacerItem(0, 0, QSizePolicy::Expanding, QSizePolicy::Minimum));
QPushButton *closeButton = new QPushButton(messageDialog);
closeButton->setText(tr("&Close"));
if (QIcon::hasThemeIcon("dialog-close")) {
closeButton->setIcon(QIcon::fromTheme("dialog-close"));
}
else if (QIcon::hasThemeIcon("gtk-close")) {
closeButton->setIcon(QIcon::fromTheme("gtk-close"));
}
buttonLayout->addWidget(closeButton);
messageLayout->addLayout(buttonLayout);
QObject::connect(backButton, &QPushButton::clicked, [stackWidget,backButton,nextButton,closeButton]() {
int index = stackWidget->currentIndex();
if (index > 0) {
index--;
stackWidget->setCurrentIndex(index);
nextButton->setEnabled(true);
if (index > 0) {
backButton->setEnabled(true);
}
else {
backButton->setEnabled(false);
closeButton->setFocus();
}
}
});
QObject::connect(nextButton, &QPushButton::clicked, [stackWidget,backButton,nextButton,closeButton]() {
int index = stackWidget->currentIndex();
if (index < stackWidget->count()-1) {
index++;
stackWidget->setCurrentIndex(index);
backButton->setEnabled(true);
if (index < stackWidget->count()-1) {
nextButton->setEnabled(true);
}
else {
nextButton->setEnabled(false);
closeButton->setFocus();
}
}
});
QObject::connect(closeButton, &QPushButton::clicked, messageDialog, &QDialog::accept);
QObject::connect(messageDialog, &QDialog::finished, messageDialog, &QDialog::deleteLater);
QTimer::singleShot(0, closeButton, [=](){
closeButton->setFocus();
});
messageDialog->show();
}
void UserInterface::updateCacheId(uint cacheId)
{
QSettings settings(GTA5SYNC_APPVENDOR, GTA5SYNC_APPSTR);
settings.beginGroup("Messages");
settings.setValue("CacheId", cacheId);
settings.endGroup();
}
#endif
void UserInterface::on_actionSelect_GTA_Folder_triggered() void UserInterface::on_actionSelect_GTA_Folder_triggered()
{ {
QString GTAV_Folder_Temp = QFileDialog::getExistingDirectory(this, tr("Select GTA V Folder..."), StandardPaths::documentsLocation(), QFileDialog::ShowDirsOnly); QString GTAV_Folder_Temp = QFileDialog::getExistingDirectory(this, tr("Select GTA V Folder..."), StandardPaths::documentsLocation(), QFileDialog::ShowDirsOnly);
if (QFileInfo(GTAV_Folder_Temp).exists()) if (QDir(GTAV_Folder_Temp).exists()) {
{ if (profileOpen) {
if (profileOpen)
{
closeProfile_p(); closeProfile_p();
} }
GTAV_Folder = GTAV_Folder_Temp; GTAV_Folder = GTAV_Folder_Temp;
@ -622,37 +861,41 @@ void UserInterface::on_actionSelect_GTA_Folder_triggered()
void UserInterface::on_action_Enable_In_game_triggered() void UserInterface::on_action_Enable_In_game_triggered()
{ {
if (profileOpen) if (profileOpen)
{
profileUI->enableSelected(); profileUI->enableSelected();
}
} }
void UserInterface::on_action_Disable_In_game_triggered() void UserInterface::on_action_Disable_In_game_triggered()
{ {
if (profileOpen) if (profileOpen)
{
profileUI->disableSelected(); profileUI->disableSelected();
}
} }
void UserInterface::retranslateUi() void UserInterface::retranslateUi()
{ {
ui->retranslateUi(this); ui->retranslateUi(this);
ui->actionAbout_gta5sync->setText(tr("&About %1").arg(GTA5SYNC_APPSTR)); #ifdef GTA5SYNC_DONATE
QString appVersion = GTA5SYNC_APPVER; #ifdef GTA5SYNC_DONATE_ADDRESSES
#ifndef GTA5SYNC_BUILDTYPE_REL donateAction->setText(tr("&Donate"));
#ifdef GTA5SYNC_COMMIT
if (!appVersion.contains("-")) { appVersion = appVersion % "-" % GTA5SYNC_COMMIT; }
#endif #endif
#endif
#ifdef Q_OS_MAC
ui->actionAbout_gta5sync->setText(QApplication::translate("MAC_APPLICATION_MENU", "About %1").arg(GTA5SYNC_APPSTR));
ui->actionOptions->setText(QApplication::translate("MAC_APPLICATION_MENU", "Preferences..."));
#else
ui->actionAbout_gta5sync->setText(tr("&About %1").arg(GTA5SYNC_APPSTR));
#endif
QString appVersion = QApplication::applicationVersion();
const char* literalBuildType = GTA5SYNC_BUILDTYPE;
#ifdef GTA5SYNC_COMMIT
if ((strcmp(literalBuildType, REL_BUILDTYPE) != 0) && !appVersion.contains("-"))
appVersion = appVersion % "-" % GTA5SYNC_COMMIT;
#endif #endif
ui->labVersion->setText(QString("%1 %2").arg(GTA5SYNC_APPSTR, appVersion)); ui->labVersion->setText(QString("%1 %2").arg(GTA5SYNC_APPSTR, appVersion));
if (profileOpen) if (profileOpen) {
{ setWindowTitle(defaultWindowTitle.arg(profileName));
this->setWindowTitle(defaultWindowTitle.arg(profileName));
} }
else else {
{ setWindowTitle(defaultWindowTitle.arg(tr("Select Profile")));
this->setWindowTitle(defaultWindowTitle.arg(tr("Select Profile")));
} }
} }

View File

@ -31,6 +31,10 @@
#include <QString> #include <QString>
#include <QMap> #include <QMap>
#ifdef GTA5SYNC_MOTD
#include "MessageThread.h"
#endif
namespace Ui { namespace Ui {
class UserInterface; class UserInterface;
} }
@ -39,8 +43,12 @@ class UserInterface : public QMainWindow
{ {
Q_OBJECT Q_OBJECT
public: public:
#ifdef GTA5SYNC_MOTD
explicit UserInterface(ProfileDatabase *profileDB, CrewDatabase *crewDB, DatabaseThread *threadDB, MessageThread *messageThread, QWidget *parent = 0);
#else
explicit UserInterface(ProfileDatabase *profileDB, CrewDatabase *crewDB, DatabaseThread *threadDB, QWidget *parent = 0); explicit UserInterface(ProfileDatabase *profileDB, CrewDatabase *crewDB, DatabaseThread *threadDB, QWidget *parent = 0);
void setupDirEnv(); #endif
void setupDirEnv(bool showFolderDialog = true);
~UserInterface(); ~UserInterface();
private slots: private slots:
@ -67,6 +75,11 @@ private slots:
void on_actionSet_Crew_triggered(); void on_actionSet_Crew_triggered();
void on_actionSet_Title_triggered(); void on_actionSet_Title_triggered();
void settingsApplied(int contentMode, bool languageChanged); void settingsApplied(int contentMode, bool languageChanged);
#ifdef GTA5SYNC_MOTD
void messagesArrived(const QJsonObject &object);
void showMessages(const QStringList messages);
void updateCacheId(uint cacheId);
#endif
protected: protected:
void closeEvent(QCloseEvent *ev); void closeEvent(QCloseEvent *ev);
@ -75,6 +88,14 @@ private:
ProfileDatabase *profileDB; ProfileDatabase *profileDB;
CrewDatabase *crewDB; CrewDatabase *crewDB;
DatabaseThread *threadDB; DatabaseThread *threadDB;
#ifdef GTA5SYNC_MOTD
MessageThread *threadMessage;
#endif
#ifdef GTA5SYNC_DONATE
#ifdef GTA5SYNC_DONATE_ADDRESSES
QAction *donateAction;
#endif
#endif
Ui::UserInterface *ui; Ui::UserInterface *ui;
ProfileInterface *profileUI; ProfileInterface *profileUI;
QList<QPushButton*> profileBtns; QList<QPushButton*> profileBtns;

862
anpro/QrCode.cpp Normal file
View File

@ -0,0 +1,862 @@
/*
* QR Code generator library (C++)
*
* Copyright (c) Project Nayuki. (MIT License)
* https://www.nayuki.io/page/qr-code-generator-library
*
* Permission is hereby granted, free of charge, to any person obtaining a copy of
* this software and associated documentation files (the "Software"), to deal in
* the Software without restriction, including without limitation the rights to
* use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
* the Software, and to permit persons to whom the Software is furnished to do so,
* subject to the following conditions:
* - The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
* - The Software is provided "as is", without warranty of any kind, express or
* implied, including but not limited to the warranties of merchantability,
* fitness for a particular purpose and noninfringement. In no event shall the
* authors or copyright holders be liable for any claim, damages or other
* liability, whether in an action of contract, tort or otherwise, arising from,
* out of or in connection with the Software or the use or other dealings in the
* Software.
*/
#include <algorithm>
#include <climits>
#include <cstddef>
#include <cstdlib>
#include <cstring>
#include <sstream>
#include <stdexcept>
#include <utility>
#include "QrCode.h"
using std::int8_t;
using std::uint8_t;
using std::size_t;
using std::vector;
namespace qrcodegen {
QrSegment::Mode::Mode(int mode, int cc0, int cc1, int cc2) :
modeBits(mode) {
numBitsCharCount[0] = cc0;
numBitsCharCount[1] = cc1;
numBitsCharCount[2] = cc2;
}
int QrSegment::Mode::getModeBits() const {
return modeBits;
}
int QrSegment::Mode::numCharCountBits(int ver) const {
return numBitsCharCount[(ver + 7) / 17];
}
const QrSegment::Mode QrSegment::Mode::NUMERIC (0x1, 10, 12, 14);
const QrSegment::Mode QrSegment::Mode::ALPHANUMERIC(0x2, 9, 11, 13);
const QrSegment::Mode QrSegment::Mode::BYTE (0x4, 8, 16, 16);
const QrSegment::Mode QrSegment::Mode::KANJI (0x8, 8, 10, 12);
const QrSegment::Mode QrSegment::Mode::ECI (0x7, 0, 0, 0);
QrSegment QrSegment::makeBytes(const vector<uint8_t> &data) {
if (data.size() > static_cast<unsigned int>(INT_MAX))
throw std::length_error("Data too long");
BitBuffer bb;
for (uint8_t b : data)
bb.appendBits(b, 8);
return QrSegment(Mode::BYTE, static_cast<int>(data.size()), std::move(bb));
}
QrSegment QrSegment::makeNumeric(const char *digits) {
BitBuffer bb;
int accumData = 0;
int accumCount = 0;
int charCount = 0;
for (; *digits != '\0'; digits++, charCount++) {
char c = *digits;
if (c < '0' || c > '9')
throw std::domain_error("String contains non-numeric characters");
accumData = accumData * 10 + (c - '0');
accumCount++;
if (accumCount == 3) {
bb.appendBits(static_cast<uint32_t>(accumData), 10);
accumData = 0;
accumCount = 0;
}
}
if (accumCount > 0) // 1 or 2 digits remaining
bb.appendBits(static_cast<uint32_t>(accumData), accumCount * 3 + 1);
return QrSegment(Mode::NUMERIC, charCount, std::move(bb));
}
QrSegment QrSegment::makeAlphanumeric(const char *text) {
BitBuffer bb;
int accumData = 0;
int accumCount = 0;
int charCount = 0;
for (; *text != '\0'; text++, charCount++) {
const char *temp = std::strchr(ALPHANUMERIC_CHARSET, *text);
if (temp == nullptr)
throw std::domain_error("String contains unencodable characters in alphanumeric mode");
accumData = accumData * 45 + static_cast<int>(temp - ALPHANUMERIC_CHARSET);
accumCount++;
if (accumCount == 2) {
bb.appendBits(static_cast<uint32_t>(accumData), 11);
accumData = 0;
accumCount = 0;
}
}
if (accumCount > 0) // 1 character remaining
bb.appendBits(static_cast<uint32_t>(accumData), 6);
return QrSegment(Mode::ALPHANUMERIC, charCount, std::move(bb));
}
vector<QrSegment> QrSegment::makeSegments(const char *text) {
// Select the most efficient segment encoding automatically
vector<QrSegment> result;
if (*text == '\0'); // Leave result empty
else if (isNumeric(text))
result.push_back(makeNumeric(text));
else if (isAlphanumeric(text))
result.push_back(makeAlphanumeric(text));
else {
vector<uint8_t> bytes;
for (; *text != '\0'; text++)
bytes.push_back(static_cast<uint8_t>(*text));
result.push_back(makeBytes(bytes));
}
return result;
}
QrSegment QrSegment::makeEci(long assignVal) {
BitBuffer bb;
if (assignVal < 0)
throw std::domain_error("ECI assignment value out of range");
else if (assignVal < (1 << 7))
bb.appendBits(static_cast<uint32_t>(assignVal), 8);
else if (assignVal < (1 << 14)) {
bb.appendBits(2, 2);
bb.appendBits(static_cast<uint32_t>(assignVal), 14);
} else if (assignVal < 1000000L) {
bb.appendBits(6, 3);
bb.appendBits(static_cast<uint32_t>(assignVal), 21);
} else
throw std::domain_error("ECI assignment value out of range");
return QrSegment(Mode::ECI, 0, std::move(bb));
}
QrSegment::QrSegment(Mode md, int numCh, const std::vector<bool> &dt) :
mode(md),
numChars(numCh),
data(dt) {
if (numCh < 0)
throw std::domain_error("Invalid value");
}
QrSegment::QrSegment(Mode md, int numCh, std::vector<bool> &&dt) :
mode(md),
numChars(numCh),
data(std::move(dt)) {
if (numCh < 0)
throw std::domain_error("Invalid value");
}
int QrSegment::getTotalBits(const vector<QrSegment> &segs, int version) {
int result = 0;
for (const QrSegment &seg : segs) {
int ccbits = seg.mode.numCharCountBits(version);
if (seg.numChars >= (1L << ccbits))
return -1; // The segment's length doesn't fit the field's bit width
if (4 + ccbits > INT_MAX - result)
return -1; // The sum will overflow an int type
result += 4 + ccbits;
if (seg.data.size() > static_cast<unsigned int>(INT_MAX - result))
return -1; // The sum will overflow an int type
result += static_cast<int>(seg.data.size());
}
return result;
}
bool QrSegment::isAlphanumeric(const char *text) {
for (; *text != '\0'; text++) {
if (std::strchr(ALPHANUMERIC_CHARSET, *text) == nullptr)
return false;
}
return true;
}
bool QrSegment::isNumeric(const char *text) {
for (; *text != '\0'; text++) {
char c = *text;
if (c < '0' || c > '9')
return false;
}
return true;
}
QrSegment::Mode QrSegment::getMode() const {
return mode;
}
int QrSegment::getNumChars() const {
return numChars;
}
const std::vector<bool> &QrSegment::getData() const {
return data;
}
const char *QrSegment::ALPHANUMERIC_CHARSET = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ $%*+-./:";
int QrCode::getFormatBits(Ecc ecl) {
switch (ecl) {
case Ecc::LOW : return 1;
case Ecc::MEDIUM : return 0;
case Ecc::QUARTILE: return 3;
case Ecc::HIGH : return 2;
default: throw std::logic_error("Assertion error");
}
}
QrCode QrCode::encodeText(const char *text, Ecc ecl) {
vector<QrSegment> segs = QrSegment::makeSegments(text);
return encodeSegments(segs, ecl);
}
QrCode QrCode::encodeBinary(const vector<uint8_t> &data, Ecc ecl) {
vector<QrSegment> segs{QrSegment::makeBytes(data)};
return encodeSegments(segs, ecl);
}
QrCode QrCode::encodeSegments(const vector<QrSegment> &segs, Ecc ecl,
int minVersion, int maxVersion, int mask, bool boostEcl) {
if (!(MIN_VERSION <= minVersion && minVersion <= maxVersion && maxVersion <= MAX_VERSION) || mask < -1 || mask > 7)
throw std::invalid_argument("Invalid value");
// Find the minimal version number to use
int version, dataUsedBits;
for (version = minVersion; ; version++) {
int dataCapacityBits = getNumDataCodewords(version, ecl) * 8; // Number of data bits available
dataUsedBits = QrSegment::getTotalBits(segs, version);
if (dataUsedBits != -1 && dataUsedBits <= dataCapacityBits)
break; // This version number is found to be suitable
if (version >= maxVersion) { // All versions in the range could not fit the given data
std::ostringstream sb;
if (dataUsedBits == -1)
sb << "Segment too long";
else {
sb << "Data length = " << dataUsedBits << " bits, ";
sb << "Max capacity = " << dataCapacityBits << " bits";
}
throw data_too_long(sb.str());
}
}
if (dataUsedBits == -1)
throw std::logic_error("Assertion error");
// Increase the error correction level while the data still fits in the current version number
for (Ecc newEcl : vector<Ecc>{Ecc::MEDIUM, Ecc::QUARTILE, Ecc::HIGH}) { // From low to high
if (boostEcl && dataUsedBits <= getNumDataCodewords(version, newEcl) * 8)
ecl = newEcl;
}
// Concatenate all segments to create the data bit string
BitBuffer bb;
for (const QrSegment &seg : segs) {
bb.appendBits(static_cast<uint32_t>(seg.getMode().getModeBits()), 4);
bb.appendBits(static_cast<uint32_t>(seg.getNumChars()), seg.getMode().numCharCountBits(version));
bb.insert(bb.end(), seg.getData().begin(), seg.getData().end());
}
if (bb.size() != static_cast<unsigned int>(dataUsedBits))
throw std::logic_error("Assertion error");
// Add terminator and pad up to a byte if applicable
size_t dataCapacityBits = static_cast<size_t>(getNumDataCodewords(version, ecl)) * 8;
if (bb.size() > dataCapacityBits)
throw std::logic_error("Assertion error");
bb.appendBits(0, std::min(4, static_cast<int>(dataCapacityBits - bb.size())));
bb.appendBits(0, (8 - static_cast<int>(bb.size() % 8)) % 8);
if (bb.size() % 8 != 0)
throw std::logic_error("Assertion error");
// Pad with alternating bytes until data capacity is reached
for (uint8_t padByte = 0xEC; bb.size() < dataCapacityBits; padByte ^= 0xEC ^ 0x11)
bb.appendBits(padByte, 8);
// Pack bits into bytes in big endian
vector<uint8_t> dataCodewords(bb.size() / 8);
for (size_t i = 0; i < bb.size(); i++)
dataCodewords[i >> 3] |= (bb.at(i) ? 1 : 0) << (7 - (i & 7));
// Create the QR Code object
return QrCode(version, ecl, dataCodewords, mask);
}
QrCode::QrCode(int ver, Ecc ecl, const vector<uint8_t> &dataCodewords, int msk) :
// Initialize fields and check arguments
version(ver),
errorCorrectionLevel(ecl) {
if (ver < MIN_VERSION || ver > MAX_VERSION)
throw std::domain_error("Version value out of range");
if (msk < -1 || msk > 7)
throw std::domain_error("Mask value out of range");
size = ver * 4 + 17;
size_t sz = static_cast<size_t>(size);
modules = vector<vector<bool> >(sz, vector<bool>(sz)); // Initially all white
isFunction = vector<vector<bool> >(sz, vector<bool>(sz));
// Compute ECC, draw modules
drawFunctionPatterns();
const vector<uint8_t> allCodewords = addEccAndInterleave(dataCodewords);
drawCodewords(allCodewords);
// Do masking
if (msk == -1) { // Automatically choose best mask
long minPenalty = LONG_MAX;
for (int i = 0; i < 8; i++) {
applyMask(i);
drawFormatBits(i);
long penalty = getPenaltyScore();
if (penalty < minPenalty) {
msk = i;
minPenalty = penalty;
}
applyMask(i); // Undoes the mask due to XOR
}
}
if (msk < 0 || msk > 7)
throw std::logic_error("Assertion error");
this->mask = msk;
applyMask(msk); // Apply the final choice of mask
drawFormatBits(msk); // Overwrite old format bits
isFunction.clear();
isFunction.shrink_to_fit();
}
int QrCode::getVersion() const {
return version;
}
int QrCode::getSize() const {
return size;
}
QrCode::Ecc QrCode::getErrorCorrectionLevel() const {
return errorCorrectionLevel;
}
int QrCode::getMask() const {
return mask;
}
bool QrCode::getModule(int x, int y) const {
return 0 <= x && x < size && 0 <= y && y < size && module(x, y);
}
std::string QrCode::toSvgString(int border) const {
if (border < 0)
throw std::domain_error("Border must be non-negative");
if (border > INT_MAX / 2 || border * 2 > INT_MAX - size)
throw std::overflow_error("Border too large");
std::ostringstream sb;
sb << "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n";
sb << "<!DOCTYPE svg PUBLIC \"-//W3C//DTD SVG 1.1//EN\" \"http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd\">\n";
sb << "<svg xmlns=\"http://www.w3.org/2000/svg\" version=\"1.1\" viewBox=\"0 0 ";
sb << (size + border * 2) << " " << (size + border * 2) << "\" stroke=\"none\">\n";
sb << "\t<rect width=\"100%\" height=\"100%\" fill=\"#FFFFFF\"/>\n";
sb << "\t<path d=\"";
for (int y = 0; y < size; y++) {
for (int x = 0; x < size; x++) {
if (getModule(x, y)) {
if (x != 0 || y != 0)
sb << " ";
sb << "M" << (x + border) << "," << (y + border) << "h1v1h-1z";
}
}
}
sb << "\" fill=\"#000000\"/>\n";
sb << "</svg>\n";
return sb.str();
}
void QrCode::drawFunctionPatterns() {
// Draw horizontal and vertical timing patterns
for (int i = 0; i < size; i++) {
setFunctionModule(6, i, i % 2 == 0);
setFunctionModule(i, 6, i % 2 == 0);
}
// Draw 3 finder patterns (all corners except bottom right; overwrites some timing modules)
drawFinderPattern(3, 3);
drawFinderPattern(size - 4, 3);
drawFinderPattern(3, size - 4);
// Draw numerous alignment patterns
const vector<int> alignPatPos = getAlignmentPatternPositions();
size_t numAlign = alignPatPos.size();
for (size_t i = 0; i < numAlign; i++) {
for (size_t j = 0; j < numAlign; j++) {
// Don't draw on the three finder corners
if (!((i == 0 && j == 0) || (i == 0 && j == numAlign - 1) || (i == numAlign - 1 && j == 0)))
drawAlignmentPattern(alignPatPos.at(i), alignPatPos.at(j));
}
}
// Draw configuration data
drawFormatBits(0); // Dummy mask value; overwritten later in the constructor
drawVersion();
}
void QrCode::drawFormatBits(int msk) {
// Calculate error correction code and pack bits
int data = getFormatBits(errorCorrectionLevel) << 3 | msk; // errCorrLvl is uint2, msk is uint3
int rem = data;
for (int i = 0; i < 10; i++)
rem = (rem << 1) ^ ((rem >> 9) * 0x537);
int bits = (data << 10 | rem) ^ 0x5412; // uint15
if (bits >> 15 != 0)
throw std::logic_error("Assertion error");
// Draw first copy
for (int i = 0; i <= 5; i++)
setFunctionModule(8, i, getBit(bits, i));
setFunctionModule(8, 7, getBit(bits, 6));
setFunctionModule(8, 8, getBit(bits, 7));
setFunctionModule(7, 8, getBit(bits, 8));
for (int i = 9; i < 15; i++)
setFunctionModule(14 - i, 8, getBit(bits, i));
// Draw second copy
for (int i = 0; i < 8; i++)
setFunctionModule(size - 1 - i, 8, getBit(bits, i));
for (int i = 8; i < 15; i++)
setFunctionModule(8, size - 15 + i, getBit(bits, i));
setFunctionModule(8, size - 8, true); // Always black
}
void QrCode::drawVersion() {
if (version < 7)
return;
// Calculate error correction code and pack bits
int rem = version; // version is uint6, in the range [7, 40]
for (int i = 0; i < 12; i++)
rem = (rem << 1) ^ ((rem >> 11) * 0x1F25);
long bits = static_cast<long>(version) << 12 | rem; // uint18
if (bits >> 18 != 0)
throw std::logic_error("Assertion error");
// Draw two copies
for (int i = 0; i < 18; i++) {
bool bit = getBit(bits, i);
int a = size - 11 + i % 3;
int b = i / 3;
setFunctionModule(a, b, bit);
setFunctionModule(b, a, bit);
}
}
void QrCode::drawFinderPattern(int x, int y) {
for (int dy = -4; dy <= 4; dy++) {
for (int dx = -4; dx <= 4; dx++) {
int dist = std::max(std::abs(dx), std::abs(dy)); // Chebyshev/infinity norm
int xx = x + dx, yy = y + dy;
if (0 <= xx && xx < size && 0 <= yy && yy < size)
setFunctionModule(xx, yy, dist != 2 && dist != 4);
}
}
}
void QrCode::drawAlignmentPattern(int x, int y) {
for (int dy = -2; dy <= 2; dy++) {
for (int dx = -2; dx <= 2; dx++)
setFunctionModule(x + dx, y + dy, std::max(std::abs(dx), std::abs(dy)) != 1);
}
}
void QrCode::setFunctionModule(int x, int y, bool isBlack) {
size_t ux = static_cast<size_t>(x);
size_t uy = static_cast<size_t>(y);
modules .at(uy).at(ux) = isBlack;
isFunction.at(uy).at(ux) = true;
}
bool QrCode::module(int x, int y) const {
return modules.at(static_cast<size_t>(y)).at(static_cast<size_t>(x));
}
vector<uint8_t> QrCode::addEccAndInterleave(const vector<uint8_t> &data) const {
if (data.size() != static_cast<unsigned int>(getNumDataCodewords(version, errorCorrectionLevel)))
throw std::invalid_argument("Invalid argument");
// Calculate parameter numbers
int numBlocks = NUM_ERROR_CORRECTION_BLOCKS[static_cast<int>(errorCorrectionLevel)][version];
int blockEccLen = ECC_CODEWORDS_PER_BLOCK [static_cast<int>(errorCorrectionLevel)][version];
int rawCodewords = getNumRawDataModules(version) / 8;
int numShortBlocks = numBlocks - rawCodewords % numBlocks;
int shortBlockLen = rawCodewords / numBlocks;
// Split data into blocks and append ECC to each block
vector<vector<uint8_t> > blocks;
const vector<uint8_t> rsDiv = reedSolomonComputeDivisor(blockEccLen);
for (int i = 0, k = 0; i < numBlocks; i++) {
vector<uint8_t> dat(data.cbegin() + k, data.cbegin() + (k + shortBlockLen - blockEccLen + (i < numShortBlocks ? 0 : 1)));
k += static_cast<int>(dat.size());
const vector<uint8_t> ecc = reedSolomonComputeRemainder(dat, rsDiv);
if (i < numShortBlocks)
dat.push_back(0);
dat.insert(dat.end(), ecc.cbegin(), ecc.cend());
blocks.push_back(std::move(dat));
}
// Interleave (not concatenate) the bytes from every block into a single sequence
vector<uint8_t> result;
for (size_t i = 0; i < blocks.at(0).size(); i++) {
for (size_t j = 0; j < blocks.size(); j++) {
// Skip the padding byte in short blocks
if (i != static_cast<unsigned int>(shortBlockLen - blockEccLen) || j >= static_cast<unsigned int>(numShortBlocks))
result.push_back(blocks.at(j).at(i));
}
}
if (result.size() != static_cast<unsigned int>(rawCodewords))
throw std::logic_error("Assertion error");
return result;
}
void QrCode::drawCodewords(const vector<uint8_t> &data) {
if (data.size() != static_cast<unsigned int>(getNumRawDataModules(version) / 8))
throw std::invalid_argument("Invalid argument");
size_t i = 0; // Bit index into the data
// Do the funny zigzag scan
for (int right = size - 1; right >= 1; right -= 2) { // Index of right column in each column pair
if (right == 6)
right = 5;
for (int vert = 0; vert < size; vert++) { // Vertical counter
for (int j = 0; j < 2; j++) {
size_t x = static_cast<size_t>(right - j); // Actual x coordinate
bool upward = ((right + 1) & 2) == 0;
size_t y = static_cast<size_t>(upward ? size - 1 - vert : vert); // Actual y coordinate
if (!isFunction.at(y).at(x) && i < data.size() * 8) {
modules.at(y).at(x) = getBit(data.at(i >> 3), 7 - static_cast<int>(i & 7));
i++;
}
// If this QR Code has any remainder bits (0 to 7), they were assigned as
// 0/false/white by the constructor and are left unchanged by this method
}
}
}
if (i != data.size() * 8)
throw std::logic_error("Assertion error");
}
void QrCode::applyMask(int msk) {
if (msk < 0 || msk > 7)
throw std::domain_error("Mask value out of range");
size_t sz = static_cast<size_t>(size);
for (size_t y = 0; y < sz; y++) {
for (size_t x = 0; x < sz; x++) {
bool invert;
switch (msk) {
case 0: invert = (x + y) % 2 == 0; break;
case 1: invert = y % 2 == 0; break;
case 2: invert = x % 3 == 0; break;
case 3: invert = (x + y) % 3 == 0; break;
case 4: invert = (x / 3 + y / 2) % 2 == 0; break;
case 5: invert = x * y % 2 + x * y % 3 == 0; break;
case 6: invert = (x * y % 2 + x * y % 3) % 2 == 0; break;
case 7: invert = ((x + y) % 2 + x * y % 3) % 2 == 0; break;
default: throw std::logic_error("Assertion error");
}
modules.at(y).at(x) = modules.at(y).at(x) ^ (invert & !isFunction.at(y).at(x));
}
}
}
long QrCode::getPenaltyScore() const {
long result = 0;
// Adjacent modules in row having same color, and finder-like patterns
for (int y = 0; y < size; y++) {
bool runColor = false;
int runX = 0;
std::array<int,7> runHistory = {};
for (int x = 0; x < size; x++) {
if (module(x, y) == runColor) {
runX++;
if (runX == 5)
result += PENALTY_N1;
else if (runX > 5)
result++;
} else {
finderPenaltyAddHistory(runX, runHistory);
if (!runColor)
result += finderPenaltyCountPatterns(runHistory) * PENALTY_N3;
runColor = module(x, y);
runX = 1;
}
}
result += finderPenaltyTerminateAndCount(runColor, runX, runHistory) * PENALTY_N3;
}
// Adjacent modules in column having same color, and finder-like patterns
for (int x = 0; x < size; x++) {
bool runColor = false;
int runY = 0;
std::array<int,7> runHistory = {};
for (int y = 0; y < size; y++) {
if (module(x, y) == runColor) {
runY++;
if (runY == 5)
result += PENALTY_N1;
else if (runY > 5)
result++;
} else {
finderPenaltyAddHistory(runY, runHistory);
if (!runColor)
result += finderPenaltyCountPatterns(runHistory) * PENALTY_N3;
runColor = module(x, y);
runY = 1;
}
}
result += finderPenaltyTerminateAndCount(runColor, runY, runHistory) * PENALTY_N3;
}
// 2*2 blocks of modules having same color
for (int y = 0; y < size - 1; y++) {
for (int x = 0; x < size - 1; x++) {
bool color = module(x, y);
if ( color == module(x + 1, y) &&
color == module(x, y + 1) &&
color == module(x + 1, y + 1))
result += PENALTY_N2;
}
}
// Balance of black and white modules
int black = 0;
for (const vector<bool> &row : modules) {
for (bool color : row) {
if (color)
black++;
}
}
int total = size * size; // Note that size is odd, so black/total != 1/2
// Compute the smallest integer k >= 0 such that (45-5k)% <= black/total <= (55+5k)%
int k = static_cast<int>((std::abs(black * 20L - total * 10L) + total - 1) / total) - 1;
result += k * PENALTY_N4;
return result;
}
vector<int> QrCode::getAlignmentPatternPositions() const {
if (version == 1)
return vector<int>();
else {
int numAlign = version / 7 + 2;
int step = (version == 32) ? 26 :
(version*4 + numAlign*2 + 1) / (numAlign*2 - 2) * 2;
vector<int> result;
for (int i = 0, pos = size - 7; i < numAlign - 1; i++, pos -= step)
result.insert(result.begin(), pos);
result.insert(result.begin(), 6);
return result;
}
}
int QrCode::getNumRawDataModules(int ver) {
if (ver < MIN_VERSION || ver > MAX_VERSION)
throw std::domain_error("Version number out of range");
int result = (16 * ver + 128) * ver + 64;
if (ver >= 2) {
int numAlign = ver / 7 + 2;
result -= (25 * numAlign - 10) * numAlign - 55;
if (ver >= 7)
result -= 36;
}
if (!(208 <= result && result <= 29648))
throw std::logic_error("Assertion error");
return result;
}
int QrCode::getNumDataCodewords(int ver, Ecc ecl) {
return getNumRawDataModules(ver) / 8
- ECC_CODEWORDS_PER_BLOCK [static_cast<int>(ecl)][ver]
* NUM_ERROR_CORRECTION_BLOCKS[static_cast<int>(ecl)][ver];
}
vector<uint8_t> QrCode::reedSolomonComputeDivisor(int degree) {
if (degree < 1 || degree > 255)
throw std::domain_error("Degree out of range");
// Polynomial coefficients are stored from highest to lowest power, excluding the leading term which is always 1.
// For example the polynomial x^3 + 255x^2 + 8x + 93 is stored as the uint8 array {255, 8, 93}.
vector<uint8_t> result(static_cast<size_t>(degree));
result.at(result.size() - 1) = 1; // Start off with the monomial x^0
// Compute the product polynomial (x - r^0) * (x - r^1) * (x - r^2) * ... * (x - r^{degree-1}),
// and drop the highest monomial term which is always 1x^degree.
// Note that r = 0x02, which is a generator element of this field GF(2^8/0x11D).
uint8_t root = 1;
for (int i = 0; i < degree; i++) {
// Multiply the current product by (x - r^i)
for (size_t j = 0; j < result.size(); j++) {
result.at(j) = reedSolomonMultiply(result.at(j), root);
if (j + 1 < result.size())
result.at(j) ^= result.at(j + 1);
}
root = reedSolomonMultiply(root, 0x02);
}
return result;
}
vector<uint8_t> QrCode::reedSolomonComputeRemainder(const vector<uint8_t> &data, const vector<uint8_t> &divisor) {
vector<uint8_t> result(divisor.size());
for (uint8_t b : data) { // Polynomial division
uint8_t factor = b ^ result.at(0);
result.erase(result.begin());
result.push_back(0);
for (size_t i = 0; i < result.size(); i++)
result.at(i) ^= reedSolomonMultiply(divisor.at(i), factor);
}
return result;
}
uint8_t QrCode::reedSolomonMultiply(uint8_t x, uint8_t y) {
// Russian peasant multiplication
int z = 0;
for (int i = 7; i >= 0; i--) {
z = (z << 1) ^ ((z >> 7) * 0x11D);
z ^= ((y >> i) & 1) * x;
}
if (z >> 8 != 0)
throw std::logic_error("Assertion error");
return static_cast<uint8_t>(z);
}
int QrCode::finderPenaltyCountPatterns(const std::array<int,7> &runHistory) const {
int n = runHistory.at(1);
if (n > size * 3)
throw std::logic_error("Assertion error");
bool core = n > 0 && runHistory.at(2) == n && runHistory.at(3) == n * 3 && runHistory.at(4) == n && runHistory.at(5) == n;
return (core && runHistory.at(0) >= n * 4 && runHistory.at(6) >= n ? 1 : 0)
+ (core && runHistory.at(6) >= n * 4 && runHistory.at(0) >= n ? 1 : 0);
}
int QrCode::finderPenaltyTerminateAndCount(bool currentRunColor, int currentRunLength, std::array<int,7> &runHistory) const {
if (currentRunColor) { // Terminate black run
finderPenaltyAddHistory(currentRunLength, runHistory);
currentRunLength = 0;
}
currentRunLength += size; // Add white border to final run
finderPenaltyAddHistory(currentRunLength, runHistory);
return finderPenaltyCountPatterns(runHistory);
}
void QrCode::finderPenaltyAddHistory(int currentRunLength, std::array<int,7> &runHistory) const {
if (runHistory.at(0) == 0)
currentRunLength += size; // Add white border to initial run
std::copy_backward(runHistory.cbegin(), runHistory.cend() - 1, runHistory.end());
runHistory.at(0) = currentRunLength;
}
bool QrCode::getBit(long x, int i) {
return ((x >> i) & 1) != 0;
}
/*---- Tables of constants ----*/
const int QrCode::PENALTY_N1 = 3;
const int QrCode::PENALTY_N2 = 3;
const int QrCode::PENALTY_N3 = 40;
const int QrCode::PENALTY_N4 = 10;
const int8_t QrCode::ECC_CODEWORDS_PER_BLOCK[4][41] = {
// Version: (note that index 0 is for padding, and is set to an illegal value)
//0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40 Error correction level
{-1, 7, 10, 15, 20, 26, 18, 20, 24, 30, 18, 20, 24, 26, 30, 22, 24, 28, 30, 28, 28, 28, 28, 30, 30, 26, 28, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30}, // Low
{-1, 10, 16, 26, 18, 24, 16, 18, 22, 22, 26, 30, 22, 22, 24, 24, 28, 28, 26, 26, 26, 26, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28}, // Medium
{-1, 13, 22, 18, 26, 18, 24, 18, 22, 20, 24, 28, 26, 24, 20, 30, 24, 28, 28, 26, 30, 28, 30, 30, 30, 30, 28, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30}, // Quartile
{-1, 17, 28, 22, 16, 22, 28, 26, 26, 24, 28, 24, 28, 22, 24, 24, 30, 28, 28, 26, 28, 30, 24, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30}, // High
};
const int8_t QrCode::NUM_ERROR_CORRECTION_BLOCKS[4][41] = {
// Version: (note that index 0 is for padding, and is set to an illegal value)
//0, 1, 2, 3, 4, 5, 6, 7, 8, 9,10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40 Error correction level
{-1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 4, 4, 4, 4, 4, 6, 6, 6, 6, 7, 8, 8, 9, 9, 10, 12, 12, 12, 13, 14, 15, 16, 17, 18, 19, 19, 20, 21, 22, 24, 25}, // Low
{-1, 1, 1, 1, 2, 2, 4, 4, 4, 5, 5, 5, 8, 9, 9, 10, 10, 11, 13, 14, 16, 17, 17, 18, 20, 21, 23, 25, 26, 28, 29, 31, 33, 35, 37, 38, 40, 43, 45, 47, 49}, // Medium
{-1, 1, 1, 2, 2, 4, 4, 6, 6, 8, 8, 8, 10, 12, 16, 12, 17, 16, 18, 21, 20, 23, 23, 25, 27, 29, 34, 34, 35, 38, 40, 43, 45, 48, 51, 53, 56, 59, 62, 65, 68}, // Quartile
{-1, 1, 1, 2, 4, 4, 4, 5, 6, 8, 8, 11, 11, 16, 16, 18, 16, 19, 21, 25, 25, 25, 34, 30, 32, 35, 37, 40, 42, 45, 48, 51, 54, 57, 60, 63, 66, 70, 74, 77, 81}, // High
};
data_too_long::data_too_long(const std::string &msg) :
std::length_error(msg) {}
BitBuffer::BitBuffer()
: std::vector<bool>() {}
void BitBuffer::appendBits(std::uint32_t val, int len) {
if (len < 0 || len > 31 || val >> len != 0)
throw std::domain_error("Value out of range");
for (int i = len - 1; i >= 0; i--) // Append bit by bit
this->push_back(((val >> i) & 1) != 0);
}
}

556
anpro/QrCode.h Normal file
View File

@ -0,0 +1,556 @@
/*
* QR Code generator library (C++)
*
* Copyright (c) Project Nayuki. (MIT License)
* https://www.nayuki.io/page/qr-code-generator-library
*
* Permission is hereby granted, free of charge, to any person obtaining a copy of
* this software and associated documentation files (the "Software"), to deal in
* the Software without restriction, including without limitation the rights to
* use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
* the Software, and to permit persons to whom the Software is furnished to do so,
* subject to the following conditions:
* - The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
* - The Software is provided "as is", without warranty of any kind, express or
* implied, including but not limited to the warranties of merchantability,
* fitness for a particular purpose and noninfringement. In no event shall the
* authors or copyright holders be liable for any claim, damages or other
* liability, whether in an action of contract, tort or otherwise, arising from,
* out of or in connection with the Software or the use or other dealings in the
* Software.
*/
#pragma once
#include <array>
#include <cstdint>
#include <stdexcept>
#include <string>
#include <vector>
namespace qrcodegen {
/*
* A segment of character/binary/control data in a QR Code symbol.
* Instances of this class are immutable.
* The mid-level way to create a segment is to take the payload data
* and call a static factory function such as QrSegment::makeNumeric().
* The low-level way to create a segment is to custom-make the bit buffer
* and call the QrSegment() constructor with appropriate values.
* This segment class imposes no length restrictions, but QR Codes have restrictions.
* Even in the most favorable conditions, a QR Code can only hold 7089 characters of data.
* Any segment longer than this is meaningless for the purpose of generating QR Codes.
*/
class QrSegment final {
/*---- Public helper enumeration ----*/
/*
* Describes how a segment's data bits are interpreted. Immutable.
*/
public: class Mode final {
/*-- Constants --*/
public: static const Mode NUMERIC;
public: static const Mode ALPHANUMERIC;
public: static const Mode BYTE;
public: static const Mode KANJI;
public: static const Mode ECI;
/*-- Fields --*/
// The mode indicator bits, which is a uint4 value (range 0 to 15).
private: int modeBits;
// Number of character count bits for three different version ranges.
private: int numBitsCharCount[3];
/*-- Constructor --*/
private: Mode(int mode, int cc0, int cc1, int cc2);
/*-- Methods --*/
/*
* (Package-private) Returns the mode indicator bits, which is an unsigned 4-bit value (range 0 to 15).
*/
public: int getModeBits() const;
/*
* (Package-private) Returns the bit width of the character count field for a segment in
* this mode in a QR Code at the given version number. The result is in the range [0, 16].
*/
public: int numCharCountBits(int ver) const;
};
/*---- Static factory functions (mid level) ----*/
/*
* Returns a segment representing the given binary data encoded in
* byte mode. All input byte vectors are acceptable. Any text string
* can be converted to UTF-8 bytes and encoded as a byte mode segment.
*/
public: static QrSegment makeBytes(const std::vector<std::uint8_t> &data);
/*
* Returns a segment representing the given string of decimal digits encoded in numeric mode.
*/
public: static QrSegment makeNumeric(const char *digits);
/*
* Returns a segment representing the given text string encoded in alphanumeric mode.
* The characters allowed are: 0 to 9, A to Z (uppercase only), space,
* dollar, percent, asterisk, plus, hyphen, period, slash, colon.
*/
public: static QrSegment makeAlphanumeric(const char *text);
/*
* Returns a list of zero or more segments to represent the given text string. The result
* may use various segment modes and switch modes to optimize the length of the bit stream.
*/
public: static std::vector<QrSegment> makeSegments(const char *text);
/*
* Returns a segment representing an Extended Channel Interpretation
* (ECI) designator with the given assignment value.
*/
public: static QrSegment makeEci(long assignVal);
/*---- Public static helper functions ----*/
/*
* Tests whether the given string can be encoded as a segment in alphanumeric mode.
* A string is encodable iff each character is in the following set: 0 to 9, A to Z
* (uppercase only), space, dollar, percent, asterisk, plus, hyphen, period, slash, colon.
*/
public: static bool isAlphanumeric(const char *text);
/*
* Tests whether the given string can be encoded as a segment in numeric mode.
* A string is encodable iff each character is in the range 0 to 9.
*/
public: static bool isNumeric(const char *text);
/*---- Instance fields ----*/
/* The mode indicator of this segment. Accessed through getMode(). */
private: Mode mode;
/* The length of this segment's unencoded data. Measured in characters for
* numeric/alphanumeric/kanji mode, bytes for byte mode, and 0 for ECI mode.
* Always zero or positive. Not the same as the data's bit length.
* Accessed through getNumChars(). */
private: int numChars;
/* The data bits of this segment. Accessed through getData(). */
private: std::vector<bool> data;
/*---- Constructors (low level) ----*/
/*
* Creates a new QR Code segment with the given attributes and data.
* The character count (numCh) must agree with the mode and the bit buffer length,
* but the constraint isn't checked. The given bit buffer is copied and stored.
*/
public: QrSegment(Mode md, int numCh, const std::vector<bool> &dt);
/*
* Creates a new QR Code segment with the given parameters and data.
* The character count (numCh) must agree with the mode and the bit buffer length,
* but the constraint isn't checked. The given bit buffer is moved and stored.
*/
public: QrSegment(Mode md, int numCh, std::vector<bool> &&dt);
/*---- Methods ----*/
/*
* Returns the mode field of this segment.
*/
public: Mode getMode() const;
/*
* Returns the character count field of this segment.
*/
public: int getNumChars() const;
/*
* Returns the data bits of this segment.
*/
public: const std::vector<bool> &getData() const;
// (Package-private) Calculates the number of bits needed to encode the given segments at
// the given version. Returns a non-negative number if successful. Otherwise returns -1 if a
// segment has too many characters to fit its length field, or the total bits exceeds INT_MAX.
public: static int getTotalBits(const std::vector<QrSegment> &segs, int version);
/*---- Private constant ----*/
/* The set of all legal characters in alphanumeric mode, where
* each character value maps to the index in the string. */
private: static const char *ALPHANUMERIC_CHARSET;
};
/*
* A QR Code symbol, which is a type of two-dimension barcode.
* Invented by Denso Wave and described in the ISO/IEC 18004 standard.
* Instances of this class represent an immutable square grid of black and white cells.
* The class provides static factory functions to create a QR Code from text or binary data.
* The class covers the QR Code Model 2 specification, supporting all versions (sizes)
* from 1 to 40, all 4 error correction levels, and 4 character encoding modes.
*
* Ways to create a QR Code object:
* - High level: Take the payload data and call QrCode::encodeText() or QrCode::encodeBinary().
* - Mid level: Custom-make the list of segments and call QrCode::encodeSegments().
* - Low level: Custom-make the array of data codeword bytes (including
* segment headers and final padding, excluding error correction codewords),
* supply the appropriate version number, and call the QrCode() constructor.
* (Note that all ways require supplying the desired error correction level.)
*/
class QrCode final {
/*---- Public helper enumeration ----*/
/*
* The error correction level in a QR Code symbol.
*/
public: enum class Ecc {
LOW = 0 , // The QR Code can tolerate about 7% erroneous codewords
MEDIUM , // The QR Code can tolerate about 15% erroneous codewords
QUARTILE, // The QR Code can tolerate about 25% erroneous codewords
HIGH , // The QR Code can tolerate about 30% erroneous codewords
};
// Returns a value in the range 0 to 3 (unsigned 2-bit integer).
private: static int getFormatBits(Ecc ecl);
/*---- Static factory functions (high level) ----*/
/*
* Returns a QR Code representing the given Unicode text string at the given error correction level.
* As a conservative upper bound, this function is guaranteed to succeed for strings that have 2953 or fewer
* UTF-8 code units (not Unicode code points) if the low error correction level is used. The smallest possible
* QR Code version is automatically chosen for the output. The ECC level of the result may be higher than
* the ecl argument if it can be done without increasing the version.
*/
public: static QrCode encodeText(const char *text, Ecc ecl);
/*
* Returns a QR Code representing the given binary data at the given error correction level.
* This function always encodes using the binary segment mode, not any text mode. The maximum number of
* bytes allowed is 2953. The smallest possible QR Code version is automatically chosen for the output.
* The ECC level of the result may be higher than the ecl argument if it can be done without increasing the version.
*/
public: static QrCode encodeBinary(const std::vector<std::uint8_t> &data, Ecc ecl);
/*---- Static factory functions (mid level) ----*/
/*
* Returns a QR Code representing the given segments with the given encoding parameters.
* The smallest possible QR Code version within the given range is automatically
* chosen for the output. Iff boostEcl is true, then the ECC level of the result
* may be higher than the ecl argument if it can be done without increasing the
* version. The mask number is either between 0 to 7 (inclusive) to force that
* mask, or -1 to automatically choose an appropriate mask (which may be slow).
* This function allows the user to create a custom sequence of segments that switches
* between modes (such as alphanumeric and byte) to encode text in less space.
* This is a mid-level API; the high-level API is encodeText() and encodeBinary().
*/
public: static QrCode encodeSegments(const std::vector<QrSegment> &segs, Ecc ecl,
int minVersion=1, int maxVersion=40, int mask=-1, bool boostEcl=true); // All optional parameters
/*---- Instance fields ----*/
// Immutable scalar parameters:
/* The version number of this QR Code, which is between 1 and 40 (inclusive).
* This determines the size of this barcode. */
private: int version;
/* The width and height of this QR Code, measured in modules, between
* 21 and 177 (inclusive). This is equal to version * 4 + 17. */
private: int size;
/* The error correction level used in this QR Code. */
private: Ecc errorCorrectionLevel;
/* The index of the mask pattern used in this QR Code, which is between 0 and 7 (inclusive).
* Even if a QR Code is created with automatic masking requested (mask = -1),
* the resulting object still has a mask value between 0 and 7. */
private: int mask;
// Private grids of modules/pixels, with dimensions of size*size:
// The modules of this QR Code (false = white, true = black).
// Immutable after constructor finishes. Accessed through getModule().
private: std::vector<std::vector<bool> > modules;
// Indicates function modules that are not subjected to masking. Discarded when constructor finishes.
private: std::vector<std::vector<bool> > isFunction;
/*---- Constructor (low level) ----*/
/*
* Creates a new QR Code with the given version number,
* error correction level, data codeword bytes, and mask number.
* This is a low-level API that most users should not use directly.
* A mid-level API is the encodeSegments() function.
*/
public: QrCode(int ver, Ecc ecl, const std::vector<std::uint8_t> &dataCodewords, int msk);
/*---- Public instance methods ----*/
/*
* Returns this QR Code's version, in the range [1, 40].
*/
public: int getVersion() const;
/*
* Returns this QR Code's size, in the range [21, 177].
*/
public: int getSize() const;
/*
* Returns this QR Code's error correction level.
*/
public: Ecc getErrorCorrectionLevel() const;
/*
* Returns this QR Code's mask, in the range [0, 7].
*/
public: int getMask() const;
/*
* Returns the color of the module (pixel) at the given coordinates, which is false
* for white or true for black. The top left corner has the coordinates (x=0, y=0).
* If the given coordinates are out of bounds, then false (white) is returned.
*/
public: bool getModule(int x, int y) const;
/*
* Returns a string of SVG code for an image depicting this QR Code, with the given number
* of border modules. The string always uses Unix newlines (\n), regardless of the platform.
*/
public: std::string toSvgString(int border) const;
/*---- Private helper methods for constructor: Drawing function modules ----*/
// Reads this object's version field, and draws and marks all function modules.
private: void drawFunctionPatterns();
// Draws two copies of the format bits (with its own error correction code)
// based on the given mask and this object's error correction level field.
private: void drawFormatBits(int msk);
// Draws two copies of the version bits (with its own error correction code),
// based on this object's version field, iff 7 <= version <= 40.
private: void drawVersion();
// Draws a 9*9 finder pattern including the border separator,
// with the center module at (x, y). Modules can be out of bounds.
private: void drawFinderPattern(int x, int y);
// Draws a 5*5 alignment pattern, with the center module
// at (x, y). All modules must be in bounds.
private: void drawAlignmentPattern(int x, int y);
// Sets the color of a module and marks it as a function module.
// Only used by the constructor. Coordinates must be in bounds.
private: void setFunctionModule(int x, int y, bool isBlack);
// Returns the color of the module at the given coordinates, which must be in range.
private: bool module(int x, int y) const;
/*---- Private helper methods for constructor: Codewords and masking ----*/
// Returns a new byte string representing the given data with the appropriate error correction
// codewords appended to it, based on this object's version and error correction level.
private: std::vector<std::uint8_t> addEccAndInterleave(const std::vector<std::uint8_t> &data) const;
// Draws the given sequence of 8-bit codewords (data and error correction) onto the entire
// data area of this QR Code. Function modules need to be marked off before this is called.
private: void drawCodewords(const std::vector<std::uint8_t> &data);
// XORs the codeword modules in this QR Code with the given mask pattern.
// The function modules must be marked and the codeword bits must be drawn
// before masking. Due to the arithmetic of XOR, calling applyMask() with
// the same mask value a second time will undo the mask. A final well-formed
// QR Code needs exactly one (not zero, two, etc.) mask applied.
private: void applyMask(int msk);
// Calculates and returns the penalty score based on state of this QR Code's current modules.
// This is used by the automatic mask choice algorithm to find the mask pattern that yields the lowest score.
private: long getPenaltyScore() const;
/*---- Private helper functions ----*/
// Returns an ascending list of positions of alignment patterns for this version number.
// Each position is in the range [0,177), and are used on both the x and y axes.
// This could be implemented as lookup table of 40 variable-length lists of unsigned bytes.
private: std::vector<int> getAlignmentPatternPositions() const;
// Returns the number of data bits that can be stored in a QR Code of the given version number, after
// all function modules are excluded. This includes remainder bits, so it might not be a multiple of 8.
// The result is in the range [208, 29648]. This could be implemented as a 40-entry lookup table.
private: static int getNumRawDataModules(int ver);
// Returns the number of 8-bit data (i.e. not error correction) codewords contained in any
// QR Code of the given version number and error correction level, with remainder bits discarded.
// This stateless pure function could be implemented as a (40*4)-cell lookup table.
private: static int getNumDataCodewords(int ver, Ecc ecl);
// Returns a Reed-Solomon ECC generator polynomial for the given degree. This could be
// implemented as a lookup table over all possible parameter values, instead of as an algorithm.
private: static std::vector<std::uint8_t> reedSolomonComputeDivisor(int degree);
// Returns the Reed-Solomon error correction codeword for the given data and divisor polynomials.
private: static std::vector<std::uint8_t> reedSolomonComputeRemainder(const std::vector<std::uint8_t> &data, const std::vector<std::uint8_t> &divisor);
// Returns the product of the two given field elements modulo GF(2^8/0x11D).
// All inputs are valid. This could be implemented as a 256*256 lookup table.
private: static std::uint8_t reedSolomonMultiply(std::uint8_t x, std::uint8_t y);
// Can only be called immediately after a white run is added, and
// returns either 0, 1, or 2. A helper function for getPenaltyScore().
private: int finderPenaltyCountPatterns(const std::array<int,7> &runHistory) const;
// Must be called at the end of a line (row or column) of modules. A helper function for getPenaltyScore().
private: int finderPenaltyTerminateAndCount(bool currentRunColor, int currentRunLength, std::array<int,7> &runHistory) const;
// Pushes the given value to the front and drops the last value. A helper function for getPenaltyScore().
private: void finderPenaltyAddHistory(int currentRunLength, std::array<int,7> &runHistory) const;
// Returns true iff the i'th bit of x is set to 1.
private: static bool getBit(long x, int i);
/*---- Constants and tables ----*/
// The minimum version number supported in the QR Code Model 2 standard.
public: static constexpr int MIN_VERSION = 1;
// The maximum version number supported in the QR Code Model 2 standard.
public: static constexpr int MAX_VERSION = 40;
// For use in getPenaltyScore(), when evaluating which mask is best.
private: static const int PENALTY_N1;
private: static const int PENALTY_N2;
private: static const int PENALTY_N3;
private: static const int PENALTY_N4;
private: static const std::int8_t ECC_CODEWORDS_PER_BLOCK[4][41];
private: static const std::int8_t NUM_ERROR_CORRECTION_BLOCKS[4][41];
};
/*---- Public exception class ----*/
/*
* Thrown when the supplied data does not fit any QR Code version. Ways to handle this exception include:
* - Decrease the error correction level if it was greater than Ecc::LOW.
* - If the encodeSegments() function was called with a maxVersion argument, then increase
* it if it was less than QrCode::MAX_VERSION. (This advice does not apply to the other
* factory functions because they search all versions up to QrCode::MAX_VERSION.)
* - Split the text data into better or optimal segments in order to reduce the number of bits required.
* - Change the text or binary data to be shorter.
* - Change the text to fit the character set of a particular segment mode (e.g. alphanumeric).
* - Propagate the error upward to the caller/user.
*/
class data_too_long : public std::length_error {
public: explicit data_too_long(const std::string &msg);
};
/*
* An appendable sequence of bits (0s and 1s). Mainly used by QrSegment.
*/
class BitBuffer final : public std::vector<bool> {
/*---- Constructor ----*/
// Creates an empty bit buffer (length 0).
public: BitBuffer();
/*---- Method ----*/
// Appends the given number of low-order bits of the given value
// to this buffer. Requires 0 <= len <= 31 and val < 2^len.
public: void appendBits(std::uint32_t val, int len);
};
}

View File

@ -1,6 +1,7 @@
/***************************************************************************** /*****************************************************************************
* ImageCropper Qt Widget for cropping images * ImageCropper Qt Widget for cropping images
* Copyright (C) 2013 Dimka Novikov, to@dimkanovikov.pro * Copyright (C) 2013 Dimka Novikov, to@dimkanovikov.pro
* Copyright (C) 2020 Syping
* *
* This library is free software; you can redistribute it and/or * This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public * modify it under the terms of the GNU Lesser General Public
@ -17,7 +18,9 @@
*****************************************************************************/ *****************************************************************************/
#include "imagecropper.h" #include "imagecropper.h"
#include "AppEnv.h"
#include <QPainterPath>
#include <QMouseEvent> #include <QMouseEvent>
#include <QPainter> #include <QPainter>
@ -112,16 +115,16 @@ const QPixmap ImageCropper::cropImage()
// Получим размер отображаемого изображения // Получим размер отображаемого изображения
QSize scaledImageSize = QSize scaledImageSize =
pimpl->imageForCropping.scaled( pimpl->imageForCropping.scaled(
this->size(), Qt::KeepAspectRatio, Qt::FastTransformation size(), Qt::KeepAspectRatio, Qt::SmoothTransformation
).size(); ).size();
// Определим расстояние от левого и верхнего краёв // Определим расстояние от левого и верхнего краёв
float leftDelta = 0; float leftDelta = 0;
float topDelta = 0; float topDelta = 0;
const float HALF_COUNT = 2; const float HALF_COUNT = 2;
if (this->size().height() == scaledImageSize.height()) { if (size().height() == scaledImageSize.height()) {
leftDelta = (this->width() - scaledImageSize.width()) / HALF_COUNT; leftDelta = (width() - scaledImageSize.width()) / HALF_COUNT;
} else { } else {
topDelta = (this->height() - scaledImageSize.height()) / HALF_COUNT; topDelta = (height() - scaledImageSize.height()) / HALF_COUNT;
} }
// Определим пропорцию области обрезки по отношению к исходному изображению // Определим пропорцию области обрезки по отношению к исходному изображению
float xScale = (float)pimpl->imageForCropping.width() / scaledImageSize.width(); float xScale = (float)pimpl->imageForCropping.width() / scaledImageSize.width();
@ -145,39 +148,54 @@ const QPixmap ImageCropper::cropImage()
void ImageCropper::paintEvent(QPaintEvent* _event) void ImageCropper::paintEvent(QPaintEvent* _event)
{ {
QWidget::paintEvent( _event ); QWidget::paintEvent(_event);
// //
QPainter widgetPainter(this); QPainter widgetPainter(this);
// Рисуем изображение по центру виджета // Рисуем изображение по центру виджета
{ {
#if QT_VERSION >= 0x050600
qreal screenRatioPR = AppEnv::screenRatioPR();
// ... подгоним изображение для отображения по размеру виджета // ... подгоним изображение для отображения по размеру виджета
QPixmap scaledImage = QPixmap scaledImage =
pimpl->imageForCropping.scaled(this->size(), Qt::KeepAspectRatio, Qt::FastTransformation); pimpl->imageForCropping.scaled(qRound((double)width() * screenRatioPR), qRound((double)height() * screenRatioPR), Qt::KeepAspectRatio, Qt::SmoothTransformation);
scaledImage.setDevicePixelRatio(screenRatioPR);
#else
QPixmap scaledImage =
pimpl->imageForCropping.scaled(size(), Qt::KeepAspectRatio, Qt::SmoothTransformation);
#endif
// ... заливаем фон // ... заливаем фон
widgetPainter.fillRect( this->rect(), pimpl->backgroundColor ); widgetPainter.fillRect(rect(), pimpl->backgroundColor);
// ... рисуем изображение по центру виджета // ... рисуем изображение по центру виджета
if ( this->size().height() == scaledImage.height() ) { #if QT_VERSION >= 0x050600
widgetPainter.drawPixmap( ( this->width() - scaledImage.width() ) / 2, 0, scaledImage ); if (qRound((double)height() * screenRatioPR) == scaledImage.height()) {
widgetPainter.drawPixmap( ( qRound((double)width() * screenRatioPR) - scaledImage.width() ) / 2, 0, scaledImage );
} else { } else {
widgetPainter.drawPixmap( 0, ( this->height() - scaledImage.height() ) / 2, scaledImage ); widgetPainter.drawPixmap( 0, ( qRound((double)height() * screenRatioPR) - scaledImage.height() ) / 2, scaledImage );
} }
#else
if (height() == scaledImage.height()) {
widgetPainter.drawPixmap( ( width()- scaledImage.width() ) / 2, 0, scaledImage );
} else {
widgetPainter.drawPixmap( 0, ( height() - scaledImage.height() ) / 2, scaledImage );
}
#endif
} }
// Рисуем область обрезки // Рисуем область обрезки
{ {
// ... если это первое отображение после инициилизации, то центруем областо обрезки // ... если это первое отображение после инициилизации, то центруем областо обрезки
if (pimpl->croppingRect.isNull()) { if (pimpl->croppingRect.isNull()) {
const int width = WIDGET_MINIMUM_SIZE.width()/2; const int cwidth = WIDGET_MINIMUM_SIZE.width()/2;
const int height = WIDGET_MINIMUM_SIZE.height()/2; const int cheight = WIDGET_MINIMUM_SIZE.height()/2;
pimpl->croppingRect.setSize(QSize(width, height)); pimpl->croppingRect.setSize(QSize(cwidth, cheight));
float x = (this->width() - pimpl->croppingRect.width())/2; float x = (width() - pimpl->croppingRect.width())/2;
float y = (this->height() - pimpl->croppingRect.height())/2; float y = (height() - pimpl->croppingRect.height())/2;
pimpl->croppingRect.moveTo(x, y); pimpl->croppingRect.moveTo(x, y);
} }
// ... рисуем затемненную область // ... рисуем затемненную область
QPainterPath p; QPainterPath p;
p.addRect(pimpl->croppingRect); p.addRect(pimpl->croppingRect);
p.addRect(this->rect()); p.addRect(rect());
widgetPainter.setBrush(QBrush(QColor(0,0,0,120))); widgetPainter.setBrush(QBrush(QColor(0,0,0,120)));
widgetPainter.setPen(Qt::transparent); widgetPainter.setPen(Qt::transparent);
widgetPainter.drawPath(p); widgetPainter.drawPath(p);

View File

@ -1,6 +1,6 @@
/***************************************************************************** /*****************************************************************************
* gta5view Grand Theft Auto V Profile Viewer * gta5view Grand Theft Auto V Profile Viewer
* Copyright (C) 2016-2018 Syping * Copyright (C) 2016-2021 Syping
* *
* This program is free software: you can redistribute it and/or modify * This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by * it under the terms of the GNU General Public License as published by
@ -21,6 +21,13 @@
#if __cplusplus #if __cplusplus
#include <QString> #include <QString>
#define REL_BUILDTYPE QT_TRANSLATE_NOOP("AboutDialog", "Release")
#define RC_BUILDTYPE QT_TRANSLATE_NOOP("AboutDialog", "Release Candidate")
#define BETA_BUILDTYPE QT_TRANSLATE_NOOP("AboutDialog", "Beta")
#define ALPHA_BUILDTYPE QT_TRANSLATE_NOOP("AboutDialog", "Alpha")
#define DEV_BUILDTYPE QT_TRANSLATE_NOOP("AboutDialog", "Developer")
#define DAILY_BUILDTYPE QT_TRANSLATE_NOOP("AboutDialog", "Daily Build")
#define CUSTOM_BUILDTYPE QT_TRANSLATE_NOOP("AboutDialog", "Custom")
#endif #endif
#ifndef GTA5SYNC_APPVENDOR #ifndef GTA5SYNC_APPVENDOR
@ -28,7 +35,7 @@
#endif #endif
#ifndef GTA5SYNC_APPVENDORLINK #ifndef GTA5SYNC_APPVENDORLINK
#define GTA5SYNC_APPVENDORLINK "g5e://about?U3lwaW5n:R2l0TGFiOiA8YSBocmVmPSJodHRwczovL2dpdGxhYi5jb20vU3lwaW5nIj5TeXBpbmc8L2E+PGJyLz5HaXRIdWI6IDxhIGhyZWY9Imh0dHBzOi8vZ2l0aHViLmNvbS9TeXBpbmciPlN5cGluZzwvYT48YnIvPlNvY2lhbCBDbHViOiA8YSBocmVmPSJodHRwczovL3NvY2lhbGNsdWIucm9ja3N0YXJnYW1lcy5jb20vbWVtYmVyL1N5cGluZy80NjMwMzA1NiI+U3lwaW5nPC9hPg==" #define GTA5SYNC_APPVENDORLINK "g5e://about?U3lwaW5n:R2l0TGFiOiA8YSBocmVmPSJodHRwczovL2dpdGxhYi5jb20vU3lwaW5nIj5TeXBpbmc8L2E+PGJyLz5HaXRIdWI6IDxhIGhyZWY9Imh0dHBzOi8vZ2l0aHViLmNvbS9TeXBpbmciPlN5cGluZzwvYT48YnIvPlNvY2lhbCBDbHViOiA8YSBocmVmPSJodHRwczovL3NvY2lhbGNsdWIucm9ja3N0YXJnYW1lcy5jb20vbWVtYmVyL1N5cGluZy80NjMwMzA1NiI+U3lwaW5nPC9hPg"
#endif #endif
#ifndef GTA5SYNC_APPSTR #ifndef GTA5SYNC_APPSTR
@ -40,50 +47,14 @@
#endif #endif
#ifndef GTA5SYNC_COPYRIGHT #ifndef GTA5SYNC_COPYRIGHT
#define GTA5SYNC_COPYRIGHT "2016-2018" #define GTA5SYNC_COPYRIGHT "2016-2023"
#endif #endif
#ifndef GTA5SYNC_APPVER #ifndef GTA5SYNC_APPVER
#define GTA5SYNC_APPVER "1.6.0" #define GTA5SYNC_APPVER "1.10.2"
#endif #endif
#if __cplusplus #if __cplusplus
#ifdef GTA5SYNC_BUILDTYPE_REL
#ifndef GTA5SYNC_BUILDTYPE
#define GTA5SYNC_BUILDTYPE QT_TRANSLATE_NOOP("AboutDialog", "Release")
#endif
#endif
#ifdef GTA5SYNC_BUILDTYPE_RC
#ifndef GTA5SYNC_BUILDTYPE
#define GTA5SYNC_BUILDTYPE QT_TRANSLATE_NOOP("AboutDialog", "Release Candidate")
#endif
#endif
#ifdef GTA5SYNC_BUILDTYPE_DAILY
#ifndef GTA5SYNC_BUILDTYPE
#define GTA5SYNC_BUILDTYPE QT_TRANSLATE_NOOP("AboutDialog", "Daily Build")
#endif
#endif
#ifdef GTA5SYNC_BUILDTYPE_DEV
#ifndef GTA5SYNC_BUILDTYPE
#define GTA5SYNC_BUILDTYPE QT_TRANSLATE_NOOP("AboutDialog", "Developer")
#endif
#endif
#ifdef GTA5SYNC_BUILDTYPE_BETA
#ifndef GTA5SYNC_BUILDTYPE
#define GTA5SYNC_BUILDTYPE QT_TRANSLATE_NOOP("AboutDialog", "Beta")
#endif
#endif
#ifdef GTA5SYNC_BUILDTYPE_ALPHA
#ifndef GTA5SYNC_BUILDTYPE
#define GTA5SYNC_BUILDTYPE QT_TRANSLATE_NOOP("AboutDialog", "Alpha")
#endif
#endif
#ifndef GTA5SYNC_BUILDTYPE #ifndef GTA5SYNC_BUILDTYPE
#define GTA5SYNC_BUILDTYPE QT_TRANSLATE_NOOP("AboutDialog", "Custom") #define GTA5SYNC_BUILDTYPE QT_TRANSLATE_NOOP("AboutDialog", "Custom")
#endif #endif
@ -94,7 +65,11 @@
#ifdef GTA5SYNC_QCONF #ifdef GTA5SYNC_QCONF
#ifndef GTA5SYNC_SHARE #ifndef GTA5SYNC_SHARE
#define GTA5SYNC_SHARE "RUNDIR:SEPARATOR:..SEPARATOR:share" #ifdef Q_OS_WIN
#define GTA5SYNC_SHARE "RUNDIR:"
#else
#define GTA5SYNC_SHARE "RUNDIR:/../share"
#endif
#endif #endif
#ifndef GTA5SYNC_LANG #ifndef GTA5SYNC_LANG
#define GTA5SYNC_LANG "QCONFLANG:" #define GTA5SYNC_LANG "QCONFLANG:"
@ -107,22 +82,16 @@
#define GTA5SYNC_INLANG ":/tr" #define GTA5SYNC_INLANG ":/tr"
#endif #endif
#endif #endif
#endif #else
#ifndef GTA5SYNC_SHARE #ifndef GTA5SYNC_SHARE
#define GTA5SYNC_SHARE "RUNDIR:" #define GTA5SYNC_SHARE "RUNDIR:"
#endif #endif
#ifndef GTA5SYNC_LANG #ifndef GTA5SYNC_LANG
#define GTA5SYNC_LANG "SHAREDDIR:SEPARATOR:lang" #define GTA5SYNC_LANG "SHAREDDIR:/lang"
#endif #endif
#ifndef GTA5SYNC_PLUG #ifndef GTA5SYNC_PLUG
#define GTA5SYNC_PLUG "RUNDIR:SEPARATOR:plugins" #define GTA5SYNC_PLUG "RUNDIR:/plugins"
#endif #endif
#ifdef GTA5SYNC_WINRT
#undef GTA5SYNC_WIN
#endif #endif
#ifndef GTA5SYNC_COMPILER #ifndef GTA5SYNC_COMPILER

242
configure vendored
View File

@ -1,242 +0,0 @@
#!/usr/bin/env bash
#*****************************************************************************
# gta5view Grand Theft Auto V Profile Viewer
# Copyright (C) 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/>.
#*****************************************************************************
# Argbash generated code
die()
{
local _ret=$2
test -n "$_ret" || _ret=1
test "$_PRINT_HELP" = yes && print_help >&2
echo "$1" >&2
exit ${_ret}
}
begins_with_short_option()
{
local first_option all_short_options
all_short_options='h'
first_option="${1:0:1}"
test "$all_short_options" = "${all_short_options/$first_option/}" && return 1 || return 0
}
_arg_prefix=
_arg_qmake=
_arg_telemetry_authid=
_arg_telemetry_authpw=
_arg_telemetry_pushurl=
_arg_telemetry_regurl=
_arg_telemetry_weburl=
print_help ()
{
printf '%s\n' "gta5view Configure Script"
printf 'Usage: %s [--prefix <arg>] [--qmake <arg>] [--telemetry-authid <arg>] [--telemetry-authpw <arg>] [--telemetry-pushurl <arg>] [--telemetry-regurl <arg>] [--telemetry-weburl <arg>] [-h|--help]\n' "$0"
printf '\t%s\n' "-h,--help: Prints help"
}
parse_commandline ()
{
while test $# -gt 0
do
_key="$1"
case "$_key" in
--prefix)
test $# -lt 2 && die "Missing value for the optional argument '$_key'." 1
_arg_prefix="$2"
shift
;;
--prefix=*)
_arg_prefix="${_key##--prefix=}"
;;
--qmake)
test $# -lt 2 && die "Missing value for the optional argument '$_key'." 1
_arg_qmake="$2"
shift
;;
--qmake=*)
_arg_qmake="${_key##--qmake=}"
;;
--telemetry-authid)
test $# -lt 2 && die "Missing value for the optional argument '$_key'." 1
_arg_telemetry_authid="$2"
shift
;;
--telemetry-authid=*)
_arg_telemetry_authid="${_key##--telemetry-authid=}"
;;
--telemetry-authpw)
test $# -lt 2 && die "Missing value for the optional argument '$_key'." 1
_arg_telemetry_authpw="$2"
shift
;;
--telemetry-authpw=*)
_arg_telemetry_authpw="${_key##--telemetry-authpw=}"
;;
--telemetry-pushurl)
test $# -lt 2 && die "Missing value for the optional argument '$_key'." 1
_arg_telemetry_pushurl="$2"
shift
;;
--telemetry-pushurl=*)
_arg_telemetry_pushurl="${_key##--telemetry-pushurl=}"
;;
--telemetry-regurl)
test $# -lt 2 && die "Missing value for the optional argument '$_key'." 1
_arg_telemetry_regurl="$2"
shift
;;
--telemetry-regurl=*)
_arg_telemetry_regurl="${_key##--telemetry-regurl=}"
;;
--telemetry-weburl)
test $# -lt 2 && die "Missing value for the optional argument '$_key'." 1
_arg_telemetry_weburl="$2"
shift
;;
--telemetry-weburl=*)
_arg_telemetry_weburl="${_key##--telemetry-weburl=}"
;;
-h|--help)
print_help
exit 0
;;
-h*)
print_help
exit 0
;;
*)
_PRINT_HELP=yes die "FATAL ERROR: Got an unexpected argument '$1'" 1
;;
esac
shift
done
}
parse_commandline "$@"
# Initialise bash script - Step 1
if [ "${_arg_prefix}" != "" ]; then
PREFIX=${_arg_prefix}
fi
if [ "${_arg_qmake}" != "" ]; then
QMAKE_PATH=${_arg_qmake}
fi
if [ "${_arg_telemetry_authid}" != "" ] && [ "${_arg_telemetry_authpw}" != "" ] && [ "${_arg_telemetry_pushurl}" != "" ] && [ "${_arg_telemetry_regurl}" != "" ]; then
_telemetry_args="${_telemetry_args} DEFINES+=GTA5SYNC_TELEMETRY"
_telemetry_args="${_telemetry_args} DEFINES+=GTA5SYNC_TELEMETRY_AUTHID=\\\\\\\"${_arg_telemetry_authid}\\\\\\\""
_telemetry_args="${_telemetry_args} DEFINES+=GTA5SYNC_TELEMETRY_AUTHPW=\\\\\\\"${_arg_telemetry_authpw}\\\\\\\""
_telemetry_args="${_telemetry_args} DEFINES+=GTA5SYNC_TELEMETRY_PUSHURL=\\\\\\\"${_arg_telemetry_pushurl}\\\\\\\""
_telemetry_args="${_telemetry_args} DEFINES+=GTA5SYNC_TELEMETRY_REGURL=\\\\\\\"${_arg_telemetry_regurl}\\\\\\\""
if [ "${_arg_telemetry_weburl}" != "" ]; then
_telemetry_args="${_telemetry_args} DEFINES+=GTA5SYNC_TELEMETRY_WEBURL=\\\\\\\"${_arg_telemetry_weburl}\\\\\\\""
fi
else
_telemetry_args=
fi
# Initialise bash script - Step 2
set +e
_extra_args=
# Find Source Directory
SOURCE=${BASH_SOURCE[0]}
while [ -h "$SOURCE" ]; do
SOURCE_DIR=$(cd -P "$(dirname "$SOURCE")" && pwd)
SOURCE=$(readlink "$SOURCE")
[[ $SOURCE != /* ]] && SOURCE="${SOURCE_DIR}/${SOURCE}"
done
SOURCE_DIR=$(cd -P "$(dirname "$SOURCE")" && pwd)
# Find Qt Installation
export QT_SELECT=qt5
if [ -x "${QMAKE_PATH}" ]; then
QMAKE_PATH=${QMAKE_PATH}
QT_VERSION=$(${QMAKE_PATH} -query "QT_VERSION")
elif [ -x "$(command -v qmake-qt5)" ]; then
QMAKE_PATH=$(command -v qmake-qt5)
QT_VERSION=$(${QMAKE_PATH} -query "QT_VERSION")
elif [ -x "$(command -v qmake)" ]; then
QMAKE_PATH=$(command -v qmake)
QT_VERSION=$(${QMAKE_PATH} -query "QT_VERSION")
else
QMAKE_PATH=$(find /usr/ -executable -name qmake -type f 2> /dev/null | sed -n 1p)
if [ "${QMAKE_PATH}" == "" ]; then
echo "Qt qmake not found"
exit 1
fi
QT_VERSION=$(${QMAKE_PATH} -query "QT_VERSION")
fi
echo "Found Qt ${QT_VERSION} with qmake located at ${QMAKE_PATH}"
# Find Make Installation
if [ -x "${MAKE_PATH}" ]; then
MAKE_PATH=${MAKE_PATH}
elif [ -x "$(command -v make)" ]; then
MAKE_PATH=$(command -v make)
else
MAKE_PATH=$(find /usr/ -executable -name make -type f 2> /dev/null | sed -n 1p)
if [ "${MAKE_PATH}" == "" ]; then
echo "Make not found"
exit 1
fi
fi
# Clean Makefile
if [ "${RUN_MAKE_CLEAN}" != "NO" ]; then
if [ -f "Makefile" ]; then
echo "${MAKE_PATH} distclean"
${MAKE_PATH} distclean
fi
fi
# Set qConf
if [ "${NO_QCONF}" != "YES" ]; then
_extra_args="${_extra_args} DEFINES+=GTA5SYNC_QCONF"
fi
# Set Prefix
if [ "${PREFIX}" != "" ]; then
_extra_args="${_extra_args} GTA5SYNC_PREFIX=${PREFIX}"
fi
# Set Build Type
if [ "${BUILDTYPE}" == "Alpha" ]; then
_extra_args="${_extra_args} DEFINES+=GTA5SYNC_BUILDTYPE_ALPHA"
elif [ "${BUILDTYPE}" == "Beta" ]; then
_extra_args="${_extra_args} DEFINES+=GTA5SYNC_BUILDTYPE_BETA"
elif [ "${BUILDTYPE}" == "Developer" ]; then
_extra_args="${_extra_args} DEFINES+=GTA5SYNC_BUILDTYPE_DEV"
elif [ "${BUILDTYPE}" == "Daily Build" ]; then
_extra_args="${_extra_args} DEFINES+=GTA5SYNC_BUILDTYPE_DAILY"
elif [ "${BUILDTYPE}" == "Release Candidate" ]; then
_extra_args="${_extra_args} DEFINES+=GTA5SYNC_BUILDTYPE_RC"
elif [ "${BUILDTYPE}" == "Release" ]; then
_extra_args="${_extra_args} DEFINES+=GTA5SYNC_BUILDTYPE_REL"
fi
# Add Telemetry Args
if [ "${_telemetry_args}" != "" ]; then
_extra_args="${_extra_args}${_telemetry_args}"
fi
# Generating Makefile
echo "${QMAKE_PATH}${_extra_args} ${SOURCE_DIR}/gta5view.pro"
${QMAKE_PATH}${_extra_args} ${SOURCE_DIR}/gta5view.pro
# Make dependencies
if [ "${RUN_MAKE_DEPEND}" == "YES" ]; then
echo "${MAKE_PATH} depend"
${MAKE_PATH} depend
fi
exit 0

View File

@ -1,6 +1,6 @@
#/***************************************************************************** #/*****************************************************************************
#* gta5view Grand Theft Auto V Profile Viewer #* gta5view Grand Theft Auto V Profile Viewer
#* Copyright (C) 2015-2018 Syping #* Copyright (C) 2015-2021 Syping
#* #*
#* This program is free software: you can redistribute it and/or modify #* This program is free software: you can redistribute it and/or modify
#* it under the terms of the GNU General Public License as published by #* it under the terms of the GNU General Public License as published by
@ -16,16 +16,17 @@
#* along with this program. If not, see <http://www.gnu.org/licenses/>. #* along with this program. If not, see <http://www.gnu.org/licenses/>.
#*****************************************************************************/ #*****************************************************************************/
QT += core gui network QT += core gui network svg
greaterThan(QT_MAJOR_VERSION, 4): QT += widgets greaterThan(QT_MAJOR_VERSION, 4): QT += widgets
greaterThan(QT_MAJOR_VERSION, 4): greaterThan(QT_MINOR_VERSION, 1): win32: QT += winextras greaterThan(QT_MAJOR_VERSION, 4): win32: LIBS += -ldwmapi
DEPLOYMENT.display_name = gta5view DEPLOYMENT.display_name = gta5view
TARGET = gta5view TARGET = gta5view
TEMPLATE = app TEMPLATE = app
HEADERS += config.h HEADERS += config.h \
wrapper.h
PRECOMPILED_HEADER += config.h PRECOMPILED_HEADER += config.h
SOURCES += main.cpp \ SOURCES += main.cpp \
@ -37,10 +38,10 @@ SOURCES += main.cpp \
ExportThread.cpp \ ExportThread.cpp \
GlobalString.cpp \ GlobalString.cpp \
IconLoader.cpp \ IconLoader.cpp \
ImageEditorDialog.cpp \
ImportDialog.cpp \ ImportDialog.cpp \
JsonEditorDialog.cpp \ JsonEditorDialog.cpp \
MapLocationDialog.cpp \ MapLocationDialog.cpp \
MessageThread.cpp \
OptionsDialog.cpp \ OptionsDialog.cpp \
PictureDialog.cpp \ PictureDialog.cpp \
PictureExport.cpp \ PictureExport.cpp \
@ -50,6 +51,7 @@ SOURCES += main.cpp \
ProfileInterface.cpp \ ProfileInterface.cpp \
ProfileLoader.cpp \ ProfileLoader.cpp \
ProfileWidget.cpp \ ProfileWidget.cpp \
RagePhoto.cpp \
SavegameCopy.cpp \ SavegameCopy.cpp \
SavegameData.cpp \ SavegameData.cpp \
SavegameDialog.cpp \ SavegameDialog.cpp \
@ -70,7 +72,7 @@ SOURCES += main.cpp \
uimod/UiModLabel.cpp \ uimod/UiModLabel.cpp \
uimod/UiModWidget.cpp uimod/UiModWidget.cpp
HEADERS += \ HEADERS += \
AboutDialog.h \ AboutDialog.h \
AppEnv.h \ AppEnv.h \
CrewDatabase.h \ CrewDatabase.h \
@ -79,10 +81,10 @@ HEADERS += \
ExportThread.h \ ExportThread.h \
GlobalString.h \ GlobalString.h \
IconLoader.h \ IconLoader.h \
ImageEditorDialog.h \
ImportDialog.h \ ImportDialog.h \
JsonEditorDialog.h \ JsonEditorDialog.h \
MapLocationDialog.h \ MapLocationDialog.h \
MessageThread.h \
OptionsDialog.h \ OptionsDialog.h \
PictureDialog.h \ PictureDialog.h \
PictureExport.h \ PictureExport.h \
@ -92,6 +94,7 @@ HEADERS += \
ProfileInterface.h \ ProfileInterface.h \
ProfileLoader.h \ ProfileLoader.h \
ProfileWidget.h \ ProfileWidget.h \
RagePhoto.h \
SavegameCopy.h \ SavegameCopy.h \
SavegameData.h \ SavegameData.h \
SavegameDialog.h \ SavegameDialog.h \
@ -114,10 +117,9 @@ HEADERS += \
uimod/UiModLabel.h \ uimod/UiModLabel.h \
uimod/UiModWidget.h uimod/UiModWidget.h
FORMS += \ FORMS += \
AboutDialog.ui \ AboutDialog.ui \
ExportDialog.ui \ ExportDialog.ui \
ImageEditorDialog.ui \
ImportDialog.ui \ ImportDialog.ui \
JsonEditorDialog.ui \ JsonEditorDialog.ui \
MapLocationDialog.ui \ MapLocationDialog.ui \
@ -135,22 +137,35 @@ TRANSLATIONS += \
res/gta5sync.ts \ res/gta5sync.ts \
res/gta5sync_de.ts \ res/gta5sync_de.ts \
res/gta5sync_en_US.ts \ res/gta5sync_en_US.ts \
res/gta5sync_es.ts \
res/gta5sync_fr.ts \ res/gta5sync_fr.ts \
res/gta5sync_ko.ts \
res/gta5sync_ru.ts \ res/gta5sync_ru.ts \
res/gta5sync_uk.ts \ res/gta5sync_uk.ts \
res/gta5sync_zh_TW.ts res/gta5sync_zh_TW.ts
RESOURCES += \ RESOURCES += \
res/tr_g5p.qrc \ res/img.qrc \
res/app.qrc res/template.qrc \
res/tr_g5p.qrc
DISTFILES += res/app.rc \ DISTFILES += \
res/gta5view.desktop \ res/gta5view-16.png \
res/gta5view-24.png \
res/gta5view-32.png \
res/gta5view-40.png \
res/gta5view-48.png \
res/gta5view-64.png \
res/gta5view-96.png \
res/gta5view-128.png \
res/gta5view-256.png \
res/gta5view-512.png \
res/app.rc \
res/de.syping.gta5view.desktop \
res/de.syping.gta5view.png \
res/gta5sync_de.ts \ res/gta5sync_de.ts \
res/gta5sync_en_US.ts \ res/gta5sync_en_US.ts \
res/gta5sync_es.ts \
res/gta5sync_fr.ts \ res/gta5sync_fr.ts \
res/gta5sync_ko.ts \
res/gta5sync_ru.ts \ res/gta5sync_ru.ts \
res/gta5sync_uk.ts \ res/gta5sync_uk.ts \
res/gta5sync_zh_TW.ts \ res/gta5sync_zh_TW.ts \
@ -162,20 +177,17 @@ INCLUDEPATH += ./anpro ./pcg ./tmext ./uimod
# GTA5SYNC/GTA5VIEW ONLY # GTA5SYNC/GTA5VIEW ONLY
DEFINES += GTA5SYNC_QMAKE # We using qmake do we?
DEFINES += GTA5SYNC_PROJECT # Enable exclusive gta5sync/gta5view functions DEFINES += GTA5SYNC_PROJECT # Enable exclusive gta5sync/gta5view functions
DEFINES += GTA5SYNC_NOASSIST # Not assisting at proper usage of SnapmaticPicture class
# WINDOWS ONLY # WINDOWS ONLY
win32: DEFINES += GTA5SYNC_WIN
win32: RC_FILE += res/app.rc win32: RC_FILE += res/app.rc
win32: LIBS += -luser32
win32: CONFIG -= embed_manifest_exe win32: CONFIG -= embed_manifest_exe
contains(DEFINES, GTA5SYNC_APV): greaterThan(QT_MAJOR_VERSION, 4): greaterThan(QT_MINOR_VERSION, 1): win32: LIBS += -ldwmapi
contains(DEFINES, GTA5SYNC_TELEMETRY): win32: LIBS += -ld3d9 # Required for getting information about GPU contains(DEFINES, GTA5SYNC_TELEMETRY): win32: LIBS += -ld3d9 # Required for getting information about GPU
# MAC OS X ONLY # MAC OS X ONLY
macx: ICON = res/5sync.icns macx: ICON = res/gta5view.icns
# QT4 ONLY STUFF # QT4 ONLY STUFF
@ -197,49 +209,77 @@ isEqual(QT_MAJOR_VERSION, 4): SOURCES += qjson4/QJsonArray.cpp \
qjson4/QJsonValueRef.cpp \ qjson4/QJsonValueRef.cpp \
qjson4/QJsonParser.cpp qjson4/QJsonParser.cpp
isEqual(QT_MAJOR_VERSION, 4): RESOURCES += res/tr_qt4.qrc isEqual(QT_MAJOR_VERSION, 4): RESOURCES += res/qt4/tr_qt.qrc
isEqual(QT_MAJOR_VERSION, 4): GTA5SYNC_RCC = $$[QT_INSTALL_BINS]/rcc isEqual(QT_MAJOR_VERSION, 4): GTA5SYNC_RCC = $$[QT_INSTALL_BINS]/rcc
# QT5 ONLY STUFF # QT5 ONLY STUFF
isEqual(QT_MAJOR_VERSION, 5): RESOURCES += res/tr_qt5.qrc isEqual(QT_MAJOR_VERSION, 5): RESOURCES += res/qt5/tr_qt.qrc
isEqual(QT_MAJOR_VERSION, 5): GTA5SYNC_RCC = $$[QT_HOST_BINS]/rcc
# QT5+ ONLY STUFF
greaterThan(QT_MAJOR_VERSION, 4): GTA5SYNC_RCC = $$[QT_HOST_BINS]/rcc
# QT6 ONLY STUFF
isEqual(QT_MAJOR_VERSION, 6): RESOURCES += res/qt6/tr_qt.qrc
# RESOURCE COMPILATION # RESOURCE COMPILATION
depend.depends += $$PWD/res/global.qrc system($$GTA5SYNC_RCC -threshold 0 -compress 9 $$PWD/res/global.qrc -o $$OUT_PWD/qrc_global.cpp) {
depend.commands += $$GTA5SYNC_RCC -binary -threshold 0 -compress 9 $$PWD/res/global.qrc -o $$PWD/res/global.rcc SOURCES += $$OUT_PWD/qrc_global.cpp
QMAKE_EXTRA_TARGETS += depend } else {
message("Failed to generate qrc_global.cpp")
}
# PROJECT INSTALLATION # PROJECT INSTALLATION
isEmpty(GTA5SYNC_PREFIX): GTA5SYNC_PREFIX = /usr/local isEmpty(GTA5SYNC_PREFIX): GTA5SYNC_PREFIX = /usr/local
appfiles.path = $$GTA5SYNC_PREFIX/share/applications appfiles.path = $$GTA5SYNC_PREFIX/share/applications
appfiles.files = $$PWD/res/gta5view.desktop appfiles.files = $$PWD/res/de.syping.gta5view.desktop
pixmaps.path = $$GTA5SYNC_PREFIX/share/pixmaps pixmaps.path = $$GTA5SYNC_PREFIX/share/pixmaps
pixmaps.files = $$PWD/res/gta5view.png pixmaps.files = $$PWD/res/de.syping.gta5view.png
target.path = $$GTA5SYNC_PREFIX/bin target.path = $$GTA5SYNC_PREFIX/bin
INSTALLS += target pixmaps appfiles INSTALLS += target pixmaps appfiles
# QCONF BASED BUILD STUFF # QCONF BASED BUILD STUFF
contains(DEFINES, GTA5SYNC_QCONF){ contains(DEFINES, GTA5SYNC_QCONF) {
isEqual(QT_MAJOR_VERSION, 4): RESOURCES -= res/tr_qt4.qrc isEqual(QT_MAJOR_VERSION, 4): RESOURCES -= res/qt4/tr_qt.qrc
isEqual(QT_MAJOR_VERSION, 5): RESOURCES -= res/tr_qt5.qrc isEqual(QT_MAJOR_VERSION, 5): RESOURCES -= res/qt5/tr_qt.qrc
!contains(DEFINES, GTA5SYNC_QCONF_IN){ isEqual(QT_MAJOR_VERSION, 6): RESOURCES -= res/qt6/tr_qt.qrc
!contains(DEFINES, GTA5SYNC_QCONF_IN) {
RESOURCES -= res/tr_g5p.qrc RESOURCES -= res/tr_g5p.qrc
langfiles.path = $$GTA5SYNC_PREFIX/share/gta5view/translations langfiles.path = $$GTA5SYNC_PREFIX/share/gta5view/translations
langfiles.files = $$PWD/res/gta5sync_en_US.qm $$PWD/res/gta5sync_de.qm $$PWD/res/gta5sync_fr.qm $$PWD/res/gta5sync_ru.qm $$PWD/res/gta5sync_uk.qm $$PWD/res/gta5sync_zh_TW.qm $$PWD/res/qtbase_en_GB.qm $$PWD/res/qtbase_zh_TW.qm langfiles.files = $$PWD/res/gta5sync_en_US.qm $$PWD/res/gta5sync_de.qm $$PWD/res/gta5sync_fr.qm $$PWD/res/gta5sync_ko.qm $$PWD/res/gta5sync_ru.qm $$PWD/res/gta5sync_uk.qm $$PWD/res/gta5sync_zh_TW.qm $$PWD/res/qtbase_en_GB.qm
INSTALLS += langfiles INSTALLS += langfiles
} }
} }
# TELEMETRY BASED STUFF # TELEMETRY BASED STUFF
!contains(DEFINES, GTA5SYNC_TELEMETRY){ !contains(DEFINES, GTA5SYNC_TELEMETRY) {
SOURCES -= TelemetryClass.cpp \ SOURCES -= TelemetryClass.cpp \
tmext/TelemetryClassAuthenticator.cpp tmext/TelemetryClassAuthenticator.cpp
HEADERS -= TelemetryClass.h \ HEADERS -= TelemetryClass.h \
tmext/TelemetryClassAuthenticator.h tmext/TelemetryClassAuthenticator.h
} }
!contains(DEFINES, GTA5SYNC_MOTD) {
SOURCES -= MessageThread.cpp
HEADERS -= MessageThread.h
} else {
lessThan(QT_MAJOR_VERSION, 5) {
SOURCES -= MessageThread.cpp
HEADERS -= MessageThread.h
DEFINES -= GTA5SYNC_MOTD
message("Messages require Qt5 or newer!")
}
}
# CMAKE BASED STUFF
greaterThan(QT_MAJOR_VERSION, 4) {
message("Building gta5view with QMake is deprecated, please use CMake instead!")
}

154
main.cpp
View File

@ -1,6 +1,6 @@
/***************************************************************************** /*****************************************************************************
* gta5view Grand Theft Auto V Profile Viewer * gta5view Grand Theft Auto V Profile Viewer
* Copyright (C) 2016-2018 Syping * Copyright (C) 2016-2021 Syping
* *
* This program is free software: you can redistribute it and/or modify * This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by * it under the terms of the GNU General Public License as published by
@ -31,7 +31,6 @@
#include "IconLoader.h" #include "IconLoader.h"
#include "AppEnv.h" #include "AppEnv.h"
#include "config.h" #include "config.h"
#include <QDesktopWidget>
#include <QStringBuilder> #include <QStringBuilder>
#include <QSignalMapper> #include <QSignalMapper>
#include <QStyleFactory> #include <QStyleFactory>
@ -50,28 +49,39 @@
#include <QLayout> #include <QLayout>
#include <QObject> #include <QObject>
#include <QString> #include <QString>
#include <QDebug>
#include <QFont> #include <QFont>
#include <QFile> #include <QFile>
#ifdef GTA5SYNC_WIN #if QT_VERSION < 0x060000
#include <QDesktopWidget>
#endif
#ifdef Q_OS_WIN
#include "windows.h" #include "windows.h"
#include <iostream> #include <iostream>
#endif #endif
#ifdef GTA5SYNC_MOTD
#include "MessageThread.h"
#endif
#ifdef GTA5SYNC_TELEMETRY #ifdef GTA5SYNC_TELEMETRY
#include "TelemetryClass.h" #include "TelemetryClass.h"
#endif #endif
int main(int argc, char *argv[]) int main(int argc, char *argv[])
{ {
#if QT_VERSION >= 0x050600
#if QT_VERSION < 0x060000
QApplication::setAttribute(Qt::AA_EnableHighDpiScaling, true);
QApplication::setAttribute(Qt::AA_UseHighDpiPixmaps, true);
#endif
#endif
QApplication a(argc, argv); QApplication a(argc, argv);
a.setApplicationName(GTA5SYNC_APPSTR); a.setApplicationName(GTA5SYNC_APPSTR);
a.setApplicationVersion(GTA5SYNC_APPVER); a.setApplicationVersion(GTA5SYNC_APPVER);
a.setQuitOnLastWindowClosed(false); a.setQuitOnLastWindowClosed(false);
QResource::registerResource(":/global/global.rcc");
QSettings settings(GTA5SYNC_APPVENDOR, GTA5SYNC_APPSTR); QSettings settings(GTA5SYNC_APPVENDOR, GTA5SYNC_APPSTR);
settings.beginGroup("Startup"); settings.beginGroup("Startup");
@ -83,41 +93,30 @@ int main(int argc, char *argv[])
settings.sync(); settings.sync();
#endif #endif
bool isFirstStart = settings.value("IsFirstStart", true).toBool();
bool customStyle = settings.value("CustomStyle", false).toBool(); bool customStyle = settings.value("CustomStyle", false).toBool();
QString appStyle = settings.value("AppStyle", "Default").toString(); if (customStyle) {
const QString appStyle = settings.value("AppStyle", "Default").toString();
if (customStyle) if (QStyleFactory::keys().contains(appStyle, Qt::CaseInsensitive)) {
{
if (QStyleFactory::keys().contains(appStyle, Qt::CaseInsensitive))
{
a.setStyle(QStyleFactory::create(appStyle)); a.setStyle(QStyleFactory::create(appStyle));
} }
} }
#ifdef GTA5SYNC_WIN #ifdef Q_OS_WIN
#if QT_VERSION >= 0x050400 #if QT_VERSION >= 0x060000
bool alwaysUseMessageFont = settings.value("AlwaysUseMessageFont", false).toBool(); a.setFont(QApplication::font("QMenu"));
if (QSysInfo::windowsVersion() >= 0x0080 || alwaysUseMessageFont) #elif QT_VERSION >= 0x050400
{ if (QSysInfo::windowsVersion() >= 0x0080) {
// Get Windows Font a.setFont(QApplication::font("QMenu"));
NONCLIENTMETRICS ncm;
ncm.cbSize = sizeof(ncm);
SystemParametersInfo(SPI_GETNONCLIENTMETRICS, ncm.cbSize, &ncm, 0);
LOGFONTW uiFont = ncm.lfMessageFont;
QString uiFontStr(QString::fromStdWString(std::wstring(uiFont.lfFaceName)));
#ifdef GTA5SYNC_DEBUG
qDebug() << QApplication::tr("Font") << QApplication::tr("Selected Font: %1").arg(uiFontStr);
#endif
// Set Application Font
QFont appFont(uiFontStr, 9);
a.setFont(appFont);
} }
#endif #endif
#endif #endif
bool customFont = settings.value("CustomFont", false).toBool();
if (customFont) {
const QFont appFont = qvariant_cast<QFont>(settings.value("AppFont", a.font()));
a.setFont(appFont);
}
QStringList applicationArgs = a.arguments(); QStringList applicationArgs = a.arguments();
QString selectedAction; QString selectedAction;
QString arg1; QString arg1;
@ -131,28 +130,10 @@ int main(int argc, char *argv[])
Telemetry->work(); Telemetry->work();
#endif #endif
if (!applicationArgs.contains("--skip-firststart"))
{
if (isFirstStart)
{
QMessageBox::StandardButton button = QMessageBox::information(a.desktop(), QString("%1 %2").arg(GTA5SYNC_APPSTR, GTA5SYNC_APPVER), QApplication::tr("<h4>Welcome to %1!</h4>You want to configure %1 before you start using it?").arg(GTA5SYNC_APPSTR), QMessageBox::Yes | QMessageBox::No, QMessageBox::No);
if (button == QMessageBox::Yes)
{
ProfileDatabase profileDB;
OptionsDialog optionsDialog(&profileDB);
optionsDialog.setWindowIcon(IconLoader::loadingAppIcon());
optionsDialog.show();
optionsDialog.exec();
}
settings.setValue("IsFirstStart", false);
}
}
#ifdef GTA5SYNC_TELEMETRY #ifdef GTA5SYNC_TELEMETRY
bool telemetryWindowLaunched = settings.value("PersonalUsageDataWindowLaunched", false).toBool(); bool telemetryWindowLaunched = settings.value("PersonalUsageDataWindowLaunched", false).toBool();
bool pushUsageData = settings.value("PushUsageData", false).toBool(); bool pushUsageData = settings.value("PushUsageData", false).toBool();
if (!telemetryWindowLaunched && !pushUsageData) if (!telemetryWindowLaunched && !pushUsageData) {
{
QDialog *telemetryDialog = new QDialog(); QDialog *telemetryDialog = new QDialog();
telemetryDialog->setObjectName(QStringLiteral("TelemetryDialog")); telemetryDialog->setObjectName(QStringLiteral("TelemetryDialog"));
telemetryDialog->setWindowTitle(QString("%1 %2").arg(GTA5SYNC_APPSTR, GTA5SYNC_APPVER)); telemetryDialog->setWindowTitle(QString("%1 %2").arg(GTA5SYNC_APPSTR, GTA5SYNC_APPVER));
@ -184,8 +165,7 @@ int main(int argc, char *argv[])
telemetryDialog->setFixedSize(telemetryDialog->sizeHint()); telemetryDialog->setFixedSize(telemetryDialog->sizeHint());
telemetryDialog->exec(); telemetryDialog->exec();
QObject::disconnect(telemetryButton, SIGNAL(clicked(bool)), telemetryDialog, SLOT(close())); QObject::disconnect(telemetryButton, SIGNAL(clicked(bool)), telemetryDialog, SLOT(close()));
if (telemetryCheckBox->isChecked()) if (telemetryCheckBox->isChecked()) {
{
QSettings telemetrySettings(GTA5SYNC_APPVENDOR, GTA5SYNC_APPSTR); QSettings telemetrySettings(GTA5SYNC_APPVENDOR, GTA5SYNC_APPSTR);
telemetrySettings.beginGroup("Telemetry"); telemetrySettings.beginGroup("Telemetry");
telemetrySettings.setValue("PushUsageData", true); telemetrySettings.setValue("PushUsageData", true);
@ -201,43 +181,35 @@ int main(int argc, char *argv[])
#endif #endif
settings.endGroup(); settings.endGroup();
for (QString currentArg : applicationArgs) for (const QString &currentArg : applicationArgs) {
{
QString reworkedArg; QString reworkedArg;
if (currentArg.left(9) == "-showpic=" && selectedAction == "") if (currentArg.left(9) == "-showpic=" && selectedAction == "") {
{ reworkedArg = QString(currentArg).remove(0,9);
reworkedArg = currentArg.remove(0,9);
arg1 = reworkedArg; arg1 = reworkedArg;
selectedAction = "showpic"; selectedAction = "showpic";
} }
else if (currentArg.left(9) == "-showsgd=" && selectedAction == "") else if (currentArg.left(9) == "-showsgd=" && selectedAction == "") {
{ reworkedArg = QString(currentArg).remove(0,9);
reworkedArg = currentArg.remove(0,9);
arg1 = reworkedArg; arg1 = reworkedArg;
selectedAction = "showsgd"; selectedAction = "showsgd";
} }
else if (selectedAction == "") else if (selectedAction == "") {
{
QFile argumentFile(currentArg); QFile argumentFile(currentArg);
QFileInfo argumentFileInfo(argumentFile); QFileInfo argumentFileInfo(argumentFile);
if (argumentFile.exists()) if (argumentFile.exists()) {
{
QString argumentFileName = argumentFileInfo.fileName(); QString argumentFileName = argumentFileInfo.fileName();
QString argumentFileType = argumentFileName.left(4); QString argumentFileType = argumentFileName.left(4);
QString argumentFileExt = argumentFileName.right(4); QString argumentFileExt = argumentFileName.right(4);
if (argumentFileType == "PGTA" || argumentFileExt == ".g5e") if (argumentFileType == "PGTA" || argumentFileExt == ".g5e") {
{
arg1 = currentArg; arg1 = currentArg;
selectedAction = "showpic"; selectedAction = "showpic";
} }
else if (argumentFileType == "SGTA") else if (argumentFileType == "SGTA") {
{
arg1 = currentArg; arg1 = currentArg;
selectedAction = "showsgd"; selectedAction = "showsgd";
} }
else if (argumentFileType == "MISR") else if (argumentFileType == "MISR") {
{
arg1 = currentArg; arg1 = currentArg;
selectedAction = "showsgd"; selectedAction = "showsgd";
} }
@ -245,8 +217,7 @@ int main(int argc, char *argv[])
} }
} }
if (selectedAction == "showpic") if (selectedAction == "showpic") {
{
CrewDatabase crewDB; CrewDatabase crewDB;
ProfileDatabase profileDB; ProfileDatabase profileDB;
DatabaseThread threadDB(&crewDB); DatabaseThread threadDB(&crewDB);
@ -256,13 +227,13 @@ int main(int argc, char *argv[])
bool readOk = picture.readingPictureFromFile(arg1); bool readOk = picture.readingPictureFromFile(arg1);
picDialog.setWindowIcon(IconLoader::loadingAppIcon()); picDialog.setWindowIcon(IconLoader::loadingAppIcon());
picDialog.setSnapmaticPicture(&picture, readOk); picDialog.setSnapmaticPicture(&picture, readOk);
#ifndef Q_OS_LINUX
picDialog.setWindowFlags(picDialog.windowFlags()^Qt::Dialog^Qt::Window); picDialog.setWindowFlags(picDialog.windowFlags()^Qt::Dialog^Qt::Window);
#endif
int crewID = picture.getSnapmaticProperties().crewID; int crewID = picture.getSnapmaticProperties().crewID;
if (crewID != 0) { crewDB.addCrew(crewID); } if (crewID != 0)
if (!readOk) { return 1; } crewDB.addCrew(crewID);
if (!readOk)
return 1;
QObject::connect(&threadDB, SIGNAL(crewNameFound(int, QString)), &crewDB, SLOT(setCrewName(int, QString))); QObject::connect(&threadDB, SIGNAL(crewNameFound(int, QString)), &crewDB, SLOT(setCrewName(int, QString)));
QObject::connect(&threadDB, SIGNAL(crewNameUpdated()), &picDialog, SLOT(crewNameUpdated())); QObject::connect(&threadDB, SIGNAL(crewNameUpdated()), &picDialog, SLOT(crewNameUpdated()));
@ -276,8 +247,7 @@ int main(int argc, char *argv[])
return a.exec(); return a.exec();
} }
else if (selectedAction == "showsgd") else if (selectedAction == "showsgd") {
{
SavegameDialog savegameDialog; SavegameDialog savegameDialog;
SavegameData savegame; SavegameData savegame;
@ -286,7 +256,8 @@ int main(int argc, char *argv[])
savegameDialog.setSavegameData(&savegame, arg1, readOk); savegameDialog.setSavegameData(&savegame, arg1, readOk);
savegameDialog.setWindowFlags(savegameDialog.windowFlags()^Qt::Dialog^Qt::Window); savegameDialog.setWindowFlags(savegameDialog.windowFlags()^Qt::Dialog^Qt::Window);
if (!readOk) { return 1; } if (!readOk)
return 1;
a.setQuitOnLastWindowClosed(true); a.setQuitOnLastWindowClosed(true);
savegameDialog.show(); savegameDialog.show();
@ -303,9 +274,32 @@ int main(int argc, char *argv[])
QObject::connect(&threadDB, SIGNAL(finished()), &a, SLOT(quit())); QObject::connect(&threadDB, SIGNAL(finished()), &a, SLOT(quit()));
threadDB.start(); threadDB.start();
#ifdef GTA5SYNC_MOTD
uint cacheId;
{
QSettings messageSettings(GTA5SYNC_APPVENDOR, GTA5SYNC_APPSTR);
messageSettings.beginGroup("Messages");
cacheId = messageSettings.value("CacheId", 0).toUInt();
messageSettings.endGroup();
}
MessageThread threadMessage(cacheId);
QObject::connect(&threadMessage, SIGNAL(finished()), &threadDB, SLOT(terminateThread()));
threadMessage.start();
#endif
#ifdef GTA5SYNC_MOTD
UserInterface uiWindow(&profileDB, &crewDB, &threadDB, &threadMessage);
QObject::connect(&threadMessage, SIGNAL(messagesArrived(QJsonObject)), &uiWindow, SLOT(messagesArrived(QJsonObject)));
QObject::connect(&threadMessage, SIGNAL(updateCacheId(uint)), &uiWindow, SLOT(updateCacheId(uint)));
#else
UserInterface uiWindow(&profileDB, &crewDB, &threadDB); UserInterface uiWindow(&profileDB, &crewDB, &threadDB);
#endif
uiWindow.setWindowIcon(IconLoader::loadingAppIcon()); uiWindow.setWindowIcon(IconLoader::loadingAppIcon());
#ifdef GTA5SYNC_FLATPAK
uiWindow.setupDirEnv(false);
#else
uiWindow.setupDirEnv(); uiWindow.setupDirEnv();
#endif
#ifdef Q_OS_ANDROID #ifdef Q_OS_ANDROID
uiWindow.showMaximized(); uiWindow.showMaximized();
#else #else

View File

@ -39,45 +39,45 @@ QJsonDocument::QJsonDocument() : root_(0) {
// Name: QJsonDocument // Name: QJsonDocument
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
QJsonDocument::QJsonDocument(const QJsonObject &object) : root_(0) { QJsonDocument::QJsonDocument(const QJsonObject &object) : root_(0) {
setObject(object); setObject(object);
} }
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
// Name: QJsonDocument // Name: QJsonDocument
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
QJsonDocument::QJsonDocument(const QJsonArray &array) : root_(0) { QJsonDocument::QJsonDocument(const QJsonArray &array) : root_(0) {
setArray(array); setArray(array);
} }
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
// Name: QJsonDocument // Name: QJsonDocument
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
QJsonDocument::QJsonDocument(const QJsonDocument &other) : root_(0) { QJsonDocument::QJsonDocument(const QJsonDocument &other) : root_(0) {
if(other.root_) { if(other.root_) {
root_ = other.root_->clone(); root_ = other.root_->clone();
} }
} }
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
// Name: ~QJsonDocument // Name: ~QJsonDocument
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
QJsonDocument::~QJsonDocument() { QJsonDocument::~QJsonDocument() {
delete root_; delete root_;
} }
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
// Name: operator= // Name: operator=
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
QJsonDocument &QJsonDocument::operator=(const QJsonDocument &other) { QJsonDocument &QJsonDocument::operator=(const QJsonDocument &other) {
QJsonDocument(other).swap(*this); QJsonDocument(other).swap(*this);
return *this; return *this;
} }
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
// Name: operator!= // Name: operator!=
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
bool QJsonDocument::operator!=(const QJsonDocument &other) const { bool QJsonDocument::operator!=(const QJsonDocument &other) const {
return !(*this == other); return !(*this == other);
} }
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
@ -85,30 +85,30 @@ bool QJsonDocument::operator!=(const QJsonDocument &other) const {
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
bool QJsonDocument::operator==(const QJsonDocument &other) const { bool QJsonDocument::operator==(const QJsonDocument &other) const {
if(isArray() && other.isArray()) { if(isArray() && other.isArray()) {
return array() == other.array(); return array() == other.array();
} }
if(isObject() && other.isObject()) { if(isObject() && other.isObject()) {
return object() == other.object(); return object() == other.object();
} }
if(isEmpty() && other.isEmpty()) { if(isEmpty() && other.isEmpty()) {
return true; return true;
} }
if(isNull() && other.isNull()) { if(isNull() && other.isNull()) {
return true; return true;
} }
return false; return false;
} }
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
// Name: isArray // Name: isArray
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
bool QJsonDocument::isArray() const { bool QJsonDocument::isArray() const {
return root_ && root_->toArray(); return root_ && root_->toArray();
} }
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
@ -116,56 +116,56 @@ bool QJsonDocument::isArray() const {
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
bool QJsonDocument::isEmpty() const { bool QJsonDocument::isEmpty() const {
// TODO(eteran): figure out the rules here that Qt5 uses // TODO(eteran): figure out the rules here that Qt5 uses
// it *looks* like they define empty as being NULL // it *looks* like they define empty as being NULL
// which is obviously different than this // which is obviously different than this
return !root_; return !root_;
} }
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
// Name: isNull // Name: isNull
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
bool QJsonDocument::isNull() const { bool QJsonDocument::isNull() const {
return !root_; return !root_;
} }
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
// Name: isObject // Name: isObject
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
bool QJsonDocument::isObject() const { bool QJsonDocument::isObject() const {
return root_ && root_->toObject(); return root_ && root_->toObject();
} }
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
// Name: setArray // Name: setArray
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
void QJsonDocument::setArray(const QJsonArray &array) { void QJsonDocument::setArray(const QJsonArray &array) {
setRoot(array); setRoot(array);
} }
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
// Name: setObject // Name: setObject
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
void QJsonDocument::setObject(const QJsonObject &object) { void QJsonDocument::setObject(const QJsonObject &object) {
setRoot(object); setRoot(object);
} }
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
// Name: setRoot // Name: setRoot
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
void QJsonDocument::setRoot(const QJsonRoot &root) { void QJsonDocument::setRoot(const QJsonRoot &root) {
delete root_; delete root_;
root_ = root.clone(); root_ = root.clone();
} }
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
// Name: toBinaryData // Name: toBinaryData
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
QByteArray QJsonDocument::toBinaryData() const { QByteArray QJsonDocument::toBinaryData() const {
QByteArray r; QByteArray r;
// TODO(eteran): implement this // TODO(eteran): implement this
return r; return r;
} }
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
@ -173,100 +173,107 @@ QByteArray QJsonDocument::toBinaryData() const {
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
QString QJsonDocument::escapeString(const QString &s) const { QString QJsonDocument::escapeString(const QString &s) const {
QString r; QString r;
Q_FOREACH(QChar ch, s) { Q_FOREACH(QChar ch, s) {
switch(ch.toLatin1()) { switch(ch.toLatin1()) {
case '\"': r.append("\\\""); break; case '\"': r.append("\\\""); break;
case '\\': r.append("\\\\"); break; case '\\': r.append("\\\\"); break;
#if 0 #if 0
case '/': r.append("\\/"); break; case '/': r.append("\\/"); break;
#endif #endif
case '\b': r.append("\\b"); break; case '\b': r.append("\\b"); break;
case '\f': r.append("\\f"); break; case '\f': r.append("\\f"); break;
case '\n': r.append("\\n"); break; case '\n': r.append("\\n"); break;
case '\r': r.append("\\r"); break; case '\r': r.append("\\r"); break;
case '\t': r.append("\\t"); break; case '\t': r.append("\\t"); break;
default: default:
r += ch; r += ch;
break; break;
} }
} }
return r; return r;
} }
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
// Name: toJson // Name: toJson
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
QString QJsonDocument::toJson(const QJsonValue &v, JsonFormat format) const { QString QJsonDocument::toJson(const QJsonValue &v, JsonFormat format, int indent) const {
QString b; QString b;
QTextStream ss(&b, QIODevice::WriteOnly | QIODevice::Text); QTextStream ss(&b, QIODevice::WriteOnly | QIODevice::Text);
bool compact = (format == JsonFormat::Compact);
switch(v.type()) { switch(v.type()) {
case QJsonValue::Null: case QJsonValue::Null:
ss << "null"; ss << "null";
break; break;
case QJsonValue::Bool: case QJsonValue::Bool:
ss << (v.toBool() ? "true" : "false"); ss << (v.toBool() ? "true" : "false");
break; break;
case QJsonValue::Double: case QJsonValue::Double:
{ {
double d = v.toDouble (); double d = v.toDouble ();
if (qIsFinite(d)) { if (qIsFinite(d)) {
// +2 to format to ensure the expected precision // +2 to format to ensure the expected precision
ss << QByteArray::number(d, 'g', 15 + 2); // ::digits10 is 15 ss << QByteArray::number(d, 'g', 15 + 2); // ::digits10 is 15
} else { } else {
ss << "null"; // +INF || -INF || NaN (see RFC4627#section2.4) ss << "null"; // +INF || -INF || NaN (see RFC4627#section2.4)
} }
} }
break; break;
case QJsonValue::String: case QJsonValue::String:
ss << '"' << escapeString(v.toString()) << '"'; ss << '"' << escapeString(v.toString()) << '"';
break; break;
case QJsonValue::Array: case QJsonValue::Array:
{ {
const QJsonArray a = v.toArray(); const QJsonArray a = v.toArray();
ss << "["; ss << (compact ? "[" : "[\n");
if(!a.empty()) { if(!a.empty()) {
QJsonArray::const_iterator it = a.begin(); QJsonArray::const_iterator it = a.begin();
QJsonArray::const_iterator e = a.end(); QJsonArray::const_iterator e = a.end();
ss << toJson(*it++, format); if (!compact) ss << QByteArray(4*indent, ' ');
ss << toJson(*it++, format, indent+1);
for(;it != e; ++it) { for(;it != e; ++it) {
ss << ','; ss << (compact ? "," : ",\n");
ss << toJson(*it, format); if (!compact) ss << QByteArray(4*indent, ' ');
} ss << toJson(*it, format, indent+1);
} }
ss << "]"; }
} indent--;
break; ss << (compact ? "]" : QString("\n%1]").arg(QString(4*indent, ' ')));
case QJsonValue::Object: }
{ break;
const QJsonObject o = v.toObject(); case QJsonValue::Object:
ss << "{"; {
if(!o.empty()) { const QJsonObject o = v.toObject();
QJsonObject::const_iterator it = o.begin(); ss << (compact ? "{" : "{\n");
QJsonObject::const_iterator e = o.end(); if(!o.empty()) {
QJsonObject::const_iterator it = o.begin();
QJsonObject::const_iterator e = o.end();
ss << '"' << escapeString(it.key()) << "\": " << toJson(it.value(), format); if (!compact) ss << QByteArray(4*indent, ' ');
++it; ss << '"' << escapeString(it.key()) << (compact ? "\":" : "\": ") << toJson(it.value(), format, indent+1);
for(;it != e; ++it) { ++it;
ss << ','; for(;it != e; ++it) {
ss << '"' << escapeString(it.key()) << "\": " << toJson(it.value(), format); ss << (compact ? "," : ",\n");
} if (!compact) ss << QByteArray(4*indent, ' ');
} ss << '"' << escapeString(it.key()) << (compact ? "\":" : "\": ") << toJson(it.value(), format, indent+1);
ss << "}"; }
} }
break; indent--;
case QJsonValue::Undefined: ss << (compact ? "}" : QString("\n%1}").arg(QString(4*indent, ' ')));
Q_ASSERT(0); }
break; break;
} case QJsonValue::Undefined:
Q_ASSERT(0);
break;
}
return b; return b;
} }
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
@ -274,19 +281,19 @@ QString QJsonDocument::toJson(const QJsonValue &v, JsonFormat format) const {
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
QByteArray QJsonDocument::toJson(JsonFormat format) const { QByteArray QJsonDocument::toJson(JsonFormat format) const {
Q_UNUSED(format); Q_UNUSED(format);
if(isArray()) { if(isArray()) {
QString s = toJson(array(), format); QString s = toJson(array(), format);
return s.toUtf8(); return s.toUtf8();
} }
if(isObject()) { if(isObject()) {
QString s = toJson(object(), format); QString s = toJson(object(), format);
return s.toUtf8(); return s.toUtf8();
} }
return QByteArray(); return QByteArray();
} }
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
@ -294,17 +301,17 @@ QByteArray QJsonDocument::toJson(JsonFormat format) const {
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
QVariant QJsonDocument::toVariant() const { QVariant QJsonDocument::toVariant() const {
if(!isEmpty()) { if(!isEmpty()) {
if(QJsonObject *const object = root_->toObject()) { if(QJsonObject *const object = root_->toObject()) {
return object->toVariantMap(); return object->toVariantMap();
} }
if(QJsonArray *const array = root_->toArray()) { if(QJsonArray *const array = root_->toArray()) {
return array->toVariantList(); return array->toVariantList();
} }
} }
return QVariant(); return QVariant();
} }
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
@ -312,13 +319,13 @@ QVariant QJsonDocument::toVariant() const {
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
QJsonArray QJsonDocument::array() const { QJsonArray QJsonDocument::array() const {
if(!isEmpty()) { if(!isEmpty()) {
if(QJsonArray *const array = root_->toArray()) { if(QJsonArray *const array = root_->toArray()) {
return *array; return *array;
} }
} }
return QJsonArray(); return QJsonArray();
} }
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
@ -326,54 +333,54 @@ QJsonArray QJsonDocument::array() const {
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
QJsonObject QJsonDocument::object() const { QJsonObject QJsonDocument::object() const {
if(!isEmpty()) { if(!isEmpty()) {
if(QJsonObject *const object = root_->toObject()) { if(QJsonObject *const object = root_->toObject()) {
return *object; return *object;
} }
} }
return QJsonObject(); return QJsonObject();
} }
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
// Name: rawData // Name: rawData
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
const char *QJsonDocument::rawData(int *size) const { const char *QJsonDocument::rawData(int *size) const {
Q_UNUSED(size); Q_UNUSED(size);
// TODO(eteran): implement this // TODO(eteran): implement this
return 0; return 0;
} }
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
// Name: fromBinaryData // Name: fromBinaryData
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
QJsonDocument QJsonDocument::fromBinaryData(const QByteArray &data, DataValidation validation) { QJsonDocument QJsonDocument::fromBinaryData(const QByteArray &data, DataValidation validation) {
Q_UNUSED(data); Q_UNUSED(data);
Q_UNUSED(validation); Q_UNUSED(validation);
QJsonDocument doc; QJsonDocument doc;
// TODO(eteran): implement this // TODO(eteran): implement this
return doc; return doc;
} }
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
// Name: fromJson // Name: fromJson
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
QJsonDocument QJsonDocument::fromJson(const QByteArray &json, QJsonParseError *error) { QJsonDocument QJsonDocument::fromJson(const QByteArray &json, QJsonParseError *error) {
QJsonDocument doc; QJsonDocument doc;
const char *const begin = json.constData(); const char *const begin = json.constData();
const char *const end = begin + json.size(); const char *const end = begin + json.size();
QJsonParser parser(begin, end); QJsonParser parser(begin, end);
doc.root_ = parser.parse(); doc.root_ = parser.parse();
if(error) { if(error) {
*error = parser.state(); *error = parser.state();
} }
return doc; return doc;
} }
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
@ -381,10 +388,10 @@ QJsonDocument QJsonDocument::fromJson(const QByteArray &json, QJsonParseError *e
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
QJsonDocument QJsonDocument::fromRawData(const char *data, int size, DataValidation validation) { QJsonDocument QJsonDocument::fromRawData(const char *data, int size, DataValidation validation) {
// data has to be aligned to a 4 byte boundary. // data has to be aligned to a 4 byte boundary.
Q_ASSERT(!(reinterpret_cast<quintptr>(data) % 3)); Q_ASSERT(!(reinterpret_cast<quintptr>(data) % 3));
return fromBinaryData(QByteArray::fromRawData(data, size), validation); return fromBinaryData(QByteArray::fromRawData(data, size), validation);
} }
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
@ -392,26 +399,26 @@ QJsonDocument QJsonDocument::fromRawData(const char *data, int size, DataValidat
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
QJsonDocument QJsonDocument::fromVariant(const QVariant &variant) { QJsonDocument QJsonDocument::fromVariant(const QVariant &variant) {
QJsonDocument doc; QJsonDocument doc;
if (variant.type() == QVariant::Map) { if (variant.type() == QVariant::Map) {
doc.setObject(QJsonObject::fromVariantMap(variant.toMap())); doc.setObject(QJsonObject::fromVariantMap(variant.toMap()));
} else if (variant.type() == QVariant::Hash) { } else if (variant.type() == QVariant::Hash) {
doc.setObject(QJsonObject::fromVariantHash(variant.toHash())); doc.setObject(QJsonObject::fromVariantHash(variant.toHash()));
} else if (variant.type() == QVariant::List) { } else if (variant.type() == QVariant::List) {
doc.setArray(QJsonArray::fromVariantList(variant.toList())); doc.setArray(QJsonArray::fromVariantList(variant.toList()));
} else if (variant.type() == QVariant::StringList) { } else if (variant.type() == QVariant::StringList) {
doc.setArray(QJsonArray::fromStringList(variant.toStringList())); doc.setArray(QJsonArray::fromStringList(variant.toStringList()));
} }
return doc; return doc;
} }
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
// Name: swap // Name: swap
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
void QJsonDocument::swap(QJsonDocument &other) { void QJsonDocument::swap(QJsonDocument &other) {
qSwap(root_, other.root_); qSwap(root_, other.root_);
} }
#endif #endif

View File

@ -36,66 +36,66 @@ class QJsonRoot;
class QJsonDocument { class QJsonDocument {
public: public:
enum DataValidation { enum DataValidation {
Validate = 0, Validate = 0,
BypassValidation = 1 BypassValidation = 1
}; };
enum JsonFormat { enum JsonFormat {
Indented, Indented,
Compact Compact
}; };
public: public:
QJsonDocument(); QJsonDocument();
QJsonDocument(const QJsonObject &object); QJsonDocument(const QJsonObject &object);
QJsonDocument(const QJsonArray &array); QJsonDocument(const QJsonArray &array);
QJsonDocument(const QJsonDocument &other); QJsonDocument(const QJsonDocument &other);
~QJsonDocument(); ~QJsonDocument();
public: public:
QJsonDocument &operator=(const QJsonDocument &other); QJsonDocument &operator=(const QJsonDocument &other);
public: public:
bool operator!=(const QJsonDocument &other) const; bool operator!=(const QJsonDocument &other) const;
bool operator==(const QJsonDocument &other) const; bool operator==(const QJsonDocument &other) const;
public: public:
bool isArray() const; bool isArray() const;
bool isEmpty() const; bool isEmpty() const;
bool isNull() const; bool isNull() const;
bool isObject() const; bool isObject() const;
public: public:
QByteArray toBinaryData() const; QByteArray toBinaryData() const;
QByteArray toJson(JsonFormat format = Indented) const; QByteArray toJson(JsonFormat format = Indented) const;
QVariant toVariant() const; QVariant toVariant() const;
public: public:
QJsonArray array() const; QJsonArray array() const;
QJsonObject object() const; QJsonObject object() const;
const char *rawData(int *size) const; const char *rawData(int *size) const;
public: public:
void setArray(const QJsonArray &array); void setArray(const QJsonArray &array);
void setObject(const QJsonObject &object); void setObject(const QJsonObject &object);
public: public:
static QJsonDocument fromBinaryData(const QByteArray &data, DataValidation validation = Validate); static QJsonDocument fromBinaryData(const QByteArray &data, DataValidation validation = Validate);
static QJsonDocument fromJson(const QByteArray &json, QJsonParseError *error = 0); static QJsonDocument fromJson(const QByteArray &json, QJsonParseError *error = 0);
static QJsonDocument fromRawData(const char *data, int size, DataValidation validation = Validate); static QJsonDocument fromRawData(const char *data, int size, DataValidation validation = Validate);
static QJsonDocument fromVariant(const QVariant &variant); static QJsonDocument fromVariant(const QVariant &variant);
private: private:
void setRoot(const QJsonRoot &root); void setRoot(const QJsonRoot &root);
QString toJson(const QJsonValue &v, JsonFormat format) const; QString toJson(const QJsonValue &v, JsonFormat format, int indent = 1) const;
QString escapeString(const QString &s) const; QString escapeString(const QString &s) const;
private: private:
void swap(QJsonDocument &other); void swap(QJsonDocument &other);
private: private:
QJsonRoot *root_; QJsonRoot *root_;
}; };
#endif #endif

Binary file not shown.

Before

Width:  |  Height:  |  Size: 38 KiB

After

Width:  |  Height:  |  Size: 88 KiB

BIN
res/add.svgz Normal file

Binary file not shown.

View File

@ -1,33 +0,0 @@
<RCC>
<qresource prefix="/img">
<file>5sync-48.png</file>
<file>5sync-16.png</file>
<file>5sync-24.png</file>
<file>5sync-32.png</file>
<file>5sync-40.png</file>
<file>5sync-64.png</file>
<file>5sync-96.png</file>
<file>5sync-128.png</file>
<file>5sync-256.png</file>
<file>avatararea.png</file>
<file>avatarareaimport.png</file>
<file>back.png</file>
<file>empty1x16.png</file>
<file>mappreview.jpg</file>
<file>next.png</file>
<file>pointmaker-8.png</file>
<file>pointmaker-16.png</file>
<file>pointmaker-24.png</file>
<file>pointmaker-32.png</file>
<file>savegame.png</file>
<file>watermark_1b.png</file>
<file>watermark_2b.png</file>
<file>watermark_2r.png</file>
</qresource>
<qresource prefix="/global">
<file>global.rcc</file>
</qresource>
<qresource prefix="/template">
<file>template.g5e</file>
</qresource>
</RCC>

View File

@ -1,14 +1,11 @@
IDI_ICON1 ICON DISCARDABLE "5sync.ico" IDI_ICON1 ICON DISCARDABLE "5sync.ico"
#define RT_MANIFEST 24 #define RT_MANIFEST 24
#define CREATEPROCESS_MANIFEST_RESOURCE_ID 1 #define CREATEPROCESS_MANIFEST_RESOURCE_ID 1
CREATEPROCESS_MANIFEST_RESOURCE_ID RT_MANIFEST "gta5view.exe.manifest" CREATEPROCESS_MANIFEST_RESOURCE_ID RT_MANIFEST "gta5view.exe.manifest"
#include <windows.h> #include <windows.h>
VS_VERSION_INFO VERSIONINFO VS_VERSION_INFO VERSIONINFO
FILEVERSION 1, 6, 0, 0 FILEVERSION 1, 10, 2, 0
PRODUCTVERSION 1, 6, 0, 0 PRODUCTVERSION 1, 10, 2, 0
FILEFLAGSMASK 0x3fL FILEFLAGSMASK 0x3fL
FILEFLAGS 0 FILEFLAGS 0
FILEOS VOS_NT_WINDOWS32 FILEOS VOS_NT_WINDOWS32
@ -25,12 +22,12 @@ BEGIN
BEGIN BEGIN
VALUE "CompanyName", "Syping" VALUE "CompanyName", "Syping"
VALUE "FileDescription", "gta5view" VALUE "FileDescription", "gta5view"
VALUE "FileVersion", "1.6.0" VALUE "FileVersion", "1.10.2"
VALUE "InternalName", "gta5view" VALUE "InternalName", "gta5view"
VALUE "LegalCopyright", "Copyright © 2016-2018 Syping" VALUE "LegalCopyright", "Copyright © 2016-2023 Syping"
VALUE "OriginalFilename", "gta5view.exe" VALUE "OriginalFilename", "gta5view.exe"
VALUE "ProductName", "gta5view" VALUE "ProductName", "gta5view"
VALUE "ProductVersion", "1.6.0" VALUE "ProductVersion", "1.10.2"
END END
END END
END END

Binary file not shown.

Before

Width:  |  Height:  |  Size: 317 B

BIN
res/back.svgz Normal file

Binary file not shown.

1
res/btc.str Normal file
View File

@ -0,0 +1 @@
Bitcoin

BIN
res/btc.svgz Normal file

Binary file not shown.

View File

@ -0,0 +1,13 @@
[Desktop Entry]
Type=Application
Name=gta5view
Comment=Open and edit GTA V profiles
Comment[de]=GTA V Profile öffnen und bearbeiten
Comment[ko]=GTA V
Comment[ru]=Просмотрщик и редактор профилей GTA V
Comment[zh_TW]= GTA V
Categories=Qt;Utility;FileTools;
TryExec=gta5view
Exec=gta5view %f
Icon=de.syping.gta5view
MimeType=application/x-gta5view-export;

View File

@ -0,0 +1,72 @@
<?xml version="1.0" encoding="UTF-8"?>
<!-- Copyright 2021 Syping -->
<component type="desktop-application">
<id>de.syping.gta5view</id>
<launchable type="desktop-id">de.syping.gta5view.desktop</launchable>
<metadata_license>CC0-1.0</metadata_license>
<project_license>GPL-3.0+</project_license>
<name>gta5view</name>
<summary>Open and edit GTA V profiles</summary>
<summary xml:lang="de">GTA V Profile öffnen und bearbeiten</summary>
<summary xml:lang="ko">GTA V 프로필을 열고 편집</summary>
<summary xml:lang="ru">Просмотрщик и редактор профилей GTA V</summary>
<summary xml:lang="zh-TW">打開與編輯 GTA V 個人檔案</summary>
<icon type="remote">https://img.syping.de/gta5view/gta5view.png</icon>
<description>
<p>Open Source Snapmatic and Savegame viewer/editor for GTA V</p>
<p>Features</p>
<ul>
<li>View Snapmatics with the ability to disable them in-game</li>
<li>Edit Snapmatic pictures and properties in multiple ways</li>
<li>Import/Export Snapmatics, Savegames and pictures</li>
<li>Choose between multiple Social Club accounts as GTA V profiles IDs</li>
</ul>
</description>
<categories>
<category>Utility</category>
</categories>
<developer_name>Syping</developer_name>
<releases>
<release date="2023-03-15" version="1.10.2"/>
<release date="2021-06-17" version="1.10.1"/>
<release date="2021-05-27" version="1.10.0"/>
<release date="2021-03-22" version="1.9.2"/>
<release date="2020-12-16" version="1.9.1"/>
<release date="2020-11-30" version="1.9.0"/>
<release date="2020-10-11" version="1.8.0"/>
</releases>
<screenshots>
<screenshot type="default">
<caption>User Interface</caption>
<image type="source">https://img.syping.de/gta5view/mainui_kde.png</image>
</screenshot>
<screenshot>
<caption>Snapmatic Viewer</caption>
<image type="source">https://img.syping.de/gta5view/picture_kde.png</image>
</screenshot>
<screenshot>
<caption>Picture Importer</caption>
<image type="source">https://img.syping.de/gta5view/import_kde.png</image>
</screenshot>
<screenshot>
<caption>Snapmatic Player Editor</caption>
<image type="source">https://img.syping.de/gta5view/players_kde.png</image>
</screenshot>
<screenshot>
<caption>Snapmatic Property Editor</caption>
<image type="source">https://img.syping.de/gta5view/prop_kde.png</image>
</screenshot>
</screenshots>
<content_rating type="oars-1.1" />
<url type="homepage">https://gta5view.syping.de/</url>
</component>

View File

Before

Width:  |  Height:  |  Size: 13 KiB

After

Width:  |  Height:  |  Size: 13 KiB

View File

@ -0,0 +1,8 @@
<?xml version="1.0" encoding="utf-8"?>
<mime-info xmlns="http://www.freedesktop.org/standards/shared-mime-info">
<mime-type type="application/x-gta5view-export">
<comment>gta5view Export</comment>
<glob pattern="*.g5e"/>
<generic-icon name="de.syping.gta5view"/>
</mime-type>
</mime-info>

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