From f60c93ee6461493ae0f96718ff86f5ce97a1e288 Mon Sep 17 00:00:00 2001 From: Elias Steurer Date: Thu, 13 May 2021 13:35:54 +0200 Subject: [PATCH] Add more docs --- ScreenPlayShader/shaderlibrary.cpp | 4 + ScreenPlaySysInfo/cpu.cpp | 3 + ScreenPlaySysInfo/gpu.cpp | 5 +- ScreenPlaySysInfo/storage.cpp | 1 - ScreenPlaySysInfo/sysinfo.cpp | 3 + ScreenPlaySysInfo/uptime.cpp | 5 +- .../inc/public/ScreenPlayUtil/contenttypes.h | 29 +++---- ScreenPlayUtil/src/util.cpp | 23 +++-- ScreenPlayWallpaper/src/winwindow.cpp | 86 +++++++++++++++---- 9 files changed, 107 insertions(+), 52 deletions(-) diff --git a/ScreenPlayShader/shaderlibrary.cpp b/ScreenPlayShader/shaderlibrary.cpp index 7f3234e4..868813de 100644 --- a/ScreenPlayShader/shaderlibrary.cpp +++ b/ScreenPlayShader/shaderlibrary.cpp @@ -12,6 +12,10 @@ \brief . */ +/*! + * \brief ShaderLibrary::ShaderLibrary + * \param parent + */ ShaderLibrary::ShaderLibrary(QQuickItem* parent) : QQuickItem(parent) { diff --git a/ScreenPlaySysInfo/cpu.cpp b/ScreenPlaySysInfo/cpu.cpp index b59e6c33..dc665daf 100644 --- a/ScreenPlaySysInfo/cpu.cpp +++ b/ScreenPlaySysInfo/cpu.cpp @@ -19,6 +19,9 @@ CPU::CPU(QObject* parent) m_updateTimer.start(m_tickRate); } +/*! + * \brief CPU::update + */ void CPU::update() { BOOL status; diff --git a/ScreenPlaySysInfo/gpu.cpp b/ScreenPlaySysInfo/gpu.cpp index 4d87459b..8603b9c6 100644 --- a/ScreenPlaySysInfo/gpu.cpp +++ b/ScreenPlaySysInfo/gpu.cpp @@ -28,8 +28,11 @@ static const char* vendor_name(iware::gpu::vendor_t vendor) noexcept \class GPU \inmodule ScreenPlaySysInfo \brief . - */ + +/*! + * \brief GPU::GPU + */ GPU::GPU(QObject* parent) : QObject(parent) { diff --git a/ScreenPlaySysInfo/storage.cpp b/ScreenPlaySysInfo/storage.cpp index 8bfda384..4178c097 100644 --- a/ScreenPlaySysInfo/storage.cpp +++ b/ScreenPlaySysInfo/storage.cpp @@ -1,6 +1,5 @@ #include "storage.h" - /*! \class Storage \inmodule ScreenPlaySysInfo diff --git a/ScreenPlaySysInfo/sysinfo.cpp b/ScreenPlaySysInfo/sysinfo.cpp index 5574e47a..301aa6e9 100644 --- a/ScreenPlaySysInfo/sysinfo.cpp +++ b/ScreenPlaySysInfo/sysinfo.cpp @@ -13,6 +13,9 @@ */ +/*! + * \brief SysInfo::SysInfo + */ SysInfo::SysInfo(QQuickItem* parent) : QQuickItem(parent) , m_ram(std::make_unique()) diff --git a/ScreenPlaySysInfo/uptime.cpp b/ScreenPlaySysInfo/uptime.cpp index ca8bc14f..3a15e07c 100644 --- a/ScreenPlaySysInfo/uptime.cpp +++ b/ScreenPlaySysInfo/uptime.cpp @@ -5,7 +5,6 @@ #include #endif - /*! \class Uptime \inmodule ScreenPlaySysInfo @@ -18,11 +17,13 @@ Uptime::Uptime(QObject* parent) m_updateTimer.start(m_tickRate); } +/*! + * \brief Uptime::update + */ void Uptime::update() { #ifdef Q_OS_WINDOWS auto ticks = GetTickCount64(); - auto milliseconds = ticks % 1000; ticks /= 1000; auto seconds = ticks % 60; ticks /= 60; diff --git a/ScreenPlayUtil/inc/public/ScreenPlayUtil/contenttypes.h b/ScreenPlayUtil/inc/public/ScreenPlayUtil/contenttypes.h index 278b0bd8..393ae69d 100644 --- a/ScreenPlayUtil/inc/public/ScreenPlayUtil/contenttypes.h +++ b/ScreenPlayUtil/inc/public/ScreenPlayUtil/contenttypes.h @@ -37,12 +37,10 @@ namespace ScreenPlay { /*! - \class ScreenPlay::SearchType + \namespace ScreenPlay::SearchType \inmodule ScreenPlayUtil - \brief Global Enums. - + \brief Global enum for search types. Used in the "Installed" tab. */ - namespace SearchType { Q_NAMESPACE @@ -57,12 +55,12 @@ namespace SearchType { } /*! - \class ScreenPlay::FillMode + \namespace ScreenPlay::FillMode \inmodule ScreenPlayUtil - \brief Global Enums. - + \brief Global enum for fill mode. This is a c++ representation + of HTML fill modes. We use "_" instead of "-" for scale down, + because c++ forbids "-" in enum names. */ - namespace FillMode { Q_NAMESPACE @@ -77,20 +75,17 @@ namespace FillMode { } /*! - \class ScreenPlay::InstalledType + \namespace ScreenPlay::InstalledType \inmodule ScreenPlayUtil - \brief Global Enums. - + \brief When changing the enum, one also needs to change: + GlobalVariables::getAvailableWallpaper + GlobalVariables::getAvailableWidgets + Common/Util.js isWallpaper() and isWidget() + ScreenPlayWallpaper: BaseWindow::parseWallpaperType() */ - namespace InstalledType { Q_NAMESPACE - // When changing the enum, one also needs to change: - // GlobalVariables::getAvailableWallpaper - // GlobalVariables::getAvailableWidgets - // Common/Util.js isWallpaper() and isWidget() - // ScreenPlayWallpaper: BaseWindow::parseWallpaperType() enum class InstalledType { Unknown, //Wallpaper diff --git a/ScreenPlayUtil/src/util.cpp b/ScreenPlayUtil/src/util.cpp index dc8b8d44..f03b6b61 100644 --- a/ScreenPlayUtil/src/util.cpp +++ b/ScreenPlayUtil/src/util.cpp @@ -41,7 +41,8 @@ std::optional openJsonFileToObject(const QString& path) } /*! - \brief . + \brief Writes a QJsonObject into a given file. It defaults to truncate the file + or you can set it to append to an existing file. */ bool writeJsonObjectToFile(const QString& absoluteFilePath, const QJsonObject& object, bool truncate) { @@ -111,7 +112,7 @@ QString generateRandomString(quint32 length) } /*! - \brief Return .exe in windows otherwise empty string. + \brief Return .exe on windows otherwise empty string. */ QString executableEnding() { @@ -176,7 +177,6 @@ QString toString(const QStringList& list) /*! \brief Util function that converts a QVector of Strings into a QJsonArray. - */ QJsonArray fillArray(const QVector& items) { @@ -188,9 +188,7 @@ QJsonArray fillArray(const QVector& items) } /*! - \brief Maps the Search type to an installed type. Used for filtering the installed - content. - + \brief Maps the Search type to an installed type. Used for filtering the installed content. */ ScreenPlay::SearchType::SearchType getSearchTypeFromInstalledType(const ScreenPlay::InstalledType::InstalledType type) { @@ -264,7 +262,7 @@ QString toLocal(const QString& url) } /*! - \brief . + \brief Returns a list of available wallpaper types like videoWallpaper. */ QStringList getAvailableWallpaper() { @@ -279,7 +277,7 @@ QStringList getAvailableWallpaper() } /*! - \brief . + \brief Returns a list of available widget types like qmlWidget. */ QStringList getAvailableWidgets() { @@ -290,7 +288,7 @@ QStringList getAvailableWidgets() } /*! - \brief . + \brief Returns a combined list of available widgets and wallpaper types. */ QStringList getAvailableTypes() { @@ -298,7 +296,7 @@ QStringList getAvailableTypes() } /*! - \brief . + \brief Returns true of the given type is a wallpaper. */ bool isWallpaper(const ScreenPlay::InstalledType::InstalledType type) { @@ -314,7 +312,7 @@ bool isWallpaper(const ScreenPlay::InstalledType::InstalledType type) } /*! - \brief . + \brief Returns true of the given type is a widget. */ bool isWidget(const ScreenPlay::InstalledType::InstalledType type) { @@ -325,7 +323,8 @@ bool isWidget(const ScreenPlay::InstalledType::InstalledType type) } /*! - \brief See https://developer.mozilla.org/en-US/docs/Web/CSS/object-fit + \brief HTML video fillModes to be used in the QWebEngine video player. + See https://developer.mozilla.org/en-US/docs/Web/CSS/object-fit */ QStringList getAvailableFillModes() { diff --git a/ScreenPlayWallpaper/src/winwindow.cpp b/ScreenPlayWallpaper/src/winwindow.cpp index 82ac8fbc..eeadc70e 100644 --- a/ScreenPlayWallpaper/src/winwindow.cpp +++ b/ScreenPlayWallpaper/src/winwindow.cpp @@ -37,6 +37,9 @@ struct WinMonitorStats { WinMonitorStats() { EnumDisplayMonitors(0, 0, MonitorEnum, (LPARAM)this); } }; +/*! + \brief Searches for the worker window for our window to parent to. +*/ BOOL WINAPI SearchForWorkerWindow(HWND hwnd, LPARAM lparam) { // 0xXXXXXXX "" WorkerW @@ -55,6 +58,10 @@ QPoint g_LastMousePosition { 0, 0 }; QPoint g_globalOffset { 0, 0 }; QQuickView* g_winGlobalHook = nullptr; +/*! + \brief Windows mouse callback. This hook then forwards the event to the Qt window. + We must manually call a release event otherwise QML gets stuck. +*/ LRESULT __stdcall MouseHookCallback(int nCode, WPARAM wParam, LPARAM lParam) { @@ -109,6 +116,9 @@ LRESULT __stdcall MouseHookCallback(int nCode, WPARAM wParam, LPARAM lParam) return CallNextHookEx(g_mouseHook, nCode, wParam, lParam); } +/*! + \brief Setup the SetWindowsHookEx hook to be used to receive mouse events. +*/ void WinWindow::setupWindowMouseHook() { using ScreenPlay::InstalledType::InstalledType; @@ -129,9 +139,20 @@ void WinWindow::setupWindowMouseHook() /*! \class WinWindow \inmodule ScreenPlayWallpaper - \brief . + \brief ScreenPlayWindow used for the Windows implementation. */ +/*! + \brief Creates a window on Windows from the give parameters: + \a activeScreensList + \a projectFilePath + \a appID + \a volume + \a fillmode + \a type + \a checkWallpaperVisible + \a debugMode + */ WinWindow::WinWindow( const QVector& activeScreensList, const QString& projectFilePath, @@ -213,27 +234,27 @@ WinWindow::WinWindow( if (!debugMode) sdk()->start(); } - +/*! + \brief Calls ShowWindow function to set the main window in/visible. +*/ void WinWindow::setVisible(bool show) { if (show) { - if (!ShowWindow(m_windowHandleWorker, SW_SHOW)) { - qDebug() << "Cannot set window handle SW_SHOW"; - } if (!ShowWindow(m_windowHandle, SW_SHOW)) { qDebug() << "Cannot set window handle SW_SHOW"; } } else { - if (!ShowWindow(m_windowHandleWorker, SW_HIDE)) { - qDebug() << "Cannot set window handle SW_HIDE"; - } if (!ShowWindow(m_windowHandle, SW_HIDE)) { qDebug() << "Cannot set window handle SW_HIDE"; } } } - +/*! + \brief This function fires a qmlExit() signal to the UI for it to handle + nice fade out animation first. Then the UI is responsible for calling + WinWindow::terminate(). +*/ void WinWindow::destroyThis() { emit qmlExit(); @@ -254,6 +275,9 @@ BOOL CALLBACK GetMonitorByIndex(HMONITOR hMonitor, HDC hdcMonitor, LPRECT lprcMo return TRUE; } +/*! + \brief This method is called if the user want to have one wallpaper on one window. +*/ void WinWindow::setupWallpaperForOneScreen(int activeScreen) { const QRect screenRect = QApplication::screens().at(activeScreen)->geometry(); @@ -302,6 +326,9 @@ void WinWindow::setupWallpaperForOneScreen(int activeScreen) } } +/*! + \brief This method is called if the user want to have one wallpaper on all windows. +*/ void WinWindow::setupWallpaperForAllScreens() { QRect rect; @@ -320,6 +347,9 @@ void WinWindow::setupWallpaperForAllScreens() } } +/*! + \brief This method is called if the user want to have one wallpaper on multiple windows. +*/ void WinWindow::setupWallpaperForMultipleScreens(const QVector& activeScreensList) { QRect rect; @@ -360,14 +390,19 @@ bool WinWindow::searchWorkerWindowToParentTo() return EnumWindows(SearchForWorkerWindow, reinterpret_cast(&m_windowHandleWorker)); } +/*! + \brief Reads the logicalDotsPerInch and mapps them to scaling factors. + This is needed to detect if the user has different monitors with + different scaling factors. + + screen->logicalDotsPerInch() + 100% -> 96 -> 1 + 125% -> 120 -> 1.25 + 150% -> 144 -> 1.5 + ... +*/ float WinWindow::getScaling(const int monitorIndex) { - // screen->logicalDotsPerInch() - // 100% - 96 - // 125% - 120 - // 150% - 144 - // 175% - 168 - // 200% - 192 QScreen* screen = QApplication::screens().at(monitorIndex); const int factor = screen->logicalDotsPerInch(); switch (factor) { @@ -395,6 +430,10 @@ float WinWindow::getScaling(const int monitorIndex) } } +/*! + \brief Sets the size and the parent to the worker handle to be displayed behind the + desktop icons. +*/ void WinWindow::configureWindowGeometry() { ShowWindow(m_windowHandle, SW_HIDE); @@ -403,8 +442,6 @@ void WinWindow::configureWindowGeometry() qFatal("No worker window found"); } - ShowWindow(m_windowHandleWorker, SW_HIDE); - RECT rect {}; if (!GetWindowRect(m_windowHandleWorker, &rect)) { qFatal("Unable to get WindoeRect from worker"); @@ -473,7 +510,10 @@ int GetMonitorIndex(HMONITOR hMonitor) return info.iIndex; } - +/*! + \brief This method is called via a fixed interval to detect if a window completely + covers a monitor. If then sets visualPaused for QML to pause the content. +*/ void WinWindow::checkForFullScreenWindow() { @@ -501,7 +541,10 @@ void WinWindow::checkForFullScreenWindow() setVisualsPaused(false); } } - +/*! + \brief Custom exit method to force a redraw of the window so that + the default desktop wallpaper can be seen agian. +*/ void WinWindow::terminate() { ShowWindow(m_windowHandle, SW_HIDE); @@ -514,6 +557,11 @@ void WinWindow::terminate() QApplication::quit(); } +/*! + \brief Call the qml engine clearComponentCache. This function is used for + refreshing wallpaper when the content has changed. For example this + is needed for live editing when the content is chached. +*/ void WinWindow::clearComponentCache() { m_window.engine()->clearComponentCache();