[vlc-devel] [PATCH 1/5] qt: change interface scale on Ctrl+Wheel events
Pierre Lamot
pierre at videolabs.io
Tue Sep 1 18:33:27 CEST 2020
---
.../interface_window_handler.cpp | 22 ++++++++++++++++++-
.../interface_window_handler.hpp | 1 +
.../gui/qt/maininterface/main_interface.cpp | 9 ++++++++
.../gui/qt/maininterface/main_interface.hpp | 1 +
4 files changed, 32 insertions(+), 1 deletion(-)
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();
--
2.25.1
More information about the vlc-devel
mailing list