Open image selector at selected item immediately
This commit is contained in:
@@ -17,6 +17,7 @@ ShellRoot {
|
|||||||
property bool imagesLoaded: false
|
property bool imagesLoaded: false
|
||||||
property bool opened: false
|
property bool opened: false
|
||||||
property bool showLabels: false
|
property bool showLabels: false
|
||||||
|
property bool animateSelection: true
|
||||||
property string doneFile: ""
|
property string doneFile: ""
|
||||||
property string socketPath: (Quickshell.env("XDG_RUNTIME_DIR") || ("/run/user/" + Quickshell.env("UID"))) + "/omarchy-image-selector.sock"
|
property string socketPath: (Quickshell.env("XDG_RUNTIME_DIR") || ("/run/user/" + Quickshell.env("UID"))) + "/omarchy-image-selector.sock"
|
||||||
property color accent: "#798186"
|
property color accent: "#798186"
|
||||||
@@ -53,14 +54,15 @@ ShellRoot {
|
|||||||
return name.replace(/[-_]+/g, " ").replace(/\b\w/g, function(match) { return match.toUpperCase() })
|
return name.replace(/[-_]+/g, " ").replace(/\b\w/g, function(match) { return match.toUpperCase() })
|
||||||
}
|
}
|
||||||
|
|
||||||
function select(index) {
|
function select(index, immediate) {
|
||||||
if (imageModel.count === 0) return
|
if (imageModel.count === 0) return
|
||||||
if (index < 0) index = imageModel.count - 1
|
if (index < 0) index = imageModel.count - 1
|
||||||
else if (index >= imageModel.count) index = 0
|
else if (index >= imageModel.count) index = 0
|
||||||
|
|
||||||
|
animateSelection = immediate !== true
|
||||||
selectedIndex = index
|
selectedIndex = index
|
||||||
list.currentIndex = index
|
list.currentIndex = index
|
||||||
list.centerSelected()
|
list.centerSelected(immediate === true)
|
||||||
}
|
}
|
||||||
|
|
||||||
function applySelected() {
|
function applySelected() {
|
||||||
@@ -86,7 +88,7 @@ ShellRoot {
|
|||||||
root.addImage(columns[0], columns[1])
|
root.addImage(columns[0], columns[1])
|
||||||
}
|
}
|
||||||
|
|
||||||
root.select(root.selectedImageIndex())
|
root.select(root.selectedImageIndex(), true)
|
||||||
root.imagesLoaded = true
|
root.imagesLoaded = true
|
||||||
root.opened = true
|
root.opened = true
|
||||||
list.forceActiveFocus()
|
list.forceActiveFocus()
|
||||||
@@ -263,12 +265,20 @@ ShellRoot {
|
|||||||
header: Item { width: (list.width - root.expandedWidth) / 2; height: 1 }
|
header: Item { width: (list.width - root.expandedWidth) / 2; height: 1 }
|
||||||
footer: Item { width: (list.width - root.expandedWidth) / 2; height: 1 }
|
footer: Item { width: (list.width - root.expandedWidth) / 2; height: 1 }
|
||||||
|
|
||||||
function centerSelected() {
|
function centerSelected(immediate) {
|
||||||
Qt.callLater(function() {
|
var center = function() {
|
||||||
var selectedItem = list.itemAtIndex(root.selectedIndex)
|
list.contentX = Math.max(0, root.selectedIndex * (root.sliceWidth + root.sliceSpacing))
|
||||||
if (selectedItem)
|
}
|
||||||
list.contentX = selectedItem.x + selectedItem.width / 2 - list.width / 2
|
|
||||||
})
|
if (immediate) {
|
||||||
|
center()
|
||||||
|
Qt.callLater(function() {
|
||||||
|
center()
|
||||||
|
root.animateSelection = true
|
||||||
|
})
|
||||||
|
} else {
|
||||||
|
Qt.callLater(center)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Keys.priority: Keys.BeforeItem
|
Keys.priority: Keys.BeforeItem
|
||||||
@@ -311,7 +321,10 @@ ShellRoot {
|
|||||||
readonly property real bottomRight: root.skewOffset >= 0 ? width - skAbs : width
|
readonly property real bottomRight: root.skewOffset >= 0 ? width - skAbs : width
|
||||||
readonly property real bottomLeft: root.skewOffset >= 0 ? 0 : skAbs
|
readonly property real bottomLeft: root.skewOffset >= 0 ? 0 : skAbs
|
||||||
|
|
||||||
Behavior on width { NumberAnimation { duration: 120; easing.type: Easing.OutCubic } }
|
Behavior on width {
|
||||||
|
enabled: root.animateSelection
|
||||||
|
NumberAnimation { duration: 120; easing.type: Easing.OutCubic }
|
||||||
|
}
|
||||||
|
|
||||||
Item {
|
Item {
|
||||||
id: maskShape
|
id: maskShape
|
||||||
|
|||||||
Reference in New Issue
Block a user