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