Renamed all services to xxxService. Moved a couple things in Commons

This commit is contained in:
quadbyte 2025-08-15 21:45:58 -04:00
parent 7e334ae768
commit 83ff5f5589
86 changed files with 275 additions and 211 deletions

View file

@ -3,6 +3,7 @@ import QtQuick.Controls
import QtQuick.Layouts
import Quickshell
import qs.Modules.Audio
import qs.Commons
import qs.Services
import qs.Widgets
@ -17,7 +18,7 @@ NBox {
// Height can be overridden by parent layout (SidePanel binds it to stats card)
//implicitHeight: content.implicitHeight + Style.marginLarge * 2 * scaling
// Component.onCompleted: {
// console.log(MediaPlayer.trackArtUrl)
// console.log(MediaService.trackArtUrl)
// }
ColumnLayout {
anchors.fill: parent
@ -58,7 +59,7 @@ NBox {
ColumnLayout {
id: main
visible: MediaPlayer.currentPlayer && MediaPlayer.canPlay
visible: MediaService.currentPlayer && MediaService.canPlay
spacing: Style.marginMedium * scaling
// Player selector
@ -66,10 +67,10 @@ NBox {
id: playerSelector
Layout.fillWidth: true
Layout.preferredHeight: Style.barHeight * 0.83 * scaling
visible: MediaPlayer.getAvailablePlayers().length > 1
model: MediaPlayer.getAvailablePlayers()
visible: MediaService.getAvailablePlayers().length > 1
model: MediaService.getAvailablePlayers()
textRole: "identity"
currentIndex: MediaPlayer.selectedPlayerIndex
currentIndex: MediaService.selectedPlayerIndex
background: Rectangle {
visible: false
@ -145,8 +146,8 @@ NBox {
}
onActivated: {
MediaPlayer.selectedPlayerIndex = currentIndex
MediaPlayer.updateCurrentPlayer()
MediaService.selectedPlayerIndex = currentIndex
MediaService.updateCurrentPlayer()
}
}
@ -167,11 +168,11 @@ NBox {
NImageRounded {
id: trackArt
visible: MediaPlayer.trackArtUrl.toString() !== ""
visible: MediaService.trackArtUrl.toString() !== ""
anchors.fill: parent
anchors.margins: Style.marginTiny * scaling
imagePath: MediaPlayer.trackArtUrl
imagePath: MediaService.trackArtUrl
fallbackIcon: "music_note"
borderColor: Colors.mOutline
borderWidth: Math.max(1, Style.borderThin * scaling)
@ -196,8 +197,8 @@ NBox {
spacing: Style.marginTiny * scaling
NText {
visible: MediaPlayer.trackTitle !== ""
text: MediaPlayer.trackTitle
visible: MediaService.trackTitle !== ""
text: MediaService.trackTitle
font.pointSize: Style.fontSizeMedium * scaling
font.weight: Style.fontWeightBold
elide: Text.ElideRight
@ -207,8 +208,8 @@ NBox {
}
NText {
visible: MediaPlayer.trackArtist !== ""
text: MediaPlayer.trackArtist
visible: MediaService.trackArtist !== ""
text: MediaService.trackArtist
color: Colors.mOnSurface
font.pointSize: Style.fontSizeSmall * scaling
elide: Text.ElideRight
@ -216,8 +217,8 @@ NBox {
}
NText {
visible: MediaPlayer.trackAlbum !== ""
text: MediaPlayer.trackAlbum
visible: MediaService.trackAlbum !== ""
text: MediaService.trackAlbum
color: Colors.mOnSurface
font.pointSize: Style.fontSizeSmall * scaling
elide: Text.ElideRight
@ -230,7 +231,7 @@ NBox {
// Progress bar
Rectangle {
id: progressBarBackground
visible: (MediaPlayer.currentPlayer && MediaPlayer.trackLength > 0)
visible: (MediaService.currentPlayer && MediaService.trackLength > 0)
width: parent.width
height: 4 * scaling
radius: Style.radiusSmall * scaling
@ -238,10 +239,10 @@ NBox {
Layout.fillWidth: true
property real progressRatio: {
if (!MediaPlayer.currentPlayer || !MediaPlayer.isPlaying || MediaPlayer.trackLength <= 0) {
if (!MediaService.currentPlayer || !MediaService.isPlaying || MediaService.trackLength <= 0) {
return 0
}
return Math.min(1, MediaPlayer.currentPosition / MediaPlayer.trackLength)
return Math.min(1, MediaService.currentPosition / MediaService.trackLength)
}
Rectangle {
@ -261,7 +262,7 @@ NBox {
// Interactive progress handle
Rectangle {
id: progressHandle
visible: (MediaPlayer.currentPlayer && MediaPlayer.trackLength > 0)
visible: (MediaService.currentPlayer && MediaService.trackLength > 0)
width: 16 * scaling
height: 16 * scaling
radius: width * 0.5
@ -285,17 +286,17 @@ NBox {
anchors.fill: parent
hoverEnabled: true
cursorShape: Qt.PointingHandCursor
enabled: MediaPlayer.trackLength > 0 && MediaPlayer.canSeek
enabled: MediaService.trackLength > 0 && MediaService.canSeek
onClicked: function (mouse) {
let ratio = mouse.x / width
MediaPlayer.seekByRatio(ratio)
MediaService.seekByRatio(ratio)
}
onPositionChanged: function (mouse) {
if (pressed) {
let ratio = Math.max(0, Math.min(1, mouse.x / width))
MediaPlayer.seekByRatio(ratio)
MediaService.seekByRatio(ratio)
}
}
}
@ -312,24 +313,24 @@ NBox {
NIconButton {
icon: "skip_previous"
tooltipText: "Previous Media"
visible: MediaPlayer.canGoPrevious
onClicked: MediaPlayer.canGoPrevious ? MediaPlayer.previous() : {}
visible: MediaService.canGoPrevious
onClicked: MediaService.canGoPrevious ? MediaService.previous() : {}
}
// Play/Pause button
NIconButton {
icon: MediaPlayer.isPlaying ? "pause" : "play_arrow"
tooltipText: MediaPlayer.isPlaying ? "Pause" : "Play"
visible: (MediaPlayer.canPlay || MediaPlayer.canPause)
onClicked: (MediaPlayer.canPlay || MediaPlayer.canPause) ? MediaPlayer.playPause() : {}
icon: MediaService.isPlaying ? "pause" : "play_arrow"
tooltipText: MediaService.isPlaying ? "Pause" : "Play"
visible: (MediaService.canPlay || MediaService.canPause)
onClicked: (MediaService.canPlay || MediaService.canPause) ? MediaService.playPause() : {}
}
// Next button
NIconButton {
icon: "skip_next"
tooltipText: "Next Media"
visible: MediaPlayer.canGoNext
onClicked: MediaPlayer.canGoNext ? MediaPlayer.next() : {}
visible: MediaService.canGoNext
onClicked: MediaService.canGoNext ? MediaService.next() : {}
}
}
}
@ -341,7 +342,7 @@ NBox {
sourceComponent: LinearSpectrum {
width: 300 * scaling
height: 80 * scaling
values: Cava.values
values: CavaService.values
fillColor: Colors.mOnSurface
Layout.alignment: Qt.AlignHCenter
}

View file

@ -3,6 +3,7 @@ import QtQuick.Controls
import QtQuick.Layouts
import Quickshell
import Quickshell.Services.UPower
import qs.Commons
import qs.Services
import qs.Widgets

View file

@ -6,6 +6,7 @@ import Quickshell.Io
import Quickshell.Widgets
import qs.Modules.Settings
import qs.Modules.SidePanel
import qs.Commons
import qs.Services
import qs.Widgets

View file

@ -1,5 +1,6 @@
import QtQuick
import QtQuick.Layouts
import qs.Commons
import qs.Services
import qs.Widgets
@ -27,7 +28,7 @@ NBox {
}
NCircleStat {
value: SystemStats.cpuUsage
value: SystemStatsService.cpuUsage
icon: "speed"
flat: true
contentScale: 0.8
@ -35,7 +36,7 @@ NBox {
height: 68 * scaling
}
NCircleStat {
value: SystemStats.cpuTemp
value: SystemStatsService.cpuTemp
suffix: "°C"
icon: "device_thermostat"
flat: true
@ -44,7 +45,7 @@ NBox {
height: 68 * scaling
}
NCircleStat {
value: SystemStats.memoryUsagePer
value: SystemStatsService.memoryUsagePer
icon: "memory"
flat: true
contentScale: 0.8
@ -52,7 +53,7 @@ NBox {
height: 68 * scaling
}
NCircleStat {
value: SystemStats.diskUsage
value: SystemStatsService.diskUsage
icon: "hard_drive"
flat: true
contentScale: 0.8

View file

@ -3,6 +3,7 @@ import QtQuick.Controls
import QtQuick.Layouts
import Quickshell
import qs.Modules.Settings
import qs.Commons
import qs.Services
import qs.Widgets
@ -22,10 +23,10 @@ NBox {
// Screen Recorder
NIconButton {
icon: "videocam"
tooltipText: ScreenRecorder.isRecording ? "Stop Screen Recording" : "Start Screen Recording"
showFilled: ScreenRecorder.isRecording
tooltipText: ScreenRecorderService.isRecording ? "Stop Screen Recording" : "Start Screen Recording"
showFilled: ScreenRecorderService.isRecording
onClicked: {
ScreenRecorder.toggleRecording()
ScreenRecorderService.toggleRecording()
}
}

View file

@ -1,6 +1,7 @@
import QtQuick
import QtQuick.Layouts
import Quickshell
import qs.Commons
import qs.Services
import qs.Widgets
@ -8,7 +9,7 @@ import qs.Widgets
NBox {
id: root
readonly property bool weatherReady: (Location.data.weather !== null)
readonly property bool weatherReady: (LocationService.data.weather !== null)
// TBC weatherReady is not turning to false when we reset weather...
Layout.fillWidth: true
@ -26,7 +27,7 @@ NBox {
RowLayout {
spacing: Style.marginSmall * scaling
NText {
text: weatherReady ? Location.weatherSymbolFromCode(Location.data.weather.current_weather.weathercode) : ""
text: weatherReady ? LocationService.weatherSymbolFromCode(LocationService.data.weather.current_weather.weathercode) : ""
font.family: "Material Symbols Outlined"
font.pointSize: Style.fontSizeXXL * 1.5 * scaling
color: Colors.mPrimary
@ -51,10 +52,10 @@ NBox {
if (!weatherReady) {
return ""
}
var temp = Location.data.weather.current_weather.temperature
var temp = LocationService.data.weather.current_weather.temperature
var suffix = "C"
if (Settings.data.location.useFahrenheit) {
temp = Location.celsiusToFahrenheit(temp)
temp = LocationService.celsiusToFahrenheit(temp)
var suffix = "F"
}
temp = Math.round(temp)
@ -65,9 +66,9 @@ NBox {
}
NText {
text: weatherReady ? `(${Location.data.weather.timezone_abbreviation})` : ""
text: weatherReady ? `(${LocationService.data.weather.timezone_abbreviation})` : ""
font.pointSize: Style.fontSizeSmall * scaling
visible: Location.data.weather
visible: LocationService.data.weather
}
}
}
@ -84,27 +85,27 @@ NBox {
Layout.alignment: Qt.AlignHCenter
spacing: Style.marginLarge * scaling
Repeater {
model: weatherReady ? Location.data.weather.daily.time : []
model: weatherReady ? LocationService.data.weather.daily.time : []
delegate: ColumnLayout {
Layout.alignment: Qt.AlignHCenter
spacing: Style.marginSmall * scaling
NText {
text: Qt.formatDateTime(new Date(Location.data.weather.daily.time[index]), "ddd")
text: Qt.formatDateTime(new Date(LocationService.data.weather.daily.time[index]), "ddd")
color: Colors.mOnSurface
}
NText {
text: Location.weatherSymbolFromCode(Location.data.weather.daily.weathercode[index])
text: LocationService.weatherSymbolFromCode(LocationService.data.weather.daily.weathercode[index])
font.family: "Material Symbols Outlined"
font.pointSize: Style.fontSizeXL * scaling
color: Colors.mPrimary
}
NText {
text: {
var max = Location.data.weather.daily.temperature_2m_max[index]
var min = Location.data.weather.daily.temperature_2m_min[index]
var max = LocationService.data.weather.daily.temperature_2m_max[index]
var min = LocationService.data.weather.daily.temperature_2m_min[index]
if (Settings.data.location.useFahrenheit) {
max = Location.celsiusToFahrenheit(max)
min = Location.celsiusToFahrenheit(min)
max = LocationService.celsiusToFahrenheit(max)
min = LocationService.celsiusToFahrenheit(min)
}
max = Math.round(max)
min = Math.round(min)