winfo: add no active client placeholders

Also change close button to kill
This commit is contained in:
2 * r + 2 * t 2025-06-22 00:07:11 +10:00
parent 0789b4f66a
commit 60deccddf0
3 changed files with 58 additions and 19 deletions

View file

@ -140,7 +140,7 @@ ColumnLayout {
Button { Button {
color: Colours.palette.m3errorContainer color: Colours.palette.m3errorContainer
onColor: Colours.palette.m3onErrorContainer onColor: Colours.palette.m3onErrorContainer
text: qsTr("Close") text: qsTr("Kill")
function onClicked(): void { function onClicked(): void {
Hyprland.dispatch(`movetoworkspace ${wsId},address:${Hyprland.activeClient?.address}`); Hyprland.dispatch(`movetoworkspace ${wsId},address:${Hyprland.activeClient?.address}`);

View file

@ -14,7 +14,7 @@ ColumnLayout {
Label { Label {
Layout.topMargin: Appearance.padding.large * 2 Layout.topMargin: Appearance.padding.large * 2
text: Hyprland.activeClient.title text: Hyprland.activeClient?.title ?? "No active client"
wrapMode: Text.WrapAtWordBoundaryOrAnywhere wrapMode: Text.WrapAtWordBoundaryOrAnywhere
font.pointSize: Appearance.font.size.large font.pointSize: Appearance.font.size.large
@ -22,7 +22,7 @@ ColumnLayout {
} }
Label { Label {
text: Hyprland.activeClient.wmClass text: Hyprland.activeClient?.wmClass ?? "No active client"
color: Colours.palette.m3tertiary color: Colours.palette.m3tertiary
font.pointSize: Appearance.font.size.larger font.pointSize: Appearance.font.size.larger
@ -41,74 +41,78 @@ ColumnLayout {
Detail { Detail {
icon: "location_on" icon: "location_on"
text: qsTr("Address: %1").arg(Hyprland.activeClient.address) text: qsTr("Address: %1").arg(Hyprland.activeClient?.address ?? "unknown")
color: Colours.palette.m3primary color: Colours.palette.m3primary
} }
Detail { Detail {
icon: "location_searching" icon: "location_searching"
text: qsTr("Position: %1, %2").arg(Hyprland.activeClient.x).arg(Hyprland.activeClient.y) text: qsTr("Position: %1, %2").arg(Hyprland.activeClient?.x ?? -1).arg(Hyprland.activeClient?.y ?? -1)
} }
Detail { Detail {
icon: "resize" icon: "resize"
text: qsTr("Size: %1 x %2").arg(Hyprland.activeClient.width).arg(Hyprland.activeClient.height) text: qsTr("Size: %1 x %2").arg(Hyprland.activeClient?.width ?? -1).arg(Hyprland.activeClient?.height ?? -1)
color: Colours.palette.m3tertiary color: Colours.palette.m3tertiary
} }
Detail { Detail {
icon: "workspaces" icon: "workspaces"
text: qsTr("Workspace: %1 (%2)").arg(Hyprland.activeClient.workspace.name).arg(Hyprland.activeClient.workspace.id) text: qsTr("Workspace: %1 (%2)").arg(Hyprland.activeClient?.workspace.name ?? -1).arg(Hyprland.activeClient?.workspace.id ?? -1)
color: Colours.palette.m3secondary color: Colours.palette.m3secondary
} }
Detail { Detail {
icon: "desktop_windows" icon: "desktop_windows"
text: { text: {
const mon = Hyprland.activeClient.monitor; const mon = Hyprland.activeClient?.monitor;
if (mon)
return qsTr("Monitor: %1 (%2) at %3, %4").arg(mon.name).arg(mon.id).arg(mon.x).arg(mon.y); return qsTr("Monitor: %1 (%2) at %3, %4").arg(mon.name).arg(mon.id).arg(mon.x).arg(mon.y);
return qsTr("Monitor: unknown");
} }
} }
Detail { Detail {
icon: "page_header" icon: "page_header"
text: qsTr("Initial title: %1").arg(Hyprland.activeClient.initialTitle) text: qsTr("Initial title: %1").arg(Hyprland.activeClient?.initialTitle ?? "unknown")
color: Colours.palette.m3tertiary color: Colours.palette.m3tertiary
} }
Detail { Detail {
icon: "category" icon: "category"
text: qsTr("Initial class: %1").arg(Hyprland.activeClient.initialClass) text: qsTr("Initial class: %1").arg(Hyprland.activeClient?.initialClass ?? "unknown")
} }
Detail { Detail {
icon: "account_tree" icon: "account_tree"
text: qsTr("Process id: %1").arg(Hyprland.activeClient.pid) text: qsTr("Process id: %1").arg(Hyprland.activeClient?.pid ?? -1)
color: Colours.palette.m3primary color: Colours.palette.m3primary
} }
Detail { Detail {
icon: "picture_in_picture_center" icon: "picture_in_picture_center"
text: qsTr("Floating: %1").arg(Hyprland.activeClient.floating ? "yes" : "no") text: qsTr("Floating: %1").arg(Hyprland.activeClient?.floating ? "yes" : "no")
color: Colours.palette.m3secondary color: Colours.palette.m3secondary
} }
Detail { Detail {
icon: "gradient" icon: "gradient"
text: qsTr("Xwayland: %1").arg(Hyprland.activeClient.lastIpcObject.xwayland ? "yes" : "no") text: qsTr("Xwayland: %1").arg(Hyprland.activeClient?.lastIpcObject.xwayland ? "yes" : "no")
} }
Detail { Detail {
icon: "keep" icon: "keep"
text: qsTr("Pinned: %1").arg(Hyprland.activeClient.lastIpcObject.pinned ? "yes" : "no") text: qsTr("Pinned: %1").arg(Hyprland.activeClient?.lastIpcObject.pinned ? "yes" : "no")
color: Colours.palette.m3secondary color: Colours.palette.m3secondary
} }
Detail { Detail {
icon: "fullscreen" icon: "fullscreen"
text: { text: {
const fs = Hyprland.activeClient.fullscreen; const fs = Hyprland.activeClient?.fullscreen;
if (fs)
return qsTr("Fullscreen state: %1").arg(fs == 0 ? "off" : fs == 1 ? "maximised" : "on"); return qsTr("Fullscreen state: %1").arg(fs == 0 ? "off" : fs == 1 ? "maximised" : "on");
return qsTr("Fullscreen state: unknown");
} }
color: Colours.palette.m3tertiary color: Colours.palette.m3tertiary
} }

View file

@ -18,7 +18,7 @@ Item {
Layout.preferredWidth: preview.implicitWidth + Appearance.padding.large * 2 Layout.preferredWidth: preview.implicitWidth + Appearance.padding.large * 2
Layout.fillHeight: true Layout.fillHeight: true
ClippingRectangle { StyledClippingRect {
id: preview id: preview
anchors.horizontalCenter: parent.horizontalCenter anchors.horizontalCenter: parent.horizontalCenter
@ -29,9 +29,44 @@ Item {
implicitWidth: view.implicitWidth implicitWidth: view.implicitWidth
color: "transparent" color: Colours.palette.m3surfaceContainer
radius: Appearance.rounding.small radius: Appearance.rounding.small
Loader {
anchors.centerIn: parent
active: !Hyprland.activeClient
asynchronous: true
sourceComponent: ColumnLayout {
spacing: 0
MaterialIcon {
Layout.alignment: Qt.AlignHCenter
text: "web_asset_off"
color: Colours.palette.m3outline
font.pointSize: Appearance.font.size.extraLarge * 3
font.variableAxes: ({
opsz: Appearance.font.size.extraLarge * 3
})
}
StyledText {
Layout.alignment: Qt.AlignHCenter
text: qsTr("No active client")
color: Colours.palette.m3outline
font.pointSize: Appearance.font.size.extraLarge
font.weight: 500
}
StyledText {
Layout.alignment: Qt.AlignHCenter
text: qsTr("Try switching to a window")
color: Colours.palette.m3outline
font.pointSize: Appearance.font.size.large
}
}
}
ScreencopyView { ScreencopyView {
id: view id: view