clean RAM after use profile, button focus fixed

This commit is contained in:
Rafael 2016-03-27 13:19:50 +02:00
parent 6e165de9e2
commit fc37a5963c
7 changed files with 72 additions and 10 deletions

View file

@ -40,6 +40,14 @@ ProfileInterface::ProfileInterface(ProfileDatabase *profileDB, CrewDatabase *cre
ProfileInterface::~ProfileInterface()
{
foreach(SavegameData *savegame, savegames)
{
delete savegame;
}
foreach(SnapmaticPicture *picture, pictures)
{
delete picture;
}
delete ui;
}
@ -64,6 +72,7 @@ void ProfileInterface::on_savegameLoaded(SavegameData *savegame, QString savegam
SavegameWidget *sgdWidget = new SavegameWidget();
sgdWidget->setSavegameData(savegame, savegamePath);
ui->vlSavegame->addWidget(sgdWidget);
savegames.append(savegame);
}
void ProfileInterface::on_pictureLoaded(SnapmaticPicture *picture, QString picturePath)
@ -71,6 +80,7 @@ void ProfileInterface::on_pictureLoaded(SnapmaticPicture *picture, QString pictu
SnapmaticWidget *picWidget = new SnapmaticWidget(profileDB);
picWidget->setSnapmaticPicture(picture, picturePath);
ui->vlSnapmatic->addWidget(picWidget);
pictures.append(picture);
}
void ProfileInterface::on_loadingProgress(int value, int maximum)
@ -90,5 +100,5 @@ void ProfileInterface::on_profileLoaded()
void ProfileInterface::on_cmdCloseProfile_clicked()
{
this->close();
emit profileClosed();
}

View file

@ -24,6 +24,7 @@
#include "SavegameData.h"
#include "CrewDatabase.h"
#include <QWidget>
#include <QList>
namespace Ui {
class ProfileInterface;
@ -52,6 +53,11 @@ private:
QString profileFolder;
QString profileName;
QString loadingStr;
QList<SavegameData*> savegames;
QList<SnapmaticPicture*> pictures;
signals:
void profileClosed();
};
#endif // PROFILEINTERFACE_H

View file

@ -172,6 +172,9 @@
<property name="text">
<string>Close Profile</string>
</property>
<property name="autoDefault">
<bool>true</bool>
</property>
</widget>
</item>
</layout>

View file

@ -45,6 +45,9 @@
<property name="text">
<string>Copy</string>
</property>
<property name="autoDefault">
<bool>true</bool>
</property>
</widget>
</item>
<item>
@ -52,6 +55,9 @@
<property name="text">
<string>Delete</string>
</property>
<property name="autoDefault">
<bool>true</bool>
</property>
</widget>
</item>
</layout>

View file

@ -60,6 +60,9 @@
<property name="text">
<string>View</string>
</property>
<property name="autoDefault">
<bool>true</bool>
</property>
</widget>
</item>
<item>
@ -67,6 +70,9 @@
<property name="text">
<string>Delete</string>
</property>
<property name="autoDefault">
<bool>true</bool>
</property>
</widget>
</item>
</layout>

View file

@ -38,6 +38,8 @@ UserInterface::UserInterface(ProfileDatabase *profileDB, CrewDatabase *crewDB, Q
ui(new Ui::UserInterface)
{
ui->setupUi(this);
profileOpen = 0;
profileUI = 0;
// init settings
QSettings SyncSettings("Syping", "gta5sync");
@ -66,24 +68,49 @@ UserInterface::UserInterface(ProfileDatabase *profileDB, CrewDatabase *crewDB, Q
}
else
{
QMessageBox::warning(this, tr("GTA V Sync"), tr("GTA V Folder not found!"));
QMessageBox::warning(this, tr("gta5sync"), tr("GTA V Folder not found!"));
}
SyncSettings.endGroup();
// profiles init
SyncSettings.beginGroup("Profile");
QString defaultProfile = SyncSettings.value("Default", "").toString();
QDir GTAV_ProfilesDir;
GTAV_ProfilesFolder = GTAV_Folder + "/Profiles";
GTAV_ProfilesDir.setPath(GTAV_ProfilesFolder);
QStringList GTAV_Profiles = GTAV_ProfilesDir.entryList(QDir::Dirs | QDir::NoDotAndDotDot, QDir::NoSort);
if (GTAV_Profiles.length() >= 1)
if (GTAV_Profiles.length() == 1)
{
QString profileName = GTAV_Profiles.at(0);
ProfileInterface *profile1 = new ProfileInterface(profileDB, crewDB);
ui->swProfile->addWidget(profile1);
ui->swProfile->setCurrentWidget(profile1);
profile1->setProfileFolder(GTAV_ProfilesFolder + "/" + profileName, profileName);
profile1->setupProfileInterface();
openProfile(GTAV_Profiles.at(0));
}
else if(GTAV_Profiles.contains(defaultProfile))
{
openProfile(defaultProfile);
}
SyncSettings.endGroup();
}
void UserInterface::openProfile(QString profileName)
{
profileOpen = true;
profileUI = new ProfileInterface(profileDB, crewDB);
ui->swProfile->addWidget(profileUI);
ui->swProfile->setCurrentWidget(profileUI);
profileUI->setProfileFolder(GTAV_ProfilesFolder + "/" + profileName, profileName);
profileUI->setupProfileInterface();
QObject::connect(profileUI, SIGNAL(profileClosed()), this, SLOT(closeProfile()));
}
void UserInterface::closeProfile()
{
if (profileOpen)
{
profileOpen = false;
ui->swProfile->removeWidget(profileUI);
profileUI->deleteLater();
delete profileUI;
}
}

View file

@ -19,6 +19,7 @@
#ifndef USERINTERFACE_H
#define USERINTERFACE_H
#include "ProfileInterface.h"
#include "ProfileDatabase.h"
#include "CrewDatabase.h"
#include <QMainWindow>
@ -38,14 +39,17 @@ public:
private slots:
void on_actionExit_triggered();
void closeProfile();
private:
ProfileDatabase *profileDB;
CrewDatabase *crewDB;
Ui::UserInterface *ui;
ProfileInterface *profileUI;
bool profileOpen;
QString GTAV_Folder;
QString GTAV_ProfilesFolder;
QMap<QString, QString> GTAV_ProfileMap;
void openProfile(QString profileName);
};
#endif // USERINTERFACE_H