Closed regorxxx closed 1 year ago
Once I get the basics, we can go fancy with a popup showing the current rows and asking which row to edit, etc.
It's in gr-callbacks.js -> metadata grid will be rebuild from function on_metadb_changed(handle_list, fromhook) {
str.grid = [];
for (let k = 0; k < metadataGrid.length; k++) {
let val = $(metadataGrid[k].val);
if (val && metadataGrid[k].label) {
if (metadataGrid[k].age) {
val = $('$date(' + val + ')'); // Never show time
const age = calcAgeDateString(val);
if (age) {
val += ` (${age})`;
}
}
str.grid.push({
age: metadataGrid[k].age,
label: metadataGrid[k].label,
val
});
}
}
And there is also a function clearUIVariables() {
which clears all, used for example on_playback_stop or in initMain()
// * Note: These settings will
Almost all settings are saved but some not:
"title_format_strings": {
"themeStyleCustom": {
"themeCustomFont": {
"metadataGrid": [
"settings": {
These are not saved and only for manual edits, that means user need to manually open the config file and modify them themselves. All others settings will be saved automatically to the config file via top menu Options > Settings > Theme configuration > Save settings to config file -> setThemeSettings(true)
The configuration file is defined via gr-configuration.js with settings from
gr-defaults.js ( const defaultMetadataGrid = [
)
and gr-settings.js ( Line 1180 ).
There is also this in gr-settings: config.addConfigurationObject(gridSchema, prefs.metadataGrid); // Can't Object.assign here to add new fields. Add new fields in the upgrade section of migrateCheck
function migrateCheck(version, storedVersion) {
/**
* Adds or Replaces value in the grid with updated string from defaults
* @param {MetadataGridEntry[]} grid
* @param {string} label Label of the value to add or replace
* @param {number} position 0-based index of place to insert new value if existing entry not found
*/
const replaceGridEntry = (grid, label, position) => {
const entryIdx = grid.findIndex(gridEntry => gridEntry && gridEntry.label.toLowerCase() === label.toLowerCase());
const newVal = defaultMetadataGrid[defaultMetadataGrid.findIndex(e => e && e.label.toLowerCase() === label.toLowerCase())];
if (entryIdx >= 0) {
grid[entryIdx] = newVal;
} else {
grid.splice(position, 0, newVal);
}
};
if (version !== storedVersion) {
const configFile = config.readConfiguration();
/** @type {MetadataGridEntry[]} */
const grid = configFile.metadataGrid;
// This function clears default values which have changed
switch (storedVersion) {
case '2.0.3':
default:
break;
}
}
pref.version = currentVersion; // Always update the version panel property
}
That would be it. Mordred is using the migrateCheck function for updates, that means when he releases a new update on Github it will be triggered and it should update also the config file. When a new version is released, there will be a hyperlink in the lowerbar. This will link to the releases page on Github. Never tried it myself because I don't have the public release yet on Github ;)
I have stripped it down, but original it looks like this: https://github.com/kbuffington/Georgia/blob/11d434e6e0882810a5cff7522c395c71557b85a2/js/settings.js#L200
Hope that helps and thanks for your help!
-Tom
Uhm... 1) solved. I refactored code.
So on on_metadb_changed is reused with lp value.
And the same on the menu, not needing to process all again.
The second took me some time, since I kept using the method without the file reflecting the changes XD (and no error being thrown). Not sure why Mordred did not add an update method for arrays anyway.
So fixed that... just in case this is not the last time another array config gets the same treatment. gr-configuration.js
And throws a popup in case you fuck up mixing config value types.
Good work and thanks @regorxxx, tried it out and it works as it should =) Sorry I didn't warn you about how the configuration system works ;)
But we should add a guard if the user types invalid stuff ( delete all and type random stuff in the input ) in the pattern:
Error: Spider Monkey Panel v1.6.2-dev+7c0928bf ({04620F16-1878-47A1-8EFE-0CE0B99566CC}: Georgia-ReBORN v2.3.0 by TT)
newVal.filter is not a function
File: gr-menu.js
Line: 1797, Column: 34
Stack trace:
detailsOptions/<@gr-menu.js:1797:34
doCallback@gr-helpers.js:1537:23
onOptionsMenu@gr-menu.js:87:7
append_albumCover_context_menu_to/<@Control_ContextMenu.js:565:7
execute_menu@Control_ContextMenu.js:285:8
execute_menu@Control_ContextMenu.js:199:17
execute@Control_ContextMenu.js:419:15
on_mouse_rbtn_up@gr-callbacks.js:2679:9
I'm refactoring the top menu button code atm, because otherwise other devs would lose their mind how frustrating that shit is ;)
-Tom
My bad, obviously try/catch parsing to JSON is not enough, will add more checks and polisishing. Was just for you to test it.
Yep I know, just wanted to let you know :)
So there it is. Unless I missed something, you have to try to break it on purpose, but the same can be done with the config file so...
Thanks, tested and it's working!
@regorxxx,
uploaded WIP Beta 10c for us, contains all your additions. Only some small name changes, linted your code and refactored a one liner so ESLint doesn't complain... You should just replace all your javascript files because there were more changes I needed to do when refactored the top menu code...
Also check latest changelog in the zip file for more information.
I think I'm gonna switch to ESLyric and put the Lyric Show 3 Panel to rest, here is the same with ESLyric: Here is the zip.
-Tom
Why don't you use foo_openlyrics Lyrics? (just curiosity) https://github.com/jacquesh/foo_openlyrics
See this here: https://github.com/jacquesh/foo_openlyrics/issues/177
@regorxxx, just released Beta 10c, wanted to let you know we will postpone this for Beta 10d and write it then in the changelog and make it official.
Will be available in Beta 11, I've implemented a custom menu for the metadata grid and one other surprise.
Ok, as said, it was easy. Now I have 2 questions, don't want to investigate all files until I get it right spending hours (for me learning the internals, and then you testing it).