Open Source Snapmatic picture and Savegame viewer/editor for GTA V https://gta5view.syping.de/
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

OptionsDialog.cpp 21KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643
  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. #ifndef Q_QS_ANDROID
  98. // DPI calculation
  99. qreal screenRatio = AppEnv::screenRatio();
  100. resize(435 * screenRatio, 405 * screenRatio);
  101. #endif
  102. this->setWindowTitle(windowTitle().arg(GTA5SYNC_APPSTR));
  103. }
  104. OptionsDialog::~OptionsDialog()
  105. {
  106. delete settings;
  107. qDeleteAll(playerItems.begin(), playerItems.end());
  108. playerItems.clear();
  109. delete ui;
  110. }
  111. void OptionsDialog::setupTreeWidget()
  112. {
  113. for (QString playerIDStr : profileDB->getPlayers())
  114. {
  115. bool ok;
  116. int playerID = playerIDStr.toInt(&ok);
  117. if (ok)
  118. {
  119. QString playerName = profileDB->getPlayerName(playerID);
  120. QStringList playerTreeViewList;
  121. playerTreeViewList += playerIDStr;
  122. playerTreeViewList += playerName;
  123. QTreeWidgetItem *playerItem = new QTreeWidgetItem(playerTreeViewList);
  124. ui->twPlayers->addTopLevelItem(playerItem);
  125. playerItems += playerItem;
  126. }
  127. }
  128. ui->twPlayers->sortItems(1, Qt::AscendingOrder);
  129. }
  130. void OptionsDialog::setupLanguageBox()
  131. {
  132. settings->beginGroup("Interface");
  133. currentLanguage = settings->value("Language", "System").toString();
  134. currentAreaLanguage = settings->value("AreaLanguage", "Auto").toString();
  135. settings->endGroup();
  136. QString cbSysStr = tr("%1 (Next Closest Language)", "First language a person can talk with a different person/application. \"Native\" or \"Not Native\".").arg(tr("System",
  137. "System in context of System default"));
  138. QString cbAutoStr = tr("%1 (Closest to Interface)", "Next closest language compared to the Interface").arg(tr("Auto", "Automatic language choice."));
  139. ui->cbLanguage->addItem(cbSysStr, "System");
  140. ui->cbAreaLanguage->addItem(cbAutoStr, "Auto");
  141. QStringList availableLanguages;
  142. availableLanguages << QString("en_GB");
  143. #ifndef GTA5SYNC_QCONF
  144. availableLanguages << TranslationClass::listTranslations(AppEnv::getExLangFolder());
  145. #endif
  146. availableLanguages << TranslationClass::listTranslations(AppEnv::getInLangFolder());
  147. availableLanguages.removeDuplicates();
  148. availableLanguages.sort();
  149. for (QString lang : availableLanguages)
  150. {
  151. QLocale langLocale(lang);
  152. QString cbLangStr = langLocale.nativeLanguageName() % " (" % langLocale.nativeCountryName() % ") [" % lang % "]";
  153. QString langIconStr = "flag-" % TranslationClass::getCountryCode(langLocale);
  154. ui->cbLanguage->addItem(QIcon::fromTheme(langIconStr), cbLangStr, lang);
  155. if (currentLanguage == lang)
  156. {
  157. #if QT_VERSION >= 0x050000
  158. ui->cbLanguage->setCurrentText(cbLangStr);
  159. #else
  160. int indexOfLang = ui->cbLanguage->findText(cbLangStr);
  161. ui->cbLanguage->setCurrentIndex(indexOfLang);
  162. #endif
  163. }
  164. }
  165. QString aCurrentLanguage = QString("en_GB");
  166. if (Translator->isLanguageLoaded()) { aCurrentLanguage = Translator->getCurrentLanguage(); }
  167. QLocale currentLocale = QLocale(aCurrentLanguage);
  168. ui->labCurrentLanguage->setText(tr("Current: %1").arg(currentLocale.nativeLanguageName() % " (" % currentLocale.nativeCountryName() % ") [" % aCurrentLanguage % "]"));
  169. availableLanguages.clear();
  170. availableLanguages << TranslationClass::listAreaTranslations();
  171. availableLanguages.removeDuplicates();
  172. availableLanguages.sort();
  173. for (QString lang : availableLanguages)
  174. {
  175. // correcting Language Location if possible
  176. QString aLang = lang;
  177. if (QFile::exists(":/global/global." % lang % ".loc"))
  178. {
  179. QFile locFile(":/global/global." % lang % ".loc");
  180. if (locFile.open(QFile::ReadOnly))
  181. {
  182. aLang = QString::fromUtf8(locFile.readLine()).trimmed();
  183. locFile.close();
  184. }
  185. }
  186. QLocale langLocale(aLang);
  187. QString cbLangStr = langLocale.nativeLanguageName() % " (" % langLocale.nativeCountryName() % ") [" % aLang % "]";
  188. QString langIconStr = "flag-" % TranslationClass::getCountryCode(langLocale);
  189. ui->cbAreaLanguage->addItem(QIcon::fromTheme(langIconStr), cbLangStr, lang);
  190. if (currentAreaLanguage == lang)
  191. {
  192. #if QT_VERSION >= 0x050000
  193. ui->cbAreaLanguage->setCurrentText(cbLangStr);
  194. #else
  195. int indexOfLang = ui->cbAreaLanguage->findText(cbLangStr);
  196. ui->cbAreaLanguage->setCurrentIndex(indexOfLang);
  197. #endif
  198. }
  199. }
  200. QString aCurrentAreaLanguage = Translator->getCurrentAreaLanguage();
  201. if (QFile::exists(":/global/global." % aCurrentAreaLanguage % ".loc"))
  202. {
  203. qDebug() << "locFile found";
  204. QFile locFile(":/global/global." % aCurrentAreaLanguage % ".loc");
  205. if (locFile.open(QFile::ReadOnly))
  206. {
  207. aCurrentAreaLanguage = QString::fromUtf8(locFile.readLine()).trimmed();
  208. locFile.close();
  209. }
  210. }
  211. currentLocale = QLocale(aCurrentAreaLanguage);
  212. ui->labCurrentAreaLanguage->setText(tr("Current: %1").arg(currentLocale.nativeLanguageName() % " (" % currentLocale.nativeCountryName() % ") [" % aCurrentAreaLanguage % "]"));
  213. }
  214. void OptionsDialog::setupRadioButtons()
  215. {
  216. bool contentModeOk;
  217. settings->beginGroup("Profile");
  218. contentMode = settings->value("ContentMode", 0).toInt(&contentModeOk);
  219. settings->endGroup();
  220. if (contentModeOk)
  221. {
  222. switch (contentMode)
  223. {
  224. case 0:
  225. ui->rbOpenWithSC->setChecked(true);
  226. break;
  227. case 1:
  228. ui->rbOpenWithDC->setChecked(true);
  229. break;
  230. case 2:
  231. ui->rbSelectWithSC->setChecked(true);
  232. break;
  233. }
  234. }
  235. }
  236. void OptionsDialog::setupInterfaceSettings()
  237. {
  238. settings->beginGroup("Startup");
  239. bool alwaysUseMessageFont = settings->value("AlwaysUseMessageFont", false).toBool();
  240. ui->cbAlwaysUseMessageFont->setChecked(alwaysUseMessageFont);
  241. #ifdef GTA5SYNC_WIN
  242. if (QSysInfo::windowsVersion() >= 0x0080)
  243. {
  244. ui->gbFont->setVisible(false);
  245. ui->cbAlwaysUseMessageFont->setVisible(false);
  246. }
  247. #else
  248. ui->gbFont->setVisible(false);
  249. ui->cbAlwaysUseMessageFont->setVisible(false);
  250. #endif
  251. QString currentStyle = QApplication::style()->objectName();
  252. QString appStyle = settings->value("AppStyle", currentStyle).toString();
  253. bool customStyle = settings->value("CustomStyle", false).toBool();
  254. const QStringList availableStyles = QStyleFactory::keys();
  255. ui->cbStyleList->addItems(availableStyles);
  256. if (availableStyles.contains(appStyle, Qt::CaseInsensitive))
  257. {
  258. // use 'for' for select to be sure it's case insensitive
  259. int currentIndex = 0;
  260. for (QString currentStyleFF : availableStyles)
  261. {
  262. if (currentStyleFF.toLower() == appStyle.toLower())
  263. {
  264. ui->cbStyleList->setCurrentIndex(currentIndex);
  265. }
  266. currentIndex++;
  267. }
  268. }
  269. else
  270. {
  271. if (availableStyles.contains(currentStyle, Qt::CaseInsensitive))
  272. {
  273. int currentIndex = 0;
  274. for (QString currentStyleFF : availableStyles)
  275. {
  276. if (currentStyleFF.toLower() == currentStyle.toLower())
  277. {
  278. ui->cbStyleList->setCurrentIndex(currentIndex);
  279. }
  280. currentIndex++;
  281. }
  282. }
  283. }
  284. if (customStyle)
  285. {
  286. ui->cbDefaultStyle->setChecked(false);
  287. }
  288. settings->endGroup();
  289. }
  290. void OptionsDialog::on_cmdOK_clicked()
  291. {
  292. applySettings();
  293. close();
  294. }
  295. void OptionsDialog::applySettings()
  296. {
  297. settings->beginGroup("Interface");
  298. #if QT_VERSION >= 0x050000
  299. settings->setValue("Language", ui->cbLanguage->currentData());
  300. settings->setValue("AreaLanguage", ui->cbAreaLanguage->currentData());
  301. #else
  302. settings->setValue("Language", ui->cbLanguage->itemData(ui->cbLanguage->currentIndex()));
  303. settings->setValue("AreaLanguage", ui->cbAreaLanguage->itemData(ui->cbAreaLanguage->currentIndex()));
  304. #endif
  305. #ifdef GTA5SYNC_WIN
  306. #if QT_VERSION >= 0x050200
  307. settings->setValue("NavigationBar", ui->cbSnapmaticNavigationBar->isChecked());
  308. #endif
  309. #endif
  310. settings->endGroup();
  311. settings->beginGroup("Profile");
  312. int newContentMode = 0;
  313. if (ui->rbOpenWithSC->isChecked())
  314. {
  315. newContentMode = 0;
  316. }
  317. else if (ui->rbOpenWithDC->isChecked())
  318. {
  319. newContentMode = 1;
  320. }
  321. else if (ui->rbSelectWithSC->isChecked())
  322. {
  323. newContentMode = 2;
  324. }
  325. settings->setValue("ContentMode", newContentMode);
  326. #if QT_VERSION >= 0x050000
  327. settings->setValue("Default", ui->cbProfiles->currentData());
  328. #else
  329. settings->setValue("Default", ui->cbProfiles->itemData(ui->cbProfiles->currentIndex()));
  330. #endif
  331. settings->endGroup();
  332. settings->beginGroup("Pictures");
  333. if (ui->cbPicCustomQuality->isChecked())
  334. {
  335. settings->setValue("CustomQuality", ui->hsPicQuality->value());
  336. }
  337. settings->setValue("CustomQualityEnabled", ui->cbPicCustomQuality->isChecked());
  338. QString sizeMode = "Default";
  339. if (ui->rbPicDesktopRes->isChecked())
  340. {
  341. sizeMode = "Desktop";
  342. }
  343. else if (ui->rbPicCustomRes->isChecked())
  344. {
  345. sizeMode = "Custom";
  346. settings->setValue("CustomSize", QSize(ui->sbPicExportWidth->value(), ui->sbPicExportHeight->value()));
  347. }
  348. settings->setValue("ExportSizeMode", sizeMode);
  349. settings->setValue("AspectRatio", aspectRatio);
  350. settings->endGroup();
  351. bool forceCustomFolder = ui->cbForceCustomFolder->isChecked();
  352. settings->beginGroup("dir");
  353. settings->setValue("dir", ui->txtFolder->text());
  354. settings->setValue("force", forceCustomFolder);
  355. settings->endGroup();
  356. bool defaultStyle = ui->cbDefaultStyle->isChecked();
  357. settings->beginGroup("Startup");
  358. if (!defaultStyle)
  359. {
  360. QString newStyle = ui->cbStyleList->currentText();
  361. settings->setValue("CustomStyle", true);
  362. settings->setValue("AppStyle", newStyle);
  363. QApplication::setStyle(QStyleFactory::create(newStyle));
  364. }
  365. else
  366. {
  367. settings->setValue("CustomStyle", false);
  368. }
  369. settings->setValue("AlwaysUseMessageFont", ui->cbAlwaysUseMessageFont->isChecked());
  370. settings->endGroup();
  371. #ifdef GTA5SYNC_TELEMETRY
  372. settings->beginGroup("Telemetry");
  373. settings->setValue("PushAppConf", ui->cbAppConfigStats->isChecked());
  374. settings->setValue("PushUsageData", ui->cbUsageData->isChecked());
  375. if (!Telemetry->isStateForced()) { settings->setValue("IsEnabled", ui->cbParticipateStats->isChecked()); }
  376. settings->endGroup();
  377. Telemetry->refresh();
  378. Telemetry->work();
  379. #endif
  380. #if QT_VERSION >= 0x050000
  381. bool languageChanged = ui->cbLanguage->currentData().toString() != currentLanguage;
  382. bool languageAreaChanged = ui->cbAreaLanguage->currentData().toString() != currentAreaLanguage;
  383. #else
  384. bool languageChanged = ui->cbLanguage->itemData(ui->cbLanguage->currentIndex()).toString() != currentLanguage;
  385. bool languageAreaChanged = ui->cbAreaLanguage->itemData(ui->cbLanguage->currentIndex()).toString() != currentAreaLanguage;
  386. #endif
  387. if (languageChanged)
  388. {
  389. Translator->unloadTranslation(qApp);
  390. Translator->initUserLanguage();
  391. Translator->loadTranslation(qApp);
  392. }
  393. else if (languageAreaChanged)
  394. {
  395. Translator->initUserLanguage();
  396. }
  397. emit settingsApplied(newContentMode, languageChanged);
  398. if ((forceCustomFolder && ui->txtFolder->text() != currentCFolder) || (forceCustomFolder != currentFFolder && forceCustomFolder))
  399. {
  400. QMessageBox::information(this, tr("%1", "%1").arg(GTA5SYNC_APPSTR), tr("The new Custom Folder will initialise after you restart %1.").arg(GTA5SYNC_APPSTR));
  401. }
  402. }
  403. void OptionsDialog::setupDefaultProfile()
  404. {
  405. settings->beginGroup("Profile");
  406. defaultProfile = settings->value("Default", "").toString();
  407. settings->endGroup();
  408. QString cbNoneStr = tr("No Profile", "No Profile, as default");
  409. ui->cbProfiles->addItem(cbNoneStr, "");
  410. }
  411. void OptionsDialog::commitProfiles(const QStringList &profiles)
  412. {
  413. for (QString profile : profiles)
  414. {
  415. ui->cbProfiles->addItem(tr("Profile: %1").arg(profile), profile);
  416. if (defaultProfile == profile)
  417. {
  418. #if QT_VERSION >= 0x050000
  419. ui->cbProfiles->setCurrentText(tr("Profile: %1").arg(profile));
  420. #else
  421. int indexOfProfile = ui->cbProfiles->findText(tr("Profile: %1").arg(profile));
  422. ui->cbProfiles->setCurrentIndex(indexOfProfile);
  423. #endif
  424. }
  425. }
  426. }
  427. void OptionsDialog::on_rbPicCustomRes_toggled(bool checked)
  428. {
  429. ui->labPicCustomRes->setEnabled(checked);
  430. ui->sbPicExportWidth->setEnabled(checked);
  431. ui->sbPicExportHeight->setEnabled(checked);
  432. ui->labPicXDescription->setEnabled(checked);
  433. }
  434. void OptionsDialog::on_cbPicCustomQuality_toggled(bool checked)
  435. {
  436. ui->hsPicQuality->setEnabled(checked);
  437. ui->labPicQuality->setEnabled(checked);
  438. ui->labPicQualityDescription->setEnabled(checked);
  439. }
  440. void OptionsDialog::on_hsPicQuality_valueChanged(int value)
  441. {
  442. customQuality = value;
  443. ui->labPicQuality->setText(percentString.arg(QString::number(value)));
  444. }
  445. void OptionsDialog::setupPictureSettings()
  446. {
  447. settings->beginGroup("Pictures");
  448. // Quality Settings
  449. customQuality = settings->value("CustomQuality", defaultQuality).toInt();
  450. if (customQuality < 1 || customQuality > 100)
  451. {
  452. customQuality = 100;
  453. }
  454. ui->hsPicQuality->setValue(customQuality);
  455. ui->cbPicCustomQuality->setChecked(settings->value("CustomQualityEnabled", false).toBool());
  456. // Size Settings
  457. cusExportSize = settings->value("CustomSize", defExportSize).toSize();
  458. if (cusExportSize.width() > 3840)
  459. {
  460. cusExportSize.setWidth(3840);
  461. }
  462. else if (cusExportSize.height() > 2160)
  463. {
  464. cusExportSize.setHeight(2160);
  465. }
  466. if (cusExportSize.width() < 1)
  467. {
  468. cusExportSize.setWidth(1);
  469. }
  470. else if (cusExportSize.height() < 1)
  471. {
  472. cusExportSize.setHeight(1);
  473. }
  474. ui->sbPicExportWidth->setValue(cusExportSize.width());
  475. ui->sbPicExportHeight->setValue(cusExportSize.height());
  476. QString sizeMode = settings->value("ExportSizeMode", "Default").toString();
  477. if (sizeMode == "Desktop")
  478. {
  479. ui->rbPicDesktopRes->setChecked(true);
  480. }
  481. else if (sizeMode == "Custom")
  482. {
  483. ui->rbPicCustomRes->setChecked(true);
  484. }
  485. else
  486. {
  487. ui->rbPicDefaultRes->setChecked(true);
  488. }
  489. aspectRatio = (Qt::AspectRatioMode)settings->value("AspectRatio", Qt::KeepAspectRatio).toInt();
  490. if (aspectRatio == Qt::IgnoreAspectRatio)
  491. {
  492. ui->cbIgnoreAspectRatio->setChecked(true);
  493. }
  494. settings->endGroup();
  495. }
  496. void OptionsDialog::setupStatisticsSettings()
  497. {
  498. #ifdef GTA5SYNC_TELEMETRY
  499. ui->cbParticipateStats->setText(tr("Participate in %1 User Statistics").arg(GTA5SYNC_APPSTR));
  500. ui->labUserStats->setText(QString("<a href=\"%2\">%1</a>").arg(tr("View %1 User Statistics Online").arg(GTA5SYNC_APPSTR), TelemetryClass::getWebURL().toString()));
  501. settings->beginGroup("Telemetry");
  502. ui->cbParticipateStats->setChecked(Telemetry->isEnabled());
  503. ui->cbAppConfigStats->setChecked(settings->value("PushAppConf", false).toBool());
  504. ui->cbUsageData->setChecked(settings->value("PushUsageData", false).toBool());
  505. settings->endGroup();
  506. if (Telemetry->isStateForced())
  507. {
  508. ui->cbParticipateStats->setEnabled(false);
  509. }
  510. if (Telemetry->isRegistered())
  511. {
  512. ui->labParticipationID->setText(tr("Participation ID: %1").arg(Telemetry->getRegisteredID()));
  513. }
  514. else
  515. {
  516. ui->labParticipationID->setText(tr("Participation ID: %1").arg(tr("Not registered")));
  517. ui->cmdCopyStatsID->setVisible(false);
  518. }
  519. #else
  520. ui->tabWidget->removeTab(ui->tabWidget->indexOf(ui->tabStats));
  521. #endif
  522. }
  523. void OptionsDialog::on_cbIgnoreAspectRatio_toggled(bool checked)
  524. {
  525. if (checked)
  526. {
  527. aspectRatio = Qt::IgnoreAspectRatio;
  528. }
  529. else
  530. {
  531. aspectRatio = Qt::KeepAspectRatio;
  532. }
  533. }
  534. void OptionsDialog::setupCustomGTAFolder()
  535. {
  536. bool ok;
  537. QString defaultGameFolder = AppEnv::getGameFolder(&ok);
  538. settings->beginGroup("dir");
  539. currentCFolder = settings->value("dir", "").toString();
  540. currentFFolder = settings->value("force", false).toBool();
  541. if (currentCFolder == "" && ok)
  542. {
  543. currentCFolder = defaultGameFolder;
  544. }
  545. ui->txtFolder->setText(currentCFolder);
  546. ui->cbForceCustomFolder->setChecked(currentFFolder);
  547. settings->endGroup();
  548. }
  549. void OptionsDialog::setupSnapmaticPictureViewer()
  550. {
  551. #ifdef GTA5SYNC_WIN
  552. #if QT_VERSION >= 0x050200
  553. settings->beginGroup("Interface");
  554. ui->cbSnapmaticNavigationBar->setChecked(settings->value("NavigationBar", false).toBool());
  555. settings->endGroup();
  556. #else
  557. ui->cbSnapmaticNavigationBar->setVisible(false);
  558. ui->gbSnapmaticPictureViewer->setVisible(false);
  559. #endif
  560. #else
  561. ui->cbSnapmaticNavigationBar->setVisible(false);
  562. ui->gbSnapmaticPictureViewer->setVisible(false);
  563. #endif
  564. }
  565. void OptionsDialog::on_cmdExploreFolder_clicked()
  566. {
  567. QString GTAV_Folder = QFileDialog::getExistingDirectory(this, UserInterface::tr("Select GTA V Folder..."), StandardPaths::documentsLocation(), QFileDialog::ShowDirsOnly);
  568. if (QFileInfo(GTAV_Folder).exists())
  569. {
  570. ui->txtFolder->setText(GTAV_Folder);
  571. }
  572. }
  573. void OptionsDialog::on_cbDefaultStyle_toggled(bool checked)
  574. {
  575. ui->cbStyleList->setDisabled(checked);
  576. }
  577. void OptionsDialog::on_cmdCopyStatsID_clicked()
  578. {
  579. #ifdef GTA5SYNC_TELEMETRY
  580. QApplication::clipboard()->setText(Telemetry->getRegisteredID());
  581. #endif
  582. }