Add button to select settings profile in title bar

This commit is contained in:
JannisX11 2023-01-11 17:49:17 +01:00
parent 214cfcf3d3
commit 28090ee1af
3 changed files with 54 additions and 0 deletions

View File

@ -333,6 +333,17 @@
header .tool .icon {
font-size: 20px;
}
#settings_profiles_header_menu {
width: 24px;
text-align: center;
padding-top: 2px;
margin-right: 4px;
opacity: 0.9;
}
#settings_profiles_header_menu:hover {
opacity: 1.0;
color: var(--color-light);
}
/*Mobile*/
body.is_mobile #page_wrapper {

View File

@ -199,6 +199,9 @@
</div>
<div class="app-drag-region" id="header_free_bar"></div>
<div id="update_menu"></div>
<div id="settings_profiles_header_menu" class="hidden">
<i class="material-icons">settings_applications</i>
</div>
<ul id="windows_window_menu" hidden>
<li onclick="currentwindow.minimize()"><i class="material-icons" style="margin-top: 4px;">remove</i></li>
<li onclick="currentwindow.isMaximized() ? currentwindow.unmaximize() : currentwindow.maximize()"><i class="material-icons">crop_square</i><!--🗖--></li>

View File

@ -209,6 +209,7 @@ class SettingsProfile {
if (update) {
Settings.updateSettingsInProfiles();
Settings.saveLocalStorages();
Settings.updateProfileButton();
}
}
extend(data) {
@ -296,6 +297,7 @@ class SettingsProfile {
if (confirm('settings_profile.confirm_delete'))
this.remove();
Settings.dialog.content_vue.profile = null;
SettingsProfile.unselect();
dialog.close();
}}
},
@ -306,6 +308,10 @@ class SettingsProfile {
if (this.condition.type == 'format') this.condition.value = result.format;
if (this.condition.type == 'file_path') this.condition.value = result.file_path;
Settings.saveLocalStorages();
Settings.updateProfileButton();
},
onCancel() {
Settings.updateProfileButton();
}
}).show();
}
@ -322,6 +328,7 @@ SettingsProfile.unselect = function(update = true) {
if (update) {
Settings.updateSettingsInProfiles();
Settings.saveLocalStorages();
Settings.updateProfileButton();
}
}
@ -525,6 +532,33 @@ const Settings = {
if (profile.selected) new_profile.select(false);
})
}
Settings.profile_menu_button = document.getElementById('settings_profiles_header_menu');
Settings.profile_menu_button.addEventListener('click', event => {
let list = [
{
name: 'generic.none',
icon: SettingsProfile.selected ? 'radio_button_unchecked' : 'radio_button_checked',
click: () => {
SettingsProfile.unselect();
}
},
'_'
];
SettingsProfile.all.forEach(profile => {
if (profile.condition.type != 'selectable') return;
list.push({
name: profile.name,
icon: profile.selected ? 'radio_button_checked' : 'radio_button_unchecked',
color: markerColors[profile.color].standard,
click: () => {
profile.select();
}
})
})
new Menu(list).open(Settings.profile_menu_button);
});
Settings.profile_menu_button.setAttribute('title', tl('data.settings_profile'))
Settings.updateProfileButton();
},
addCategory(id, data = {}) {
Settings.structure[id] = {
@ -584,6 +618,7 @@ const Settings = {
ipcRenderer.send('edit-launch-setting', {key: id, value: setting.value})
}
}
Settings.updateProfileButton();
Blockbench.dispatchEvent('update_settings');
},
updateSettingsInProfiles() {
@ -598,6 +633,11 @@ const Settings = {
if (setting.onChange) setting.onChange(setting.value);
})
},
updateProfileButton() {
let profile = SettingsProfile.selected;
Settings.profile_menu_button.style.color = profile ? markerColors[profile.color].standard : '';
Settings.profile_menu_button.classList.toggle('hidden', SettingsProfile.all.findIndex(p => p.condition.type == 'selectable') == -1);
},
import(file) {
let data = JSON.parse(file.content);
for (let key in settings) {