mirror of
https://gitlab.com/kelteseth/ScreenPlay.git
synced 2024-11-22 02:32:29 +01:00
Fix all formatting scripts and format files
They default to format but also can be used for checking
This commit is contained in:
parent
9b1de7cadf
commit
e327f73812
@ -15,5 +15,6 @@ formatting:
|
|||||||
- python -m pip install -U pip wheel --break-system-packages
|
- python -m pip install -U pip wheel --break-system-packages
|
||||||
- python -m pip install -U cmakelang --break-system-packages
|
- python -m pip install -U cmakelang --break-system-packages
|
||||||
- cd Tools
|
- cd Tools
|
||||||
- python clang_format.py
|
- python check_format_cmake.py --check
|
||||||
- python cmake_format.py
|
- python check_format_cpp.py --check
|
||||||
|
- python check_format_qml.py --check
|
||||||
|
8
.vscode/tasks.json
vendored
8
.vscode/tasks.json
vendored
@ -28,7 +28,7 @@
|
|||||||
"cwd": "${workspaceFolder}/Tools"
|
"cwd": "${workspaceFolder}/Tools"
|
||||||
},
|
},
|
||||||
"args": [
|
"args": [
|
||||||
"clang_format.py"
|
"check_format_cpp.py"
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@ -46,7 +46,7 @@
|
|||||||
"cwd": "${workspaceFolder}/Tools"
|
"cwd": "${workspaceFolder}/Tools"
|
||||||
},
|
},
|
||||||
"args": [
|
"args": [
|
||||||
"cmake_format.py"
|
"check_format_cmake.py"
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@ -64,7 +64,7 @@
|
|||||||
"cwd": "${workspaceFolder}/Tools"
|
"cwd": "${workspaceFolder}/Tools"
|
||||||
},
|
},
|
||||||
"args": [
|
"args": [
|
||||||
"qml_format.py"
|
"check_format_qml.py"
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@ -87,7 +87,7 @@
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"type": "process",
|
"type": "process",
|
||||||
"label": "Export ScreenPlay release, with deploy and steam enabled",
|
"label": "Build ScreenPlay release, with deploy and steam enabled",
|
||||||
"command": "python3",
|
"command": "python3",
|
||||||
"windows": {
|
"windows": {
|
||||||
"command": "python"
|
"command": "python"
|
||||||
|
@ -1,4 +1,3 @@
|
|||||||
|
|
||||||
// SPDX-License-Identifier: BSD-3-Clause
|
// SPDX-License-Identifier: BSD-3-Clause
|
||||||
import QtQuick
|
import QtQuick
|
||||||
import QtQuick.Layouts
|
import QtQuick.Layouts
|
||||||
|
@ -42,19 +42,19 @@ Item {
|
|||||||
anchors.fill: parent
|
anchors.fill: parent
|
||||||
hoverEnabled: true
|
hoverEnabled: true
|
||||||
Component.onCompleted: {
|
Component.onCompleted: {
|
||||||
attractor.pointX = parent.width * .5
|
attractor.pointX = parent.width * .5;
|
||||||
attractor.pointY = 0
|
attractor.pointY = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
onPressed: {
|
onPressed: {
|
||||||
attractor.enabled = true
|
attractor.enabled = true;
|
||||||
}
|
}
|
||||||
onPositionChanged: {
|
onPositionChanged: {
|
||||||
attractor.pointX = mouseX
|
attractor.pointX = mouseX;
|
||||||
attractor.pointY = mouseY
|
attractor.pointY = mouseY;
|
||||||
}
|
}
|
||||||
onReleased: {
|
onReleased: {
|
||||||
attractor.enabled = false
|
attractor.enabled = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -119,7 +119,7 @@ Item {
|
|||||||
bottom: parent.bottom
|
bottom: parent.bottom
|
||||||
bottomMargin: -width * .65
|
bottomMargin: -width * .65
|
||||||
}
|
}
|
||||||
SequentialAnimation on opacity {
|
SequentialAnimation on opacity {
|
||||||
loops: Animation.Infinite
|
loops: Animation.Infinite
|
||||||
|
|
||||||
OpacityAnimator {
|
OpacityAnimator {
|
||||||
|
@ -8,32 +8,31 @@ Item {
|
|||||||
implicitHeight: 100
|
implicitHeight: 100
|
||||||
|
|
||||||
function timeChanged() {
|
function timeChanged() {
|
||||||
var date = new Date
|
var date = new Date;
|
||||||
var hours = ""
|
var hours = "";
|
||||||
var minutes = ""
|
var minutes = "";
|
||||||
var seconds = ""
|
var seconds = "";
|
||||||
if (date.getHours() < 10) {
|
if (date.getHours() < 10) {
|
||||||
hours = "0" + date.getHours().toString()
|
hours = "0" + date.getHours().toString();
|
||||||
} else {
|
} else {
|
||||||
hours = date.getHours().toString()
|
hours = date.getHours().toString();
|
||||||
}
|
}
|
||||||
if (date.getMinutes() < 10) {
|
if (date.getMinutes() < 10) {
|
||||||
minutes = "0" + date.getMinutes().toString()
|
minutes = "0" + date.getMinutes().toString();
|
||||||
} else {
|
} else {
|
||||||
minutes = date.getMinutes().toString()
|
minutes = date.getMinutes().toString();
|
||||||
}
|
}
|
||||||
if (date.getSeconds() < 10) {
|
if (date.getSeconds() < 10) {
|
||||||
seconds = "0" + date.getSeconds().toString()
|
seconds = "0" + date.getSeconds().toString();
|
||||||
} else {
|
} else {
|
||||||
seconds = date.getSeconds().toString()
|
seconds = date.getSeconds().toString();
|
||||||
}
|
}
|
||||||
var days = ['Sunday', 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday']
|
var days = ['Sunday', 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday'];
|
||||||
var months = ['January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December']
|
var months = ['January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December'];
|
||||||
var day = days[date.getDay()]
|
var day = days[date.getDay()];
|
||||||
var month = months[date.getMonth()]
|
var month = months[date.getMonth()];
|
||||||
txtClock.text = hours + ":" + minutes + ":" + seconds
|
txtClock.text = hours + ":" + minutes + ":" + seconds;
|
||||||
txtDate.text = day + ", " + date.getDay(
|
txtDate.text = day + ", " + date.getDay() + " " + month + ", " + date.getFullYear();
|
||||||
) + " " + month + ", " + date.getFullYear()
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Timer {
|
Timer {
|
||||||
|
@ -1,4 +1,3 @@
|
|||||||
|
|
||||||
// SPDX-License-Identifier: BSD-3-Clause
|
// SPDX-License-Identifier: BSD-3-Clause
|
||||||
import QtQuick
|
import QtQuick
|
||||||
import QtQuick.Layouts
|
import QtQuick.Layouts
|
||||||
@ -17,16 +16,16 @@ Item {
|
|||||||
property string link
|
property string link
|
||||||
property string mediaContent
|
property string mediaContent
|
||||||
onMediaContentChanged: {
|
onMediaContentChanged: {
|
||||||
print("src")
|
print("src");
|
||||||
const src = parseItem(model.mediaContent, 'url="', '"')
|
const src = parseItem(model.mediaContent, 'url="', '"');
|
||||||
print("src", src)
|
print("src", src);
|
||||||
//img.source = src;
|
//img.source = src;
|
||||||
}
|
}
|
||||||
|
|
||||||
function parseItem(raw, startTag, endTag) {
|
function parseItem(raw, startTag, endTag) {
|
||||||
var startIdx = raw.indexOf(startTag) + startTag.length
|
var startIdx = raw.indexOf(startTag) + startTag.length;
|
||||||
var endIdx = raw.indexOf(endTag, startIdx)
|
var endIdx = raw.indexOf(endTag, startIdx);
|
||||||
return raw.substring(startIdx, endIdx)
|
return raw.substring(startIdx, endIdx);
|
||||||
}
|
}
|
||||||
|
|
||||||
RowLayout {
|
RowLayout {
|
||||||
@ -49,8 +48,8 @@ Item {
|
|||||||
MouseArea {
|
MouseArea {
|
||||||
anchors.fill: parent
|
anchors.fill: parent
|
||||||
onClicked: {
|
onClicked: {
|
||||||
print(model.category)
|
print(model.category);
|
||||||
print(model.mediaContent)
|
print(model.mediaContent);
|
||||||
//Qt.openUrlExternally(model.link);
|
//Qt.openUrlExternally(model.link);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,4 +1,3 @@
|
|||||||
|
|
||||||
// SPDX-License-Identifier: BSD-3-Clause
|
// SPDX-License-Identifier: BSD-3-Clause
|
||||||
import QtQuick
|
import QtQuick
|
||||||
import QtQuick.Controls
|
import QtQuick.Controls
|
||||||
@ -18,7 +17,7 @@ Item {
|
|||||||
query: "/rss/channel/item"
|
query: "/rss/channel/item"
|
||||||
onStatusChanged: {
|
onStatusChanged: {
|
||||||
if (status === XmlListModel.Error) {
|
if (status === XmlListModel.Error) {
|
||||||
console.log("Error: " + errorString)
|
console.log("Error: " + errorString);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -12,41 +12,38 @@ Item {
|
|||||||
property string pubDate
|
property string pubDate
|
||||||
property string pubDateFormatted
|
property string pubDateFormatted
|
||||||
onPubDateChanged: {
|
onPubDateChanged: {
|
||||||
var date = new Date(pubDate)
|
var date = new Date(pubDate);
|
||||||
root.pubDateFormatted = date.toLocaleDateString(
|
root.pubDateFormatted = date.toLocaleDateString(Qt.locale(), "ddd, dd MMM yyyy") + ' ' + date.toLocaleTimeString(Qt.locale(), "HH:mm:ss");
|
||||||
Qt.locale(),
|
|
||||||
"ddd, dd MMM yyyy") + ' ' + date.toLocaleTimeString(
|
|
||||||
Qt.locale(), "HH:mm:ss")
|
|
||||||
}
|
}
|
||||||
property string description
|
property string description
|
||||||
onDescriptionChanged: {
|
onDescriptionChanged: {
|
||||||
print("description")
|
print("description");
|
||||||
// See https://hnrss.org/frontpage <description> content
|
// See https://hnrss.org/frontpage <description> content
|
||||||
// We need to manually parse it here to get the points and comments
|
// We need to manually parse it here to get the points and comments
|
||||||
points = parsePoints(description)
|
points = parsePoints(description);
|
||||||
commentCount = parseCommentCount(description)
|
commentCount = parseCommentCount(description);
|
||||||
print(points, commentCount)
|
print(points, commentCount);
|
||||||
}
|
}
|
||||||
|
|
||||||
function parseCommentCount(raw) {
|
function parseCommentCount(raw) {
|
||||||
var commentPrefix = "<p># Comments: "
|
var commentPrefix = "<p># Comments: ";
|
||||||
var commentSuffix = "</p>"
|
var commentSuffix = "</p>";
|
||||||
var startIdx = raw.indexOf(commentPrefix)
|
var startIdx = raw.indexOf(commentPrefix);
|
||||||
if (startIdx === -1)
|
if (startIdx === -1)
|
||||||
return "N/A" // return "N/A" if comment count is not found in the description
|
return "N/A"; // return "N/A" if comment count is not found in the description
|
||||||
startIdx += commentPrefix.length
|
startIdx += commentPrefix.length;
|
||||||
var endIdx = raw.indexOf(commentSuffix, startIdx)
|
var endIdx = raw.indexOf(commentSuffix, startIdx);
|
||||||
return raw.substring(startIdx, endIdx)
|
return raw.substring(startIdx, endIdx);
|
||||||
}
|
}
|
||||||
function parsePoints(raw) {
|
function parsePoints(raw) {
|
||||||
var pointsPrefix = "<p>Points: "
|
var pointsPrefix = "<p>Points: ";
|
||||||
var pointsSuffix = "</p>"
|
var pointsSuffix = "</p>";
|
||||||
var startIdx = raw.indexOf(pointsPrefix)
|
var startIdx = raw.indexOf(pointsPrefix);
|
||||||
if (startIdx === -1)
|
if (startIdx === -1)
|
||||||
return "N/A" // return "N/A" if points are not found in the description
|
return "N/A"; // return "N/A" if points are not found in the description
|
||||||
startIdx += pointsPrefix.length
|
startIdx += pointsPrefix.length;
|
||||||
var endIdx = raw.indexOf(pointsSuffix, startIdx)
|
var endIdx = raw.indexOf(pointsSuffix, startIdx);
|
||||||
return raw.substring(startIdx, endIdx)
|
return raw.substring(startIdx, endIdx);
|
||||||
}
|
}
|
||||||
RowLayout {
|
RowLayout {
|
||||||
id: wrapper
|
id: wrapper
|
||||||
@ -68,15 +65,14 @@ Item {
|
|||||||
anchors.fill: parent
|
anchors.fill: parent
|
||||||
cursorShape: Qt.PointingHandCursor
|
cursorShape: Qt.PointingHandCursor
|
||||||
onClicked: {
|
onClicked: {
|
||||||
Qt.openUrlExternally(model.link)
|
Qt.openUrlExternally(model.link);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Text {
|
Text {
|
||||||
id: descriptionText
|
id: descriptionText
|
||||||
text: root.points + " Points • " + root.commentCount
|
text: root.points + " Points • " + root.commentCount + " Comments 🔗 " + "• Published: " + root.pubDateFormatted
|
||||||
+ " Comments 🔗 " + "• Published: " + root.pubDateFormatted
|
|
||||||
wrapMode: Text.WordWrap
|
wrapMode: Text.WordWrap
|
||||||
font.pointSize: 10
|
font.pointSize: 10
|
||||||
opacity: .7
|
opacity: .7
|
||||||
@ -85,7 +81,7 @@ Item {
|
|||||||
anchors.fill: parent
|
anchors.fill: parent
|
||||||
cursorShape: Qt.PointingHandCursor
|
cursorShape: Qt.PointingHandCursor
|
||||||
onClicked: {
|
onClicked: {
|
||||||
Qt.openUrlExternally(model.commentsLink)
|
Qt.openUrlExternally(model.commentsLink);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,4 +1,3 @@
|
|||||||
|
|
||||||
// SPDX-License-Identifier: BSD-3-Clause
|
// SPDX-License-Identifier: BSD-3-Clause
|
||||||
import QtQuick
|
import QtQuick
|
||||||
import QtQuick.Layouts
|
import QtQuick.Layouts
|
||||||
@ -44,7 +43,7 @@ Item {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
onActivated: {
|
onActivated: {
|
||||||
rssModel.source = combo.currentValue
|
rssModel.source = combo.currentValue;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
ToolButton {
|
ToolButton {
|
||||||
@ -79,10 +78,10 @@ Item {
|
|||||||
source: combo.currentValue
|
source: combo.currentValue
|
||||||
query: "/rss/channel/item"
|
query: "/rss/channel/item"
|
||||||
function load() {
|
function load() {
|
||||||
print(":load")
|
print(":load");
|
||||||
var tempSource = rssModel.source
|
var tempSource = rssModel.source;
|
||||||
rssModel.source = ""
|
rssModel.source = "";
|
||||||
rssModel.source = tempSource
|
rssModel.source = tempSource;
|
||||||
}
|
}
|
||||||
|
|
||||||
XmlListModelRole {
|
XmlListModelRole {
|
||||||
|
@ -1,4 +1,3 @@
|
|||||||
|
|
||||||
// SPDX-License-Identifier: BSD-3-Clause
|
// SPDX-License-Identifier: BSD-3-Clause
|
||||||
import QtQuick
|
import QtQuick
|
||||||
import QtQuick.Layouts
|
import QtQuick.Layouts
|
||||||
@ -28,11 +27,11 @@ Item {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function stringListToString(list) {
|
function stringListToString(list) {
|
||||||
let out = ""
|
let out = "";
|
||||||
for (var i = 0; i < list.length; i++) {
|
for (var i = 0; i < list.length; i++) {
|
||||||
out += "\n" + list[i]
|
out += "\n" + list[i];
|
||||||
}
|
}
|
||||||
return out
|
return out;
|
||||||
}
|
}
|
||||||
|
|
||||||
RowLayout {
|
RowLayout {
|
||||||
@ -57,8 +56,7 @@ Item {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
Text {
|
Text {
|
||||||
text: root.stringListToString(
|
text: root.stringListToString(ipAddress.privateIpV4AddressList)
|
||||||
ipAddress.privateIpV4AddressList)
|
|
||||||
color: root.accentColor
|
color: root.accentColor
|
||||||
font {
|
font {
|
||||||
pointSize: 16
|
pointSize: 16
|
||||||
@ -66,8 +64,7 @@ Item {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
Text {
|
Text {
|
||||||
text: root.stringListToString(
|
text: root.stringListToString(ipAddress.privateIpV6AddressList)
|
||||||
ipAddress.privateIpV6AddressList)
|
|
||||||
color: root.accentColor
|
color: root.accentColor
|
||||||
font {
|
font {
|
||||||
pointSize: 16
|
pointSize: 16
|
||||||
|
@ -1,4 +1,3 @@
|
|||||||
|
|
||||||
// SPDX-License-Identifier: BSD-3-Clause
|
// SPDX-License-Identifier: BSD-3-Clause
|
||||||
import QtQuick
|
import QtQuick
|
||||||
import QtQuick.Layouts
|
import QtQuick.Layouts
|
||||||
@ -20,56 +19,57 @@ Item {
|
|||||||
id: weather
|
id: weather
|
||||||
city: "Friedrichshafen"
|
city: "Friedrichshafen"
|
||||||
onReady: {
|
onReady: {
|
||||||
rp.model = weather.days
|
rp.model = weather.days;
|
||||||
// Qt bug https://bugreports.qt.io/browse/QTBUG-105137
|
// Qt bug https://bugreports.qt.io/browse/QTBUG-105137
|
||||||
test()
|
test();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
function test() {}
|
function test() {
|
||||||
|
}
|
||||||
|
|
||||||
function mapWeatherCode(code) {
|
function mapWeatherCode(code) {
|
||||||
const weather_time = ""
|
const weather_time = "";
|
||||||
// or "-day", "-night"
|
// or "-day", "-night"
|
||||||
const weather_prefix = "wi" + weather_time + "-"
|
const weather_prefix = "wi" + weather_time + "-";
|
||||||
// https://open-meteo.com/en/docs
|
// https://open-meteo.com/en/docs
|
||||||
// WMO Weather interpretation codes (WW)
|
// WMO Weather interpretation codes (WW)
|
||||||
// to https://erikflowers.github.io/weather-icons/
|
// to https://erikflowers.github.io/weather-icons/
|
||||||
switch (code) {
|
switch (code) {
|
||||||
case 0:
|
case 0:
|
||||||
return weather_prefix + "day-sunny"
|
return weather_prefix + "day-sunny";
|
||||||
case 1:
|
case 1:
|
||||||
case 2:
|
case 2:
|
||||||
case 3:
|
case 3:
|
||||||
return weather_prefix + "cloud"
|
return weather_prefix + "cloud";
|
||||||
case 45:
|
case 45:
|
||||||
case 48:
|
case 48:
|
||||||
return weather_prefix + "day-sunny"
|
return weather_prefix + "day-sunny";
|
||||||
case 51:
|
case 51:
|
||||||
case 53:
|
case 53:
|
||||||
case 55:
|
case 55:
|
||||||
return weather_prefix + "rain-mix"
|
return weather_prefix + "rain-mix";
|
||||||
case 61:
|
case 61:
|
||||||
case 63:
|
case 63:
|
||||||
case 65:
|
case 65:
|
||||||
return weather_prefix + "rain-mix"
|
return weather_prefix + "rain-mix";
|
||||||
case 71:
|
case 71:
|
||||||
case 73:
|
case 73:
|
||||||
case 75:
|
case 75:
|
||||||
return weather_prefix + "snow"
|
return weather_prefix + "snow";
|
||||||
case 77:
|
case 77:
|
||||||
return weather_prefix + "snow"
|
return weather_prefix + "snow";
|
||||||
case 80:
|
case 80:
|
||||||
case 81:
|
case 81:
|
||||||
case 82:
|
case 82:
|
||||||
return weather_prefix + "snow"
|
return weather_prefix + "snow";
|
||||||
case 85:
|
case 85:
|
||||||
case 86:
|
case 86:
|
||||||
return weather_prefix + "snow"
|
return weather_prefix + "snow";
|
||||||
case 95:
|
case 95:
|
||||||
return weather_prefix + "thunderstorm"
|
return weather_prefix + "thunderstorm";
|
||||||
case 96:
|
case 96:
|
||||||
case 99:
|
case 99:
|
||||||
return weather_prefix + "storm-showers"
|
return weather_prefix + "storm-showers";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -89,9 +89,7 @@ Item {
|
|||||||
Layout.alignment: Qt.AlignCenter
|
Layout.alignment: Qt.AlignCenter
|
||||||
horizontalAlignment: Text.AlignHCenter
|
horizontalAlignment: Text.AlignHCenter
|
||||||
color: Material.primaryTextColor
|
color: Material.primaryTextColor
|
||||||
text: "longtitude: " + weather.longtitude + " - latitude: "
|
text: "longtitude: " + weather.longtitude + " - latitude: " + weather.latitude + " - elevation: " + weather.elevation + "m - population: " + weather.population
|
||||||
+ weather.latitude + " - elevation: " + weather.elevation
|
|
||||||
+ "m - population: " + weather.population
|
|
||||||
}
|
}
|
||||||
|
|
||||||
RowLayout {
|
RowLayout {
|
||||||
@ -129,8 +127,7 @@ Item {
|
|||||||
}
|
}
|
||||||
Layout.alignment: Qt.AlignCenter
|
Layout.alignment: Qt.AlignCenter
|
||||||
horizontalAlignment: Image.AlignHCenter
|
horizontalAlignment: Image.AlignHCenter
|
||||||
source: "qrc:/qml/ScreenPlayWeather/assets/icons/" + root.mapWeatherCode(
|
source: "qrc:/qml/ScreenPlayWeather/assets/icons/" + root.mapWeatherCode(weatherCode) + ".svg"
|
||||||
weatherCode) + ".svg"
|
|
||||||
}
|
}
|
||||||
TextItem {
|
TextItem {
|
||||||
text: "Weather Code"
|
text: "Weather Code"
|
||||||
|
@ -1,4 +1,3 @@
|
|||||||
|
|
||||||
// SPDX-License-Identifier: BSD-3-Clause
|
// SPDX-License-Identifier: BSD-3-Clause
|
||||||
import QtQuick
|
import QtQuick
|
||||||
import QtQuick.Controls
|
import QtQuick.Controls
|
||||||
@ -15,27 +14,27 @@ Item {
|
|||||||
property int defaultHeight: 200
|
property int defaultHeight: 200
|
||||||
|
|
||||||
function request(url, callback) {
|
function request(url, callback) {
|
||||||
var xhr = new XMLHttpRequest()
|
var xhr = new XMLHttpRequest();
|
||||||
xhr.onreadystatechange = (function (myxhr) {
|
xhr.onreadystatechange = (function (myxhr) {
|
||||||
return function () {
|
return function () {
|
||||||
if (myxhr.readyState === 4)
|
if (myxhr.readyState === 4)
|
||||||
callback(myxhr)
|
callback(myxhr);
|
||||||
}
|
};
|
||||||
})(xhr)
|
})(xhr);
|
||||||
xhr.open('GET', url)
|
xhr.open('GET', url);
|
||||||
xhr.send('')
|
xhr.send('');
|
||||||
}
|
}
|
||||||
|
|
||||||
Component.onCompleted: {
|
Component.onCompleted: {
|
||||||
request("http://xkcd.com/info.0.json", function (o) {
|
request("http://xkcd.com/info.0.json", function (o) {
|
||||||
if (o.status === 200) {
|
if (o.status === 200) {
|
||||||
var d = eval('new Object(' + o.responseText + ')')
|
var d = eval('new Object(' + o.responseText + ')');
|
||||||
console.log(o.responseText)
|
console.log(o.responseText);
|
||||||
img.source = d.img
|
img.source = d.img;
|
||||||
} else {
|
} else {
|
||||||
console.log("Some error has occurred")
|
console.log("Some error has occurred");
|
||||||
}
|
}
|
||||||
})
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
Image {
|
Image {
|
||||||
@ -45,22 +44,22 @@ Item {
|
|||||||
property size imgSize: Qt.size(root.defaultWidth, defaultHeight)
|
property size imgSize: Qt.size(root.defaultWidth, defaultHeight)
|
||||||
onStatusChanged: {
|
onStatusChanged: {
|
||||||
if (img.status !== Image.Ready)
|
if (img.status !== Image.Ready)
|
||||||
return
|
return;
|
||||||
if (img.sourceSize.width === 0 || img.sourceSize.height === 0)
|
if (img.sourceSize.width === 0 || img.sourceSize.height === 0)
|
||||||
return
|
return;
|
||||||
root.implicitWidth = img.sourceSize.width
|
root.implicitWidth = img.sourceSize.width;
|
||||||
root.implicitHeight = img.sourceSize.height
|
root.implicitHeight = img.sourceSize.height;
|
||||||
print(img.status, img.sourceSize.width, img.sourceSize.height)
|
print(img.status, img.sourceSize.width, img.sourceSize.height);
|
||||||
img.imgSize = Qt.size(img.sourceSize.width, img.sourceSize.height)
|
img.imgSize = Qt.size(img.sourceSize.width, img.sourceSize.height);
|
||||||
print("img.size", img.imgSize)
|
print("img.size", img.imgSize);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
MouseArea {
|
MouseArea {
|
||||||
anchors.fill: parent
|
anchors.fill: parent
|
||||||
onClicked: {
|
onClicked: {
|
||||||
root.state = root.state === "expanded" ? "normal" : "expanded"
|
root.state = root.state === "expanded" ? "normal" : "expanded";
|
||||||
print(root.state, root.implicitHeight, root.implicitWidth)
|
print(root.state, root.implicitHeight, root.implicitWidth);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -11,17 +11,9 @@ Item {
|
|||||||
implicitWidth: 240
|
implicitWidth: 240
|
||||||
implicitHeight: 120
|
implicitHeight: 120
|
||||||
property int totalHours: 24
|
property int totalHours: 24
|
||||||
property int remainingHours: Math.max(0, Math.floor(
|
property int remainingHours: Math.max(0, Math.floor((new Date().setHours(24, 0, 0, 0) - new Date()) / 3600000))
|
||||||
(new Date().setHours(
|
property int totalDays: new Date(new Date().getFullYear() + 1, 0, 1) - new Date() / (24 * 60 * 60 * 1000)
|
||||||
24, 0, 0,
|
property int remainingDays: Math.max(0, Math.floor((new Date(new Date().getFullYear() + 1, 0, 1) - new Date()) / (24 * 60 * 60 * 1000)))
|
||||||
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.theme: Material.Dark
|
||||||
Material.accent: Material.DeepOrange
|
Material.accent: Material.DeepOrange
|
||||||
@ -50,11 +42,7 @@ Item {
|
|||||||
running: true
|
running: true
|
||||||
repeat: true
|
repeat: true
|
||||||
onTriggered: {
|
onTriggered: {
|
||||||
remainingHours = Math.max(
|
remainingHours = Math.max(0, Math.floor((new Date().setHours(24, 0, 0, 0) - new Date()) / 3600000));
|
||||||
0,
|
|
||||||
Math.floor((new Date().setHours(
|
|
||||||
24, 0, 0,
|
|
||||||
0) - new Date()) / 3600000))
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -81,11 +69,7 @@ Item {
|
|||||||
running: true
|
running: true
|
||||||
repeat: true
|
repeat: true
|
||||||
onTriggered: {
|
onTriggered: {
|
||||||
remainingDays = Math.max(0,
|
remainingDays = Math.max(0, Math.floor((new Date(new Date().getFullYear() + 1, 0, 1) - new Date()) / (24 * 60 * 60 * 1000)));
|
||||||
Math.floor((new Date(new Date().getFullYear(
|
|
||||||
) + 1,
|
|
||||||
0, 1)
|
|
||||||
- new Date()) / (24 * 60 * 60 * 1000)))
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -138,6 +138,7 @@ set(RESOURCES
|
|||||||
assets/icons/icon_close.svg
|
assets/icons/icon_close.svg
|
||||||
assets/icons/icon_code.svg
|
assets/icons/icon_code.svg
|
||||||
assets/icons/icon_community.svg
|
assets/icons/icon_community.svg
|
||||||
|
assets/icons/icon_contains_audio.svg
|
||||||
assets/icons/icon_delete.svg
|
assets/icons/icon_delete.svg
|
||||||
assets/icons/icon_document.svg
|
assets/icons/icon_document.svg
|
||||||
assets/icons/icon_done.svg
|
assets/icons/icon_done.svg
|
||||||
@ -152,7 +153,6 @@ set(RESOURCES
|
|||||||
assets/icons/icon_installed.svg
|
assets/icons/icon_installed.svg
|
||||||
assets/icons/icon_launch.svg
|
assets/icons/icon_launch.svg
|
||||||
assets/icons/icon_minimize.svg
|
assets/icons/icon_minimize.svg
|
||||||
assets/icons/icon_contains_audio.svg
|
|
||||||
assets/icons/icon_movie.svg
|
assets/icons/icon_movie.svg
|
||||||
assets/icons/icon_new_releases.svg
|
assets/icons/icon_new_releases.svg
|
||||||
assets/icons/icon_open_in_new.svg
|
assets/icons/icon_open_in_new.svg
|
||||||
|
@ -175,7 +175,6 @@ Item {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
Image {
|
Image {
|
||||||
id: icnType
|
id: icnType
|
||||||
|
|
||||||
|
@ -43,7 +43,7 @@ Item {
|
|||||||
const item = App.installedListModel.get(root.contentFolderName);
|
const item = App.installedListModel.get(root.contentFolderName);
|
||||||
txtHeadline.text = item.m_title;
|
txtHeadline.text = item.m_title;
|
||||||
const previewGiFilePath = Qt.resolvedUrl(item.m_absoluteStoragePath + "/" + item.m_previewGIF);
|
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);
|
root.hasPreviewGif = App.util.fileExists(previewGiFilePath);
|
||||||
if (hasPreviewGif) {
|
if (hasPreviewGif) {
|
||||||
animatedImagePreview.source = previewGiFilePath;
|
animatedImagePreview.source = previewGiFilePath;
|
||||||
|
@ -82,7 +82,7 @@ Item {
|
|||||||
isChecked: App.settings.showDefaultContent
|
isChecked: App.settings.showDefaultContent
|
||||||
onCheckboxChanged: function (checked) {
|
onCheckboxChanged: function (checked) {
|
||||||
App.settings.setShowDefaultContent(checked);
|
App.settings.setShowDefaultContent(checked);
|
||||||
App.installedListModel.reset()
|
App.installedListModel.reset();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -186,20 +186,19 @@ void ScreenPlaySDK::ScreenPlaySDK::redirectMessageOutputToMainWindow(QtMsgType t
|
|||||||
|
|
||||||
// Also redirect to regular output if we debug
|
// Also redirect to regular output if we debug
|
||||||
// wallpaper or widgets directly
|
// wallpaper or widgets directly
|
||||||
switch (type)
|
switch (type) {
|
||||||
{
|
|
||||||
case QtDebugMsg:
|
case QtDebugMsg:
|
||||||
qDebug() << msg;
|
qDebug() << msg;
|
||||||
break;
|
break;
|
||||||
case QtWarningMsg:
|
case QtWarningMsg:
|
||||||
qWarning() << msg;
|
qWarning() << msg;
|
||||||
break;
|
break;
|
||||||
case QtCriticalMsg:
|
case QtCriticalMsg:
|
||||||
case QtFatalMsg:
|
case QtFatalMsg:
|
||||||
qCritical() << msg;
|
qCritical() << msg;
|
||||||
break;
|
break;
|
||||||
case QtInfoMsg:
|
case QtInfoMsg:
|
||||||
qInfo() << msg;
|
qInfo() << msg;
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
|
@ -27,9 +27,9 @@ bool ProjectFile::init()
|
|||||||
return false;
|
return false;
|
||||||
file = obj.value("file").toString();
|
file = obj.value("file").toString();
|
||||||
|
|
||||||
QFileInfo fileInfo(folder.path() + "/"+ file);
|
QFileInfo fileInfo(folder.path() + "/" + file);
|
||||||
if(!fileInfo.exists()){
|
if (!fileInfo.exists()) {
|
||||||
qCritical() << "Requested file:" << fileInfo.absoluteFilePath() << "does not exist!";
|
qCritical() << "Requested file:" << fileInfo.absoluteFilePath() << "does not exist!";
|
||||||
return false;
|
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");
|
QFileInfo audioFile(folder.absolutePath() + "/audio.mp3");
|
||||||
containsAudio = audioFile.exists();
|
containsAudio = audioFile.exists();
|
||||||
}
|
}
|
||||||
|
@ -49,7 +49,7 @@ Item {
|
|||||||
onPlaybackStateChanged: {
|
onPlaybackStateChanged: {
|
||||||
if (mediaPlayer.playbackState == MediaPlayer.PlayingState && !fadeInDone) {
|
if (mediaPlayer.playbackState == MediaPlayer.PlayingState && !fadeInDone) {
|
||||||
fadeInDone = true;
|
fadeInDone = true;
|
||||||
startTimer.start()
|
startTimer.start();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
loops: root.loops ? MediaPlayer.Infinite : 1
|
loops: root.loops ? MediaPlayer.Infinite : 1
|
||||||
@ -72,8 +72,7 @@ Item {
|
|||||||
id: pauseTimer
|
id: pauseTimer
|
||||||
interval: 100
|
interval: 100
|
||||||
onTriggered: {
|
onTriggered: {
|
||||||
mediaPlayer.pause()
|
mediaPlayer.pause();
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Connections {
|
Connections {
|
||||||
@ -96,12 +95,12 @@ Item {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function onVisualsPausedChanged(visualsPaused) {
|
function onVisualsPausedChanged(visualsPaused) {
|
||||||
if(!Wallpaper.isPlaying)
|
if (!Wallpaper.isPlaying)
|
||||||
return
|
return;
|
||||||
if(visualsPaused)
|
if (visualsPaused)
|
||||||
pauseTimer.start()
|
pauseTimer.start();
|
||||||
else
|
else
|
||||||
mediaPlayer.play()
|
mediaPlayer.play();
|
||||||
}
|
}
|
||||||
|
|
||||||
target: Wallpaper
|
target: Wallpaper
|
||||||
|
@ -60,8 +60,8 @@ ScreenPlay::WallpaperExitCode BaseWindow::setup()
|
|||||||
|
|
||||||
// We do not yet have implemented continue playing the audio.mp3 yet
|
// We do not yet have implemented continue playing the audio.mp3 yet
|
||||||
// so disable the checkWallpaperVisible for now
|
// so disable the checkWallpaperVisible for now
|
||||||
if(checkWallpaperVisible()){
|
if (checkWallpaperVisible()) {
|
||||||
if(projectFile.containsAudio){
|
if (projectFile.containsAudio) {
|
||||||
qInfo() << "Disable wallpaper visible check, because it contains audio.";
|
qInfo() << "Disable wallpaper visible check, because it contains audio.";
|
||||||
setCheckWallpaperVisible(false);
|
setCheckWallpaperVisible(false);
|
||||||
}
|
}
|
||||||
|
@ -26,7 +26,7 @@ int main(int argc, char* argv[])
|
|||||||
QtWebEngineQuick::initialize();
|
QtWebEngineQuick::initialize();
|
||||||
|
|
||||||
#if defined(Q_OS_WIN)
|
#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_DISABLE_HW_TEXTURES_CONVERSION", "1");
|
||||||
qputenv("QT_MEDIA_BACKEND", "ffmpeg");
|
qputenv("QT_MEDIA_BACKEND", "ffmpeg");
|
||||||
#endif
|
#endif
|
||||||
@ -55,8 +55,8 @@ int main(int argc, char* argv[])
|
|||||||
|
|
||||||
// Lets center the widget
|
// Lets center the widget
|
||||||
const auto* screen = QGuiApplication::screens().at(0);
|
const auto* screen = QGuiApplication::screens().at(0);
|
||||||
const int offset = - 200;
|
const int offset = -200;
|
||||||
QPoint center((screen->size().width() / 2) + offset, (screen->size().height() / 2)+offset);
|
QPoint center((screen->size().width() / 2) + offset, (screen->size().height() / 2) + offset);
|
||||||
|
|
||||||
WidgetWindow spwmw(projectPath,
|
WidgetWindow spwmw(projectPath,
|
||||||
"appid",
|
"appid",
|
||||||
|
56
Tools/check_format_cmake.py
Normal file
56
Tools/check_format_cmake.py
Normal file
@ -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)
|
61
Tools/check_format_cpp.py
Normal file
61
Tools/check_format_cpp.py
Normal file
@ -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 "<replacement " in result.stdout:
|
||||||
|
print(f"{file} is not correctly formatted.")
|
||||||
|
print(f"{result.stdout} ")
|
||||||
|
return False
|
||||||
|
return True
|
||||||
|
|
||||||
|
|
||||||
|
def main(git_staged_only=False, check_only=False):
|
||||||
|
exclude_folders = ("ScreenPlayWorkshop/SteamSDK",
|
||||||
|
"ThirdParty", "build-x64-windows-release")
|
||||||
|
file_list = find_files(
|
||||||
|
('.cpp', '.h'), util.repo_root_path(), git_staged_only, exclude_folders)
|
||||||
|
|
||||||
|
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)
|
86
Tools/check_format_qml.py
Normal file
86
Tools/check_format_qml.py
Normal file
@ -0,0 +1,86 @@
|
|||||||
|
#!/usr/bin/python3
|
||||||
|
import os
|
||||||
|
import subprocess
|
||||||
|
import argparse
|
||||||
|
import util
|
||||||
|
import defines
|
||||||
|
import hashlib
|
||||||
|
from format_util import find_files
|
||||||
|
from format_util import execute_threaded
|
||||||
|
from sys import stdout, exit
|
||||||
|
import hashlib
|
||||||
|
import shutil
|
||||||
|
|
||||||
|
stdout.reconfigure(encoding='utf-8')
|
||||||
|
|
||||||
|
|
||||||
|
def format_qml_file(file):
|
||||||
|
executable = "qmlformat"
|
||||||
|
if os.name == 'nt':
|
||||||
|
executable = "qmlformat.exe"
|
||||||
|
qt_bin_path = defines.QT_BIN_PATH
|
||||||
|
executable = qt_bin_path.joinpath(executable)
|
||||||
|
|
||||||
|
# Add -i for formatting in place
|
||||||
|
process = subprocess.run(
|
||||||
|
[executable, "-i -l unix", file], capture_output=True, shell=True)
|
||||||
|
print("Format: %s \t return: %s" % (file, process.returncode))
|
||||||
|
|
||||||
|
|
||||||
|
def compute_md5(file_path):
|
||||||
|
"""Compute MD5 hash of the content of the given file."""
|
||||||
|
with open(file_path, 'rb') as f:
|
||||||
|
return hashlib.md5(f.read()).hexdigest()
|
||||||
|
|
||||||
|
|
||||||
|
def check_format_qml_file(file):
|
||||||
|
executable = "qmlformat"
|
||||||
|
if os.name == 'nt':
|
||||||
|
executable = "qmlformat.exe"
|
||||||
|
qt_bin_path = defines.QT_BIN_PATH
|
||||||
|
executable = qt_bin_path.joinpath(executable)
|
||||||
|
|
||||||
|
# Step 1: Copy the original file
|
||||||
|
backup_file = file + ".backup"
|
||||||
|
shutil.copy(file, backup_file)
|
||||||
|
|
||||||
|
# Step 2: Run qmlformat with in-place editing
|
||||||
|
subprocess.run([executable, "-i", file], check=True)
|
||||||
|
|
||||||
|
# Step 3: Compare MD5 hash of the original (backup) and the formatted file
|
||||||
|
original_hash = compute_md5(backup_file)
|
||||||
|
formatted_hash = compute_md5(file)
|
||||||
|
|
||||||
|
# Step 4: Remove the backup copy
|
||||||
|
os.remove(backup_file)
|
||||||
|
|
||||||
|
# Step 5: Return the comparison result
|
||||||
|
if original_hash != formatted_hash:
|
||||||
|
print(f"{file} is not correctly formatted.")
|
||||||
|
return False
|
||||||
|
return True
|
||||||
|
|
||||||
|
|
||||||
|
def main(git_staged_only=False, check_only=False):
|
||||||
|
exclude_folders = ("ThirdParty", "build-x64-windows-release")
|
||||||
|
file_list = find_files(('.qml'), util.repo_root_path(),
|
||||||
|
git_staged_only, exclude_folders)
|
||||||
|
|
||||||
|
if check_only:
|
||||||
|
result = execute_threaded(file_list, check_format_qml_file)
|
||||||
|
if not result:
|
||||||
|
print("Some files are not correctly formatted!")
|
||||||
|
exit(1)
|
||||||
|
else:
|
||||||
|
execute_threaded(file_list, format_qml_file)
|
||||||
|
|
||||||
|
|
||||||
|
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)
|
@ -1,36 +0,0 @@
|
|||||||
#!/usr/bin/python3
|
|
||||||
# SPDX-License-Identifier: LicenseRef-EliasSteurerTachiom OR AGPL-3.0-only
|
|
||||||
import os
|
|
||||||
import subprocess
|
|
||||||
import argparse
|
|
||||||
from format_util import find_files
|
|
||||||
from format_util import check_git_exit
|
|
||||||
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 main(git_staged_only=False):
|
|
||||||
file_list = find_files(('.cpp', '.h'), "", git_staged_only)
|
|
||||||
execute_threaded(file_list, format_file_function)
|
|
||||||
if not git_staged_only:
|
|
||||||
check_git_exit("Clang Format")
|
|
||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
|
||||||
parser = argparse.ArgumentParser()
|
|
||||||
parser.add_argument('-s', action="store_true", dest="stage_only",
|
|
||||||
default=False)
|
|
||||||
args = parser.parse_args()
|
|
||||||
main(args.stage_only)
|
|
@ -1,31 +0,0 @@
|
|||||||
#!/usr/bin/python3
|
|
||||||
# SPDX-License-Identifier: LicenseRef-EliasSteurerTachiom OR AGPL-3.0-only
|
|
||||||
import os
|
|
||||||
import argparse
|
|
||||||
from format_util import find_files
|
|
||||||
from format_util import check_git_exit
|
|
||||||
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 = "cmake-format.exe"
|
|
||||||
os.system(" %s -c ../.cmake-format.py -i %s" % (executable, file))
|
|
||||||
print("Format: ", file)
|
|
||||||
|
|
||||||
def main(git_staged_only=False):
|
|
||||||
file_list = find_files(('CMakeLists.txt'), "", git_staged_only)
|
|
||||||
execute_threaded(file_list, format_file_function)
|
|
||||||
if not git_staged_only:
|
|
||||||
check_git_exit("CMake Format")
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
|
||||||
parser = argparse.ArgumentParser()
|
|
||||||
parser.add_argument('-s', action="store_true", dest="stage_only",
|
|
||||||
default=False)
|
|
||||||
args = parser.parse_args()
|
|
||||||
main(args.stage_only)
|
|
@ -3,6 +3,7 @@
|
|||||||
import subprocess
|
import subprocess
|
||||||
import sys
|
import sys
|
||||||
import os
|
import os
|
||||||
|
import util
|
||||||
from multiprocessing import cpu_count
|
from multiprocessing import cpu_count
|
||||||
from multiprocessing import Pool
|
from multiprocessing import Pool
|
||||||
from multiprocessing import dummy
|
from multiprocessing import dummy
|
||||||
@ -28,33 +29,38 @@ def find_all_git_staged_files():
|
|||||||
return out
|
return out
|
||||||
|
|
||||||
|
|
||||||
def find_files(file_endings_tuple, path="", git_staged_only=False):
|
def find_files(file_endings_tuple, path="", git_staged_only=False, exclude_folders=()):
|
||||||
file_list = []
|
file_list = []
|
||||||
# Get the root folder by moving one up
|
|
||||||
root = Path(__file__).parent.absolute()
|
|
||||||
root = os.path.abspath(os.path.join(root, "../"))
|
|
||||||
|
|
||||||
root = os.path.join(root, path)
|
|
||||||
print(root)
|
|
||||||
|
|
||||||
if git_staged_only:
|
if git_staged_only:
|
||||||
file_list = find_all_git_staged_files()
|
file_list = find_all_git_staged_files() # Assuming you've defined this
|
||||||
else:
|
else:
|
||||||
file_list = find_all_files(root)
|
for dirpath, dirnames, filenames in os.walk(path):
|
||||||
|
# Normalize the current directory path
|
||||||
|
norm_dirpath = os.path.normpath(dirpath)
|
||||||
|
|
||||||
filtered_file_list = []
|
# Check if the current directory is to be excluded
|
||||||
for filename in file_list:
|
if exclude_folders and any(os.path.normpath(excl_folder) in norm_dirpath for excl_folder in exclude_folders):
|
||||||
if filename.endswith(file_endings_tuple):
|
continue
|
||||||
filtered_file_list.append(os.path.join(root, filename))
|
|
||||||
|
|
||||||
return filtered_file_list
|
for filename in filenames:
|
||||||
|
if filename.endswith(file_endings_tuple):
|
||||||
|
file_list.append(os.path.join(dirpath, filename))
|
||||||
|
|
||||||
|
return file_list
|
||||||
|
|
||||||
|
|
||||||
def execute_threaded(file_list, format_file_function):
|
def execute_threaded(file_list, format_file_function):
|
||||||
p = Pool(cpu_count())
|
if not file_list:
|
||||||
p.map(format_file_function, file_list)
|
return True # or False, depending on how you want to handle an empty list
|
||||||
p.close()
|
|
||||||
p.join()
|
with Pool(cpu_count()) as p:
|
||||||
|
results = p.map(format_file_function, file_list)
|
||||||
|
|
||||||
|
# Check if any result is False and return accordingly
|
||||||
|
if any(result is False for result in results):
|
||||||
|
return False
|
||||||
|
return True
|
||||||
|
|
||||||
|
|
||||||
def check_git_exit(caller_name):
|
def check_git_exit(caller_name):
|
||||||
@ -70,4 +76,3 @@ def check_git_exit(caller_name):
|
|||||||
out.replace("\\n", "\n")
|
out.replace("\\n", "\n")
|
||||||
# print(out)
|
# print(out)
|
||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
|
|
||||||
|
@ -1,40 +0,0 @@
|
|||||||
#!/usr/bin/python3
|
|
||||||
# SPDX-License-Identifier: LicenseRef-EliasSteurerTachiom OR AGPL-3.0-only
|
|
||||||
import os
|
|
||||||
import subprocess
|
|
||||||
import argparse
|
|
||||||
import sys
|
|
||||||
import defines
|
|
||||||
from format_util import find_files
|
|
||||||
from format_util import check_git_exit
|
|
||||||
from format_util import execute_threaded
|
|
||||||
from sys import stdout
|
|
||||||
|
|
||||||
stdout.reconfigure(encoding='utf-8')
|
|
||||||
|
|
||||||
|
|
||||||
def format_file_function(file):
|
|
||||||
executable = "qmlformat"
|
|
||||||
if os.name == 'nt':
|
|
||||||
executable = "qmlformat.exe"
|
|
||||||
qt_bin_path = defines.QT_BIN_PATH
|
|
||||||
executable = qt_bin_path.joinpath(executable)
|
|
||||||
|
|
||||||
process = subprocess.run(
|
|
||||||
"%s -i %s" % (executable, file), capture_output=True, shell=True)
|
|
||||||
print("Format: %s \t return: %s" % (file, process.returncode))
|
|
||||||
|
|
||||||
|
|
||||||
def main(git_staged_only=False):
|
|
||||||
file_list = find_files(('.qml'), os.path.abspath(os.path.join(os.getcwd(), "../")), git_staged_only)
|
|
||||||
execute_threaded(file_list, format_file_function)
|
|
||||||
if not git_staged_only:
|
|
||||||
check_git_exit("QML Format")
|
|
||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
|
||||||
parser = argparse.ArgumentParser()
|
|
||||||
parser.add_argument('-s', action="store_true", dest="stage_only",
|
|
||||||
default=False)
|
|
||||||
args = parser.parse_args()
|
|
||||||
main(args.stage_only)
|
|
Loading…
Reference in New Issue
Block a user