Skip to content

Commit

Permalink
qt: support for Qt5 windows build
Browse files Browse the repository at this point in the history
  • Loading branch information
funman committed Mar 11, 2014
1 parent f00c837 commit 2c8bd7d
Show file tree
Hide file tree
Showing 4 changed files with 66 additions and 11 deletions.
18 changes: 16 additions & 2 deletions modules/gui/qt4/main_interface.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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 */
Expand Down Expand Up @@ -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) ) );
Expand All @@ -1121,7 +1135,7 @@ void MainInterface::toggleUpdateSystrayMenu()
}
#else
hide();
#endif
#endif // _WIN32
}
if( sysTray )
VLCMenuBar::updateSystrayMenu( this, p_intf );
Expand Down
1 change: 1 addition & 0 deletions modules/gui/qt4/main_interface.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -175,6 +175,7 @@ class MainInterface : public QVLCMW
bool b_statusbarVisible;

#ifdef _WIN32
HWND WinId();
HIMAGELIST himl;
ITaskbarList3 *p_taskbl;
UINT taskbar_wmsg;
Expand Down
48 changes: 41 additions & 7 deletions modules/gui/qt4/main_interface_win32.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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" );
}

Expand All @@ -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 );
}
Expand Down Expand Up @@ -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 );
}
10 changes: 8 additions & 2 deletions modules/gui/qt4/qt4.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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

/*****************************************************************************
Expand Down

0 comments on commit 2c8bd7d

Please sign in to comment.