forked from Shinonome/dots-hyprland
cheatsheet: put in loader
This commit is contained in:
@@ -19,12 +19,26 @@ Scope { // Scope
|
||||
id: cheatsheetVariants
|
||||
model: Quickshell.screens
|
||||
|
||||
PanelWindow { // Window
|
||||
Loader {
|
||||
id: cheatsheetLoader
|
||||
active: false
|
||||
property var modelData
|
||||
|
||||
sourceComponent: PanelWindow { // Window
|
||||
id: cheatsheetRoot
|
||||
visible: false
|
||||
visible: cheatsheetLoader.active
|
||||
focusable: true
|
||||
|
||||
property var modelData
|
||||
anchors {
|
||||
top: true
|
||||
bottom: true
|
||||
left: true
|
||||
right: true
|
||||
}
|
||||
|
||||
function hide() {
|
||||
cheatsheetLoader.active = false
|
||||
}
|
||||
|
||||
screen: modelData
|
||||
exclusiveZone: 0
|
||||
@@ -44,7 +58,7 @@ Scope { // Scope
|
||||
windows: [ cheatsheetRoot ]
|
||||
active: false
|
||||
onCleared: () => {
|
||||
if (!active) cheatsheetRoot.visible = false
|
||||
if (!active) cheatsheetRoot.hide()
|
||||
}
|
||||
}
|
||||
|
||||
@@ -76,7 +90,7 @@ Scope { // Scope
|
||||
|
||||
Keys.onPressed: (event) => { // Esc to close
|
||||
if (event.key === Qt.Key_Escape) {
|
||||
cheatsheetRoot.visible = false
|
||||
cheatsheetRoot.hide()
|
||||
}
|
||||
}
|
||||
|
||||
@@ -94,7 +108,7 @@ Scope { // Scope
|
||||
|
||||
PointingHandInteraction {}
|
||||
onClicked: {
|
||||
cheatsheetRoot.visible = false
|
||||
cheatsheetRoot.hide()
|
||||
}
|
||||
|
||||
background: Item {}
|
||||
@@ -149,7 +163,7 @@ Scope { // Scope
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
IpcHandler {
|
||||
@@ -157,30 +171,22 @@ Scope { // Scope
|
||||
|
||||
function toggle(): void {
|
||||
for (let i = 0; i < cheatsheetVariants.instances.length; i++) {
|
||||
let panelWindow = cheatsheetVariants.instances[i];
|
||||
if (panelWindow.modelData.name == Hyprland.focusedMonitor.name) {
|
||||
panelWindow.visible = !panelWindow.visible;
|
||||
if(panelWindow.visible) Notifications.timeoutAll();
|
||||
}
|
||||
const loader = cheatsheetVariants.instances[i];
|
||||
loader.active = !loader.active;
|
||||
}
|
||||
}
|
||||
|
||||
function close(): void {
|
||||
for (let i = 0; i < cheatsheetVariants.instances.length; i++) {
|
||||
let panelWindow = cheatsheetVariants.instances[i];
|
||||
if (panelWindow.modelData.name == Hyprland.focusedMonitor.name) {
|
||||
panelWindow.visible = false;
|
||||
}
|
||||
const loader = cheatsheetVariants.instances[i];
|
||||
loader.active = false
|
||||
}
|
||||
}
|
||||
|
||||
function open(): void {
|
||||
for (let i = 0; i < cheatsheetVariants.instances.length; i++) {
|
||||
let panelWindow = cheatsheetVariants.instances[i];
|
||||
if (panelWindow.modelData.name == Hyprland.focusedMonitor.name) {
|
||||
panelWindow.visible = true;
|
||||
if(panelWindow.visible) Notifications.timeoutAll();
|
||||
}
|
||||
const loader = cheatsheetVariants.instances[i];
|
||||
loader.active = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -191,11 +197,8 @@ Scope { // Scope
|
||||
|
||||
onPressed: {
|
||||
for (let i = 0; i < cheatsheetVariants.instances.length; i++) {
|
||||
let panelWindow = cheatsheetVariants.instances[i];
|
||||
if (panelWindow.modelData.name == Hyprland.focusedMonitor.name) {
|
||||
panelWindow.visible = !panelWindow.visible;
|
||||
if(panelWindow.visible) Notifications.timeoutAll();
|
||||
}
|
||||
const loader = cheatsheetVariants.instances[i];
|
||||
loader.active = !loader.active;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -206,11 +209,8 @@ Scope { // Scope
|
||||
|
||||
onPressed: {
|
||||
for (let i = 0; i < cheatsheetVariants.instances.length; i++) {
|
||||
let panelWindow = cheatsheetVariants.instances[i];
|
||||
if (panelWindow.modelData.name == Hyprland.focusedMonitor.name) {
|
||||
panelWindow.visible = true;
|
||||
if(panelWindow.visible) Notifications.timeoutAll();
|
||||
}
|
||||
const loader = cheatsheetVariants.instances[i];
|
||||
loader.active = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -221,10 +221,8 @@ Scope { // Scope
|
||||
|
||||
onPressed: {
|
||||
for (let i = 0; i < cheatsheetVariants.instances.length; i++) {
|
||||
let panelWindow = cheatsheetVariants.instances[i];
|
||||
if (panelWindow.modelData.name == Hyprland.focusedMonitor.name) {
|
||||
panelWindow.visible = false;
|
||||
}
|
||||
const loader = cheatsheetVariants.instances[i];
|
||||
loader.active = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user