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

UserInterface.cpp 20KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677
  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 "UserInterface.h"
  19. #include "ui_UserInterface.h"
  20. #include "ProfileInterface.h"
  21. #include "SnapmaticPicture.h"
  22. #include "SidebarGenerator.h"
  23. #include "SavegameDialog.h"
  24. #include "StandardPaths.h"
  25. #include "OptionsDialog.h"
  26. #include "PictureDialog.h"
  27. #include "SavegameData.h"
  28. #include "AboutDialog.h"
  29. #include "IconLoader.h"
  30. #include "AppEnv.h"
  31. #include "config.h"
  32. #include <QtGlobal>
  33. #include <QStringBuilder>
  34. #include <QStyleFactory>
  35. #include <QFileDialog>
  36. #include <QHBoxLayout>
  37. #include <QSpacerItem>
  38. #include <QPushButton>
  39. #include <QMessageBox>
  40. #include <QSettings>
  41. #include <QFileInfo>
  42. #include <QDebug>
  43. #include <QFile>
  44. #include <QDir>
  45. #include <QMap>
  46. UserInterface::UserInterface(ProfileDatabase *profileDB, CrewDatabase *crewDB, DatabaseThread *threadDB, QWidget *parent) :
  47. QMainWindow(parent), profileDB(profileDB), crewDB(crewDB), threadDB(threadDB),
  48. ui(new Ui::UserInterface)
  49. {
  50. ui->setupUi(this);
  51. contentMode = 0;
  52. profileOpen = 0;
  53. profileUI = 0;
  54. ui->menuProfile->setEnabled(false);
  55. ui->actionSelect_profile->setEnabled(false);
  56. ui->actionAbout_gta5sync->setIcon(IconLoader::loadingAppIcon());
  57. ui->actionAbout_gta5sync->setText(tr("&About %1").arg(GTA5SYNC_APPSTR));
  58. ui->cmdClose->setToolTip(ui->cmdClose->toolTip().arg(GTA5SYNC_APPSTR));
  59. defaultWindowTitle = tr("%2 - %1").arg("%1", GTA5SYNC_APPSTR);
  60. this->setWindowTitle(defaultWindowTitle.arg(tr("Select Profile")));
  61. QString appVersion = GTA5SYNC_APPVER;
  62. #ifndef GTA5SYNC_BUILDTYPE_REL
  63. #ifdef GTA5SYNC_COMMIT
  64. if (!appVersion.contains("-")) { appVersion = appVersion % "-" % GTA5SYNC_COMMIT; }
  65. #endif
  66. #endif
  67. ui->labVersion->setText(QString("%1 %2").arg(GTA5SYNC_APPSTR, appVersion));
  68. // Set Icon for Close Button
  69. if (QIcon::hasThemeIcon("dialog-close"))
  70. {
  71. ui->cmdClose->setIcon(QIcon::fromTheme("dialog-close"));
  72. }
  73. else if (QIcon::hasThemeIcon("gtk-close"))
  74. {
  75. ui->cmdClose->setIcon(QIcon::fromTheme("gtk-close"));
  76. }
  77. // Set Icon for Reload Button
  78. if (QIcon::hasThemeIcon("view-refresh"))
  79. {
  80. ui->cmdReload->setIcon(QIcon::fromTheme("view-refresh"));
  81. }
  82. else if (QIcon::hasThemeIcon("reload"))
  83. {
  84. ui->cmdReload->setIcon(QIcon::fromTheme("reload"));
  85. }
  86. // Set Icon for Choose GTA V Folder Menu Item
  87. if (QIcon::hasThemeIcon("document-open-folder"))
  88. {
  89. ui->actionSelect_GTA_Folder->setIcon(QIcon::fromTheme("document-open-folder"));
  90. }
  91. else if (QIcon::hasThemeIcon("gtk-directory"))
  92. {
  93. ui->actionSelect_GTA_Folder->setIcon(QIcon::fromTheme("gtk-directory"));
  94. }
  95. // Set Icon for Open File Menu Item
  96. if (QIcon::hasThemeIcon("document-open"))
  97. {
  98. ui->actionOpen_File->setIcon(QIcon::fromTheme("document-open"));
  99. }
  100. // Set Icon for Close Profile Menu Item
  101. if (QIcon::hasThemeIcon("dialog-close"))
  102. {
  103. ui->actionSelect_profile->setIcon(QIcon::fromTheme("dialog-close"));
  104. }
  105. else if (QIcon::hasThemeIcon("gtk-close"))
  106. {
  107. ui->actionSelect_profile->setIcon(QIcon::fromTheme("gtk-close"));
  108. }
  109. // Set Icon for Exit Menu Item
  110. if (QIcon::hasThemeIcon("application-exit"))
  111. {
  112. #ifndef Q_OS_MACOS // Setting icon for exit/quit lead to a crash in Mac OS X
  113. ui->actionExit->setIcon(QIcon::fromTheme("application-exit"));
  114. #endif
  115. }
  116. // Set Icon for Preferences Menu Item
  117. if (QIcon::hasThemeIcon("preferences-system"))
  118. {
  119. #ifndef Q_OS_MACOS // Setting icon for preferences/settings/options lead to a crash in Mac OS X
  120. ui->actionOptions->setIcon(QIcon::fromTheme("preferences-system"));
  121. #endif
  122. }
  123. else if (QIcon::hasThemeIcon("configure"))
  124. {
  125. #ifndef Q_OS_MACOS // Setting icon for preferences/settings/options lead to a crash in Mac OS X
  126. ui->actionOptions->setIcon(QIcon::fromTheme("configure"));
  127. #endif
  128. }
  129. // Set Icon for Profile Import Menu Item
  130. if (QIcon::hasThemeIcon("document-import"))
  131. {
  132. ui->action_Import->setIcon(QIcon::fromTheme("document-import"));
  133. }
  134. else if (QIcon::hasThemeIcon("document-open"))
  135. {
  136. ui->action_Import->setIcon(QIcon::fromTheme("document-open"));
  137. }
  138. // Set Icon for Profile Export Menu Item
  139. if (QIcon::hasThemeIcon("document-export"))
  140. {
  141. ui->actionExport_selected->setIcon(QIcon::fromTheme("document-export"));
  142. }
  143. else if (QIcon::hasThemeIcon("document-save"))
  144. {
  145. ui->actionExport_selected->setIcon(QIcon::fromTheme("document-save"));
  146. }
  147. // Set Icon for Profile Remove Menu Item
  148. if (QIcon::hasThemeIcon("remove"))
  149. {
  150. ui->actionDelete_selected->setIcon(QIcon::fromTheme("remove"));
  151. }
  152. // DPI calculation
  153. qreal screenRatio = AppEnv::screenRatio();
  154. #ifndef Q_QS_ANDROID
  155. resize(625 * screenRatio, 500 * screenRatio);
  156. #endif
  157. ui->vlUserInterface->setSpacing(6 * screenRatio);
  158. ui->vlUserInterface->setContentsMargins(9 * screenRatio, 9 * screenRatio, 9 * screenRatio, 9 * screenRatio);
  159. }
  160. void UserInterface::setupDirEnv()
  161. {
  162. // settings init
  163. QSettings settings(GTA5SYNC_APPVENDOR, GTA5SYNC_APPSTR);
  164. bool folderExists;
  165. GTAV_Folder = AppEnv::getGameFolder(&folderExists);
  166. if (folderExists)
  167. {
  168. QDir::setCurrent(GTAV_Folder);
  169. }
  170. else
  171. {
  172. GTAV_Folder = QFileDialog::getExistingDirectory(this, tr("Select GTA V Folder..."), StandardPaths::documentsLocation(), QFileDialog::ShowDirsOnly);
  173. if (QFileInfo(GTAV_Folder).exists())
  174. {
  175. folderExists = true;
  176. QDir::setCurrent(GTAV_Folder);
  177. AppEnv::setGameFolder(GTAV_Folder);
  178. // First time folder selection save
  179. settings.beginGroup("dir");
  180. if (settings.value("dir", "").toString().isEmpty())
  181. {
  182. settings.setValue("dir", GTAV_Folder);
  183. }
  184. settings.endGroup();
  185. }
  186. }
  187. // profiles init
  188. settings.beginGroup("Profile");
  189. QString defaultProfile = settings.value("Default", "").toString();
  190. bool contentModeOk;
  191. contentMode = settings.value("ContentMode", 0).toInt(&contentModeOk);
  192. if (contentMode != 0 && contentMode != 1 && contentMode != 2)
  193. {
  194. contentMode = 0;
  195. }
  196. if (folderExists)
  197. {
  198. QDir GTAV_ProfilesDir;
  199. GTAV_ProfilesFolder = GTAV_Folder % "/Profiles";
  200. GTAV_ProfilesDir.setPath(GTAV_ProfilesFolder);
  201. GTAV_Profiles = GTAV_ProfilesDir.entryList(QDir::Dirs | QDir::NoDotAndDotDot, QDir::NoSort);
  202. setupProfileUi();
  203. if (GTAV_Profiles.length() == 1)
  204. {
  205. openProfile(GTAV_Profiles.at(0));
  206. }
  207. else if(GTAV_Profiles.contains(defaultProfile))
  208. {
  209. openProfile(defaultProfile);
  210. }
  211. }
  212. else
  213. {
  214. GTAV_Profiles = QStringList();
  215. setupProfileUi();
  216. }
  217. settings.endGroup();
  218. }
  219. void UserInterface::setupProfileUi()
  220. {
  221. qreal screenRatio = AppEnv::screenRatio();
  222. if (GTAV_Profiles.isEmpty())
  223. {
  224. QPushButton *changeDirBtn = new QPushButton(tr("Select &GTA V Folder..."), ui->swSelection);
  225. changeDirBtn->setObjectName("cmdChangeDir");
  226. changeDirBtn->setMinimumSize(0, 40 * screenRatio);
  227. changeDirBtn->setAutoDefault(true);
  228. ui->vlButtons->addWidget(changeDirBtn);
  229. profileBtns += changeDirBtn;
  230. QObject::connect(changeDirBtn, SIGNAL(clicked(bool)), this, SLOT(changeFolder_clicked()));
  231. }
  232. else for (QString GTAV_Profile : GTAV_Profiles)
  233. {
  234. QPushButton *profileBtn = new QPushButton(GTAV_Profile, ui->swSelection);
  235. profileBtn->setObjectName(GTAV_Profile);
  236. profileBtn->setMinimumSize(0, 40 * screenRatio);
  237. profileBtn->setAutoDefault(true);
  238. ui->vlButtons->addWidget(profileBtn);
  239. profileBtns += profileBtn;
  240. QObject::connect(profileBtn, SIGNAL(clicked(bool)), this, SLOT(profileButton_clicked()));
  241. }
  242. profileBtns.at(0)->setFocus();
  243. }
  244. void UserInterface::changeFolder_clicked()
  245. {
  246. on_actionSelect_GTA_Folder_triggered();
  247. }
  248. void UserInterface::on_cmdReload_clicked()
  249. {
  250. for (QPushButton *profileBtn : profileBtns)
  251. {
  252. ui->vlButtons->removeWidget(profileBtn);
  253. delete profileBtn;
  254. }
  255. profileBtns.clear();
  256. setupDirEnv();
  257. }
  258. void UserInterface::profileButton_clicked()
  259. {
  260. QPushButton *profileBtn = (QPushButton*)sender();
  261. openProfile(profileBtn->objectName());
  262. }
  263. void UserInterface::openProfile(const QString &profileName_)
  264. {
  265. profileOpen = true;
  266. profileName = profileName_;
  267. profileUI = new ProfileInterface(profileDB, crewDB, threadDB);
  268. ui->swProfile->addWidget(profileUI);
  269. ui->swProfile->setCurrentWidget(profileUI);
  270. profileUI->setProfileFolder(GTAV_ProfilesFolder % QDir::separator() % profileName, profileName);
  271. profileUI->settingsApplied(contentMode, false);
  272. profileUI->setupProfileInterface();
  273. QObject::connect(profileUI, SIGNAL(profileClosed()), this, SLOT(closeProfile()));
  274. QObject::connect(profileUI, SIGNAL(profileLoaded()), this, SLOT(profileLoaded()));
  275. this->setWindowTitle(defaultWindowTitle.arg(profileName));
  276. }
  277. void UserInterface::closeProfile()
  278. {
  279. if (profileOpen)
  280. {
  281. closeProfile_p();
  282. }
  283. this->setWindowTitle(defaultWindowTitle.arg(tr("Select Profile")));
  284. }
  285. void UserInterface::closeProfile_p()
  286. {
  287. profileOpen = false;
  288. profileName.clear();
  289. profileName.squeeze();
  290. ui->menuProfile->setEnabled(false);
  291. ui->actionSelect_profile->setEnabled(false);
  292. ui->swProfile->removeWidget(profileUI);
  293. profileUI->disconnect();
  294. delete profileUI;
  295. }
  296. void UserInterface::closeEvent(QCloseEvent *ev)
  297. {
  298. Q_UNUSED(ev)
  299. threadDB->terminateThread();
  300. }
  301. UserInterface::~UserInterface()
  302. {
  303. if (profileOpen)
  304. {
  305. closeProfile_p();
  306. }
  307. for (QPushButton *profileBtn : profileBtns)
  308. {
  309. delete profileBtn;
  310. }
  311. profileBtns.clear();
  312. delete ui;
  313. }
  314. void UserInterface::on_actionExit_triggered()
  315. {
  316. this->close();
  317. }
  318. void UserInterface::on_actionSelect_profile_triggered()
  319. {
  320. closeProfile();
  321. openSelectProfile();
  322. }
  323. void UserInterface::openSelectProfile()
  324. {
  325. // not needed right now
  326. }
  327. void UserInterface::on_actionAbout_gta5sync_triggered()
  328. {
  329. AboutDialog *aboutDialog = new AboutDialog(this);
  330. aboutDialog->setWindowIcon(windowIcon());
  331. aboutDialog->setModal(true);
  332. #ifdef Q_OS_ANDROID
  333. // Android ...
  334. aboutDialog->showMaximized();
  335. #else
  336. aboutDialog->show();
  337. #endif
  338. aboutDialog->exec();
  339. delete aboutDialog;
  340. }
  341. void UserInterface::profileLoaded()
  342. {
  343. ui->menuProfile->setEnabled(true);
  344. ui->actionSelect_profile->setEnabled(true);
  345. }
  346. void UserInterface::on_actionSelect_all_triggered()
  347. {
  348. if (profileOpen)
  349. {
  350. profileUI->selectAllWidgets();
  351. }
  352. }
  353. void UserInterface::on_actionDeselect_all_triggered()
  354. {
  355. if (profileOpen)
  356. {
  357. profileUI->deselectAllWidgets();
  358. }
  359. }
  360. void UserInterface::on_actionExport_selected_triggered()
  361. {
  362. if (profileOpen)
  363. {
  364. profileUI->exportSelected();
  365. }
  366. }
  367. void UserInterface::on_actionDelete_selected_triggered()
  368. {
  369. if (profileOpen)
  370. {
  371. profileUI->deleteSelected();
  372. }
  373. }
  374. void UserInterface::on_actionOptions_triggered()
  375. {
  376. OptionsDialog *optionsDialog = new OptionsDialog(profileDB, this);
  377. optionsDialog->setWindowIcon(windowIcon());
  378. optionsDialog->commitProfiles(GTAV_Profiles);
  379. QObject::connect(optionsDialog, SIGNAL(settingsApplied(int, bool)), this, SLOT(settingsApplied(int, bool)));
  380. optionsDialog->setModal(true);
  381. #ifdef Q_OS_ANDROID
  382. // Android ...
  383. optionsDialog->showMaximized();
  384. #else
  385. optionsDialog->show();
  386. #endif
  387. optionsDialog->exec();
  388. delete optionsDialog;
  389. }
  390. void UserInterface::on_action_Import_triggered()
  391. {
  392. if (profileOpen)
  393. {
  394. profileUI->importFiles();
  395. }
  396. }
  397. void UserInterface::on_actionOpen_File_triggered()
  398. {
  399. QSettings settings(GTA5SYNC_APPVENDOR, GTA5SYNC_APPSTR);
  400. settings.beginGroup("FileDialogs");
  401. fileDialogPreOpen:
  402. QFileDialog fileDialog(this);
  403. fileDialog.setFileMode(QFileDialog::ExistingFiles);
  404. fileDialog.setViewMode(QFileDialog::Detail);
  405. fileDialog.setAcceptMode(QFileDialog::AcceptOpen);
  406. fileDialog.setOption(QFileDialog::DontUseNativeDialog, false);
  407. fileDialog.setWindowFlags(fileDialog.windowFlags()^Qt::WindowContextHelpButtonHint);
  408. fileDialog.setWindowTitle(tr("Open File..."));
  409. QStringList filters;
  410. filters << ProfileInterface::tr("All profile files (*.g5e SGTA* PGTA*)");
  411. filters << ProfileInterface::tr("GTA V Export (*.g5e)");
  412. filters << ProfileInterface::tr("Savegames files (SGTA*)");
  413. filters << ProfileInterface::tr("Snapmatic pictures (PGTA*)");
  414. filters << ProfileInterface::tr("All files (**)");
  415. fileDialog.setNameFilters(filters);
  416. QList<QUrl> sidebarUrls = SidebarGenerator::generateSidebarUrls(fileDialog.sidebarUrls());
  417. fileDialog.setSidebarUrls(sidebarUrls);
  418. fileDialog.setDirectory(settings.value("OpenDialogDirectory", StandardPaths::documentsLocation()).toString());
  419. fileDialog.restoreGeometry(settings.value("OpenDialogGeometry","").toByteArray());
  420. if (fileDialog.exec())
  421. {
  422. QStringList selectedFiles = fileDialog.selectedFiles();
  423. if (selectedFiles.length() == 1)
  424. {
  425. QString selectedFile = selectedFiles.at(0);
  426. if (!openFile(selectedFile, true)) goto fileDialogPreOpen;
  427. }
  428. }
  429. settings.setValue("OpenDialogGeometry", fileDialog.saveGeometry());
  430. settings.setValue("OpenDialogDirectory", fileDialog.directory().absolutePath());
  431. settings.endGroup();
  432. }
  433. bool UserInterface::openFile(QString selectedFile, bool warn)
  434. {
  435. QString selectedFileName = QFileInfo(selectedFile).fileName();
  436. if (QFile::exists(selectedFile))
  437. {
  438. if (selectedFileName.left(4) == "PGTA" || selectedFileName.right(4) == ".g5e")
  439. {
  440. SnapmaticPicture *picture = new SnapmaticPicture(selectedFile);
  441. if (picture->readingPicture())
  442. {
  443. openSnapmaticFile(picture);
  444. delete picture;
  445. return true;
  446. }
  447. else
  448. {
  449. if (warn) QMessageBox::warning(this, tr("Open File"), ProfileInterface::tr("Failed to read Snapmatic picture"));
  450. delete picture;
  451. return false;
  452. }
  453. }
  454. else if (selectedFileName.left(4) == "SGTA")
  455. {
  456. SavegameData *savegame = new SavegameData(selectedFile);
  457. if (savegame->readingSavegame())
  458. {
  459. openSavegameFile(savegame);
  460. delete savegame;
  461. return true;
  462. }
  463. else
  464. {
  465. if (warn) QMessageBox::warning(this, tr("Open File"), ProfileInterface::tr("Failed to read Savegame file"));
  466. delete savegame;
  467. return false;
  468. }
  469. }
  470. else
  471. {
  472. SnapmaticPicture *picture = new SnapmaticPicture(selectedFile);
  473. SavegameData *savegame = new SavegameData(selectedFile);
  474. if (picture->readingPicture())
  475. {
  476. delete savegame;
  477. openSnapmaticFile(picture);
  478. delete picture;
  479. return true;
  480. }
  481. else if (savegame->readingSavegame())
  482. {
  483. delete picture;
  484. openSavegameFile(savegame);
  485. delete savegame;
  486. return true;
  487. }
  488. else
  489. {
  490. delete savegame;
  491. delete picture;
  492. if (warn) QMessageBox::warning(this, tr("Open File"), tr("Can't open %1 because of not valid file format").arg("\""+selectedFileName+"\""));
  493. return false;
  494. }
  495. }
  496. }
  497. if (warn) QMessageBox::warning(this, tr("Open File"), ProfileInterface::tr("No valid file is selected"));
  498. return false;
  499. }
  500. void UserInterface::openSnapmaticFile(SnapmaticPicture *picture)
  501. {
  502. PictureDialog picDialog(profileDB, crewDB, this);
  503. picDialog.setSnapmaticPicture(picture, true);
  504. picDialog.setModal(true);
  505. int crewID = picture->getSnapmaticProperties().crewID;
  506. if (crewID != 0) { crewDB->addCrew(crewID); }
  507. QObject::connect(threadDB, SIGNAL(crewNameUpdated()), &picDialog, SLOT(crewNameUpdated()));
  508. QObject::connect(threadDB, SIGNAL(playerNameUpdated()), &picDialog, SLOT(playerNameUpdated()));
  509. #ifdef Q_OS_ANDROID
  510. // Android optimization should be put here
  511. picDialog.showMaximized();
  512. #else
  513. picDialog.show();
  514. picDialog.setMinimumSize(picDialog.size());
  515. picDialog.setMaximumSize(picDialog.size());
  516. #endif
  517. picDialog.exec();
  518. }
  519. void UserInterface::openSavegameFile(SavegameData *savegame)
  520. {
  521. SavegameDialog sgdDialog(this);
  522. sgdDialog.setSavegameData(savegame, savegame->getSavegameFileName(), true);
  523. sgdDialog.setModal(true);
  524. #ifdef Q_OS_ANDROID
  525. // Android optimization should be put here
  526. sgdDialog.showMaximized();
  527. #else
  528. sgdDialog.show();
  529. #endif
  530. sgdDialog.exec();
  531. }
  532. void UserInterface::settingsApplied(int _contentMode, bool languageChanged)
  533. {
  534. if (languageChanged)
  535. {
  536. retranslateUi();
  537. }
  538. contentMode = _contentMode;
  539. if (profileOpen)
  540. {
  541. profileUI->settingsApplied(contentMode, languageChanged);
  542. }
  543. }
  544. void UserInterface::on_actionSelect_GTA_Folder_triggered()
  545. {
  546. QString GTAV_Folder_Temp = QFileDialog::getExistingDirectory(this, tr("Select GTA V Folder..."), StandardPaths::documentsLocation(), QFileDialog::ShowDirsOnly);
  547. if (QFileInfo(GTAV_Folder_Temp).exists())
  548. {
  549. if (profileOpen)
  550. {
  551. closeProfile_p();
  552. }
  553. GTAV_Folder = GTAV_Folder_Temp;
  554. QDir::setCurrent(GTAV_Folder);
  555. AppEnv::setGameFolder(GTAV_Folder);
  556. on_cmdReload_clicked();
  557. }
  558. }
  559. void UserInterface::on_action_Enable_In_game_triggered()
  560. {
  561. if (profileOpen)
  562. {
  563. profileUI->enableSelected();
  564. }
  565. }
  566. void UserInterface::on_action_Disable_In_game_triggered()
  567. {
  568. if (profileOpen)
  569. {
  570. profileUI->disableSelected();
  571. }
  572. }
  573. void UserInterface::retranslateUi()
  574. {
  575. ui->retranslateUi(this);
  576. ui->actionAbout_gta5sync->setText(tr("&About %1").arg(GTA5SYNC_APPSTR));
  577. QString appVersion = GTA5SYNC_APPVER;
  578. #ifndef GTA5SYNC_BUILDTYPE_REL
  579. #ifdef GTA5SYNC_COMMIT
  580. if (!appVersion.contains("-")) { appVersion = appVersion % "-" % GTA5SYNC_COMMIT; }
  581. #endif
  582. #endif
  583. ui->labVersion->setText(QString("%1 %2").arg(GTA5SYNC_APPSTR, appVersion));
  584. if (profileOpen)
  585. {
  586. this->setWindowTitle(defaultWindowTitle.arg(profileName));
  587. }
  588. else
  589. {
  590. this->setWindowTitle(defaultWindowTitle.arg(tr("Select Profile")));
  591. }
  592. }
  593. void UserInterface::on_actionQualify_as_Avatar_triggered()
  594. {
  595. profileUI->massTool(MassTool::Qualify);
  596. }
  597. void UserInterface::on_actionChange_Players_triggered()
  598. {
  599. profileUI->massTool(MassTool::Players);
  600. }
  601. void UserInterface::on_actionSet_Crew_triggered()
  602. {
  603. profileUI->massTool(MassTool::Crew);
  604. }
  605. void UserInterface::on_actionSet_Title_triggered()
  606. {
  607. profileUI->massTool(MassTool::Title);
  608. }