1
0
mirror of https://github.com/AvengeMedia/DankMaterialShell.git synced 2025-12-06 21:45:38 -05:00

mecha refactoring

This commit is contained in:
bbedward
2025-07-23 15:15:51 -04:00
parent 19adcf3578
commit c01da89311
37 changed files with 431 additions and 396 deletions

164
Modules/TopBar/Battery.qml Normal file
View File

@@ -0,0 +1,164 @@
import QtQuick
import Quickshell.Services.UPower
import qs.Common
import qs.Services
import qs.Widgets
Rectangle {
id: battery
property bool batteryPopupVisible: false
signal toggleBatteryPopup()
width: BatteryService.batteryAvailable ? 70 : 40
height: 30
radius: Theme.cornerRadius
color: batteryArea.containsMouse || batteryPopupVisible ? Qt.rgba(Theme.primary.r, Theme.primary.g, Theme.primary.b, 0.16) : Qt.rgba(Theme.secondary.r, Theme.secondary.g, Theme.secondary.b, 0.08)
visible: true
Row {
anchors.centerIn: parent
spacing: 4
DankIcon {
name: Theme.getBatteryIcon(BatteryService.batteryLevel, BatteryService.isCharging, BatteryService.batteryAvailable)
size: Theme.iconSize - 6
color: {
if (!BatteryService.batteryAvailable)
return Theme.surfaceText;
if (BatteryService.isLowBattery && !BatteryService.isCharging)
return Theme.error;
if (BatteryService.isCharging)
return Theme.primary;
return Theme.surfaceText;
}
anchors.verticalCenter: parent.verticalCenter
SequentialAnimation on opacity {
running: BatteryService.isCharging
loops: Animation.Infinite
NumberAnimation {
to: 0.6
duration: 1000
easing.type: Easing.InOutQuad
}
NumberAnimation {
to: 1
duration: 1000
easing.type: Easing.InOutQuad
}
}
}
Text {
text: BatteryService.batteryLevel + "%"
font.pixelSize: Theme.fontSizeSmall
font.weight: Font.Medium
color: {
if (!BatteryService.batteryAvailable)
return Theme.surfaceText;
if (BatteryService.isLowBattery && !BatteryService.isCharging)
return Theme.error;
if (BatteryService.isCharging)
return Theme.primary;
return Theme.surfaceText;
}
anchors.verticalCenter: parent.verticalCenter
visible: BatteryService.batteryAvailable
}
}
MouseArea {
id: batteryArea
anchors.fill: parent
hoverEnabled: true
cursorShape: Qt.PointingHandCursor
onClicked: {
toggleBatteryPopup();
}
}
// Tooltip on hover
Rectangle {
id: batteryTooltip
width: Math.max(120, tooltipText.contentWidth + Theme.spacingM * 2)
height: tooltipText.contentHeight + Theme.spacingS * 2
radius: Theme.cornerRadius
color: Theme.surfaceContainer
border.color: Qt.rgba(Theme.outline.r, Theme.outline.g, Theme.outline.b, 0.2)
border.width: 1
visible: batteryArea.containsMouse && !batteryPopupVisible
anchors.bottom: parent.top
anchors.bottomMargin: Theme.spacingS
anchors.horizontalCenter: parent.horizontalCenter
opacity: batteryArea.containsMouse ? 1 : 0
Column {
anchors.centerIn: parent
spacing: 2
Text {
id: tooltipText
text: {
if (!BatteryService.batteryAvailable) {
if (typeof PowerProfiles === "undefined")
return "Power Management";
switch (PowerProfiles.profile) {
case PowerProfile.PowerSaver:
return "Power Profile: Power Saver";
case PowerProfile.Performance:
return "Power Profile: Performance";
default:
return "Power Profile: Balanced";
}
}
let status = BatteryService.batteryStatus;
let level = BatteryService.batteryLevel + "%";
let time = BatteryService.formatTimeRemaining();
if (time !== "Unknown")
return status + " • " + level + " • " + time;
else
return status + " • " + level;
}
font.pixelSize: Theme.fontSizeSmall
color: Theme.surfaceText
horizontalAlignment: Text.AlignHCenter
}
}
Behavior on opacity {
NumberAnimation {
duration: Theme.shortDuration
easing.type: Theme.standardEasing
}
}
}
Behavior on color {
ColorAnimation {
duration: Theme.shortDuration
easing.type: Theme.standardEasing
}
}
}

View File

