forked from bitcoin/bitcoin
-
Notifications
You must be signed in to change notification settings - Fork 132
feat(qt): Port win_taskbar_progress to Qt6 #215
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Draft
kwsantiago
wants to merge
1
commit into
bitcoinknots:29.x-knots
Choose a base branch
from
kwsantiago:kwsantiago/191-win-taskbar-progress-qt6
base: 29.x-knots
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,106 @@ | ||
| // Copyright (c) 2025 The Bitcoin Knots developers | ||
| // Distributed under the MIT software license, see the accompanying | ||
| // file COPYING or http://www.opensource.org/licenses/mit-license.php. | ||
|
|
||
| #include <qt/wintaskbarprogress.h> | ||
|
|
||
| #include <QWindow> | ||
|
|
||
| #include <cassert> | ||
| #include <windows.h> | ||
| #include <shobjidl.h> | ||
|
|
||
| WinTaskbarProgress::WinTaskbarProgress(QObject *parent) | ||
| : QObject(parent) | ||
| { | ||
| } | ||
|
|
||
| WinTaskbarProgress::~WinTaskbarProgress() | ||
| { | ||
| releaseTaskbarButton(); | ||
| } | ||
|
|
||
| void WinTaskbarProgress::setWindow(QWindow* window) | ||
| { | ||
kwsantiago marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| assert(!m_taskbar_button); | ||
| if (m_window == window) { | ||
| return; | ||
| } | ||
|
|
||
| m_window = window; | ||
| initTaskbarButton(); | ||
| updateProgress(); | ||
| } | ||
|
|
||
| QWindow* WinTaskbarProgress::window() const | ||
| { | ||
| return m_window; | ||
| } | ||
|
|
||
| void WinTaskbarProgress::setValue(int value) | ||
| { | ||
| if (m_value == value) { | ||
| return; | ||
| } | ||
|
|
||
| m_value = value; | ||
| updateProgress(); | ||
| } | ||
|
|
||
| void WinTaskbarProgress::setVisible(bool visible) | ||
| { | ||
| if (m_visible == visible) { | ||
| return; | ||
| } | ||
|
|
||
| m_visible = visible; | ||
| updateProgress(); | ||
| } | ||
|
|
||
| void WinTaskbarProgress::updateProgress() | ||
| { | ||
| if (!m_taskbar_button || !m_window) { | ||
| return; | ||
| } | ||
|
|
||
| if (m_visible) { | ||
| // Set progress value | ||
| m_taskbar_button->SetProgressValue((HWND)m_window->winId(), m_value, 100); | ||
| // Set progress state to normal | ||
| m_taskbar_button->SetProgressState((HWND)m_window->winId(), TBPF_NORMAL); | ||
| } else { | ||
| // Hide progress bar | ||
| m_taskbar_button->SetProgressState((HWND)m_window->winId(), TBPF_NOPROGRESS); | ||
| } | ||
| } | ||
|
|
||
| void WinTaskbarProgress::initTaskbarButton() | ||
| { | ||
| if (m_taskbar_button || !m_window) { | ||
| return; | ||
| } | ||
|
|
||
| HRESULT hr = CoCreateInstance(CLSID_TaskbarList, nullptr, CLSCTX_INPROC_SERVER, | ||
| IID_PPV_ARGS(&m_taskbar_button)); | ||
|
|
||
| if (SUCCEEDED(hr)) { | ||
| hr = m_taskbar_button->HrInit(); | ||
| if (!SUCCEEDED(hr)) { | ||
| m_taskbar_button->Release(); | ||
| m_taskbar_button = nullptr; | ||
| } | ||
| } | ||
| } | ||
|
|
||
| void WinTaskbarProgress::releaseTaskbarButton() | ||
| { | ||
| if (!m_taskbar_button) { | ||
| return; | ||
| } | ||
|
|
||
| if (m_window) { | ||
| m_taskbar_button->SetProgressState((HWND)m_window->winId(), TBPF_NOPROGRESS); | ||
| } | ||
| m_taskbar_button->Release(); | ||
| m_taskbar_button = nullptr; | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,61 @@ | ||
| // Copyright (c) 2025 The Bitcoin Knots developers | ||
| // Distributed under the MIT software license, see the accompanying | ||
| // file COPYING or http://www.opensource.org/licenses/mit-license.php. | ||
|
|
||
| #ifndef BITCOIN_QT_WINTASKBARPROGRESS_H | ||
| #define BITCOIN_QT_WINTASKBARPROGRESS_H | ||
|
|
||
| #include <QObject> | ||
|
|
||
| class QWindow; | ||
| struct ITaskbarList3; | ||
|
|
||
| /** | ||
| * Manages Windows taskbar button progress indicator. | ||
| * Provides a platform-independent wrapper around the native Windows API | ||
| * for taskbar progress updates. | ||
| */ | ||
| class WinTaskbarProgress : public QObject | ||
| { | ||
| Q_OBJECT | ||
|
|
||
| public: | ||
| explicit WinTaskbarProgress(QObject *parent = nullptr); | ||
| ~WinTaskbarProgress(); | ||
|
|
||
| /** | ||
| * Set the window handle for taskbar progress updates | ||
| * @param[in] window The QWindow to update taskbar progress for | ||
| */ | ||
| void setWindow(QWindow* window); | ||
|
|
||
| /** | ||
| * Get the current window handle | ||
| * @return The current QWindow pointer, or nullptr if not set | ||
| */ | ||
| QWindow* window() const; | ||
|
|
||
| /** | ||
| * Set the progress value | ||
| * @param[in] value Progress value (0-100) | ||
| */ | ||
| void setValue(int value); | ||
|
|
||
| /** | ||
| * Set progress visibility | ||
| * @param[in] visible True to show progress, false to hide | ||
| */ | ||
| void setVisible(bool visible); | ||
|
|
||
| private: | ||
| QWindow* m_window = nullptr; | ||
| int m_value = 0; | ||
| bool m_visible = false; | ||
| ITaskbarList3* m_taskbar_button = nullptr; | ||
|
|
||
| void updateProgress(); | ||
| void initTaskbarButton(); | ||
| void releaseTaskbarButton(); | ||
| }; | ||
|
|
||
| #endif // BITCOIN_QT_WINTASKBARPROGRESS_H |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.