[libraries/mpvqt] src: mpvcontroller: add signals for more mpv events

George Florea Bănuș <[email protected]>
Newsgroups gmane.comp.kde.cvs
Message-ID <[email protected]>
Git commit 46fbdd87e876b46817991e7b7af840d8c54f9db4 by George Florea Bănuș.
Committed on 25/07/2026 at 09:43.
Pushed by georgefb into branch 'master'.

mpvcontroller: add signals for more mpv events

M  +42   -4    src/mpvcontroller.cpp
M  +8    -0    src/mpvcontroller.h

https://invent.kde.org/libraries/mpvqt/-/commit/46fbdd87e876b46817991e7b7af840d8c54f9db4

diff --git a/src/mpvcontroller.cpp b/src/mpvcontroller.cpp
index c243d83..6cc6983 100644
--- a/src/mpvcontroller.cpp
+++ b/src/mpvcontroller.cpp
@@ -291,19 +291,57 @@ void MpvController::eventHandler()
             Q_EMIT propertyChanged(QString::fromUtf8(prop->name), data);
             break;
         }
-        case MPV_EVENT_NONE:
         case MPV_EVENT_SHUTDOWN:
-        case MPV_EVENT_LOG_MESSAGE:
-        case MPV_EVENT_CLIENT_MESSAGE:
+            Q_EMIT shutdown();
+            break;
+        case MPV_EVENT_LOG_MESSAGE: {
+            mpv_event_log_message *logMessageEvent = static_cast<mpv_event_log_message *>(event->data);
+            if (logMessageEvent == nullptr) {
+                qDebug() << "MpvController::eventHandler MPV_EVENT_LOG_MESSAGE: logMessageEvent is nullptr";
+                break;
+            }
+            Q_EMIT logMessage(QString::fromUtf8(logMessageEvent->prefix), QString::fromUtf8(logMessageEvent->level), QString::fromUtf8(logMessageEvent->text));
+            break;
+        }
+        case MPV_EVENT_CLIENT_MESSAGE: {
+            mpv_event_client_message *clientMessageEvent = static_cast<mpv_event_client_message *>(event->data);
+            if (clientMessageEvent == nullptr) {
+                qDebug() << "MpvController::eventHandler MPV_EVENT_CLIENT_MESSAGE: clientMessageEvent is nullptr";
+                break;
+            }
+            QStringList args;
+            for (int i = 0; i < clientMessageEvent->num_args; i++) {
+                args.append(QString::fromUtf8(clientMessageEvent->args[i]));
+            }
+            Q_EMIT clientMessage(event->reply_userdata, args);
+            break;
+        }
         case MPV_EVENT_AUDIO_RECONFIG:
+            Q_EMIT audioReconfig();
+            break;
         case MPV_EVENT_SEEK:
+            Q_EMIT seek();
+            break;
         case MPV_EVENT_PLAYBACK_RESTART:
+            Q_EMIT playbackRestart();
+            break;
         case MPV_EVENT_QUEUE_OVERFLOW:
-        case MPV_EVENT_HOOK:
+            Q_EMIT queueOverflow();
+            break;
+        case MPV_EVENT_HOOK: {
+            mpv_event_hook *hookEvent = static_cast<mpv_event_hook *>(event->data);
+            if (hookEvent == nullptr) {
+                qDebug() << "MpvController::eventHandler MPV_EVENT_HOOK: hookEvent is nullptr";
+                break;
+            }
+            Q_EMIT hook(QString::fromUtf8(hookEvent->name), hookEvent->id, event->reply_userdata);
+            break;
+        }
 #if MPV_ENABLE_DEPRECATED
         case MPV_EVENT_IDLE:
         case MPV_EVENT_TICK:
 #endif
+        case MPV_EVENT_NONE:
             break;
         }
     }
diff --git a/src/mpvcontroller.h b/src/mpvcontroller.h
index c6fbb92..e150004 100644
--- a/src/mpvcontroller.h
+++ b/src/mpvcontroller.h
@@ -183,6 +183,14 @@ Q_SIGNALS:
     void fileLoaded();
     void endFile(QString reason);
     void videoReconfig();
+    void seek();
+    void playbackRestart();
+    void queueOverflow();
+    void shutdown();
+    void logMessage(QString prefix, QString level, QString msg);
+    void clientMessage(uint64_t eventId, QStringList args);
+    void audioReconfig();
+    void hook(QString name, uint64_t hookId, uint64_t eventId);
 
 private:
     std::shared_ptr<MpvHandleManager> mpvHandleManager() const;
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.