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 "SnapmaticWidget.h"
#include "SavegameWidget.h"
#include <QFileInfo>
#include <QRegExp>
#include <QDebug>
#include <QFile>
#include <QDir>
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;
}

View file

@ -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

View file

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

View file

@ -18,15 +18,29 @@
#include "SnapmaticWidget.h"
#include "ui_SnapmaticWidget.h"
#include "SnapmaticPicture.h"
#include <QPixmap>
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;
}

View file

@ -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

View file

@ -22,6 +22,7 @@
#include <QMessageBox>
#include <QSettings>
#include <QFileInfo>
#include <QDebug>
#include <QFile>
#include <QDir>
#include <QMap>
@ -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()