added loading progress frame
This commit is contained in:
parent
7d099291ad
commit
32f3c79071
5 changed files with 100 additions and 12 deletions
|
@ -33,7 +33,7 @@ ProfileInterface::ProfileInterface(ProfileDatabase *profileDB, CrewDatabase *cre
|
||||||
ui(new Ui::ProfileInterface)
|
ui(new Ui::ProfileInterface)
|
||||||
{
|
{
|
||||||
ui->setupUi(this);
|
ui->setupUi(this);
|
||||||
ui->labProfileContent->setVisible(false);
|
ui->saProfile->setVisible(false);
|
||||||
contentStr = ui->labProfileContent->text();
|
contentStr = ui->labProfileContent->text();
|
||||||
profileFolder = "";
|
profileFolder = "";
|
||||||
}
|
}
|
||||||
|
@ -51,11 +51,11 @@ void ProfileInterface::setProfileFolder(QString folder, QString profile)
|
||||||
|
|
||||||
void ProfileInterface::setupProfileInterface()
|
void ProfileInterface::setupProfileInterface()
|
||||||
{
|
{
|
||||||
ui->labProfileContent->setText(contentStr.arg(profileName));
|
|
||||||
|
|
||||||
ProfileLoader *profileLoader = new ProfileLoader(profileFolder, crewDB);
|
ProfileLoader *profileLoader = new ProfileLoader(profileFolder, crewDB);
|
||||||
QObject::connect(profileLoader, SIGNAL(savegameLoaded(SavegameData*, QString)), this, SLOT(on_savegameLoaded(SavegameData*, QString)));
|
QObject::connect(profileLoader, SIGNAL(savegameLoaded(SavegameData*, QString)), this, SLOT(on_savegameLoaded(SavegameData*, QString)));
|
||||||
QObject::connect(profileLoader, SIGNAL(pictureLoaded(SnapmaticPicture*, QString)), this, SLOT(on_pictureLoaded(SnapmaticPicture*, QString)));
|
QObject::connect(profileLoader, SIGNAL(pictureLoaded(SnapmaticPicture*, QString)), this, SLOT(on_pictureLoaded(SnapmaticPicture*, QString)));
|
||||||
|
QObject::connect(profileLoader, SIGNAL(loadingProgress(int,int)), this, SLOT(on_loadingProgress(int,int)));
|
||||||
|
QObject::connect(profileLoader, SIGNAL(finished()), this, SLOT(on_profileLoaded()));
|
||||||
profileLoader->start();
|
profileLoader->start();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -73,6 +73,23 @@ void ProfileInterface::on_pictureLoaded(SnapmaticPicture *picture, QString pictu
|
||||||
ui->vlSnapmatic->addWidget(picWidget);
|
ui->vlSnapmatic->addWidget(picWidget);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void ProfileInterface::on_loadingProgress(int value, int maximum)
|
||||||
|
{
|
||||||
|
ui->pbPictureLoading->setMaximum(maximum);
|
||||||
|
ui->pbPictureLoading->setValue(value);
|
||||||
|
ui->labProfileContent->setText(contentStr.arg(QString::number(value), QString::number(maximum)));
|
||||||
|
}
|
||||||
|
|
||||||
|
void ProfileInterface::on_profileLoaded()
|
||||||
|
{
|
||||||
|
QSpacerItem *saSpacerItem = new QSpacerItem(0, 0, QSizePolicy::Minimum, QSizePolicy::Expanding);
|
||||||
|
ui->saProfileContent->layout()->addItem(saSpacerItem);
|
||||||
|
ui->saProfile->setVisible(true);
|
||||||
|
ui->pbPictureLoading->setVisible(false);
|
||||||
|
ui->labProfileContent->setVisible(false);
|
||||||
|
ui->frmLoading->setVisible(false);
|
||||||
|
}
|
||||||
|
|
||||||
void ProfileInterface::on_cmdCloseProfile_clicked()
|
void ProfileInterface::on_cmdCloseProfile_clicked()
|
||||||
{
|
{
|
||||||
this->close();
|
this->close();
|
||||||
|
|
|
@ -42,6 +42,8 @@ private slots:
|
||||||
void on_cmdCloseProfile_clicked();
|
void on_cmdCloseProfile_clicked();
|
||||||
void on_pictureLoaded(SnapmaticPicture *picture, QString picturePath);
|
void on_pictureLoaded(SnapmaticPicture *picture, QString picturePath);
|
||||||
void on_savegameLoaded(SavegameData *savegame, QString savegamePath);
|
void on_savegameLoaded(SavegameData *savegame, QString savegamePath);
|
||||||
|
void on_loadingProgress(int value, int maximum);
|
||||||
|
void on_profileLoaded();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
ProfileDatabase *profileDB;
|
ProfileDatabase *profileDB;
|
||||||
|
|
|
@ -27,13 +27,70 @@
|
||||||
<number>0</number>
|
<number>0</number>
|
||||||
</property>
|
</property>
|
||||||
<item>
|
<item>
|
||||||
<widget class="QLabel" name="labProfileContent">
|
<widget class="QFrame" name="frmLoading">
|
||||||
<property name="text">
|
<property name="frameShape">
|
||||||
<string>Content of Profile %1</string>
|
<enum>QFrame::NoFrame</enum>
|
||||||
</property>
|
</property>
|
||||||
<property name="alignment">
|
<property name="frameShadow">
|
||||||
<set>Qt::AlignCenter</set>
|
<enum>QFrame::Plain</enum>
|
||||||
</property>
|
</property>
|
||||||
|
<property name="lineWidth">
|
||||||
|
<number>0</number>
|
||||||
|
</property>
|
||||||
|
<layout class="QVBoxLayout" name="vlLoading">
|
||||||
|
<property name="topMargin">
|
||||||
|
<number>0</number>
|
||||||
|
</property>
|
||||||
|
<property name="bottomMargin">
|
||||||
|
<number>0</number>
|
||||||
|
</property>
|
||||||
|
<item>
|
||||||
|
<spacer name="vsLoading2">
|
||||||
|
<property name="orientation">
|
||||||
|
<enum>Qt::Vertical</enum>
|
||||||
|
</property>
|
||||||
|
<property name="sizeHint" stdset="0">
|
||||||
|
<size>
|
||||||
|
<width>0</width>
|
||||||
|
<height>0</height>
|
||||||
|
</size>
|
||||||
|
</property>
|
||||||
|
</spacer>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QLabel" name="labProfileContent">
|
||||||
|
<property name="text">
|
||||||
|
<string>Loading %1 files of %2</string>
|
||||||
|
</property>
|
||||||
|
<property name="alignment">
|
||||||
|
<set>Qt::AlignCenter</set>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QProgressBar" name="pbPictureLoading">
|
||||||
|
<property name="value">
|
||||||
|
<number>0</number>
|
||||||
|
</property>
|
||||||
|
<property name="textVisible">
|
||||||
|
<bool>false</bool>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<spacer name="vsLoading1">
|
||||||
|
<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>
|
||||||
|
@ -47,7 +104,7 @@
|
||||||
<x>0</x>
|
<x>0</x>
|
||||||
<y>0</y>
|
<y>0</y>
|
||||||
<width>398</width>
|
<width>398</width>
|
||||||
<height>232</height>
|
<height>121</height>
|
||||||
</rect>
|
</rect>
|
||||||
</property>
|
</property>
|
||||||
<layout class="QVBoxLayout" name="vlProfile">
|
<layout class="QVBoxLayout" name="vlProfile">
|
||||||
|
|
|
@ -32,15 +32,25 @@ ProfileLoader::ProfileLoader(QString profileFolder, CrewDatabase *crewDB, QObjec
|
||||||
|
|
||||||
void ProfileLoader::run()
|
void ProfileLoader::run()
|
||||||
{
|
{
|
||||||
|
int loadedV = 0;
|
||||||
QDir profileDir;
|
QDir profileDir;
|
||||||
profileDir.setPath(profileFolder);
|
profileDir.setPath(profileFolder);
|
||||||
|
|
||||||
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);
|
||||||
QStringList BackupFiles = SavegameFiles.filter(".bak", Qt::CaseInsensitive);
|
QStringList BackupFiles = SavegameFiles.filter(".bak", Qt::CaseInsensitive);
|
||||||
|
profileDir.setNameFilters(QStringList("PGTA*"));
|
||||||
|
QStringList SnapmaticPics = profileDir.entryList(QDir::Files | QDir::NoDot, QDir::NoSort);
|
||||||
|
|
||||||
|
SavegameFiles.removeDuplicates();
|
||||||
|
SnapmaticPics.removeDuplicates();
|
||||||
foreach(const QString &BackupFile, BackupFiles)
|
foreach(const QString &BackupFile, BackupFiles)
|
||||||
{
|
{
|
||||||
SavegameFiles.removeAll(BackupFile);
|
SavegameFiles.removeAll(BackupFile);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int maximumV = SavegameFiles.length() + SnapmaticPics.length();
|
||||||
|
|
||||||
foreach(const QString &SavegameFile, SavegameFiles)
|
foreach(const QString &SavegameFile, SavegameFiles)
|
||||||
{
|
{
|
||||||
QString sgdPath = profileFolder + "/" + SavegameFile;
|
QString sgdPath = profileFolder + "/" + SavegameFile;
|
||||||
|
@ -49,10 +59,9 @@ void ProfileLoader::run()
|
||||||
{
|
{
|
||||||
emit savegameLoaded(savegame, sgdPath);
|
emit savegameLoaded(savegame, sgdPath);
|
||||||
}
|
}
|
||||||
|
loadedV++;
|
||||||
|
emit loadingProgress(loadedV, maximumV);
|
||||||
}
|
}
|
||||||
|
|
||||||
profileDir.setNameFilters(QStringList("PGTA*"));
|
|
||||||
QStringList SnapmaticPics = profileDir.entryList(QDir::Files | QDir::NoDot, QDir::NoSort);
|
|
||||||
foreach(const QString &SnapmaticPic, SnapmaticPics)
|
foreach(const QString &SnapmaticPic, SnapmaticPics)
|
||||||
{
|
{
|
||||||
QString picturePath = profileFolder + "/" + SnapmaticPic;
|
QString picturePath = profileFolder + "/" + SnapmaticPic;
|
||||||
|
@ -62,5 +71,7 @@ void ProfileLoader::run()
|
||||||
emit pictureLoaded(picture, picturePath);
|
emit pictureLoaded(picture, picturePath);
|
||||||
crewDB->addCrew(picture->getCrewNumber());
|
crewDB->addCrew(picture->getCrewNumber());
|
||||||
}
|
}
|
||||||
|
loadedV++;
|
||||||
|
emit loadingProgress(loadedV, maximumV);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -41,6 +41,7 @@ private:
|
||||||
signals:
|
signals:
|
||||||
void pictureLoaded(SnapmaticPicture *picture, QString picturePath);
|
void pictureLoaded(SnapmaticPicture *picture, QString picturePath);
|
||||||
void savegameLoaded(SavegameData *savegame, QString savegamePath);
|
void savegameLoaded(SavegameData *savegame, QString savegamePath);
|
||||||
|
void loadingProgress(int value, int maximum);
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // PROFILELOADER_H
|
#endif // PROFILELOADER_H
|
||||||
|
|
Loading…
Reference in a new issue