zach's nutty qmlformat
This commit is contained in:
+20
-19
@@ -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 ]
|
||||
|
||||
onExited: function( exitCode ) {
|
||||
if ( exitCode !== 0 ) {
|
||||
console.log( "creating dir" )
|
||||
dirCreate.running = true
|
||||
command: ["test", "-d", root.configDir]
|
||||
running: true
|
||||
|
||||
onExited: function (exitCode) {
|
||||
if (exitCode !== 0) {
|
||||
console.log("creating dir");
|
||||
dirCreate.running = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Process {
|
||||
id: dirCreate
|
||||
running: false
|
||||
command: [ "mkdir", "-p", root.configDir ]
|
||||
|
||||
onExited: function(): void {
|
||||
console.log( "Created config directory:", root.configDir )
|
||||
command: ["mkdir", "-p", root.configDir]
|
||||
running: false
|
||||
|
||||
onExited: function (): void {
|
||||
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 string gifFolder: Quickshell.shellDir + "/Gifs"
|
||||
property real maxScale: 1
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+4
-3
@@ -3,15 +3,16 @@ 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" ]
|
||||
nameFilters: ["*.gif"]
|
||||
showDirs: false
|
||||
showHidden: false
|
||||
sortField: FolderListModel.Name
|
||||
|
||||
+44
-40
@@ -7,78 +7,82 @@ import Qt.labs.folderlistmodel
|
||||
import qs.Modules
|
||||
|
||||
Repeater {
|
||||
id: gifRepeater
|
||||
required property FolderListModel gifsModel
|
||||
id: gifRepeater
|
||||
|
||||
model: gifsModel
|
||||
Item {
|
||||
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
|
||||
height: Math.floor(gif.sourceSize.height / gifSaved.scaling)
|
||||
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 )
|
||||
width: Math.floor(gif.sourceSize.width / gifSaved.scaling)
|
||||
z: gifSaved.zIndex
|
||||
|
||||
AnimatedImage {
|
||||
id: gif
|
||||
source: gifItem.fileUrl
|
||||
fillMode: Image.PreserveAspectFit
|
||||
anchors.fill: parent
|
||||
}
|
||||
onXChanged: if (gifItem.loaded)
|
||||
gifSaved.positionX = gifItem.x
|
||||
onYChanged: if (gifItem.loaded)
|
||||
gifSaved.positionY = gifItem.y
|
||||
|
||||
AnimatedImage {
|
||||
id: gif
|
||||
|
||||
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
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+9
-9
@@ -1,13 +1,13 @@
|
||||
import QtQuick
|
||||
|
||||
MouseArea {
|
||||
anchors.fill: parent
|
||||
acceptedButtons: Qt.LeftButton
|
||||
hoverEnabled: true
|
||||
drag.target: parent
|
||||
drag.axis: Drag.XAndYAxis
|
||||
drag.minimumX: 0
|
||||
drag.maximumX: Screen.width - parent.width
|
||||
drag.minimumY: 0
|
||||
drag.maximumY: Screen.height - parent.height
|
||||
acceptedButtons: Qt.LeftButton
|
||||
anchors.fill: parent
|
||||
drag.axis: Drag.XAndYAxis
|
||||
drag.maximumX: Screen.width - parent.width
|
||||
drag.maximumY: Screen.height - parent.height
|
||||
drag.minimumX: 0
|
||||
drag.minimumY: 0
|
||||
drag.target: parent
|
||||
hoverEnabled: true
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user