forked from Shinonome/dots-hyprland
feat(modules/bar): add weather bar
This commit is contained in:
@@ -0,0 +1,68 @@
|
||||
pragma ComponentBehavior: Bound
|
||||
import "root:/modules/common"
|
||||
import "root:/modules/common/widgets"
|
||||
import "root:/constants"
|
||||
import "root:/services"
|
||||
import Quickshell
|
||||
import QtQuick
|
||||
import QtQuick.Layouts
|
||||
|
||||
Item {
|
||||
id: root
|
||||
property real margin: 5
|
||||
implicitHeight: 32
|
||||
implicitWidth: mouseArea.implicitWidth + margin * 2
|
||||
|
||||
MouseArea {
|
||||
id: mouseArea
|
||||
property bool hovered: false
|
||||
implicitWidth: rowLayout.implicitWidth
|
||||
implicitHeight: rowLayout.implicitHeight
|
||||
anchors.centerIn: root
|
||||
|
||||
hoverEnabled: true
|
||||
onEntered: {
|
||||
popupLoader.item.visible = true;
|
||||
}
|
||||
onExited: {
|
||||
popupLoader.item.visible = false;
|
||||
}
|
||||
|
||||
RowLayout {
|
||||
id: rowLayout
|
||||
|
||||
MaterialSymbol {
|
||||
fill: 0
|
||||
text: WeatherIcons.codeToName[WeatherService.data.wCode]
|
||||
iconSize: Appearance.font.pixelSize.large
|
||||
color: Appearance.colors.colOnLayer1
|
||||
}
|
||||
|
||||
StyledText {
|
||||
visible: true
|
||||
font.pixelSize: Appearance.font.pixelSize.normal
|
||||
color: Appearance.colors.colOnLayer1
|
||||
text: WeatherService.data.temp
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
LazyLoader {
|
||||
id: popupLoader
|
||||
active: true
|
||||
|
||||
component: PopupWindow {
|
||||
id: popupWindow
|
||||
implicitWidth: weatherPopup.implicitWidth
|
||||
implicitHeight: weatherPopup.implicitHeight
|
||||
anchor.item: root
|
||||
anchor.edges: Edges.Bottom
|
||||
anchor.rect.x: (root.implicitWidth - popupWindow.implicitWidth) / 2
|
||||
anchor.rect.y: root.implicitHeight + 10
|
||||
color: "transparent"
|
||||
WeatherPopup {
|
||||
id: weatherPopup
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,45 @@
|
||||
import QtQuick
|
||||
import QtQuick.Layouts
|
||||
|
||||
import "root:/modules/common"
|
||||
import "root:/modules/common/widgets"
|
||||
|
||||
Rectangle {
|
||||
id: root
|
||||
radius: Appearance.rounding.verysmall
|
||||
color: Appearance.colors.colLayer1
|
||||
border.color: Appearance.colors.colShadow
|
||||
border.width: 1
|
||||
implicitWidth: columnLayout.implicitWidth * 2
|
||||
implicitHeight: columnLayout.implicitHeight * 2
|
||||
Layout.fillWidth: parent
|
||||
|
||||
property alias title: title.text
|
||||
property alias value: value.text
|
||||
property alias symbol: symbol.text
|
||||
|
||||
ColumnLayout {
|
||||
id: columnLayout
|
||||
anchors.fill: parent
|
||||
spacing: -10
|
||||
RowLayout {
|
||||
Layout.alignment: Qt.AlignHCenter
|
||||
MaterialSymbol {
|
||||
id: symbol
|
||||
fill: 0
|
||||
iconSize: Appearance.font.pixelSize.normal
|
||||
}
|
||||
Text {
|
||||
id: title
|
||||
font.pixelSize: Appearance.font.pixelSize.smaller
|
||||
color: Appearance.colors.colOnLayer2
|
||||
}
|
||||
}
|
||||
Text {
|
||||
id: value
|
||||
Layout.alignment: Qt.AlignHCenter
|
||||
font.pixelSize: Appearance.font.pixelSize.normal
|
||||
color: Appearance.colors.colOnLayer2
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,95 @@
|
||||
import "root:/services"
|
||||
import "root:/modules/common"
|
||||
import "root:/modules/common/widgets"
|
||||
|
||||
import QtQuick
|
||||
import QtQuick.Layouts
|
||||
|
||||
Rectangle {
|
||||
id: root
|
||||
readonly property real margin: 10
|
||||
implicitWidth: columnLayout.implicitWidth + margin * 2
|
||||
implicitHeight: columnLayout.implicitHeight + margin * 2
|
||||
color: Appearance.colors.colLayer0
|
||||
radius: 12
|
||||
clip: true
|
||||
border.color: Appearance.colors.colShadow
|
||||
border.width: 1
|
||||
|
||||
ColumnLayout {
|
||||
id: columnLayout
|
||||
spacing: 5
|
||||
anchors.centerIn: root
|
||||
implicitWidth: Math.max(header.implicitWidth, gridLayout.implicitWidth)
|
||||
implicitHeight: gridLayout.implicitHeight
|
||||
|
||||
// Header
|
||||
RowLayout {
|
||||
id: header
|
||||
spacing: 5
|
||||
Layout.fillWidth: parent
|
||||
Layout.alignment: Qt.AlignHCenter
|
||||
MaterialSymbol {
|
||||
fill: 0
|
||||
text: "location_on"
|
||||
iconSize: Appearance.font.pixelSize.huge
|
||||
}
|
||||
|
||||
Text {
|
||||
text: WeatherService.data.city
|
||||
font.pixelSize: Appearance.font.pixelSize.large
|
||||
color: Appearance.colors.colOnLayer0
|
||||
}
|
||||
}
|
||||
|
||||
// Metrics grid
|
||||
GridLayout {
|
||||
id: gridLayout
|
||||
columns: 2
|
||||
rowSpacing: 5
|
||||
columnSpacing: 5
|
||||
uniformCellWidths: true
|
||||
|
||||
WeatherCard {
|
||||
title: "UV Index"
|
||||
symbol: "wb_sunny"
|
||||
value: WeatherService.data.uv
|
||||
}
|
||||
WeatherCard {
|
||||
title: "Wind"
|
||||
symbol: "air"
|
||||
value: `(${WeatherService.data.windDir}) ${WeatherService.data.wind}`
|
||||
}
|
||||
WeatherCard {
|
||||
title: "Precipitation"
|
||||
symbol: "rainy_light"
|
||||
value: WeatherService.data.precip
|
||||
}
|
||||
WeatherCard {
|
||||
title: "Humidity"
|
||||
symbol: "humidity_low"
|
||||
value: WeatherService.data.humidity
|
||||
}
|
||||
WeatherCard {
|
||||
title: "Visibility"
|
||||
symbol: "visibility"
|
||||
value: WeatherService.data.visib
|
||||
}
|
||||
WeatherCard {
|
||||
title: "Pressure"
|
||||
symbol: "readiness_score"
|
||||
value: WeatherService.data.press
|
||||
}
|
||||
WeatherCard {
|
||||
title: "Sunrise"
|
||||
symbol: "wb_twilight"
|
||||
value: WeatherService.data.sunrise
|
||||
}
|
||||
WeatherCard {
|
||||
title: "Sunset"
|
||||
symbol: "bedtime"
|
||||
value: WeatherService.data.sunset
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user