qmlformat
This commit is contained in:
parent
2f691fc72a
commit
408f9a73a6
3 changed files with 376 additions and 376 deletions
|
|
@ -17,7 +17,8 @@ Variants {
|
|||
screen: modelData
|
||||
implicitHeight: Style.barHeight * scaling
|
||||
color: "transparent"
|
||||
visible: Settings.data.bar.monitors.includes(modelData.name) || (Settings.data.bar.monitors.length === 0)
|
||||
visible: Settings.data.bar.monitors.includes(modelData.name)
|
||||
|| (Settings.data.bar.monitors.length === 0)
|
||||
|
||||
anchors {
|
||||
top: true
|
||||
|
|
@ -51,7 +52,6 @@ Variants {
|
|||
text: screen.name
|
||||
anchors.verticalCenter: parent.verticalCenter
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Row {
|
||||
|
|
@ -62,9 +62,7 @@ Variants {
|
|||
anchors.verticalCenter: parent.verticalCenter
|
||||
spacing: Style.marginSmall * scaling
|
||||
|
||||
Workspace {
|
||||
}
|
||||
|
||||
Workspace {}
|
||||
}
|
||||
|
||||
Row {
|
||||
|
|
@ -89,8 +87,8 @@ Variants {
|
|||
|
||||
icon: "experiment"
|
||||
anchors.verticalCenter: parent.verticalCenter
|
||||
onClicked: function() {
|
||||
demoPanel.isLoaded = !demoPanel.isLoaded;
|
||||
onClicked: function () {
|
||||
demoPanel.isLoaded = !demoPanel.isLoaded
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -99,25 +97,21 @@ Variants {
|
|||
|
||||
icon: "widgets"
|
||||
anchors.verticalCenter: parent.verticalCenter
|
||||
onClicked: function() {
|
||||
onClicked: function () {
|
||||
// Map this button's center to the screen and open the side panel below it
|
||||
const localCenterX = width / 2;
|
||||
const localCenterY = height / 2;
|
||||
const globalPoint = mapToItem(null, localCenterX, localCenterY);
|
||||
const localCenterX = width / 2
|
||||
const localCenterY = height / 2
|
||||
const globalPoint = mapToItem(null, localCenterX, localCenterY)
|
||||
if (sidePanel.isLoaded)
|
||||
sidePanel.isLoaded = false;
|
||||
sidePanel.isLoaded = false
|
||||
else if (sidePanel.openAt)
|
||||
sidePanel.openAt(globalPoint.x, screen);
|
||||
sidePanel.openAt(globalPoint.x, screen)
|
||||
else
|
||||
// Fallback: toggle if API unavailable
|
||||
sidePanel.isLoaded = true;
|
||||
sidePanel.isLoaded = true
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -15,7 +15,9 @@ Item {
|
|||
property bool testCharging: false
|
||||
|
||||
property var battery: UPower.displayDevice
|
||||
property bool isReady: testMode ? true : (battery && battery.ready && battery.isLaptopBattery && battery.isPresent)
|
||||
property bool isReady: testMode ? true : (battery && battery.ready
|
||||
&& battery.isLaptopBattery
|
||||
&& battery.isPresent)
|
||||
property real percent: testMode ? testPercent : (isReady ? (battery.percentage * 100) : 0)
|
||||
property bool charging: testMode ? testCharging : (isReady ? battery.state === UPowerDeviceState.Charging : false)
|
||||
property bool show: isReady && percent > 0
|
||||
|
|
@ -23,29 +25,29 @@ Item {
|
|||
// Choose icon based on charge and charging state
|
||||
function batteryIcon() {
|
||||
if (!show)
|
||||
return "";
|
||||
return ""
|
||||
|
||||
if (charging)
|
||||
return "battery_android_bolt";
|
||||
return "battery_android_bolt"
|
||||
|
||||
if (percent >= 95)
|
||||
return "battery_android_full";
|
||||
return "battery_android_full"
|
||||
|
||||
// Hardcoded battery symbols
|
||||
if (percent >= 85)
|
||||
return "battery_android_6";
|
||||
return "battery_android_6"
|
||||
if (percent >= 70)
|
||||
return "battery_android_5";
|
||||
return "battery_android_5"
|
||||
if (percent >= 55)
|
||||
return "battery_android_4";
|
||||
return "battery_android_4"
|
||||
if (percent >= 40)
|
||||
return "battery_android_3";
|
||||
return "battery_android_3"
|
||||
if (percent >= 25)
|
||||
return "battery_android_2";
|
||||
return "battery_android_2"
|
||||
if (percent >= 10)
|
||||
return "battery_android_1";
|
||||
return "battery_android_1"
|
||||
if (percent >= 0)
|
||||
return "battery_android_0";
|
||||
return "battery_android_0"
|
||||
}
|
||||
|
||||
visible: testMode || (isReady && battery.isLaptopBattery)
|
||||
|
|
@ -64,12 +66,12 @@ Item {
|
|||
anchors.fill: parent
|
||||
hoverEnabled: true
|
||||
onEntered: {
|
||||
pill.showDelayed();
|
||||
batteryTooltip.show();
|
||||
pill.showDelayed()
|
||||
batteryTooltip.show()
|
||||
}
|
||||
onExited: {
|
||||
pill.hide();
|
||||
batteryTooltip.show();
|
||||
pill.hide()
|
||||
batteryTooltip.show()
|
||||
}
|
||||
}
|
||||
NTooltip {
|
||||
|
|
@ -78,42 +80,44 @@ Item {
|
|||
target: pill
|
||||
delay: Style.tooltipDelayLong
|
||||
text: {
|
||||
let lines = [];
|
||||
let lines = []
|
||||
if (!root.isReady) {
|
||||
return "";
|
||||
return ""
|
||||
}
|
||||
|
||||
if (root.battery.timeToEmpty > 0) {
|
||||
lines.push("Time left: " + Time.formatVagueHumanReadableTime(root.battery.timeToEmpty));
|
||||
lines.push("Time left: " + Time.formatVagueHumanReadableTime(
|
||||
root.battery.timeToEmpty))
|
||||
}
|
||||
|
||||
if (root.battery.timeToFull > 0) {
|
||||
lines.push("Time until full: " + Time.formatVagueHumanReadableTime(root.battery.timeToFull));
|
||||
lines.push("Time until full: " + Time.formatVagueHumanReadableTime(
|
||||
root.battery.timeToFull))
|
||||
}
|
||||
|
||||
if (root.battery.changeRate !== undefined) {
|
||||
const rate = root.battery.changeRate;
|
||||
const rate = root.battery.changeRate
|
||||
if (rate > 0) {
|
||||
lines.push(root.charging ? "Charging rate: " + rate.toFixed(2) + " W" : "Discharging rate: " + rate.toFixed(2) + " W");
|
||||
lines.push(
|
||||
root.charging ? "Charging rate: " + rate.toFixed(
|
||||
2) + " W" : "Discharging rate: " + rate.toFixed(
|
||||
2) + " W")
|
||||
} else if (rate < 0) {
|
||||
lines.push("Discharging rate: " + Math.abs(rate).toFixed(2) + " W")
|
||||
} else {
|
||||
lines.push("Estimating...")
|
||||
}
|
||||
else if (rate < 0) {
|
||||
lines.push("Discharging rate: " + Math.abs(rate).toFixed(2) + " W");
|
||||
}
|
||||
else {
|
||||
lines.push("Estimating...");
|
||||
}
|
||||
}
|
||||
else {
|
||||
lines.push(root.charging ? "Charging" : "Discharging");
|
||||
} else {
|
||||
lines.push(root.charging ? "Charging" : "Discharging")
|
||||
}
|
||||
|
||||
|
||||
if (root.battery.healthPercentage !== undefined && root.battery.healthPercentage > 0) {
|
||||
lines.push("Health: " + Math.round(root.battery.healthPercentage) + "%");
|
||||
if (root.battery.healthPercentage !== undefined
|
||||
&& root.battery.healthPercentage > 0) {
|
||||
lines.push("Health: " + Math.round(
|
||||
root.battery.healthPercentage) + "%")
|
||||
}
|
||||
return lines.join("\n");
|
||||
return lines.join("\n")
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -3,7 +3,7 @@ import QtQuick.Controls
|
|||
import qs.Services
|
||||
|
||||
Item {
|
||||
id: revealPill
|
||||
id: root
|
||||
|
||||
readonly property real scaling: Scaling.scale(screen)
|
||||
|
||||
|
|
@ -15,9 +15,6 @@ Item {
|
|||
property color iconTextColor: Colors.backgroundPrimary
|
||||
property color collapsedIconColor: Colors.textPrimary
|
||||
property real sizeMultiplier: 0.8
|
||||
property int pillHeight: Style.baseWidgetSize * sizeMultiplier * scaling
|
||||
property int iconSize: Style.baseWidgetSize * sizeMultiplier * scaling
|
||||
property int pillPaddingHorizontal: 14 * scaling
|
||||
property bool autoHide: false
|
||||
|
||||
// Internal state
|
||||
|
|
@ -25,8 +22,13 @@ Item {
|
|||
property bool shouldAnimateHide: false
|
||||
|
||||
// Exposed width logic
|
||||
readonly property int pillOverlap: iconSize / 2
|
||||
readonly property int maxPillWidth: Math.max(1, textItem.implicitWidth + pillPaddingHorizontal * 2 + pillOverlap)
|
||||
readonly property int pillHeight: Style.baseWidgetSize * sizeMultiplier * scaling
|
||||
readonly property int iconSize: Style.baseWidgetSize * sizeMultiplier * scaling
|
||||
readonly property int pillPaddingHorizontal: 14 * scaling
|
||||
readonly property int pillOverlap: iconSize * 0.5
|
||||
readonly property int maxPillWidth: Math.max(
|
||||
1, textItem.implicitWidth
|
||||
+ pillPaddingHorizontal * 2 + pillOverlap)
|
||||
|
||||
signal shown
|
||||
signal hidden
|
||||
|
|
@ -41,14 +43,14 @@ Item {
|
|||
x: (iconCircle.x + iconCircle.width / 2) - width
|
||||
opacity: showPill ? 1 : 0
|
||||
color: pillColor
|
||||
topLeftRadius: pillHeight / 2
|
||||
bottomLeftRadius: pillHeight / 2
|
||||
topLeftRadius: pillHeight * 0.5
|
||||
bottomLeftRadius: pillHeight * 0.5
|
||||
anchors.verticalCenter: parent.verticalCenter
|
||||
|
||||
Text {
|
||||
id: textItem
|
||||
anchors.centerIn: parent
|
||||
text: revealPill.text
|
||||
text: root.text
|
||||
font.pointSize: Colors.fontSizeSmall * scaling
|
||||
font.family: Settings.data.ui.fontFamily
|
||||
font.weight: Font.Bold
|
||||
|
|
@ -92,7 +94,7 @@ Item {
|
|||
anchors.centerIn: parent
|
||||
font.family: showPill ? "Material Symbols Rounded" : "Material Symbols Outlined"
|
||||
font.pointSize: Colors.fontSizeSmall * scaling
|
||||
text: revealPill.icon
|
||||
text: root.icon
|
||||
color: showPill ? iconTextColor : collapsedIconColor
|
||||
}
|
||||
}
|
||||
|
|
@ -117,11 +119,11 @@ Item {
|
|||
easing.type: Easing.OutCubic
|
||||
}
|
||||
onStarted: {
|
||||
showPill = true;
|
||||
showPill = true
|
||||
}
|
||||
onStopped: {
|
||||
delayedHideAnim.start();
|
||||
shown();
|
||||
delayedHideAnim.start()
|
||||
shown()
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -157,36 +159,36 @@ Item {
|
|||
easing.type: Easing.InCubic
|
||||
}
|
||||
onStopped: {
|
||||
showPill = false;
|
||||
shouldAnimateHide = false;
|
||||
hidden();
|
||||
showPill = false
|
||||
shouldAnimateHide = false
|
||||
hidden()
|
||||
}
|
||||
}
|
||||
|
||||
function show() {
|
||||
if (!showPill) {
|
||||
shouldAnimateHide = autoHide;
|
||||
showAnim.start();
|
||||
shouldAnimateHide = autoHide
|
||||
showAnim.start()
|
||||
} else {
|
||||
hideAnim.stop();
|
||||
delayedHideAnim.restart();
|
||||
hideAnim.stop()
|
||||
delayedHideAnim.restart()
|
||||
}
|
||||
}
|
||||
|
||||
function hide() {
|
||||
if (showPill) {
|
||||
hideAnim.start();
|
||||
hideAnim.start()
|
||||
}
|
||||
showTimer.stop();
|
||||
showTimer.stop()
|
||||
}
|
||||
|
||||
function showDelayed() {
|
||||
if (!showPill) {
|
||||
shouldAnimateHide = autoHide;
|
||||
showTimer.start();
|
||||
shouldAnimateHide = autoHide
|
||||
showTimer.start()
|
||||
} else {
|
||||
hideAnim.stop();
|
||||
delayedHideAnim.restart();
|
||||
hideAnim.stop()
|
||||
delayedHideAnim.restart()
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -195,7 +197,7 @@ Item {
|
|||
interval: Style.pillDelay
|
||||
onTriggered: {
|
||||
if (!showPill) {
|
||||
showAnim.start();
|
||||
showAnim.start()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue