mirror of
https://github.com/AvengeMedia/DankMaterialShell.git
synced 2026-01-25 05:52:50 -05:00
refactor: start trimming AI bullcrap patterns
This commit is contained in:
@@ -12,25 +12,7 @@ PanelWindow {
|
||||
id: centerCommandCenter
|
||||
|
||||
property var theme: Theme
|
||||
property bool hasActiveMedia: root.hasActiveMedia
|
||||
property var weather: root.weather
|
||||
|
||||
property bool showMediaPlayer: hasActiveMedia || hideMediaTimer.running
|
||||
|
||||
Timer {
|
||||
id: hideMediaTimer
|
||||
interval: 3000
|
||||
running: false
|
||||
repeat: false
|
||||
}
|
||||
|
||||
onHasActiveMediaChanged: {
|
||||
if (hasActiveMedia) {
|
||||
hideMediaTimer.stop()
|
||||
} else {
|
||||
hideMediaTimer.start()
|
||||
}
|
||||
}
|
||||
readonly property bool hasActiveMedia: MprisController.activePlayer !== null
|
||||
|
||||
visible: root.calendarVisible
|
||||
|
||||
@@ -70,7 +52,7 @@ PanelWindow {
|
||||
|
||||
// Main row with widgets and calendar
|
||||
let widgetHeight = 160 // Media widget always present
|
||||
widgetHeight += (weather ? 140 : 80) + theme.spacingM // Weather widget always present
|
||||
widgetHeight += 140 + theme.spacingM // Weather widget always present
|
||||
let calendarHeight = 300
|
||||
let mainRowHeight = Math.max(widgetHeight, calendarHeight)
|
||||
|
||||
@@ -177,7 +159,7 @@ PanelWindow {
|
||||
width: parent.width
|
||||
height: {
|
||||
let widgetHeight = 160 // Media widget always present
|
||||
widgetHeight += (weather ? 140 : 80) + theme.spacingM // Weather widget always present
|
||||
widgetHeight += 140 + theme.spacingM // Weather widget always present
|
||||
let calendarHeight = 300
|
||||
return Math.max(widgetHeight, calendarHeight)
|
||||
}
|
||||
@@ -204,9 +186,8 @@ PanelWindow {
|
||||
WeatherWidget {
|
||||
visible: true // Always visible - shows placeholder when no weather
|
||||
width: parent.width
|
||||
height: weather ? 140 : 80
|
||||
height: 140
|
||||
theme: centerCommandCenter.theme
|
||||
weather: centerCommandCenter.weather
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -12,6 +12,32 @@ Rectangle {
|
||||
property MprisPlayer activePlayer: MprisController.activePlayer
|
||||
property var theme: Theme
|
||||
|
||||
property string lastValidTitle: ""
|
||||
property string lastValidArtist: ""
|
||||
property string lastValidAlbum: ""
|
||||
property string lastValidArtUrl: ""
|
||||
|
||||
Timer {
|
||||
id: clearCacheTimer
|
||||
interval: 2000
|
||||
onTriggered: {
|
||||
if (!activePlayer) {
|
||||
lastValidTitle = ""
|
||||
lastValidArtist = ""
|
||||
lastValidAlbum = ""
|
||||
lastValidArtUrl = ""
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
onActivePlayerChanged: {
|
||||
if (!activePlayer) {
|
||||
clearCacheTimer.restart()
|
||||
} else {
|
||||
clearCacheTimer.stop()
|
||||
}
|
||||
}
|
||||
|
||||
width: parent.width
|
||||
height: parent.height
|
||||
radius: theme.cornerRadiusLarge
|
||||
@@ -49,15 +75,6 @@ Rectangle {
|
||||
}
|
||||
}
|
||||
|
||||
// Initialize when player changes
|
||||
onActivePlayerChanged: {
|
||||
if (activePlayer) {
|
||||
currentPosition = activePlayer.position || 0
|
||||
} else {
|
||||
currentPosition = 0
|
||||
}
|
||||
}
|
||||
|
||||
// Backend events
|
||||
Connections {
|
||||
target: activePlayer
|
||||
@@ -85,7 +102,7 @@ Rectangle {
|
||||
Column {
|
||||
anchors.centerIn: parent
|
||||
spacing: theme.spacingS
|
||||
visible: !activePlayer || !activePlayer.trackTitle || activePlayer.trackTitle === ""
|
||||
visible: (!activePlayer && !lastValidTitle) || (activePlayer && activePlayer.trackTitle === "" && lastValidTitle === "")
|
||||
|
||||
Text {
|
||||
text: "music_note"
|
||||
@@ -107,7 +124,7 @@ Rectangle {
|
||||
Column {
|
||||
anchors.fill: parent
|
||||
spacing: theme.spacingS
|
||||
visible: activePlayer && activePlayer.trackTitle && activePlayer.trackTitle !== ""
|
||||
visible: activePlayer && activePlayer.trackTitle !== "" || lastValidTitle !== ""
|
||||
|
||||
// Normal media info when playing
|
||||
Row {
|
||||
@@ -129,7 +146,12 @@ Rectangle {
|
||||
Image {
|
||||
id: albumArt
|
||||
anchors.fill: parent
|
||||
source: activePlayer?.trackArtUrl || ""
|
||||
source: activePlayer?.trackArtUrl || lastValidArtUrl || ""
|
||||
onSourceChanged: {
|
||||
if (activePlayer?.trackArtUrl) {
|
||||
lastValidArtUrl = activePlayer.trackArtUrl;
|
||||
}
|
||||
}
|
||||
fillMode: Image.PreserveAspectCrop
|
||||
smooth: true
|
||||
}
|
||||
@@ -157,7 +179,12 @@ Rectangle {
|
||||
spacing: theme.spacingXS
|
||||
|
||||
Text {
|
||||
text: activePlayer?.trackTitle || "Unknown Track"
|
||||
text: activePlayer?.trackTitle || lastValidTitle || "Unknown Track"
|
||||
onTextChanged: {
|
||||
if (activePlayer?.trackTitle) {
|
||||
lastValidTitle = activePlayer.trackTitle;
|
||||
}
|
||||
}
|
||||
font.pixelSize: theme.fontSizeMedium
|
||||
font.weight: Font.Bold
|
||||
color: theme.surfaceText
|
||||
@@ -166,7 +193,12 @@ Rectangle {
|
||||
}
|
||||
|
||||
Text {
|
||||
text: activePlayer?.trackArtist || "Unknown Artist"
|
||||
text: activePlayer?.trackArtist || lastValidArtist || "Unknown Artist"
|
||||
onTextChanged: {
|
||||
if (activePlayer?.trackArtist) {
|
||||
lastValidArtist = activePlayer.trackArtist;
|
||||
}
|
||||
}
|
||||
font.pixelSize: theme.fontSizeSmall
|
||||
color: Qt.rgba(theme.surfaceText.r, theme.surfaceText.g, theme.surfaceText.b, 0.8)
|
||||
width: parent.width
|
||||
@@ -174,7 +206,12 @@ Rectangle {
|
||||
}
|
||||
|
||||
Text {
|
||||
text: activePlayer?.trackAlbum || ""
|
||||
text: activePlayer?.trackAlbum || lastValidAlbum || ""
|
||||
onTextChanged: {
|
||||
if (activePlayer?.trackAlbum) {
|
||||
lastValidAlbum = activePlayer.trackAlbum;
|
||||
}
|
||||
}
|
||||
font.pixelSize: theme.fontSizeSmall
|
||||
color: Qt.rgba(theme.surfaceText.r, theme.surfaceText.g, theme.surfaceText.b, 0.6)
|
||||
width: parent.width
|
||||
|
||||
@@ -8,7 +8,6 @@ Rectangle {
|
||||
id: weatherWidget
|
||||
|
||||
property var theme: Theme
|
||||
property var weather
|
||||
|
||||
width: parent.width
|
||||
height: parent.height
|
||||
@@ -31,26 +30,18 @@ Rectangle {
|
||||
Column {
|
||||
anchors.centerIn: parent
|
||||
spacing: theme.spacingS
|
||||
visible: !weather || !weather.available || weather.temp === 0
|
||||
visible: !WeatherService.weather.available || WeatherService.weather.temp === 0
|
||||
|
||||
Text {
|
||||
text: weather && weather.loading ? "cloud_sync" : "cloud_off"
|
||||
text: "cloud_off"
|
||||
font.family: theme.iconFont
|
||||
font.pixelSize: theme.iconSize + 8
|
||||
color: Qt.rgba(theme.surfaceText.r, theme.surfaceText.g, theme.surfaceText.b, 0.5)
|
||||
anchors.horizontalCenter: parent.horizontalCenter
|
||||
|
||||
RotationAnimation on rotation {
|
||||
from: 0
|
||||
to: 360
|
||||
duration: 2000
|
||||
running: weather && weather.loading
|
||||
loops: Animation.Infinite
|
||||
}
|
||||
}
|
||||
|
||||
Text {
|
||||
text: weather && weather.loading ? "Loading Weather..." : "No Weather Data"
|
||||
text: "No Weather Data"
|
||||
font.pixelSize: theme.fontSizeMedium
|
||||
color: Qt.rgba(theme.surfaceText.r, theme.surfaceText.g, theme.surfaceText.b, 0.7)
|
||||
anchors.horizontalCenter: parent.horizontalCenter
|
||||
@@ -62,7 +53,7 @@ Rectangle {
|
||||
anchors.fill: parent
|
||||
anchors.margins: theme.spacingL
|
||||
spacing: theme.spacingS
|
||||
visible: weather && weather.available && weather.temp !== 0
|
||||
visible: WeatherService.weather.available && WeatherService.weather.temp !== 0
|
||||
|
||||
// Weather header info
|
||||
Item {
|
||||
@@ -70,12 +61,12 @@ Rectangle {
|
||||
height: 60
|
||||
|
||||
Row {
|
||||
anchors.fill: parent
|
||||
anchors.centerIn: parent
|
||||
spacing: theme.spacingL
|
||||
|
||||
// Weather icon
|
||||
Text {
|
||||
text: weather ? WeatherService.getWeatherIcon(weather.wCode) : ""
|
||||
text: WeatherService.getWeatherIcon(WeatherService.weather.wCode)
|
||||
font.family: theme.iconFont
|
||||
font.pixelSize: theme.iconSize + 8
|
||||
color: theme.primary
|
||||
@@ -87,7 +78,7 @@ Rectangle {
|
||||
anchors.verticalCenter: parent.verticalCenter
|
||||
|
||||
Text {
|
||||
text: weather ? ((Prefs.useFahrenheit ? weather.tempF : weather.temp) + "°" + (Prefs.useFahrenheit ? "F" : "C")) : ""
|
||||
text: (Prefs.useFahrenheit ? WeatherService.weather.tempF : WeatherService.weather.temp) + "°" + (Prefs.useFahrenheit ? "F" : "C")
|
||||
font.pixelSize: theme.fontSizeXLarge
|
||||
color: theme.surfaceText
|
||||
font.weight: Font.Light
|
||||
@@ -96,13 +87,13 @@ Rectangle {
|
||||
anchors.fill: parent
|
||||
hoverEnabled: true
|
||||
cursorShape: Qt.PointingHandCursor
|
||||
onClicked: if (weather) Prefs.setTemperatureUnit(!Prefs.useFahrenheit)
|
||||
enabled: weather !== null
|
||||
onClicked: if (WeatherService.weather.available) Prefs.setTemperatureUnit(!Prefs.useFahrenheit)
|
||||
enabled: WeatherService.weather.available
|
||||
}
|
||||
}
|
||||
|
||||
Text {
|
||||
text: weather ? weather.city : ""
|
||||
text: WeatherService.weather.city || ""
|
||||
font.pixelSize: theme.fontSizeMedium
|
||||
color: Qt.rgba(theme.surfaceText.r, theme.surfaceText.g, theme.surfaceText.b, 0.7)
|
||||
visible: text.length > 0
|
||||
@@ -127,7 +118,7 @@ Rectangle {
|
||||
anchors.verticalCenter: parent.verticalCenter
|
||||
}
|
||||
Text {
|
||||
text: weather ? weather.humidity + "%" : "--"
|
||||
text: WeatherService.weather.humidity ? WeatherService.weather.humidity + "%" : "--"
|
||||
font.pixelSize: theme.fontSizeSmall
|
||||
color: theme.surfaceText
|
||||
anchors.verticalCenter: parent.verticalCenter
|
||||
@@ -144,7 +135,7 @@ Rectangle {
|
||||
anchors.verticalCenter: parent.verticalCenter
|
||||
}
|
||||
Text {
|
||||
text: weather ? weather.wind : "--"
|
||||
text: WeatherService.weather.wind || "--"
|
||||
font.pixelSize: theme.fontSizeSmall
|
||||
color: theme.surfaceText
|
||||
anchors.verticalCenter: parent.verticalCenter
|
||||
@@ -161,7 +152,7 @@ Rectangle {
|
||||
anchors.verticalCenter: parent.verticalCenter
|
||||
}
|
||||
Text {
|
||||
text: weather ? weather.sunrise : "--"
|
||||
text: WeatherService.weather.sunrise || "--"
|
||||
font.pixelSize: theme.fontSizeSmall
|
||||
color: theme.surfaceText
|
||||
anchors.verticalCenter: parent.verticalCenter
|
||||
@@ -178,7 +169,7 @@ Rectangle {
|
||||
anchors.verticalCenter: parent.verticalCenter
|
||||
}
|
||||
Text {
|
||||
text: weather ? weather.sunset : "--"
|
||||
text: WeatherService.weather.sunset || "--"
|
||||
font.pixelSize: theme.fontSizeSmall
|
||||
color: theme.surfaceText
|
||||
anchors.verticalCenter: parent.verticalCenter
|
||||
|
||||
Reference in New Issue
Block a user