mirror of
https://github.com/cmclark00/retro-imager.git
synced 2025-05-18 16:05:21 +01:00
Windows: show progress in taskbar
Windows: show progress in taskbar Closes #132 Implemented in ImageWriter class instead of qml for practical reasons. GUI stuff does not really belong there, but there is no easy way to have platform specific stuff in qml, lacking #ifdef
This commit is contained in:
parent
1e73123ca9
commit
1d0087929c
4 changed files with 65 additions and 11 deletions
|
@ -42,7 +42,8 @@ elseif (WIN32)
|
||||||
set(DEPENDENCIES acceleratedcryptographichash.cpp dependencies/mountutils/src/windows/functions.cpp dependencies/drivelist/src/windows/list.cpp
|
set(DEPENDENCIES acceleratedcryptographichash.cpp dependencies/mountutils/src/windows/functions.cpp dependencies/drivelist/src/windows/list.cpp
|
||||||
windows/winfile.cpp windows/winfile.h
|
windows/winfile.cpp windows/winfile.h
|
||||||
windows/rpi-imager.rc)
|
windows/rpi-imager.rc)
|
||||||
set(EXTRALIBS setupapi)
|
find_package(Qt5WinExtras REQUIRED)
|
||||||
|
set(EXTRALIBS setupapi Qt5::WinExtras)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
include_directories(BEFORE .)
|
include_directories(BEFORE .)
|
||||||
|
|
|
@ -34,6 +34,8 @@
|
||||||
#ifdef Q_OS_WIN
|
#ifdef Q_OS_WIN
|
||||||
#include <windows.h>
|
#include <windows.h>
|
||||||
#include <winioctl.h>
|
#include <winioctl.h>
|
||||||
|
#include <QWinTaskbarButton>
|
||||||
|
#include <QWinTaskbarProgress>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
ImageWriter::ImageWriter(QObject *parent)
|
ImageWriter::ImageWriter(QObject *parent)
|
||||||
|
@ -52,6 +54,7 @@ ImageWriter::ImageWriter(QObject *parent)
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef Q_OS_WIN
|
#ifdef Q_OS_WIN
|
||||||
|
_taskbarButton = nullptr;
|
||||||
QProcess *p = new QProcess(this);
|
QProcess *p = new QProcess(this);
|
||||||
p->start("net stop ShellHWDetection");
|
p->start("net stop ShellHWDetection");
|
||||||
#endif
|
#endif
|
||||||
|
@ -207,8 +210,6 @@ void ImageWriter::startWrite()
|
||||||
_thread->setInputBufferSize(IMAGEWRITER_UNCOMPRESSED_BLOCKSIZE);
|
_thread->setInputBufferSize(IMAGEWRITER_UNCOMPRESSED_BLOCKSIZE);
|
||||||
}
|
}
|
||||||
|
|
||||||
_powersave.applyBlock(tr("Downloading and writing image"));
|
|
||||||
|
|
||||||
connect(_thread, SIGNAL(success()), SLOT(onSuccess()));
|
connect(_thread, SIGNAL(success()), SLOT(onSuccess()));
|
||||||
connect(_thread, SIGNAL(error(QString)), SLOT(onError(QString)));
|
connect(_thread, SIGNAL(error(QString)), SLOT(onError(QString)));
|
||||||
connect(_thread, SIGNAL(finalizing()), SLOT(onFinalizing()));
|
connect(_thread, SIGNAL(finalizing()), SLOT(onFinalizing()));
|
||||||
|
@ -264,8 +265,7 @@ void ImageWriter::startWrite()
|
||||||
_thread->start();
|
_thread->start();
|
||||||
}
|
}
|
||||||
|
|
||||||
_dlnow = 0; _verifynow = 0;
|
startProgressPolling();
|
||||||
_polltimer.start(PROGRESS_UPDATE_INTERVAL);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void ImageWriter::onCacheFileUpdated(QByteArray sha256)
|
void ImageWriter::onCacheFileUpdated(QByteArray sha256)
|
||||||
|
@ -359,6 +359,41 @@ DriveListModel *ImageWriter::getDriveList()
|
||||||
return &_drivelist;
|
return &_drivelist;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void ImageWriter::startProgressPolling()
|
||||||
|
{
|
||||||
|
_powersave.applyBlock(tr("Downloading and writing image"));
|
||||||
|
#ifdef Q_OS_WIN
|
||||||
|
if (!_taskbarButton && _engine)
|
||||||
|
{
|
||||||
|
QWindow* window = qobject_cast<QWindow*>( _engine->rootObjects().at(0) );
|
||||||
|
if (window)
|
||||||
|
{
|
||||||
|
_taskbarButton = new QWinTaskbarButton(this);
|
||||||
|
_taskbarButton->setWindow(window);
|
||||||
|
_taskbarButton->progress()->setMaximum(0);
|
||||||
|
_taskbarButton->progress()->setVisible(true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
_dlnow = 0; _verifynow = 0;
|
||||||
|
_polltimer.start(PROGRESS_UPDATE_INTERVAL);
|
||||||
|
}
|
||||||
|
|
||||||
|
void ImageWriter::stopProgressPolling()
|
||||||
|
{
|
||||||
|
_polltimer.stop();
|
||||||
|
pollProgress();
|
||||||
|
#ifdef Q_OS_WIN
|
||||||
|
if (_taskbarButton)
|
||||||
|
{
|
||||||
|
_taskbarButton->progress()->setVisible(false);
|
||||||
|
_taskbarButton->deleteLater();
|
||||||
|
_taskbarButton = nullptr;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
_powersave.removeBlock();
|
||||||
|
}
|
||||||
|
|
||||||
void ImageWriter::pollProgress()
|
void ImageWriter::pollProgress()
|
||||||
{
|
{
|
||||||
if (!_thread)
|
if (!_thread)
|
||||||
|
@ -379,6 +414,13 @@ void ImageWriter::pollProgress()
|
||||||
if (newDlNow != _dlnow)
|
if (newDlNow != _dlnow)
|
||||||
{
|
{
|
||||||
_dlnow = newDlNow;
|
_dlnow = newDlNow;
|
||||||
|
#ifdef Q_OS_WIN
|
||||||
|
if (_taskbarButton)
|
||||||
|
{
|
||||||
|
_taskbarButton->progress()->setMaximum(dlTotal);
|
||||||
|
_taskbarButton->progress()->setValue(newDlNow);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
emit downloadProgress(newDlNow, dlTotal);
|
emit downloadProgress(newDlNow, dlTotal);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -388,6 +430,13 @@ void ImageWriter::pollProgress()
|
||||||
{
|
{
|
||||||
_verifynow = newVerifyNow;
|
_verifynow = newVerifyNow;
|
||||||
quint64 verifyTotal = _thread->verifyTotal();
|
quint64 verifyTotal = _thread->verifyTotal();
|
||||||
|
#ifdef Q_OS_WIN
|
||||||
|
if (_taskbarButton)
|
||||||
|
{
|
||||||
|
_taskbarButton->progress()->setMaximum(verifyTotal);
|
||||||
|
_taskbarButton->progress()->setValue(newVerifyNow);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
emit verifyProgress(newVerifyNow, verifyTotal);
|
emit verifyProgress(newVerifyNow, verifyTotal);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -402,17 +451,13 @@ void ImageWriter::setVerifyEnabled(bool verify)
|
||||||
/* Relay events from download thread to QML */
|
/* Relay events from download thread to QML */
|
||||||
void ImageWriter::onSuccess()
|
void ImageWriter::onSuccess()
|
||||||
{
|
{
|
||||||
_polltimer.stop();
|
stopProgressPolling();
|
||||||
pollProgress();
|
|
||||||
_powersave.removeBlock();
|
|
||||||
emit success();
|
emit success();
|
||||||
}
|
}
|
||||||
|
|
||||||
void ImageWriter::onError(QString msg)
|
void ImageWriter::onError(QString msg)
|
||||||
{
|
{
|
||||||
_polltimer.stop();
|
stopProgressPolling();
|
||||||
pollProgress();
|
|
||||||
_powersave.removeBlock();
|
|
||||||
emit error(msg);
|
emit error(msg);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -18,6 +18,7 @@
|
||||||
class QQmlApplicationEngine;
|
class QQmlApplicationEngine;
|
||||||
class DownloadThread;
|
class DownloadThread;
|
||||||
class QNetworkReply;
|
class QNetworkReply;
|
||||||
|
class QWinTaskbarButton;
|
||||||
|
|
||||||
class ImageWriter : public QObject
|
class ImageWriter : public QObject
|
||||||
{
|
{
|
||||||
|
@ -106,6 +107,8 @@ signals:
|
||||||
|
|
||||||
protected slots:
|
protected slots:
|
||||||
|
|
||||||
|
void startProgressPolling();
|
||||||
|
void stopProgressPolling();
|
||||||
void pollProgress();
|
void pollProgress();
|
||||||
void pollNetwork();
|
void pollNetwork();
|
||||||
void syncTime();
|
void syncTime();
|
||||||
|
@ -130,6 +133,9 @@ protected:
|
||||||
DownloadThread *_thread;
|
DownloadThread *_thread;
|
||||||
bool _verifyEnabled, _multipleFilesInZip, _cachingEnabled, _embeddedMode, _online;
|
bool _verifyEnabled, _multipleFilesInZip, _cachingEnabled, _embeddedMode, _online;
|
||||||
QSettings _settings;
|
QSettings _settings;
|
||||||
|
#ifdef Q_OS_WIN
|
||||||
|
QWinTaskbarButton *_taskbarButton;
|
||||||
|
#endif
|
||||||
|
|
||||||
void _parseCompressedFile();
|
void _parseCompressedFile();
|
||||||
};
|
};
|
||||||
|
|
|
@ -242,6 +242,7 @@ File "deploy\Qt5QuickControls2.dll"
|
||||||
File "deploy\Qt5QuickTemplates2.dll"
|
File "deploy\Qt5QuickTemplates2.dll"
|
||||||
File "deploy\Qt5Svg.dll"
|
File "deploy\Qt5Svg.dll"
|
||||||
File "deploy\Qt5Widgets.dll"
|
File "deploy\Qt5Widgets.dll"
|
||||||
|
File "deploy\Qt5WinExtras.dll"
|
||||||
File "deploy\rpi-imager.exe"
|
File "deploy\rpi-imager.exe"
|
||||||
SetOutPath "$INSTDIR\styles"
|
SetOutPath "$INSTDIR\styles"
|
||||||
File "deploy\styles\qwindowsvistastyle.dll"
|
File "deploy\styles\qwindowsvistastyle.dll"
|
||||||
|
@ -695,6 +696,7 @@ Delete "$INSTDIR\Qt5QuickControls2.dll"
|
||||||
Delete "$INSTDIR\Qt5QuickTemplates2.dll"
|
Delete "$INSTDIR\Qt5QuickTemplates2.dll"
|
||||||
Delete "$INSTDIR\Qt5Svg.dll"
|
Delete "$INSTDIR\Qt5Svg.dll"
|
||||||
Delete "$INSTDIR\Qt5Widgets.dll"
|
Delete "$INSTDIR\Qt5Widgets.dll"
|
||||||
|
Delete "$INSTDIR\Qt5WinExtras.dll"
|
||||||
# Old name
|
# Old name
|
||||||
Delete "$INSTDIR\imagingutility.exe"
|
Delete "$INSTDIR\imagingutility.exe"
|
||||||
Delete "$INSTDIR\rpi-imager.exe"
|
Delete "$INSTDIR\rpi-imager.exe"
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue