diff --git a/BUILD.md b/BUILD.md index 92589cc..c990959 100644 --- a/BUILD.md +++ b/BUILD.md @@ -43,7 +43,7 @@ To disable: `-DSOCKETS=OFF` ### Wayland This feature enables wayland support. Subfeatures exist for each particular wayland integration. -WARNING: Wayland integration relies on featurs that are not part of the public Qt API and which +WARNING: Wayland integration relies on features that are not part of the public Qt API and which may break in minor releases. Updating quickshell's dependencies without ensuring without ensuring that the current Qt version is supported WILL result in quickshell failing to build or misbehaving at runtime. diff --git a/src/core/proxywindow.cpp b/src/core/proxywindow.cpp index c2961c2..4eef5f3 100644 --- a/src/core/proxywindow.cpp +++ b/src/core/proxywindow.cpp @@ -156,9 +156,7 @@ void ProxyWindowBase::completeWindow() { emit this->screenChanged(); } -bool ProxyWindowBase::deleteOnInvisible() const { - return false; -} +bool ProxyWindowBase::deleteOnInvisible() const { return false; } QQuickWindow* ProxyWindowBase::backingWindow() const { return this->window; } QQuickItem* ProxyWindowBase::contentItem() const { return this->mContentItem; } diff --git a/src/services/mpris/watcher.cpp b/src/services/mpris/watcher.cpp index 8c67a4d..8a78893 100644 --- a/src/services/mpris/watcher.cpp +++ b/src/services/mpris/watcher.cpp @@ -16,7 +16,7 @@ namespace qs::service::mpris { Q_LOGGING_CATEGORY(logMprisWatcher, "quickshell.service.mpris.watcher", QtWarningMsg); -MprisWatcher::MprisWatcher(QObject* parent): QObject(parent) { +MprisWatcher::MprisWatcher() { qCDebug(logMprisWatcher) << "Starting MprisWatcher"; auto bus = QDBusConnection::sessionBus(); @@ -102,4 +102,13 @@ void MprisWatcher::registerPlayer(const QString& address) { qCDebug(logMprisWatcher) << "Registered MprisPlayer" << address; } +MprisWatcher* MprisWatcher::instance() { + static MprisWatcher* instance = new MprisWatcher(); // NOLINT + return instance; +} + +ObjectModel* MprisQml::players() { // NOLINT + return MprisWatcher::instance()->players(); +} + } // namespace qs::service::mpris diff --git a/src/services/mpris/watcher.hpp b/src/services/mpris/watcher.hpp index 91275c7..d60471c 100644 --- a/src/services/mpris/watcher.hpp +++ b/src/services/mpris/watcher.hpp @@ -18,16 +18,12 @@ namespace qs::service::mpris { ///! Provides access to MprisPlayers. class MprisWatcher: public QObject { Q_OBJECT; - QML_NAMED_ELEMENT(Mpris); - QML_SINGLETON; - /// All connected MPRIS players. - Q_PROPERTY(ObjectModel* players READ players CONSTANT); public: - explicit MprisWatcher(QObject* parent = nullptr); - [[nodiscard]] ObjectModel* players(); + static MprisWatcher* instance(); + private slots: void onServiceRegistered(const QString& service); void onServiceUnregistered(const QString& service); @@ -35,6 +31,8 @@ private slots: void onPlayerDestroyed(QObject* object); private: + explicit MprisWatcher(); + void registerExisting(); void registerPlayer(const QString& address); @@ -43,4 +41,17 @@ private: ObjectModel readyPlayers {this}; }; +class MprisQml: public QObject { + Q_OBJECT; + QML_NAMED_ELEMENT(Mpris); + QML_SINGLETON; + /// All connected MPRIS players. + Q_PROPERTY(ObjectModel* players READ players CONSTANT); + +public: + explicit MprisQml(QObject* parent = nullptr): QObject(parent) {}; + + [[nodiscard]] ObjectModel* players(); +}; + } // namespace qs::service::mpris