Commit 2c8fd86a authored by Hugo Beauzée-Luyssen's avatar Hugo Beauzée-Luyssen

qt: Make main_interface_win32 a subclass of main_interface

parent 9841b74f
......@@ -120,7 +120,7 @@ libqt_plugin_la_SOURCES = \
util/singleton.hpp \
styles/seekstyle.cpp styles/seekstyle.hpp
if HAVE_WIN32
libqt_plugin_la_SOURCES += main_interface_win32.cpp
libqt_plugin_la_SOURCES += main_interface_win32.cpp main_interface_win32.hpp
endif
# Meta-object compilation
......@@ -207,6 +207,10 @@ nodist_libqt_plugin_la_SOURCES = \
util/buttons/BrowseButton.moc.cpp \
styles/seekstyle.moc.cpp
if HAVE_WIN32
nodist_libqt_plugin_la_SOURCES += main_interface_win32.moc.cpp
endif
nodist_libqt_plugin_la_SOURCES += \
ui/equalizer.h \
ui/video_effects.h \
......
......@@ -65,12 +65,6 @@
#include <vlc_keys.h> /* Wheel event */
#include <vlc_vout_display.h> /* vout_thread_t and VOUT_ events */
#if defined(_WIN32) && HAS_QT5
#include <QWindow>
#include <qpa/qplatformnativeinterface.h>
#endif
// #define DEBUG_INTF
/* Callback prototypes */
......@@ -143,11 +137,6 @@ MainInterface::MainInterface( intf_thread_t *_p_intf ) : QVLCMW( _p_intf )
/* Set the other interface settings */
settings = getSettings();
#ifdef _WIN32
/* Volume keys */
p_intf->p_sys->disable_volume_keys = var_InheritBool( p_intf, "qt-disable-volume-keys" );
#endif
/* */
b_plDocked = getSettings()->value( "MainWindow/pl-dock-status", true ).toBool();
......@@ -172,14 +161,6 @@ MainInterface::MainInterface( intf_thread_t *_p_intf ) : QVLCMW( _p_intf )
createStatusBar();
setStatusBarVisibility( getSettings()->value( "MainWindow/status-bar-visible", false ).toBool() );
#ifdef _WIN32
himl = NULL;
p_taskbl = NULL;
taskbar_wmsg = RegisterWindowMessage(TEXT("TaskbarButtonCreated"));
if (taskbar_wmsg == 0)
msg_Warn( p_intf, "Failed to register TaskbarButtonCreated message" );
#endif
/*********************************
* Create the Systray Management *
*********************************/
......@@ -278,14 +259,6 @@ MainInterface::~MainInterface()
if( videoWidget )
releaseVideoSlot();
#ifdef _WIN32
if( himl )
ImageList_Destroy( himl );
if(p_taskbl)
p_taskbl->Release();
CoUninitialize();
#endif
/* Be sure to kill the actionsManager... Only used in the MI and control */
ActionsManager::killInstance();
......@@ -362,9 +335,6 @@ void MainInterface::reloadPrefs()
{
i_notificationSetting = var_InheritInteger( p_intf, "qt-notification" );
b_pauseOnMinimize = var_InheritBool( p_intf, "qt-pause-minimized" );
#ifdef _WIN32
p_intf->p_sys->disable_volume_keys = var_InheritBool( p_intf, "qt-disable-volume-keys" );
#endif
if( !var_InheritBool( p_intf, "qt-fs-controller" ) && fullscreenControls )
{
delete fullscreenControls;
......@@ -864,9 +834,6 @@ void MainInterface::setVideoFullScreen( bool fs )
* qt-fullscreen-screennumber is forced) */
setMinimalView( b_minimalView );
setInterfaceFullScreen( b_interfaceFullScreen );
#ifdef _WIN32
changeThumbbarButtons( THEMIM->getIM()->playingStatus() );
#endif
}
videoWidget->sync();
}
......@@ -1257,6 +1224,11 @@ void MainInterface::createSystray()
this, updateSystrayTooltipStatus( int ) );
}
void MainInterface::toggleUpdateSystrayMenuWhenVisible()
{
hide();
}
/**
* Updates the Systray Icon's menu and toggle the main interface
*/
......@@ -1277,38 +1249,7 @@ void MainInterface::toggleUpdateSystrayMenu()
else
{
/* Visible (possibly under other windows) */
#ifdef _WIN32
/* 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 HAS_QT5
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( winId, GW_HWNDPREV );
hwnd && ( !IsWindowVisible( hwnd ) ||
( GetWindowInfo( hwnd, &wi ) &&
(wi.dwExStyle&WS_EX_NOACTIVATE) ) );
hwnd = GetNextWindow( hwnd, GW_HWNDPREV ) );
if( !hwnd || !GetWindowInfo( hwnd, &wi ) ||
(wi.dwExStyle&WS_EX_TOPMOST) )
{
hide();
}
else
{
activateWindow();
}
#else
hide();
#endif // _WIN32
toggleUpdateSystrayMenuWhenVisible();
}
if( sysTray )
VLCMenuBar::updateSystrayMenu( this, p_intf );
......
......@@ -92,12 +92,6 @@ public:
protected:
void dropEventPlay( QDropEvent* event, bool b_play ) { dropEventPlay(event, b_play, true); }
void dropEventPlay( QDropEvent *, bool, bool );
#ifdef _WIN32
#if HAS_QT5
virtual bool nativeEvent(const QByteArray &eventType, void *message, long *result);
#endif
virtual bool winEvent( MSG *, long * );
#endif
void changeEvent( QEvent * ) Q_DECL_OVERRIDE;
void dropEvent( QDropEvent *) Q_DECL_OVERRIDE;
void dragEnterEvent( QDragEnterEvent * ) Q_DECL_OVERRIDE;
......@@ -107,8 +101,9 @@ protected:
void keyPressEvent( QKeyEvent *) Q_DECL_OVERRIDE;
void wheelEvent( QWheelEvent * ) Q_DECL_OVERRIDE;
bool eventFilter(QObject *, QEvent *) Q_DECL_OVERRIDE;
virtual void toggleUpdateSystrayMenuWhenVisible();
private:
protected:
/* Main Widgets Creation */
void createMainWidget( QSettings* );
void createStatusBar();
......@@ -184,14 +179,6 @@ private:
bool b_hasPausedWhenMinimized;
bool b_statusbarVisible;
#ifdef _WIN32
HWND WinId( QWidget *);
HIMAGELIST himl;
ITaskbarList3 *p_taskbl;
UINT taskbar_wmsg;
void createTaskBarButtons();
#endif
static const Qt::Key kc[10]; /* easter eggs */
int i_kc_offset;
......@@ -209,12 +196,6 @@ public slots:
void setStatusBarVisibility(bool b_visible);
void setPlaylistVisibility(bool b_visible);
#ifdef _WIN32
void changeThumbbarButtons( int );
void playlistItemAppended( int itemId, int parentId );
void playlistItemRemoved( int itemId );
#endif
/* Manage the Video Functions from the vout threads */
void getVideoSlot( WId *p_id, struct vout_window_t *,
unsigned *pi_width, unsigned *pi_height, bool );
......@@ -223,10 +204,10 @@ public slots:
void emitBoss();
void emitRaise();
void reloadPrefs();
virtual void reloadPrefs();
void toolBarConfUpdated();
private slots:
protected slots:
void debug();
void recreateToolbars();
void setName( const QString& );
......@@ -259,7 +240,7 @@ private slots:
void setVideoSize( unsigned int, unsigned int );
void videoSizeChanged( int, int );
void setVideoFullScreen( bool );
virtual void setVideoFullScreen( bool );
void setHideMouse( bool );
void setVideoOnTop( bool );
void setBoss();
......
......@@ -5,6 +5,7 @@
* $Id$
*
* Authors: Jean-Baptiste Kempf <jb@videolan.org>
* Hugo Beauzée-Luyssen <hugo@beauzee.fr>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
......@@ -21,8 +22,11 @@
* 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
*****************************************************************************/
#if HAVE_CONFIG_H
# include "config.h"
#endif
#include "main_interface.hpp"
#include "main_interface_win32.hpp"
#include "input_manager.hpp"
#include "actions_manager.hpp"
......@@ -38,7 +42,6 @@
# include <qpa/qplatformnativeinterface.h>
#endif
#define WM_APPCOMMAND 0x0319
#define APPCOMMAND_VOLUME_MUTE 8
......@@ -80,7 +83,28 @@
#define GET_FLAGS_LPARAM(lParam) (LOWORD(lParam))
#define GET_KEYSTATE_LPARAM(lParam) GET_FLAGS_LPARAM(lParam)
HWND MainInterface::WinId( QWidget *w )
MainInterfaceWin32::MainInterfaceWin32( intf_thread_t *_p_intf )
: MainInterface( _p_intf )
, himl( NULL )
, p_taskbl( NULL )
{
/* Volume keys */
_p_intf->p_sys->disable_volume_keys = var_InheritBool( _p_intf, "qt-disable-volume-keys" );
taskbar_wmsg = RegisterWindowMessage(TEXT("TaskbarButtonCreated"));
if (taskbar_wmsg == 0)
msg_Warn( p_intf, "Failed to register TaskbarButtonCreated message" );
}
MainInterfaceWin32::~MainInterfaceWin32()
{
if( himl )
ImageList_Destroy( himl );
if(p_taskbl)
p_taskbl->Release();
CoUninitialize();
}
HWND MainInterfaceWin32::WinId( QWidget *w )
{
#if HAS_QT5
if( w && w->windowHandle() )
......@@ -109,7 +133,7 @@ enum HBitmapFormat
};
#endif
void MainInterface::createTaskBarButtons()
void MainInterfaceWin32::createTaskBarButtons()
{
/*Here is the code for the taskbar thumb buttons
FIXME:We need pretty buttons in 16x16 px that are handled correctly by masks in Qt
......@@ -203,13 +227,13 @@ void MainInterface::createTaskBarButtons()
}
#if HAS_QT5
bool MainInterface::nativeEvent(const QByteArray &, void *message, long *result)
bool MainInterfaceWin32::nativeEvent(const QByteArray &, void *message, long *result)
{
return winEvent( static_cast<MSG*>( message ), result );
}
#endif
bool MainInterface::winEvent ( MSG * msg, long * result )
bool MainInterfaceWin32::winEvent ( MSG * msg, long * result )
{
if (msg->message == taskbar_wmsg)
{
......@@ -307,17 +331,58 @@ bool MainInterface::winEvent ( MSG * msg, long * result )
return false;
}
void MainInterface::playlistItemAppended( int, int )
void MainInterfaceWin32::setVideoFullScreen( bool fs )
{
MainInterface::setVideoFullScreen( fs );
if( !fs )
changeThumbbarButtons( THEMIM->getIM()->playingStatus() );
}
void MainInterfaceWin32::toggleUpdateSystrayMenuWhenVisible()
{
/* 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 HAS_QT5
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( winId, GW_HWNDPREV );
hwnd && ( !IsWindowVisible( hwnd ) || ( GetWindowInfo( hwnd, &wi ) &&
( wi.dwExStyle&WS_EX_NOACTIVATE ) ) );
hwnd = GetNextWindow( hwnd, GW_HWNDPREV ) )
{
}
if( !hwnd || !GetWindowInfo( hwnd, &wi ) || (wi.dwExStyle&WS_EX_TOPMOST) )
hide();
else
activateWindow();
}
void MainInterfaceWin32::reloadPrefs()
{
p_intf->p_sys->disable_volume_keys = var_InheritBool( p_intf, "qt-disable-volume-keys" );
MainInterface::reloadPrefs();
}
void MainInterfaceWin32::playlistItemAppended( int, int )
{
changeThumbbarButtons( THEMIM->getIM()->playingStatus() );
}
void MainInterface::playlistItemRemoved( int )
void MainInterfaceWin32::playlistItemRemoved( int )
{
changeThumbbarButtons( THEMIM->getIM()->playingStatus() );
}
void MainInterface::changeThumbbarButtons( int i_status )
void MainInterfaceWin32::changeThumbbarButtons( int i_status )
{
if( p_taskbl == NULL )
return;
......
/*****************************************************************************
* main_interface_win32.cpp : Main interface
****************************************************************************
* Copyright (C) 2006-2010 VideoLAN and AUTHORS
* $Id$
*
* Authors: Jean-Baptiste Kempf <jb@videolan.org>
* Hugo Beauzée-Luyssen <hugo@beauzee.fr>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
*****************************************************************************/
#ifndef MAIN_INTERFACE_WIN32_HPP
#define MAIN_INTERFACE_WIN32_HPP
#include "main_interface.hpp"
class MainInterfaceWin32 : public MainInterface
{
Q_OBJECT
public:
MainInterfaceWin32( intf_thread_t *p_intf );
virtual ~MainInterfaceWin32();
private:
#if HAS_QT5
virtual bool nativeEvent(const QByteArray &eventType, void *message, long *result) Q_DECL_OVERRIDE;
#endif
virtual bool winEvent( MSG *, long * );
virtual void toggleUpdateSystrayMenuWhenVisible() Q_DECL_OVERRIDE;
private:
HWND WinId( QWidget *);
void createTaskBarButtons();
private:
HIMAGELIST himl;
ITaskbarList3 *p_taskbl;
UINT taskbar_wmsg;
private slots:
void changeThumbbarButtons( int );
void playlistItemAppended( int itemId, int parentId );
void playlistItemRemoved( int itemId );
virtual void reloadPrefs() Q_DECL_OVERRIDE;
virtual void setVideoFullScreen( bool fs ) Q_DECL_OVERRIDE;
};
#endif // MAIN_INTERFACE_WIN32_HPP
......@@ -36,7 +36,11 @@
#include "input_manager.hpp" /* THEMIM destruction */
#include "dialogs_provider.hpp" /* THEDP creation */
#include "main_interface.hpp" /* MainInterface creation */
#ifdef _WIN32
# include "main_interface_win32.hpp"
#else
# include "main_interface.hpp" /* MainInterface creation */
#endif
#include "extensions_manager.hpp" /* Extensions manager */
#include "managers/addons_manager.hpp" /* Addons manager */
#include "dialogs/help.hpp" /* Launch Update */
......@@ -574,7 +578,11 @@ static void *ThreadPlatform( void *obj, char *platform_name )
if( !p_sys->b_isDialogProvider )
{
#ifdef _WIN32
p_mi = new MainInterfaceWin32( p_intf );
#else
p_mi = new MainInterface( p_intf );
#endif
p_sys->p_mi = p_mi;
/* Check window type from the Qt platform back-end */
......
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