This commit is contained in:
Nariman Jelveh
2025-09-30 18:27:33 -07:00
parent 6429dcf15e
commit 6ee60f9c13

View File

@@ -62,16 +62,6 @@ async function UIDesktop(options) {
// Add this near the very beginning of the UIDesktop function
window.desktop_icons_hidden = false; // Set default value immediately
// Initialize the preference early
puter.kv.get('desktop_icons_hidden').then(async (val) => {
window.desktop_icons_hidden = val === 'true';
// Apply the setting immediately if needed
if (window.desktop_icons_hidden) {
hideDesktopIcons();
}
});
// Initialize toolbar auto-hide preference
window.toolbar_auto_hide_enabled = true; // Set default value
@@ -81,31 +71,6 @@ async function UIDesktop(options) {
window.toolbar_auto_hide_enabled = false;
}
// Modify the hide/show functions to use CSS rules that will apply to all icons, including future ones
window.hideDesktopIcons = function () {
// Add a CSS class to the desktop container that will hide all child icons
$('.desktop.item-container').addClass('desktop-icons-hidden');
};
window.showDesktopIcons = function () {
// Remove the CSS class to show all icons
$('.desktop.item-container').removeClass('desktop-icons-hidden');
};
// Add this function to the global scope
window.toggleDesktopIcons = function () {
window.desktop_icons_hidden = !window.desktop_icons_hidden;
if (window.desktop_icons_hidden) {
hideDesktopIcons();
} else {
showDesktopIcons();
}
// Save preference
puter.kv.set('desktop_icons_hidden', window.desktop_icons_hidden.toString());
};
// Give Camera and Recorder write permissions to Desktop
puter.kv.get('has_set_default_app_user_permissions').then(async (user_permissions) => {
if (!user_permissions) {
@@ -751,6 +716,16 @@ async function UIDesktop(options) {
// Set desktop height based on taskbar height
$('.desktop').css('height', `calc(100vh - ${window.taskbar_height + window.toolbar_height}px)`)
// Initialize the preference early
puter.kv.get('desktop_icons_hidden').then(async (val) => {
window.desktop_icons_hidden = (val === 'true' || val === true);
// Apply the setting immediately if needed
if (window.desktop_icons_hidden) {
hideDesktopIcons();
}
});
// ---------------------------------------------------------------
// Taskbar
// ---------------------------------------------------------------
@@ -2364,4 +2339,28 @@ window.reset_window_size_and_position = (el_window) => {
});
}
export default UIDesktop;
// Modify the hide/show functions to use CSS rules that will apply to all icons, including future ones
window.hideDesktopIcons = function () {
$('.desktop.item-container').addClass('desktop-icons-hidden');
};
window.showDesktopIcons = function () {
$('.desktop.item-container').removeClass('desktop-icons-hidden');
};
// Add this function to the global scope
window.toggleDesktopIcons = function () {
window.desktop_icons_hidden = !window.desktop_icons_hidden;
if (window.desktop_icons_hidden) {
hideDesktopIcons();
} else {
showDesktopIcons();
}
// Save preference
puter.kv.set('desktop_icons_hidden', window.desktop_icons_hidden.toString());
};
export default UIDesktop;