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
|
||||
}
|
||||
}
|
||||
}
|
||||
+12
-11
@@ -7,49 +7,50 @@ import Quickshell
|
||||
Singleton {
|
||||
id: root
|
||||
|
||||
property alias gifFolder: adapter.gifFolder
|
||||
property alias maxScaling: adapter.maxScaling
|
||||
property string configDir: Quickshell.env("HOME") + "/.config/I-DeskPet"
|
||||
property string configPath: configDir + "/config.json"
|
||||
property alias gifFolder: adapter.gifFolder
|
||||
property alias maxScaling: adapter.maxScale
|
||||
|
||||
Process {
|
||||
id: dirCheck
|
||||
running: true
|
||||
|
||||
command: ["test", "-d", root.configDir]
|
||||
running: true
|
||||
|
||||
onExited: function (exitCode) {
|
||||
if (exitCode !== 0) {
|
||||
console.log( "creating dir" )
|
||||
dirCreate.running = true
|
||||
console.log("creating dir");
|
||||
dirCreate.running = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Process {
|
||||
id: dirCreate
|
||||
running: false
|
||||
|
||||
command: ["mkdir", "-p", root.configDir]
|
||||
running: false
|
||||
|
||||
onExited: function (): void {
|
||||
console.log( "Created config directory:", root.configDir )
|
||||
console.log("Created config directory:", root.configDir);
|
||||
}
|
||||
}
|
||||
|
||||
FileView {
|
||||
id: watcher
|
||||
path: root.configPath
|
||||
|
||||
path: root.configPath
|
||||
watchChanges: true
|
||||
|
||||
onFileChanged: reload()
|
||||
|
||||
onAdapterUpdated: writeAdapter()
|
||||
onFileChanged: reload()
|
||||
|
||||
JsonAdapter {
|
||||
id: adapter
|
||||
|
||||
property string gifFolder: Quickshell.shellDir + "/Gifs"
|
||||
property real maxScaling: 1
|
||||
property real maxScale: 1
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+3
-2
@@ -3,13 +3,14 @@ import Qt.labs.folderlistmodel
|
||||
|
||||
Item {
|
||||
id: root
|
||||
required property string gifFolder
|
||||
|
||||
property alias gifsModel: folderModel
|
||||
property alias count: folderModel.count
|
||||
required property string gifFolder
|
||||
property alias gifsModel: folderModel
|
||||
|
||||
FolderListModel {
|
||||
id: folderModel
|
||||
|
||||
folder: "file://" + root.gifFolder
|
||||
nameFilters: ["*.gif"]
|
||||
showDirs: false
|
||||
|
||||
+34
-30
@@ -8,75 +8,79 @@ import qs.Modules
|
||||
|
||||
Repeater {
|
||||
id: gifRepeater
|
||||
|
||||
required property FolderListModel gifsModel
|
||||
|
||||
model: gifsModel
|
||||
|
||||
Item {
|
||||
id: gifItem
|
||||
|
||||
required property url fileUrl
|
||||
required property string fileBaseName
|
||||
required property url fileUrl
|
||||
property alias hovered: mouse.containsMouse
|
||||
required property int index
|
||||
property bool loaded: false
|
||||
property alias hovered: mouse.containsMouse
|
||||
property alias zIndex: gifSaved.zIndex
|
||||
|
||||
z: gifSaved.zIndex
|
||||
visible: gifItem.loaded
|
||||
onXChanged: if ( gifItem.loaded ) gifSaved.positionX = gifItem.x
|
||||
onYChanged: if ( gifItem.loaded ) gifSaved.positionY = gifItem.y
|
||||
width: Math.floor( gif.sourceSize.width / gifSaved.scaling )
|
||||
height: Math.floor(gif.sourceSize.height / gifSaved.scaling)
|
||||
visible: gifItem.loaded
|
||||
width: Math.floor(gif.sourceSize.width / gifSaved.scaling)
|
||||
z: gifSaved.zIndex
|
||||
|
||||
onXChanged: if (gifItem.loaded)
|
||||
gifSaved.positionX = gifItem.x
|
||||
onYChanged: if (gifItem.loaded)
|
||||
gifSaved.positionY = gifItem.y
|
||||
|
||||
AnimatedImage {
|
||||
id: gif
|
||||
source: gifItem.fileUrl
|
||||
fillMode: Image.PreserveAspectFit
|
||||
|
||||
anchors.fill: parent
|
||||
fillMode: Image.PreserveAspectFit
|
||||
source: gifItem.fileUrl
|
||||
}
|
||||
|
||||
Mouse {
|
||||
id: mouse
|
||||
onWheel: (wheel)=> {
|
||||
gifSaved.scaling = Math.max( ConfigLoader.maxScaling, ( gifSaved.scaling + 0.1 * ( wheel.angleDelta.y / 120 ) ) )
|
||||
}
|
||||
|
||||
onDoubleClicked: gifSaved.scaling = 1
|
||||
onWheel: wheel => {
|
||||
gifSaved.scaling = Math.max(ConfigLoader.maxScaling, (gifSaved.scaling + 0.1 * (wheel.angleDelta.y / 120)));
|
||||
}
|
||||
}
|
||||
|
||||
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
|
||||
property string name: gifItem.fileBaseName + ".json"
|
||||
|
||||
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
|
||||
}
|
||||
|
||||
path: configPath
|
||||
watchChanges: true
|
||||
|
||||
onFileChanged: reload()
|
||||
|
||||
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 {
|
||||
id: gifSaved
|
||||
|
||||
property real scaling: 1
|
||||
property int positionX: 0
|
||||
property int positionY: 0
|
||||
property real scaling: 1
|
||||
property int zIndex: -1
|
||||
}
|
||||
}
|
||||
|
||||
+5
-5
@@ -1,13 +1,13 @@
|
||||
import QtQuick
|
||||
|
||||
MouseArea {
|
||||
anchors.fill: parent
|
||||
acceptedButtons: Qt.LeftButton
|
||||
hoverEnabled: true
|
||||
drag.target: parent
|
||||
anchors.fill: parent
|
||||
drag.axis: Drag.XAndYAxis
|
||||
drag.minimumX: 0
|
||||
drag.maximumX: Screen.width - parent.width
|
||||
drag.minimumY: 0
|
||||
drag.maximumY: Screen.height - parent.height
|
||||
drag.minimumX: 0
|
||||
drag.minimumY: 0
|
||||
drag.target: parent
|
||||
hoverEnabled: true
|
||||
}
|
||||
|
||||
@@ -9,42 +9,75 @@ import qs.Modules
|
||||
|
||||
PanelWindow {
|
||||
id: mainWindow
|
||||
WlrLayershell.namespace: "I-DeskPet"
|
||||
WlrLayershell.layer: WlrLayer.Overlay
|
||||
WlrLayershell.exclusionMode: ExclusionMode.Ignore
|
||||
surfaceFormat.opaque: false
|
||||
color: "transparent"
|
||||
|
||||
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 {
|
||||
left: true
|
||||
bottom: true
|
||||
left: true
|
||||
right: true
|
||||
top: true
|
||||
}
|
||||
|
||||
margins {
|
||||
left: 0
|
||||
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 )
|
||||
mainWindow.repeaterItems = Array.from({
|
||||
length: gifLoader.count
|
||||
}, (_, i) => gifLoader.itemAt(i)).filter(v => v !== null);
|
||||
}
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -56,56 +89,36 @@ PanelWindow {
|
||||
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
|
||||
}
|
||||
}
|
||||
width: modelData.width
|
||||
x: modelData.x
|
||||
y: modelData.y
|
||||
|
||||
function petRegion( itemObject ) {
|
||||
let newregion = regionComponent.createObject( pets, { "item": itemObject })
|
||||
pets.regions.push( newregion )
|
||||
Component.onCompleted: {
|
||||
console.log(modelData);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Component {
|
||||
id: regionComponent
|
||||
Region { }
|
||||
|
||||
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
|
||||
mainWindow.WlrLayershell.layer = WlrLayer.Overlay;
|
||||
mainWindow.onTop = true;
|
||||
} else {
|
||||
mainWindow.WlrLayershell.layer = WlrLayer.Bottom
|
||||
mainWindow.onTop = false
|
||||
mainWindow.WlrLayershell.layer = WlrLayer.Bottom;
|
||||
mainWindow.onTop = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -113,13 +126,14 @@ PanelWindow {
|
||||
GlobalShortcut {
|
||||
appid: "I-DeskPet"
|
||||
name: "toggle-Region"
|
||||
|
||||
onPressed: {
|
||||
if (!mainWindow.setMask) {
|
||||
mainWindow.mask = mainWindow.petMove
|
||||
mainWindow.setMask = true
|
||||
mainWindow.mask = mainWindow.petMove;
|
||||
mainWindow.setMask = true;
|
||||
} else {
|
||||
mainWindow.mask = mainWindow.noMove
|
||||
mainWindow.setMask = false
|
||||
mainWindow.mask = mainWindow.noMove;
|
||||
mainWindow.setMask = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -127,40 +141,42 @@ PanelWindow {
|
||||
GlobalShortcut {
|
||||
appid: "I-DeskPet"
|
||||
name: "cycle-zIndex"
|
||||
|
||||
onPressed: {
|
||||
let items = mainWindow.repeaterItems
|
||||
if ( items.length < 2 ) return
|
||||
let items = mainWindow.repeaterItems;
|
||||
if (items.length < 2)
|
||||
return;
|
||||
|
||||
// Find the hovered GIF
|
||||
let hovered = null
|
||||
let hovered = null;
|
||||
for (let i = 0; i < items.length; i++) {
|
||||
if (items[i].hovered) {
|
||||
hovered = items[i]
|
||||
break
|
||||
hovered = items[i];
|
||||
break;
|
||||
}
|
||||
}
|
||||
if ( !hovered ) return
|
||||
|
||||
let currentZ = hovered.zIndex
|
||||
let maxZ = items.length - 1
|
||||
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
|
||||
items[i].zIndex += 1;
|
||||
}
|
||||
}
|
||||
hovered.zIndex = 0
|
||||
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
|
||||
items[i].zIndex = currentZ;
|
||||
break;
|
||||
}
|
||||
}
|
||||
hovered.zIndex = currentZ + 1
|
||||
hovered.zIndex = currentZ + 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user