some progress at the UI

This commit is contained in:
Rafael 2016-03-26 08:53:37 +01:00
parent a608702e69
commit 5ac9276193
6 changed files with 68 additions and 27 deletions

View file

@ -20,6 +20,10 @@
#include "ui_ProfileInterface.h" #include "ui_ProfileInterface.h"
#include "SnapmaticWidget.h" #include "SnapmaticWidget.h"
#include "SavegameWidget.h" #include "SavegameWidget.h"
#include <QFileInfo>
#include <QRegExp>
#include <QDebug>
#include <QFile>
#include <QDir> #include <QDir>
ProfileInterface::ProfileInterface(QWidget *parent) : ProfileInterface::ProfileInterface(QWidget *parent) :
@ -27,6 +31,7 @@ ProfileInterface::ProfileInterface(QWidget *parent) :
ui(new Ui::ProfileInterface) ui(new Ui::ProfileInterface)
{ {
ui->setupUi(this); ui->setupUi(this);
contentStr = ui->labProfileContent->text();
profileFolder = ""; profileFolder = "";
} }
@ -35,8 +40,33 @@ ProfileInterface::~ProfileInterface()
delete ui; delete ui;
} }
void ProfileInterface::setProfileFolder(QString folder) void ProfileInterface::setProfileFolder(QString folder, QString profile)
{ {
profileFolder = folder; 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;
} }

View file

@ -30,12 +30,15 @@ class ProfileInterface : public QWidget
Q_OBJECT Q_OBJECT
public: public:
explicit ProfileInterface(QWidget *parent = 0); explicit ProfileInterface(QWidget *parent = 0);
void setProfileFolder(QString folder); void setProfileFolder(QString folder, QString profile);
void setupProfileInterface();
~ProfileInterface(); ~ProfileInterface();
private: private:
Ui::ProfileInterface *ui; Ui::ProfileInterface *ui;
QString profileFolder; QString profileFolder;
QString profileName;
QString contentStr;
}; };
#endif // PROFILEINTERFACE_H #endif // PROFILEINTERFACE_H

View file

@ -49,7 +49,7 @@
<height>300</height> <height>300</height>
</rect> </rect>
</property> </property>
<layout class="QVBoxLayout" name="verticalLayout"> <layout class="QVBoxLayout" name="vlSnapmaticContent">
<item> <item>
<widget class="QLabel" name="labProfileContent"> <widget class="QLabel" name="labProfileContent">
<property name="text"> <property name="text">
@ -60,19 +60,6 @@
</property> </property>
</widget> </widget>
</item> </item>
<item>
<spacer name="vsContent">
<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> </layout>
</widget> </widget>
</widget> </widget>

View file

@ -18,15 +18,29 @@
#include "SnapmaticWidget.h" #include "SnapmaticWidget.h"
#include "ui_SnapmaticWidget.h" #include "ui_SnapmaticWidget.h"
#include "SnapmaticPicture.h"
#include <QPixmap>
SnapmaticWidget::SnapmaticWidget(QWidget *parent) : SnapmaticWidget::SnapmaticWidget(QWidget *parent) :
QWidget(parent), QWidget(parent),
ui(new Ui::SnapmaticWidget) ui(new Ui::SnapmaticWidget)
{ {
ui->setupUi(this); ui->setupUi(this);
picPath = "";
smpic = 0;
} }
SnapmaticWidget::~SnapmaticWidget() SnapmaticWidget::~SnapmaticWidget()
{ {
delete ui; 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;
}

View file

@ -32,11 +32,13 @@ class SnapmaticWidget : public QWidget
public: public:
explicit SnapmaticWidget(QWidget *parent = 0); explicit SnapmaticWidget(QWidget *parent = 0);
void setSnapmaticPicture(SnapmaticPicture *picutre, QString picturePath); void setSnapmaticPicture(SnapmaticPicture *picture, QString picturePath);
~SnapmaticWidget(); ~SnapmaticWidget();
private: private:
Ui::SnapmaticWidget *ui; Ui::SnapmaticWidget *ui;
SnapmaticPicture *smpic;
QString picPath;
}; };
#endif // SNAPMATICWIDGET_H #endif // SNAPMATICWIDGET_H

View file

@ -22,6 +22,7 @@
#include <QMessageBox> #include <QMessageBox>
#include <QSettings> #include <QSettings>
#include <QFileInfo> #include <QFileInfo>
#include <QDebug>
#include <QFile> #include <QFile>
#include <QDir> #include <QDir>
#include <QMap> #include <QMap>
@ -45,9 +46,9 @@ UserInterface::UserInterface(QWidget *parent) :
// init folder // init folder
#ifdef QT5_MODE #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 #else
QString GTAV_defaultFolder = QDesktopServices::storageLocation(QDesktopServices::DocumentsLocation) + "\\Rockstar Games\\GTA V"; QString GTAV_defaultFolder = QDesktopServices::storageLocation(QDesktopServices::DocumentsLocation) + "/Rockstar Games/GTA V";
#endif #endif
QDir GTAV_Dir; QDir GTAV_Dir;
if (forceDir) if (forceDir)
@ -70,16 +71,20 @@ UserInterface::UserInterface(QWidget *parent) :
// profiles init // profiles init
QDir GTAV_ProfilesDir; QDir GTAV_ProfilesDir;
GTAV_ProfilesFolder = GTAV_Folder + "\\Profiles"; GTAV_ProfilesFolder = GTAV_Folder + "/Profiles";
GTAV_ProfilesDir.setPath(GTAV_ProfilesFolder); GTAV_ProfilesDir.setPath(GTAV_ProfilesFolder);
QStringList GTAV_Profiles = GTAV_ProfilesDir.entryList(QDir::NoFilter, QDir::NoSort); QStringList GTAV_Profiles = GTAV_ProfilesDir.entryList(QDir::Dirs | QDir::NoDotAndDotDot, QDir::NoSort);
GTAV_Profiles.removeAll("..");
GTAV_Profiles.removeAll(".");
ProfileInterface *profile1 = new ProfileInterface(); if (GTAV_Profiles.length() >= 1)
ui->swProfile->addWidget(profile1); {
ui->swProfile->setCurrentWidget(profile1); 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() UserInterface::~UserInterface()