mirror of
https://github.com/AvengeMedia/DankMaterialShell.git
synced 2026-01-24 21:42:51 -05:00
weather: fix fahrenheit conversion
This commit is contained in:
@@ -2,19 +2,16 @@ import QtQuick
|
||||
import QtQuick.Effects
|
||||
import Quickshell
|
||||
import Quickshell.Wayland
|
||||
import Quickshell.Widgets
|
||||
import Quickshell.Io
|
||||
import qs.Common
|
||||
import qs.Widgets
|
||||
import qs.Modules
|
||||
import qs.Services
|
||||
|
||||
Variants {
|
||||
model: {
|
||||
if (SessionData.isGreeterMode) {
|
||||
return Quickshell.screens
|
||||
return Quickshell.screens;
|
||||
}
|
||||
return SettingsData.getFilteredScreens("wallpaper")
|
||||
return SettingsData.getFilteredScreens("wallpaper");
|
||||
}
|
||||
|
||||
PanelWindow {
|
||||
@@ -50,9 +47,9 @@ Variants {
|
||||
target: SessionData
|
||||
function onIsLightModeChanged() {
|
||||
if (SessionData.perModeWallpaper) {
|
||||
var newSource = SessionData.getMonitorWallpaper(modelData.name) || ""
|
||||
var newSource = SessionData.getMonitorWallpaper(modelData.name) || "";
|
||||
if (newSource !== root.source) {
|
||||
root.source = newSource
|
||||
root.source = newSource;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -61,32 +58,32 @@ Variants {
|
||||
function getFillMode(modeName) {
|
||||
switch (modeName) {
|
||||
case "Stretch":
|
||||
return Image.Stretch
|
||||
return Image.Stretch;
|
||||
case "Fit":
|
||||
case "PreserveAspectFit":
|
||||
return Image.PreserveAspectFit
|
||||
return Image.PreserveAspectFit;
|
||||
case "Fill":
|
||||
case "PreserveAspectCrop":
|
||||
return Image.PreserveAspectCrop
|
||||
return Image.PreserveAspectCrop;
|
||||
case "Tile":
|
||||
return Image.Tile
|
||||
return Image.Tile;
|
||||
case "TileVertically":
|
||||
return Image.TileVertically
|
||||
return Image.TileVertically;
|
||||
case "TileHorizontally":
|
||||
return Image.TileHorizontally
|
||||
return Image.TileHorizontally;
|
||||
case "Pad":
|
||||
return Image.Pad
|
||||
return Image.Pad;
|
||||
default:
|
||||
return Image.PreserveAspectCrop
|
||||
return Image.PreserveAspectCrop;
|
||||
}
|
||||
}
|
||||
|
||||
Component.onCompleted: {
|
||||
if (source) {
|
||||
const formattedSource = source.startsWith("file://") ? source : "file://" + source
|
||||
setWallpaperImmediate(formattedSource)
|
||||
const formattedSource = source.startsWith("file://") ? source : "file://" + source;
|
||||
setWallpaperImmediate(formattedSource);
|
||||
}
|
||||
isInitialized = true
|
||||
isInitialized = true;
|
||||
}
|
||||
|
||||
property bool isInitialized: false
|
||||
@@ -94,55 +91,54 @@ Variants {
|
||||
readonly property bool transitioning: transitionAnimation.running
|
||||
|
||||
onSourceChanged: {
|
||||
const isColor = source.startsWith("#")
|
||||
const isColor = source.startsWith("#");
|
||||
|
||||
if (!source) {
|
||||
setWallpaperImmediate("")
|
||||
setWallpaperImmediate("");
|
||||
} else if (isColor) {
|
||||
setWallpaperImmediate("")
|
||||
setWallpaperImmediate("");
|
||||
} else {
|
||||
if (!isInitialized || !currentWallpaper.source) {
|
||||
setWallpaperImmediate(source.startsWith("file://") ? source : "file://" + source)
|
||||
isInitialized = true
|
||||
setWallpaperImmediate(source.startsWith("file://") ? source : "file://" + source);
|
||||
isInitialized = true;
|
||||
} else if (CompositorService.isNiri && SessionData.isSwitchingMode) {
|
||||
setWallpaperImmediate(source.startsWith("file://") ? source : "file://" + source)
|
||||
setWallpaperImmediate(source.startsWith("file://") ? source : "file://" + source);
|
||||
} else {
|
||||
changeWallpaper(source.startsWith("file://") ? source : "file://" + source)
|
||||
changeWallpaper(source.startsWith("file://") ? source : "file://" + source);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function setWallpaperImmediate(newSource) {
|
||||
transitionAnimation.stop()
|
||||
root.transitionProgress = 0.0
|
||||
currentWallpaper.source = newSource
|
||||
nextWallpaper.source = ""
|
||||
currentWallpaper.opacity = 1
|
||||
nextWallpaper.opacity = 0
|
||||
transitionAnimation.stop();
|
||||
root.transitionProgress = 0.0;
|
||||
currentWallpaper.source = newSource;
|
||||
nextWallpaper.source = "";
|
||||
currentWallpaper.opacity = 1;
|
||||
nextWallpaper.opacity = 0;
|
||||
}
|
||||
|
||||
function changeWallpaper(newPath) {
|
||||
if (newPath === currentWallpaper.source)
|
||||
return
|
||||
return;
|
||||
if (!newPath || newPath.startsWith("#"))
|
||||
return
|
||||
|
||||
return;
|
||||
if (root.transitioning) {
|
||||
transitionAnimation.stop()
|
||||
root.transitionProgress = 0
|
||||
currentWallpaper.source = nextWallpaper.source
|
||||
nextWallpaper.source = ""
|
||||
transitionAnimation.stop();
|
||||
root.transitionProgress = 0;
|
||||
currentWallpaper.source = nextWallpaper.source;
|
||||
nextWallpaper.source = "";
|
||||
}
|
||||
|
||||
if (!currentWallpaper.source) {
|
||||
setWallpaperImmediate(newPath)
|
||||
return
|
||||
setWallpaperImmediate(newPath);
|
||||
return;
|
||||
}
|
||||
|
||||
nextWallpaper.source = newPath
|
||||
nextWallpaper.source = newPath;
|
||||
|
||||
if (nextWallpaper.status === Image.Ready) {
|
||||
transitionAnimation.start()
|
||||
transitionAnimation.start();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -179,10 +175,9 @@ Variants {
|
||||
|
||||
onStatusChanged: {
|
||||
if (status !== Image.Ready)
|
||||
return
|
||||
|
||||
return;
|
||||
if (!root.transitioning) {
|
||||
transitionAnimation.start()
|
||||
transitionAnimation.start();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -222,14 +217,14 @@ Variants {
|
||||
easing.type: Easing.InOutCubic
|
||||
onFinished: {
|
||||
Qt.callLater(() => {
|
||||
if (nextWallpaper.source && nextWallpaper.status === Image.Ready && !nextWallpaper.source.toString().startsWith("#")) {
|
||||
currentWallpaper.source = nextWallpaper.source
|
||||
}
|
||||
nextWallpaper.source = ""
|
||||
currentWallpaper.opacity = 1
|
||||
nextWallpaper.opacity = 0
|
||||
root.transitionProgress = 0.0
|
||||
})
|
||||
if (nextWallpaper.source && nextWallpaper.status === Image.Ready && !nextWallpaper.source.toString().startsWith("#")) {
|
||||
currentWallpaper.source = nextWallpaper.source;
|
||||
}
|
||||
nextWallpaper.source = "";
|
||||
currentWallpaper.opacity = 1;
|
||||
nextWallpaper.opacity = 0;
|
||||
root.transitionProgress = 0.0;
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,9 +1,4 @@
|
||||
import QtQuick
|
||||
import QtQuick.Effects
|
||||
import Quickshell
|
||||
import Quickshell.Io
|
||||
import Quickshell.Wayland
|
||||
import Quickshell.Widgets
|
||||
import qs.Common
|
||||
import qs.Services
|
||||
import qs.Widgets
|
||||
@@ -42,7 +37,7 @@ DankPopout {
|
||||
onShouldBeVisibleChanged: {
|
||||
if (shouldBeVisible) {
|
||||
if (SystemUpdateService.updateCount === 0 && !SystemUpdateService.isChecking) {
|
||||
SystemUpdateService.checkForUpdates()
|
||||
SystemUpdateService.checkForUpdates();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -57,19 +52,23 @@ DankPopout {
|
||||
smooth: true
|
||||
|
||||
Repeater {
|
||||
model: [{
|
||||
model: [
|
||||
{
|
||||
"margin": -3,
|
||||
"color": Qt.rgba(0, 0, 0, 0.05),
|
||||
"z": -3
|
||||
}, {
|
||||
},
|
||||
{
|
||||
"margin": -2,
|
||||
"color": Qt.rgba(0, 0, 0, 0.08),
|
||||
"z": -2
|
||||
}, {
|
||||
},
|
||||
{
|
||||
"margin": 0,
|
||||
"color": Qt.rgba(Theme.outline.r, Theme.outline.g, Theme.outline.b, 0.12),
|
||||
"z": -1
|
||||
}]
|
||||
}
|
||||
]
|
||||
Rectangle {
|
||||
anchors.fill: parent
|
||||
anchors.margins: modelData.margin
|
||||
@@ -109,14 +108,18 @@ DankPopout {
|
||||
StyledText {
|
||||
anchors.verticalCenter: parent.verticalCenter
|
||||
text: {
|
||||
if (SystemUpdateService.isChecking) return "Checking...";
|
||||
if (SystemUpdateService.hasError) return "Error";
|
||||
if (SystemUpdateService.updateCount === 0) return "Up to date";
|
||||
if (SystemUpdateService.isChecking)
|
||||
return "Checking...";
|
||||
if (SystemUpdateService.hasError)
|
||||
return "Error";
|
||||
if (SystemUpdateService.updateCount === 0)
|
||||
return "Up to date";
|
||||
return SystemUpdateService.updateCount + " updates";
|
||||
}
|
||||
font.pixelSize: Theme.fontSizeMedium
|
||||
color: {
|
||||
if (SystemUpdateService.hasError) return Theme.error;
|
||||
if (SystemUpdateService.hasError)
|
||||
return Theme.error;
|
||||
return Theme.surfaceText;
|
||||
}
|
||||
}
|
||||
@@ -131,7 +134,7 @@ DankPopout {
|
||||
enabled: !SystemUpdateService.isChecking
|
||||
opacity: enabled ? 1.0 : 0.5
|
||||
onClicked: {
|
||||
SystemUpdateService.checkForUpdates()
|
||||
SystemUpdateService.checkForUpdates();
|
||||
}
|
||||
|
||||
RotationAnimation {
|
||||
@@ -145,7 +148,7 @@ DankPopout {
|
||||
|
||||
onRunningChanged: {
|
||||
if (!running) {
|
||||
checkForUpdatesButton.rotation = 0
|
||||
checkForUpdatesButton.rotation = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -156,9 +159,9 @@ DankPopout {
|
||||
Rectangle {
|
||||
width: parent.width
|
||||
height: {
|
||||
let usedHeight = 40 + Theme.spacingL
|
||||
usedHeight += 48 + Theme.spacingL
|
||||
return parent.height - usedHeight
|
||||
let usedHeight = 40 + Theme.spacingL;
|
||||
usedHeight += 48 + Theme.spacingL;
|
||||
return parent.height - usedHeight;
|
||||
}
|
||||
radius: Theme.cornerRadius
|
||||
color: Qt.rgba(Theme.surfaceVariant.r, Theme.surfaceVariant.g, Theme.surfaceVariant.b, 0.1)
|
||||
@@ -190,7 +193,8 @@ DankPopout {
|
||||
}
|
||||
font.pixelSize: Theme.fontSizeMedium
|
||||
color: {
|
||||
if (SystemUpdateService.hasError) return Theme.errorText;
|
||||
if (SystemUpdateService.hasError)
|
||||
return Theme.errorText;
|
||||
return Theme.surfaceText;
|
||||
}
|
||||
wrapMode: Text.WordWrap
|
||||
@@ -246,7 +250,9 @@ DankPopout {
|
||||
}
|
||||
|
||||
Behavior on color {
|
||||
ColorAnimation { duration: Theme.shortDuration }
|
||||
ColorAnimation {
|
||||
duration: Theme.shortDuration
|
||||
}
|
||||
}
|
||||
|
||||
MouseArea {
|
||||
@@ -274,7 +280,9 @@ DankPopout {
|
||||
opacity: SystemUpdateService.updateCount > 0 ? 1.0 : 0.5
|
||||
|
||||
Behavior on color {
|
||||
ColorAnimation { duration: Theme.shortDuration }
|
||||
ColorAnimation {
|
||||
duration: Theme.shortDuration
|
||||
}
|
||||
}
|
||||
|
||||
Row {
|
||||
@@ -304,13 +312,12 @@ DankPopout {
|
||||
cursorShape: Qt.PointingHandCursor
|
||||
enabled: SystemUpdateService.updateCount > 0
|
||||
onClicked: {
|
||||
SystemUpdateService.runUpdates()
|
||||
systemUpdatePopout.close()
|
||||
SystemUpdateService.runUpdates();
|
||||
systemUpdatePopout.close();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Rectangle {
|
||||
width: (parent.width - Theme.spacingM) / 2
|
||||
height: parent.height
|
||||
@@ -318,7 +325,9 @@ DankPopout {
|
||||
color: closeMouseArea.containsMouse ? Theme.errorPressed : Theme.secondaryHover
|
||||
|
||||
Behavior on color {
|
||||
ColorAnimation { duration: Theme.shortDuration }
|
||||
ColorAnimation {
|
||||
duration: Theme.shortDuration
|
||||
}
|
||||
}
|
||||
|
||||
Row {
|
||||
@@ -347,13 +356,12 @@ DankPopout {
|
||||
hoverEnabled: true
|
||||
cursorShape: Qt.PointingHandCursor
|
||||
onClicked: {
|
||||
systemUpdatePopout.close()
|
||||
systemUpdatePopout.close();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -467,17 +467,17 @@ Singleton {
|
||||
const currentUnits = data.current_units || {}
|
||||
|
||||
const tempC = current.temperature_2m || 0
|
||||
const tempF = SettingsData.useFahrenheit ? tempC : (tempC * 9/5 + 32)
|
||||
const tempF = (tempC * 9/5 + 32)
|
||||
const feelsLikeC = current.apparent_temperature || tempC
|
||||
const feelsLikeF = SettingsData.useFahrenheit ? feelsLikeC : (feelsLikeC * 9/5 + 32)
|
||||
const feelsLikeF = (feelsLikeC * 9/5 + 32)
|
||||
|
||||
const forecast = []
|
||||
if (daily.time && daily.time.length > 0) {
|
||||
for (let i = 0; i < Math.min(daily.time.length, 7); i++) {
|
||||
const tempMinC = daily.temperature_2m_min?.[i] || 0
|
||||
const tempMaxC = daily.temperature_2m_max?.[i] || 0
|
||||
const tempMinF = SettingsData.useFahrenheit ? tempMinC : (tempMinC * 9/5 + 32)
|
||||
const tempMaxF = SettingsData.useFahrenheit ? tempMaxC : (tempMaxC * 9/5 + 32)
|
||||
const tempMinF = (tempMinC * 9/5 + 32)
|
||||
const tempMaxF = (tempMaxC * 9/5 + 32)
|
||||
|
||||
forecast.push({
|
||||
"day": formatForecastDay(daily.time[i], i),
|
||||
|
||||
Reference in New Issue
Block a user