vlc | branch: master | Pierre Lamot <[email protected]> | Tue Sep 1 16:31:55 2020 +0200| [37f0ca029f20137cf46e48e69e46a8c3acefe9e6] | committer: Pierre Lamot
qt: change interface scale on Ctrl+Wheel events > http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=37f0ca029f20137cf46e48e69e46a8c3acefe9e6 --- modules/gui/qt/maininterface/compositor_dcomp.cpp | 18 ++++++++++-------- .../qt/maininterface/interface_window_handler.cpp | 22 +++++++++++++++++++++- .../qt/maininterface/interface_window_handler.hpp | 1 + modules/gui/qt/maininterface/main_interface.cpp | 9 +++++++++ modules/gui/qt/maininterface/main_interface.hpp | 1 + 5 files changed, 42 insertions(+), 9 deletions(-) diff --git a/modules/gui/qt/maininterface/compositor_dcomp.cpp b/modules/gui/qt/maininterface/compositor_dcomp.cpp index 51e20f5d81..f459480447 100644 --- a/modules/gui/qt/maininterface/compositor_dcomp.cpp +++ b/modules/gui/qt/maininterface/compositor_dcomp.cpp @@ -207,14 +207,6 @@ MainInterface* CompositorDirectComposition::makeMainInterface() m_videoWindowHandler = std::make_unique<VideoWindowHandler>(m_intf, m_rootWindow); m_videoWindowHandler->setWindow( m_rootWindow->windowHandle() ); - m_interfaceWindowHandler = new InterfaceWindowHandlerWin32(m_intf, m_rootWindow, m_rootWindow->windowHandle(), m_rootWindow); - - m_qmlVideoSurfaceProvider = std::make_unique<VideoSurfaceProvider>(); - m_rootWindow->setVideoSurfaceProvider(m_qmlVideoSurfaceProvider.get()); - - connect(m_qmlVideoSurfaceProvider.get(), &VideoSurfaceProvider::hasVideoChanged, - m_interfaceWindowHandler, &InterfaceWindowHandlerWin32::onVideoEmbedChanged); - HR(m_dcompDevice->CreateTargetForHwnd((HWND)m_rootWindow->windowHandle()->winId(), TRUE, &m_dcompTarget), "create target"); HR(m_dcompDevice->CreateVisual(&m_rootVisual), "create root visual"); @@ -232,6 +224,16 @@ MainInterface* CompositorDirectComposition::makeMainInterface() return nullptr; } + //install the interface window handler after the creation of CompositorDCompositionUISurface + //so the event filter is handled before the one of the UISurface (for wheel events) + m_interfaceWindowHandler = new InterfaceWindowHandlerWin32(m_intf, m_rootWindow, m_rootWindow->window()->windowHandle(), m_rootWindow); + + m_qmlVideoSurfaceProvider = std::make_unique<VideoSurfaceProvider>(); + m_rootWindow->setVideoSurfaceProvider(m_qmlVideoSurfaceProvider.get()); + + connect(m_qmlVideoSurfaceProvider.get(), &VideoSurfaceProvider::hasVideoChanged, + m_interfaceWindowHandler, &InterfaceWindowHandlerWin32::onVideoEmbedChanged); + m_ui = std::make_unique<MainUI>(m_intf, m_rootWindow); ret = m_ui->setup(m_uiSurface->engine()); if (! ret) diff --git a/modules/gui/qt/maininterface/interface_window_handler.cpp b/modules/gui/qt/maininterface/interface_window_handler.cpp index e7bbbc86c3..084d0b3a45 100644 --- a/modules/gui/qt/maininterface/interface_window_handler.cpp +++ b/modules/gui/qt/maininterface/interface_window_handler.cpp @@ -72,6 +72,9 @@ InterfaceWindowHandler::InterfaceWindowHandler(intf_thread_t *_p_intf, MainInter connect( m_mainInterface, &MainInterface::setInterfaceVisibible, this, &InterfaceWindowHandler::setInterfaceVisible); + connect(this, &InterfaceWindowHandler::incrementIntfUserScaleFactor, + m_mainInterface, &MainInterface::incrementIntfUserScaleFactor); + m_window->installEventFilter(this); } @@ -84,7 +87,9 @@ InterfaceWindowHandler::~InterfaceWindowHandler() bool InterfaceWindowHandler::eventFilter(QObject*, QEvent* event) { - if( event->type() == QEvent::WindowStateChange ) + switch ( event->type() ) + { + case QEvent::WindowStateChange: { QWindowStateChangeEvent *windowStateChangeEvent = static_cast<QWindowStateChangeEvent*>(event); Qt::WindowStates newState = m_window->windowStates(); @@ -130,6 +135,21 @@ bool InterfaceWindowHandler::eventFilter(QObject*, QEvent* event) THEMPL->play(); } } + break; + } + case QEvent::Wheel: + { + QWheelEvent* wheelEvent = static_cast<QWheelEvent*>(event); + if (wheelEvent->modifiers() == Qt::ControlModifier) + { + emit incrementIntfUserScaleFactor(wheelEvent->delta() > 0); + wheelEvent->accept(); + return true; + } + break; + } + default: + break; } return false; diff --git a/modules/gui/qt/maininterface/interface_window_handler.hpp b/modules/gui/qt/maininterface/interface_window_handler.hpp index dcb2f43680..e3f0a0255a 100644 --- a/modules/gui/qt/maininterface/interface_window_handler.hpp +++ b/modules/gui/qt/maininterface/interface_window_handler.hpp @@ -52,6 +52,7 @@ signals: void fullscreenInterfaceToggled( bool ); void interfaceAlwaysOnTopChanged(bool); void interfaceFullScreenChanged(bool); + void incrementIntfUserScaleFactor(bool increment); protected: intf_thread_t* p_intf = nullptr; diff --git a/modules/gui/qt/maininterface/main_interface.cpp b/modules/gui/qt/maininterface/main_interface.cpp index 6850dd0882..4c714bf559 100644 --- a/modules/gui/qt/maininterface/main_interface.cpp +++ b/modules/gui/qt/maininterface/main_interface.cpp @@ -304,6 +304,15 @@ void MainInterface::updateIntfScaleFactor() emit intfScaleFactorChanged(); } +void MainInterface::incrementIntfUserScaleFactor(bool increment) +{ + if (increment) + m_intfUserScaleFactor = std::min(m_intfUserScaleFactor + 0.1, 3.0); + else + m_intfUserScaleFactor = std::max(m_intfUserScaleFactor - 0.1, 0.3); + updateIntfScaleFactor(); +} + inline void MainInterface::initSystray() { bool b_systrayAvailable = QSystemTrayIcon::isSystemTrayAvailable(); diff --git a/modules/gui/qt/maininterface/main_interface.hpp b/modules/gui/qt/maininterface/main_interface.hpp index b60b0c9014..5739af44ee 100644 --- a/modules/gui/qt/maininterface/main_interface.hpp +++ b/modules/gui/qt/maininterface/main_interface.hpp @@ -261,6 +261,7 @@ public slots: void setPlaylistWidthFactor( double ); void setInterfaceAlwaysOnTop( bool ); void setShowRemainingTime( bool ); + void incrementIntfUserScaleFactor( bool increment); void emitBoss(); void emitRaise(); _______________________________________________ vlc-commits mailing list [email protected] https://mailman.videolan.org/listinfo/vlc-commits
