From 5ac92761937d2f998c94f90164d550f0acde6f1e Mon Sep 17 00:00:00 2001 From: Rafael Date: Sat, 26 Mar 2016 08:53:37 +0100 Subject: [PATCH] some progress at the UI --- ProfileInterface.cpp | 34 ++++++++++++++++++++++++++++++++-- ProfileInterface.h | 5 ++++- ProfileInterface.ui | 15 +-------------- SnapmaticWidget.cpp | 14 ++++++++++++++ SnapmaticWidget.h | 4 +++- UserInterface.cpp | 23 ++++++++++++++--------- 6 files changed, 68 insertions(+), 27 deletions(-) diff --git a/ProfileInterface.cpp b/ProfileInterface.cpp index 8cb3cb0..73cffe2 100755 --- a/ProfileInterface.cpp +++ b/ProfileInterface.cpp @@ -20,6 +20,10 @@ #include "ui_ProfileInterface.h" #include "SnapmaticWidget.h" #include "SavegameWidget.h" +#include +#include +#include +#include #include ProfileInterface::ProfileInterface(QWidget *parent) : @@ -27,6 +31,7 @@ ProfileInterface::ProfileInterface(QWidget *parent) : ui(new Ui::ProfileInterface) { ui->setupUi(this); + contentStr = ui->labProfileContent->text(); profileFolder = ""; } @@ -35,8 +40,33 @@ ProfileInterface::~ProfileInterface() delete ui; } -void ProfileInterface::setProfileFolder(QString folder) +void ProfileInterface::setProfileFolder(QString folder, QString profile) { profileFolder = folder; - + profileName = profile; +} + +void ProfileInterface::setupProfileInterface() +{ + QDir profileDir; + profileDir.setPath(profileFolder); + ui->labProfileContent->setText(contentStr.arg(profileName)); + + profileDir.setNameFilters(QStringList("PGTA*")); + QStringList SnapmaticPics = profileDir.entryList(QDir::Files | QDir::NoDot, QDir::NoSort); + foreach(const QString &SnapmaticPic, SnapmaticPics) + { + QString picturePath = profileFolder + "/" + SnapmaticPic; + SnapmaticPicture *picture = new SnapmaticPicture(picturePath); + if (picture->readingPicture()) + { + SnapmaticWidget *picWidget = new SnapmaticWidget(ui->saSnapmaticContent); + picWidget->setSnapmaticPicture(picture, picturePath); + ui->saSnapmaticContent->layout()->addWidget(picWidget); + } + } + + profileDir.setNameFilters(QStringList("SGTA*")); + QStringList SavegameFiles = profileDir.entryList(QDir::Files | QDir::NoDot, QDir::NoSort); + qDebug() << SavegameFiles; } diff --git a/ProfileInterface.h b/ProfileInterface.h index 9bdafbf..7aa7202 100755 --- a/ProfileInterface.h +++ b/ProfileInterface.h @@ -30,12 +30,15 @@ class ProfileInterface : public QWidget Q_OBJECT public: explicit ProfileInterface(QWidget *parent = 0); - void setProfileFolder(QString folder); + void setProfileFolder(QString folder, QString profile); + void setupProfileInterface(); ~ProfileInterface(); private: Ui::ProfileInterface *ui; QString profileFolder; + QString profileName; + QString contentStr; }; #endif // PROFILEINTERFACE_H diff --git a/ProfileInterface.ui b/ProfileInterface.ui index ee55804..c8b17b9 100755 --- a/ProfileInterface.ui +++ b/ProfileInterface.ui @@ -49,7 +49,7 @@ 300 - + @@ -60,19 +60,6 @@ - - - - Qt::Vertical - - - - 0 - 0 - - - - diff --git a/SnapmaticWidget.cpp b/SnapmaticWidget.cpp index c8503ad..03f0e00 100755 --- a/SnapmaticWidget.cpp +++ b/SnapmaticWidget.cpp @@ -18,15 +18,29 @@ #include "SnapmaticWidget.h" #include "ui_SnapmaticWidget.h" +#include "SnapmaticPicture.h" +#include SnapmaticWidget::SnapmaticWidget(QWidget *parent) : QWidget(parent), ui(new Ui::SnapmaticWidget) { ui->setupUi(this); + picPath = ""; + smpic = 0; } SnapmaticWidget::~SnapmaticWidget() { delete ui; } + +void SnapmaticWidget::setSnapmaticPicture(SnapmaticPicture *picture, QString picturePath) +{ + QPixmap SnapmaticPixmap = picture->getPixmap(); + SnapmaticPixmap.scaled(ui->labPicture->width(), ui->labPicture->height(), Qt::KeepAspectRatio, Qt::SmoothTransformation); + ui->labPicStr->setText(picture->getPictureStr()); + ui->labPicture->setPixmap(SnapmaticPixmap); + smpic = picture; + picPath = picturePath; +} diff --git a/SnapmaticWidget.h b/SnapmaticWidget.h index eac8ea6..6ccd7d0 100755 --- a/SnapmaticWidget.h +++ b/SnapmaticWidget.h @@ -32,11 +32,13 @@ class SnapmaticWidget : public QWidget public: explicit SnapmaticWidget(QWidget *parent = 0); - void setSnapmaticPicture(SnapmaticPicture *picutre, QString picturePath); + void setSnapmaticPicture(SnapmaticPicture *picture, QString picturePath); ~SnapmaticWidget(); private: Ui::SnapmaticWidget *ui; + SnapmaticPicture *smpic; + QString picPath; }; #endif // SNAPMATICWIDGET_H diff --git a/UserInterface.cpp b/UserInterface.cpp index c1becde..f724af6 100755 --- a/UserInterface.cpp +++ b/UserInterface.cpp @@ -22,6 +22,7 @@ #include #include #include +#include #include #include #include @@ -45,9 +46,9 @@ UserInterface::UserInterface(QWidget *parent) : // init folder #ifdef QT5_MODE - QString GTAV_defaultFolder = QStandardPaths::writableLocation(QStandardPaths::DocumentsLocation) + "\\Rockstar Games\\GTA V"; + QString GTAV_defaultFolder = QStandardPaths::writableLocation(QStandardPaths::DocumentsLocation) + "/Rockstar Games/GTA V"; #else - QString GTAV_defaultFolder = QDesktopServices::storageLocation(QDesktopServices::DocumentsLocation) + "\\Rockstar Games\\GTA V"; + QString GTAV_defaultFolder = QDesktopServices::storageLocation(QDesktopServices::DocumentsLocation) + "/Rockstar Games/GTA V"; #endif QDir GTAV_Dir; if (forceDir) @@ -70,16 +71,20 @@ UserInterface::UserInterface(QWidget *parent) : // profiles init QDir GTAV_ProfilesDir; - GTAV_ProfilesFolder = GTAV_Folder + "\\Profiles"; + GTAV_ProfilesFolder = GTAV_Folder + "/Profiles"; GTAV_ProfilesDir.setPath(GTAV_ProfilesFolder); - QStringList GTAV_Profiles = GTAV_ProfilesDir.entryList(QDir::NoFilter, QDir::NoSort); - GTAV_Profiles.removeAll(".."); - GTAV_Profiles.removeAll("."); + QStringList GTAV_Profiles = GTAV_ProfilesDir.entryList(QDir::Dirs | QDir::NoDotAndDotDot, QDir::NoSort); - ProfileInterface *profile1 = new ProfileInterface(); - ui->swProfile->addWidget(profile1); - ui->swProfile->setCurrentWidget(profile1); + if (GTAV_Profiles.length() >= 1) + { + QString profileName = GTAV_Profiles.at(0); + ProfileInterface *profile1 = new ProfileInterface(); + ui->swProfile->addWidget(profile1); + ui->swProfile->setCurrentWidget(profile1); + profile1->setProfileFolder(GTAV_ProfilesFolder + "/" + profileName, profileName); + profile1->setupProfileInterface(); + } } UserInterface::~UserInterface()