Skip to content

Commit

Permalink
[win] Show task manager progress in windows task bar
Browse files Browse the repository at this point in the history
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!
  • Loading branch information
nyalldawson committed Feb 10, 2017
1 parent a46afca commit 97f6a52
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/app/CMakeLists.txt 100644 → 100755
Expand Up @@ -479,6 +479,8 @@ QT5_WRAP_CPP(QGIS_APP_MOC_SRCS ${QGIS_APP_MOC_HDRS})
SET (QGIS_APPMAIN_SRCS main.cpp)

IF (WIN32)
FIND_PACKAGE(Qt5WinExtras)

IF (MSVC)
SET (QGIS_APPMAIN_SRCS ${QGIS_APPMAIN_SRCS} ${CMAKE_CURRENT_SOURCE_DIR}/qgis_win32.rc)
ELSE(MSVC)
Expand Down Expand Up @@ -640,7 +642,7 @@ ENDIF (ANDROID)
IF(WIN32)
ADD_DEFINITIONS(-DQWT_DLL)
TARGET_LINK_LIBRARIES(${QGIS_APP_NAME} DbgHelp)
TARGET_LINK_LIBRARIES(qgis_app DbgHelp)
TARGET_LINK_LIBRARIES(qgis_app DbgHelp Qt5::WinExtras )
ENDIF(WIN32)

IF (APPLE)
Expand Down
20 changes: 20 additions & 0 deletions src/app/qgisapp.cpp 100644 → 100755
Expand Up @@ -74,11 +74,17 @@
#include <qgsapplication.h>
#include <qgscomposition.h>
#include <qgslayerstylingwidget.h>
#include "qgstaskmanager.h"

#include <QNetworkReply>
#include <QNetworkProxy>
#include <QAuthenticator>

#ifdef Q_OS_WIN
#include <QWinTaskbarButton>
#include <QWinTaskbarProgress>
#endif

//
// Mac OS X Includes
// Must include before GEOS 3 due to unqualified use of 'Point'
Expand Down Expand Up @@ -1101,6 +1107,20 @@ QgisApp::QgisApp( QSplashScreen *splash, bool restorePlugins, bool skipVersionCh
mActionTouch = nullptr;
#endif


#ifdef Q_OS_WIN
QWinTaskbarButton* taskButton = new QWinTaskbarButton( this );
taskButton->setWindow( windowHandle() );

QWinTaskbarProgress* taskProgress = taskButton->progress();
taskProgress->setVisible( false );
connect( QgsApplication::taskManager(), &QgsTaskManager::taskAdded, taskProgress, [taskProgress] { taskProgress->setMaximum( 0 ); taskProgress->show(); }
);
connect( QgsApplication::taskManager(), &QgsTaskManager::finalTaskProgressChanged, taskProgress, [taskProgress]( double val ) { taskProgress->setMaximum( 100 );taskProgress->show(); taskProgress->setValue( val ); }
);
connect( QgsApplication::taskManager(), &QgsTaskManager::allTasksFinished, taskProgress, &QWinTaskbarProgress::hide );
#endif

// supposedly all actions have been added, now register them to the shortcut manager
QgsShortcutsManager::instance()->registerAllChildren( this );

Expand Down

0 comments on commit 97f6a52

Please sign in to comment.