From dfa0428cc28c4b141ad469b5e633dd8f100b5915 Mon Sep 17 00:00:00 2001 From: Rafael Date: Sat, 26 Mar 2016 10:46:25 +0100 Subject: [PATCH] added pic open dialog at ui --- ProfileInterface.cpp | 24 +++++-- ProfileInterface.h | 9 ++- ProfileInterface.ui | 168 ++++++++++++++++--------------------------- SnapmaticWidget.cpp | 16 ++++- SnapmaticWidget.h | 9 ++- UserInterface.cpp | 6 +- UserInterface.h | 6 +- UserInterface.ui | 6 ++ main.cpp | 9 ++- 9 files changed, 132 insertions(+), 121 deletions(-) diff --git a/ProfileInterface.cpp b/ProfileInterface.cpp index c51aa67..b15f8b3 100755 --- a/ProfileInterface.cpp +++ b/ProfileInterface.cpp @@ -20,17 +20,19 @@ #include "ui_ProfileInterface.h" #include "SnapmaticWidget.h" #include "SavegameWidget.h" +#include #include #include #include #include #include -ProfileInterface::ProfileInterface(QWidget *parent) : - QWidget(parent), +ProfileInterface::ProfileInterface(ProfileDatabase *profileDB, CrewDatabase *crewDB, QWidget *parent) : + QWidget(parent), profileDB(profileDB), crewDB(crewDB), ui(new Ui::ProfileInterface) { ui->setupUi(this); + ui->labProfileContent->setVisible(false); contentStr = ui->labProfileContent->text(); profileFolder = ""; } @@ -60,11 +62,14 @@ void ProfileInterface::setupProfileInterface() SnapmaticPicture *picture = new SnapmaticPicture(picturePath); if (picture->readingPicture()) { - SnapmaticWidget *picWidget = new SnapmaticWidget(ui->saSnapmaticContent); + SnapmaticWidget *picWidget = new SnapmaticWidget(profileDB); picWidget->setSnapmaticPicture(picture, picturePath); - ui->saSnapmaticContent->layout()->addWidget(picWidget); + ui->vlSnapmatic->addWidget(picWidget); + crewDB->addCrew(picture->getCrewNumber()); } } + QSpacerItem *snapmaticSpacer = new QSpacerItem(0, 0, QSizePolicy::Minimum, QSizePolicy::Expanding); + ui->vlSnapmatic->addSpacerItem(snapmaticSpacer); profileDir.setNameFilters(QStringList("SGTA*")); QStringList SavegameFiles = profileDir.entryList(QDir::Files | QDir::NoDot, QDir::NoSort); @@ -74,9 +79,16 @@ void ProfileInterface::setupProfileInterface() SavegameData *savegame = new SavegameData(sgdPath); if (savegame->readingSavegame()) { - SavegameWidget *sgdWidget = new SavegameWidget(ui->saSavegameContent); + SavegameWidget *sgdWidget = new SavegameWidget(); sgdWidget->setSavegameData(savegame, sgdPath); - ui->saSavegameContent->layout()->addWidget(sgdWidget); + ui->vlSavegame->addWidget(sgdWidget); } } + QSpacerItem *savegameSpacer = new QSpacerItem(0, 0, QSizePolicy::Minimum, QSizePolicy::Expanding); + ui->vlSavegame->addSpacerItem(savegameSpacer); +} + +void ProfileInterface::on_cmdCloseProfile_clicked() +{ + this->close(); } diff --git a/ProfileInterface.h b/ProfileInterface.h index 7aa7202..2944412 100755 --- a/ProfileInterface.h +++ b/ProfileInterface.h @@ -19,6 +19,8 @@ #ifndef PROFILEINTERFACE_H #define PROFILEINTERFACE_H +#include "ProfileDatabase.h" +#include "CrewDatabase.h" #include namespace Ui { @@ -29,12 +31,17 @@ class ProfileInterface : public QWidget { Q_OBJECT public: - explicit ProfileInterface(QWidget *parent = 0); + explicit ProfileInterface(ProfileDatabase *profileDB, CrewDatabase *crewDB, QWidget *parent = 0); void setProfileFolder(QString folder, QString profile); void setupProfileInterface(); ~ProfileInterface(); +private slots: + void on_cmdCloseProfile_clicked(); + private: + ProfileDatabase *profileDB; + CrewDatabase *crewDB; Ui::ProfileInterface *ui; QString profileFolder; QString profileName; diff --git a/ProfileInterface.ui b/ProfileInterface.ui index 50d28c3..cbdc519 100755 --- a/ProfileInterface.ui +++ b/ProfileInterface.ui @@ -18,13 +18,13 @@ 0 - 9 + 0 0 - 9 + 0 @@ -37,123 +37,81 @@ - + + + true + + + + + 0 + 0 + 398 + 232 + + + + + 0 + + + 0 + + + 0 + + + 0 + + + + + + + + + + + + + + + + + + + 6 + - 0 + 9 - 0 + 9 - 0 + 9 - 0 + 9 - - - QFrame::NoFrame + + + Qt::Horizontal - - QFrame::Plain + + + 40 + 20 + - - true - - - - - 0 - 0 - 196 - 261 - - - - - 0 - - - 0 - - - 0 - - - 0 - - - 0 - - - - - Qt::Vertical - - - - 0 - 0 - - - - - - - + - - - QFrame::NoFrame + + + Close Profile - - QFrame::Plain - - - true - - - - - 0 - 0 - 196 - 261 - - - - - 0 - - - 0 - - - 0 - - - 0 - - - 0 - - - - - Qt::Vertical - - - - 0 - 0 - - - - - - diff --git a/SnapmaticWidget.cpp b/SnapmaticWidget.cpp index 03f0e00..9f9b706 100755 --- a/SnapmaticWidget.cpp +++ b/SnapmaticWidget.cpp @@ -19,10 +19,11 @@ #include "SnapmaticWidget.h" #include "ui_SnapmaticWidget.h" #include "SnapmaticPicture.h" +#include "PictureDialog.h" #include -SnapmaticWidget::SnapmaticWidget(QWidget *parent) : - QWidget(parent), +SnapmaticWidget::SnapmaticWidget(ProfileDatabase *profileDB, QWidget *parent) : + QWidget(parent), profileDB(profileDB), ui(new Ui::SnapmaticWidget) { ui->setupUi(this); @@ -44,3 +45,14 @@ void SnapmaticWidget::setSnapmaticPicture(SnapmaticPicture *picture, QString pic smpic = picture; picPath = picturePath; } + +void SnapmaticWidget::on_cmdView_clicked() +{ + PictureDialog *picDialog = new PictureDialog(profileDB, this); + picDialog->setWindowFlags(picDialog->windowFlags()^Qt::WindowContextHelpButtonHint); + picDialog->setSnapmaticPicture(smpic, true); + picDialog->setModal(true); + picDialog->show(); + picDialog->exec(); + picDialog->deleteLater(); +} diff --git a/SnapmaticWidget.h b/SnapmaticWidget.h index 6ccd7d0..906f6a3 100755 --- a/SnapmaticWidget.h +++ b/SnapmaticWidget.h @@ -19,8 +19,9 @@ #ifndef SNAPMATICWIDGET_H #define SNAPMATICWIDGET_H -#include #include "SnapmaticPicture.h" +#include "ProfileDatabase.h" +#include namespace Ui { class SnapmaticWidget; @@ -31,11 +32,15 @@ class SnapmaticWidget : public QWidget Q_OBJECT public: - explicit SnapmaticWidget(QWidget *parent = 0); + explicit SnapmaticWidget(ProfileDatabase *profileDB, QWidget *parent = 0); void setSnapmaticPicture(SnapmaticPicture *picture, QString picturePath); ~SnapmaticWidget(); +private slots: + void on_cmdView_clicked(); + private: + ProfileDatabase *profileDB; Ui::SnapmaticWidget *ui; SnapmaticPicture *smpic; QString picPath; diff --git a/UserInterface.cpp b/UserInterface.cpp index f724af6..838df56 100755 --- a/UserInterface.cpp +++ b/UserInterface.cpp @@ -33,8 +33,8 @@ #include #endif -UserInterface::UserInterface(QWidget *parent) : - QMainWindow(parent), +UserInterface::UserInterface(ProfileDatabase *profileDB, CrewDatabase *crewDB, QWidget *parent) : + QMainWindow(parent), profileDB(profileDB), crewDB(crewDB), ui(new Ui::UserInterface) { ui->setupUi(this); @@ -79,7 +79,7 @@ UserInterface::UserInterface(QWidget *parent) : if (GTAV_Profiles.length() >= 1) { QString profileName = GTAV_Profiles.at(0); - ProfileInterface *profile1 = new ProfileInterface(); + ProfileInterface *profile1 = new ProfileInterface(profileDB, crewDB); ui->swProfile->addWidget(profile1); ui->swProfile->setCurrentWidget(profile1); profile1->setProfileFolder(GTAV_ProfilesFolder + "/" + profileName, profileName); diff --git a/UserInterface.h b/UserInterface.h index 508dee2..c45bfbc 100755 --- a/UserInterface.h +++ b/UserInterface.h @@ -19,6 +19,8 @@ #ifndef USERINTERFACE_H #define USERINTERFACE_H +#include "ProfileDatabase.h" +#include "CrewDatabase.h" #include #include #include @@ -31,13 +33,15 @@ class UserInterface : public QMainWindow { Q_OBJECT public: - explicit UserInterface(QWidget *parent = 0); + explicit UserInterface(ProfileDatabase *profileDB, CrewDatabase *crewDB, QWidget *parent = 0); ~UserInterface(); private slots: void on_actionExit_triggered(); private: + ProfileDatabase *profileDB; + CrewDatabase *crewDB; Ui::UserInterface *ui; QString GTAV_Folder; QString GTAV_ProfilesFolder; diff --git a/UserInterface.ui b/UserInterface.ui index 1ed7b34..77d812a 100755 --- a/UserInterface.ui +++ b/UserInterface.ui @@ -10,6 +10,12 @@ 600 + + + 800 + 600 + + GTA V Sync diff --git a/main.cpp b/main.cpp index 3408827..81bb218 100755 --- a/main.cpp +++ b/main.cpp @@ -268,7 +268,14 @@ int main(int argc, char *argv[]) return a.exec(); } - UserInterface *uiWindow = new UserInterface(); + CrewDatabase *crewDB = new CrewDatabase(); + ProfileDatabase *profileDB = new ProfileDatabase(); + DatabaseThread *threadDB = new DatabaseThread(crewDB); + + QObject::connect(threadDB, SIGNAL(playerNameFound(int, QString)), profileDB, SLOT(setPlayerName(int, QString))); + threadDB->start(); + + UserInterface *uiWindow = new UserInterface(profileDB, crewDB); uiWindow->show(); return a.exec();