aboutsummaryrefslogtreecommitdiff
path: root/windows-extra
diff options
context:
space:
mode:
Diffstat (limited to 'windows-extra')
-rw-r--r--windows-extra/CMakeLists.txt16
-rw-r--r--windows-extra/windowsextra.cpp71
-rw-r--r--windows-extra/windowsextra.hpp38
3 files changed, 125 insertions, 0 deletions
diff --git a/windows-extra/CMakeLists.txt b/windows-extra/CMakeLists.txt
new file mode 100644
index 0000000..6754e46
--- /dev/null
+++ b/windows-extra/CMakeLists.txt
@@ -0,0 +1,16 @@
+set(windowsextra_SOURCES
+ windowsextra.hpp
+ windowsextra.cpp
+)
+
+include_directories(${PROJECT_SOURCE_DIR}/include/)
+
+find_package(Qt5 REQUIRED COMPONENTS Widgets WinExtras)
+
+add_library(windowsextra MODULE
+ ${windowsextra_SOURCES}
+)
+
+target_link_libraries(windowsextra Qt5::Widgets Qt5::WinExtras)
+
+install(TARGETS windowsextra LIBRARY DESTINATION ${CMAKE_INSTALL_PREFIX}/lib/qmidiplayer/)
diff --git a/windows-extra/windowsextra.cpp b/windows-extra/windowsextra.cpp
new file mode 100644
index 0000000..6c5ef1f
--- /dev/null
+++ b/windows-extra/windowsextra.cpp
@@ -0,0 +1,71 @@
+#include <cstdio>
+#include "windowsextra.hpp"
+
+#include <QMainWindow>
+#include <QTimer>
+#include <QWinTaskbarProgress>
+
+qmpWindowsExtraPlugin::qmpWindowsExtraPlugin(qmpPluginAPI *_api)
+{
+ api = _api;
+}
+qmpWindowsExtraPlugin::~qmpWindowsExtraPlugin()
+{
+ api = nullptr;
+}
+void qmpWindowsExtraPlugin::init()
+{
+ QMainWindow * w = static_cast<QMainWindow *>(api->getMainWindow());
+ m_timer = new QTimer();
+ m_taskbarIcon = new QWinTaskbarButton();
+ m_taskbarIcon->setWindow(w->windowHandle());
+
+ m_timerConnection = QObject::connect(m_timer, &QTimer::timeout, [ = ](){
+ m_taskbarIcon->progress()->setValue(api->getCurrentPlaybackPercentage());
+ });
+
+ ui_start = api->registerUIHook("main.start", [this](const void *, void *)
+ {
+ m_taskbarIcon->progress()->show();
+ m_taskbarIcon->progress()->resume();
+ m_timer->start(250);
+ }, nullptr);
+ ui_stop = api->registerUIHook("main.stop", [this](const void *, void *)
+ {
+ m_taskbarIcon->progress()->stop();
+ m_taskbarIcon->progress()->hide();
+ }, nullptr);
+ ui_pause = api->registerUIHook("main.pause", [this](const void *, void *)
+ {
+ PlaybackStatus ps = api->getPlaybackStatus();
+ if (ps.paused) {
+ m_taskbarIcon->progress()->pause();
+ } else {
+ m_taskbarIcon->progress()->resume();
+ }
+ }, nullptr);
+ ui_reset = api->registerUIHook("main.reset", [this](const void *, void *)
+ {
+ m_taskbarIcon->progress()->reset();
+ }, nullptr);
+}
+void qmpWindowsExtraPlugin::deinit()
+{
+ QObject::disconnect(m_timerConnection);
+
+ m_timer->deleteLater();
+ m_taskbarIcon->deleteLater();
+
+ api->unregisterUIHook("main.start", ui_start);
+ api->unregisterUIHook("main.stop", ui_stop);
+ api->unregisterUIHook("main.pause", ui_pause);
+ api->unregisterUIHook("main.reset", ui_reset);
+}
+const char *qmpWindowsExtraPlugin::pluginGetName()
+{
+ return "Windows Extra Feature Plugin";
+}
+const char *qmpWindowsExtraPlugin::pluginGetVersion()
+{
+ return "0.0.0";
+}
diff --git a/windows-extra/windowsextra.hpp b/windows-extra/windowsextra.hpp
new file mode 100644
index 0000000..227d4ad
--- /dev/null
+++ b/windows-extra/windowsextra.hpp
@@ -0,0 +1,38 @@
+#ifndef SAMPLEPLUGIN_H
+#define SAMPLEPLUGIN_H
+
+#include "../include/qmpcorepublic.hpp"
+
+#include <QWinTaskbarButton>
+
+class qmpWindowsExtraPlugin: public qmpPluginIntf
+{
+private:
+ qmpPluginAPI *api;
+public:
+ qmpWindowsExtraPlugin(qmpPluginAPI *_api);
+ ~qmpWindowsExtraPlugin();
+ void init();
+ void deinit();
+ const char *pluginGetName();
+ const char *pluginGetVersion();
+
+private:
+ QWinTaskbarButton * m_taskbarIcon = nullptr;
+ QTimer * m_timer = nullptr;
+ QMetaObject::Connection m_timerConnection;
+ int ui_start, ui_stop, ui_pause, ui_reset;
+};
+
+extern "C" {
+ EXPORTSYM qmpPluginIntf *qmpPluginGetInterface(qmpPluginAPI *api)
+ {
+ return new qmpWindowsExtraPlugin(api);
+ }
+ EXPORTSYM const char *qmpPluginGetAPIRev()
+ {
+ return QMP_PLUGIN_API_REV;
+ }
+}
+
+#endif // SAMPLEPLUGIN_H