2016-03-23 06:29:49 +01:00
/*****************************************************************************
* gta5sync GRAND THEFT AUTO V SYNC
2017-01-22 16:45:42 +01:00
* Copyright ( C ) 2016 - 2017 Syping
2016-03-23 06:29:49 +01:00
*
* 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 "UserInterface.h"
# include "ui_UserInterface.h"
# include "ProfileInterface.h"
2016-04-14 04:18:22 +02:00
# include "SnapmaticPicture.h"
# include "SidebarGenerator.h"
# include "SavegameDialog.h"
2016-03-28 12:23:50 +02:00
# include "StandardPaths.h"
2016-04-12 16:42:04 +02:00
# include "OptionsDialog.h"
2016-04-14 04:18:22 +02:00
# include "PictureDialog.h"
# include "SavegameData.h"
2016-03-27 18:22:22 +02:00
# include "AboutDialog.h"
2016-04-11 16:51:32 +02:00
# include "IconLoader.h"
2016-04-10 22:31:11 +02:00
# include "AppEnv.h"
2016-04-14 01:27:29 +02:00
# include "config.h"
2017-02-21 22:57:30 +01:00
# include <QtGlobal>
2016-11-28 07:59:55 +01:00
# include <QStyleFactory>
2016-04-11 16:51:32 +02:00
# include <QFileDialog>
2016-03-27 15:53:32 +02:00
# include <QHBoxLayout>
# include <QSpacerItem>
# include <QPushButton>
2016-03-25 07:07:58 +01:00
# include <QMessageBox>
# include <QSettings>
# include <QFileInfo>
2016-04-03 08:39:31 +02:00
# include <QProcess>
2016-03-26 08:53:37 +01:00
# include <QDebug>
2016-03-25 07:07:58 +01:00
# include <QFile>
# include <QDir>
# include <QMap>
2016-03-27 15:53:32 +02:00
UserInterface : : UserInterface ( ProfileDatabase * profileDB , CrewDatabase * crewDB , DatabaseThread * threadDB , QWidget * parent ) :
QMainWindow ( parent ) , profileDB ( profileDB ) , crewDB ( crewDB ) , threadDB ( threadDB ) ,
2016-03-23 06:29:49 +01:00
ui ( new Ui : : UserInterface )
{
ui - > setupUi ( this ) ;
2016-04-14 06:33:15 +02:00
contentMode = 0 ;
2016-03-27 13:19:50 +02:00
profileOpen = 0 ;
profileUI = 0 ;
2016-04-03 08:39:31 +02:00
ui - > menuProfile - > setEnabled ( false ) ;
2016-04-14 01:59:41 +02:00
ui - > actionSelect_profile - > setEnabled ( false ) ;
2016-04-14 02:41:24 +02:00
ui - > actionAbout_gta5sync - > setIcon ( IconLoader : : loadingAppIcon ( ) ) ;
2017-01-22 16:45:42 +01:00
ui - > actionAbout_gta5sync - > setText ( tr ( " &About %1 " ) . arg ( GTA5SYNC_APPSTR ) ) ;
2016-10-27 08:17:24 +02:00
defaultWindowTitle = tr ( " %2 - %1 " ) . arg ( " %1 " , GTA5SYNC_APPSTR ) ;
2016-03-28 14:10:59 +02:00
2016-04-08 16:55:28 +02:00
this - > setWindowTitle ( defaultWindowTitle . arg ( tr ( " Select Profile " ) ) ) ;
2016-10-27 08:12:59 +02:00
ui - > labVersion - > setText ( ui - > labVersion - > text ( ) . arg ( GTA5SYNC_APPSTR , GTA5SYNC_APPVER ) ) ;
2017-02-11 04:21:55 +01:00
if ( QIcon : : hasThemeIcon ( " dialog-close " ) )
{
ui - > cmdClose - > setIcon ( QIcon : : fromTheme ( " dialog-close " ) ) ;
}
2017-02-21 22:57:30 +01:00
if ( QIcon : : hasThemeIcon ( " preferences-system " ) )
{
2017-03-30 03:44:48 +02:00
# ifndef Q_OS_MACOS // Setting icon for preferences/settings/options lead to a crash in Mac OS X
2017-02-21 22:57:30 +01:00
ui - > actionOptions - > setIcon ( QIcon : : fromTheme ( " preferences-system " ) ) ;
# endif
}
if ( QIcon : : hasThemeIcon ( " application-exit " ) )
{
2017-03-30 03:44:48 +02:00
# ifndef Q_OS_MACOS // Setting icon for exit/quit lead to a crash in Mac OS X
2017-02-21 22:57:30 +01:00
ui - > actionExit - > setIcon ( QIcon : : fromTheme ( " application-exit " ) ) ;
# endif
}
2017-05-01 05:05:55 +02:00
// DPI calculation
qreal screenRatio = AppEnv : : screenRatio ( ) ;
resize ( 625 * screenRatio , 500 * screenRatio ) ;
ui - > vlUserInterface - > setSpacing ( 6 * screenRatio ) ;
ui - > vlUserInterface - > setContentsMargins ( 9 * screenRatio , 9 * screenRatio , 9 * screenRatio , 9 * screenRatio ) ;
2016-04-11 16:51:32 +02:00
}
2016-03-25 07:07:58 +01:00
2016-04-11 16:51:32 +02:00
void UserInterface : : setupDirEnv ( )
{
2016-04-10 22:31:11 +02:00
bool folderExists ;
GTAV_Folder = AppEnv : : getGameFolder ( & folderExists ) ;
if ( folderExists )
2016-03-25 07:07:58 +01:00
{
QDir : : setCurrent ( GTAV_Folder ) ;
}
else
{
2016-04-11 16:51:32 +02:00
GTAV_Folder = QFileDialog : : getExistingDirectory ( this , tr ( " Select GTA V Folder... " ) , StandardPaths : : documentsLocation ( ) , QFileDialog : : ShowDirsOnly ) ;
if ( QFileInfo ( GTAV_Folder ) . exists ( ) )
{
folderExists = true ;
QDir : : setCurrent ( GTAV_Folder ) ;
AppEnv : : setGameFolder ( GTAV_Folder ) ;
}
2016-03-25 07:07:58 +01:00
}
// profiles init
2016-04-14 06:33:15 +02:00
QSettings settings ( GTA5SYNC_APPVENDOR , GTA5SYNC_APPSTR ) ;
settings . beginGroup ( " Profile " ) ;
QString defaultProfile = settings . value ( " Default " , " " ) . toString ( ) ;
bool contentModeOk ;
contentMode = settings . value ( " ContentMode " , 0 ) . toInt ( & contentModeOk ) ;
2016-10-27 10:39:21 +02:00
if ( contentMode ! = 0 & & contentMode ! = 1 & & contentMode ! = 2 )
2016-04-14 06:33:15 +02:00
{
contentMode = 0 ;
}
2016-03-25 07:07:58 +01:00
2016-04-11 16:51:32 +02:00
if ( folderExists )
2016-03-26 08:53:37 +01:00
{
2016-04-11 16:51:32 +02:00
QDir GTAV_ProfilesDir ;
GTAV_ProfilesFolder = GTAV_Folder + QDir : : separator ( ) + " Profiles " ;
GTAV_ProfilesDir . setPath ( GTAV_ProfilesFolder ) ;
2016-04-14 06:33:15 +02:00
GTAV_Profiles = GTAV_ProfilesDir . entryList ( QDir : : Dirs | QDir : : NoDotAndDotDot , QDir : : NoSort ) ;
setupProfileUi ( ) ;
2016-04-11 16:51:32 +02:00
if ( GTAV_Profiles . length ( ) = = 1 )
{
openProfile ( GTAV_Profiles . at ( 0 ) ) ;
}
else if ( GTAV_Profiles . contains ( defaultProfile ) )
{
openProfile ( defaultProfile ) ;
}
2016-03-27 13:19:50 +02:00
}
2016-04-11 16:51:32 +02:00
else
2016-03-27 13:19:50 +02:00
{
2016-04-14 06:33:15 +02:00
GTAV_Profiles = QStringList ( ) ;
setupProfileUi ( ) ;
2016-03-27 13:19:50 +02:00
}
2016-04-14 06:33:15 +02:00
settings . endGroup ( ) ;
2016-03-27 13:19:50 +02:00
}
2016-04-14 06:33:15 +02:00
void UserInterface : : setupProfileUi ( )
2016-03-27 15:53:32 +02:00
{
2017-05-01 05:05:55 +02:00
qreal screenRatio = AppEnv : : screenRatio ( ) ;
2016-04-03 08:39:31 +02:00
if ( GTAV_Profiles . length ( ) = = 0 )
{
2016-07-26 08:00:56 +02:00
QPushButton * changeDirBtn = new QPushButton ( tr ( " Select >A V Folder... " ) , ui - > swSelection ) ;
2016-04-11 16:51:32 +02:00
changeDirBtn - > setObjectName ( " cmdChangeDir " ) ;
2017-05-01 05:05:55 +02:00
changeDirBtn - > setMinimumSize ( 0 , 40 * screenRatio ) ;
2016-04-11 16:51:32 +02:00
changeDirBtn - > setAutoDefault ( true ) ;
ui - > vlButtons - > addWidget ( changeDirBtn ) ;
profileBtns . append ( changeDirBtn ) ;
2016-04-03 08:39:31 +02:00
2016-04-11 16:51:32 +02:00
QObject : : connect ( changeDirBtn , SIGNAL ( clicked ( bool ) ) , this , SLOT ( changeFolder_clicked ( ) ) ) ;
2016-04-03 08:39:31 +02:00
}
else foreach ( const QString & GTAV_Profile , GTAV_Profiles )
2016-03-27 15:53:32 +02:00
{
QPushButton * profileBtn = new QPushButton ( GTAV_Profile , ui - > swSelection ) ;
profileBtn - > setObjectName ( GTAV_Profile ) ;
2017-05-01 05:05:55 +02:00
profileBtn - > setMinimumSize ( 0 , 40 * screenRatio ) ;
2016-03-27 15:53:32 +02:00
profileBtn - > setAutoDefault ( true ) ;
2016-04-11 16:51:32 +02:00
ui - > vlButtons - > addWidget ( profileBtn ) ;
profileBtns . append ( profileBtn ) ;
2016-03-27 15:53:32 +02:00
2016-04-03 06:12:12 +02:00
QObject : : connect ( profileBtn , SIGNAL ( clicked ( bool ) ) , this , SLOT ( profileButton_clicked ( ) ) ) ;
2016-03-27 15:53:32 +02:00
}
2016-04-11 16:51:32 +02:00
profileBtns . at ( 0 ) - > setFocus ( ) ;
2016-03-27 15:53:32 +02:00
}
2016-04-11 16:51:32 +02:00
void UserInterface : : changeFolder_clicked ( )
2016-04-03 08:39:31 +02:00
{
2016-07-26 08:00:56 +02:00
on_actionSelect_GTA_Folder_triggered ( ) ;
2016-04-11 16:51:32 +02:00
}
2016-04-11 17:18:16 +02:00
void UserInterface : : on_cmdReload_clicked ( )
2016-04-11 16:51:32 +02:00
{
foreach ( QPushButton * profileBtn , profileBtns )
2016-04-03 08:39:31 +02:00
{
2016-04-11 16:51:32 +02:00
ui - > vlButtons - > removeWidget ( profileBtn ) ;
profileBtns . removeAll ( profileBtn ) ;
delete profileBtn ;
2016-04-03 08:39:31 +02:00
}
2016-04-11 16:51:32 +02:00
setupDirEnv ( ) ;
2016-04-03 08:39:31 +02:00
}
2016-04-03 06:12:12 +02:00
void UserInterface : : profileButton_clicked ( )
2016-03-27 15:53:32 +02:00
{
QPushButton * profileBtn = ( QPushButton * ) sender ( ) ;
openProfile ( profileBtn - > objectName ( ) ) ;
}
2016-03-27 13:19:50 +02:00
void UserInterface : : openProfile ( QString profileName )
{
profileOpen = true ;
2016-03-27 15:53:32 +02:00
profileUI = new ProfileInterface ( profileDB , crewDB , threadDB ) ;
2016-03-27 13:19:50 +02:00
ui - > swProfile - > addWidget ( profileUI ) ;
ui - > swProfile - > setCurrentWidget ( profileUI ) ;
2016-04-14 06:33:15 +02:00
profileUI - > setProfileFolder ( GTAV_ProfilesFolder + QDir : : separator ( ) + profileName , profileName ) ;
profileUI - > settingsApplied ( contentMode , language ) ;
2016-03-27 13:19:50 +02:00
profileUI - > setupProfileInterface ( ) ;
QObject : : connect ( profileUI , SIGNAL ( profileClosed ( ) ) , this , SLOT ( closeProfile ( ) ) ) ;
2016-04-03 08:39:31 +02:00
QObject : : connect ( profileUI , SIGNAL ( profileLoaded ( ) ) , this , SLOT ( profileLoaded ( ) ) ) ;
2016-03-28 14:10:59 +02:00
this - > setWindowTitle ( defaultWindowTitle . arg ( profileName ) ) ;
2016-03-27 13:19:50 +02:00
}
void UserInterface : : closeProfile ( )
{
if ( profileOpen )
{
profileOpen = false ;
2016-04-03 09:23:14 +02:00
ui - > menuProfile - > setEnabled ( false ) ;
2016-04-14 01:59:41 +02:00
ui - > actionSelect_profile - > setEnabled ( false ) ;
2016-03-27 13:19:50 +02:00
ui - > swProfile - > removeWidget ( profileUI ) ;
delete profileUI ;
2016-03-26 08:53:37 +01:00
}
2016-04-08 16:55:28 +02:00
this - > setWindowTitle ( defaultWindowTitle . arg ( tr ( " Select Profile " ) ) ) ;
2016-03-23 06:29:49 +01:00
}
2017-02-17 12:07:37 +01:00
void UserInterface : : closeEvent ( QCloseEvent * ev )
{
Q_UNUSED ( ev )
threadDB - > doEndThread ( ) ;
}
2016-03-23 06:29:49 +01:00
UserInterface : : ~ UserInterface ( )
{
2016-04-11 16:51:32 +02:00
foreach ( QPushButton * profileBtn , profileBtns )
{
delete profileBtn ;
}
2016-03-23 06:29:49 +01:00
delete ui ;
}
void UserInterface : : on_actionExit_triggered ( )
{
this - > close ( ) ;
}
2016-03-27 15:53:32 +02:00
void UserInterface : : on_actionSelect_profile_triggered ( )
{
closeProfile ( ) ;
openSelectProfile ( ) ;
}
void UserInterface : : openSelectProfile ( )
{
// not needed right now
}
2016-03-27 18:22:22 +02:00
void UserInterface : : on_actionAbout_gta5sync_triggered ( )
{
AboutDialog * aboutDialog = new AboutDialog ( this ) ;
2017-03-01 15:19:40 +01:00
aboutDialog - > setWindowIcon ( windowIcon ( ) ) ;
2016-04-02 21:09:07 +02:00
aboutDialog - > setModal ( true ) ;
2017-03-30 03:44:48 +02:00
# ifdef Q_OS_ANDROID
// Android ...
aboutDialog - > showMaximized ( ) ;
# else
2016-03-27 18:22:22 +02:00
aboutDialog - > show ( ) ;
2017-03-30 03:44:48 +02:00
# endif
2016-03-27 18:22:22 +02:00
aboutDialog - > exec ( ) ;
delete aboutDialog ;
}
2016-04-03 08:39:31 +02:00
void UserInterface : : profileLoaded ( )
{
2016-04-12 23:29:28 +02:00
ui - > menuProfile - > setEnabled ( true ) ;
2016-04-14 01:59:41 +02:00
ui - > actionSelect_profile - > setEnabled ( true ) ;
2016-04-03 08:39:31 +02:00
}
void UserInterface : : on_actionSelect_all_triggered ( )
{
2016-04-14 06:33:15 +02:00
if ( profileOpen )
{
profileUI - > selectAllWidgets ( ) ;
}
2016-04-03 08:39:31 +02:00
}
void UserInterface : : on_actionDeselect_all_triggered ( )
{
2016-04-14 06:33:15 +02:00
if ( profileOpen )
{
profileUI - > deselectAllWidgets ( ) ;
}
2016-04-03 08:39:31 +02:00
}
2016-04-03 10:17:01 +02:00
void UserInterface : : on_actionExport_selected_triggered ( )
{
2016-04-14 06:33:15 +02:00
if ( profileOpen )
{
profileUI - > exportSelected ( ) ;
}
2016-04-03 10:17:01 +02:00
}
void UserInterface : : on_actionDelete_selected_triggered ( )
{
2016-04-14 06:33:15 +02:00
if ( profileOpen )
{
profileUI - > deleteSelected ( ) ;
}
2016-04-03 10:17:01 +02:00
}
2016-04-12 16:42:04 +02:00
void UserInterface : : on_actionOptions_triggered ( )
{
2016-04-14 01:27:29 +02:00
OptionsDialog * optionsDialog = new OptionsDialog ( profileDB , this ) ;
2017-03-01 15:19:40 +01:00
optionsDialog - > setWindowIcon ( windowIcon ( ) ) ;
2016-04-14 06:33:15 +02:00
optionsDialog - > commitProfiles ( GTAV_Profiles ) ;
2017-03-01 15:19:40 +01:00
QObject : : connect ( optionsDialog , SIGNAL ( settingsApplied ( int , QString ) ) , this , SLOT ( settingsApplied ( int , QString ) ) ) ;
2016-04-14 06:33:15 +02:00
2016-04-12 16:42:04 +02:00
optionsDialog - > setModal ( true ) ;
2017-03-30 03:44:48 +02:00
# ifdef Q_OS_ANDROID
// Android ...
optionsDialog - > showMaximized ( ) ;
# else
2016-04-12 16:42:04 +02:00
optionsDialog - > show ( ) ;
2017-03-30 03:44:48 +02:00
# endif
2016-04-12 16:42:04 +02:00
optionsDialog - > exec ( ) ;
2017-03-01 15:19:40 +01:00
2016-04-12 16:42:04 +02:00
delete optionsDialog ;
}
2016-04-13 00:47:07 +02:00
void UserInterface : : on_action_Import_triggered ( )
{
2016-04-14 06:33:15 +02:00
if ( profileOpen )
{
profileUI - > importFiles ( ) ;
}
2016-04-13 00:47:07 +02:00
}
2016-04-14 04:18:22 +02:00
void UserInterface : : on_actionOpen_File_triggered ( )
{
QSettings settings ( GTA5SYNC_APPVENDOR , GTA5SYNC_APPSTR ) ;
settings . beginGroup ( " FileDialogs " ) ;
fileDialogPreOpen :
QFileDialog fileDialog ( this ) ;
fileDialog . setFileMode ( QFileDialog : : ExistingFiles ) ;
fileDialog . setViewMode ( QFileDialog : : Detail ) ;
fileDialog . setAcceptMode ( QFileDialog : : AcceptOpen ) ;
fileDialog . setOption ( QFileDialog : : DontUseNativeDialog , false ) ;
fileDialog . setWindowFlags ( fileDialog . windowFlags ( ) ^ Qt : : WindowContextHelpButtonHint ) ;
fileDialog . setWindowTitle ( tr ( " Open File... " ) ) ;
QStringList filters ;
2017-01-27 04:33:27 +01:00
filters < < ProfileInterface : : tr ( " All profile files (*.g5e SGTA* PGTA*) " ) ;
filters < < ProfileInterface : : tr ( " GTA V Export (*.g5e) " ) ;
2016-04-14 04:18:22 +02:00
filters < < ProfileInterface : : tr ( " Savegames files (SGTA*) " ) ;
filters < < ProfileInterface : : tr ( " Snapmatic pictures (PGTA*) " ) ;
filters < < ProfileInterface : : tr ( " All files (**) " ) ;
fileDialog . setNameFilters ( filters ) ;
QList < QUrl > sidebarUrls = SidebarGenerator : : generateSidebarUrls ( fileDialog . sidebarUrls ( ) ) ;
fileDialog . setSidebarUrls ( sidebarUrls ) ;
2016-04-24 13:34:03 +02:00
fileDialog . setDirectory ( settings . value ( " OpenDialogDirectory " , StandardPaths : : documentsLocation ( ) ) . toString ( ) ) ;
fileDialog . restoreGeometry ( settings . value ( " OpenDialogGeometry " , " " ) . toByteArray ( ) ) ;
2016-04-14 04:18:22 +02:00
if ( fileDialog . exec ( ) )
{
QStringList selectedFiles = fileDialog . selectedFiles ( ) ;
if ( selectedFiles . length ( ) = = 1 )
{
QString selectedFile = selectedFiles . at ( 0 ) ;
if ( ! openFile ( selectedFile , true ) ) goto fileDialogPreOpen ;
}
}
2016-04-24 13:34:03 +02:00
settings . setValue ( " OpenDialogGeometry " , fileDialog . saveGeometry ( ) ) ;
settings . setValue ( " OpenDialogDirectory " , fileDialog . directory ( ) . absolutePath ( ) ) ;
2016-04-14 04:18:22 +02:00
settings . endGroup ( ) ;
}
bool UserInterface : : openFile ( QString selectedFile , bool warn )
{
QString selectedFileName = QFileInfo ( selectedFile ) . fileName ( ) ;
if ( QFile : : exists ( selectedFile ) )
{
2017-01-27 04:33:27 +01:00
if ( selectedFileName . left ( 4 ) = = " PGTA " | | selectedFileName . right ( 4 ) = = " .g5e " )
2016-04-14 04:18:22 +02:00
{
SnapmaticPicture * picture = new SnapmaticPicture ( selectedFile ) ;
if ( picture - > readingPicture ( ) )
{
openSnapmaticFile ( picture ) ;
delete picture ;
return true ;
}
else
{
2016-04-14 04:22:06 +02:00
if ( warn ) QMessageBox : : warning ( this , tr ( " Open File " ) , ProfileInterface : : tr ( " Failed to read Snapmatic picture " ) ) ;
2016-04-14 04:18:22 +02:00
delete picture ;
return false ;
}
}
else if ( selectedFileName . left ( 4 ) = = " SGTA " )
{
SavegameData * savegame = new SavegameData ( selectedFile ) ;
if ( savegame - > readingSavegame ( ) )
{
openSavegameFile ( savegame ) ;
delete savegame ;
return true ;
}
else
{
if ( warn ) QMessageBox : : warning ( this , tr ( " Open File " ) , ProfileInterface : : tr ( " Failed to read Savegame file " ) ) ;
delete savegame ;
return false ;
}
}
else
{
SnapmaticPicture * picture = new SnapmaticPicture ( selectedFile ) ;
SavegameData * savegame = new SavegameData ( selectedFile ) ;
if ( picture - > readingPicture ( ) )
{
delete savegame ;
openSnapmaticFile ( picture ) ;
delete picture ;
return true ;
}
else if ( savegame - > readingSavegame ( ) )
{
delete picture ;
openSavegameFile ( savegame ) ;
delete savegame ;
return true ;
}
else
{
delete savegame ;
delete picture ;
if ( warn ) QMessageBox : : warning ( this , tr ( " Open File " ) , tr ( " Can't open %1 because of not valid file format " ) . arg ( " \" " + selectedFileName + " \" " ) ) ;
return false ;
}
}
}
if ( warn ) QMessageBox : : warning ( this , tr ( " Open File " ) , ProfileInterface : : tr ( " No valid file is selected " ) ) ;
return false ;
}
void UserInterface : : openSnapmaticFile ( SnapmaticPicture * picture )
{
2017-03-01 15:19:40 +01:00
PictureDialog picDialog ( profileDB , crewDB , this ) ;
picDialog . setSnapmaticPicture ( picture , true ) ;
picDialog . setModal ( true ) ;
2016-04-14 04:18:22 +02:00
2016-12-10 04:35:24 +01:00
int crewID = picture - > getSnapmaticProperties ( ) . crewID ;
2016-04-14 04:18:22 +02:00
if ( crewID ! = 0 ) { crewDB - > addCrew ( crewID ) ; }
QObject : : connect ( threadDB , SIGNAL ( playerNameFound ( int , QString ) ) , profileDB , SLOT ( setPlayerName ( int , QString ) ) ) ;
2017-03-01 15:19:40 +01:00
QObject : : connect ( threadDB , SIGNAL ( playerNameUpdated ( ) ) , & picDialog , SLOT ( playerNameUpdated ( ) ) ) ;
2016-04-14 04:18:22 +02:00
2017-03-30 03:44:48 +02:00
# ifdef Q_OS_ANDROID
// Android optimization should be put here
picDialog . showMaximized ( ) ;
# else
2017-03-01 15:19:40 +01:00
picDialog . show ( ) ;
picDialog . setMinimumSize ( picDialog . size ( ) ) ;
picDialog . setMaximumSize ( picDialog . size ( ) ) ;
2017-03-30 03:44:48 +02:00
# endif
2016-04-24 15:02:01 +02:00
2017-03-01 15:19:40 +01:00
picDialog . exec ( ) ;
2016-04-14 04:18:22 +02:00
}
void UserInterface : : openSavegameFile ( SavegameData * savegame )
{
2017-03-01 15:19:40 +01:00
SavegameDialog sgdDialog ( this ) ;
sgdDialog . setSavegameData ( savegame , savegame - > getSavegameFileName ( ) , true ) ;
sgdDialog . setModal ( true ) ;
2017-03-30 03:44:48 +02:00
# ifdef Q_OS_ANDROID
// Android optimization should be put here
sgdDialog . showMaximized ( ) ;
# else
2017-03-01 15:19:40 +01:00
sgdDialog . show ( ) ;
2017-03-30 03:44:48 +02:00
# endif
2017-03-01 15:19:40 +01:00
sgdDialog . exec ( ) ;
2016-04-14 04:18:22 +02:00
}
2016-04-14 06:33:15 +02:00
void UserInterface : : settingsApplied ( int _contentMode , QString _language )
{
language = _language ;
contentMode = _contentMode ;
if ( profileOpen )
{
profileUI - > settingsApplied ( contentMode , language ) ;
}
}
2016-07-26 08:00:56 +02:00
void UserInterface : : on_actionSelect_GTA_Folder_triggered ( )
{
QString GTAV_Folder_Temp = QFileDialog : : getExistingDirectory ( this , tr ( " Select GTA V Folder... " ) , StandardPaths : : documentsLocation ( ) , QFileDialog : : ShowDirsOnly ) ;
if ( QFileInfo ( GTAV_Folder_Temp ) . exists ( ) )
{
GTAV_Folder = GTAV_Folder_Temp ;
QDir : : setCurrent ( GTAV_Folder ) ;
AppEnv : : setGameFolder ( GTAV_Folder ) ;
on_cmdReload_clicked ( ) ;
}
}
2016-10-27 11:24:26 +02:00
void UserInterface : : on_action_Enable_In_game_triggered ( )
{
if ( profileOpen )
{
profileUI - > enableSelected ( ) ;
}
}
void UserInterface : : on_action_Disable_In_game_triggered ( )
{
if ( profileOpen )
{
profileUI - > disableSelected ( ) ;
}
}