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