From 6c55773dbc7c377222b09f74449a8deabed9e44e Mon Sep 17 00:00:00 2001 From: Rafael Date: Sun, 27 Mar 2016 15:53:32 +0200 Subject: [PATCH] now can load more profiles, translation updated --- PictureDialog.cpp | 3 +++ ProfileInterface.cpp | 30 ++++++++++++++++++++--- ProfileInterface.h | 12 ++++++--- ProfileLoader.h | 1 + SnapmaticWidget.cpp | 11 +++++++-- SnapmaticWidget.h | 4 ++- UserInterface.cpp | 57 ++++++++++++++++++++++++++++++++++++++++--- UserInterface.h | 10 ++++++-- UserInterface.ui | 33 +++++++++++++++++++++++-- gta5sync_de.qm | Bin 4286 -> 4244 bytes gta5sync_de.ts | 45 ++++++++++++++++++++++------------ main.cpp | 2 +- 12 files changed, 175 insertions(+), 33 deletions(-) diff --git a/PictureDialog.cpp b/PictureDialog.cpp index 037500a..fddd79c 100755 --- a/PictureDialog.cpp +++ b/PictureDialog.cpp @@ -110,6 +110,9 @@ void PictureDialog::setSnapmaticPicture(SnapmaticPicture *picture, bool readOk) ui->labJSON->setText(jsonDrawString.arg("0.0", "0.0", "0.0", tr("No player"), tr("No crew"))); QMessageBox::warning(this,tr("Snapmatic Picture Viewer"),tr("Failed at %1").arg(picture->getLastStep())); } + + this->setMinimumSize(this->geometry().size()); + this->setMaximumSize(this->geometry().size()); } void PictureDialog::on_playerNameUpdated() diff --git a/ProfileInterface.cpp b/ProfileInterface.cpp index f202ce8..3fe5abd 100755 --- a/ProfileInterface.cpp +++ b/ProfileInterface.cpp @@ -19,35 +19,53 @@ #include "ProfileInterface.h" #include "ui_ProfileInterface.h" #include "SnapmaticWidget.h" +#include "DatabaseThread.h" #include "SavegameWidget.h" #include "ProfileLoader.h" #include #include +#include #include #include +#include #include #include -ProfileInterface::ProfileInterface(ProfileDatabase *profileDB, CrewDatabase *crewDB, QWidget *parent) : - QWidget(parent), profileDB(profileDB), crewDB(crewDB), +ProfileInterface::ProfileInterface(ProfileDatabase *profileDB, CrewDatabase *crewDB, DatabaseThread *threadDB, QWidget *parent) : + QWidget(parent), profileDB(profileDB), crewDB(crewDB), threadDB(threadDB), ui(new Ui::ProfileInterface) { ui->setupUi(this); ui->saProfile->setVisible(false); + ui->cmdCloseProfile->setEnabled(false); loadingStr = ui->labProfileLoading->text(); profileFolder = ""; + profileLoader = 0; + + QPalette palette; + QColor baseColor = palette.base().color(); + ui->saProfile->setStyleSheet("QWidget#saProfileContent{background-color: rgb(" + QString::number(baseColor.red()) + "," + QString::number(baseColor.green()) + "," + QString::number(baseColor.blue()) + ")}"); } ProfileInterface::~ProfileInterface() { foreach(SavegameData *savegame, savegames) { + savegame->deleteLater(); delete savegame; } foreach(SnapmaticPicture *picture, pictures) { + picture->deleteLater(); delete picture; } + foreach(QWidget *widget, widgets) + { + widget->deleteLater(); + delete widget; + } + profileLoader->deleteLater(); + delete profileLoader; delete ui; } @@ -59,7 +77,8 @@ void ProfileInterface::setProfileFolder(QString folder, QString profile) void ProfileInterface::setupProfileInterface() { - ProfileLoader *profileLoader = new ProfileLoader(profileFolder, crewDB); + ui->labProfileLoading->setText(tr("Loading...")); + profileLoader = new ProfileLoader(profileFolder, crewDB); QObject::connect(profileLoader, SIGNAL(savegameLoaded(SavegameData*, QString)), this, SLOT(on_savegameLoaded(SavegameData*, QString))); QObject::connect(profileLoader, SIGNAL(pictureLoaded(SnapmaticPicture*, QString)), this, SLOT(on_pictureLoaded(SnapmaticPicture*, QString))); QObject::connect(profileLoader, SIGNAL(loadingProgress(int,int)), this, SLOT(on_loadingProgress(int,int))); @@ -72,14 +91,16 @@ void ProfileInterface::on_savegameLoaded(SavegameData *savegame, QString savegam SavegameWidget *sgdWidget = new SavegameWidget(); sgdWidget->setSavegameData(savegame, savegamePath); ui->vlSavegame->addWidget(sgdWidget); + widgets.append(sgdWidget); savegames.append(savegame); } void ProfileInterface::on_pictureLoaded(SnapmaticPicture *picture, QString picturePath) { - SnapmaticWidget *picWidget = new SnapmaticWidget(profileDB); + SnapmaticWidget *picWidget = new SnapmaticWidget(profileDB, threadDB); picWidget->setSnapmaticPicture(picture, picturePath); ui->vlSnapmatic->addWidget(picWidget); + widgets.append(picWidget); pictures.append(picture); } @@ -96,6 +117,7 @@ void ProfileInterface::on_profileLoaded() ui->saProfileContent->layout()->addItem(saSpacerItem); ui->saProfile->setVisible(true); ui->frmLoading->setVisible(false); + ui->cmdCloseProfile->setEnabled(true); } void ProfileInterface::on_cmdCloseProfile_clicked() diff --git a/ProfileInterface.h b/ProfileInterface.h index 4c71f6f..dc1e902 100755 --- a/ProfileInterface.h +++ b/ProfileInterface.h @@ -21,6 +21,8 @@ #include "SnapmaticPicture.h" #include "ProfileDatabase.h" +#include "DatabaseThread.h" +#include "ProfileLoader.h" #include "SavegameData.h" #include "CrewDatabase.h" #include @@ -34,7 +36,7 @@ class ProfileInterface : public QWidget { Q_OBJECT public: - explicit ProfileInterface(ProfileDatabase *profileDB, CrewDatabase *crewDB, QWidget *parent = 0); + explicit ProfileInterface(ProfileDatabase *profileDB, CrewDatabase *crewDB, DatabaseThread *threadDB, QWidget *parent = 0); void setProfileFolder(QString folder, QString profile); void setupProfileInterface(); ~ProfileInterface(); @@ -49,12 +51,16 @@ private slots: private: ProfileDatabase *profileDB; CrewDatabase *crewDB; + DatabaseThread *threadDB; Ui::ProfileInterface *ui; + + ProfileLoader *profileLoader; + QList savegames; + QList pictures; + QList widgets; QString profileFolder; QString profileName; QString loadingStr; - QList savegames; - QList pictures; signals: void profileClosed(); diff --git a/ProfileLoader.h b/ProfileLoader.h index 5fa7321..c0ed9b4 100755 --- a/ProfileLoader.h +++ b/ProfileLoader.h @@ -37,6 +37,7 @@ protected: private: QString profileFolder; CrewDatabase *crewDB; + ProfileLoader *profileLoader; signals: void pictureLoaded(SnapmaticPicture *picture, QString picturePath); diff --git a/SnapmaticWidget.cpp b/SnapmaticWidget.cpp index 8128c88..1cdec19 100755 --- a/SnapmaticWidget.cpp +++ b/SnapmaticWidget.cpp @@ -19,11 +19,12 @@ #include "SnapmaticWidget.h" #include "ui_SnapmaticWidget.h" #include "SnapmaticPicture.h" +#include "DatabaseThread.h" #include "PictureDialog.h" #include -SnapmaticWidget::SnapmaticWidget(ProfileDatabase *profileDB, QWidget *parent) : - QWidget(parent), profileDB(profileDB), +SnapmaticWidget::SnapmaticWidget(ProfileDatabase *profileDB, DatabaseThread *threadDB, QWidget *parent) : + QWidget(parent), profileDB(profileDB), threadDB(threadDB), ui(new Ui::SnapmaticWidget) { ui->setupUi(this); @@ -52,7 +53,13 @@ void SnapmaticWidget::on_cmdView_clicked() picDialog->setWindowFlags(picDialog->windowFlags()^Qt::WindowContextHelpButtonHint); picDialog->setSnapmaticPicture(smpic, true); picDialog->setModal(true); + + // be ready for playerName updated + QObject::connect(threadDB, SIGNAL(playerNameUpdated()), picDialog, SLOT(on_playerNameUpdated())); + + // show picture dialog picDialog->show(); picDialog->exec(); picDialog->deleteLater(); + delete picDialog; } diff --git a/SnapmaticWidget.h b/SnapmaticWidget.h index 92f19f6..c66ad16 100755 --- a/SnapmaticWidget.h +++ b/SnapmaticWidget.h @@ -21,6 +21,7 @@ #include "SnapmaticPicture.h" #include "ProfileDatabase.h" +#include "DatabaseThread.h" #include namespace Ui { @@ -32,7 +33,7 @@ class SnapmaticWidget : public QWidget Q_OBJECT public: - explicit SnapmaticWidget(ProfileDatabase *profileDB, QWidget *parent = 0); + explicit SnapmaticWidget(ProfileDatabase *profileDB, DatabaseThread *threadDB, QWidget *parent = 0); void setSnapmaticPicture(SnapmaticPicture *picture, QString picturePath); ~SnapmaticWidget(); @@ -41,6 +42,7 @@ private slots: private: ProfileDatabase *profileDB; + DatabaseThread *threadDB; Ui::SnapmaticWidget *ui; SnapmaticPicture *smpic; QString picPath; diff --git a/UserInterface.cpp b/UserInterface.cpp index 32bcb2c..7b00a6c 100755 --- a/UserInterface.cpp +++ b/UserInterface.cpp @@ -19,6 +19,9 @@ #include "UserInterface.h" #include "ui_UserInterface.h" #include "ProfileInterface.h" +#include +#include +#include #include #include #include @@ -33,8 +36,8 @@ #include #endif -UserInterface::UserInterface(ProfileDatabase *profileDB, CrewDatabase *crewDB, QWidget *parent) : - QMainWindow(parent), profileDB(profileDB), crewDB(crewDB), +UserInterface::UserInterface(ProfileDatabase *profileDB, CrewDatabase *crewDB, DatabaseThread *threadDB, QWidget *parent) : + QMainWindow(parent), profileDB(profileDB), crewDB(crewDB), threadDB(threadDB), ui(new Ui::UserInterface) { ui->setupUi(this); @@ -80,6 +83,7 @@ UserInterface::UserInterface(ProfileDatabase *profileDB, CrewDatabase *crewDB, Q GTAV_ProfilesDir.setPath(GTAV_ProfilesFolder); QStringList GTAV_Profiles = GTAV_ProfilesDir.entryList(QDir::Dirs | QDir::NoDotAndDotDot, QDir::NoSort); + setupProfileUi(GTAV_Profiles); if (GTAV_Profiles.length() == 1) { @@ -92,10 +96,46 @@ UserInterface::UserInterface(ProfileDatabase *profileDB, CrewDatabase *crewDB, Q SyncSettings.endGroup(); } +void UserInterface::setupProfileUi(QStringList GTAV_Profiles) +{ + foreach(const QString >AV_Profile, GTAV_Profiles) + { + QPushButton *profileBtn = new QPushButton(GTAV_Profile, ui->swSelection); + profileBtn->setObjectName(GTAV_Profile); + profileBtn->setMinimumSize(0, 40); + profileBtn->setAutoDefault(true); + ui->swSelection->layout()->addWidget(profileBtn); + + QObject::connect(profileBtn, SIGNAL(clicked(bool)), this, SLOT(on_profileButton_clicked())); + } + QSpacerItem *buttomSpacerItem = new QSpacerItem(0, 0, QSizePolicy::Minimum, QSizePolicy::Expanding); + ui->swSelection->layout()->addItem(buttomSpacerItem); + + QHBoxLayout *footerLayout = new QHBoxLayout(); + footerLayout->setObjectName("footerLayout"); + ui->swSelection->layout()->addItem(footerLayout); + + QSpacerItem *closeButtonSpacer = new QSpacerItem(0, 0, QSizePolicy::Expanding, QSizePolicy::Minimum); + footerLayout->addSpacerItem(closeButtonSpacer); + + QPushButton *cmdClose = new QPushButton(tr("Close"), ui->swSelection); + cmdClose->setObjectName("cmdClose"); + cmdClose->setAutoDefault(true); + footerLayout->addWidget(cmdClose); + + QObject::connect(cmdClose, SIGNAL(clicked(bool)), this, SLOT(close())); +} + +void UserInterface::on_profileButton_clicked() +{ + QPushButton *profileBtn = (QPushButton*)sender(); + openProfile(profileBtn->objectName()); +} + void UserInterface::openProfile(QString profileName) { profileOpen = true; - profileUI = new ProfileInterface(profileDB, crewDB); + profileUI = new ProfileInterface(profileDB, crewDB, threadDB); ui->swProfile->addWidget(profileUI); ui->swProfile->setCurrentWidget(profileUI); profileUI->setProfileFolder(GTAV_ProfilesFolder + "/" + profileName, profileName); @@ -123,3 +163,14 @@ void UserInterface::on_actionExit_triggered() { this->close(); } + +void UserInterface::on_actionSelect_profile_triggered() +{ + closeProfile(); + openSelectProfile(); +} + +void UserInterface::openSelectProfile() +{ + // not needed right now +} diff --git a/UserInterface.h b/UserInterface.h index cef0990..6dfce56 100755 --- a/UserInterface.h +++ b/UserInterface.h @@ -21,6 +21,7 @@ #include "ProfileInterface.h" #include "ProfileDatabase.h" +#include "DatabaseThread.h" #include "CrewDatabase.h" #include #include @@ -34,22 +35,27 @@ class UserInterface : public QMainWindow { Q_OBJECT public: - explicit UserInterface(ProfileDatabase *profileDB, CrewDatabase *crewDB, QWidget *parent = 0); + explicit UserInterface(ProfileDatabase *profileDB, CrewDatabase *crewDB, DatabaseThread *threadDB, QWidget *parent = 0); ~UserInterface(); private slots: - void on_actionExit_triggered(); void closeProfile(); + void on_actionExit_triggered(); + void on_actionSelect_profile_triggered(); + void on_profileButton_clicked(); private: ProfileDatabase *profileDB; CrewDatabase *crewDB; + DatabaseThread *threadDB; Ui::UserInterface *ui; ProfileInterface *profileUI; bool profileOpen; QString GTAV_Folder; QString GTAV_ProfilesFolder; + void setupProfileUi(QStringList GTAV_Profiles); void openProfile(QString profileName); + void openSelectProfile(); }; #endif // USERINTERFACE_H diff --git a/UserInterface.ui b/UserInterface.ui index 7f03a70..1679842 100755 --- a/UserInterface.ui +++ b/UserInterface.ui @@ -38,7 +38,36 @@ 0 - + + + + + + Qt::Vertical + + + + 0 + 0 + + + + + + + + Select profile + + + Qt::AlignCenter + + + true + + + + + @@ -78,7 +107,7 @@ - Exit + Close Ctrl+Q diff --git a/gta5sync_de.qm b/gta5sync_de.qm index 09e4b1958c2123a542250dee2c4427e1f95b1f9a..e22c595c5a1650438fd8843085aa841ff660133f 100755 GIT binary patch delta 343 zcmdm|I7M-Sv=QeM29^t|3=F*e3@mR97#R2r7+B9AXJFv5V(>DX%D}+X3!yoFLuj5| z6Me-K_cJX>Fl1n04uQ~|rc95Pi7+s5KVw!ncNwU;fO)xHB?AMC1dR61w0#p>lS@hkA zfq}D+v(!ISZH1s>MJTZ{XS?Bg(+Qewpj66VPxDO|EYiia_yK+>G1m zfa24*_vIc1@)LNpH9k*vWRzeu-Wh((Wv4be1wOa5+F|?lhM3WmABb9Agz*F&(JyCu?IyG0+hq?Cej4fEpRt zxxSV#FtAp$=U;!sz%cQ)pzl1+r0FI=Bg#38z8f(xaBk*ob>0BvpXTh*GX*-0g=>e5 zC{W`MuCq=+D>?kQzF8*lC@_>UUczAS;a_6DY30pvqv#0dg1{5Q{qJ=ar=9l_=z= zDFhVdr)B1(DySMx&gGPvT*FZ@c^|*PW=GEJER%Qg@l1~8n=n~|PllDnwIZ`*G9#b( yS#%qHB diff --git a/gta5sync_de.ts b/gta5sync_de.ts index e517783..daec28c 100755 --- a/gta5sync_de.ts +++ b/gta5sync_de.ts @@ -89,7 +89,7 @@ Content of Profile %1 - Inhalt vom Profil %1 + Inhalt vom Profil %1 View @@ -100,6 +100,11 @@ Close Profile Profil schließen + + + Loading... + Lade... + SavegameDialog @@ -143,7 +148,7 @@ Kopieren - + Delete Löschen @@ -166,7 +171,7 @@ Ansehen - + Delete Löschen @@ -178,9 +183,8 @@ Grand Theft Auto V Sync - GTA V Sync - GTA V Sync + GTA V Sync @@ -188,49 +192,60 @@ gta5sync - %1 - + File Datei - + Help Hilfe - + About gta5sync Über gta5sync - + Ctrl+A Strg+A - - Exit + + + Close Schließen - + Exit + Schließen + + + Ctrl+Q Strg+Q - + + Select profile Profil auswählen - + Ctrl+P Strg+P - + GTA V Folder not found! GTA V Ordner nicht gefunden! + + + gta5sync + gta5sync + diff --git a/main.cpp b/main.cpp index a8c6ce7..251ab18 100755 --- a/main.cpp +++ b/main.cpp @@ -275,7 +275,7 @@ int main(int argc, char *argv[]) QObject::connect(threadDB, SIGNAL(playerNameFound(int, QString)), profileDB, SLOT(setPlayerName(int, QString))); threadDB->start(); - UserInterface *uiWindow = new UserInterface(profileDB, crewDB); + UserInterface *uiWindow = new UserInterface(profileDB, crewDB, threadDB); uiWindow->show(); return a.exec();