mirror of
https://github.com/noctalia-dev/noctalia-shell.git
synced 2026-05-11 17:08:27 +08:00
feat(wallpaper selector): Allow hiding or showing hidden files
This commit is contained in:
@@ -1367,6 +1367,8 @@
|
||||
"settings-folder-label": "Wallpaper folder",
|
||||
"settings-hide-wallpaper-filenames-tooltip-hide": "Hide filenames",
|
||||
"settings-hide-wallpaper-filenames-tooltip-show": "Show filenames",
|
||||
"settings-show-hidden-files-tooltip-hide": "Hide hidden files",
|
||||
"settings-show-hidden-files-tooltip-show": "Show hidden files",
|
||||
"settings-monitor-specific-description": "Set a different wallpaper folder for each monitor.",
|
||||
"settings-monitor-specific-label": "Monitor-specific directories",
|
||||
"settings-monitor-specific-tooltip": "Monitor wallpaper folder",
|
||||
|
||||
@@ -139,6 +139,7 @@
|
||||
"directory": "",
|
||||
"monitorDirectories": [],
|
||||
"enableMultiMonitorDirectories": false,
|
||||
"showHiddenFiles": false,
|
||||
"viewMode": "single",
|
||||
"setWallpaperOnAllMonitors": true,
|
||||
"fillMode": "crop",
|
||||
|
||||
@@ -342,6 +342,7 @@ Singleton {
|
||||
property string directory: ""
|
||||
property list<var> monitorDirectories: []
|
||||
property bool enableMultiMonitorDirectories: false
|
||||
property bool showHiddenFiles: false
|
||||
property string viewMode: "single" // "single" | "recursive" | "browse"
|
||||
property bool setWallpaperOnAllMonitors: true
|
||||
property string fillMode: "crop"
|
||||
|
||||
@@ -609,20 +609,20 @@ SmartPanel {
|
||||
for (var i = 0; i < directoriesList.length; i++) {
|
||||
var dirPath = directoriesList[i];
|
||||
combinedItems.push({
|
||||
"path": dirPath,
|
||||
"name": dirPath.split('/').pop(),
|
||||
"isDirectory": true
|
||||
});
|
||||
"path": dirPath,
|
||||
"name": dirPath.split('/').pop(),
|
||||
"isDirectory": true
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
// Add files
|
||||
for (var i = 0; i < wallpapersList.length; i++) {
|
||||
combinedItems.push({
|
||||
"path": wallpapersList[i],
|
||||
"name": wallpapersList[i].split('/').pop(),
|
||||
"isDirectory": false
|
||||
});
|
||||
"path": wallpapersList[i],
|
||||
"name": wallpapersList[i].split('/').pop(),
|
||||
"isDirectory": false
|
||||
});
|
||||
}
|
||||
|
||||
// Apply filter if text is present
|
||||
@@ -686,7 +686,7 @@ SmartPanel {
|
||||
var browsePath = WallpaperService.getCurrentBrowsePath(targetScreen.name);
|
||||
currentBrowsePath = browsePath;
|
||||
|
||||
WallpaperService.scanDirectoryWithDirs(targetScreen.name, browsePath, function(result) {
|
||||
WallpaperService.scanDirectoryWithDirs(targetScreen.name, browsePath, function (result) {
|
||||
wallpapersList = result.files;
|
||||
directoriesList = result.directories;
|
||||
Logger.d("WallpaperPanel", "Browse mode: Got", wallpapersList.length, "files and", directoriesList.length, "directories for screen", targetScreen.name);
|
||||
@@ -716,8 +716,10 @@ SmartPanel {
|
||||
// Helper function to get icon for current view mode
|
||||
function getViewModeIcon() {
|
||||
var mode = Settings.data.wallpaper.viewMode;
|
||||
if (mode === "single") return "folder";
|
||||
if (mode === "recursive") return "folders";
|
||||
if (mode === "single")
|
||||
return "folder";
|
||||
if (mode === "recursive")
|
||||
return "folders";
|
||||
return "folder-open";
|
||||
}
|
||||
|
||||
@@ -725,9 +727,12 @@ SmartPanel {
|
||||
function getViewModeTooltip() {
|
||||
var mode = Settings.data.wallpaper.viewMode;
|
||||
var modeName;
|
||||
if (mode === "single") modeName = I18n.tr("panels.wallpaper.view-mode-single");
|
||||
else if (mode === "recursive") modeName = I18n.tr("panels.wallpaper.view-mode-recursive");
|
||||
else modeName = I18n.tr("panels.wallpaper.view-mode-browse");
|
||||
if (mode === "single")
|
||||
modeName = I18n.tr("panels.wallpaper.view-mode-single");
|
||||
else if (mode === "recursive")
|
||||
modeName = I18n.tr("panels.wallpaper.view-mode-recursive");
|
||||
else
|
||||
modeName = I18n.tr("panels.wallpaper.view-mode-browse");
|
||||
return I18n.tr("panels.wallpaper.view-mode-cycle-tooltip").replace("{mode}", modeName);
|
||||
}
|
||||
|
||||
@@ -777,12 +782,19 @@ SmartPanel {
|
||||
}
|
||||
|
||||
NIconButton {
|
||||
icon: Settings.data.wallpaper.hideWallpaperFilenames ? "eye-closed" : "eye"
|
||||
icon: Settings.data.wallpaper.hideWallpaperFilenames ? "id-off" : "id"
|
||||
tooltipText: Settings.data.wallpaper.hideWallpaperFilenames ? I18n.tr("panels.wallpaper.settings-hide-wallpaper-filenames-tooltip-show") : I18n.tr("panels.wallpaper.settings-hide-wallpaper-filenames-tooltip-hide")
|
||||
baseSize: Style.baseWidgetSize * 0.8
|
||||
onClicked: Settings.data.wallpaper.hideWallpaperFilenames = !Settings.data.wallpaper.hideWallpaperFilenames
|
||||
}
|
||||
|
||||
NIconButton {
|
||||
icon: Settings.data.wallpaper.showHiddenFiles ? "eye" : "eye-closed"
|
||||
tooltipText: Settings.data.wallpaper.showHiddenFiles ? I18n.tr("panels.wallpaper.settings-show-hidden-files-tooltip-hide") : I18n.tr("panels.wallpaper.settings-show-hidden-files-tooltip-show")
|
||||
baseSize: Style.baseWidgetSize * 0.8
|
||||
onClicked: Settings.data.wallpaper.showHiddenFiles = !Settings.data.wallpaper.showHiddenFiles
|
||||
}
|
||||
|
||||
NIconButton {
|
||||
icon: "refresh"
|
||||
tooltipText: I18n.tr("tooltips.refresh-wallpaper-list")
|
||||
|
||||
@@ -102,6 +102,9 @@ Singleton {
|
||||
root.currentBrowsePaths = {};
|
||||
root.refreshWallpapersList();
|
||||
}
|
||||
function onShowHiddenFilesChanged() {
|
||||
root.refreshWallpapersList();
|
||||
}
|
||||
function onUseSolidColorChanged() {
|
||||
if (Settings.data.wallpaper.useSolidColor) {
|
||||
var solidPath = root.createSolidColorPath(Settings.data.wallpaper.solidColor.toString());
|
||||
@@ -494,22 +497,26 @@ Singleton {
|
||||
}
|
||||
|
||||
function setBrowsePath(screenName, path) {
|
||||
if (!screenName) return;
|
||||
if (!screenName)
|
||||
return;
|
||||
currentBrowsePaths[screenName] = path;
|
||||
browsePathChanged(screenName, path);
|
||||
}
|
||||
|
||||
function navigateUp(screenName) {
|
||||
if (!screenName) return;
|
||||
if (!screenName)
|
||||
return;
|
||||
var currentPath = getCurrentBrowsePath(screenName);
|
||||
var rootPath = getMonitorDirectory(screenName);
|
||||
|
||||
// Don't go above the root directory
|
||||
if (currentPath === rootPath) return;
|
||||
if (currentPath === rootPath)
|
||||
return;
|
||||
|
||||
// Get parent directory
|
||||
var parentPath = currentPath.replace(/\/[^\/]+\/?$/, "");
|
||||
if (parentPath === "") parentPath = "/";
|
||||
if (parentPath === "")
|
||||
parentPath = "/";
|
||||
|
||||
// Don't go above root
|
||||
if (!parentPath.startsWith(rootPath)) {
|
||||
@@ -520,7 +527,8 @@ Singleton {
|
||||
}
|
||||
|
||||
function navigateToRoot(screenName) {
|
||||
if (!screenName) return;
|
||||
if (!screenName)
|
||||
return;
|
||||
var rootPath = getMonitorDirectory(screenName);
|
||||
setBrowsePath(screenName, rootPath);
|
||||
}
|
||||
@@ -529,11 +537,17 @@ Singleton {
|
||||
// callback receives { files: [], directories: [] }
|
||||
function scanDirectoryWithDirs(screenName, directory, callback) {
|
||||
if (!directory || directory === "") {
|
||||
callback({ files: [], directories: [] });
|
||||
callback({
|
||||
files: [],
|
||||
directories: []
|
||||
});
|
||||
return;
|
||||
}
|
||||
|
||||
var result = { files: [], directories: [] };
|
||||
var result = {
|
||||
files: [],
|
||||
directories: []
|
||||
};
|
||||
var pendingScans = 2;
|
||||
|
||||
function checkComplete() {
|
||||
@@ -547,13 +561,13 @@ Singleton {
|
||||
}
|
||||
|
||||
// Scan for files
|
||||
_scanDirectoryInternal(screenName, directory, false, false, function(files) {
|
||||
_scanDirectoryInternal(screenName, directory, false, false, function (files) {
|
||||
result.files = files;
|
||||
checkComplete();
|
||||
});
|
||||
|
||||
// Scan for directories
|
||||
_scanForDirectories(directory, function(dirs) {
|
||||
_scanForDirectories(directory, function (dirs) {
|
||||
result.directories = dirs;
|
||||
checkComplete();
|
||||
});
|
||||
@@ -575,14 +589,18 @@ Singleton {
|
||||
|
||||
var processObject = Qt.createQmlObject(processString, root, "DirScan");
|
||||
|
||||
processObject.exited.connect(function(exitCode) {
|
||||
processObject.exited.connect(function (exitCode) {
|
||||
var dirs = [];
|
||||
if (exitCode === 0) {
|
||||
var lines = processObject.stdout.text.split('\n');
|
||||
for (var i = 0; i < lines.length; i++) {
|
||||
var line = lines[i].trim();
|
||||
if (line !== '') {
|
||||
dirs.push(line);
|
||||
var showHidden = Settings.data.wallpaper.showHiddenFiles;
|
||||
var name = line.split('/').pop();
|
||||
if (showHidden || !name.startsWith('.')) {
|
||||
dirs.push(line);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -636,7 +654,8 @@ Singleton {
|
||||
wallpaperLists[screenName] = [];
|
||||
wallpaperListChanged(screenName, 0);
|
||||
}
|
||||
if (callback) callback([]);
|
||||
if (callback)
|
||||
callback([]);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -646,10 +665,12 @@ Singleton {
|
||||
recursiveProcesses[screenName].running = false;
|
||||
recursiveProcesses[screenName].destroy();
|
||||
delete recursiveProcesses[screenName];
|
||||
if (updateList) scanningCount--;
|
||||
if (updateList)
|
||||
scanningCount--;
|
||||
}
|
||||
|
||||
if (updateList) scanningCount++;
|
||||
if (updateList)
|
||||
scanningCount++;
|
||||
Logger.i("Wallpaper", "Starting scan for", screenName, "in", directory, "recursive:", recursive);
|
||||
|
||||
// Build find command args dynamically from ImageCacheService filters
|
||||
@@ -690,8 +711,9 @@ Singleton {
|
||||
recursiveProcesses[screenName] = processObject;
|
||||
}
|
||||
|
||||
var handler = function(exitCode) {
|
||||
if (updateList) scanningCount--;
|
||||
var handler = function (exitCode) {
|
||||
if (updateList)
|
||||
scanningCount--;
|
||||
Logger.d("Wallpaper", "Process exited with code", exitCode, "for", screenName);
|
||||
|
||||
var files = [];
|
||||
@@ -700,7 +722,11 @@ Singleton {
|
||||
for (var i = 0; i < lines.length; i++) {
|
||||
var line = lines[i].trim();
|
||||
if (line !== '') {
|
||||
files.push(line);
|
||||
var showHidden = Settings.data.wallpaper.showHiddenFiles;
|
||||
var name = line.split('/').pop();
|
||||
if (showHidden || !name.startsWith('.')) {
|
||||
files.push(line);
|
||||
}
|
||||
}
|
||||
}
|
||||
// Sort files for consistent ordering
|
||||
@@ -735,7 +761,8 @@ Singleton {
|
||||
delete recursiveProcesses[screenName];
|
||||
}
|
||||
|
||||
if (callback) callback(files);
|
||||
if (callback)
|
||||
callback(files);
|
||||
processObject.destroy();
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user