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->setupUi(this); | ||||
|     ui->labProfileContent->setVisible(false); | ||||
|     ui->saProfile->setVisible(false); | ||||
|     contentStr = ui->labProfileContent->text(); | ||||
|     profileFolder = ""; | ||||
| } | ||||
|  | @ -51,11 +51,11 @@ void ProfileInterface::setProfileFolder(QString folder, QString profile) | |||
| 
 | ||||
| void ProfileInterface::setupProfileInterface() | ||||
| { | ||||
|     ui->labProfileContent->setText(contentStr.arg(profileName)); | ||||
| 
 | ||||
|     ProfileLoader *profileLoader = new ProfileLoader(profileFolder, crewDB); | ||||
|     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(loadingProgress(int,int)), this, SLOT(on_loadingProgress(int,int))); | ||||
|     QObject::connect(profileLoader, SIGNAL(finished()), this, SLOT(on_profileLoaded())); | ||||
|     profileLoader->start(); | ||||
| } | ||||
| 
 | ||||
|  | @ -73,6 +73,23 @@ void ProfileInterface::on_pictureLoaded(SnapmaticPicture *picture, QString pictu | |||
|     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() | ||||
| { | ||||
|     this->close(); | ||||
|  |  | |||
|  | @ -42,6 +42,8 @@ private slots: | |||
|     void on_cmdCloseProfile_clicked(); | ||||
|     void on_pictureLoaded(SnapmaticPicture *picture, QString picturePath); | ||||
|     void on_savegameLoaded(SavegameData *savegame, QString savegamePath); | ||||
|     void on_loadingProgress(int value, int maximum); | ||||
|     void on_profileLoaded(); | ||||
| 
 | ||||
| private: | ||||
|     ProfileDatabase *profileDB; | ||||
|  |  | |||
|  | @ -27,13 +27,70 @@ | |||
|     <number>0</number> | ||||
|    </property> | ||||
|    <item> | ||||
|     <widget class="QLabel" name="labProfileContent"> | ||||
|      <property name="text"> | ||||
|       <string>Content of Profile %1</string> | ||||
|     <widget class="QFrame" name="frmLoading"> | ||||
|      <property name="frameShape"> | ||||
|       <enum>QFrame::NoFrame</enum> | ||||
|      </property> | ||||
|      <property name="alignment"> | ||||
|       <set>Qt::AlignCenter</set> | ||||
|      <property name="frameShadow"> | ||||
|       <enum>QFrame::Plain</enum> | ||||
|      </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> | ||||
|    </item> | ||||
|    <item> | ||||
|  | @ -47,7 +104,7 @@ | |||
|         <x>0</x> | ||||
|         <y>0</y> | ||||
|         <width>398</width> | ||||
|         <height>232</height> | ||||
|         <height>121</height> | ||||
|        </rect> | ||||
|       </property> | ||||
|       <layout class="QVBoxLayout" name="vlProfile"> | ||||
|  |  | |||
|  | @ -32,15 +32,25 @@ ProfileLoader::ProfileLoader(QString profileFolder, CrewDatabase *crewDB, QObjec | |||
| 
 | ||||
| void ProfileLoader::run() | ||||
| { | ||||
|     int loadedV = 0; | ||||
|     QDir profileDir; | ||||
|     profileDir.setPath(profileFolder); | ||||
| 
 | ||||
|     profileDir.setNameFilters(QStringList("SGTA*")); | ||||
|     QStringList SavegameFiles = profileDir.entryList(QDir::Files | QDir::NoDot, QDir::NoSort); | ||||
|     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) | ||||
|     { | ||||
|         SavegameFiles.removeAll(BackupFile); | ||||
|     } | ||||
| 
 | ||||
|     int maximumV = SavegameFiles.length() + SnapmaticPics.length(); | ||||
| 
 | ||||
|     foreach(const QString &SavegameFile, SavegameFiles) | ||||
|     { | ||||
|         QString sgdPath = profileFolder + "/" + SavegameFile; | ||||
|  | @ -49,10 +59,9 @@ void ProfileLoader::run() | |||
|         { | ||||
|             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) | ||||
|     { | ||||
|         QString picturePath = profileFolder + "/" + SnapmaticPic; | ||||
|  | @ -62,5 +71,7 @@ void ProfileLoader::run() | |||
|             emit pictureLoaded(picture, picturePath); | ||||
|             crewDB->addCrew(picture->getCrewNumber()); | ||||
|         } | ||||
|         loadedV++; | ||||
|         emit loadingProgress(loadedV, maximumV); | ||||
|     } | ||||
| } | ||||
|  |  | |||
|  | @ -41,6 +41,7 @@ private: | |||
| signals: | ||||
|     void pictureLoaded(SnapmaticPicture *picture, QString picturePath); | ||||
|     void savegameLoaded(SavegameData *savegame, QString savegamePath); | ||||
|     void loadingProgress(int value, int maximum); | ||||
| }; | ||||
| 
 | ||||
| #endif // PROFILELOADER_H
 | ||||
|  |  | |||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue