Skip to content

Commit 97f6a52

Browse files
committed
[win] Show task manager progress in windows task bar
Hooks the task manager progress reports up to a Windows taskbar button progress bar. This lets you easily see when a background task has finished running!
1 parent a46afca commit 97f6a52

File tree

2 files changed

+23
-1
lines changed

2 files changed

+23
-1
lines changed

src/app/CMakeLists.txt

100644100755
+3-1
Original file line numberDiff line numberDiff line change
@@ -479,6 +479,8 @@ QT5_WRAP_CPP(QGIS_APP_MOC_SRCS ${QGIS_APP_MOC_HDRS})
479479
SET (QGIS_APPMAIN_SRCS main.cpp)
480480

481481
IF (WIN32)
482+
FIND_PACKAGE(Qt5WinExtras)
483+
482484
IF (MSVC)
483485
SET (QGIS_APPMAIN_SRCS ${QGIS_APPMAIN_SRCS} ${CMAKE_CURRENT_SOURCE_DIR}/qgis_win32.rc)
484486
ELSE(MSVC)
@@ -640,7 +642,7 @@ ENDIF (ANDROID)
640642
IF(WIN32)
641643
ADD_DEFINITIONS(-DQWT_DLL)
642644
TARGET_LINK_LIBRARIES(${QGIS_APP_NAME} DbgHelp)
643-
TARGET_LINK_LIBRARIES(qgis_app DbgHelp)
645+
TARGET_LINK_LIBRARIES(qgis_app DbgHelp Qt5::WinExtras )
644646
ENDIF(WIN32)
645647

646648
IF (APPLE)

src/app/qgisapp.cpp

100644100755
+20
Original file line numberDiff line numberDiff line change
@@ -74,11 +74,17 @@
7474
#include <qgsapplication.h>
7575
#include <qgscomposition.h>
7676
#include <qgslayerstylingwidget.h>
77+
#include "qgstaskmanager.h"
7778

7879
#include <QNetworkReply>
7980
#include <QNetworkProxy>
8081
#include <QAuthenticator>
8182

83+
#ifdef Q_OS_WIN
84+
#include <QWinTaskbarButton>
85+
#include <QWinTaskbarProgress>
86+
#endif
87+
8288
//
8389
// Mac OS X Includes
8490
// Must include before GEOS 3 due to unqualified use of 'Point'
@@ -1101,6 +1107,20 @@ QgisApp::QgisApp( QSplashScreen *splash, bool restorePlugins, bool skipVersionCh
11011107
mActionTouch = nullptr;
11021108
#endif
11031109

1110+
1111+
#ifdef Q_OS_WIN
1112+
QWinTaskbarButton* taskButton = new QWinTaskbarButton( this );
1113+
taskButton->setWindow( windowHandle() );
1114+
1115+
QWinTaskbarProgress* taskProgress = taskButton->progress();
1116+
taskProgress->setVisible( false );
1117+
connect( QgsApplication::taskManager(), &QgsTaskManager::taskAdded, taskProgress, [taskProgress] { taskProgress->setMaximum( 0 ); taskProgress->show(); }
1118+
);
1119+
connect( QgsApplication::taskManager(), &QgsTaskManager::finalTaskProgressChanged, taskProgress, [taskProgress]( double val ) { taskProgress->setMaximum( 100 );taskProgress->show(); taskProgress->setValue( val ); }
1120+
);
1121+
connect( QgsApplication::taskManager(), &QgsTaskManager::allTasksFinished, taskProgress, &QWinTaskbarProgress::hide );
1122+
#endif
1123+
11041124
// supposedly all actions have been added, now register them to the shortcut manager
11051125
QgsShortcutsManager::instance()->registerAllChildren( this );
11061126

0 commit comments

Comments
 (0)