@@ -6,7 +6,7 @@ import qs.Services
import qs.Widgets
Rectangle {
id: cpuWidget
id: cpuMonitor
property bool showPercentage: true
property bool showIcon: true
@@ -24,7 +24,7 @@ Rectangle {
cursorShape: Qt.PointingHandCursor
onClicked: {
ProcessMonitorService.setSortBy("cpu");
processListDropdown.toggle();
processListPopout.toggle();
}
}

View File

@@ -6,7 +6,7 @@ import qs.Services
import qs.Widgets
Rectangle {
id: ramWidget
id: ramMonitor
property bool showPercentage: true
property bool showIcon: true
@@ -24,7 +24,7 @@ Rectangle {
cursorShape: Qt.PointingHandCursor
onClicked: {
ProcessMonitorService.setSortBy("memory");
processListDropdown.toggle();
processListPopout.toggle();
}
}

View File

@@ -133,9 +133,9 @@ PanelWindow {
LauncherButton {
anchors.verticalCenter: parent.verticalCenter
isActive: appLauncher.isVisible
isActive: appDrawerPopout.isVisible
onClicked: {
appLauncher.toggle();
appDrawerPopout.toggle();
}
}
@@ -144,41 +144,41 @@ PanelWindow {
screenName: root.screenName
}
FocusedAppWidget {
FocusedApp {
anchors.verticalCenter: parent.verticalCenter
visible: Prefs.showFocusedWindow
}
}
ClockWidget {
id: clockWidget
Clock {
id: clock
anchors.centerIn: parent
onClockClicked: {
centcomCenter.calendarVisible = !centcomCenter.calendarVisible;
centcomPopout.calendarVisible = !centcomPopout.calendarVisible;
}
}
MediaWidget {
Media {
anchors.verticalCenter: parent.verticalCenter
anchors.right: clockWidget.left
anchors.rightMargin: Theme.spacingS
visible: Prefs.showMusic && MprisController.activePlayer
onClicked: {
centcomCenter.calendarVisible = !centcomCenter.calendarVisible;
centcomPopout.calendarVisible = !centcomPopout.calendarVisible;
}
}
WeatherWidget {
id: weatherWidget
Weather {
id: weather
anchors.verticalCenter: parent.verticalCenter
anchors.left: clockWidget.right
anchors.left: clock.right
anchors.leftMargin: Theme.spacingS
visible: Prefs.showWeather && WeatherService.weather.available && WeatherService.weather.temp > 0 && WeatherService.weather.tempF > 0
onClicked: {
centcomCenter.calendarVisible = !centcomCenter.calendarVisible;
centcomPopout.calendarVisible = !centcomPopout.calendarVisible;
}
}
@@ -190,7 +190,7 @@ PanelWindow {
anchors.right: parent.right
anchors.verticalCenter: parent.verticalCenter
SystemTrayWidget {
SystemTrayBar {
anchors.verticalCenter: parent.verticalCenter
visible: Prefs.showSystemTray
onMenuRequested: (menu, item, x, y) => {
@@ -240,12 +240,12 @@ PanelWindow {
}
// System Monitor Widgets
CpuMonitorWidget {
CpuMonitor {
anchors.verticalCenter: parent.verticalCenter
visible: Prefs.showSystemResources
}
RamMonitorWidget {
RamMonitor {
anchors.verticalCenter: parent.verticalCenter
visible: Prefs.showSystemResources
}
@@ -260,11 +260,11 @@ PanelWindow {
}
// Battery Widget
BatteryWidget {
Battery {
anchors.verticalCenter: parent.verticalCenter
batteryPopupVisible: batteryControlPopup.batteryPopupVisible
batteryPopupVisible: batteryPopout.batteryPopupVisible
onToggleBatteryPopup: {
batteryControlPopup.batteryPopupVisible = !batteryControlPopup.batteryPopupVisible;
batteryPopout.batteryPopupVisible = !batteryPopout.batteryPopupVisible;
}
}
@@ -272,10 +272,10 @@ PanelWindow {
// Bluetooth devices are automatically updated via signals
anchors.verticalCenter: parent.verticalCenter
isActive: controlCenter.controlCenterVisible
isActive: controlCenterPopout.controlCenterVisible
onClicked: {
controlCenter.controlCenterVisible = !controlCenter.controlCenterVisible;
if (controlCenter.controlCenterVisible) {
controlCenterPopout.controlCenterVisible = !controlCenterPopout.controlCenterVisible;
if (controlCenterPopout.controlCenterVisible) {
if (NetworkService.wifiEnabled)
WifiService.scanWifi();