From 9b52dfab2f4fdf2855ffea697589bfca7f411816 Mon Sep 17 00:00:00 2001 From: Luke Dashjr Date: Tue, 31 Mar 2020 17:07:25 +0000 Subject: [PATCH 1/4] Add QtWinExtras optional dependency Co-authored-by: Chun Kuan Lee --- build-aux/m4/bitcoin_qt.m4 | 11 +++++++++++ build_msvc/common.qt.init.vcxproj | 2 +- configure.ac | 1 + depends/Makefile | 3 ++- depends/packages/qt.mk | 12 +++++++++++- depends/patches/qt/qt.pro | 3 ++- 6 files changed, 28 insertions(+), 4 deletions(-) diff --git a/build-aux/m4/bitcoin_qt.m4 b/build-aux/m4/bitcoin_qt.m4 index 7498127860..41de25ba97 100644 --- a/build-aux/m4/bitcoin_qt.m4 +++ b/build-aux/m4/bitcoin_qt.m4 @@ -371,4 +371,15 @@ AC_DEFUN([_BITCOIN_QT_FIND_LIBS],[ PKG_CHECK_MODULES([QT_DBUS], [${qt_lib_prefix}DBus $qt_version], [QT_DBUS_INCLUDES="$QT_DBUS_CFLAGS"; have_qt_dbus=yes], [have_qt_dbus=no]) fi ]) + + 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" + ],[ + BITCOIN_QT_FAIL([${qt_lib_prefix}WinExtras $qt_version not found]) + ]) + fi + ]) ]) diff --git a/build_msvc/common.qt.init.vcxproj b/build_msvc/common.qt.init.vcxproj index dabbec707f..713ed7051e 100644 --- a/build_msvc/common.qt.init.vcxproj +++ b/build_msvc/common.qt.init.vcxproj @@ -6,7 +6,7 @@ $(QtBaseDir)\plugins $(QtBaseDir)\lib $(QtBaseDir)\include - $(QtIncludeDir);$(QtIncludeDir)\QtNetwork;$(QtIncludeDir)\QtCore;$(QtIncludeDir)\QtWidgets;$(QtIncludeDir)\QtGui; + $(QtIncludeDir);$(QtIncludeDir)\QtNetwork;$(QtIncludeDir)\QtCore;$(QtIncludeDir)\QtWidgets;$(QtIncludeDir)\QtGui;$(QtIncludeDir)\QtWinExtras; .\QtGeneratedFiles\qt $(QtBaseDir)\bin $(QtPluginsLibraryDir)\platforms\qminimal.lib;$(QtPluginsLibraryDir)\platforms\qwindows.lib;$(QtPluginsLibraryDir)\styles\qwindowsvistastyle.lib;$(QtLibraryDir)\Qt5WindowsUIAutomationSupport.lib;$(QtLibraryDir)\qtfreetype.lib;$(QtLibraryDir)\qtharfbuzz.lib;$(QtLibraryDir)\qtlibpng.lib;$(QtLibraryDir)\qtpcre2.lib;$(QtLibraryDir)\Qt5AccessibilitySupport.lib;$(QtLibraryDir)\Qt5Core.lib;$(QtLibraryDir)\Qt5Concurrent.lib;$(QtLibraryDir)\Qt5EventDispatcherSupport.lib;$(QtLibraryDir)\Qt5FontDatabaseSupport.lib;$(QtLibraryDir)\Qt5Gui.lib;$(QtLibraryDir)\Qt5Network.lib;$(QtLibraryDir)\Qt5PlatformCompositorSupport.lib;$(QtLibraryDir)\Qt5ThemeSupport.lib;$(QtLibraryDir)\Qt5Widgets.lib;$(QtLibraryDir)\Qt5WinExtras.lib;$(QtLibraryDir)\qtmain.lib;Wtsapi32.lib;userenv.lib;netapi32.lib;imm32.lib;Dwmapi.lib;version.lib;winmm.lib;UxTheme.lib diff --git a/configure.ac b/configure.ac index 4221a58a21..25845d8dbb 100644 --- a/configure.ac +++ b/configure.ac @@ -634,6 +634,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])]) dnl -static is interpreted by libtool, where it has a different meaning. dnl In libtool-speak, it's -all-static. diff --git a/depends/Makefile b/depends/Makefile index 52a9a14e56..8b6834ac26 100644 --- a/depends/Makefile +++ b/depends/Makefile @@ -259,7 +259,8 @@ endef define check_or_remove_sources mkdir -p $($(package)_source_dir); cd $($(package)_source_dir); \ - test -f $($(package)_fetched) && ( $(build_SHA256SUM) -c $($(package)_fetched) >/dev/null 2>/dev/null || \ + test -f $($(package)_fetched) && ( test `cat $($(package)_fetched) | wc -l` -eq $(words $($(package)_all_sources)) && \ + $(build_SHA256SUM) -c $($(package)_fetched) >/dev/null 2>/dev/null || \ ( echo "Checksum missing or mismatched for $(package) source. Forcing re-download."; \ rm -f $($(package)_all_sources) $($(1)_fetched))) || true endef diff --git a/depends/packages/qt.mk b/depends/packages/qt.mk index c19d353a34..17b7654e05 100644 --- a/depends/packages/qt.mk +++ b/depends/packages/qt.mk @@ -1,6 +1,6 @@ package=qt $(package)_version=5.15.16 -$(package)_download_path=https://download.qt.io/official_releases/qt/5.15/$($(package)_version)/submodules +$(package)_download_path=https://download.qt.io/archive/qt/5.15/$($(package)_version)/submodules $(package)_suffix=everywhere-opensource-src-$($(package)_version).tar.xz $(package)_file_name=qtbase-$($(package)_suffix) $(package)_sha256_hash=b04815058c18058b6ba837206756a2c87d1391f07a0dcb0dd314f970fd041592 @@ -35,6 +35,10 @@ $(package)_qttools_sha256_hash=1cab11887faca54af59f4995ee435c9ad98d194e9e6889c84 $(package)_extra_sources = $($(package)_qttranslations_file_name) $(package)_extra_sources += $($(package)_qttools_file_name) +$(package)_qtwinextras_file_name=qtwinextras-$($(package)_suffix) +$(package)_qtwinextras_sha256_hash=8e7a3b0d03b0f726b10bb050f560659fa7babaa45273e174e9fcc3bb9c169a4e +$(package)_extra_sources += $($(package)_qtwinextras_file_name) + define $(package)_set_vars $(package)_config_env = QT_MAC_SDK_NO_VERSION_CHECK=1 $(package)_config_opts_release = -release @@ -192,6 +196,7 @@ endef define $(package)_fetch_cmds $(call fetch_file,$(package),$($(package)_download_path),$($(package)_download_file),$($(package)_file_name),$($(package)_sha256_hash)) && \ $(call fetch_file,$(package),$($(package)_download_path),$($(package)_qttranslations_file_name),$($(package)_qttranslations_file_name),$($(package)_qttranslations_sha256_hash)) && \ +$(call fetch_file,$(package),$($(package)_download_path),$($(package)_qtwinextras_file_name),$($(package)_qtwinextras_file_name),$($(package)_qtwinextras_sha256_hash)) && \ $(call fetch_file,$(package),$($(package)_download_path),$($(package)_qttools_file_name),$($(package)_qttools_file_name),$($(package)_qttools_sha256_hash)) endef @@ -200,11 +205,14 @@ define $(package)_extract_cmds echo "$($(package)_sha256_hash) $($(package)_source)" > $($(package)_extract_dir)/.$($(package)_file_name).hash && \ echo "$($(package)_qttranslations_sha256_hash) $($(package)_source_dir)/$($(package)_qttranslations_file_name)" >> $($(package)_extract_dir)/.$($(package)_file_name).hash && \ echo "$($(package)_qttools_sha256_hash) $($(package)_source_dir)/$($(package)_qttools_file_name)" >> $($(package)_extract_dir)/.$($(package)_file_name).hash && \ + echo "$($(package)_qtwinextras_sha256_hash) $($(package)_source_dir)/$($(package)_qtwinextras_file_name)" >> $($(package)_extract_dir)/.$($(package)_file_name).hash && \ $(build_SHA256SUM) -c $($(package)_extract_dir)/.$($(package)_file_name).hash && \ mkdir qtbase && \ $(build_TAR) --no-same-owner --strip-components=1 -xf $($(package)_source) -C qtbase && \ mkdir qttranslations && \ $(build_TAR) --no-same-owner --strip-components=1 -xf $($(package)_source_dir)/$($(package)_qttranslations_file_name) -C qttranslations && \ + mkdir qtwinextras && \ + $(build_TAR) --no-same-owner --strip-components=1 -xf $($(package)_source_dir)/$($(package)_qtwinextras_file_name) -C qtwinextras && \ mkdir qttools && \ $(build_TAR) --no-same-owner --strip-components=1 -xf $($(package)_source_dir)/$($(package)_qttools_file_name) -C qttools endef @@ -237,6 +245,7 @@ define $(package)_preprocess_cmds patch -p1 -i $($(package)_patch_dir)/guix_cross_lib_path.patch && \ patch -p1 -i $($(package)_patch_dir)/windows_lto.patch && \ patch -p1 -i $($(package)_patch_dir)/darwin_no_libm.patch && \ + sed -i.old -e '/qwinjumplist/d' qtwinextras/src/winextras/winextras.pro && \ mkdir -p qtbase/mkspecs/macx-clang-linux &&\ cp -f qtbase/mkspecs/macx-clang/qplatformdefs.h qtbase/mkspecs/macx-clang-linux/ &&\ cp -f $($(package)_patch_dir)/mac-qmake.conf qtbase/mkspecs/macx-clang-linux/qmake.conf && \ @@ -266,6 +275,7 @@ endef define $(package)_stage_cmds $(MAKE) -C qtbase/src INSTALL_ROOT=$($(package)_staging_dir) $(addsuffix -install_subtargets,$(addprefix sub-,$($(package)_qt_libs))) && \ $(MAKE) -C qttools/src/linguist INSTALL_ROOT=$($(package)_staging_dir) $(addsuffix -install_subtargets,$(addprefix sub-,$($(package)_linguist_tools))) && \ + $(MAKE) -C qtwinextras INSTALL_ROOT=$($(package)_staging_dir) install_subtargets && \ $(MAKE) -C qttranslations INSTALL_ROOT=$($(package)_staging_dir) install_subtargets endef diff --git a/depends/patches/qt/qt.pro b/depends/patches/qt/qt.pro index 8f2e900a84..f5a59f329e 100644 --- a/depends/patches/qt/qt.pro +++ b/depends/patches/qt/qt.pro @@ -8,9 +8,10 @@ CONFIG += $$prl cache(CONFIG, add stash, prl) TEMPLATE = subdirs -SUBDIRS = qtbase qttools qttranslations +SUBDIRS = qtbase qttools qttranslations qtwinextras qttools.depends = qtbase qttranslations.depends = qttools +qtwinextras.depends = qtbase load(qt_configure) From 8e126fbb3dcdc32ce5b323ddcf7d56aa98517c23 Mon Sep 17 00:00:00 2001 From: Chun Kuan Lee Date: Mon, 3 Sep 2018 11:14:44 +0800 Subject: [PATCH 2/4] gui: Add Windows taskbar progress --- src/qt/bitcoingui.cpp | 17 +++++++++++++++++ src/qt/bitcoingui.h | 4 ++++ 2 files changed, 21 insertions(+) diff --git a/src/qt/bitcoingui.cpp b/src/qt/bitcoingui.cpp index 6d66c7473b..30e6d5e7b6 100644 --- a/src/qt/bitcoingui.cpp +++ b/src/qt/bitcoingui.cpp @@ -30,6 +30,9 @@ #ifdef Q_OS_MACOS #include +#elif defined Q_OS_WIN +#include +#include #endif #include @@ -222,6 +225,8 @@ BitcoinGUI::BitcoinGUI(interfaces::Node& node, const PlatformStyle *_platformSty #ifdef Q_OS_MACOS m_app_nap_inhibitor = new CAppNapInhibitor; +#elif defined Q_OS_WIN + m_taskbar_button = new QWinTaskbarButton(this); #endif GUIUtil::handleCloseWindowShortcut(this); @@ -1154,6 +1159,11 @@ void BitcoinGUI::setNumBlocks(int count, const QDateTime& blockDate, double nVer tooltip = tr("Processed %n block(s) of transaction history.", "", count); +#ifdef Q_OS_WIN + m_taskbar_button->setWindow(windowHandle()); + QWinTaskbarProgress* taskbar_progress = m_taskbar_button->progress(); +#endif + // Set icon state: spinning if catching up, tick otherwise if (secs < MAX_BLOCK_TIME_GAP) { tooltip = tr("Up to date") + QString(".
") + tooltip; @@ -1169,6 +1179,9 @@ void BitcoinGUI::setNumBlocks(int count, const QDateTime& blockDate, double nVer progressBarLabel->setVisible(false); progressBar->setVisible(false); +#ifdef Q_OS_WIN + taskbar_progress->setVisible(false); +#endif } else { @@ -1179,6 +1192,10 @@ 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 + taskbar_progress->setValue(qRound(nVerificationProgress * 100.0)); + taskbar_progress->setVisible(true); +#endif tooltip = tr("Catching up…") + QString("
") + tooltip; if(count != prevBlocks) diff --git a/src/qt/bitcoingui.h b/src/qt/bitcoingui.h index 73adbda5a5..04adbe64d7 100644 --- a/src/qt/bitcoingui.h +++ b/src/qt/bitcoingui.h @@ -53,6 +53,7 @@ class QComboBox; class QDateTime; class QProgressBar; class QProgressDialog; +class QWinTaskbarButton; QT_END_NAMESPACE namespace GUIUtil { @@ -172,6 +173,9 @@ private: Notificator* notificator = nullptr; RPCConsole* rpcConsole = nullptr; HelpMessageDialog* helpMessageDialog = nullptr; +#ifdef Q_OS_WIN + QWinTaskbarButton* m_taskbar_button = nullptr; +#endif ModalOverlay* modalOverlay = nullptr; QMenu* m_network_context_menu = new QMenu(this); From 89206d8109736b71b05ba4bee80b3d5f2fbf19dd Mon Sep 17 00:00:00 2001 From: Luke Dashjr Date: Fri, 11 Dec 2020 02:13:14 +0000 Subject: [PATCH 3/4] 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 41de25ba97..b62ec64f10 100644 --- a/build-aux/m4/bitcoin_qt.m4 +++ b/build-aux/m4/bitcoin_qt.m4 @@ -253,6 +253,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) @@ -375,10 +389,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 25845d8dbb..e348411590 100644 --- a/configure.ac +++ b/configure.ac @@ -634,7 +634,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 30e6d5e7b6..2d359c07e3 100644 --- a/src/qt/bitcoingui.cpp +++ b/src/qt/bitcoingui.cpp @@ -30,7 +30,8 @@ #ifdef Q_OS_MACOS #include -#elif defined Q_OS_WIN +#endif +#ifdef BITCOIN_QT_WIN_TASKBAR #include #include #endif @@ -225,7 +226,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 @@ -1159,7 +1161,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 @@ -1179,7 +1181,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 } @@ -1192,7 +1194,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 04adbe64d7..e707302cb3 100644 --- a/src/qt/bitcoingui.h +++ b/src/qt/bitcoingui.h @@ -173,7 +173,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; From 417ba13865bbaa1597a6dc832dbe96349cc5f554 Mon Sep 17 00:00:00 2001 From: Luke Dashjr Date: Thu, 12 May 2022 23:26:33 +0000 Subject: [PATCH 4/4] Bugfix: configure: Add missing result for QWinTaskbarProgress support when not building the GUI --- build-aux/m4/bitcoin_qt.m4 | 2 ++ 1 file changed, 2 insertions(+) diff --git a/build-aux/m4/bitcoin_qt.m4 b/build-aux/m4/bitcoin_qt.m4 index b62ec64f10..cd8bf304fd 100644 --- a/build-aux/m4/bitcoin_qt.m4 +++ b/build-aux/m4/bitcoin_qt.m4 @@ -265,6 +265,8 @@ AC_DEFUN([BITCOIN_QT_CONFIGURE],[ QT_LIBS="$QT_LIBS $QT_WINEXTRAS_LIBS" AC_DEFINE(BITCOIN_QT_WIN_TASKBAR, 1, [Define this symbol if building with QWinTaskbarProgress]) fi + ],[ + AC_MSG_RESULT([no, not building GUI]) ]) AC_SUBST(QT_PIE_FLAGS)