diff --git a/src/core/qmlscreen.cpp b/src/core/qmlscreen.cpp index 05e0118..26d791d 100644 --- a/src/core/qmlscreen.cpp +++ b/src/core/qmlscreen.cpp @@ -109,3 +109,21 @@ void QuickshellScreenInfo::screenDestroyed() { this->screen = nullptr; this->dangling = true; } + +QDebug operator<<(QDebug debug, const QuickshellScreenInfo* screen) { + if (screen == nullptr) { + debug.nospace() << "QuickshellScreenInfo(nullptr)"; + return debug; + } + + debug.nospace() << screen->metaObject()->className() << '(' << static_cast(screen) + << ", screen=" << screen->screen << ')'; + + return debug; +} + +QString QuickshellScreenInfo::toString() const { + QString str; + QDebug(&str) << this; + return str; +} diff --git a/src/core/qmlscreen.hpp b/src/core/qmlscreen.hpp index e499dfa..759d83e 100644 --- a/src/core/qmlscreen.hpp +++ b/src/core/qmlscreen.hpp @@ -1,9 +1,12 @@ #pragma once +#include #include #include +#include #include #include +#include #include #include @@ -55,6 +58,8 @@ public: [[nodiscard]] Qt::ScreenOrientation orientation() const; [[nodiscard]] Qt::ScreenOrientation primaryOrientation() const; + [[nodiscard]] Q_INVOKABLE QString toString() const; + QScreen* screen; private: @@ -71,3 +76,5 @@ signals: private slots: void screenDestroyed(); }; + +QDebug operator<<(QDebug debug, const QuickshellScreenInfo* screen);