From 2cedb05a8a24ddf9b448a0f11e6f7c3842ed8f3f Mon Sep 17 00:00:00 2001 From: Nariman Jelveh Date: Sat, 4 Oct 2025 12:13:57 -0700 Subject: [PATCH] add option to automatically set window title to opened file's name (#1678) * add option to automatically set window title to opened file's name A new checkbox in the app edit section to allow users to automatically set the window title to the name of the opened file. Updated related functions to handle this new setting, ensuring it is saved and reset correctly. * Update launch_app.js --- src/dev-center/js/apps.js | 14 ++++++++++++-- src/gui/src/helpers/launch_app.js | 5 +++++ 2 files changed, 17 insertions(+), 2 deletions(-) diff --git a/src/dev-center/js/apps.js b/src/dev-center/js/apps.js index fca9666c..48798978 100644 --- a/src/dev-center/js/apps.js +++ b/src/dev-center/js/apps.js @@ -430,6 +430,12 @@ function generate_edit_app_section(app) { +
+ + +

This will set your app's window title to the opened file's name when a user opens a file in your app.

+
+

Misc

@@ -504,7 +510,8 @@ function trackOriginalValues(){ resizableWindow: $('#edit-app-window-resizable').is(':checked'), hideTitleBar: $('#edit-app-hide-titlebar').is(':checked'), locked: $('#edit-app-locked').is(':checked'), - fullPageOnLanding: $('#edit-app-fullpage-on-landing').is(':checked') + fullPageOnLanding: $('#edit-app-fullpage-on-landing').is(':checked'), + setTitleToFile: $('#edit-app-set-title-to-file').is(':checked') } }; } @@ -540,7 +547,8 @@ function hasChanges() { $('#edit-app-window-resizable').is(':checked') !== originalValues.checkboxes.resizableWindow || $('#edit-app-hide-titlebar').is(':checked') !== originalValues.checkboxes.hideTitleBar || $('#edit-app-locked').is(':checked') !== originalValues.checkboxes.locked || - $('#edit-app-fullpage-on-landing').is(':checked') !== originalValues.checkboxes.fullPageOnLanding + $('#edit-app-fullpage-on-landing').is(':checked') !== originalValues.checkboxes.fullPageOnLanding || + $('#edit-app-set-title-to-file').is(':checked') !== originalValues.checkboxes.setTitleToFile ); } @@ -587,6 +595,7 @@ function resetToOriginalValues() { $('#edit-app-hide-titlebar').prop('checked', originalValues.checkboxes.hideTitleBar); $('#edit-app-locked').prop('checked', originalValues.checkboxes.locked); $('#edit-app-fullpage-on-landing').prop('checked', originalValues.checkboxes.fullPageOnLanding); + $('#edit-app-set-title-to-file').prop('checked', originalValues.checkboxes.setTitleToFile); if (originalValues.icon) { $('#edit-app-icon').css('background-image', `url(${originalValues.icon})`); @@ -1141,6 +1150,7 @@ $(document).on('click', '.edit-app-save-btn', async function (e) { window_resizable: $('#edit-app-window-resizable').is(":checked"), hide_titlebar: $('#edit-app-hide-titlebar').is(":checked"), locked: $(`#edit-app-locked`).is(":checked") ?? false, + set_title_to_opened_file: $('#edit-app-set-title-to-file').is(":checked"), }, filetypeAssociations: filetype_associations, }).then(async (app) => { diff --git a/src/gui/src/helpers/launch_app.js b/src/gui/src/helpers/launch_app.js index 46bb53d4..41217681 100644 --- a/src/gui/src/helpers/launch_app.js +++ b/src/gui/src/helpers/launch_app.js @@ -351,6 +351,11 @@ const launch_app = async (options)=>{ if(app_info.metadata?.credentialless !== undefined && typeof app_info.metadata.credentialless === 'boolean') credentialless = app_info.metadata.credentialless; + // set_title_to_opened_file + // if set_title_to_opened_file is true, set the title to the opened file's name + if(app_info.metadata?.set_title_to_opened_file !== undefined && typeof app_info.metadata.set_title_to_opened_file === 'boolean' && app_info.metadata.set_title_to_opened_file === true) + title = options.file_path ? path.basename(options.file_path) : title; + // open window el_win = UIWindow({ element_uuid: uuid,