forked from Shinonome/dots-hyprland
061bb2abeb
- Unified popup handling in ClockWidget, Resource, BatteryPopup, and WeatherBar using PanelWindow + LazyLoader for consistent positioning and compositor animations. - Replaced plain text with ColumnLayout and RowLayout where possible, adding MaterialSymbol icons for improved visual consistency with the overall desktop style. - Added Translation.tr() for bilingual (Chinese/English) support to avoid hardcoded strings. - Based on improvements from PR #1771 (mine) and PR #1773 (by @finjener), merged and refined into a more polished and practical solution.
73 lines
1.8 KiB
QML
73 lines
1.8 KiB
QML
pragma ComponentBehavior: Bound
|
|
import qs.modules.common
|
|
import qs.modules.common.widgets
|
|
import qs.services
|
|
import Quickshell
|
|
import QtQuick
|
|
import QtQuick.Layouts
|
|
|
|
MouseArea {
|
|
id: root
|
|
property real margin: 10
|
|
property bool hovered: false
|
|
implicitWidth: rowLayout.implicitWidth + margin * 2
|
|
implicitHeight: rowLayout.implicitHeight
|
|
|
|
hoverEnabled: true
|
|
|
|
RowLayout {
|
|
id: rowLayout
|
|
anchors.centerIn: parent
|
|
|
|
MaterialSymbol {
|
|
fill: 0
|
|
text: WeatherIcons.codeToName[Weather.data.wCode]
|
|
iconSize: Appearance.font.pixelSize.large
|
|
color: Appearance.colors.colOnLayer1
|
|
Layout.alignment: Qt.AlignVCenter
|
|
}
|
|
|
|
StyledText {
|
|
visible: true
|
|
font.pixelSize: Appearance.font.pixelSize.small
|
|
color: Appearance.colors.colOnLayer1
|
|
text: Weather.data.temp
|
|
Layout.alignment: Qt.AlignVCenter
|
|
}
|
|
}
|
|
|
|
LazyLoader {
|
|
id: popupLoader
|
|
active: root.containsMouse
|
|
|
|
component: PanelWindow {
|
|
id: popupWindow
|
|
visible: true
|
|
implicitWidth: weatherPopup.implicitWidth
|
|
implicitHeight: weatherPopup.implicitHeight
|
|
|
|
color: "transparent"
|
|
exclusiveZone: 0
|
|
|
|
anchors.top: true
|
|
anchors.left: true
|
|
|
|
margins {
|
|
left: root.mapToGlobal(Qt.point(
|
|
(root.width - weatherPopup.implicitWidth) / 2,
|
|
0
|
|
)).x
|
|
top: root.mapToGlobal(Qt.point(0, root.height)).y - 25
|
|
}
|
|
|
|
mask: Region {
|
|
item: weatherPopup
|
|
}
|
|
|
|
WeatherPopup {
|
|
id: weatherPopup
|
|
}
|
|
}
|
|
}
|
|
}
|