Compare commits
62 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| ce1a48639f | |||
| 4d19cfe87d | |||
| cd5eb171c8 | |||
| 0ff5c32c51 | |||
| 7e3109f758 | |||
| f5a0b763d5 | |||
| 4f813a2de7 | |||
| 7784cfd99b | |||
| 7e5b5ffed5 | |||
| 3f969d9447 | |||
| b68c139d8d | |||
| 175c3463f7 | |||
| d446be5fbd | |||
| e31ff0aa27 | |||
| a0b552e796 | |||
| b9a590be69 | |||
| 16642e7d02 | |||
| b8d825843d | |||
| 62027782a7 | |||
| 7d8037a82c | |||
| cf55c79855 | |||
| e9fab71e9d | |||
| 5318d3897b | |||
| 8967e3a1f5 | |||
| 089a5f7a49 | |||
| 4acc1556b2 | |||
| 9dd1a5430d | |||
| dbcde131aa | |||
| 2f8a3e98a5 | |||
| 03adbbd38f | |||
| bdccb9e0aa | |||
| 010643ee23 | |||
| 7fa9f85856 | |||
| 1a39b63b20 | |||
| da07682764 | |||
| b20768f64c | |||
| 2663d706b8 | |||
| c57e90d65e | |||
| cbd67c3c34 | |||
| 09d5484f52 | |||
| fc737d6edc | |||
| 7c67b41a7b | |||
| 2b16c6a612 | |||
| c6277a4a2a | |||
| ab2b3ce0a8 | |||
| 1d70410331 | |||
| 49c49e2e90 | |||
| 5dad7c0769 | |||
| 319a8ce00f | |||
| 74692b2b97 | |||
| 35522f5c3c | |||
| 5d0272b9bd | |||
| f2ac47cd88 | |||
| e7f2e43e52 | |||
| 0718d25887 | |||
| 52bc58da18 | |||
| 6911476077 | |||
| 270a7c0e4e | |||
| ae32389764 | |||
| 89962477c0 | |||
| ca365460af | |||
| e7cebf3092 |
@@ -0,0 +1,4 @@
|
|||||||
|
# Generated by Cargo
|
||||||
|
# will have compiled files and executables
|
||||||
|
debug
|
||||||
|
target
|
||||||
Binary file not shown.
|
After Width: | Height: | Size: 294 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 294 KiB |
Binary file not shown.
|
Before Width: | Height: | Size: 298 KiB |
@@ -0,0 +1,56 @@
|
|||||||
|
pragma Singleton
|
||||||
|
|
||||||
|
import QtQuick
|
||||||
|
import Quickshell.Io
|
||||||
|
import Quickshell
|
||||||
|
|
||||||
|
Singleton {
|
||||||
|
id: root
|
||||||
|
|
||||||
|
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
|
||||||
|
|
||||||
|
command: ["test", "-d", root.configDir]
|
||||||
|
running: true
|
||||||
|
|
||||||
|
onExited: function (exitCode) {
|
||||||
|
if (exitCode !== 0) {
|
||||||
|
console.log("creating dir");
|
||||||
|
dirCreate.running = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Process {
|
||||||
|
id: dirCreate
|
||||||
|
|
||||||
|
command: ["mkdir", "-p", root.configDir]
|
||||||
|
running: false
|
||||||
|
|
||||||
|
onExited: function (): void {
|
||||||
|
console.log("Created config directory:", root.configDir);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
FileView {
|
||||||
|
id: watcher
|
||||||
|
|
||||||
|
path: root.configPath
|
||||||
|
watchChanges: true
|
||||||
|
|
||||||
|
onAdapterUpdated: writeAdapter()
|
||||||
|
onFileChanged: reload()
|
||||||
|
|
||||||
|
JsonAdapter {
|
||||||
|
id: adapter
|
||||||
|
|
||||||
|
property string gifFolder: Quickshell.shellDir + "/Gifs"
|
||||||
|
property real maxScale: 1
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,20 @@
|
|||||||
|
import QtQuick
|
||||||
|
import Qt.labs.folderlistmodel
|
||||||
|
|
||||||
|
Item {
|
||||||
|
id: root
|
||||||
|
|
||||||
|
property alias count: folderModel.count
|
||||||
|
required property string gifFolder
|
||||||
|
property alias gifsModel: folderModel
|
||||||
|
|
||||||
|
FolderListModel {
|
||||||
|
id: folderModel
|
||||||
|
|
||||||
|
folder: "file://" + root.gifFolder
|
||||||
|
nameFilters: ["*.gif"]
|
||||||
|
showDirs: false
|
||||||
|
showHidden: false
|
||||||
|
sortField: FolderListModel.Name
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,88 @@
|
|||||||
|
pragma ComponentBehavior: Bound
|
||||||
|
|
||||||
|
import QtQuick
|
||||||
|
import Quickshell
|
||||||
|
import Quickshell.Io
|
||||||
|
import Qt.labs.folderlistmodel
|
||||||
|
import qs.Modules
|
||||||
|
|
||||||
|
Repeater {
|
||||||
|
id: gifRepeater
|
||||||
|
|
||||||
|
required property FolderListModel gifsModel
|
||||||
|
|
||||||
|
model: gifsModel
|
||||||
|
|
||||||
|
Item {
|
||||||
|
id: gifItem
|
||||||
|
|
||||||
|
required property string fileBaseName
|
||||||
|
required property url fileUrl
|
||||||
|
property alias hovered: mouse.containsMouse
|
||||||
|
required property int index
|
||||||
|
property bool loaded: false
|
||||||
|
property alias zIndex: gifSaved.zIndex
|
||||||
|
|
||||||
|
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
|
||||||
|
|
||||||
|
anchors.fill: parent
|
||||||
|
fillMode: Image.PreserveAspectFit
|
||||||
|
source: gifItem.fileUrl
|
||||||
|
}
|
||||||
|
|
||||||
|
Mouse {
|
||||||
|
id: mouse
|
||||||
|
|
||||||
|
onDoubleClicked: gifSaved.scaling = 1
|
||||||
|
onWheel: wheel => {
|
||||||
|
gifSaved.scaling = Math.max(ConfigLoader.maxScaling, (gifSaved.scaling + 0.1 * (wheel.angleDelta.y / 120)));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
FileView {
|
||||||
|
id: watcher
|
||||||
|
|
||||||
|
property string configDir: Quickshell.env("HOME") + "/.config/I-DeskPet/"
|
||||||
|
property string configPath: configDir + name
|
||||||
|
property string name: gifItem.fileBaseName + ".json"
|
||||||
|
|
||||||
|
path: configPath
|
||||||
|
watchChanges: true
|
||||||
|
|
||||||
|
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 int positionX: 0
|
||||||
|
property int positionY: 0
|
||||||
|
property real scaling: 1
|
||||||
|
property int zIndex: -1
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,13 @@
|
|||||||
|
import QtQuick
|
||||||
|
|
||||||
|
MouseArea {
|
||||||
|
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
|
||||||
|
}
|
||||||
@@ -1 +1,63 @@
|
|||||||
### Pet March (Evernight)
|
<div align="Center">
|
||||||
|
<h3> Pet March (Evernight) </h3>
|
||||||
|
<p>My selfmade desktop pet using QT </p>
|
||||||
|
<img src=./Assets/Evernight.gif style="margin: 0px 30px 0px 0px;" />
|
||||||
|
</div>
|
||||||
|
|
||||||
|
## Feature list
|
||||||
|
|
||||||
|
- [x] Hyprland keybind support
|
||||||
|
- [x] Toggle layer ontop/bottom
|
||||||
|
- [x] Toggle active mouse area
|
||||||
|
- [x] Dynamic path + live update
|
||||||
|
- [x] Supports multiple gifs
|
||||||
|
- [x] User config options
|
||||||
|
- [x] Evernight base gif img
|
||||||
|
|
||||||
|
# Config
|
||||||
|
|
||||||
|
Configuration is found at:
|
||||||
|
|
||||||
|
```zsh
|
||||||
|
~/.config/I-DeskPet
|
||||||
|
```
|
||||||
|
|
||||||
|
Options:
|
||||||
|
|
||||||
|
- gifFolder
|
||||||
|
- maxScaling
|
||||||
|
|
||||||
|
Example for config.json:
|
||||||
|
|
||||||
|
```json
|
||||||
|
{
|
||||||
|
"gifFolder": "/home/inorishio/Pictures/Pets",
|
||||||
|
"maxScaling": 1
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
# Hyprland keybinds
|
||||||
|
|
||||||
|
Toggle click through
|
||||||
|
|
||||||
|
```zsh
|
||||||
|
bind = CTRL, mouse:274, global, I-DeskPet:toggle-Region
|
||||||
|
```
|
||||||
|
|
||||||
|
Toggle between having your gif on your background vs foreground
|
||||||
|
|
||||||
|
```zsh
|
||||||
|
bind = SHIFT, mouse:274, global, I-DeskPet:toggle-Layer
|
||||||
|
```
|
||||||
|
|
||||||
|
Keybind for cycling through gif layering.
|
||||||
|
Hover over which gif you want to cycle it's layer for and use the keybind.
|
||||||
|
|
||||||
|
```zsh
|
||||||
|
bind = $mainMod, Z, global, I-DeskPet:cycle-zIndex
|
||||||
|
```
|
||||||
|
|
||||||
|
# Other keybinds
|
||||||
|
|
||||||
|
- Double click = Reset gif size to original
|
||||||
|
- Scroll = Scales the gif up and or down
|
||||||
|
|||||||
@@ -1,56 +1,183 @@
|
|||||||
pragma ComponentBehavior: Bound
|
pragma ComponentBehavior: Bound
|
||||||
|
|
||||||
import QtQuick
|
import QtQuick
|
||||||
import Quickshell
|
import Quickshell
|
||||||
|
import Quickshell.Io
|
||||||
import Quickshell.Wayland
|
import Quickshell.Wayland
|
||||||
//import qs.Gifs
|
import Quickshell.Hyprland
|
||||||
|
import qs.Modules
|
||||||
|
|
||||||
PanelWindow {
|
PanelWindow {
|
||||||
id: mainWindow
|
id: mainWindow
|
||||||
WlrLayershell.layer: WlrLayer.Top
|
|
||||||
color: "transparent"
|
|
||||||
anchors {
|
|
||||||
bottom: true
|
|
||||||
left: true
|
|
||||||
}
|
|
||||||
surfaceFormat.opaque: false
|
|
||||||
implicitWidth: 320
|
|
||||||
implicitHeight: 293
|
|
||||||
margins {
|
|
||||||
left: 0
|
|
||||||
bottom: 5
|
|
||||||
}
|
|
||||||
|
|
||||||
property bool onTop: true
|
property var noMove: Region {
|
||||||
|
}
|
||||||
|
property bool onTop: true
|
||||||
|
property var petMove: Region {
|
||||||
|
id: pets
|
||||||
|
|
||||||
function toggleLayer() {
|
height: Screen.height
|
||||||
if (onTop) {
|
intersection: Intersection.Xor
|
||||||
WlrLayershell.layer = WlrLayer.Bottom
|
regions: maskVariants.instances
|
||||||
onTop = false
|
width: Screen.width
|
||||||
} else {
|
}
|
||||||
WlrLayershell.layer = WlrLayer.Top
|
property list<Item> repeaterItems: []
|
||||||
onTop = true
|
property bool setMask: true
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
Rectangle {
|
function petRegion(itemObject) {
|
||||||
anchors.fill: parent
|
let newregion = regionComponent.createObject(pets, {
|
||||||
color: "transparent"
|
"item": itemObject
|
||||||
|
});
|
||||||
|
pets.regions.push(newregion);
|
||||||
|
}
|
||||||
|
|
||||||
id: petContainer
|
WlrLayershell.exclusionMode: ExclusionMode.Ignore
|
||||||
AnimatedImage {
|
WlrLayershell.layer: WlrLayer.Overlay
|
||||||
anchors.fill: parent
|
WlrLayershell.namespace: "I-DeskPet"
|
||||||
source: "Gifs/evernight.gif"
|
color: "transparent"
|
||||||
fillMode: Image.PreserveAspectFit
|
surfaceFormat.opaque: false
|
||||||
}
|
|
||||||
|
|
||||||
MouseArea {
|
mask: Region {
|
||||||
anchors.fill: parent
|
height: Screen.height
|
||||||
acceptedButtons: Qt.MiddleButton
|
intersection: Intersection.Xor
|
||||||
onClicked: (mouse) => {
|
regions: maskVariants.instances
|
||||||
if (mouse.button === Qt.MiddleButton) {
|
width: Screen.width
|
||||||
mainWindow.toggleLayer()
|
}
|
||||||
}
|
|
||||||
}
|
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) {
|
||||||
|
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
|
||||||
|
|
||||||
|
height: modelData.height
|
||||||
|
intersection: Intersection.Subtract
|
||||||
|
width: modelData.width
|
||||||
|
x: modelData.x
|
||||||
|
y: modelData.y
|
||||||
|
|
||||||
|
Component.onCompleted: {
|
||||||
|
console.log(modelData);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Component {
|
||||||
|
id: regionComponent
|
||||||
|
|
||||||
|
Region {
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
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