mirror of
https://github.com/AvengeMedia/DankMaterialShell.git
synced 2026-01-30 08:22:51 -05:00
displays: fix niri hot corner config
This commit is contained in:
@@ -1915,7 +1915,10 @@ Item {
|
|||||||
width: parent.width
|
width: parent.width
|
||||||
text: I18n.tr("Hot Corners")
|
text: I18n.tr("Hot Corners")
|
||||||
addHorizontalPadding: true
|
addHorizontalPadding: true
|
||||||
property var hotCornersData: root.getNiriSetting(outputData, modelData, "hotCorners", null)
|
property var hotCornersData: {
|
||||||
|
void (root.pendingNiriChanges);
|
||||||
|
return root.getNiriSetting(outputData, modelData, "hotCorners", null);
|
||||||
|
}
|
||||||
currentValue: {
|
currentValue: {
|
||||||
if (!hotCornersData)
|
if (!hotCornersData)
|
||||||
return I18n.tr("Inherit");
|
return I18n.tr("Inherit");
|
||||||
@@ -1955,67 +1958,42 @@ Item {
|
|||||||
|
|
||||||
Item {
|
Item {
|
||||||
width: parent.width
|
width: parent.width
|
||||||
height: hotCornersFlow.height
|
height: hotCornersGroup.implicitHeight
|
||||||
visible: hotCornersFlow.visible
|
clip: true
|
||||||
|
property var hotCornersData: {
|
||||||
|
void (root.pendingNiriChanges);
|
||||||
|
return root.getNiriSetting(outputCard.outputData, outputCard.modelData, "hotCorners", null);
|
||||||
|
}
|
||||||
|
visible: hotCornersData && !hotCornersData.off && hotCornersData.corners !== undefined
|
||||||
|
|
||||||
Flow {
|
DankButtonGroup {
|
||||||
id: hotCornersFlow
|
id: hotCornersGroup
|
||||||
anchors.left: parent.left
|
anchors.horizontalCenter: parent.horizontalCenter
|
||||||
anchors.right: parent.right
|
selectionMode: "multi"
|
||||||
anchors.leftMargin: Theme.spacingM
|
checkEnabled: false
|
||||||
anchors.rightMargin: Theme.spacingM
|
buttonHeight: 32
|
||||||
spacing: Theme.spacingS
|
buttonPadding: parent.width < 400 ? Theme.spacingXS : Theme.spacingM
|
||||||
property string outName: modelData
|
minButtonWidth: parent.width < 400 ? 28 : 56
|
||||||
property var outData: outputData
|
textSize: parent.width < 400 ? 11 : Theme.fontSizeMedium
|
||||||
visible: {
|
model: [I18n.tr("Top Left"), I18n.tr("Top Right"), I18n.tr("Bottom Left"), I18n.tr("Bottom Right")]
|
||||||
const hcData = root.getNiriSetting(outData, outName, "hotCorners", null);
|
property var cornerKeys: ["top-left", "top-right", "bottom-left", "bottom-right"]
|
||||||
return hcData && !hcData.off && hcData.corners !== undefined;
|
currentSelection: {
|
||||||
|
const hcData = parent.hotCornersData;
|
||||||
|
if (!hcData?.corners)
|
||||||
|
return [];
|
||||||
|
return hcData.corners.map(key => {
|
||||||
|
const idx = cornerKeys.indexOf(key);
|
||||||
|
return idx >= 0 ? model[idx] : null;
|
||||||
|
}).filter(v => v !== null);
|
||||||
}
|
}
|
||||||
|
onSelectionChanged: (index, selected) => {
|
||||||
Repeater {
|
const corners = currentSelection.map(label => {
|
||||||
model: ["top-left", "top-right", "bottom-left", "bottom-right"]
|
const idx = model.indexOf(label);
|
||||||
|
return idx >= 0 ? cornerKeys[idx] : null;
|
||||||
delegate: Rectangle {
|
}).filter(v => v !== null);
|
||||||
id: cornerChip
|
root.setNiriSetting(outputCard.outputData, outputCard.modelData, "hotCorners", {
|
||||||
required property string modelData
|
"corners": corners
|
||||||
property var hcData: root.getNiriSetting(hotCornersFlow.outData, hotCornersFlow.outName, "hotCorners", null)
|
});
|
||||||
property bool isEnabled: hcData?.corners?.includes(modelData) ?? false
|
|
||||||
|
|
||||||
width: cornerLabel.implicitWidth + Theme.spacingM * 2
|
|
||||||
height: 28
|
|
||||||
radius: 14
|
|
||||||
color: isEnabled ? Theme.primary : Theme.surfaceContainerHighest
|
|
||||||
border.color: isEnabled ? Theme.primary : Theme.outline
|
|
||||||
border.width: 1
|
|
||||||
|
|
||||||
StyledText {
|
|
||||||
id: cornerLabel
|
|
||||||
anchors.centerIn: parent
|
|
||||||
text: cornerChip.modelData.split("-").map(s => s.charAt(0).toUpperCase() + s.slice(1)).join(" ")
|
|
||||||
font.pixelSize: Theme.fontSizeSmall
|
|
||||||
color: cornerChip.isEnabled ? Theme.primaryText : Theme.surfaceText
|
|
||||||
}
|
|
||||||
|
|
||||||
MouseArea {
|
|
||||||
anchors.fill: parent
|
|
||||||
cursorShape: Qt.PointingHandCursor
|
|
||||||
onClicked: {
|
|
||||||
const currentHc = root.getNiriSetting(hotCornersFlow.outData, hotCornersFlow.outName, "hotCorners", {
|
|
||||||
"corners": []
|
|
||||||
});
|
|
||||||
const corners = currentHc?.corners ? [...currentHc.corners] : [];
|
|
||||||
const idx = corners.indexOf(cornerChip.modelData);
|
|
||||||
if (idx >= 0) {
|
|
||||||
corners.splice(idx, 1);
|
|
||||||
} else {
|
|
||||||
corners.push(cornerChip.modelData);
|
|
||||||
}
|
|
||||||
root.setNiriSetting(hotCornersFlow.outData, hotCornersFlow.outName, "hotCorners", {
|
|
||||||
"corners": corners
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user