added pic open dialog at ui

This commit is contained in:
Rafael 2016-03-26 10:46:25 +01:00
parent 4aa2fd844e
commit dfa0428cc2
9 changed files with 132 additions and 121 deletions

View File

@ -20,17 +20,19 @@
#include "ui_ProfileInterface.h" #include "ui_ProfileInterface.h"
#include "SnapmaticWidget.h" #include "SnapmaticWidget.h"
#include "SavegameWidget.h" #include "SavegameWidget.h"
#include <QSpacerItem>
#include <QFileInfo> #include <QFileInfo>
#include <QRegExp> #include <QRegExp>
#include <QDebug> #include <QDebug>
#include <QFile> #include <QFile>
#include <QDir> #include <QDir>
ProfileInterface::ProfileInterface(QWidget *parent) : ProfileInterface::ProfileInterface(ProfileDatabase *profileDB, CrewDatabase *crewDB, QWidget *parent) :
QWidget(parent), QWidget(parent), profileDB(profileDB), crewDB(crewDB),
ui(new Ui::ProfileInterface) ui(new Ui::ProfileInterface)
{ {
ui->setupUi(this); ui->setupUi(this);
ui->labProfileContent->setVisible(false);
contentStr = ui->labProfileContent->text(); contentStr = ui->labProfileContent->text();
profileFolder = ""; profileFolder = "";
} }
@ -60,11 +62,14 @@ void ProfileInterface::setupProfileInterface()
SnapmaticPicture *picture = new SnapmaticPicture(picturePath); SnapmaticPicture *picture = new SnapmaticPicture(picturePath);
if (picture->readingPicture()) if (picture->readingPicture())
{ {
SnapmaticWidget *picWidget = new SnapmaticWidget(ui->saSnapmaticContent); SnapmaticWidget *picWidget = new SnapmaticWidget(profileDB);
picWidget->setSnapmaticPicture(picture, picturePath); 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*")); profileDir.setNameFilters(QStringList("SGTA*"));
QStringList SavegameFiles = profileDir.entryList(QDir::Files | QDir::NoDot, QDir::NoSort); QStringList SavegameFiles = profileDir.entryList(QDir::Files | QDir::NoDot, QDir::NoSort);
@ -74,9 +79,16 @@ void ProfileInterface::setupProfileInterface()
SavegameData *savegame = new SavegameData(sgdPath); SavegameData *savegame = new SavegameData(sgdPath);
if (savegame->readingSavegame()) if (savegame->readingSavegame())
{ {
SavegameWidget *sgdWidget = new SavegameWidget(ui->saSavegameContent); SavegameWidget *sgdWidget = new SavegameWidget();
sgdWidget->setSavegameData(savegame, sgdPath); 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();
} }

View File

@ -19,6 +19,8 @@
#ifndef PROFILEINTERFACE_H #ifndef PROFILEINTERFACE_H
#define PROFILEINTERFACE_H #define PROFILEINTERFACE_H
#include "ProfileDatabase.h"
#include "CrewDatabase.h"
#include <QWidget> #include <QWidget>
namespace Ui { namespace Ui {
@ -29,12 +31,17 @@ class ProfileInterface : public QWidget
{ {
Q_OBJECT Q_OBJECT
public: public:
explicit ProfileInterface(QWidget *parent = 0); explicit ProfileInterface(ProfileDatabase *profileDB, CrewDatabase *crewDB, QWidget *parent = 0);
void setProfileFolder(QString folder, QString profile); void setProfileFolder(QString folder, QString profile);
void setupProfileInterface(); void setupProfileInterface();
~ProfileInterface(); ~ProfileInterface();
private slots:
void on_cmdCloseProfile_clicked();
private: private:
ProfileDatabase *profileDB;
CrewDatabase *crewDB;
Ui::ProfileInterface *ui; Ui::ProfileInterface *ui;
QString profileFolder; QString profileFolder;
QString profileName; QString profileName;

View File

@ -18,13 +18,13 @@
<number>0</number> <number>0</number>
</property> </property>
<property name="topMargin"> <property name="topMargin">
<number>9</number> <number>0</number>
</property> </property>
<property name="rightMargin"> <property name="rightMargin">
<number>0</number> <number>0</number>
</property> </property>
<property name="bottomMargin"> <property name="bottomMargin">
<number>9</number> <number>0</number>
</property> </property>
<item> <item>
<widget class="QLabel" name="labProfileContent"> <widget class="QLabel" name="labProfileContent">
@ -37,123 +37,81 @@
</widget> </widget>
</item> </item>
<item> <item>
<layout class="QHBoxLayout" name="hlContent"> <widget class="QScrollArea" name="saProfile">
<property name="widgetResizable">
<bool>true</bool>
</property>
<widget class="QWidget" name="saProfileContent">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>398</width>
<height>232</height>
</rect>
</property>
<layout class="QVBoxLayout" name="vlProfile">
<property name="leftMargin">
<number>0</number>
</property>
<property name="topMargin">
<number>0</number>
</property>
<property name="rightMargin">
<number>0</number>
</property>
<property name="bottomMargin">
<number>0</number>
</property>
<item>
<layout class="QHBoxLayout" name="hlContent">
<item>
<layout class="QVBoxLayout" name="vlSnapmatic"/>
</item>
<item>
<layout class="QVBoxLayout" name="vlSavegame"/>
</item>
</layout>
</item>
</layout>
</widget>
</widget>
</item>
<item>
<layout class="QHBoxLayout" name="hlButtons">
<property name="spacing">
<number>6</number>
</property>
<property name="leftMargin"> <property name="leftMargin">
<number>0</number> <number>9</number>
</property> </property>
<property name="topMargin"> <property name="topMargin">
<number>0</number> <number>9</number>
</property> </property>
<property name="rightMargin"> <property name="rightMargin">
<number>0</number> <number>9</number>
</property> </property>
<property name="bottomMargin"> <property name="bottomMargin">
<number>0</number> <number>9</number>
</property> </property>
<item> <item>
<widget class="QScrollArea" name="saSnapmatic"> <spacer name="hsProfile">
<property name="frameShape"> <property name="orientation">
<enum>QFrame::NoFrame</enum> <enum>Qt::Horizontal</enum>
</property> </property>
<property name="frameShadow"> <property name="sizeHint" stdset="0">
<enum>QFrame::Plain</enum> <size>
<width>40</width>
<height>20</height>
</size>
</property> </property>
<property name="widgetResizable"> </spacer>
<bool>true</bool>
</property>
<widget class="QWidget" name="saSnapmaticContent">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>196</width>
<height>261</height>
</rect>
</property>
<layout class="QVBoxLayout" name="vlSnapmaticContent">
<property name="spacing">
<number>0</number>
</property>
<property name="leftMargin">
<number>0</number>
</property>
<property name="topMargin">
<number>0</number>
</property>
<property name="rightMargin">
<number>0</number>
</property>
<property name="bottomMargin">
<number>0</number>
</property>
<item>
<spacer name="vsSnapmatic">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>0</width>
<height>0</height>
</size>
</property>
</spacer>
</item>
</layout>
</widget>
</widget>
</item> </item>
<item> <item>
<widget class="QScrollArea" name="saSavegame"> <widget class="QPushButton" name="cmdCloseProfile">
<property name="frameShape"> <property name="text">
<enum>QFrame::NoFrame</enum> <string>Close Profile</string>
</property> </property>
<property name="frameShadow">
<enum>QFrame::Plain</enum>
</property>
<property name="widgetResizable">
<bool>true</bool>
</property>
<widget class="QWidget" name="saSavegameContent">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>196</width>
<height>261</height>
</rect>
</property>
<layout class="QVBoxLayout" name="vlSavegameContent">
<property name="spacing">
<number>0</number>
</property>
<property name="leftMargin">
<number>0</number>
</property>
<property name="topMargin">
<number>0</number>
</property>
<property name="rightMargin">
<number>0</number>
</property>
<property name="bottomMargin">
<number>0</number>
</property>
<item>
<spacer name="vsSavegame">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>0</width>
<height>0</height>
</size>
</property>
</spacer>
</item>
</layout>
</widget>
</widget> </widget>
</item> </item>
</layout> </layout>

View File

@ -19,10 +19,11 @@
#include "SnapmaticWidget.h" #include "SnapmaticWidget.h"
#include "ui_SnapmaticWidget.h" #include "ui_SnapmaticWidget.h"
#include "SnapmaticPicture.h" #include "SnapmaticPicture.h"
#include "PictureDialog.h"
#include <QPixmap> #include <QPixmap>
SnapmaticWidget::SnapmaticWidget(QWidget *parent) : SnapmaticWidget::SnapmaticWidget(ProfileDatabase *profileDB, QWidget *parent) :
QWidget(parent), QWidget(parent), profileDB(profileDB),
ui(new Ui::SnapmaticWidget) ui(new Ui::SnapmaticWidget)
{ {
ui->setupUi(this); ui->setupUi(this);
@ -44,3 +45,14 @@ void SnapmaticWidget::setSnapmaticPicture(SnapmaticPicture *picture, QString pic
smpic = picture; smpic = picture;
picPath = picturePath; 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();
}

View File

@ -19,8 +19,9 @@
#ifndef SNAPMATICWIDGET_H #ifndef SNAPMATICWIDGET_H
#define SNAPMATICWIDGET_H #define SNAPMATICWIDGET_H
#include <QWidget>
#include "SnapmaticPicture.h" #include "SnapmaticPicture.h"
#include "ProfileDatabase.h"
#include <QWidget>
namespace Ui { namespace Ui {
class SnapmaticWidget; class SnapmaticWidget;
@ -31,11 +32,15 @@ class SnapmaticWidget : public QWidget
Q_OBJECT Q_OBJECT
public: public:
explicit SnapmaticWidget(QWidget *parent = 0); explicit SnapmaticWidget(ProfileDatabase *profileDB, QWidget *parent = 0);
void setSnapmaticPicture(SnapmaticPicture *picture, QString picturePath); void setSnapmaticPicture(SnapmaticPicture *picture, QString picturePath);
~SnapmaticWidget(); ~SnapmaticWidget();
private slots:
void on_cmdView_clicked();
private: private:
ProfileDatabase *profileDB;
Ui::SnapmaticWidget *ui; Ui::SnapmaticWidget *ui;
SnapmaticPicture *smpic; SnapmaticPicture *smpic;
QString picPath; QString picPath;

View File

@ -33,8 +33,8 @@
#include <QDesktopServices> #include <QDesktopServices>
#endif #endif
UserInterface::UserInterface(QWidget *parent) : UserInterface::UserInterface(ProfileDatabase *profileDB, CrewDatabase *crewDB, QWidget *parent) :
QMainWindow(parent), QMainWindow(parent), profileDB(profileDB), crewDB(crewDB),
ui(new Ui::UserInterface) ui(new Ui::UserInterface)
{ {
ui->setupUi(this); ui->setupUi(this);
@ -79,7 +79,7 @@ UserInterface::UserInterface(QWidget *parent) :
if (GTAV_Profiles.length() >= 1) if (GTAV_Profiles.length() >= 1)
{ {
QString profileName = GTAV_Profiles.at(0); QString profileName = GTAV_Profiles.at(0);
ProfileInterface *profile1 = new ProfileInterface(); ProfileInterface *profile1 = new ProfileInterface(profileDB, crewDB);
ui->swProfile->addWidget(profile1); ui->swProfile->addWidget(profile1);
ui->swProfile->setCurrentWidget(profile1); ui->swProfile->setCurrentWidget(profile1);
profile1->setProfileFolder(GTAV_ProfilesFolder + "/" + profileName, profileName); profile1->setProfileFolder(GTAV_ProfilesFolder + "/" + profileName, profileName);

View File

@ -19,6 +19,8 @@
#ifndef USERINTERFACE_H #ifndef USERINTERFACE_H
#define USERINTERFACE_H #define USERINTERFACE_H
#include "ProfileDatabase.h"
#include "CrewDatabase.h"
#include <QMainWindow> #include <QMainWindow>
#include <QString> #include <QString>
#include <QMap> #include <QMap>
@ -31,13 +33,15 @@ class UserInterface : public QMainWindow
{ {
Q_OBJECT Q_OBJECT
public: public:
explicit UserInterface(QWidget *parent = 0); explicit UserInterface(ProfileDatabase *profileDB, CrewDatabase *crewDB, QWidget *parent = 0);
~UserInterface(); ~UserInterface();
private slots: private slots:
void on_actionExit_triggered(); void on_actionExit_triggered();
private: private:
ProfileDatabase *profileDB;
CrewDatabase *crewDB;
Ui::UserInterface *ui; Ui::UserInterface *ui;
QString GTAV_Folder; QString GTAV_Folder;
QString GTAV_ProfilesFolder; QString GTAV_ProfilesFolder;

View File

@ -10,6 +10,12 @@
<height>600</height> <height>600</height>
</rect> </rect>
</property> </property>
<property name="minimumSize">
<size>
<width>800</width>
<height>600</height>
</size>
</property>
<property name="windowTitle"> <property name="windowTitle">
<string>GTA V Sync</string> <string>GTA V Sync</string>
</property> </property>

View File

@ -268,7 +268,14 @@ int main(int argc, char *argv[])
return a.exec(); 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(); uiWindow->show();
return a.exec(); return a.exec();