diff --git a/src/services/mpris/CMakeLists.txt b/src/services/mpris/CMakeLists.txt index a15158c4..ffe6d0ad 100644 --- a/src/services/mpris/CMakeLists.txt +++ b/src/services/mpris/CMakeLists.txt @@ -7,8 +7,7 @@ qt_add_dbus_adaptor(DBUS_INTERFACES ) set_source_files_properties(org.mpris.MediaPlayer2.Player.xml PROPERTIES - CLASSNAME DBusMprisPlayer - #[[ INCLUDE dbus_item_types.hpp ]] + CLASSNAME DBusMprisPlayer ) qt_add_dbus_interface(DBUS_INTERFACES @@ -30,7 +29,6 @@ qt_add_library(quickshell-service-mpris STATIC watcher.cpp player.cpp - #[[ dbus_item_types.cpp ]] ${DBUS_INTERFACES} ) diff --git a/src/services/mpris/dbus_item_types.cpp b/src/services/mpris/dbus_item_types.cpp deleted file mode 100644 index fa40231e..00000000 --- a/src/services/mpris/dbus_item_types.cpp +++ /dev/null @@ -1,121 +0,0 @@ -#include "dbus_item_types.hpp" - -#include -#include -#include -#include -#include -#include -#include -#include -#include - -QImage DBusMpIconPixmap::createImage() const { - // fix byte order if on a little endian machine - if (QSysInfo::ByteOrder == QSysInfo::LittleEndian) { - auto* newbuf = new quint32[this->data.size()]; - const auto* oldbuf = reinterpret_cast(this->data.data()); // NOLINT - - for (uint i = 0; i < this->data.size() / sizeof(quint32); ++i) { - newbuf[i] = qFromBigEndian(oldbuf[i]); // NOLINT - } - - return QImage( - reinterpret_cast(newbuf), // NOLINT - this->width, - this->height, - QImage::Format_ARGB32, - [](void* ptr) { delete reinterpret_cast(ptr); }, // NOLINT - newbuf - ); - } else { - return QImage( - reinterpret_cast(this->data.data()), // NOLINT - this->width, - this->height, - QImage::Format_ARGB32 - ); - } -} - -const QDBusArgument& operator>>(const QDBusArgument& argument, DBusMpIconPixmap& pixmap) { - argument.beginStructure(); - argument >> pixmap.width; - argument >> pixmap.height; - argument >> pixmap.data; - argument.endStructure(); - return argument; -} - -const QDBusArgument& operator<<(QDBusArgument& argument, const DBusMpIconPixmap& pixmap) { - argument.beginStructure(); - argument << pixmap.width; - argument << pixmap.height; - argument << pixmap.data; - argument.endStructure(); - return argument; -} - -const QDBusArgument& operator>>(const QDBusArgument& argument, DBusMpIconPixmapList& pixmaps) { - argument.beginArray(); - pixmaps.clear(); - - while (!argument.atEnd()) { - pixmaps.append(qdbus_cast(argument)); - } - - argument.endArray(); - return argument; -} - -const QDBusArgument& operator<<(QDBusArgument& argument, const DBusMpIconPixmapList& pixmaps) { - argument.beginArray(qMetaTypeId()); - - for (const auto& pixmap: pixmaps) { - argument << pixmap; - } - - argument.endArray(); - return argument; -} - -const QDBusArgument& operator>>(const QDBusArgument& argument, DBusMpTooltip& tooltip) { - argument.beginStructure(); - argument >> tooltip.icon; - argument >> tooltip.iconPixmaps; - argument >> tooltip.title; - argument >> tooltip.description; - argument.endStructure(); - return argument; -} - -const QDBusArgument& operator<<(QDBusArgument& argument, const DBusMpTooltip& tooltip) { - argument.beginStructure(); - argument << tooltip.icon; - argument << tooltip.iconPixmaps; - argument << tooltip.title; - argument << tooltip.description; - argument.endStructure(); - return argument; -} - -QDebug operator<<(QDebug debug, const DBusMpIconPixmap& pixmap) { - debug.nospace() << "DBusMpIconPixmap(width=" << pixmap.width << ", height=" << pixmap.height - << ")"; - - return debug; -} - -QDebug operator<<(QDebug debug, const DBusMpTooltip& tooltip) { - debug.nospace() << "DBusMpTooltip(title=" << tooltip.title - << ", description=" << tooltip.description << ", icon=" << tooltip.icon - << ", iconPixmaps=" << tooltip.iconPixmaps << ")"; - - return debug; -} - -QDebug operator<<(QDebug debug, const QDBusObjectPath& path) { - debug.nospace() << "QDBusObjectPath(" << path.path() << ")"; - - return debug; -} diff --git a/src/services/mpris/dbus_item_types.hpp b/src/services/mpris/dbus_item_types.hpp deleted file mode 100644 index abc27e5a..00000000 --- a/src/services/mpris/dbus_item_types.hpp +++ /dev/null @@ -1,35 +0,0 @@ -#pragma once - -#include -#include -#include -#include - -struct DBusMpIconPixmap { - qint32 width = 0; - qint32 height = 0; - QByteArray data; - - // valid only for the lifetime of the pixmap - [[nodiscard]] QImage createImage() const; -}; - -using DBusMpIconPixmapList = QList; - -struct DBusMpTooltip { - QString icon; - DBusMpIconPixmapList iconPixmaps; - QString title; - QString description; -}; - -const QDBusArgument& operator>>(const QDBusArgument& argument, DBusMpIconPixmap& pixmap); -const QDBusArgument& operator<<(QDBusArgument& argument, const DBusMpIconPixmap& pixmap); -const QDBusArgument& operator>>(const QDBusArgument& argument, DBusMpIconPixmapList& pixmaps); -const QDBusArgument& operator<<(QDBusArgument& argument, const DBusMpIconPixmapList& pixmaps); -const QDBusArgument& operator>>(const QDBusArgument& argument, DBusMpTooltip& tooltip); -const QDBusArgument& operator<<(QDBusArgument& argument, const DBusMpTooltip& tooltip); - -QDebug operator<<(QDebug debug, const DBusMpIconPixmap& pixmap); -QDebug operator<<(QDebug debug, const DBusMpTooltip& tooltip); -QDebug operator<<(QDebug debug, const QDBusObjectPath& path); diff --git a/src/services/mpris/player.cpp b/src/services/mpris/player.cpp index 0b5569a8..b8676bad 100644 --- a/src/services/mpris/player.cpp +++ b/src/services/mpris/player.cpp @@ -11,7 +11,6 @@ #include #include "../../dbus/properties.hpp" -#include "dbus_item_types.hpp" #include "dbus_player.h" using namespace qs::dbus; diff --git a/src/services/mpris/player.hpp b/src/services/mpris/player.hpp index 3550b370..168006a0 100644 --- a/src/services/mpris/player.hpp +++ b/src/services/mpris/player.hpp @@ -8,7 +8,6 @@ #include "../../dbus/properties.hpp" #include "dbus_player.h" -#include "dbus_item_types.hpp" Q_DECLARE_LOGGING_CATEGORY(logMprisPlayer);