From b569723665f03d39bc1cf2c28b22d89da7d08e71 Mon Sep 17 00:00:00 2001 From: Luke Ceddia Date: Sat, 17 Aug 2024 00:52:28 +1000 Subject: [PATCH] Fix calls to kdialog so filters work The syntax used to supply file extension filters to kdialog (KDE implementation for _Open/SaveFileDialog$ was entirely wrong. This now matches what is described in the kdialog manual. Note that my installed version of kdialog have a bug whereby filters without a filter description are ignored, so that functionality has not been tested. --- internal/c/parts/gui/tinyfiledialogs.c | 33 ++++++++++++++++---------- 1 file changed, 21 insertions(+), 12 deletions(-) diff --git a/internal/c/parts/gui/tinyfiledialogs.c b/internal/c/parts/gui/tinyfiledialogs.c index ea2e9108a..da227e93b 100644 --- a/internal/c/parts/gui/tinyfiledialogs.c +++ b/internal/c/parts/gui/tinyfiledialogs.c @@ -45,6 +45,9 @@ misrepresented as being the original software. Thanks for contributions, bug corrections & thorough testing to: - Don Heyse http://ldglite.sf.net for bug corrections & thorough testing! - Paul Rouget + +This software has been modified by the QB64PE project and has diverged from +the tinyfiledialogs distribution source. */ @@ -5436,16 +5439,19 @@ char * tinyfd_saveFileDialog( if ( aNumOfFilterPatterns > 0 ) { strcat(lDialogString , " '" ) ; - strcat( lDialogString , aFilterPatterns[0] ) ; - for ( i = 1 ; i < aNumOfFilterPatterns ; i ++ ) + if ( aSingleFilterDescription && strlen(aSingleFilterDescription) ) { - strcat( lDialogString , " " ) ; - concatAndEscapeSingleQuote( lDialogString , aFilterPatterns[i] ) ; + concatAndEscapeSingleQuote( lDialogString , aSingleFilterDescription ) ; + strcat( lDialogString , " (" ) ; + } + for ( i = 0 ; i < aNumOfFilterPatterns ; i ++ ) + { + strcat( lDialogString , " " ) ; + concatAndEscapeSingleQuote( lDialogString , aFilterPatterns[i] ) ; } if ( aSingleFilterDescription && strlen(aSingleFilterDescription) ) { - strcat( lDialogString , " | " ) ; - concatAndEscapeSingleQuote( lDialogString , aSingleFilterDescription ) ; + strcat( lDialogString , ")" ) ; } strcat( lDialogString , "'" ) ; } @@ -5831,16 +5837,19 @@ char * tinyfd_openFileDialog( if ( aNumOfFilterPatterns > 0 ) { strcat(lDialogString , " '" ) ; - strcat( lDialogString , aFilterPatterns[0] ) ; - for ( i = 1 ; i < aNumOfFilterPatterns ; i ++ ) + if ( aSingleFilterDescription && strlen(aSingleFilterDescription) ) { - strcat( lDialogString , " " ) ; - concatAndEscapeSingleQuote( lDialogString , aFilterPatterns[i] ) ; + concatAndEscapeSingleQuote( lDialogString , aSingleFilterDescription ) ; + strcat( lDialogString , " (" ) ; + } + for ( i = 0 ; i < aNumOfFilterPatterns ; i ++ ) + { + strcat( lDialogString , " " ) ; + concatAndEscapeSingleQuote( lDialogString , aFilterPatterns[i] ) ; } if ( aSingleFilterDescription && strlen(aSingleFilterDescription) ) { - strcat( lDialogString , " | " ) ; - concatAndEscapeSingleQuote( lDialogString , aSingleFilterDescription ) ; + strcat( lDialogString , ")" ) ; } strcat( lDialogString , "'" ) ; }