fix: Make showing/hiding the clock configurable #159

This commit is contained in:
meetqy 2024-03-30 10:53:39 +08:00
parent 5d45bfbfe1
commit 514abf030c
4 changed files with 28 additions and 11 deletions

View File

@ -133,9 +133,9 @@ async function UIWindowSettings(options){
h += `<div style="display: flex;align-items: center">`
h += `<span>${i18n('click_visable')}:</span>`
h += `<Select class="change-clock-visable" style="margin-left: 10px;flex: 1">`
h += `<option value="auto" selected="${window.user_preferences.clock_visable === 'auto'}">${i18n('click_visable_auto')}</option>`
h += `<option value="hide" selected="${window.user_preferences.clock_visable === 'hide'}">${i18n('click_visable_hide')}</option>`
h += `<option value="show" selected="${window.user_preferences.clock_visable === 'show'}">${i18n('click_visable_show')}</option>`
h += `<option value="auto">${i18n('click_visable_auto')}</option>`
h += `<option value="hide">${i18n('click_visable_hide')}</option>`
h += `<option value="show">${i18n('click_visable_show')}</option>`
h += `</Select>`
h += `</div>`
h += `</div>`;
@ -361,15 +361,11 @@ async function UIWindowSettings(options){
const $this = $(this);
const value = $this.val();
value === 'show' && $('#clock').show();
value === 'hide' && $('#clock').hide();
// save clock_visable to user preferences
window.mutate_user_preferences({
clock_visable: value
});
changeClockVisable(value);
})
change_clock_visable();
resolve(el_window);
});
}

View File

@ -1029,7 +1029,6 @@ async function UIDesktop(options){
}
})
}
}
$(document).on('contextmenu taphold', '.taskbar', function(event){

View File

@ -45,6 +45,9 @@ async function UITaskbar(options){
$('.desktop').append(h);
// init clock visibility
window.change_clock_visable();
//---------------------------------------------
// add `Start` to taskbar
//---------------------------------------------

View File

@ -3676,4 +3676,23 @@ window.save_desktop_item_positions = ()=>{
window.delete_desktop_item_positions = ()=>{
desktop_item_positions = {}
puter.kv.del('desktop_item_positions');
}
window.change_clock_visable = (clock_visable) => {
let newValue = clock_visable || window.user_preferences.clock_visable;
newValue === 'show' && $('#clock').show();
newValue === 'hide' && $('#clock').hide();
if(clock_visable) {
// save clock_visable to user preferences
window.mutate_user_preferences({
clock_visable: newValue
});
return;
}
$('select.change-clock-visable').val(window.user_preferences.clock_visable);
}