diff --git a/src/ui/WindowManager.cpp b/src/ui/WindowManager.cpp index d45d791..34683cb 100644 --- a/src/ui/WindowManager.cpp +++ b/src/ui/WindowManager.cpp @@ -7,12 +7,18 @@ #include "taskbar/TaskbarComponent.h" #include "input/InputComponent.h" #include "utils/Utils.h" +#include "system/SystemComponent.h" #include #include #include #include #include +#include + +#include +#include + /////////////////////////////////////////////////////////////////////////////////////////////////// WindowManager& WindowManager::Get() @@ -142,6 +148,16 @@ void WindowManager::initializeWindow(QQuickWindow* window) connect(m_webView, SIGNAL(zoomFactorChanged()), this, SLOT(onZoomFactorChanged())); enforceZoom(); } + + m_infoTimer = new QTimer(this); + m_infoTimer->setInterval(1000); + + m_systemDebugInfo = SystemComponent::Get().debugInformation(); + + connect(m_infoTimer, &QTimer::timeout, this, &WindowManager::updateDebugInfo); + connect(m_window, &QQuickWindow::beforeSynchronizing, this, &WindowManager::updateOpenGLInfo, static_cast(Qt::DirectConnection|Qt::SingleShotConnection)); + + QQmlProperty(m_window, "showDebugLayer").connectNotifySignal(this, SLOT(onShowDebugLayerChanged())); } /////////////////////////////////////////////////////////////////////////////////////////////////// @@ -881,6 +897,57 @@ void WindowManager::onZoomFactorChanged() enforceZoom(); } +/////////////////////////////////////////////////////////////////////////////////////////////////// +void WindowManager::updateDebugInfo() +{ + QString debugInfo = m_systemDebugInfo; + debugInfo += DisplayComponent::Get().debugInformation(); + debugInfo += m_openglInfo; + + QString infoString; + QDebug info(&infoString); + info << "Qt windowing info:\n"; + info << " FS: " << m_window->visibility() << "\n"; + info << " Geo: " << m_window->geometry() << "\n"; + for (QScreen* scr : QGuiApplication::screens()) + { + info << " Screen" << scr->name() << scr->geometry() << "\n"; + } + info << "\n"; + debugInfo += infoString; + + m_window->setProperty("debugInfo", debugInfo); + m_window->setProperty("videoInfo", PlayerComponent::Get().videoInformation()); +} + +/////////////////////////////////////////////////////////////////////////////////////////////////// +void WindowManager::onShowDebugLayerChanged() { + if(m_window->property("showDebugLayer").toBool()) { + m_infoTimer->start(); + updateDebugInfo(); + } else { + m_infoTimer->stop(); + } +} + +/////////////////////////////////////////////////////////////////////////////////////////////////// +void WindowManager::updateOpenGLInfo() { + m_openglInfo = ""; + QOpenGLContext* glctx = QOpenGLContext::currentContext(); + if (glctx && glctx->isValid()) + { + m_openglInfo += "\nOpenGL:\n"; + GLenum syms[4] = {GL_VENDOR, GL_RENDERER, GL_VERSION, GL_SHADING_LANGUAGE_VERSION}; + for (auto sym : syms) + { + auto s = glctx->functions()->glGetString(sym); + if (s) + m_openglInfo += QString(" ") + QString::fromUtf8(s) + "\n"; + } + m_openglInfo += "\n"; + } +} + /////////////////////////////////////////////////////////////////////////////////////////////////// void WindowManager::enforceZoom() { diff --git a/src/ui/WindowManager.h b/src/ui/WindowManager.h index 205330b..6b1bd54 100644 --- a/src/ui/WindowManager.h +++ b/src/ui/WindowManager.h @@ -69,6 +69,9 @@ private slots: void updateWindowState(bool saveGeo = true); void saveGeometrySlot(); void onZoomFactorChanged(); + void updateDebugInfo(); + void onShowDebugLayerChanged(); + void updateOpenGLInfo(); private: // Geometry (separate size/position) @@ -117,6 +120,11 @@ private: // initial size tracking to detect if size changed from default QSize m_initialSize; QSize m_initialScreenSize; + + // debug info + QString m_systemDebugInfo; + QString m_openglInfo; + QTimer* m_infoTimer; }; #endif // WINDOWMANAGER_H