From e327f7381256130b7f908e8db78c9ebe2e59ee45 Mon Sep 17 00:00:00 2001 From: Elias Steurer Date: Sun, 20 Aug 2023 11:59:02 +0200 Subject: [PATCH] Fix all formatting scripts and format files They default to format but also can be used for checking --- .gitlab/ci/check_jobs.yml | 5 +- .vscode/tasks.json | 8 +- Content/wallpaper_qml/main.qml | 1 - Content/wallpaper_qml_particles/main.qml | 14 +-- Content/widget_digital_clock/main.qml | 33 ++++--- .../widget_rss_guardian_news/PostDelegate.qml | 17 ++-- Content/widget_rss_guardian_news/main.qml | 3 +- .../widget_rss_hackernews/PostDelegate.qml | 50 +++++------ Content/widget_rss_hackernews/main.qml | 11 ++- Content/widget_system_stats/main.qml | 13 ++- Content/widget_weather/main.qml | 41 ++++----- Content/widget_xkcd/main.qml | 51 ++++++----- Content/widget_year_count_down/main.qml | 26 ++---- ScreenPlay/CMakeLists.txt | 2 +- ScreenPlay/qml/Installed/ScreenPlayItem.qml | 1 - ScreenPlay/qml/Installed/Sidebar.qml | 2 +- ScreenPlay/qml/Settings/Settings.qml | 2 +- ScreenPlaySDK/src/screenplaysdk.cpp | 11 ++- ScreenPlayUtil/src/projectfile.cpp | 8 +- ScreenPlayWallpaper/qml/MultimediaView.qml | 15 ++-- ScreenPlayWallpaper/src/basewindow.cpp | 4 +- ScreenPlayWidget/main.cpp | 6 +- Tools/check_format_cmake.py | 56 ++++++++++++ Tools/check_format_cpp.py | 61 +++++++++++++ Tools/check_format_qml.py | 86 +++++++++++++++++++ Tools/clang_format.py | 36 -------- Tools/cmake_format.py | 31 ------- Tools/format_util.py | 43 ++++++---- Tools/qml_format.py | 40 --------- 29 files changed, 372 insertions(+), 305 deletions(-) create mode 100644 Tools/check_format_cmake.py create mode 100644 Tools/check_format_cpp.py create mode 100644 Tools/check_format_qml.py delete mode 100644 Tools/clang_format.py delete mode 100644 Tools/cmake_format.py delete mode 100644 Tools/qml_format.py diff --git a/.gitlab/ci/check_jobs.yml b/.gitlab/ci/check_jobs.yml index 82e5f039..b190e2bf 100644 --- a/.gitlab/ci/check_jobs.yml +++ b/.gitlab/ci/check_jobs.yml @@ -15,5 +15,6 @@ formatting: - python -m pip install -U pip wheel --break-system-packages - python -m pip install -U cmakelang --break-system-packages - cd Tools - - python clang_format.py - - python cmake_format.py + - python check_format_cmake.py --check + - python check_format_cpp.py --check + - python check_format_qml.py --check diff --git a/.vscode/tasks.json b/.vscode/tasks.json index c83832e7..a6b91c44 100644 --- a/.vscode/tasks.json +++ b/.vscode/tasks.json @@ -28,7 +28,7 @@ "cwd": "${workspaceFolder}/Tools" }, "args": [ - "clang_format.py" + "check_format_cpp.py" ] }, { @@ -46,7 +46,7 @@ "cwd": "${workspaceFolder}/Tools" }, "args": [ - "cmake_format.py" + "check_format_cmake.py" ] }, { @@ -64,7 +64,7 @@ "cwd": "${workspaceFolder}/Tools" }, "args": [ - "qml_format.py" + "check_format_qml.py" ] }, { @@ -87,7 +87,7 @@ }, { "type": "process", - "label": "Export ScreenPlay release, with deploy and steam enabled", + "label": "Build ScreenPlay release, with deploy and steam enabled", "command": "python3", "windows": { "command": "python" diff --git a/Content/wallpaper_qml/main.qml b/Content/wallpaper_qml/main.qml index 475be5a1..92e21a65 100644 --- a/Content/wallpaper_qml/main.qml +++ b/Content/wallpaper_qml/main.qml @@ -1,4 +1,3 @@ - // SPDX-License-Identifier: BSD-3-Clause import QtQuick import QtQuick.Layouts diff --git a/Content/wallpaper_qml_particles/main.qml b/Content/wallpaper_qml_particles/main.qml index 35febbda..9f2b561f 100644 --- a/Content/wallpaper_qml_particles/main.qml +++ b/Content/wallpaper_qml_particles/main.qml @@ -42,19 +42,19 @@ Item { anchors.fill: parent hoverEnabled: true Component.onCompleted: { - attractor.pointX = parent.width * .5 - attractor.pointY = 0 + attractor.pointX = parent.width * .5; + attractor.pointY = 0; } onPressed: { - attractor.enabled = true + attractor.enabled = true; } onPositionChanged: { - attractor.pointX = mouseX - attractor.pointY = mouseY + attractor.pointX = mouseX; + attractor.pointY = mouseY; } onReleased: { - attractor.enabled = false + attractor.enabled = false; } } @@ -119,7 +119,7 @@ Item { bottom: parent.bottom bottomMargin: -width * .65 } - SequentialAnimation on opacity { + SequentialAnimation on opacity { loops: Animation.Infinite OpacityAnimator { diff --git a/Content/widget_digital_clock/main.qml b/Content/widget_digital_clock/main.qml index 42fab09e..8af90611 100644 --- a/Content/widget_digital_clock/main.qml +++ b/Content/widget_digital_clock/main.qml @@ -8,32 +8,31 @@ Item { implicitHeight: 100 function timeChanged() { - var date = new Date - var hours = "" - var minutes = "" - var seconds = "" + var date = new Date; + var hours = ""; + var minutes = ""; + var seconds = ""; if (date.getHours() < 10) { - hours = "0" + date.getHours().toString() + hours = "0" + date.getHours().toString(); } else { - hours = date.getHours().toString() + hours = date.getHours().toString(); } if (date.getMinutes() < 10) { - minutes = "0" + date.getMinutes().toString() + minutes = "0" + date.getMinutes().toString(); } else { - minutes = date.getMinutes().toString() + minutes = date.getMinutes().toString(); } if (date.getSeconds() < 10) { - seconds = "0" + date.getSeconds().toString() + seconds = "0" + date.getSeconds().toString(); } else { - seconds = date.getSeconds().toString() + seconds = date.getSeconds().toString(); } - var days = ['Sunday', 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday'] - var months = ['January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December'] - var day = days[date.getDay()] - var month = months[date.getMonth()] - txtClock.text = hours + ":" + minutes + ":" + seconds - txtDate.text = day + ", " + date.getDay( - ) + " " + month + ", " + date.getFullYear() + var days = ['Sunday', 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday']; + var months = ['January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December']; + var day = days[date.getDay()]; + var month = months[date.getMonth()]; + txtClock.text = hours + ":" + minutes + ":" + seconds; + txtDate.text = day + ", " + date.getDay() + " " + month + ", " + date.getFullYear(); } Timer { diff --git a/Content/widget_rss_guardian_news/PostDelegate.qml b/Content/widget_rss_guardian_news/PostDelegate.qml index 5e3b1d61..83b46b1e 100644 --- a/Content/widget_rss_guardian_news/PostDelegate.qml +++ b/Content/widget_rss_guardian_news/PostDelegate.qml @@ -1,4 +1,3 @@ - // SPDX-License-Identifier: BSD-3-Clause import QtQuick import QtQuick.Layouts @@ -17,16 +16,16 @@ Item { property string link property string mediaContent onMediaContentChanged: { - print("src") - const src = parseItem(model.mediaContent, 'url="', '"') - print("src", src) + print("src"); + const src = parseItem(model.mediaContent, 'url="', '"'); + print("src", src); //img.source = src; } function parseItem(raw, startTag, endTag) { - var startIdx = raw.indexOf(startTag) + startTag.length - var endIdx = raw.indexOf(endTag, startIdx) - return raw.substring(startIdx, endIdx) + var startIdx = raw.indexOf(startTag) + startTag.length; + var endIdx = raw.indexOf(endTag, startIdx); + return raw.substring(startIdx, endIdx); } RowLayout { @@ -49,8 +48,8 @@ Item { MouseArea { anchors.fill: parent onClicked: { - print(model.category) - print(model.mediaContent) + print(model.category); + print(model.mediaContent); //Qt.openUrlExternally(model.link); } } diff --git a/Content/widget_rss_guardian_news/main.qml b/Content/widget_rss_guardian_news/main.qml index e54e55e4..f86de527 100644 --- a/Content/widget_rss_guardian_news/main.qml +++ b/Content/widget_rss_guardian_news/main.qml @@ -1,4 +1,3 @@ - // SPDX-License-Identifier: BSD-3-Clause import QtQuick import QtQuick.Controls @@ -18,7 +17,7 @@ Item { query: "/rss/channel/item" onStatusChanged: { if (status === XmlListModel.Error) { - console.log("Error: " + errorString) + console.log("Error: " + errorString); } } diff --git a/Content/widget_rss_hackernews/PostDelegate.qml b/Content/widget_rss_hackernews/PostDelegate.qml index 275823d5..badb4bbc 100644 --- a/Content/widget_rss_hackernews/PostDelegate.qml +++ b/Content/widget_rss_hackernews/PostDelegate.qml @@ -12,41 +12,38 @@ Item { property string pubDate property string pubDateFormatted onPubDateChanged: { - var date = new Date(pubDate) - root.pubDateFormatted = date.toLocaleDateString( - Qt.locale(), - "ddd, dd MMM yyyy") + ' ' + date.toLocaleTimeString( - Qt.locale(), "HH:mm:ss") + var date = new Date(pubDate); + root.pubDateFormatted = date.toLocaleDateString(Qt.locale(), "ddd, dd MMM yyyy") + ' ' + date.toLocaleTimeString(Qt.locale(), "HH:mm:ss"); } property string description onDescriptionChanged: { - print("description") + print("description"); // See https://hnrss.org/frontpage content // We need to manually parse it here to get the points and comments - points = parsePoints(description) - commentCount = parseCommentCount(description) - print(points, commentCount) + points = parsePoints(description); + commentCount = parseCommentCount(description); + print(points, commentCount); } function parseCommentCount(raw) { - var commentPrefix = "

# Comments: " - var commentSuffix = "

" - var startIdx = raw.indexOf(commentPrefix) + var commentPrefix = "

# Comments: "; + var commentSuffix = "

"; + var startIdx = raw.indexOf(commentPrefix); if (startIdx === -1) - return "N/A" // return "N/A" if comment count is not found in the description - startIdx += commentPrefix.length - var endIdx = raw.indexOf(commentSuffix, startIdx) - return raw.substring(startIdx, endIdx) + return "N/A"; // return "N/A" if comment count is not found in the description + startIdx += commentPrefix.length; + var endIdx = raw.indexOf(commentSuffix, startIdx); + return raw.substring(startIdx, endIdx); } function parsePoints(raw) { - var pointsPrefix = "

Points: " - var pointsSuffix = "

" - var startIdx = raw.indexOf(pointsPrefix) + var pointsPrefix = "

Points: "; + var pointsSuffix = "

"; + var startIdx = raw.indexOf(pointsPrefix); if (startIdx === -1) - return "N/A" // return "N/A" if points are not found in the description - startIdx += pointsPrefix.length - var endIdx = raw.indexOf(pointsSuffix, startIdx) - return raw.substring(startIdx, endIdx) + return "N/A"; // return "N/A" if points are not found in the description + startIdx += pointsPrefix.length; + var endIdx = raw.indexOf(pointsSuffix, startIdx); + return raw.substring(startIdx, endIdx); } RowLayout { id: wrapper @@ -68,15 +65,14 @@ Item { anchors.fill: parent cursorShape: Qt.PointingHandCursor onClicked: { - Qt.openUrlExternally(model.link) + Qt.openUrlExternally(model.link); } } } Text { id: descriptionText - text: root.points + " Points • " + root.commentCount - + " Comments 🔗 " + "• Published: " + root.pubDateFormatted + text: root.points + " Points • " + root.commentCount + " Comments 🔗 " + "• Published: " + root.pubDateFormatted wrapMode: Text.WordWrap font.pointSize: 10 opacity: .7 @@ -85,7 +81,7 @@ Item { anchors.fill: parent cursorShape: Qt.PointingHandCursor onClicked: { - Qt.openUrlExternally(model.commentsLink) + Qt.openUrlExternally(model.commentsLink); } } } diff --git a/Content/widget_rss_hackernews/main.qml b/Content/widget_rss_hackernews/main.qml index 87708c2c..99ddc3a8 100644 --- a/Content/widget_rss_hackernews/main.qml +++ b/Content/widget_rss_hackernews/main.qml @@ -1,4 +1,3 @@ - // SPDX-License-Identifier: BSD-3-Clause import QtQuick import QtQuick.Layouts @@ -44,7 +43,7 @@ Item { } } onActivated: { - rssModel.source = combo.currentValue + rssModel.source = combo.currentValue; } } ToolButton { @@ -79,10 +78,10 @@ Item { source: combo.currentValue query: "/rss/channel/item" function load() { - print(":load") - var tempSource = rssModel.source - rssModel.source = "" - rssModel.source = tempSource + print(":load"); + var tempSource = rssModel.source; + rssModel.source = ""; + rssModel.source = tempSource; } XmlListModelRole { diff --git a/Content/widget_system_stats/main.qml b/Content/widget_system_stats/main.qml index abe23e9a..ec5fe20e 100644 --- a/Content/widget_system_stats/main.qml +++ b/Content/widget_system_stats/main.qml @@ -1,4 +1,3 @@ - // SPDX-License-Identifier: BSD-3-Clause import QtQuick import QtQuick.Layouts @@ -28,11 +27,11 @@ Item { } function stringListToString(list) { - let out = "" + let out = ""; for (var i = 0; i < list.length; i++) { - out += "\n" + list[i] + out += "\n" + list[i]; } - return out + return out; } RowLayout { @@ -57,8 +56,7 @@ Item { } } Text { - text: root.stringListToString( - ipAddress.privateIpV4AddressList) + text: root.stringListToString(ipAddress.privateIpV4AddressList) color: root.accentColor font { pointSize: 16 @@ -66,8 +64,7 @@ Item { } } Text { - text: root.stringListToString( - ipAddress.privateIpV6AddressList) + text: root.stringListToString(ipAddress.privateIpV6AddressList) color: root.accentColor font { pointSize: 16 diff --git a/Content/widget_weather/main.qml b/Content/widget_weather/main.qml index 4f934ada..42a061eb 100644 --- a/Content/widget_weather/main.qml +++ b/Content/widget_weather/main.qml @@ -1,4 +1,3 @@ - // SPDX-License-Identifier: BSD-3-Clause import QtQuick import QtQuick.Layouts @@ -20,56 +19,57 @@ Item { id: weather city: "Friedrichshafen" onReady: { - rp.model = weather.days + rp.model = weather.days; // Qt bug https://bugreports.qt.io/browse/QTBUG-105137 - test() + test(); } } - function test() {} + function test() { + } function mapWeatherCode(code) { - const weather_time = "" + const weather_time = ""; // or "-day", "-night" - const weather_prefix = "wi" + weather_time + "-" + const weather_prefix = "wi" + weather_time + "-"; // https://open-meteo.com/en/docs // WMO Weather interpretation codes (WW) // to https://erikflowers.github.io/weather-icons/ switch (code) { case 0: - return weather_prefix + "day-sunny" + return weather_prefix + "day-sunny"; case 1: case 2: case 3: - return weather_prefix + "cloud" + return weather_prefix + "cloud"; case 45: case 48: - return weather_prefix + "day-sunny" + return weather_prefix + "day-sunny"; case 51: case 53: case 55: - return weather_prefix + "rain-mix" + return weather_prefix + "rain-mix"; case 61: case 63: case 65: - return weather_prefix + "rain-mix" + return weather_prefix + "rain-mix"; case 71: case 73: case 75: - return weather_prefix + "snow" + return weather_prefix + "snow"; case 77: - return weather_prefix + "snow" + return weather_prefix + "snow"; case 80: case 81: case 82: - return weather_prefix + "snow" + return weather_prefix + "snow"; case 85: case 86: - return weather_prefix + "snow" + return weather_prefix + "snow"; case 95: - return weather_prefix + "thunderstorm" + return weather_prefix + "thunderstorm"; case 96: case 99: - return weather_prefix + "storm-showers" + return weather_prefix + "storm-showers"; } } @@ -89,9 +89,7 @@ Item { Layout.alignment: Qt.AlignCenter horizontalAlignment: Text.AlignHCenter color: Material.primaryTextColor - text: "longtitude: " + weather.longtitude + " - latitude: " - + weather.latitude + " - elevation: " + weather.elevation - + "m - population: " + weather.population + text: "longtitude: " + weather.longtitude + " - latitude: " + weather.latitude + " - elevation: " + weather.elevation + "m - population: " + weather.population } RowLayout { @@ -129,8 +127,7 @@ Item { } Layout.alignment: Qt.AlignCenter horizontalAlignment: Image.AlignHCenter - source: "qrc:/qml/ScreenPlayWeather/assets/icons/" + root.mapWeatherCode( - weatherCode) + ".svg" + source: "qrc:/qml/ScreenPlayWeather/assets/icons/" + root.mapWeatherCode(weatherCode) + ".svg" } TextItem { text: "Weather Code" diff --git a/Content/widget_xkcd/main.qml b/Content/widget_xkcd/main.qml index 377b6706..917c0cf0 100644 --- a/Content/widget_xkcd/main.qml +++ b/Content/widget_xkcd/main.qml @@ -1,4 +1,3 @@ - // SPDX-License-Identifier: BSD-3-Clause import QtQuick import QtQuick.Controls @@ -15,27 +14,27 @@ Item { property int defaultHeight: 200 function request(url, callback) { - var xhr = new XMLHttpRequest() + var xhr = new XMLHttpRequest(); xhr.onreadystatechange = (function (myxhr) { - return function () { - if (myxhr.readyState === 4) - callback(myxhr) - } - })(xhr) - xhr.open('GET', url) - xhr.send('') + return function () { + if (myxhr.readyState === 4) + callback(myxhr); + }; + })(xhr); + xhr.open('GET', url); + xhr.send(''); } Component.onCompleted: { request("http://xkcd.com/info.0.json", function (o) { - if (o.status === 200) { - var d = eval('new Object(' + o.responseText + ')') - console.log(o.responseText) - img.source = d.img - } else { - console.log("Some error has occurred") - } - }) + if (o.status === 200) { + var d = eval('new Object(' + o.responseText + ')'); + console.log(o.responseText); + img.source = d.img; + } else { + console.log("Some error has occurred"); + } + }); } Image { @@ -45,22 +44,22 @@ Item { property size imgSize: Qt.size(root.defaultWidth, defaultHeight) onStatusChanged: { if (img.status !== Image.Ready) - return + return; if (img.sourceSize.width === 0 || img.sourceSize.height === 0) - return - root.implicitWidth = img.sourceSize.width - root.implicitHeight = img.sourceSize.height - print(img.status, img.sourceSize.width, img.sourceSize.height) - img.imgSize = Qt.size(img.sourceSize.width, img.sourceSize.height) - print("img.size", img.imgSize) + return; + root.implicitWidth = img.sourceSize.width; + root.implicitHeight = img.sourceSize.height; + print(img.status, img.sourceSize.width, img.sourceSize.height); + img.imgSize = Qt.size(img.sourceSize.width, img.sourceSize.height); + print("img.size", img.imgSize); } } MouseArea { anchors.fill: parent onClicked: { - root.state = root.state === "expanded" ? "normal" : "expanded" - print(root.state, root.implicitHeight, root.implicitWidth) + root.state = root.state === "expanded" ? "normal" : "expanded"; + print(root.state, root.implicitHeight, root.implicitWidth); } } diff --git a/Content/widget_year_count_down/main.qml b/Content/widget_year_count_down/main.qml index dfddb45e..39fab9d4 100644 --- a/Content/widget_year_count_down/main.qml +++ b/Content/widget_year_count_down/main.qml @@ -11,17 +11,9 @@ Item { implicitWidth: 240 implicitHeight: 120 property int totalHours: 24 - property int remainingHours: Math.max(0, Math.floor( - (new Date().setHours( - 24, 0, 0, - 0) - new Date()) / 3600000)) - property int totalDays: new Date(new Date().getFullYear() + 1, 0, - 1) - new Date() / (24 * 60 * 60 * 1000) - property int remainingDays: Math.max( - 0, Math.floor( - (new Date(new Date().getFullYear() + 1, - 0, - 1) - new Date()) / (24 * 60 * 60 * 1000))) + property int remainingHours: Math.max(0, Math.floor((new Date().setHours(24, 0, 0, 0) - new Date()) / 3600000)) + property int totalDays: new Date(new Date().getFullYear() + 1, 0, 1) - new Date() / (24 * 60 * 60 * 1000) + property int remainingDays: Math.max(0, Math.floor((new Date(new Date().getFullYear() + 1, 0, 1) - new Date()) / (24 * 60 * 60 * 1000))) Material.theme: Material.Dark Material.accent: Material.DeepOrange @@ -50,11 +42,7 @@ Item { running: true repeat: true onTriggered: { - remainingHours = Math.max( - 0, - Math.floor((new Date().setHours( - 24, 0, 0, - 0) - new Date()) / 3600000)) + remainingHours = Math.max(0, Math.floor((new Date().setHours(24, 0, 0, 0) - new Date()) / 3600000)); } } } @@ -81,11 +69,7 @@ Item { running: true repeat: true onTriggered: { - remainingDays = Math.max(0, - Math.floor((new Date(new Date().getFullYear( - ) + 1, - 0, 1) - - new Date()) / (24 * 60 * 60 * 1000))) + remainingDays = Math.max(0, Math.floor((new Date(new Date().getFullYear() + 1, 0, 1) - new Date()) / (24 * 60 * 60 * 1000))); } } } diff --git a/ScreenPlay/CMakeLists.txt b/ScreenPlay/CMakeLists.txt index fdafccf0..d2842184 100644 --- a/ScreenPlay/CMakeLists.txt +++ b/ScreenPlay/CMakeLists.txt @@ -138,6 +138,7 @@ set(RESOURCES assets/icons/icon_close.svg assets/icons/icon_code.svg assets/icons/icon_community.svg + assets/icons/icon_contains_audio.svg assets/icons/icon_delete.svg assets/icons/icon_document.svg assets/icons/icon_done.svg @@ -152,7 +153,6 @@ set(RESOURCES assets/icons/icon_installed.svg assets/icons/icon_launch.svg assets/icons/icon_minimize.svg - assets/icons/icon_contains_audio.svg assets/icons/icon_movie.svg assets/icons/icon_new_releases.svg assets/icons/icon_open_in_new.svg diff --git a/ScreenPlay/qml/Installed/ScreenPlayItem.qml b/ScreenPlay/qml/Installed/ScreenPlayItem.qml index be8aa23d..f22a4701 100644 --- a/ScreenPlay/qml/Installed/ScreenPlayItem.qml +++ b/ScreenPlay/qml/Installed/ScreenPlayItem.qml @@ -175,7 +175,6 @@ Item { } } - Image { id: icnType diff --git a/ScreenPlay/qml/Installed/Sidebar.qml b/ScreenPlay/qml/Installed/Sidebar.qml index a9bb26ea..96ce53cc 100644 --- a/ScreenPlay/qml/Installed/Sidebar.qml +++ b/ScreenPlay/qml/Installed/Sidebar.qml @@ -43,7 +43,7 @@ Item { const item = App.installedListModel.get(root.contentFolderName); txtHeadline.text = item.m_title; const previewGiFilePath = Qt.resolvedUrl(item.m_absoluteStoragePath + "/" + item.m_previewGIF); - const previewImageFilePath = Qt.resolvedUrl( item.m_absoluteStoragePath + "/" + item.m_preview); + const previewImageFilePath = Qt.resolvedUrl(item.m_absoluteStoragePath + "/" + item.m_preview); root.hasPreviewGif = App.util.fileExists(previewGiFilePath); if (hasPreviewGif) { animatedImagePreview.source = previewGiFilePath; diff --git a/ScreenPlay/qml/Settings/Settings.qml b/ScreenPlay/qml/Settings/Settings.qml index 4f02b98a..6e540746 100644 --- a/ScreenPlay/qml/Settings/Settings.qml +++ b/ScreenPlay/qml/Settings/Settings.qml @@ -82,7 +82,7 @@ Item { isChecked: App.settings.showDefaultContent onCheckboxChanged: function (checked) { App.settings.setShowDefaultContent(checked); - App.installedListModel.reset() + App.installedListModel.reset(); } } diff --git a/ScreenPlaySDK/src/screenplaysdk.cpp b/ScreenPlaySDK/src/screenplaysdk.cpp index 20553e18..4caec706 100644 --- a/ScreenPlaySDK/src/screenplaysdk.cpp +++ b/ScreenPlaySDK/src/screenplaysdk.cpp @@ -186,20 +186,19 @@ void ScreenPlaySDK::ScreenPlaySDK::redirectMessageOutputToMainWindow(QtMsgType t // Also redirect to regular output if we debug // wallpaper or widgets directly - switch (type) - { + switch (type) { case QtDebugMsg: - qDebug() << msg; + qDebug() << msg; break; case QtWarningMsg: - qWarning() << msg; + qWarning() << msg; break; case QtCriticalMsg: case QtFatalMsg: - qCritical() << msg; + qCritical() << msg; break; case QtInfoMsg: - qInfo() << msg; + qInfo() << msg; break; default: break; diff --git a/ScreenPlayUtil/src/projectfile.cpp b/ScreenPlayUtil/src/projectfile.cpp index 401fcffa..d0e899bd 100644 --- a/ScreenPlayUtil/src/projectfile.cpp +++ b/ScreenPlayUtil/src/projectfile.cpp @@ -27,9 +27,9 @@ bool ProjectFile::init() return false; file = obj.value("file").toString(); - QFileInfo fileInfo(folder.path() + "/"+ file); - if(!fileInfo.exists()){ - qCritical() << "Requested file:" << fileInfo.absoluteFilePath() << "does not exist!"; + QFileInfo fileInfo(folder.path() + "/" + file); + if (!fileInfo.exists()) { + qCritical() << "Requested file:" << fileInfo.absoluteFilePath() << "does not exist!"; return false; } @@ -107,7 +107,7 @@ bool ProjectFile::init() } } - if (type == ScreenPlay::InstalledType::InstalledType::VideoWallpaper){ + if (type == ScreenPlay::InstalledType::InstalledType::VideoWallpaper) { QFileInfo audioFile(folder.absolutePath() + "/audio.mp3"); containsAudio = audioFile.exists(); } diff --git a/ScreenPlayWallpaper/qml/MultimediaView.qml b/ScreenPlayWallpaper/qml/MultimediaView.qml index 49101516..592462a7 100644 --- a/ScreenPlayWallpaper/qml/MultimediaView.qml +++ b/ScreenPlayWallpaper/qml/MultimediaView.qml @@ -49,7 +49,7 @@ Item { onPlaybackStateChanged: { if (mediaPlayer.playbackState == MediaPlayer.PlayingState && !fadeInDone) { fadeInDone = true; - startTimer.start() + startTimer.start(); } } loops: root.loops ? MediaPlayer.Infinite : 1 @@ -72,8 +72,7 @@ Item { id: pauseTimer interval: 100 onTriggered: { - mediaPlayer.pause() - + mediaPlayer.pause(); } } Connections { @@ -96,12 +95,12 @@ Item { } function onVisualsPausedChanged(visualsPaused) { - if(!Wallpaper.isPlaying) - return - if(visualsPaused) - pauseTimer.start() + if (!Wallpaper.isPlaying) + return; + if (visualsPaused) + pauseTimer.start(); else - mediaPlayer.play() + mediaPlayer.play(); } target: Wallpaper diff --git a/ScreenPlayWallpaper/src/basewindow.cpp b/ScreenPlayWallpaper/src/basewindow.cpp index b4119343..67231f16 100644 --- a/ScreenPlayWallpaper/src/basewindow.cpp +++ b/ScreenPlayWallpaper/src/basewindow.cpp @@ -60,8 +60,8 @@ ScreenPlay::WallpaperExitCode BaseWindow::setup() // We do not yet have implemented continue playing the audio.mp3 yet // so disable the checkWallpaperVisible for now - if(checkWallpaperVisible()){ - if(projectFile.containsAudio){ + if (checkWallpaperVisible()) { + if (projectFile.containsAudio) { qInfo() << "Disable wallpaper visible check, because it contains audio."; setCheckWallpaperVisible(false); } diff --git a/ScreenPlayWidget/main.cpp b/ScreenPlayWidget/main.cpp index 0445f60e..cffc4841 100644 --- a/ScreenPlayWidget/main.cpp +++ b/ScreenPlayWidget/main.cpp @@ -26,7 +26,7 @@ int main(int argc, char* argv[]) QtWebEngineQuick::initialize(); #if defined(Q_OS_WIN) - // Workaround for Qt 6.5.1 crash https://bugreports.qt.io/browse/QTBUG-113832 + // Workaround for Qt 6.5.1 crash https://bugreports.qt.io/browse/QTBUG-113832 qputenv("QT_DISABLE_HW_TEXTURES_CONVERSION", "1"); qputenv("QT_MEDIA_BACKEND", "ffmpeg"); #endif @@ -55,8 +55,8 @@ int main(int argc, char* argv[]) // Lets center the widget const auto* screen = QGuiApplication::screens().at(0); - const int offset = - 200; - QPoint center((screen->size().width() / 2) + offset, (screen->size().height() / 2)+offset); + const int offset = -200; + QPoint center((screen->size().width() / 2) + offset, (screen->size().height() / 2) + offset); WidgetWindow spwmw(projectPath, "appid", diff --git a/Tools/check_format_cmake.py b/Tools/check_format_cmake.py new file mode 100644 index 00000000..c3d1849a --- /dev/null +++ b/Tools/check_format_cmake.py @@ -0,0 +1,56 @@ +#!/usr/bin/python3 +# SPDX-License-Identifier: LicenseRef-EliasSteurerTachiom OR AGPL-3.0-only +import os +import argparse +import util +from format_util import find_files +from format_util import execute_threaded +from sys import stdout + +stdout.reconfigure(encoding='utf-8') + + +def format_file_function(file): + executable = "cmake-format" + if os.name == 'nt': + executable += ".exe" + os.system(" %s -c ../.cmake-format.py -i %s" % (executable, file)) + print("Format: ", file) + + +def check_format_file_function(file): + executable = "cmake-format" + if os.name == 'nt': + executable += ".exe" + result = os.system(" %s -c ../.cmake-format.py --check %s" % + (executable, file)) + + # If the return code is non-zero, the file isn't formatted correctly + if result != 0: + print(f"{file} is not correctly formatted.") + return False + return True + + +def main(git_staged_only=False, check_only=False): + file_list = find_files( + ('CMakeLists.txt', '*.cmake'), util.repo_root_path(), git_staged_only) + + if check_only: + result = execute_threaded(file_list, check_format_file_function) + if not result: # Since result is a single boolean, you can directly check its value + print("Some files are not correctly formatted!") + exit(1) + else: + execute_threaded(file_list, format_file_function) + + +if __name__ == "__main__": + parser = argparse.ArgumentParser() + parser.add_argument('-s', '--stage-only', action="store_true", dest="stage_only", default=False, + help="Check/format only staged files") + parser.add_argument('-c', '--check', action="store_true", dest="check_only", default=False, + help="Only check if files are correctly formatted without actually formatting them") + + args = parser.parse_args() + main(args.stage_only, args.check_only) diff --git a/Tools/check_format_cpp.py b/Tools/check_format_cpp.py new file mode 100644 index 00000000..793135f3 --- /dev/null +++ b/Tools/check_format_cpp.py @@ -0,0 +1,61 @@ +#!/usr/bin/python3 +# SPDX-License-Identifier: LicenseRef-EliasSteurerTachiom OR AGPL-3.0-only +import os +import subprocess +import argparse +import util +from format_util import find_files +from format_util import execute_threaded +from sys import stdout + +stdout.reconfigure(encoding='utf-8') + + +def format_file_function(file): + executable = "clang-format" + if os.name == 'nt': + executable = "clang-format.exe" + process = subprocess.run(" %s -style=file -i %s" % + (executable, file), capture_output=True, shell=True) + print("Format: %s \t return: %s" % (file, process.returncode)) + + +def check_format_file_function(file): + executable = "clang-format" + if os.name == 'nt': + executable += ".exe" + result = subprocess.run(" %s -style=file --output-replacements-xml %s" % + (executable, file), capture_output=True, shell=True, text=True) + + # Check for opening replacement tag with attributes (a space after it indicates attributes) + if "