|
@@ -20,6 +20,7 @@
|
|
|
#include <QFont>
|
|
|
#include <QFontDatabase>
|
|
|
#include <QNetworkAccessManager>
|
|
|
+#include <QWinTaskbarProgress>
|
|
|
|
|
|
#include <ui_statuswidget.h>
|
|
|
|
|
@@ -78,8 +79,14 @@ MainWindow::MainWindow(QWidget *parent)
|
|
|
window_height = default_window_height * window_scale_factor / 100;
|
|
|
resize(window_width, window_height);
|
|
|
|
|
|
- qDebug() << __FUNCTION__ << "Finished main frame initialisation";
|
|
|
show();
|
|
|
+
|
|
|
+ qDebug() << __FUNCTION__ << "Initializing taskbar icon and progress...";
|
|
|
+ _windows_taskbar_button = new QWinTaskbarButton(this);
|
|
|
+ _windows_taskbar_button->setWindow(windowHandle());
|
|
|
+
|
|
|
+ qDebug() << __FUNCTION__ << "Finished main frame initialisation";
|
|
|
+
|
|
|
}
|
|
|
|
|
|
MainWindow::~MainWindow()
|
|
@@ -268,11 +275,52 @@ void MainWindow::setupWindowBackgroundAndMask(QPixmap background)
|
|
|
}
|
|
|
|
|
|
|
|
|
+void MainWindow::onPatchDownloaderStarted() {
|
|
|
+ _windows_taskbar_button->progress()->setVisible(true);
|
|
|
+}
|
|
|
+
|
|
|
+void MainWindow::onPatchDownloaderFinished() {
|
|
|
+ _windows_taskbar_button->progress()->setVisible(false);
|
|
|
+}
|
|
|
+
|
|
|
+void MainWindow::onPatchDownloaderProgressChanged(Downloader::Status status) {
|
|
|
+ int download_percent = status.total_bytes > 0 ? status.downloaded_bytes * 100 / status.total_bytes : 100;
|
|
|
+ _windows_taskbar_button->progress()->setValue(download_percent);
|
|
|
+}
|
|
|
+
|
|
|
+void MainWindow::onPatchInstallerStarted() {
|
|
|
+ _windows_taskbar_button->progress()->setVisible(true);
|
|
|
+}
|
|
|
+
|
|
|
+void MainWindow::onPatchInstallerFinished() {
|
|
|
+ _windows_taskbar_button->progress()->setVisible(false);
|
|
|
+}
|
|
|
+
|
|
|
+void MainWindow::onPatchInstallerProgressChanged(PatchInstaller::Status status) {
|
|
|
+ int install_percent = status.total_parts > 0 ? status.finished_parts * 100 / status.total_parts : 100;
|
|
|
+ _windows_taskbar_button->progress()->setValue(install_percent);
|
|
|
+}
|
|
|
+
|
|
|
+void MainWindow::onPatchInstallerVideoProgressChanged(int finished_videos, int total_videos, Downloader::Status) {
|
|
|
+ int install_percent = total_videos > 0 ? finished_videos * 100 / total_videos : 100;
|
|
|
+ _windows_taskbar_button->progress()->setValue(install_percent);
|
|
|
+}
|
|
|
+
|
|
|
|
|
|
void MainWindow::makeConnections()
|
|
|
{
|
|
|
connect(&PatchInstaller::instance(), &PatchInstaller::started, this, [this](){show_warning_on_close = true;});
|
|
|
connect(&PatchInstaller::instance(), &PatchInstaller::finished, this, [this](){show_warning_on_close = false;});
|
|
|
+
|
|
|
+ connect(&PatchDownloader::instance(), &PatchDownloader::started, this, &MainWindow::onPatchDownloaderStarted);
|
|
|
+ connect(&PatchDownloader::instance(), &PatchDownloader::progressChanged, this, &MainWindow::onPatchDownloaderProgressChanged);
|
|
|
+ connect(&PatchDownloader::instance(), &PatchDownloader::finished, this, &MainWindow::onPatchDownloaderFinished);
|
|
|
+
|
|
|
+ connect(&PatchInstaller::instance(), &PatchInstaller::started, this, &MainWindow::onPatchInstallerStarted);
|
|
|
+ connect(&PatchInstaller::instance(), &PatchInstaller::progressChanged, this, &MainWindow::onPatchInstallerProgressChanged);
|
|
|
+ connect(&PatchInstaller::instance(), &PatchInstaller::finished, this, &MainWindow::onPatchInstallerFinished);
|
|
|
+
|
|
|
+ connect(&PatchInstaller::instance(), &PatchInstaller::videosDownloadProgressChanged, this, &MainWindow::onPatchInstallerVideoProgressChanged);
|
|
|
}
|
|
|
|
|
|
void MainWindow::setupMenuHoverWidget()
|