[vlc-commits] qt: support for Qt5 windows build
Rafaël Carré
git at videolan.org
Tue Mar 11 11:35:17 CET 2014
vlc | branch: master | Rafaël Carré <funman at videolan.org> | Tue Mar 11 11:17:14 2014 +0100| [2c8bd7d88537277d202ebaa489c62fbc1ab220db] | committer: Rafaël Carré
qt: support for Qt5 windows build
> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=2c8bd7d88537277d202ebaa489c62fbc1ab220db
---
modules/gui/qt4/main_interface.cpp | 18 +++++++++--
modules/gui/qt4/main_interface.hpp | 1 +
modules/gui/qt4/main_interface_win32.cpp | 48 +++++++++++++++++++++++++-----
modules/gui/qt4/qt4.cpp | 10 +++++--
4 files changed, 66 insertions(+), 11 deletions(-)
diff --git a/modules/gui/qt4/main_interface.cpp b/modules/gui/qt4/main_interface.cpp
index 7034fc5..6466e46 100644
--- a/modules/gui/qt4/main_interface.cpp
+++ b/modules/gui/qt4/main_interface.cpp
@@ -63,6 +63,12 @@
#include <vlc_keys.h> /* Wheel event */
#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
/* Callback prototypes */
@@ -1102,10 +1108,18 @@ void MainInterface::toggleUpdateSystrayMenu()
/* check if any visible window is above vlc in the z-order,
* but ignore the ones always on top
* 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;
HWND hwnd;
wi.cbSize = sizeof( WINDOWINFO );
- for( hwnd = GetNextWindow( internalWinId(), GW_HWNDPREV );
+ for( hwnd = GetNextWindow( winId, GW_HWNDPREV );
hwnd && ( !IsWindowVisible( hwnd ) ||
( GetWindowInfo( hwnd, &wi ) &&
(wi.dwExStyle&WS_EX_NOACTIVATE) ) );
@@ -1121,7 +1135,7 @@ void MainInterface::toggleUpdateSystrayMenu()
}
#else
hide();
-#endif
+#endif // _WIN32
}
if( sysTray )
VLCMenuBar::updateSystrayMenu( this, p_intf );
diff --git a/modules/gui/qt4/main_interface.hpp b/modules/gui/qt4/main_interface.hpp
index bb413fc..8a69193 100644
--- a/modules/gui/qt4/main_interface.hpp
+++ b/modules/gui/qt4/main_interface.hpp
@@ -175,6 +175,7 @@ private:
bool b_statusbarVisible;
#ifdef _WIN32
+ HWND WinId();
HIMAGELIST himl;
ITaskbarList3 *p_taskbl;
UINT taskbar_wmsg;
diff --git a/modules/gui/qt4/main_interface_win32.cpp b/modules/gui/qt4/main_interface_win32.cpp
index e49f256..4c0dca2 100644
--- a/modules/gui/qt4/main_interface_win32.cpp
+++ b/modules/gui/qt4/main_interface_win32.cpp
@@ -31,6 +31,12 @@
#include <QBitmap>
#include <vlc_windows_interfaces.h>
+#if defined(_WIN32) && QT_VERSION >= 0x050000
+#include <QWindow>
+#include <qpa/qplatformnativeinterface.h>
+#endif
+
+
#define WM_APPCOMMAND 0x0319
#define APPCOMMAND_VOLUME_MUTE 8
@@ -72,6 +78,34 @@
#define GET_FLAGS_LPARAM(lParam) (LOWORD(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()
{
/*Here is the code for the taskbar thumb buttons
@@ -104,13 +138,13 @@ void MainInterface::createTaskBarButtons()
QBitmap mask3 = img3.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" );
- 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" );
- 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" );
- 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" );
}
@@ -134,12 +168,12 @@ void MainInterface::createTaskBarButtons()
thbButtons[2].iBitmap = 3;
thbButtons[2].dwFlags = THBF_HIDDEN;
- HRESULT hr = p_taskbl->ThumbBarSetImageList(winId(), himl );
+ HRESULT hr = p_taskbl->ThumbBarSetImageList(WinId(), himl );
if(S_OK != hr)
msg_Err( p_intf, "ThumbBarSetImageList failed with error %08lx", hr );
else
{
- hr = p_taskbl->ThumbBarAddButtons(winId(), 3, thbButtons);
+ hr = p_taskbl->ThumbBarAddButtons(WinId(), 3, thbButtons);
if(S_OK != hr)
msg_Err( p_intf, "ThumbBarAddButtons failed with error %08lx", hr );
}
@@ -299,7 +333,7 @@ void MainInterface::changeThumbbarButtons( int i_status )
default:
return;
}
- HRESULT hr = p_taskbl->ThumbBarUpdateButtons(this->winId(), 3, thbButtons);
+ HRESULT hr = p_taskbl->ThumbBarUpdateButtons(WinId(), 3, thbButtons);
if(S_OK != hr)
msg_Err( p_intf, "ThumbBarUpdateButtons failed with error %08lx", hr );
}
diff --git a/modules/gui/qt4/qt4.cpp b/modules/gui/qt4/qt4.cpp
index a35d112..9cb0b35 100644
--- a/modules/gui/qt4/qt4.cpp
+++ b/modules/gui/qt4/qt4.cpp
@@ -51,8 +51,14 @@
#ifdef _WIN32 /* For static builds */
#include <QtPlugin>
- Q_IMPORT_PLUGIN(qjpeg)
- Q_IMPORT_PLUGIN(qtaccessiblewidgets)
+ #if QT_VERSION >= 0x050000
+ Q_IMPORT_PLUGIN(QWindowsIntegrationPlugin)
+ Q_IMPORT_PLUGIN(QJpegPlugin)
+ Q_IMPORT_PLUGIN(AccessibleFactory)
+ #else
+ Q_IMPORT_PLUGIN(qjpeg)
+ Q_IMPORT_PLUGIN(qtaccessiblewidgets)
+ #endif
#endif
/*****************************************************************************
More information about the vlc-commits
mailing list