Add QDebug stream operator for AbstractOutput

This can be useful for debugging purposes.
This commit is contained in:
Vlad Zahorodnii 2021-02-23 12:45:04 +02:00
parent 33ba2974eb
commit 220a1e0441
2 changed files with 24 additions and 0 deletions

View file

@ -53,6 +53,27 @@ const uint16_t *GammaRamp::blue() const
return m_table.data() + 2 * m_size;
}
QDebug operator<<(QDebug debug, const AbstractOutput *output)
{
QDebugStateSaver saver(debug);
debug.nospace();
if (output) {
debug << output->metaObject()->className() << '(' << static_cast<const void *>(output);
debug << ", name=" << output->name();
debug << ", geometry=" << output->geometry();
debug << ", scale=" << output->scale();
if (debug.verbosity() > 2) {
debug << ", manufacturer=" << output->manufacturer();
debug << ", model=" << output->model();
debug << ", serialNumber=" << output->serialNumber();
}
debug << ')';
} else {
debug << "AbstractOutput(0x0)";
}
return debug;
}
AbstractOutput::AbstractOutput(QObject *parent)
: QObject(parent)
{

View file

@ -11,6 +11,7 @@
#include <kwin_export.h>
#include <QDebug>
#include <QObject>
#include <QRect>
#include <QSize>
@ -210,6 +211,8 @@ private:
int m_directScanoutCount = 0;
};
KWIN_EXPORT QDebug operator<<(QDebug debug, const AbstractOutput *output);
} // namespace KWin
#endif