qs: fix layout issues of ip component

This commit is contained in:
2026-01-03 23:14:18 +01:00
parent 0a02ae14bb
commit 4e2a3ed796
4 changed files with 34 additions and 73 deletions
@@ -28,7 +28,7 @@ Singleton {
readonly property string tempHigh: ""
readonly property string tempMedium: ""
readonly property string tempLow: ""
readonly property string global: ""
readonly property string ip: "󰇧"
readonly property string upload: ""
readonly property string download: ""
readonly property string speedSlower: "󰾆"
@@ -3,80 +3,33 @@ import QtQuick.Layouts
import Quickshell
import qs.Constants
import qs.Services
import qs.Modules.Bar.Misc
Item {
id: root
MonitorItem {
symbol: Icons.ip
fillColor: Colors.peach
value: 100
maxValue: 100
textValue: displayText
symbolSize: 18
property int displayIndex: 0
readonly property list<string> displayTexts: [IpService.countryCode, IpService.ip, IpService.alias]
readonly property string displayText: displayTexts[displayIndex]
implicitHeight: parent.height
implicitWidth: layout.width + 10
RowLayout {
id: layout
anchors.top: parent.top
anchors.bottom: parent.bottom
spacing: 0
Text {
text: Icons.global
font.pointSize: Fonts.icon + 6
color: Colors.peach
}
Item {
id: expander
implicitWidth: mouseArea.containsMouse ? ipText.implicitWidth + 10 : 0
implicitHeight: parent.height
clip: true
Text {
id: ipText
text: displayText
font.pointSize: displayIndex === 0 ? Fonts.medium : Fonts.small
font.family: Fonts.primary
color: Colors.peach
anchors.verticalCenter: parent.verticalCenter
anchors.left: parent.left
anchors.leftMargin: 5
}
Behavior on implicitWidth {
NumberAnimation {
duration: Style.animationFast
easing.type: Easing.InOutCubic
}
}
}
onClicked: (mouse) => {
WriteClipboard.write(displayText);
SendNotification.show("Copied to clipboard", displayText);
}
MouseArea {
id: mouseArea
anchors.fill: parent
cursorShape: Qt.PointingHandCursor
hoverEnabled: true
acceptedButtons: Qt.LeftButton | Qt.RightButton | Qt.MiddleButton
onClicked: (mouse) => {
if (mouse.button === Qt.LeftButton) {
WriteClipboard.write(displayText);
SendNotification.show("Copied to clipboard", displayText);
} else if (mouse.button === Qt.RightButton){
let iter = 0;
do {
displayIndex = (displayIndex + 1) % displayTexts.length;
} while (!displayTexts[displayIndex] && iter++ < displayTexts.length);
} else if (mouse.button === Qt.MiddleButton)
IpService.refresh();
}
onRightClicked: {
let iter = 0;
do {
displayIndex = (displayIndex + 1) % displayTexts.length;
} while (!displayTexts[displayIndex] && iter++ < displayTexts.length);
}
onMiddleClicked: {
IpService.refresh();
}
}
@@ -8,6 +8,7 @@ Item {
id: root
required property string symbol
property int symbolSize: Fonts.icon
property real maxValue: 100
property real value: 100
property string textValue: "" // override value in textDisplay if set
@@ -29,6 +30,7 @@ Item {
signal wheelDown()
signal clicked()
signal rightClicked()
signal middleClicked()
implicitHeight: parent.height - 5
implicitWidth: parent.height + (_expand ? textDisplay.width : 0)
@@ -74,13 +76,15 @@ Item {
anchors.fill: parent
hoverEnabled: !disableHover
acceptedButtons: Qt.LeftButton | Qt.RightButton
acceptedButtons: Qt.LeftButton | Qt.RightButton | Qt.MiddleButton
cursorShape: pointerCursor ? Qt.PointingHandCursor : Qt.ArrowCursor
onClicked: (mouse) => {
if (mouse.button === Qt.LeftButton)
root.clicked();
else if (mouse.button === Qt.RightButton)
root.rightClicked();
else if (mouse.button === Qt.MiddleButton)
root.middleClicked();
}
onWheel: (wheel) => {
if (wheel.angleDelta.y > 0)
@@ -142,7 +146,7 @@ Item {
anchors.fill: parent
text: symbol
font.family: Fonts.nerd
font.pointSize: Fonts.icon
font.pointSize: symbolSize
color: root.realColor
horizontalAlignment: Text.AlignHCenter
verticalAlignment: Text.AlignVCenter
@@ -14,8 +14,12 @@ Singleton {
readonly property string pixelFormat: "p010le"
property string recordingDisplay: ""
readonly property int framerate: 60
readonly property var codecParams: Object.freeze(["preset=p5", "rc=vbr", "cq=18", "b:v=80M", "maxrate=120M", "bufsize=160M", "color_range=tv"])
readonly property var filterArgs: Object.freeze([])
readonly property var codecParams: Object.freeze([
"preset=p5", "rc=vbr", "cq=18",
"b:v=80M", "maxrate=120M", "bufsize=160M",
"color_range=tv"
])
readonly property var filterArgs: ""
function getFilename() {
var d = new Date();
@@ -84,9 +88,9 @@ Singleton {
recordProcess.command.push("-p");
recordProcess.command.push(param);
}
for (const filter of filterArgs) {
if (filterArgs !== "") {
recordProcess.command.push("-F");
recordProcess.command.push(filter);
recordProcess.command.push(filterArgs);
}
Logger.log("RecordService", "Starting recording with command: " + recordProcess.command.join(" "));
recordProcess.onErrorExit = function() {