zach's nutty qmlformat
This commit is contained in:
@@ -0,0 +1,18 @@
|
|||||||
|
|
||||||
|
FileView {
|
||||||
|
id: watcher
|
||||||
|
path: root.configPath
|
||||||
|
|
||||||
|
watchChanges: true
|
||||||
|
|
||||||
|
onFileChanged: reload()
|
||||||
|
|
||||||
|
onAdapterUpdated: writeAdapter()
|
||||||
|
|
||||||
|
JsonAdapter {
|
||||||
|
id: adapter
|
||||||
|
|
||||||
|
property string gifFolder: Quickshell.shellDir + "/Gifs"
|
||||||
|
property real maxScaling: 1
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,38 @@
|
|||||||
|
|
||||||
|
FileView {
|
||||||
|
id: watcher
|
||||||
|
path: configPath
|
||||||
|
|
||||||
|
property string name: gifItem.fileBaseName + ".json"
|
||||||
|
property string configDir: Quickshell.env("HOME") + "/.config/I-DeskPet/"
|
||||||
|
property string configPath: configDir + name
|
||||||
|
|
||||||
|
onLoaded: {
|
||||||
|
if ( gifSaved.zIndex === -1 ) gifSaved.zIndex = gifItem.index
|
||||||
|
gifItem.x = gifSaved.positionX
|
||||||
|
gifItem.y = gifSaved.positionY
|
||||||
|
gifItem.loaded = true
|
||||||
|
}
|
||||||
|
|
||||||
|
onLoadFailed: {
|
||||||
|
gifSaved.zIndex = gifItem.index
|
||||||
|
writeAdapter()
|
||||||
|
gifItem.loaded = true
|
||||||
|
}
|
||||||
|
|
||||||
|
watchChanges: true
|
||||||
|
|
||||||
|
onFileChanged: reload()
|
||||||
|
|
||||||
|
onAdapterUpdated: writeAdapter()
|
||||||
|
|
||||||
|
JsonAdapter {
|
||||||
|
id: gifSaved
|
||||||
|
|
||||||
|
property real scaling: 1
|
||||||
|
property int positionX: 0
|
||||||
|
property int positionY: 0
|
||||||
|
property int zIndex: -1
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
+38
@@ -0,0 +1,38 @@
|
|||||||
|
|
||||||
|
FileView {
|
||||||
|
id: watcher
|
||||||
|
path: configPath
|
||||||
|
|
||||||
|
property string name: gifItem.fileBaseName + ".json"
|
||||||
|
property string configDir: Quickshell.env("HOME") + "/.config/I-DeskPet/"
|
||||||
|
property string configPath: configDir + name
|
||||||
|
|
||||||
|
onLoaded: {
|
||||||
|
if ( gifSaved.zIndex === -1 ) gifSaved.zIndex = gifItem.index
|
||||||
|
gifItem.x = gifSaved.positionX
|
||||||
|
gifItem.y = gifSaved.positionY
|
||||||
|
gifItem.loaded = true
|
||||||
|
}
|
||||||
|
|
||||||
|
onLoadFailed: {
|
||||||
|
gifSaved.zIndex = gifItem.index
|
||||||
|
writeAdapter()
|
||||||
|
gifItem.loaded = true
|
||||||
|
}
|
||||||
|
|
||||||
|
watchChanges: true
|
||||||
|
|
||||||
|
onFileChanged: reload()
|
||||||
|
|
||||||
|
onAdapterUpdated: writeAdapter()
|
||||||
|
|
||||||
|
JsonAdapter {
|
||||||
|
id: gifSaved
|
||||||
|
|
||||||
|
property real scaling: 1
|
||||||
|
property int positionX: 0
|
||||||
|
property int positionY: 0
|
||||||
|
property int zIndex: -1
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
+20
-19
@@ -7,49 +7,50 @@ import Quickshell
|
|||||||
Singleton {
|
Singleton {
|
||||||
id: root
|
id: root
|
||||||
|
|
||||||
property alias gifFolder: adapter.gifFolder
|
|
||||||
property alias maxScaling: adapter.maxScaling
|
|
||||||
property string configDir: Quickshell.env("HOME") + "/.config/I-DeskPet"
|
property string configDir: Quickshell.env("HOME") + "/.config/I-DeskPet"
|
||||||
property string configPath: configDir + "/config.json"
|
property string configPath: configDir + "/config.json"
|
||||||
|
property alias gifFolder: adapter.gifFolder
|
||||||
|
property alias maxScaling: adapter.maxScale
|
||||||
|
|
||||||
Process {
|
Process {
|
||||||
id: dirCheck
|
id: dirCheck
|
||||||
running: true
|
|
||||||
command: [ "test", "-d", root.configDir ]
|
|
||||||
|
|
||||||
onExited: function( exitCode ) {
|
command: ["test", "-d", root.configDir]
|
||||||
if ( exitCode !== 0 ) {
|
running: true
|
||||||
console.log( "creating dir" )
|
|
||||||
dirCreate.running = true
|
onExited: function (exitCode) {
|
||||||
|
if (exitCode !== 0) {
|
||||||
|
console.log("creating dir");
|
||||||
|
dirCreate.running = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Process {
|
Process {
|
||||||
id: dirCreate
|
id: dirCreate
|
||||||
running: false
|
|
||||||
command: [ "mkdir", "-p", root.configDir ]
|
|
||||||
|
|
||||||
onExited: function(): void {
|
command: ["mkdir", "-p", root.configDir]
|
||||||
console.log( "Created config directory:", root.configDir )
|
running: false
|
||||||
|
|
||||||
|
onExited: function (): void {
|
||||||
|
console.log("Created config directory:", root.configDir);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
FileView {
|
FileView {
|
||||||
id: watcher
|
id: watcher
|
||||||
path: root.configPath
|
|
||||||
|
|
||||||
|
path: root.configPath
|
||||||
watchChanges: true
|
watchChanges: true
|
||||||
|
|
||||||
onFileChanged: reload()
|
|
||||||
|
|
||||||
onAdapterUpdated: writeAdapter()
|
onAdapterUpdated: writeAdapter()
|
||||||
|
onFileChanged: reload()
|
||||||
|
|
||||||
JsonAdapter {
|
JsonAdapter {
|
||||||
id: adapter
|
id: adapter
|
||||||
|
|
||||||
property string gifFolder: Quickshell.shellDir + "/Gifs"
|
property string gifFolder: Quickshell.shellDir + "/Gifs"
|
||||||
property real maxScaling: 1
|
property real maxScale: 1
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+4
-3
@@ -3,15 +3,16 @@ import Qt.labs.folderlistmodel
|
|||||||
|
|
||||||
Item {
|
Item {
|
||||||
id: root
|
id: root
|
||||||
required property string gifFolder
|
|
||||||
|
|
||||||
property alias gifsModel: folderModel
|
|
||||||
property alias count: folderModel.count
|
property alias count: folderModel.count
|
||||||
|
required property string gifFolder
|
||||||
|
property alias gifsModel: folderModel
|
||||||
|
|
||||||
FolderListModel {
|
FolderListModel {
|
||||||
id: folderModel
|
id: folderModel
|
||||||
|
|
||||||
folder: "file://" + root.gifFolder
|
folder: "file://" + root.gifFolder
|
||||||
nameFilters: [ "*.gif" ]
|
nameFilters: ["*.gif"]
|
||||||
showDirs: false
|
showDirs: false
|
||||||
showHidden: false
|
showHidden: false
|
||||||
sortField: FolderListModel.Name
|
sortField: FolderListModel.Name
|
||||||
|
|||||||
+44
-40
@@ -7,78 +7,82 @@ import Qt.labs.folderlistmodel
|
|||||||
import qs.Modules
|
import qs.Modules
|
||||||
|
|
||||||
Repeater {
|
Repeater {
|
||||||
id: gifRepeater
|
id: gifRepeater
|
||||||
required property FolderListModel gifsModel
|
|
||||||
|
|
||||||
model: gifsModel
|
required property FolderListModel gifsModel
|
||||||
Item {
|
|
||||||
|
model: gifsModel
|
||||||
|
|
||||||
|
Item {
|
||||||
id: gifItem
|
id: gifItem
|
||||||
|
|
||||||
required property url fileUrl
|
|
||||||
required property string fileBaseName
|
required property string fileBaseName
|
||||||
|
required property url fileUrl
|
||||||
|
property alias hovered: mouse.containsMouse
|
||||||
required property int index
|
required property int index
|
||||||
property bool loaded: false
|
property bool loaded: false
|
||||||
property alias hovered: mouse.containsMouse
|
|
||||||
property alias zIndex: gifSaved.zIndex
|
property alias zIndex: gifSaved.zIndex
|
||||||
|
|
||||||
z: gifSaved.zIndex
|
height: Math.floor(gif.sourceSize.height / gifSaved.scaling)
|
||||||
visible: gifItem.loaded
|
visible: gifItem.loaded
|
||||||
onXChanged: if ( gifItem.loaded ) gifSaved.positionX = gifItem.x
|
width: Math.floor(gif.sourceSize.width / gifSaved.scaling)
|
||||||
onYChanged: if ( gifItem.loaded ) gifSaved.positionY = gifItem.y
|
z: gifSaved.zIndex
|
||||||
width: Math.floor( gif.sourceSize.width / gifSaved.scaling )
|
|
||||||
height: Math.floor( gif.sourceSize.height / gifSaved.scaling )
|
|
||||||
|
|
||||||
AnimatedImage {
|
onXChanged: if (gifItem.loaded)
|
||||||
id: gif
|
gifSaved.positionX = gifItem.x
|
||||||
source: gifItem.fileUrl
|
onYChanged: if (gifItem.loaded)
|
||||||
fillMode: Image.PreserveAspectFit
|
gifSaved.positionY = gifItem.y
|
||||||
anchors.fill: parent
|
|
||||||
}
|
AnimatedImage {
|
||||||
|
id: gif
|
||||||
|
|
||||||
|
anchors.fill: parent
|
||||||
|
fillMode: Image.PreserveAspectFit
|
||||||
|
source: gifItem.fileUrl
|
||||||
|
}
|
||||||
|
|
||||||
Mouse {
|
Mouse {
|
||||||
id: mouse
|
id: mouse
|
||||||
onWheel: (wheel)=> {
|
|
||||||
gifSaved.scaling = Math.max( ConfigLoader.maxScaling, ( gifSaved.scaling + 0.1 * ( wheel.angleDelta.y / 120 ) ) )
|
|
||||||
}
|
|
||||||
|
|
||||||
onDoubleClicked: gifSaved.scaling = 1
|
onDoubleClicked: gifSaved.scaling = 1
|
||||||
|
onWheel: wheel => {
|
||||||
|
gifSaved.scaling = Math.max(ConfigLoader.maxScaling, (gifSaved.scaling + 0.1 * (wheel.angleDelta.y / 120)));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
FileView {
|
FileView {
|
||||||
id: watcher
|
id: watcher
|
||||||
path: configPath
|
|
||||||
|
|
||||||
property string name: gifItem.fileBaseName + ".json"
|
|
||||||
property string configDir: Quickshell.env("HOME") + "/.config/I-DeskPet/"
|
property string configDir: Quickshell.env("HOME") + "/.config/I-DeskPet/"
|
||||||
property string configPath: configDir + name
|
property string configPath: configDir + name
|
||||||
|
property string name: gifItem.fileBaseName + ".json"
|
||||||
|
|
||||||
onLoaded: {
|
path: configPath
|
||||||
if ( gifSaved.zIndex === -1 ) gifSaved.zIndex = gifItem.index
|
|
||||||
gifItem.x = gifSaved.positionX
|
|
||||||
gifItem.y = gifSaved.positionY
|
|
||||||
gifItem.loaded = true
|
|
||||||
}
|
|
||||||
|
|
||||||
onLoadFailed: {
|
|
||||||
gifSaved.zIndex = gifItem.index
|
|
||||||
writeAdapter()
|
|
||||||
gifItem.loaded = true
|
|
||||||
}
|
|
||||||
|
|
||||||
watchChanges: true
|
watchChanges: true
|
||||||
|
|
||||||
onFileChanged: reload()
|
|
||||||
|
|
||||||
onAdapterUpdated: writeAdapter()
|
onAdapterUpdated: writeAdapter()
|
||||||
|
onFileChanged: reload()
|
||||||
|
onLoadFailed: {
|
||||||
|
gifSaved.zIndex = gifItem.index;
|
||||||
|
writeAdapter();
|
||||||
|
gifItem.loaded = true;
|
||||||
|
}
|
||||||
|
onLoaded: {
|
||||||
|
if (gifSaved.zIndex === -1)
|
||||||
|
gifSaved.zIndex = gifItem.index;
|
||||||
|
gifItem.x = gifSaved.positionX;
|
||||||
|
gifItem.y = gifSaved.positionY;
|
||||||
|
gifItem.loaded = true;
|
||||||
|
}
|
||||||
|
|
||||||
JsonAdapter {
|
JsonAdapter {
|
||||||
id: gifSaved
|
id: gifSaved
|
||||||
|
|
||||||
property real scaling: 1
|
|
||||||
property int positionX: 0
|
property int positionX: 0
|
||||||
property int positionY: 0
|
property int positionY: 0
|
||||||
|
property real scaling: 1
|
||||||
property int zIndex: -1
|
property int zIndex: -1
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+9
-9
@@ -1,13 +1,13 @@
|
|||||||
import QtQuick
|
import QtQuick
|
||||||
|
|
||||||
MouseArea {
|
MouseArea {
|
||||||
anchors.fill: parent
|
acceptedButtons: Qt.LeftButton
|
||||||
acceptedButtons: Qt.LeftButton
|
anchors.fill: parent
|
||||||
hoverEnabled: true
|
drag.axis: Drag.XAndYAxis
|
||||||
drag.target: parent
|
drag.maximumX: Screen.width - parent.width
|
||||||
drag.axis: Drag.XAndYAxis
|
drag.maximumY: Screen.height - parent.height
|
||||||
drag.minimumX: 0
|
drag.minimumX: 0
|
||||||
drag.maximumX: Screen.width - parent.width
|
drag.minimumY: 0
|
||||||
drag.minimumY: 0
|
drag.target: parent
|
||||||
drag.maximumY: Screen.height - parent.height
|
hoverEnabled: true
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,167 +1,183 @@
|
|||||||
pragma ComponentBehavior: Bound
|
pragma ComponentBehavior: Bound
|
||||||
|
|
||||||
import QtQuick
|
|
||||||
import Quickshell
|
|
||||||
import Quickshell.Io
|
|
||||||
import Quickshell.Wayland
|
|
||||||
import Quickshell.Hyprland
|
|
||||||
import qs.Modules
|
|
||||||
|
|
||||||
PanelWindow {
|
|
||||||
id: mainWindow
|
|
||||||
WlrLayershell.namespace: "I-DeskPet"
|
|
||||||
WlrLayershell.layer: WlrLayer.Overlay
|
|
||||||
WlrLayershell.exclusionMode: ExclusionMode.Ignore
|
|
||||||
surfaceFormat.opaque: false
|
|
||||||
color: "transparent"
|
|
||||||
|
|
||||||
property bool onTop: true
|
|
||||||
property list<Item> repeaterItems: []
|
|
||||||
|
|
||||||
anchors {
|
|
||||||
left: true
|
|
||||||
bottom: true
|
|
||||||
right: true
|
|
||||||
top: true
|
|
||||||
}
|
|
||||||
|
|
||||||
margins {
|
|
||||||
left: 0
|
|
||||||
bottom: 0
|
|
||||||
right: 0
|
|
||||||
top: 0
|
|
||||||
}
|
|
||||||
|
|
||||||
GetGifs {
|
|
||||||
id: getGifs
|
|
||||||
gifFolder: ConfigLoader.gifFolder
|
|
||||||
}
|
|
||||||
|
|
||||||
GifsLoader {
|
import QtQuick
|
||||||
id: gifLoader
|
import Quickshell
|
||||||
gifsModel: getGifs.gifsModel
|
import Quickshell.Io
|
||||||
onItemAdded: function( index, item ) {
|
import Quickshell.Wayland
|
||||||
mainWindow.repeaterItems = Array.from( { length: gifLoader.count }, (_, i) => gifLoader.itemAt(i) ).filter( v => v !== null )
|
import Quickshell.Hyprland
|
||||||
|
import qs.Modules
|
||||||
|
|
||||||
|
PanelWindow {
|
||||||
|
id: mainWindow
|
||||||
|
|
||||||
|
property var noMove: Region {
|
||||||
|
}
|
||||||
|
property bool onTop: true
|
||||||
|
property var petMove: Region {
|
||||||
|
id: pets
|
||||||
|
|
||||||
|
height: Screen.height
|
||||||
|
intersection: Intersection.Xor
|
||||||
|
regions: maskVariants.instances
|
||||||
|
width: Screen.width
|
||||||
|
}
|
||||||
|
property list<Item> repeaterItems: []
|
||||||
|
property bool setMask: true
|
||||||
|
|
||||||
|
function petRegion(itemObject) {
|
||||||
|
let newregion = regionComponent.createObject(pets, {
|
||||||
|
"item": itemObject
|
||||||
|
});
|
||||||
|
pets.regions.push(newregion);
|
||||||
|
}
|
||||||
|
|
||||||
|
WlrLayershell.exclusionMode: ExclusionMode.Ignore
|
||||||
|
WlrLayershell.layer: WlrLayer.Overlay
|
||||||
|
WlrLayershell.namespace: "I-DeskPet"
|
||||||
|
color: "transparent"
|
||||||
|
surfaceFormat.opaque: false
|
||||||
|
|
||||||
|
mask: Region {
|
||||||
|
height: Screen.height
|
||||||
|
intersection: Intersection.Xor
|
||||||
|
regions: maskVariants.instances
|
||||||
|
width: Screen.width
|
||||||
|
}
|
||||||
|
|
||||||
|
anchors {
|
||||||
|
bottom: true
|
||||||
|
left: true
|
||||||
|
right: true
|
||||||
|
top: true
|
||||||
|
}
|
||||||
|
|
||||||
|
margins {
|
||||||
|
bottom: 0
|
||||||
|
left: 0
|
||||||
|
right: 0
|
||||||
|
top: 0
|
||||||
|
}
|
||||||
|
|
||||||
|
GetGifs {
|
||||||
|
id: getGifs
|
||||||
|
|
||||||
|
gifFolder: ConfigLoader.gifFolder
|
||||||
|
}
|
||||||
|
|
||||||
|
GifsLoader {
|
||||||
|
id: gifLoader
|
||||||
|
|
||||||
|
gifsModel: getGifs.gifsModel
|
||||||
|
|
||||||
|
onItemAdded: function (index, item) {
|
||||||
|
mainWindow.repeaterItems = Array.from({
|
||||||
|
length: gifLoader.count
|
||||||
|
}, (_, i) => gifLoader.itemAt(i)).filter(v => v !== null);
|
||||||
}
|
}
|
||||||
onItemRemoved: function( index, item ) {
|
onItemRemoved: function (index, item) {
|
||||||
mainWindow.repeaterItems = Array.from( { length: gifLoader.count }, (_, i) => gifLoader.itemAt(i) ).filter( v => v !== null )
|
mainWindow.repeaterItems = Array.from({
|
||||||
|
length: gifLoader.count
|
||||||
|
}, (_, i) => gifLoader.itemAt(i)).filter(v => v !== null);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Variants {
|
|
||||||
id: maskVariants
|
|
||||||
|
|
||||||
model: [ ...mainWindow.repeaterItems ]
|
|
||||||
|
|
||||||
Region {
|
|
||||||
required property Item modelData
|
|
||||||
|
|
||||||
Component.onCompleted: {
|
|
||||||
console.log(modelData)
|
|
||||||
}
|
|
||||||
|
|
||||||
x: modelData.x
|
|
||||||
y: modelData.y
|
|
||||||
width: modelData.width
|
|
||||||
height: modelData.height
|
|
||||||
intersection: Intersection.Subtract
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
function petRegion( itemObject ) {
|
|
||||||
let newregion = regionComponent.createObject( pets, { "item": itemObject })
|
|
||||||
pets.regions.push( newregion )
|
|
||||||
}
|
|
||||||
|
|
||||||
Component {
|
|
||||||
id: regionComponent
|
|
||||||
Region { }
|
|
||||||
}
|
|
||||||
|
|
||||||
mask: Region {
|
|
||||||
width: Screen.width
|
|
||||||
height: Screen.height
|
|
||||||
intersection: Intersection.Xor
|
|
||||||
regions: maskVariants.instances
|
|
||||||
}
|
|
||||||
|
|
||||||
property var petMove: Region { id: pets
|
|
||||||
width: Screen.width
|
|
||||||
height: Screen.height
|
|
||||||
intersection: Intersection.Xor
|
|
||||||
regions: maskVariants.instances
|
|
||||||
}
|
|
||||||
|
|
||||||
property var noMove: Region {}
|
|
||||||
|
|
||||||
property bool setMask: true
|
|
||||||
|
|
||||||
GlobalShortcut {
|
|
||||||
appid: "I-DeskPet"
|
|
||||||
name: "toggle-Layer"
|
|
||||||
onPressed: {
|
|
||||||
if (!mainWindow.onTop) {
|
|
||||||
mainWindow.WlrLayershell.layer = WlrLayer.Overlay
|
|
||||||
mainWindow.onTop = true
|
|
||||||
} else {
|
|
||||||
mainWindow.WlrLayershell.layer = WlrLayer.Bottom
|
|
||||||
mainWindow.onTop = false
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
GlobalShortcut {
|
|
||||||
appid: "I-DeskPet"
|
|
||||||
name: "toggle-Region"
|
|
||||||
onPressed: {
|
|
||||||
if ( !mainWindow.setMask ) {
|
|
||||||
mainWindow.mask = mainWindow.petMove
|
|
||||||
mainWindow.setMask = true
|
|
||||||
} else {
|
|
||||||
mainWindow.mask = mainWindow.noMove
|
|
||||||
mainWindow.setMask = false
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
GlobalShortcut {
|
Variants {
|
||||||
appid: "I-DeskPet"
|
id: maskVariants
|
||||||
name: "cycle-zIndex"
|
|
||||||
onPressed: {
|
|
||||||
let items = mainWindow.repeaterItems
|
|
||||||
if ( items.length < 2 ) return
|
|
||||||
|
|
||||||
// Find the hovered GIF
|
model: [...mainWindow.repeaterItems]
|
||||||
let hovered = null
|
|
||||||
for ( let i = 0; i < items.length; i++ ) {
|
|
||||||
if ( items[i].hovered ) {
|
|
||||||
hovered = items[i]
|
|
||||||
break
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if ( !hovered ) return
|
|
||||||
|
|
||||||
let currentZ = hovered.zIndex
|
Region {
|
||||||
let maxZ = items.length - 1
|
required property Item modelData
|
||||||
|
|
||||||
if ( currentZ >= maxZ ) {
|
height: modelData.height
|
||||||
// Already on top, wrap to bottom: shift everyone else up by 1
|
intersection: Intersection.Subtract
|
||||||
for ( let i = 0; i < items.length; i++ ) {
|
width: modelData.width
|
||||||
if ( items[i] !== hovered ) {
|
x: modelData.x
|
||||||
items[i].zIndex += 1
|
y: modelData.y
|
||||||
}
|
|
||||||
}
|
Component.onCompleted: {
|
||||||
hovered.zIndex = 0
|
console.log(modelData);
|
||||||
} else {
|
}
|
||||||
// Swap with the item directly above
|
}
|
||||||
for ( let i = 0; i < items.length; i++ ) {
|
}
|
||||||
if ( items[i] !== hovered && items[i].zIndex === currentZ + 1 ) {
|
|
||||||
items[i].zIndex = currentZ
|
Component {
|
||||||
break
|
id: regionComponent
|
||||||
}
|
|
||||||
}
|
Region {
|
||||||
hovered.zIndex = currentZ + 1
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
GlobalShortcut {
|
||||||
|
appid: "I-DeskPet"
|
||||||
|
name: "toggle-Layer"
|
||||||
|
|
||||||
|
onPressed: {
|
||||||
|
if (!mainWindow.onTop) {
|
||||||
|
mainWindow.WlrLayershell.layer = WlrLayer.Overlay;
|
||||||
|
mainWindow.onTop = true;
|
||||||
|
} else {
|
||||||
|
mainWindow.WlrLayershell.layer = WlrLayer.Bottom;
|
||||||
|
mainWindow.onTop = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
GlobalShortcut {
|
||||||
|
appid: "I-DeskPet"
|
||||||
|
name: "toggle-Region"
|
||||||
|
|
||||||
|
onPressed: {
|
||||||
|
if (!mainWindow.setMask) {
|
||||||
|
mainWindow.mask = mainWindow.petMove;
|
||||||
|
mainWindow.setMask = true;
|
||||||
|
} else {
|
||||||
|
mainWindow.mask = mainWindow.noMove;
|
||||||
|
mainWindow.setMask = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
GlobalShortcut {
|
||||||
|
appid: "I-DeskPet"
|
||||||
|
name: "cycle-zIndex"
|
||||||
|
|
||||||
|
onPressed: {
|
||||||
|
let items = mainWindow.repeaterItems;
|
||||||
|
if (items.length < 2)
|
||||||
|
return;
|
||||||
|
|
||||||
|
// Find the hovered GIF
|
||||||
|
let hovered = null;
|
||||||
|
for (let i = 0; i < items.length; i++) {
|
||||||
|
if (items[i].hovered) {
|
||||||
|
hovered = items[i];
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (!hovered)
|
||||||
|
return;
|
||||||
|
let currentZ = hovered.zIndex;
|
||||||
|
let maxZ = items.length - 1;
|
||||||
|
|
||||||
|
if (currentZ >= maxZ) {
|
||||||
|
// Already on top, wrap to bottom: shift everyone else up by 1
|
||||||
|
for (let i = 0; i < items.length; i++) {
|
||||||
|
if (items[i] !== hovered) {
|
||||||
|
items[i].zIndex += 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
hovered.zIndex = 0;
|
||||||
|
} else {
|
||||||
|
// Swap with the item directly above
|
||||||
|
for (let i = 0; i < items.length; i++) {
|
||||||
|
if (items[i] !== hovered && items[i].zIndex === currentZ + 1) {
|
||||||
|
items[i].zIndex = currentZ;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
hovered.zIndex = currentZ + 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user