117 lines
3.4 KiB
QML
117 lines
3.4 KiB
QML
// One per-application window rule.
|
|
//
|
|
// Three lines rather than SettingRow's two, and that third line is the point:
|
|
// the rule was chosen as behaviors -- float, center, workspace 4 -- and it is
|
|
// written to the compositor as a rule. Showing only the friendly sentence makes
|
|
// the card a black box; showing only the rule makes it a config file with a
|
|
// nicer font. Both, with the compositor line in mono underneath, is how
|
|
// somebody learns what the ticks actually did.
|
|
//
|
|
// The rule text and the sentence both come from WindowRules, which is the one
|
|
// place that knows what hypr/rules.lua emits.
|
|
|
|
import QtQuick
|
|
import qs.config
|
|
import qs.services
|
|
|
|
Item {
|
|
id: root
|
|
|
|
required property var rule
|
|
property bool divider: true
|
|
|
|
signal editRequested
|
|
signal removeRequested
|
|
|
|
readonly property string windowClass: String(root.rule?.class ?? "")
|
|
readonly property int openNow: WindowRules.matchesOpen(root.windowClass)
|
|
|
|
width: parent ? parent.width : 620
|
|
implicitHeight: Math.max(64, copy.implicitHeight + 22)
|
|
|
|
Column {
|
|
id: copy
|
|
|
|
anchors.left: parent.left
|
|
anchors.right: trailing.left
|
|
anchors.rightMargin: 16
|
|
anchors.verticalCenter: parent.verticalCenter
|
|
spacing: 3
|
|
|
|
Text {
|
|
width: parent.width
|
|
text: String(root.rule?.label ?? root.windowClass)
|
|
color: Theme.fg
|
|
font.family: Theme.fontFamily
|
|
font.pixelSize: Theme.fontSize
|
|
font.weight: Font.Medium
|
|
elide: Text.ElideRight
|
|
}
|
|
|
|
Text {
|
|
width: parent.width
|
|
text: WindowRules.summaryFor(root.rule)
|
|
+ (root.openNow === 0
|
|
? ""
|
|
: (root.openNow === 1
|
|
? " · 1 window open now"
|
|
: " · " + root.openNow + " windows open now"))
|
|
color: Theme.fgDim
|
|
font.family: Theme.fontFamily
|
|
font.pixelSize: Theme.fontSizeSmall
|
|
wrapMode: Text.WordWrap
|
|
}
|
|
|
|
Text {
|
|
width: parent.width
|
|
text: WindowRules.ruleLineFor(root.rule)
|
|
color: Theme.fgMuted
|
|
font.family: Theme.fontMono
|
|
font.pixelSize: Math.max(9, Theme.fontSizeSmall - 1)
|
|
elide: Text.ElideRight
|
|
}
|
|
}
|
|
|
|
Item {
|
|
id: trailing
|
|
|
|
anchors.right: parent.right
|
|
anchors.verticalCenter: parent.verticalCenter
|
|
width: removeConfirm.armed ? 250 : 170
|
|
height: 32
|
|
|
|
Row {
|
|
anchors.right: parent.right
|
|
anchors.verticalCenter: parent.verticalCenter
|
|
spacing: 8
|
|
|
|
SettingsButton {
|
|
anchors.verticalCenter: parent.verticalCenter
|
|
text: "Edit"
|
|
enabled: !WindowRules.reloading
|
|
onClicked: root.editRequested()
|
|
}
|
|
|
|
ConfirmAction {
|
|
id: removeConfirm
|
|
|
|
anchors.verticalCenter: parent.verticalCenter
|
|
actionId: "window-rule-remove:" + root.windowClass
|
|
armText: "Remove…"
|
|
confirmText: "Remove it"
|
|
enabled: !WindowRules.reloading
|
|
onConfirmed: root.removeRequested()
|
|
}
|
|
}
|
|
}
|
|
|
|
Rectangle {
|
|
anchors.left: copy.left
|
|
anchors.right: parent.right
|
|
anchors.bottom: parent.bottom
|
|
height: 1
|
|
visible: root.divider
|
|
color: Theme.alpha(Theme.fg, 0.065)
|
|
}
|
|
}
|