Skip to content

Commit b569723

Browse files
committed
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.
1 parent ee247e6 commit b569723

File tree

1 file changed

+21
-12
lines changed

1 file changed

+21
-12
lines changed

internal/c/parts/gui/tinyfiledialogs.c

+21-12
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,9 @@ misrepresented as being the original software.
4545
Thanks for contributions, bug corrections & thorough testing to:
4646
- Don Heyse http://ldglite.sf.net for bug corrections & thorough testing!
4747
- Paul Rouget
48+
49+
This software has been modified by the QB64PE project and has diverged from
50+
the tinyfiledialogs distribution source.
4851
*/
4952

5053

@@ -5436,16 +5439,19 @@ char * tinyfd_saveFileDialog(
54365439
if ( aNumOfFilterPatterns > 0 )
54375440
{
54385441
strcat(lDialogString , " '" ) ;
5439-
strcat( lDialogString , aFilterPatterns[0] ) ;
5440-
for ( i = 1 ; i < aNumOfFilterPatterns ; i ++ )
5442+
if ( aSingleFilterDescription && strlen(aSingleFilterDescription) )
54415443
{
5442-
strcat( lDialogString , " " ) ;
5443-
concatAndEscapeSingleQuote( lDialogString , aFilterPatterns[i] ) ;
5444+
concatAndEscapeSingleQuote( lDialogString , aSingleFilterDescription ) ;
5445+
strcat( lDialogString , " (" ) ;
5446+
}
5447+
for ( i = 0 ; i < aNumOfFilterPatterns ; i ++ )
5448+
{
5449+
strcat( lDialogString , " " ) ;
5450+
concatAndEscapeSingleQuote( lDialogString , aFilterPatterns[i] ) ;
54445451
}
54455452
if ( aSingleFilterDescription && strlen(aSingleFilterDescription) )
54465453
{
5447-
strcat( lDialogString , " | " ) ;
5448-
concatAndEscapeSingleQuote( lDialogString , aSingleFilterDescription ) ;
5454+
strcat( lDialogString , ")" ) ;
54495455
}
54505456
strcat( lDialogString , "'" ) ;
54515457
}
@@ -5831,16 +5837,19 @@ char * tinyfd_openFileDialog(
58315837
if ( aNumOfFilterPatterns > 0 )
58325838
{
58335839
strcat(lDialogString , " '" ) ;
5834-
strcat( lDialogString , aFilterPatterns[0] ) ;
5835-
for ( i = 1 ; i < aNumOfFilterPatterns ; i ++ )
5840+
if ( aSingleFilterDescription && strlen(aSingleFilterDescription) )
58365841
{
5837-
strcat( lDialogString , " " ) ;
5838-
concatAndEscapeSingleQuote( lDialogString , aFilterPatterns[i] ) ;
5842+
concatAndEscapeSingleQuote( lDialogString , aSingleFilterDescription ) ;
5843+
strcat( lDialogString , " (" ) ;
5844+
}
5845+
for ( i = 0 ; i < aNumOfFilterPatterns ; i ++ )
5846+
{
5847+
strcat( lDialogString , " " ) ;
5848+
concatAndEscapeSingleQuote( lDialogString , aFilterPatterns[i] ) ;
58395849
}
58405850
if ( aSingleFilterDescription && strlen(aSingleFilterDescription) )
58415851
{
5842-
strcat( lDialogString , " | " ) ;
5843-
concatAndEscapeSingleQuote( lDialogString , aSingleFilterDescription ) ;
5852+
strcat( lDialogString , ")" ) ;
58445853
}
58455854
strcat( lDialogString , "'" ) ;
58465855
}

0 commit comments

Comments
 (0)