diff --git a/src/core/windows7thumbbar.cpp b/src/core/windows7thumbbar.cpp index 99b6a713..7cd52dcf 100644 --- a/src/core/windows7thumbbar.cpp +++ b/src/core/windows7thumbbar.cpp @@ -26,6 +26,7 @@ #include #include #include +#include #include #ifndef _WIN32_WINNT @@ -47,7 +48,14 @@ const int Windows7ThumbBar::kMaxButtonCount = 7; Windows7ThumbBar::Windows7ThumbBar(QWidget *widget) : QObject(widget), widget_(widget), - button_created_message_id_(0) {} + timer_(new QTimer(this)), + button_created_message_id_(0) { + + timer_->setSingleShot(true); + timer_->setInterval(300); + connect(timer_, SIGNAL(timeout()), SLOT(ActionChanged())); + +} void Windows7ThumbBar::SetActions(const QList &actions) { @@ -57,7 +65,7 @@ void Windows7ThumbBar::SetActions(const QList &actions) { actions_ = actions; for (QAction *action : actions) { if (action) { - connect(action, SIGNAL(changed()), SLOT(ActionChanged())); + connect(action, SIGNAL(changed()), SLOT(ActionChangedTriggered())); } } qLog(Debug) << "Done"; @@ -80,7 +88,7 @@ ITaskbarList3 *Windows7ThumbBar::CreateTaskbarList() { hr = taskbar_list->HrInit(); if (hr != S_OK) { - qLog(Warning) << "Error initialising taskbar list" << Qt::hex << DWORD (hr); + qLog(Warning) << "Error initializing taskbar list" << Qt::hex << DWORD (hr); taskbar_list->Release(); return nullptr; } @@ -162,6 +170,10 @@ void Windows7ThumbBar::HandleWinEvent(MSG *msg) { } +void Windows7ThumbBar::ActionChangedTriggered() { + if (!timer_->isActive()) timer_->start(); +} + void Windows7ThumbBar::ActionChanged() { ITaskbarList3 *taskbar_list = CreateTaskbarList(); diff --git a/src/core/windows7thumbbar.h b/src/core/windows7thumbbar.h index cd8eec53..8fd48322 100644 --- a/src/core/windows7thumbbar.h +++ b/src/core/windows7thumbbar.h @@ -28,8 +28,9 @@ #include #include #include -#include -#include + +class QTimer; +class QAction; class Windows7ThumbBar : public QObject { Q_OBJECT @@ -52,10 +53,12 @@ class Windows7ThumbBar : public QObject { void SetupButton(const QAction *action, THUMBBUTTON *button); private slots: + void ActionChangedTriggered(); void ActionChanged(); private: QWidget *widget_; + QTimer *timer_; QList actions_; unsigned int button_created_message_id_;