From 05af8bd4843001384335eb1ece22e8ca650e98c9 Mon Sep 17 00:00:00 2001 From: Luke Dashjr Date: Fri, 11 Dec 2020 02:13:14 +0000 Subject: [PATCH] GUI: If QWinTaskbarButton is missing, just build without it --- build-aux/m4/bitcoin_qt.m4 | 19 ++++++++++++++++--- configure.ac | 2 +- src/qt/bitcoingui.cpp | 12 +++++++----- src/qt/bitcoingui.h | 2 +- 4 files changed, 25 insertions(+), 10 deletions(-) diff --git a/build-aux/m4/bitcoin_qt.m4 b/build-aux/m4/bitcoin_qt.m4 index daac543448..ac1e90adda 100644 --- a/build-aux/m4/bitcoin_qt.m4 +++ b/build-aux/m4/bitcoin_qt.m4 @@ -273,6 +273,20 @@ AC_DEFUN([BITCOIN_QT_CONFIGURE],[ AC_MSG_RESULT([$bitcoin_enable_qt]) fi + AC_MSG_CHECKING([whether to build with QWinTaskbarProgress support]) + BITCOIN_QT_CHECK([ + if test "x$have_qt_winextras" != xyes; then + AC_MSG_RESULT([no, ${qt_lib_prefix}WinExtras $qt_version not found]) + elif test "x$have_dwmapi" != xyes; then + AC_MSG_RESULT([no, dwmapi missing]) + else + AC_MSG_RESULT([yes]) + QT_INCLUDES="$QT_INCLUDES $QT_WINEXTRAS_CFLAGS" + QT_LIBS="$QT_LIBS $QT_WINEXTRAS_LIBS" + AC_DEFINE(BITCOIN_QT_WIN_TASKBAR, 1, [Define this symbol if building with QWinTaskbarProgress]) + fi + ]) + AC_SUBST(QT_PIE_FLAGS) AC_SUBST(QT_INCLUDES) AC_SUBST(QT_LIBS) @@ -398,10 +412,9 @@ AC_DEFUN([_BITCOIN_QT_FIND_LIBS],[ BITCOIN_QT_CHECK([ if test "x$TARGET_OS" = xwindows; then PKG_CHECK_MODULES([QT_WINEXTRAS], [${qt_lib_prefix}WinExtras $qt_version], [ - QT_INCLUDES="$QT_INCLUDES $QT_WINEXTRAS_CFLAGS" - QT_LIBS="$QT_LIBS $QT_WINEXTRAS_LIBS" + have_qt_winextras=yes ],[ - BITCOIN_QT_FAIL([${qt_lib_prefix}WinExtras $qt_version not found]) + have_qt_winextras=no ]) fi ]) diff --git a/configure.ac b/configure.ac index 578487c488..266993cd71 100644 --- a/configure.ac +++ b/configure.ac @@ -699,7 +699,7 @@ case $host in AC_CHECK_LIB([ws2_32], [WSAStartup], [], [AC_MSG_ERROR([libws2_32 missing])]) AC_CHECK_LIB([shlwapi], [PathRemoveFileSpecW], [], [AC_MSG_ERROR([libshlwapi missing])]) AC_CHECK_LIB([iphlpapi], [GetAdaptersAddresses], [], [AC_MSG_ERROR([libiphlpapi missing])]) - AC_CHECK_LIB([dwmapi], [main], [], [AC_MSG_ERROR([libdwmapi missing])]) + AC_CHECK_LIB([dwmapi], [main], [have_dwmapi=yes], [have_dwmapi=no]) dnl -static is interpreted by libtool, where it has a different meaning. dnl In libtool-speak, it's -all-static. diff --git a/src/qt/bitcoingui.cpp b/src/qt/bitcoingui.cpp index 60cd3e6566..241495d2e6 100644 --- a/src/qt/bitcoingui.cpp +++ b/src/qt/bitcoingui.cpp @@ -28,7 +28,8 @@ #ifdef Q_OS_MACOS #include -#elif defined Q_OS_WIN +#endif +#ifdef BITCOIN_QT_WIN_TASKBAR #include #include #endif @@ -223,7 +224,8 @@ BitcoinGUI::BitcoinGUI(interfaces::Node& node, const PlatformStyle *_platformSty #ifdef Q_OS_MACOS m_app_nap_inhibitor = new CAppNapInhibitor; -#elif defined Q_OS_WIN +#endif +#ifdef BITCOIN_QT_WIN_TASKBAR m_taskbar_button = new QWinTaskbarButton(this); #endif @@ -1133,7 +1135,7 @@ void BitcoinGUI::setNumBlocks(int count, const QDateTime& blockDate, double nVer tooltip = tr("Processed %n block(s) of transaction history.", "", count); -#ifdef Q_OS_WIN +#ifdef BITCOIN_QT_WIN_TASKBAR m_taskbar_button->setWindow(windowHandle()); QWinTaskbarProgress* taskbar_progress = m_taskbar_button->progress(); #endif @@ -1153,7 +1155,7 @@ void BitcoinGUI::setNumBlocks(int count, const QDateTime& blockDate, double nVer progressBarLabel->setVisible(false); progressBar->setVisible(false); -#ifdef Q_OS_WIN +#ifdef BITCOIN_QT_WIN_TASKBAR taskbar_progress->setVisible(false); #endif } @@ -1166,7 +1168,7 @@ void BitcoinGUI::setNumBlocks(int count, const QDateTime& blockDate, double nVer progressBar->setMaximum(1000000000); progressBar->setValue(nVerificationProgress * 1000000000.0 + 0.5); progressBar->setVisible(true); -#ifdef Q_OS_WIN +#ifdef BITCOIN_QT_WIN_TASKBAR taskbar_progress->setValue(qRound(nVerificationProgress * 100.0)); taskbar_progress->setVisible(true); #endif diff --git a/src/qt/bitcoingui.h b/src/qt/bitcoingui.h index 449282c6dd..fdf1ecac0f 100644 --- a/src/qt/bitcoingui.h +++ b/src/qt/bitcoingui.h @@ -175,7 +175,7 @@ private: Notificator* notificator = nullptr; RPCConsole* rpcConsole = nullptr; HelpMessageDialog* helpMessageDialog = nullptr; -#ifdef Q_OS_WIN +#ifdef BITCOIN_QT_WIN_TASKBAR QWinTaskbarButton* m_taskbar_button = nullptr; #endif ModalOverlay* modalOverlay = nullptr;