@ -24,6 +24,7 @@
# include <tqdbusobjectpath.h>
// TDE
# include <tdeio/renamedlg.h>
# include <tdefiledialog.h>
# include <kpushbutton.h>
# include <twin.h>
@ -126,7 +127,84 @@ bool TDEFileChooserPortal::SaveFiles(const TQT_DBusObjectPath& handle,
TQMap < TQString , TQT_DBusVariant > & results ,
TQT_DBusError & error )
{
return false ;
// Get list of files to save
if ( ! OPTION_VALID ( " files " , " aay " ) )
{
kdWarning ( ) < < " TDEFileChooserPortal::SaveFiles: "
< < " Invalid or misssing files option " < < endl ;
return false ;
}
TQValueList < TQT_DBusData > filelist = options [ " files " ] . value . toTQValueList ( ) ;
TQValueList < TQT_DBusData > : : iterator fi ;
TQStringList files ;
for ( fi = filelist . begin ( ) ; fi ! = filelist . end ( ) ; + + fi )
{
files < < bytelist_to_string ( ( * fi ) . toList ( ) . toByteList ( ) ) ;
}
// Parse options
FileDialogOpts opts ;
opts . caption = title ;
if ( OPTION_VALID ( " accept_label " , " s " ) )
opts . okButtonText = options [ " accept_label " ] . value . toString ( ) ;
if ( OPTION_VALID ( " modal " , " b " ) )
opts . modal = options [ " modal " ] . value . toBool ( ) ;
if ( OPTION_VALID ( " current_folder " , " ay " ) )
opts . startDir = bytelist_to_string ( options [ " current_folder " ] . value . toList ( ) . toByteList ( ) ) ;
// We can't just use execFileDialog because we need to do some special processing
KFileDialog * dialog = new KFileDialog ( opts . startDir , TQString : : null ,
nullptr , " xdg-tde-file-chooser " ,
opts . modal ) ;
dialog - > setMode ( KFile : : LocalOnly | KFile : : Directory ) ;
if ( ! opts . caption . isNull ( ) )
dialog - > setPlainCaption ( opts . caption ) ;
if ( ! opts . okButtonText . isNull ( ) )
dialog - > okButton ( ) - > setText ( opts . okButtonText ) ;
if ( opts . windowId > 0 ) KWin : : setMainWindow ( dialog , opts . windowId ) ;
if ( dialog - > exec ( ) = = TQDialog : : Accepted )
{
TQDir d ( dialog - > selectedURL ( ) . path ( ) ) ;
KURL : : List urllist ;
for ( TQStringList : : Iterator it = files . begin ( ) ; it ! = files . end ( ) ; + + it )
{
TQString filename = ( * it ) ;
TQFileInfo fi ( d , filename ) ;
KURL url ( fi . absFilePath ( ) ) ;
if ( fi . exists ( ) )
{
TDEIO : : RenameDlg rename ( dialog , opts . caption , TQString : : null ,
fi . absFilePath ( ) , TDEIO : : M_OVERWRITE ) ;
int result = rename . exec ( ) ;
switch ( result )
{
case TDEIO : : R_RENAME :
url = rename . newDestURL ( ) ;
break ;
case TDEIO : : R_CANCEL :
url = KURL ( ) ;
break ;
}
}
urllist < < url . url ( ) ;
}
response = 0 ;
TQT_DBusDataList urls = kurl_list_to_datalist ( urllist ) ;
TQT_DBusVariant var = TQT_DBusData : : fromList ( urls ) . getAsVariantData ( ) . toVariant ( ) ;
results . insert ( " uris " , var ) ;
}
else response = 1 ;
return true ;
}
void TDEFileChooserPortal : : handleMethodReply ( const TQT_DBusMessage & reply )