mirror of
https://github.com/end-4/dots-hyprland.git
synced 2026-06-05 23:09:26 -05:00
wallpaper selector: not reinvent MouseArea containsMouse
This commit is contained in:
@@ -10,12 +10,11 @@ import Qt5Compat.GraphicalEffects
|
||||
import Quickshell
|
||||
import Quickshell.Io
|
||||
|
||||
Item {
|
||||
MouseArea {
|
||||
id: root
|
||||
required property var fileModelData
|
||||
property bool isDirectory: fileModelData.fileIsDir
|
||||
property bool useThumbnail: Images.isValidImageByName(fileModelData.fileName)
|
||||
property bool isHovered: false
|
||||
|
||||
property alias colBackground: background.color
|
||||
property alias colText: wallpaperItemName.color
|
||||
@@ -24,6 +23,9 @@ Item {
|
||||
|
||||
signal activated
|
||||
|
||||
hoverEnabled: true
|
||||
onClicked: root.activated()
|
||||
|
||||
Rectangle {
|
||||
id: background
|
||||
anchors {
|
||||
@@ -130,23 +132,4 @@ Item {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
MouseArea {
|
||||
anchors.fill: parent
|
||||
hoverEnabled: true
|
||||
onEntered: {
|
||||
for (let i = 0; i < grid.count; i++) {
|
||||
const item = grid.itemAtIndex(i);
|
||||
if (item && item !== parent) {
|
||||
item.isHovered = false;
|
||||
}
|
||||
}
|
||||
parent.isHovered = true;
|
||||
grid.currentIndex = index;
|
||||
}
|
||||
onExited: {
|
||||
parent.isHovered = false;
|
||||
}
|
||||
onClicked: root.activated()
|
||||
}
|
||||
}
|
||||
|
||||
@@ -209,12 +209,6 @@ Item {
|
||||
}
|
||||
|
||||
function moveSelection(delta) {
|
||||
for (let i = 0; i < count; i++) {
|
||||
const item = itemAtIndex(i);
|
||||
if (item) {
|
||||
item.isHovered = false;
|
||||
}
|
||||
}
|
||||
currentIndex = Math.max(0, Math.min(grid.model.count - 1, currentIndex + delta));
|
||||
positionViewAtIndex(currentIndex, GridView.Contain);
|
||||
}
|
||||
@@ -234,11 +228,15 @@ Item {
|
||||
fileModelData: modelData
|
||||
width: grid.cellWidth
|
||||
height: grid.cellHeight
|
||||
colBackground: (index === grid?.currentIndex || parent?.isHovered) ? Appearance.colors.colPrimaryContainer : ColorUtils.transparentize(Appearance.colors.colPrimaryContainer)
|
||||
colText: (index === grid.currentIndex || parent.isHovered) ? Appearance.colors.colPrimary : Appearance.colors.colOnLayer0
|
||||
colBackground: (index === grid?.currentIndex || containsMouse) ? Appearance.colors.colPrimaryContainer : ColorUtils.transparentize(Appearance.colors.colPrimaryContainer)
|
||||
colText: (index === grid.currentIndex || containsMouse) ? Appearance.colors.colPrimary : Appearance.colors.colOnLayer0
|
||||
|
||||
onEntered: {
|
||||
grid.currentIndex = index;
|
||||
}
|
||||
|
||||
onActivated: {
|
||||
Wallpapers.select(fileModelData.filePath, root.useDarkMode);
|
||||
|
||||
filterField.text = "";
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user