wallpaper selector: fix dark mode

This commit is contained in:
end-4
2025-08-24 14:25:39 +07:00
parent 8bbf040100
commit 8277a2d942
4 changed files with 21 additions and 52 deletions
@@ -16,10 +16,9 @@ Image {
if (!fileModelData.fileIsDir)
return Quickshell.iconPath("application-x-zerosize");
const name = fileModelData.fileName;
const homeDir = Directories.home
if ([Directories.documents, Directories.downloads, Directories.music, Directories.pictures, Directories.videos].includes(name))
return Quickshell.iconPath(`folder-${name.toLowerCase()}`);
if ([Directories.documents, Directories.downloads, Directories.music, Directories.pictures, Directories.videos].includes(fileModelData.filePath))
return Quickshell.iconPath(`folder-${fileModelData.fileName.toLowerCase()}`);
return Quickshell.iconPath("inode-directory");
}
@@ -17,7 +17,8 @@ Item {
property bool useThumbnail: Images.isValidImageByName(fileModelData.fileName)
property bool isHovered: false
property alias color: background.color
property alias colBackground: background.color
property alias colText: wallpaperItemName.color
property alias radius: background.radius
property alias padding: background.anchors.margins
@@ -122,7 +123,6 @@ Item {
horizontalAlignment: Text.AlignHCenter
elide: Text.ElideRight
font.pixelSize: Appearance.font.pixelSize.smaller
color: (index === grid.currentIndex || parent.isHovered) ? Appearance.colors.colOnPrimary : Appearance.colors.colOnLayer0
Behavior on color {
animation: Appearance.animation.elementMoveFast.colorAnimation.createObject(this)
}
@@ -116,46 +116,14 @@ Item {
implicitWidth: 140
clip: true
model: [
{
icon: "home",
name: "Home",
path: Directories.home
},
{
icon: "folder",
name: "Documents",
path: Directories.documents
},
{
icon: "download",
name: "Downloads",
path: Directories.downloads
},
{
icon: "image",
name: "Pictures",
path: Directories.pictures
},
{
icon: "movie",
name: "Videos",
path: Directories.videos
},
{
icon: "",
name: "---",
path: "INTENTIONALLY_INVALID_DIR"
},
{
icon: "wallpaper",
name: "Wallpapers",
path: `${Directories.pictures}/Wallpapers`
},
{
icon: "favorite",
name: "Homework",
path: `${Directories.pictures}/homework`
},
{ icon: "home", name: "Home", path: Directories.home },
{ icon: "docs", name: "Documents", path: Directories.documents },
{ icon: "download", name: "Downloads", path: Directories.downloads },
{ icon: "image", name: "Pictures", path: Directories.pictures },
{ icon: "movie", name: "Videos", path: Directories.videos },
{ icon: "", name: "---", path: "INTENTIONALLY_INVALID_DIR" },
{ icon: "wallpaper", name: "Wallpapers", path: `${Directories.pictures}/Wallpapers` },
{ icon: "favorite", name: "Homework", path: `${Directories.pictures}/homework` },
]
delegate: RippleButton {
id: quickDirButton
@@ -266,7 +234,8 @@ Item {
fileModelData: modelData
width: grid.cellWidth
height: grid.cellHeight
color: (index === grid?.currentIndex || parent?.isHovered) ? Appearance.colors.colPrimary : ColorUtils.transparentize(Appearance.colors.colPrimary)
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
onActivated: {
Wallpapers.select(fileModelData.filePath, root.useDarkMode);
@@ -314,7 +283,7 @@ Item {
implicitWidth: height
buttonRadius: Appearance.rounding.full
onClicked: {
Wallpapers.openFallbackPicker();
Wallpapers.openFallbackPicker(root.useDarkMode);
GlobalStates.wallpaperSelectorOpen = false;
}
contentItem: MaterialSymbol {
@@ -370,12 +339,10 @@ Item {
// No filtering, just navigate grid
if (event.key === Qt.Key_Down) {
grid.moveSelection(grid.columns);
wallpaperGrid.forceActiveFocus();
event.accepted = true;
}
if (event.key === Qt.Key_Up) {
grid.moveSelection(-grid.columns);
wallpaperGrid.forceActiveFocus();
event.accepted = true;
}
}
@@ -29,8 +29,11 @@ Singleton {
id: applyProc
}
function openFallbackPicker() {
applyProc.exec([Directories.wallpaperSwitchScriptPath])
function openFallbackPicker(darkMode = Appearance.m3colors.darkmode) {
applyProc.exec([
Directories.wallpaperSwitchScriptPath,
"--mode", (darkMode ? "dark" : "light")
])
}
function apply(path, darkMode = Appearance.m3colors.darkmode) {
@@ -62,7 +65,7 @@ Singleton {
}
function select(filePath, darkMode = Appearance.m3colors.darkmode) {
selectProc.select(filePath);
selectProc.select(filePath, darkMode);
}
Process {