diff --git a/src/module/qt_window/mpvwidget.cc b/src/module/qt_window/mpvwidget.cc index 22c50cc8c7464287e9e50701461aedb6ac59a277..c835cc820e2894304b44f412eb46d7b72c52fbc8 100644 --- a/src/module/qt_window/mpvwidget.cc +++ b/src/module/qt_window/mpvwidget.cc @@ -113,6 +113,17 @@ MpvWidget::paintGL() mpv_render_context_render(mpv_gl, params); } +void +MpvWidget::toggle_fullscreen() +{ + if (window()->isFullScreen()) { + was_maximized ? window()->showMaximized() : window()->showNormal(); + } else { + was_maximized = window()->isMaximized(); + window()->showFullScreen(); + } +} + void MpvWidget::on_mpv_events() { @@ -396,12 +407,18 @@ MpvWidget::keyPressEvent(QKeyEvent *event) case Qt::Key_J: MPV_SEND_COMMAND_ASYNC("osd-msg", "cycle", "sub", "down", nullptr); case Qt::Key_Underscore: MPV_SEND_COMMAND_ASYNC("osd-msg", "cycle", "video", nullptr); + /* Window management */ + case Qt::Key_F: + toggle_fullscreen(); + break; + /* Misc */ case Qt::Key_I: MPV_SEND_COMMAND_ASYNC("script-binding", "stats/display-stats", nullptr); case Qt::Key_Delete: MPV_SEND_COMMAND_ASYNC("script-message", "osc-visibility", (m_oscVisible = !m_oscVisible) ? "always" : "never", nullptr); case Qt::Key_Z: MPV_SEND_COMMAND_ASYNC("osd-msg", "add", "sub-delay", "-0.1", nullptr); + case Qt::Key_X: MPV_SEND_COMMAND_ASYNC("osd-msg", "add", "sub-delay", "+0.1", nullptr); case Qt::Key_M: MPV_SEND_COMMAND_ASYNC("osd-msg", "cycle", "mute", nullptr); default: break; @@ -409,3 +426,12 @@ MpvWidget::keyPressEvent(QKeyEvent *event) return QOpenGLWidget::keyPressEvent(event); } } + +void +MpvWidget::mouseDoubleClickEvent(QMouseEvent *event) +{ + if (event->button() == Qt::LeftButton) + { + toggle_fullscreen(); + } +} diff --git a/src/module/qt_window/mpvwidget.hh b/src/module/qt_window/mpvwidget.hh index 31a5b1b7e8af961fe3617184d430b7e8838b1cc5..48eb977a5c679739b4144abc7934b3a54ad86b7a 100644 --- a/src/module/qt_window/mpvwidget.hh +++ b/src/module/qt_window/mpvwidget.hh @@ -33,6 +33,7 @@ public: private: enum { PLAY, PAUSE, STOP, NONSTOPPED } m_state = STOP; + bool was_maximized = false; queue *m_queue; lkt_db *m_db; @@ -46,6 +47,7 @@ private: protected: void keyPressEvent(QKeyEvent *event); + void mouseDoubleClickEvent(QMouseEvent *event); public: bool get_elapsed(int *); @@ -55,6 +57,7 @@ public: bool set_position(int); bool load_file(const char *); bool toggle_pause(); + void toggle_fullscreen(); bool stop(); private: