mirror of
https://github.com/clementine-player/Clementine
synced 2025-01-31 11:35:24 +01:00
Add some buttons to the Windows 7 taskbar list. They don't do anything yet, but they sure look pretty!
This commit is contained in:
parent
55f212a713
commit
f79c10f41e
@ -18,7 +18,7 @@
|
||||
#include <QtGlobal>
|
||||
|
||||
#ifdef Q_OS_WIN32
|
||||
# define _WIN32_WINNT 0x0500
|
||||
# define _WIN32_WINNT 0x0600
|
||||
# include <windows.h>
|
||||
# include <iostream>
|
||||
#endif // Q_OS_WIN32
|
||||
|
@ -15,6 +15,10 @@
|
||||
along with Clementine. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#ifdef Q_OS_WIN32
|
||||
# define _WIN32_WINNT 0x0600
|
||||
#endif
|
||||
|
||||
#include "mainwindow.h"
|
||||
#include "ui_mainwindow.h"
|
||||
#include "core/backgroundstreams.h"
|
||||
@ -119,6 +123,9 @@
|
||||
|
||||
#ifdef Q_OS_WIN32
|
||||
# include <qtsparkle/Updater>
|
||||
# include <windows.h>
|
||||
# include <commctrl.h>
|
||||
# include <shobjidl.h>
|
||||
#endif
|
||||
|
||||
|
||||
@ -184,7 +191,8 @@ MainWindow::MainWindow(
|
||||
playlist_menu_(new QMenu(this)),
|
||||
library_sort_model_(new QSortFilterProxyModel(this)),
|
||||
track_position_timer_(new QTimer(this)),
|
||||
was_maximized_(false)
|
||||
was_maximized_(false),
|
||||
taskbar_list_(NULL)
|
||||
{
|
||||
// Create some objects in the database thread
|
||||
playlist_backend_ = new PlaylistBackend;
|
||||
@ -1641,3 +1649,53 @@ void MainWindow::ShowScriptDialog() {
|
||||
}
|
||||
script_dialog_->show();
|
||||
}
|
||||
|
||||
#ifdef Q_OS_WIN32
|
||||
static const int kTaskbarIconSize = 16;
|
||||
|
||||
static void SetButton(const QIcon& icon, const QString& tooltip, uint id,
|
||||
THUMBBUTTON* button) {
|
||||
button->dwMask = THUMBBUTTONMASK(THB_ICON | THB_TOOLTIP | THB_FLAGS);
|
||||
button->iId = id;
|
||||
button->dwFlags = THBF_ENABLED;
|
||||
button->hIcon = icon.pixmap(kTaskbarIconSize).toWinHICON();
|
||||
tooltip.toWCharArray(button->szTip);
|
||||
}
|
||||
|
||||
bool MainWindow::winEvent(MSG* m, long* result) {
|
||||
static UINT sTaskbarButtonCreated = WM_NULL;
|
||||
|
||||
if (sTaskbarButtonCreated == WM_NULL) {
|
||||
// Compute the value for the TaskbarButtonCreated message
|
||||
sTaskbarButtonCreated = RegisterWindowMessage("TaskbarButtonCreated");
|
||||
}
|
||||
|
||||
if (m->message == sTaskbarButtonCreated) {
|
||||
if (!taskbar_list_) {
|
||||
// Get the interface
|
||||
if (CoCreateInstance(CLSID_ITaskbarList, NULL, CLSCTX_ALL,
|
||||
IID_ITaskbarList3, (void**) &taskbar_list_)) {
|
||||
qWarning() << "Error creating the ITaskbarList3 interface";
|
||||
return false;
|
||||
}
|
||||
|
||||
ITaskbarList3* taskbar_list = reinterpret_cast<ITaskbarList3*>(taskbar_list_);
|
||||
if (taskbar_list->HrInit()) {
|
||||
taskbar_list->Release();
|
||||
taskbar_list_ = NULL;
|
||||
return false;
|
||||
}
|
||||
|
||||
// Add the playback control buttons
|
||||
THUMBBUTTON buttons[4] = {};
|
||||
SetButton(IconLoader::Load("media-skip-backward"), tr("Previous track"), 0, &buttons[0]);
|
||||
SetButton(IconLoader::Load("media-playback-start"), tr("Pause"), 1, &buttons[1]);
|
||||
SetButton(IconLoader::Load("media-playback-stop"), tr("Stop"), 2, &buttons[2]);
|
||||
SetButton(IconLoader::Load("media-skip-forward"), tr("Next track"), 3, &buttons[3]);
|
||||
|
||||
taskbar_list->ThumbBarAddButtons(winId(), 4, buttons);
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
#endif // Q_OS_WIN32
|
||||
|
@ -107,6 +107,10 @@ class MainWindow : public QMainWindow, public PlatformInterface {
|
||||
void resizeEvent(QResizeEvent* event);
|
||||
void closeEvent(QCloseEvent* event);
|
||||
|
||||
#ifdef Q_OS_WIN32
|
||||
bool winEvent(MSG* message, long* result);
|
||||
#endif
|
||||
|
||||
// PlatformInterface
|
||||
void Activate();
|
||||
bool LoadUrl(const QString& url);
|
||||
@ -280,6 +284,9 @@ class MainWindow : public QMainWindow, public PlatformInterface {
|
||||
bool autoclear_playlist_;
|
||||
|
||||
BackgroundStreams* background_streams_;
|
||||
|
||||
// Really an ITaskbarList3* but I don't want to have to include windows.h here
|
||||
void* taskbar_list_;
|
||||
};
|
||||
|
||||
#endif // MAINWINDOW_H
|
||||
|
Loading…
x
Reference in New Issue
Block a user