From 0dfb8a6030c96400510e61d70508f49183ddd121 Mon Sep 17 00:00:00 2001 From: Daniel Prado Velasco Date: Thu, 9 May 2024 21:19:24 +0200 Subject: [PATCH] The style definition file (keynote.kns) is now updated after each modification, and not just on exit the application Among other things, this allows you to assign a keyboard shortcut to a newly created style without having to reopen the application. Ref: #697 --- editor/kn_StyleMng.pas | 16 ++++++++++++++++ kn_Main.pas | 6 +----- 2 files changed, 17 insertions(+), 5 deletions(-) diff --git a/editor/kn_StyleMng.pas b/editor/kn_StyleMng.pas index b60c251..41b012a 100644 --- a/editor/kn_StyleMng.pas +++ b/editor/kn_StyleMng.pas @@ -37,6 +37,8 @@ interface procedure StyleDescribe( const FromEditor, LongDesc : boolean ); procedure StyleRedefine; + procedure CheckSaveStyleManagerInfo; + var StylesModified : boolean; // styles are only saved if this flag is TRUE LastStyleRange : TStyleRange; // obsolete @@ -192,6 +194,8 @@ procedure StyleCreate( aRange : TStyleRange; ExistingStyle : TStyle ); Form_Main.Combo_Style.ItemIndex := idx; Form_Main.StatusBar.Panels[PANEL_HINT].Text := Format( STR_10, [Name,STYLE_RANGES[aRange]] ); + CheckSaveStyleManagerInfo; + except on E : Exception do begin messagedlg( STR_11 + E.Message, mtError, [mbOK], 0 ); @@ -331,6 +335,8 @@ procedure StyleRename( aName : string ); Form_Main.Combo_Style.ItemIndex := Form_Main.Combo_Style.Items.IndexOf( name ); + CheckSaveStyleManagerInfo; + except showmessage( STR_16 ); end; @@ -360,6 +366,8 @@ procedure StyleDelete( aName : string ); if ( Form_Main.Combo_Style.Items.Count > 0 ) then Form_Main.Combo_Style.ItemIndex := 0; + CheckSaveStyleManagerInfo; + except showmessage( STR_18 ); end; @@ -396,6 +404,14 @@ procedure StyleRedefine; StyleCreate( LastStyleRange, TStyle( StyleManager.Objects[Form_Main.Combo_Style.ItemIndex] )); end; +procedure CheckSaveStyleManagerInfo; +begin + if StylesModified and (not App.opt_NoSaveOpt) then begin + if SaveStyleManagerInfo( Style_FN ) then + StylesModified := false; + end; +end; + initialization StylesModified := false; diff --git a/kn_Main.pas b/kn_Main.pas index e690b71..ea561bc 100644 --- a/kn_Main.pas +++ b/kn_Main.pas @@ -2053,11 +2053,7 @@ procedure TForm_Main.FormCloseQuery(Sender: TObject; if ( not App.opt_NoSaveOpt ) then begin SaveFileManagerInfo( MGR_FN ); - if StylesModified then - begin - SaveStyleManagerInfo( Style_FN ); - StylesModified := false; - end; + CheckSaveStyleManagerInfo; SaveFavorites( FAV_FN ); if App.opt_NoRegistry then IniSaveToolbarPositions( Self, changefileext( INI_FN, ext_MRU ), 'TB97a' )