From 2f4d52403b17c6aeb4095d3cf50035fe411e4db7 Mon Sep 17 00:00:00 2001 From: quadbyte Date: Sun, 10 Aug 2025 14:49:43 -0400 Subject: [PATCH] Fixed all qmlfmt warnings/errors --- Bin/run-qmlfmt.sh | 1 - Modules/Background/WallpaperPicker.qml | 8 + Modules/DemoPanel/DemoPanel.qml | 68 ++++-- Services/Location.qml | 10 +- Services/MediaPlayer.qml | 284 ++++++++++++------------- Widgets/NToggle.qml | 8 +- 6 files changed, 210 insertions(+), 169 deletions(-) diff --git a/Bin/run-qmlfmt.sh b/Bin/run-qmlfmt.sh index 39f2579..71f4f90 100755 --- a/Bin/run-qmlfmt.sh +++ b/Bin/run-qmlfmt.sh @@ -4,5 +4,4 @@ # Can be installed from AUR "qmlfmt-git" # Requires qt6-5compat -#find . -name "*.qml" -exec sh -c 'echo "Formatting $0..."; qmlfmt -e -b 120 -t 2 -i 2 -w "$0"' {} \; find . -name "*.qml" -print -exec qmlfmt -e -b 120 -t 2 -i 2 -w {} \; \ No newline at end of file diff --git a/Modules/Background/WallpaperPicker.qml b/Modules/Background/WallpaperPicker.qml index e69de29..5fc2b8b 100644 --- a/Modules/Background/WallpaperPicker.qml +++ b/Modules/Background/WallpaperPicker.qml @@ -0,0 +1,8 @@ +pragma Singleton + +import Quickshell +import qs.Services + +Item { + id: root +} diff --git a/Modules/DemoPanel/DemoPanel.qml b/Modules/DemoPanel/DemoPanel.qml index 8236509..5b26c70 100644 --- a/Modules/DemoPanel/DemoPanel.qml +++ b/Modules/DemoPanel/DemoPanel.qml @@ -6,10 +6,10 @@ import Quickshell.Wayland import qs.Services import qs.Widgets + /* An experiment/demo panel to tweaks widgets */ - NLoader { id: root @@ -32,7 +32,9 @@ NLoader { anchors.centerIn: parent // Prevent closing when clicking in the panel bg - MouseArea { anchors.fill: parent } + MouseArea { + anchors.fill: parent + } ColumnLayout { anchors.fill: parent @@ -42,61 +44,93 @@ NLoader { // NIconButton ColumnLayout { spacing: 16 * scaling - NText { text: "NIconButton"; color: Colors.accentSecondary } + NText { + text: "NIconButton" + color: Colors.accentSecondary + } NIconButton { id: myIconButton icon: "refresh" - onEntered: function() { myTooltip.show() } - onExited: function() { myTooltip.hide() } + onEntered: function () { + myTooltip.show() + } + onExited: function () { + myTooltip.hide() + } + } + NTooltip { + id: myTooltip + target: myIconButton + positionAbove: false + text: "Hello world" } - NTooltip { id: myTooltip; target: myIconButton; positionAbove: false; text: "Hello world"; } - NDivider { Layout.fillWidth: true } + NDivider { + Layout.fillWidth: true + } } // NToggle ColumnLayout { spacing: Style.marginLarge * scaling uniformCellSizes: true - NText { text: "NToggle + NTooltip"; color: Colors.accentSecondary } + NText { + text: "NToggle + NTooltip" + color: Colors.accentSecondary + } NToggle { label: "Label" description: "Description" - onToggled: function(value: bool) { console.log("NToggle: " + value) } + onToggled: function (value) { + console.log("NToggle: " + value) + } } - - NDivider { Layout.fillWidth: true } + NDivider { + Layout.fillWidth: true + } } // NSlider ColumnLayout { spacing: 16 * scaling - NText { text: "Scaling"; color: Colors.accentSecondary } + NText { + text: "Scaling" + color: Colors.accentSecondary + } RowLayout { spacing: Style.marginSmall * scaling - NText { text: `${Math.round(Scaling.overrideScale * 100)}%`; Layout.alignment: Qt.AlignVCenter } + NText { + text: `${Math.round(Scaling.overrideScale * 100)}%` + Layout.alignment: Qt.AlignVCenter + } NSlider { id: scaleSlider from: 0.6 to: 1.8 stepSize: 0.01 value: Scaling.overrideScale - onMoved: function() { Scaling.overrideScale = value } - onPressedChanged: function() { Scaling.overrideEnabled = true } + onMoved: function () { + Scaling.overrideScale = value + } + onPressedChanged: function () { + Scaling.overrideEnabled = true + } } NIconButton { icon: "restart_alt" sizeMultiplier: 0.7 - onClicked: function() { + onClicked: function () { Scaling.overrideEnabled = false Scaling.overrideScale = 1.0 } } } - NDivider { Layout.fillWidth: true } + NDivider { + Layout.fillWidth: true + } } } } diff --git a/Services/Location.qml b/Services/Location.qml index 9458435..64d8820 100644 --- a/Services/Location.qml +++ b/Services/Location.qml @@ -1,2 +1,10 @@ +pragma Singleton + +import Quickshell +import qs.Services + // Weather logic and caching -// Calendar Hollidays logic and caching \ No newline at end of file +// Calendar Hollidays logic and caching +Singleton { + id: root +} diff --git a/Services/MediaPlayer.qml b/Services/MediaPlayer.qml index b9d17d0..806142c 100644 --- a/Services/MediaPlayer.qml +++ b/Services/MediaPlayer.qml @@ -1,169 +1,161 @@ -// pragma Singleton +pragma Singleton -// import QtQuick -// import Quickshell -// import Quickshell.Services.Mpris -// import qs.Services +import Quickshell +import Quickshell.Services.Mpris +import qs.Services -// Singleton { -// id: manager +Singleton { + id: root -// property var currentPlayer: null -// property real currentPosition: 0 -// property int selectedPlayerIndex: 0 -// property bool isPlaying: currentPlayer ? currentPlayer.isPlaying : false -// property string trackTitle: currentPlayer ? (currentPlayer.trackTitle -// || "Unknown Track") : "" -// property string trackArtist: currentPlayer ? (currentPlayer.trackArtist -// || "Unknown Artist") : "" -// property string trackAlbum: currentPlayer ? (currentPlayer.trackAlbum -// || "Unknown Album") : "" -// property string trackArtUrl: currentPlayer ? (currentPlayer.trackArtUrl -// || "") : "" -// property real trackLength: currentPlayer ? currentPlayer.length : 0 -// property bool canPlay: currentPlayer ? currentPlayer.canPlay : false -// property bool canPause: currentPlayer ? currentPlayer.canPause : false -// property bool canGoNext: currentPlayer ? currentPlayer.canGoNext : false -// property bool canGoPrevious: currentPlayer ? currentPlayer.canGoPrevious : false -// property bool canSeek: currentPlayer ? currentPlayer.canSeek : false -// property bool hasPlayer: getAvailablePlayers().length > 0 + // property var currentPlayer: null + // property real currentPosition: 0 + // property int selectedPlayerIndex: 0 + // property bool isPlaying: currentPlayer ? currentPlayer.isPlaying : false + // property string trackTitle: currentPlayer ? (currentPlayer.trackTitle || "Unknown Track") : "" + // property string trackArtist: currentPlayer ? (currentPlayer.trackArtist || "Unknown Artist") : "" + // property string trackAlbum: currentPlayer ? (currentPlayer.trackAlbum || "Unknown Album") : "" + // property string trackArtUrl: currentPlayer ? (currentPlayer.trackArtUrl || "") : "" + // property real trackLength: currentPlayer ? currentPlayer.length : 0 + // property bool canPlay: currentPlayer ? currentPlayer.canPlay : false + // property bool canPause: currentPlayer ? currentPlayer.canPause : false + // property bool canGoNext: currentPlayer ? currentPlayer.canGoNext : false + // property bool canGoPrevious: currentPlayer ? currentPlayer.canGoPrevious : false + // property bool canSeek: currentPlayer ? currentPlayer.canSeek : false + // property bool hasPlayer: getAvailablePlayers().length > 0 -// Item { -// Component.onCompleted: { -// updateCurrentPlayer() -// } -// } + // Item { + // Component.onCompleted: { + // updateCurrentPlayer() + // } + // } -// function getAvailablePlayers() { -// if (!Mpris.players || !Mpris.players.values) { -// return [] -// } + // function getAvailablePlayers() { + // if (!Mpris.players || !Mpris.players.values) { + // return [] + // } -// let allPlayers = Mpris.players.values -// let controllablePlayers = [] + // let allPlayers = Mpris.players.values + // let controllablePlayers = [] -// for (var i = 0; i < allPlayers.length; i++) { -// let player = allPlayers[i] -// if (player && player.canControl) { -// controllablePlayers.push(player) -// } -// } + // for (var i = 0; i < allPlayers.length; i++) { + // let player = allPlayers[i] + // if (player && player.canControl) { + // controllablePlayers.push(player) + // } + // } -// return controllablePlayers -// } + // return controllablePlayers + // } -// function findActivePlayer() { -// let availablePlayers = getAvailablePlayers() -// if (availablePlayers.length === 0) { -// return null -// } + // function findActivePlayer() { + // let availablePlayers = getAvailablePlayers() + // if (availablePlayers.length === 0) { + // return null + // } -// if (selectedPlayerIndex < availablePlayers.length) { -// return availablePlayers[selectedPlayerIndex] -// } else { -// selectedPlayerIndex = 0 -// return availablePlayers[0] -// } -// } + // if (selectedPlayerIndex < availablePlayers.length) { + // return availablePlayers[selectedPlayerIndex] + // } else { + // selectedPlayerIndex = 0 + // return availablePlayers[0] + // } + // } -// // Switch to the most recently active player -// function updateCurrentPlayer() { -// let newPlayer = findActivePlayer() -// if (newPlayer !== currentPlayer) { -// currentPlayer = newPlayer -// currentPosition = currentPlayer ? currentPlayer.position : 0 -// } -// } + // // Switch to the most recently active player + // function updateCurrentPlayer() { + // let newPlayer = findActivePlayer() + // if (newPlayer !== currentPlayer) { + // currentPlayer = newPlayer + // currentPosition = currentPlayer ? currentPlayer.position : 0 + // } + // } -// function playPause() { -// if (currentPlayer) { -// if (currentPlayer.isPlaying) { -// currentPlayer.pause() -// } else { -// currentPlayer.play() -// } -// } -// } + // function playPause() { + // if (currentPlayer) { + // if (currentPlayer.isPlaying) { + // currentPlayer.pause() + // } else { + // currentPlayer.play() + // } + // } + // } -// function play() { -// if (currentPlayer && currentPlayer.canPlay) { -// currentPlayer.play() -// } -// } + // function play() { + // if (currentPlayer && currentPlayer.canPlay) { + // currentPlayer.play() + // } + // } -// function pause() { -// if (currentPlayer && currentPlayer.canPause) { -// currentPlayer.pause() -// } -// } + // function pause() { + // if (currentPlayer && currentPlayer.canPause) { + // currentPlayer.pause() + // } + // } -// function next() { -// if (currentPlayer && currentPlayer.canGoNext) { -// currentPlayer.next() -// } -// } + // function next() { + // if (currentPlayer && currentPlayer.canGoNext) { + // currentPlayer.next() + // } + // } -// function previous() { -// if (currentPlayer && currentPlayer.canGoPrevious) { -// currentPlayer.previous() -// } -// } + // function previous() { + // if (currentPlayer && currentPlayer.canGoPrevious) { + // currentPlayer.previous() + // } + // } -// function seek(position) { -// if (currentPlayer && currentPlayer.canSeek) { -// currentPlayer.position = position -// currentPosition = position -// } -// } + // function seek(position) { + // if (currentPlayer && currentPlayer.canSeek) { + // currentPlayer.position = position + // currentPosition = position + // } + // } -// // Seek to position based on ratio (0.0 to 1.0) -// function seekByRatio(ratio) { -// if (currentPlayer && currentPlayer.canSeek && currentPlayer.length > 0) { -// let seekPosition = ratio * currentPlayer.length -// currentPlayer.position = seekPosition -// currentPosition = seekPosition -// } -// } + // // Seek to position based on ratio (0.0 to 1.0) + // function seekByRatio(ratio) { + // if (currentPlayer && currentPlayer.canSeek && currentPlayer.length > 0) { + // let seekPosition = ratio * currentPlayer.length + // currentPlayer.position = seekPosition + // currentPosition = seekPosition + // } + // } -// // Update progress bar every second while playing -// Timer { -// id: positionTimer -// interval: 1000 -// running: currentPlayer && currentPlayer.isPlaying -// && currentPlayer.length > 0 -// && currentPlayer.playbackState === MprisPlaybackState.Playing -// repeat: true -// onTriggered: { -// if (currentPlayer && currentPlayer.isPlaying -// && currentPlayer.playbackState === MprisPlaybackState.Playing) { -// currentPosition = currentPlayer.position -// } else { -// running = false -// } -// } -// } + // // Update progress bar every second while playing + // Timer { + // id: positionTimer + // interval: 1000 + // running: currentPlayer && currentPlayer.isPlaying && currentPlayer.length > 0 + // && currentPlayer.playbackState === MprisPlaybackState.Playing + // repeat: true + // onTriggered: { + // if (currentPlayer && currentPlayer.isPlaying && currentPlayer.playbackState === MprisPlaybackState.Playing) { + // currentPosition = currentPlayer.position + // } else { + // running = false + // } + // } + // } -// // Reset position when switching to inactive player -// onCurrentPlayerChanged: { -// if (!currentPlayer || !currentPlayer.isPlaying -// || currentPlayer.playbackState !== MprisPlaybackState.Playing) { -// currentPosition = 0 -// } -// } + // // Reset position when switching to inactive player + // onCurrentPlayerChanged: { + // if (!currentPlayer || !currentPlayer.isPlaying || currentPlayer.playbackState !== MprisPlaybackState.Playing) { + // currentPosition = 0 + // } + // } -// // Update current player when available players change -// Connections { -// target: Mpris.players -// function onValuesChanged() { -// updateCurrentPlayer() -// } -// } + // // Update current player when available players change + // Connections { + // target: Mpris.players + // function onValuesChanged() { + // updateCurrentPlayer() + // } + // } -// Cava { -// id: cava -// count: 44 -// } + // Cava { + // id: cava + // count: 44 + // } -// // Expose cava values -// property alias cavaValues: cava.values -// } + // // Expose cava values + // property alias cavaValues: cava.values +} diff --git a/Widgets/NToggle.qml b/Widgets/NToggle.qml index c4cfc95..1c191f7 100644 --- a/Widgets/NToggle.qml +++ b/Widgets/NToggle.qml @@ -11,7 +11,7 @@ RowLayout { property string description: "" property bool value: false property bool hovering: false - property var onToggled: function (value: bool) {} + property var onToggled: function (value) {} Layout.fillWidth: true @@ -41,7 +41,7 @@ RowLayout { width: Style.baseWidgetSize * 1.625 * scaling height: Style.baseWidgetSize * scaling radius: height * 0.5 - color: value ? Colors.accentPrimary :Colors.surfaceVariant + color: value ? Colors.accentPrimary : Colors.surfaceVariant border.color: value ? Colors.accentPrimary : Colors.outline border.width: Math.min(1, Style.borderMedium * scaling) @@ -70,8 +70,8 @@ RowLayout { onEntered: hovering = true onExited: hovering = false onClicked: { - value = !value; - root.onToggled(value); + value = !value + root.onToggled(value) } } }