Browse Source

Merge pull request #3879 from Laserlicht/innoextract_process

progress of innoextract extraction
Ivan Savenko 1 year ago
parent
commit
021c0f035d

+ 11 - 9
launcher/firstLaunch/firstlaunch_moc.cpp

@@ -311,13 +311,9 @@ void FirstLaunchView::extractGogData()
 	if(fileBin.isEmpty())
 		return;
 
-	ui->pushButtonGogInstall->setText(tr("Installing... Please wait!"));
-	QPalette pal = ui->pushButtonGogInstall->palette();
-	pal.setColor(QPalette::Button, QColor(Qt::yellow));
-	ui->pushButtonGogInstall->setAutoFillBackground(true);
-	ui->pushButtonGogInstall->setPalette(pal);
-	ui->pushButtonGogInstall->update();
-	ui->pushButtonGogInstall->repaint();
+	ui->progressBarGog->setVisible(true);
+	ui->pushButtonGogInstall->setVisible(false);
+	setEnabled(false);
 
 	QTimer::singleShot(100, this, [this, fileExe, fileBin](){ // background to make sure FileDialog is closed...
 		QTemporaryDir dir;
@@ -340,14 +336,20 @@ void FirstLaunchView::extractGogData()
 			o.filenames.set_expand(true);
 
 			o.preserve_file_times = true; // also correctly closes file -> without it: on Windows the files are not written completly
+			
+			process_file(tmpFileExe.toStdString(), o, [this](float progress) {
+				ui->progressBarGog->setValue(progress * 100);
+				qApp->processEvents();
+			});
 
-			process_file(tmpFileExe.toStdString(), o);
+			ui->progressBarGog->setVisible(false);
+			ui->pushButtonGogInstall->setVisible(true);
+			setEnabled(true);
 
 			QStringList dirData = tempDir.entryList({"data"}, QDir::Filter::Dirs);
 			if(dirData.empty() || QDir(tempDir.filePath(dirData.front())).entryList({"*.lod"}, QDir::Filter::Files).empty())
 			{
 				QMessageBox::critical(this, tr("No Heroes III data!"), tr("Selected files do not contain Heroes III data!"), QMessageBox::Ok, QMessageBox::Ok);
-				ui->pushButtonGogInstall->setText(tr("Install gog.com files"));
 				return;
 			}
 			copyHeroesData(dir.path(), true);

+ 28 - 0
launcher/firstLaunch/firstlaunch_moc.ui

@@ -289,6 +289,34 @@ Heroes® of Might and Magic® III HD is currently not supported!</string>
            </property>
           </widget>
          </item>
+         <item row="4" column="3">
+          <widget class="QProgressBar" name="progressBarGog">
+            <property name="sizePolicy">
+             <sizepolicy hsizetype="Expanding" vsizetype="Minimum">
+              <horstretch>0</horstretch>
+              <verstretch>0</verstretch>
+             </sizepolicy>
+            </property>
+            <property name="maximum">
+             <number>100</number>
+            </property>
+            <property name="value">
+             <number>0</number>
+            </property>
+            <property name="textVisible">
+             <bool>true</bool>
+            </property>
+            <property name="invertedAppearance">
+             <bool>false</bool>
+            </property>
+            <property name="format">
+             <string>Installing... %p%</string>
+            </property>
+            <property name="visible">
+              <bool>false</bool>
+            </property>
+           </widget>
+         </item>
          <item row="2" column="3">
           <widget class="QPushButton" name="pushButtonDataSearch">
            <property name="sizePolicy">

+ 1 - 1
launcher/lib/innoextract

@@ -1 +1 @@
-Subproject commit 46adb5762331aa3f19113fe09c72fc2d37caf90c
+Subproject commit 9977089412ebafe9f79936aa65a2edf16a84ae3e