Open Source Snapmatic picture and Savegame viewer/editor for GTA V https://gta5view.syping.de/

OptionsDialog.cpp 25KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737
  1. /*****************************************************************************
  2. * gta5view Grand Theft Auto V Profile Viewer
  3. * Copyright (C) 2016-2018 Syping
  4. *
  5. * This program is free software: you can redistribute it and/or modify
  6. * it under the terms of the GNU General Public License as published by
  7. * the Free Software Foundation, either version 3 of the License, or
  8. * (at your option) any later version.
  9. *
  10. * This program is distributed in the hope that it will be useful,
  11. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  13. * GNU General Public License for more details.
  14. *
  15. * You should have received a copy of the GNU General Public License
  16. * along with this program. If not, see <http://www.gnu.org/licenses/>.
  17. *****************************************************************************/
  18. #include "OptionsDialog.h"
  19. #include "ui_OptionsDialog.h"
  20. #include "TranslationClass.h"
  21. #include "StandardPaths.h"
  22. #include "UserInterface.h"
  23. #include "AppEnv.h"
  24. #include "config.h"
  25. #include <QStringBuilder>
  26. #include <QDesktopWidget>
  27. #include <QJsonDocument>
  28. #include <QStyleFactory>
  29. #include <QApplication>
  30. #include <QJsonObject>
  31. #include <QFileDialog>
  32. #include <QMessageBox>
  33. #include <QStringList>
  34. #include <QClipboard>
  35. #include <QLocale>
  36. #include <QString>
  37. #include <QTimer>
  38. #include <QDebug>
  39. #include <QList>
  40. #include <QDir>
  41. #ifdef GTA5SYNC_TELEMETRY
  42. #include "TelemetryClass.h"
  43. #endif
  44. OptionsDialog::OptionsDialog(ProfileDatabase *profileDB, QWidget *parent) :
  45. QDialog(parent), profileDB(profileDB),
  46. ui(new Ui::OptionsDialog)
  47. {
  48. // Set Window Flags
  49. setWindowFlags(windowFlags()^Qt::WindowContextHelpButtonHint);
  50. // Setup User Interface
  51. ui->setupUi(this);
  52. ui->tabWidget->setCurrentIndex(0);
  53. ui->labPicCustomRes->setVisible(false);
  54. ui->cmdCancel->setDefault(true);
  55. ui->cmdCancel->setFocus();
  56. QRect desktopResolution = QApplication::desktop()->screenGeometry(this);
  57. int desktopSizeWidth = desktopResolution.width();
  58. int desktopSizeHeight = desktopResolution.height();
  59. aspectRatio = Qt::KeepAspectRatio;
  60. defExportSize = QSize(960, 536);
  61. cusExportSize = defExportSize;
  62. defaultQuality = 100;
  63. customQuality = 100;
  64. contentMode = 0;
  65. settings = new QSettings(GTA5SYNC_APPVENDOR, GTA5SYNC_APPSTR);
  66. percentString = ui->labPicQuality->text();
  67. ui->labPicQuality->setText(percentString.arg(QString::number(defaultQuality)));
  68. ui->rbPicDesktopRes->setText(ui->rbPicDesktopRes->text().arg(QString::number(desktopSizeWidth), QString::number(desktopSizeHeight)));
  69. ui->rbPicDefaultRes->setText(ui->rbPicDefaultRes->text().arg(QString::number(defExportSize.width()), QString::number(defExportSize.height())));
  70. // Set Icon for OK Button
  71. if (QIcon::hasThemeIcon("dialog-ok"))
  72. {
  73. ui->cmdOK->setIcon(QIcon::fromTheme("dialog-ok"));
  74. }
  75. else if (QIcon::hasThemeIcon("gtk-ok"))
  76. {
  77. ui->cmdOK->setIcon(QIcon::fromTheme("gtk-ok"));
  78. }
  79. // Set Icon for Cancel Button
  80. if (QIcon::hasThemeIcon("dialog-cancel"))
  81. {
  82. ui->cmdCancel->setIcon(QIcon::fromTheme("dialog-cancel"));
  83. }
  84. else if (QIcon::hasThemeIcon("gtk-cancel"))
  85. {
  86. ui->cmdCancel->setIcon(QIcon::fromTheme("gtk-cancel"));
  87. }
  88. setupTreeWidget();
  89. setupLanguageBox();
  90. setupRadioButtons();
  91. setupDefaultProfile();
  92. setupPictureSettings();
  93. setupCustomGTAFolder();
  94. setupInterfaceSettings();
  95. setupStatisticsSettings();
  96. setupSnapmaticPictureViewer();
  97. setupWindowsGameSettings();
  98. #ifndef Q_QS_ANDROID
  99. // DPI calculation
  100. qreal screenRatio = AppEnv::screenRatio();
  101. resize(435 * screenRatio, 405 * screenRatio);
  102. #endif
  103. setWindowTitle(windowTitle().arg(GTA5SYNC_APPSTR));
  104. }
  105. OptionsDialog::~OptionsDialog()
  106. {
  107. delete settings;
  108. qDeleteAll(playerItems.begin(), playerItems.end());
  109. playerItems.clear();
  110. delete ui;
  111. }
  112. void OptionsDialog::setupTreeWidget()
  113. {
  114. for (QString playerIDStr : profileDB->getPlayers())
  115. {
  116. bool ok;
  117. int playerID = playerIDStr.toInt(&ok);
  118. if (ok)
  119. {
  120. QString playerName = profileDB->getPlayerName(playerID);
  121. QStringList playerTreeViewList;
  122. playerTreeViewList += playerIDStr;
  123. playerTreeViewList += playerName;
  124. QTreeWidgetItem *playerItem = new QTreeWidgetItem(playerTreeViewList);
  125. ui->twPlayers->addTopLevelItem(playerItem);
  126. playerItems += playerItem;
  127. }
  128. }
  129. ui->twPlayers->sortItems(1, Qt::AscendingOrder);
  130. }
  131. void OptionsDialog::setupLanguageBox()
  132. {
  133. settings->beginGroup("Interface");
  134. currentLanguage = settings->value("Language", "System").toString();
  135. currentAreaLanguage = settings->value("AreaLanguage", "Auto").toString();
  136. settings->endGroup();
  137. QString cbSysStr = tr("%1 (Language priority)", "First language a person can talk with a different person/application. \"Native\" or \"Not Native\".").arg(tr("System",
  138. "System in context of System default"));
  139. #ifdef GTA5SYNC_WIN
  140. QString cbAutoStr;
  141. if (AppEnv::getGameLanguage(AppEnv::getGameVersion()) != GameLanguage::Undefined)
  142. {
  143. cbAutoStr = tr("%1 (Game language)", "Next closest language compared to the Game settings").arg(tr("Auto", "Automatic language choice."));
  144. }
  145. else
  146. {
  147. cbAutoStr = tr("%1 (Closest to Interface)", "Next closest language compared to the Interface").arg(tr("Auto", "Automatic language choice."));
  148. }
  149. #else
  150. QString cbAutoStr = tr("%1 (Closest to Interface)", "Next closest language compared to the Interface").arg(tr("Auto", "Automatic language choice."));
  151. #endif
  152. ui->cbLanguage->addItem(cbSysStr, "System");
  153. ui->cbAreaLanguage->addItem(cbAutoStr, "Auto");
  154. QStringList availableLanguages;
  155. availableLanguages << QString("en_GB");
  156. #ifndef GTA5SYNC_QCONF
  157. availableLanguages << TranslationClass::listTranslations(AppEnv::getExLangFolder());
  158. #endif
  159. availableLanguages << TranslationClass::listTranslations(AppEnv::getInLangFolder());
  160. availableLanguages.removeDuplicates();
  161. availableLanguages.sort();
  162. for (QString lang : availableLanguages)
  163. {
  164. QLocale langLocale(lang);
  165. QString cbLangStr = langLocale.nativeLanguageName() % " (" % langLocale.nativeCountryName() % ") [" % lang % "]";
  166. QString langIconStr = "flag-" % TranslationClass::getCountryCode(langLocale);
  167. ui->cbLanguage->addItem(QIcon::fromTheme(langIconStr), cbLangStr, lang);
  168. if (currentLanguage == lang)
  169. {
  170. #if QT_VERSION >= 0x050000
  171. ui->cbLanguage->setCurrentText(cbLangStr);
  172. #else
  173. int indexOfLang = ui->cbLanguage->findText(cbLangStr);
  174. ui->cbLanguage->setCurrentIndex(indexOfLang);
  175. #endif
  176. }
  177. }
  178. QString aCurrentLanguage = QString("en_GB");
  179. if (Translator->isLanguageLoaded()) { aCurrentLanguage = Translator->getCurrentLanguage(); }
  180. QLocale currentLocale = QLocale(aCurrentLanguage);
  181. ui->labCurrentLanguage->setText(tr("Current: %1").arg(currentLocale.nativeLanguageName() % " (" % currentLocale.nativeCountryName() % ") [" % aCurrentLanguage % "]"));
  182. availableLanguages.clear();
  183. availableLanguages << TranslationClass::listAreaTranslations();
  184. availableLanguages.removeDuplicates();
  185. availableLanguages.sort();
  186. for (QString lang : availableLanguages)
  187. {
  188. // correcting Language Location if possible
  189. QString aLang = lang;
  190. if (QFile::exists(":/global/global." % lang % ".loc"))
  191. {
  192. QFile locFile(":/global/global." % lang % ".loc");
  193. if (locFile.open(QFile::ReadOnly))
  194. {
  195. aLang = QString::fromUtf8(locFile.readLine()).trimmed();
  196. locFile.close();
  197. }
  198. }
  199. QLocale langLocale(aLang);
  200. QString cbLangStr = langLocale.nativeLanguageName() % " (" % langLocale.nativeCountryName() % ") [" % aLang % "]";
  201. QString langIconStr = "flag-" % TranslationClass::getCountryCode(langLocale);
  202. ui->cbAreaLanguage->addItem(QIcon::fromTheme(langIconStr), cbLangStr, lang);
  203. if (currentAreaLanguage == lang)
  204. {
  205. #if QT_VERSION >= 0x050000
  206. ui->cbAreaLanguage->setCurrentText(cbLangStr);
  207. #else
  208. int indexOfLang = ui->cbAreaLanguage->findText(cbLangStr);
  209. ui->cbAreaLanguage->setCurrentIndex(indexOfLang);
  210. #endif
  211. }
  212. }
  213. QString aCurrentAreaLanguage = Translator->getCurrentAreaLanguage();
  214. if (QFile::exists(":/global/global." % aCurrentAreaLanguage % ".loc"))
  215. {
  216. qDebug() << "locFile found";
  217. QFile locFile(":/global/global." % aCurrentAreaLanguage % ".loc");
  218. if (locFile.open(QFile::ReadOnly))
  219. {
  220. aCurrentAreaLanguage = QString::fromUtf8(locFile.readLine()).trimmed();
  221. locFile.close();
  222. }
  223. }
  224. currentLocale = QLocale(aCurrentAreaLanguage);
  225. ui->labCurrentAreaLanguage->setText(tr("Current: %1").arg(currentLocale.nativeLanguageName() % " (" % currentLocale.nativeCountryName() % ") [" % aCurrentAreaLanguage % "]"));
  226. }
  227. void OptionsDialog::setupRadioButtons()
  228. {
  229. bool contentModeOk;
  230. settings->beginGroup("Profile");
  231. contentMode = settings->value("ContentMode", 0).toInt(&contentModeOk);
  232. settings->endGroup();
  233. if (contentModeOk)
  234. {
  235. switch (contentMode)
  236. {
  237. case 0:
  238. ui->rbOpenWithSC->setChecked(true);
  239. break;
  240. case 1:
  241. ui->rbOpenWithDC->setChecked(true);
  242. break;
  243. case 2:
  244. ui->rbSelectWithSC->setChecked(true);
  245. break;
  246. }
  247. }
  248. }
  249. void OptionsDialog::setupInterfaceSettings()
  250. {
  251. settings->beginGroup("Startup");
  252. bool alwaysUseMessageFont = settings->value("AlwaysUseMessageFont", false).toBool();
  253. ui->cbAlwaysUseMessageFont->setChecked(alwaysUseMessageFont);
  254. #ifdef GTA5SYNC_WIN
  255. if (QSysInfo::windowsVersion() >= 0x0080)
  256. {
  257. ui->gbFont->setVisible(false);
  258. ui->cbAlwaysUseMessageFont->setVisible(false);
  259. }
  260. #else
  261. ui->gbFont->setVisible(false);
  262. ui->cbAlwaysUseMessageFont->setVisible(false);
  263. #endif
  264. QString currentStyle = QApplication::style()->objectName();
  265. QString appStyle = settings->value("AppStyle", currentStyle).toString();
  266. bool customStyle = settings->value("CustomStyle", false).toBool();
  267. const QStringList availableStyles = QStyleFactory::keys();
  268. ui->cbStyleList->addItems(availableStyles);
  269. if (availableStyles.contains(appStyle, Qt::CaseInsensitive))
  270. {
  271. // use 'for' for select to be sure it's case insensitive
  272. int currentIndex = 0;
  273. for (QString currentStyleFF : availableStyles)
  274. {
  275. if (currentStyleFF.toLower() == appStyle.toLower())
  276. {
  277. ui->cbStyleList->setCurrentIndex(currentIndex);
  278. }
  279. currentIndex++;
  280. }
  281. }
  282. else
  283. {
  284. if (availableStyles.contains(currentStyle, Qt::CaseInsensitive))
  285. {
  286. int currentIndex = 0;
  287. for (QString currentStyleFF : availableStyles)
  288. {
  289. if (currentStyleFF.toLower() == currentStyle.toLower())
  290. {
  291. ui->cbStyleList->setCurrentIndex(currentIndex);
  292. }
  293. currentIndex++;
  294. }
  295. }
  296. }
  297. if (customStyle)
  298. {
  299. ui->cbDefaultStyle->setChecked(false);
  300. }
  301. settings->endGroup();
  302. }
  303. void OptionsDialog::on_cmdOK_clicked()
  304. {
  305. applySettings();
  306. close();
  307. }
  308. void OptionsDialog::applySettings()
  309. {
  310. settings->beginGroup("Interface");
  311. #if QT_VERSION >= 0x050000
  312. settings->setValue("Language", ui->cbLanguage->currentData());
  313. settings->setValue("AreaLanguage", ui->cbAreaLanguage->currentData());
  314. #else
  315. settings->setValue("Language", ui->cbLanguage->itemData(ui->cbLanguage->currentIndex()));
  316. settings->setValue("AreaLanguage", ui->cbAreaLanguage->itemData(ui->cbAreaLanguage->currentIndex()));
  317. #endif
  318. #ifdef GTA5SYNC_WIN
  319. #if QT_VERSION >= 0x050200
  320. settings->setValue("NavigationBar", ui->cbSnapmaticNavigationBar->isChecked());
  321. #endif
  322. #endif
  323. settings->endGroup();
  324. settings->beginGroup("Profile");
  325. int newContentMode = 0;
  326. if (ui->rbOpenWithSC->isChecked())
  327. {
  328. newContentMode = 0;
  329. }
  330. else if (ui->rbOpenWithDC->isChecked())
  331. {
  332. newContentMode = 1;
  333. }
  334. else if (ui->rbSelectWithSC->isChecked())
  335. {
  336. newContentMode = 2;
  337. }
  338. settings->setValue("ContentMode", newContentMode);
  339. #if QT_VERSION >= 0x050000
  340. settings->setValue("Default", ui->cbProfiles->currentData());
  341. #else
  342. settings->setValue("Default", ui->cbProfiles->itemData(ui->cbProfiles->currentIndex()));
  343. #endif
  344. settings->endGroup();
  345. settings->beginGroup("Pictures");
  346. if (ui->cbPicCustomQuality->isChecked())
  347. {
  348. settings->setValue("CustomQuality", ui->hsPicQuality->value());
  349. }
  350. settings->setValue("CustomQualityEnabled", ui->cbPicCustomQuality->isChecked());
  351. QString sizeMode = "Default";
  352. if (ui->rbPicDesktopRes->isChecked())
  353. {
  354. sizeMode = "Desktop";
  355. }
  356. else if (ui->rbPicCustomRes->isChecked())
  357. {
  358. sizeMode = "Custom";
  359. settings->setValue("CustomSize", QSize(ui->sbPicExportWidth->value(), ui->sbPicExportHeight->value()));
  360. }
  361. settings->setValue("ExportSizeMode", sizeMode);
  362. settings->setValue("AspectRatio", aspectRatio);
  363. settings->endGroup();
  364. bool forceCustomFolder = ui->cbForceCustomFolder->isChecked();
  365. settings->beginGroup("dir");
  366. settings->setValue("dir", ui->txtFolder->text());
  367. settings->setValue("force", forceCustomFolder);
  368. settings->endGroup();
  369. bool defaultStyle = ui->cbDefaultStyle->isChecked();
  370. settings->beginGroup("Startup");
  371. if (!defaultStyle)
  372. {
  373. QString newStyle = ui->cbStyleList->currentText();
  374. settings->setValue("CustomStyle", true);
  375. settings->setValue("AppStyle", newStyle);
  376. QApplication::setStyle(QStyleFactory::create(newStyle));
  377. }
  378. else
  379. {
  380. settings->setValue("CustomStyle", false);
  381. }
  382. settings->setValue("AlwaysUseMessageFont", ui->cbAlwaysUseMessageFont->isChecked());
  383. settings->endGroup();
  384. #ifdef GTA5SYNC_TELEMETRY
  385. settings->beginGroup("Telemetry");
  386. settings->setValue("PushAppConf", ui->cbAppConfigStats->isChecked());
  387. settings->setValue("PushUsageData", ui->cbUsageData->isChecked());
  388. if (!Telemetry->isStateForced()) { settings->setValue("IsEnabled", ui->cbParticipateStats->isChecked()); }
  389. settings->endGroup();
  390. Telemetry->refresh();
  391. Telemetry->work();
  392. if (ui->cbUsageData->isChecked() && Telemetry->canPush())
  393. {
  394. QJsonDocument jsonDocument;
  395. QJsonObject jsonObject;
  396. jsonObject["Type"] = "SettingsUpdated";
  397. jsonObject["UpdateTime"] = QString::number(QDateTime::currentDateTimeUtc().toTime_t());
  398. jsonDocument.setObject(jsonObject);
  399. Telemetry->push(TelemetryCategory::PersonalData, jsonDocument);
  400. }
  401. #endif
  402. #if QT_VERSION >= 0x050000
  403. bool languageChanged = ui->cbLanguage->currentData().toString() != currentLanguage;
  404. bool languageAreaChanged = ui->cbAreaLanguage->currentData().toString() != currentAreaLanguage;
  405. #else
  406. bool languageChanged = ui->cbLanguage->itemData(ui->cbLanguage->currentIndex()).toString() != currentLanguage;
  407. bool languageAreaChanged = ui->cbAreaLanguage->itemData(ui->cbLanguage->currentIndex()).toString() != currentAreaLanguage;
  408. #endif
  409. if (languageChanged)
  410. {
  411. Translator->unloadTranslation(qApp);
  412. Translator->initUserLanguage();
  413. Translator->loadTranslation(qApp);
  414. }
  415. else if (languageAreaChanged)
  416. {
  417. Translator->initUserLanguage();
  418. }
  419. settings->sync();
  420. emit settingsApplied(newContentMode, languageChanged);
  421. if ((forceCustomFolder && ui->txtFolder->text() != currentCFolder) || (forceCustomFolder != currentFFolder && forceCustomFolder))
  422. {
  423. QMessageBox::information(this, tr("%1", "%1").arg(GTA5SYNC_APPSTR), tr("The new Custom Folder will initialise after you restart %1.").arg(GTA5SYNC_APPSTR));
  424. }
  425. }
  426. void OptionsDialog::setupDefaultProfile()
  427. {
  428. settings->beginGroup("Profile");
  429. defaultProfile = settings->value("Default", "").toString();
  430. settings->endGroup();
  431. QString cbNoneStr = tr("No Profile", "No Profile, as default");
  432. ui->cbProfiles->addItem(cbNoneStr, "");
  433. }
  434. void OptionsDialog::commitProfiles(const QStringList &profiles)
  435. {
  436. for (QString profile : profiles)
  437. {
  438. ui->cbProfiles->addItem(tr("Profile: %1").arg(profile), profile);
  439. if (defaultProfile == profile)
  440. {
  441. #if QT_VERSION >= 0x050000
  442. ui->cbProfiles->setCurrentText(tr("Profile: %1").arg(profile));
  443. #else
  444. int indexOfProfile = ui->cbProfiles->findText(tr("Profile: %1").arg(profile));
  445. ui->cbProfiles->setCurrentIndex(indexOfProfile);
  446. #endif
  447. }
  448. }
  449. }
  450. void OptionsDialog::on_rbPicCustomRes_toggled(bool checked)
  451. {
  452. ui->labPicCustomRes->setEnabled(checked);
  453. ui->sbPicExportWidth->setEnabled(checked);
  454. ui->sbPicExportHeight->setEnabled(checked);
  455. ui->labPicXDescription->setEnabled(checked);
  456. }
  457. void OptionsDialog::on_cbPicCustomQuality_toggled(bool checked)
  458. {
  459. ui->hsPicQuality->setEnabled(checked);
  460. ui->labPicQuality->setEnabled(checked);
  461. ui->labPicQualityDescription->setEnabled(checked);
  462. }
  463. void OptionsDialog::on_hsPicQuality_valueChanged(int value)
  464. {
  465. customQuality = value;
  466. ui->labPicQuality->setText(percentString.arg(QString::number(value)));
  467. }
  468. void OptionsDialog::setupPictureSettings()
  469. {
  470. settings->beginGroup("Pictures");
  471. // Quality Settings
  472. customQuality = settings->value("CustomQuality", defaultQuality).toInt();
  473. if (customQuality < 1 || customQuality > 100)
  474. {
  475. customQuality = 100;
  476. }
  477. ui->hsPicQuality->setValue(customQuality);
  478. ui->cbPicCustomQuality->setChecked(settings->value("CustomQualityEnabled", false).toBool());
  479. // Size Settings
  480. cusExportSize = settings->value("CustomSize", defExportSize).toSize();
  481. if (cusExportSize.width() > 3840)
  482. {
  483. cusExportSize.setWidth(3840);
  484. }
  485. else if (cusExportSize.height() > 2160)
  486. {
  487. cusExportSize.setHeight(2160);
  488. }
  489. if (cusExportSize.width() < 1)
  490. {
  491. cusExportSize.setWidth(1);
  492. }
  493. else if (cusExportSize.height() < 1)
  494. {
  495. cusExportSize.setHeight(1);
  496. }
  497. ui->sbPicExportWidth->setValue(cusExportSize.width());
  498. ui->sbPicExportHeight->setValue(cusExportSize.height());
  499. QString sizeMode = settings->value("ExportSizeMode", "Default").toString();
  500. if (sizeMode == "Desktop")
  501. {
  502. ui->rbPicDesktopRes->setChecked(true);
  503. }
  504. else if (sizeMode == "Custom")
  505. {
  506. ui->rbPicCustomRes->setChecked(true);
  507. }
  508. else
  509. {
  510. ui->rbPicDefaultRes->setChecked(true);
  511. }
  512. aspectRatio = (Qt::AspectRatioMode)settings->value("AspectRatio", Qt::KeepAspectRatio).toInt();
  513. if (aspectRatio == Qt::IgnoreAspectRatio)
  514. {
  515. ui->cbIgnoreAspectRatio->setChecked(true);
  516. }
  517. settings->endGroup();
  518. }
  519. void OptionsDialog::setupStatisticsSettings()
  520. {
  521. #ifdef GTA5SYNC_TELEMETRY
  522. ui->cbParticipateStats->setText(tr("Participate in %1 User Statistics").arg(GTA5SYNC_APPSTR));
  523. ui->labUserStats->setText(QString("<a href=\"%2\">%1</a>").arg(tr("View %1 User Statistics Online").arg(GTA5SYNC_APPSTR), TelemetryClass::getWebURL().toString()));
  524. settings->beginGroup("Telemetry");
  525. ui->cbParticipateStats->setChecked(Telemetry->isEnabled());
  526. ui->cbAppConfigStats->setChecked(settings->value("PushAppConf", false).toBool());
  527. ui->cbUsageData->setChecked(settings->value("PushUsageData", false).toBool());
  528. settings->endGroup();
  529. if (Telemetry->isStateForced())
  530. {
  531. ui->cbParticipateStats->setEnabled(false);
  532. }
  533. if (Telemetry->isRegistered())
  534. {
  535. ui->labParticipationID->setText(tr("Participation ID: %1").arg(Telemetry->getRegisteredID()));
  536. }
  537. else
  538. {
  539. ui->labParticipationID->setText(tr("Participation ID: %1").arg(tr("Not registered")));
  540. ui->cmdCopyStatsID->setVisible(false);
  541. }
  542. #else
  543. ui->tabWidget->removeTab(ui->tabWidget->indexOf(ui->tabStats));
  544. #endif
  545. }
  546. void OptionsDialog::setupWindowsGameSettings()
  547. {
  548. #ifdef GTA5SYNC_GAME
  549. GameVersion gameVersion = AppEnv::getGameVersion();
  550. #ifdef GTA5SYNC_WIN
  551. if (gameVersion != GameVersion::NoVersion)
  552. {
  553. if (gameVersion == GameVersion::SocialClubVersion)
  554. {
  555. ui->gbSteam->setDisabled(true);
  556. ui->labSocialClubFound->setText(tr("Found: %1").arg(QString("<span style=\"color: green\">%1</span>").arg(tr("Yes"))));
  557. ui->labSteamFound->setText(tr("Found: %1").arg(QString("<span style=\"color: red\">%1</span>").arg(tr("No"))));
  558. if (AppEnv::getGameLanguage(GameVersion::SocialClubVersion) != GameLanguage::Undefined)
  559. {
  560. ui->labSocialClubLanguage->setText(tr("Language: %1").arg(QLocale(AppEnv::gameLanguageToString(AppEnv::getGameLanguage(GameVersion::SocialClubVersion))).nativeLanguageName()));
  561. }
  562. else
  563. {
  564. ui->labSocialClubLanguage->setText(tr("Language: %1").arg(tr("OS defined")));
  565. }
  566. ui->labSteamLanguage->setVisible(false);
  567. }
  568. else if (gameVersion == GameVersion::SteamVersion)
  569. {
  570. ui->gbSocialClub->setDisabled(true);
  571. ui->labSocialClubFound->setText(tr("Found: %1").arg(QString("<span style=\"color: red\">%1</span>").arg(tr("No"))));
  572. ui->labSteamFound->setText(tr("Found: %1").arg(QString("<span style=\"color: green\">%1</span>").arg(tr("Yes"))));
  573. ui->labSocialClubLanguage->setVisible(false);
  574. if (AppEnv::getGameLanguage(GameVersion::SteamVersion) != GameLanguage::Undefined)
  575. {
  576. ui->labSteamLanguage->setText(tr("Language: %1").arg(QLocale(AppEnv::gameLanguageToString(AppEnv::getGameLanguage(GameVersion::SteamVersion))).nativeLanguageName()));
  577. }
  578. else
  579. {
  580. ui->labSteamLanguage->setText(tr("Language: %1").arg(tr("Steam defined")));
  581. }
  582. }
  583. else
  584. {
  585. ui->labSocialClubFound->setText(tr("Found: %1").arg(QString("<span style=\"color: green\">%1</span>").arg(tr("Yes"))));
  586. ui->labSteamFound->setText(tr("Found: %1").arg(QString("<span style=\"color: green\">%1</span>").arg(tr("Yes"))));
  587. if (AppEnv::getGameLanguage(GameVersion::SocialClubVersion) != GameLanguage::Undefined)
  588. {
  589. ui->labSocialClubLanguage->setText(tr("Language: %1").arg(QLocale(AppEnv::gameLanguageToString(AppEnv::getGameLanguage(GameVersion::SocialClubVersion))).nativeLanguageName()));
  590. }
  591. else
  592. {
  593. ui->labSocialClubLanguage->setText(tr("Language: %1").arg(tr("OS defined")));
  594. }
  595. if (AppEnv::getGameLanguage(GameVersion::SteamVersion) != GameLanguage::Undefined)
  596. {
  597. ui->labSteamLanguage->setText(tr("Language: %1").arg(QLocale(AppEnv::gameLanguageToString(AppEnv::getGameLanguage(GameVersion::SteamVersion))).nativeLanguageName()));
  598. }
  599. else
  600. {
  601. ui->labSteamLanguage->setText(tr("Language: %1").arg(tr("Steam defined")));
  602. }
  603. }
  604. }
  605. else
  606. {
  607. ui->tabWidget->removeTab(ui->tabWidget->indexOf(ui->tabGame));
  608. }
  609. #else
  610. ui->tabWidget->removeTab(ui->tabWidget->indexOf(ui->tabGame));
  611. #endif
  612. #else
  613. ui->tabWidget->removeTab(ui->tabWidget->indexOf(ui->tabGame));
  614. #endif
  615. }
  616. void OptionsDialog::on_cbIgnoreAspectRatio_toggled(bool checked)
  617. {
  618. if (checked)
  619. {
  620. aspectRatio = Qt::IgnoreAspectRatio;
  621. }
  622. else
  623. {
  624. aspectRatio = Qt::KeepAspectRatio;
  625. }
  626. }
  627. void OptionsDialog::setupCustomGTAFolder()
  628. {
  629. bool ok;
  630. QString defaultGameFolder = AppEnv::getGameFolder(&ok);
  631. settings->beginGroup("dir");
  632. currentCFolder = settings->value("dir", "").toString();
  633. currentFFolder = settings->value("force", false).toBool();
  634. if (currentCFolder == "" && ok)
  635. {
  636. currentCFolder = defaultGameFolder;
  637. }
  638. ui->txtFolder->setText(currentCFolder);
  639. ui->cbForceCustomFolder->setChecked(currentFFolder);
  640. settings->endGroup();
  641. }
  642. void OptionsDialog::setupSnapmaticPictureViewer()
  643. {
  644. #ifdef GTA5SYNC_WIN
  645. #if QT_VERSION >= 0x050200
  646. settings->beginGroup("Interface");
  647. ui->cbSnapmaticNavigationBar->setChecked(settings->value("NavigationBar", false).toBool());
  648. settings->endGroup();
  649. #else
  650. ui->cbSnapmaticNavigationBar->setVisible(false);
  651. ui->gbSnapmaticPictureViewer->setVisible(false);
  652. #endif
  653. #else
  654. ui->cbSnapmaticNavigationBar->setVisible(false);
  655. ui->gbSnapmaticPictureViewer->setVisible(false);
  656. #endif
  657. }
  658. void OptionsDialog::on_cmdExploreFolder_clicked()
  659. {
  660. QString GTAV_Folder = QFileDialog::getExistingDirectory(this, UserInterface::tr("Select GTA V Folder..."), StandardPaths::documentsLocation(), QFileDialog::ShowDirsOnly);
  661. if (QFileInfo(GTAV_Folder).exists())
  662. {
  663. ui->txtFolder->setText(GTAV_Folder);
  664. }
  665. }
  666. void OptionsDialog::on_cbDefaultStyle_toggled(bool checked)
  667. {
  668. ui->cbStyleList->setDisabled(checked);
  669. }
  670. void OptionsDialog::on_cmdCopyStatsID_clicked()
  671. {
  672. #ifdef GTA5SYNC_TELEMETRY
  673. QApplication::clipboard()->setText(Telemetry->getRegisteredID());
  674. #endif
  675. }