diff --git a/inc/lektor/queue.h b/inc/lektor/queue.h index f1deec241b160d3795802bf23cd41f3bb18544a7..d70dbc37a6496867a99fc5aeba220656cf51c157 100644 --- a/inc/lektor/queue.h +++ b/inc/lektor/queue.h @@ -23,9 +23,9 @@ enum { }; #if defined(__cplusplus) -#define CAST_LKT_EVENT(i) reinterpret_cast<void*>(static_cast<size_t>(i)) +#define CAST_LKT_EVENT(i) reinterpret_cast<void *>(static_cast<size_t>(i)) #else -#define CAST_LKT_EVENT(i) ((void*)(size_t)i) +#define CAST_LKT_EVENT(i) ((void *)(size_t)i) #endif #define LKT_PLAY_STOP CAST_LKT_EVENT(__LKT_PLAY_STOP) #define LKT_PLAY_PLAY CAST_LKT_EVENT(__LKT_PLAY_PLAY) diff --git a/src/module/module_qt_window.cc b/src/module/module_qt_window.cc index 514d6c31cdf4a8803b67299d4d8e4dc3cbf18b25..7b78f826f5ecfffb3899886d7ad520a1a9110a36 100644 --- a/src/module/module_qt_window.cc +++ b/src/module/module_qt_window.cc @@ -196,9 +196,9 @@ module_qt_window_new(struct module_qt_window_s **win, struct queue *queue, lkt_d RETURN_UNLESS(*win, "Out of memory", false); memset(*win, 0, sizeof(struct module_qt_window_s)); - (*win)->queue = queue; - (*win)->db = db; - (*win)->reg = qt_window_reg; + (*win)->queue = queue; + (*win)->db = db; + (*win)->reg = qt_window_reg; arg = LKT_ALLOC_STRUCT(poller_thread_arg); RETURN_UNLESS(arg, "Out of memory", false); diff --git a/src/module/qt_window/mainwindow.cc b/src/module/qt_window/mainwindow.cc index 05d0a88e3ea0ac738590887eb32c18a758cd6b1c..01b6a280300f350268b9f49799339ba778e86641 100644 --- a/src/module/qt_window/mainwindow.cc +++ b/src/module/qt_window/mainwindow.cc @@ -8,14 +8,19 @@ MainWindow::MainWindow(struct module_qt_window_s *qt_window, QWidget *parent) setCentralWidget(qt_window->mpv_widget); setFocusPolicy(Qt::StrongFocus); - connect(this, &MainWindow::emitCloseMpv, this, &MainWindow::__closeMpv, Qt::BlockingQueuedConnection); + connect(this, &MainWindow::emitCloseMpv, this, &MainWindow::__closeMpv, + Qt::BlockingQueuedConnection); } -void MainWindow::closeMpv(bool* exited) noexcept { +void +MainWindow::closeMpv(bool *exited) noexcept +{ emit emitCloseMpv(exited); } -void MainWindow::__closeMpv(bool* exited){ +void +MainWindow::__closeMpv(bool *exited) +{ delete centralWidget(); *exited = true; } diff --git a/src/module/qt_window/mainwindow.hh b/src/module/qt_window/mainwindow.hh index 4d15fb87ce377a8b361bf6d3c908ddf0ce26393c..6af91748641442cfbc7bbd491f175c4d7b0d931f 100644 --- a/src/module/qt_window/mainwindow.hh +++ b/src/module/qt_window/mainwindow.hh @@ -12,16 +12,14 @@ public: explicit MainWindow(struct module_qt_window_s *qt_window, QWidget *parent = nullptr); public slots: - inline void updateWindowTitle(QString str) noexcept { - setWindowTitle(str); - } + inline void updateWindowTitle(QString str) noexcept { setWindowTitle(str); } signals: - void emitCloseMpv(bool*); + void emitCloseMpv(bool *); private slots: - void __closeMpv(bool*); + void __closeMpv(bool *); public: - void closeMpv(bool*) noexcept; + void closeMpv(bool *) noexcept; }; diff --git a/src/module/qt_window/mpvwidget.cc b/src/module/qt_window/mpvwidget.cc index 443a8654e08cc52065db0163a84f82be4c40515f..3a850fe15253cdd452ab869bbe75863894f7682f 100644 --- a/src/module/qt_window/mpvwidget.cc +++ b/src/module/qt_window/mpvwidget.cc @@ -131,12 +131,8 @@ MpvWidget::handle_mpv_event(mpv_event *event) (void)prop; switch (event->event_id) { - case MPV_EVENT_PAUSE: - lkt_queue_send(m_queue, LKT_EVENT_PLAY_TOGGLE, LKT_PLAY_PAUSE); - break; - case MPV_EVENT_UNPAUSE: - lkt_queue_send(m_queue, LKT_EVENT_PLAY_TOGGLE, LKT_PLAY_PLAY); - break; + case MPV_EVENT_PAUSE: lkt_queue_send(m_queue, LKT_EVENT_PLAY_TOGGLE, LKT_PLAY_PAUSE); break; + case MPV_EVENT_UNPAUSE: lkt_queue_send(m_queue, LKT_EVENT_PLAY_TOGGLE, LKT_PLAY_PLAY); break; case MPV_EVENT_SHUTDOWN: lkt_queue_send(m_queue, LKT_EVENT_PLAY_TOGGLE, LKT_PLAY_STOP); @@ -157,11 +153,11 @@ MpvWidget::handle_mpv_event(mpv_event *event) prop = static_cast<mpv_event_property *>(event->data); if (strcmp(prop->name, "time-pos") == 0) { if (prop->format == MPV_FORMAT_DOUBLE) { - m_position = static_cast<int>(*reinterpret_cast<double*>(prop->data)); + m_position = static_cast<int>(*reinterpret_cast<double *>(prop->data)); } } else if (strcmp(prop->name, "duration") == 0) { if (prop->format == MPV_FORMAT_DOUBLE) { - m_duration = static_cast<int>(*reinterpret_cast<double*>(prop->data)); + m_duration = static_cast<int>(*reinterpret_cast<double *>(prop->data)); } } break; @@ -191,8 +187,7 @@ MpvWidget::handle_mpv_event(mpv_event *event) case MPV_EVENT_CHAPTER_CHANGE: case MPV_EVENT_PLAYBACK_RESTART: case MPV_EVENT_QUEUE_OVERFLOW: - case MPV_EVENT_HOOK: - break; + case MPV_EVENT_HOOK: break; } } @@ -240,7 +235,7 @@ MpvWidget::get_duration(int UNUSED *dur_sec) bool MpvWidget::set_paused(int paused) { - const char *cmd[] = {"set", "pause", paused == 1 ? "yes" : "no", nullptr}; + const char *cmd[] = { "set", "pause", paused == 1 ? "yes" : "no", nullptr }; mpv_command_async(mpv, 0, cmd); return true; } @@ -261,7 +256,7 @@ bool MpvWidget::load_file(const char *filepath) { const bool ret = !lmpv_load_file(mpv, filepath); - m_inhib = true; + m_inhib = true; if (ret) { LOG_DEBUG("WINDOW", "Loaded file: %s", filepath); @@ -296,65 +291,51 @@ MpvWidget::update_window_title() bool MpvWidget::toggle_pause() { - const char *cmd[] = {"cycle", "pause", nullptr}; + const char *cmd[] = { "cycle", "pause", nullptr }; mpv_command_async(mpv, 0, cmd); return true; } -#define MPV_SEND_COMMAND_ASYNC( ... ) \ - { \ - const char *cmd[] = { __VA_ARGS__ }; \ - mpv_command_async(mpv, 0, cmd); \ - break; \ +#define MPV_SEND_COMMAND_ASYNC(...) \ + { \ + const char *cmd[] = { __VA_ARGS__ }; \ + mpv_command_async(mpv, 0, cmd); \ + break; \ } void -MpvWidget::keyPressEvent(QKeyEvent* event) +MpvWidget::keyPressEvent(QKeyEvent *event) { - switch(event->modifiers()){ + switch (event->modifiers()) { /* SHIFTED */ case Qt::ShiftModifier: - switch(event->key()){ - case Qt::Key_J: - MPV_SEND_COMMAND_ASYNC("osd-msg", "cycle", "sub", nullptr); - case Qt::Key_Period: - MPV_SEND_COMMAND_ASYNC("osd-msg","frame-step", nullptr); - case Qt::Key_Z: - MPV_SEND_COMMAND_ASYNC("osd-msg", "add", "sub-delay", "+0.1", nullptr); - case Qt::Key_G: - MPV_SEND_COMMAND_ASYNC("osd-msg", "add", "sub-scale", "+0.1", nullptr); - case Qt::Key_F: - MPV_SEND_COMMAND_ASYNC("osd-msg", "add", "sub-scale", "-0.1", nullptr); + switch (event->key()) { + case Qt::Key_J: MPV_SEND_COMMAND_ASYNC("osd-msg", "cycle", "sub", nullptr); + case Qt::Key_Period: MPV_SEND_COMMAND_ASYNC("osd-msg", "frame-step", nullptr); + case Qt::Key_Z: MPV_SEND_COMMAND_ASYNC("osd-msg", "add", "sub-delay", "+0.1", nullptr); + case Qt::Key_G: MPV_SEND_COMMAND_ASYNC("osd-msg", "add", "sub-scale", "+0.1", nullptr); + case Qt::Key_F: MPV_SEND_COMMAND_ASYNC("osd-msg", "add", "sub-scale", "-0.1", nullptr); } break; - /* UN-SHIFTED */ default: - switch(event->key()){ + switch (event->key()) { /* Playback */ case Qt::Key_Space: lmpv_toggle_pause(mpv); //lkt_queue_send(m_queue, LKT_EVENT_PLAY_TOGGLE, LKT_PLAY_TOGGLE); break; case Qt::Key_Return: - case Qt::Key_Greater: - lkt_queue_send(m_queue, LKT_EVENT_PLAY_NEXT, nullptr); - break; - case Qt::Key_Less: - lkt_queue_send(m_queue, LKT_EVENT_PLAY_PREV, nullptr); - break; - case Qt::Key_Left: - MPV_SEND_COMMAND_ASYNC("osd-msg-bar", "seek", "-5", "relative", nullptr); + case Qt::Key_Greater: lkt_queue_send(m_queue, LKT_EVENT_PLAY_NEXT, nullptr); break; + case Qt::Key_Less: lkt_queue_send(m_queue, LKT_EVENT_PLAY_PREV, nullptr); break; + case Qt::Key_Left: MPV_SEND_COMMAND_ASYNC("osd-msg-bar", "seek", "-5", "relative", nullptr); case Qt::Key_Right: MPV_SEND_COMMAND_ASYNC("osd-msg-bar", "seek", "+5", "relative", nullptr); case Qt::Key_Down: MPV_SEND_COMMAND_ASYNC("osd-msg-bar", "seek", "-60", "relative", nullptr); - case Qt::Key_Up: - MPV_SEND_COMMAND_ASYNC("osd-msg-bar", "seek", "+60", "relative", nullptr); - case Qt::Key_L: - MPV_SEND_COMMAND_ASYNC("osd-msg", "ab-loop", nullptr); - case Qt::Key_O: - MPV_SEND_COMMAND_ASYNC("osd-msg-bar", "show-progress", nullptr); + case Qt::Key_Up: MPV_SEND_COMMAND_ASYNC("osd-msg-bar", "seek", "+60", "relative", nullptr); + case Qt::Key_L: MPV_SEND_COMMAND_ASYNC("osd-msg", "ab-loop", nullptr); + case Qt::Key_O: MPV_SEND_COMMAND_ASYNC("osd-msg-bar", "show-progress", nullptr); case Qt::Key_BracketLeft: MPV_SEND_COMMAND_ASYNC("osd-msg", "multiply", "speed", "1/1.1", nullptr); case Qt::Key_BracketRight: @@ -363,33 +344,24 @@ MpvWidget::keyPressEvent(QKeyEvent* event) MPV_SEND_COMMAND_ASYNC("osd-msg", "multiply", "speed", "0.5", nullptr); case Qt::Key_BraceRight: MPV_SEND_COMMAND_ASYNC("osd-msg", "multiply", "speed", "2", nullptr); - case Qt::Key_Backspace: - MPV_SEND_COMMAND_ASYNC("osd-msg", "set", "speed", "1.0", nullptr); - case Qt::Key_Semicolon: - MPV_SEND_COMMAND_ASYNC("osd-msg","frame-step", nullptr); - case Qt::Key_Comma: - MPV_SEND_COMMAND_ASYNC("osd-msg","frame-back-step", nullptr); + case Qt::Key_Backspace: MPV_SEND_COMMAND_ASYNC("osd-msg", "set", "speed", "1.0", nullptr); + case Qt::Key_Semicolon: MPV_SEND_COMMAND_ASYNC("osd-msg", "frame-step", nullptr); + case Qt::Key_Comma: MPV_SEND_COMMAND_ASYNC("osd-msg", "frame-back-step", nullptr); /* Track management */ - case Qt::Key_NumberSign: - MPV_SEND_COMMAND_ASYNC("osd-msg", "cycle", "audio", nullptr); - 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); + case Qt::Key_NumberSign: MPV_SEND_COMMAND_ASYNC("osd-msg", "cycle", "audio", nullptr); + 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); /* Misc */ - case Qt::Key_I: - MPV_SEND_COMMAND_ASYNC("script-binding", "stats/display-stats", nullptr); + 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_M: - MPV_SEND_COMMAND_ASYNC("osd-msg", "cycle", "mute", nullptr); + 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_M: MPV_SEND_COMMAND_ASYNC("osd-msg", "cycle", "mute", nullptr); - default: - break; + default: break; } return QOpenGLWidget::keyPressEvent(event); } diff --git a/src/module/qt_window/mpvwidget.hh b/src/module/qt_window/mpvwidget.hh index ff54773ce194b6f2181194b8abf01f8d6b6a364b..9131b61cec4084a9a6b21c5a5041fe584b2e46af 100644 --- a/src/module/qt_window/mpvwidget.hh +++ b/src/module/qt_window/mpvwidget.hh @@ -38,10 +38,10 @@ private: int m_position; int m_duration; bool m_oscVisible = false; - bool m_inhib = false; + bool m_inhib = false; protected: - void keyPressEvent(QKeyEvent* event); + void keyPressEvent(QKeyEvent *event); public: bool get_elapsed(int *);