Commit 2c8bd7d8 authored by Rafaël Carré's avatar Rafaël Carré

qt: support for Qt5 windows build

parent f00c837f
...@@ -63,6 +63,12 @@ ...@@ -63,6 +63,12 @@
#include <vlc_keys.h> /* Wheel event */ #include <vlc_keys.h> /* Wheel event */
#include <vlc_vout_display.h> /* vout_thread_t and VOUT_ events */ #include <vlc_vout_display.h> /* vout_thread_t and VOUT_ events */
#if QT_VERSION >= 0x050000
#include <QWindow>
#include <qpa/qplatformnativeinterface.h>
#endif
// #define DEBUG_INTF // #define DEBUG_INTF
/* Callback prototypes */ /* Callback prototypes */
...@@ -1102,10 +1108,18 @@ void MainInterface::toggleUpdateSystrayMenu() ...@@ -1102,10 +1108,18 @@ void MainInterface::toggleUpdateSystrayMenu()
/* check if any visible window is above vlc in the z-order, /* check if any visible window is above vlc in the z-order,
* but ignore the ones always on top * but ignore the ones always on top
* and the ones which can't be activated */ * and the ones which can't be activated */
HWND winId;
#if QT_VERSION >= 0x050000
QWindow *window = windowHandle();
winId = static_cast<HWND>(QGuiApplication::platformNativeInterface()->nativeResourceForWindow("handle", window));
#else
winId = internalWinId();
#endif
WINDOWINFO wi; WINDOWINFO wi;
HWND hwnd; HWND hwnd;
wi.cbSize = sizeof( WINDOWINFO ); wi.cbSize = sizeof( WINDOWINFO );
for( hwnd = GetNextWindow( internalWinId(), GW_HWNDPREV ); for( hwnd = GetNextWindow( winId, GW_HWNDPREV );
hwnd && ( !IsWindowVisible( hwnd ) || hwnd && ( !IsWindowVisible( hwnd ) ||
( GetWindowInfo( hwnd, &wi ) && ( GetWindowInfo( hwnd, &wi ) &&
(wi.dwExStyle&WS_EX_NOACTIVATE) ) ); (wi.dwExStyle&WS_EX_NOACTIVATE) ) );
...@@ -1121,7 +1135,7 @@ void MainInterface::toggleUpdateSystrayMenu() ...@@ -1121,7 +1135,7 @@ void MainInterface::toggleUpdateSystrayMenu()
} }
#else #else
hide(); hide();
#endif #endif // _WIN32
} }
if( sysTray ) if( sysTray )
VLCMenuBar::updateSystrayMenu( this, p_intf ); VLCMenuBar::updateSystrayMenu( this, p_intf );
......
...@@ -175,6 +175,7 @@ private: ...@@ -175,6 +175,7 @@ private:
bool b_statusbarVisible; bool b_statusbarVisible;
#ifdef _WIN32 #ifdef _WIN32
HWND WinId();
HIMAGELIST himl; HIMAGELIST himl;
ITaskbarList3 *p_taskbl; ITaskbarList3 *p_taskbl;
UINT taskbar_wmsg; UINT taskbar_wmsg;
......
...@@ -31,6 +31,12 @@ ...@@ -31,6 +31,12 @@
#include <QBitmap> #include <QBitmap>
#include <vlc_windows_interfaces.h> #include <vlc_windows_interfaces.h>
#if defined(_WIN32) && QT_VERSION >= 0x050000
#include <QWindow>
#include <qpa/qplatformnativeinterface.h>
#endif
#define WM_APPCOMMAND 0x0319 #define WM_APPCOMMAND 0x0319
#define APPCOMMAND_VOLUME_MUTE 8 #define APPCOMMAND_VOLUME_MUTE 8
...@@ -72,6 +78,34 @@ ...@@ -72,6 +78,34 @@
#define GET_FLAGS_LPARAM(lParam) (LOWORD(lParam)) #define GET_FLAGS_LPARAM(lParam) (LOWORD(lParam))
#define GET_KEYSTATE_LPARAM(lParam) GET_FLAGS_LPARAM(lParam) #define GET_KEYSTATE_LPARAM(lParam) GET_FLAGS_LPARAM(lParam)
HWND MainInterface::WinId()
{
#if QT_VERSION >= 0x050000
QWindow *window = windowHandle();
HWND id = static_cast<HWND>(QGuiApplication::platformNativeInterface()->
nativeResourceForWindow("handle", window));
return id;
#else
return winId();
#endif
}
#if defined(_WIN32) && QT_VERSION < 0x050000
static const int PremultipliedAlpha = QPixmap::PremultipliedAlpha;
static HBITMAP qt_pixmapToWinHBITMAP(const QPixmap &p, int hbitmapFormat = 0)
{
return p.toWinHBITMAP((enum QBitmap::HBitmapFormat)hbitmapFormat);
}
#else
Q_GUI_EXPORT HBITMAP qt_pixmapToWinHBITMAP(const QPixmap &p, int hbitmapFormat = 0);
enum HBitmapFormat
{
NoAlpha,
PremultipliedAlpha,
Alpha
};
#endif
void MainInterface::createTaskBarButtons() void MainInterface::createTaskBarButtons()
{ {
/*Here is the code for the taskbar thumb buttons /*Here is the code for the taskbar thumb buttons
...@@ -104,13 +138,13 @@ void MainInterface::createTaskBarButtons() ...@@ -104,13 +138,13 @@ void MainInterface::createTaskBarButtons()
QBitmap mask3 = img3.createMaskFromColor(Qt::transparent); QBitmap mask3 = img3.createMaskFromColor(Qt::transparent);
QBitmap mask4 = img4.createMaskFromColor(Qt::transparent); QBitmap mask4 = img4.createMaskFromColor(Qt::transparent);
if(-1 == ImageList_Add(himl, img.toWinHBITMAP(QPixmap::PremultipliedAlpha),mask.toWinHBITMAP())) if(-1 == ImageList_Add(himl, qt_pixmapToWinHBITMAP(img, PremultipliedAlpha), qt_pixmapToWinHBITMAP(mask)))
msg_Err( p_intf, "First ImageList_Add failed" ); msg_Err( p_intf, "First ImageList_Add failed" );
if(-1 == ImageList_Add(himl, img2.toWinHBITMAP(QPixmap::PremultipliedAlpha),mask2.toWinHBITMAP())) if(-1 == ImageList_Add(himl, qt_pixmapToWinHBITMAP(img2, PremultipliedAlpha), qt_pixmapToWinHBITMAP(mask2)))
msg_Err( p_intf, "Second ImageList_Add failed" ); msg_Err( p_intf, "Second ImageList_Add failed" );
if(-1 == ImageList_Add(himl, img3.toWinHBITMAP(QPixmap::PremultipliedAlpha),mask3.toWinHBITMAP())) if(-1 == ImageList_Add(himl, qt_pixmapToWinHBITMAP(img3, PremultipliedAlpha), qt_pixmapToWinHBITMAP(mask3)))
msg_Err( p_intf, "Third ImageList_Add failed" ); msg_Err( p_intf, "Third ImageList_Add failed" );
if(-1 == ImageList_Add(himl, img4.toWinHBITMAP(QPixmap::PremultipliedAlpha),mask4.toWinHBITMAP())) if(-1 == ImageList_Add(himl, qt_pixmapToWinHBITMAP(img4, PremultipliedAlpha), qt_pixmapToWinHBITMAP(mask4)))
msg_Err( p_intf, "Fourth ImageList_Add failed" ); msg_Err( p_intf, "Fourth ImageList_Add failed" );
} }
...@@ -134,12 +168,12 @@ void MainInterface::createTaskBarButtons() ...@@ -134,12 +168,12 @@ void MainInterface::createTaskBarButtons()
thbButtons[2].iBitmap = 3; thbButtons[2].iBitmap = 3;
thbButtons[2].dwFlags = THBF_HIDDEN; thbButtons[2].dwFlags = THBF_HIDDEN;
HRESULT hr = p_taskbl->ThumbBarSetImageList(winId(), himl ); HRESULT hr = p_taskbl->ThumbBarSetImageList(WinId(), himl );
if(S_OK != hr) if(S_OK != hr)
msg_Err( p_intf, "ThumbBarSetImageList failed with error %08lx", hr ); msg_Err( p_intf, "ThumbBarSetImageList failed with error %08lx", hr );
else else
{ {
hr = p_taskbl->ThumbBarAddButtons(winId(), 3, thbButtons); hr = p_taskbl->ThumbBarAddButtons(WinId(), 3, thbButtons);
if(S_OK != hr) if(S_OK != hr)
msg_Err( p_intf, "ThumbBarAddButtons failed with error %08lx", hr ); msg_Err( p_intf, "ThumbBarAddButtons failed with error %08lx", hr );
} }
...@@ -299,7 +333,7 @@ void MainInterface::changeThumbbarButtons( int i_status ) ...@@ -299,7 +333,7 @@ void MainInterface::changeThumbbarButtons( int i_status )
default: default:
return; return;
} }
HRESULT hr = p_taskbl->ThumbBarUpdateButtons(this->winId(), 3, thbButtons); HRESULT hr = p_taskbl->ThumbBarUpdateButtons(WinId(), 3, thbButtons);
if(S_OK != hr) if(S_OK != hr)
msg_Err( p_intf, "ThumbBarUpdateButtons failed with error %08lx", hr ); msg_Err( p_intf, "ThumbBarUpdateButtons failed with error %08lx", hr );
} }
...@@ -51,8 +51,14 @@ ...@@ -51,8 +51,14 @@
#ifdef _WIN32 /* For static builds */ #ifdef _WIN32 /* For static builds */
#include <QtPlugin> #include <QtPlugin>
Q_IMPORT_PLUGIN(qjpeg) #if QT_VERSION >= 0x050000
Q_IMPORT_PLUGIN(qtaccessiblewidgets) Q_IMPORT_PLUGIN(QWindowsIntegrationPlugin)
Q_IMPORT_PLUGIN(QJpegPlugin)
Q_IMPORT_PLUGIN(AccessibleFactory)
#else
Q_IMPORT_PLUGIN(qjpeg)
Q_IMPORT_PLUGIN(qtaccessiblewidgets)
#endif
#endif #endif
/***************************************************************************** /*****************************************************************************
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment