diff --git a/src/ui/mainwindow.cc b/src/ui/mainwindow.cc index 84dc77dd6..5e85d0798 100644 --- a/src/ui/mainwindow.cc +++ b/src/ui/mainwindow.cc @@ -3945,80 +3945,46 @@ void MainWindow::on_exportFavorites_triggered() QString fileName = QFileDialog::getSaveFileName( this, tr( "Export Favorites to file" ), exportPath, - tr( "XML files (*.xml);;All files (*.*)" ) ); + tr( "Text files (*.txt);;XML files (*.xml)" ) ); if ( fileName.size() == 0 ) { return; } - cfg.historyExportPath = QDir::toNativeSeparators( QFileInfo( fileName ).absoluteDir().absolutePath() ); QFile file( fileName ); - - if ( !file.open( QFile::WriteOnly | QIODevice::Text ) ) { errorMessageOnStatusBar( QString( tr( "Export error: " ) ) + file.errorString() ); return; } + if ( fileName.endsWith( ".xml", Qt::CaseInsensitive ) ) { + QByteArray data; + ui.favoritesPaneWidget->getDataInXml( data ); - QByteArray data; - ui.favoritesPaneWidget->getDataInXml( data ); - - if ( file.write( data ) != data.size() ) { - errorMessageOnStatusBar( QString( tr( "Export error: " ) ) + file.errorString() ); - return; - } - - file.close(); - mainStatusBar->showMessage( tr( "Favorites export complete" ), 5000 ); -} - -void MainWindow::on_ExportFavoritesToList_triggered() -{ - QString exportPath; - if ( cfg.historyExportPath.isEmpty() ) { - exportPath = QDir::homePath(); + if ( file.write( data ) != data.size() ) { + errorMessageOnStatusBar( QString( tr( "Export error: " ) ) + file.errorString() ); + return; + } } else { - exportPath = QDir::fromNativeSeparators( cfg.historyExportPath ); - if ( !QDir( exportPath ).exists() ) { - exportPath = QDir::homePath(); + // Write UTF-8 BOM + QByteArray line; + line.append( 0xEF ).append( 0xBB ).append( 0xBF ); + if ( file.write( line ) != line.size() ) { + errorMessageOnStatusBar( QString( tr( "Export error: " ) ) + file.errorString() ); + return; } - } - - QString fileName = QFileDialog::getSaveFileName( this, - tr( "Export Favorites to file as plain list" ), - exportPath, - tr( "Text files (*.txt);;All files (*.*)" ) ); - if ( fileName.size() == 0 ) { - return; - } - cfg.historyExportPath = QDir::toNativeSeparators( QFileInfo( fileName ).absoluteDir().absolutePath() ); - QFile file( fileName ); + // Write Favorites + QString data; + ui.favoritesPaneWidget->getDataInPlainText( data ); - if ( !file.open( QFile::WriteOnly | QIODevice::Text ) ) { - errorMessageOnStatusBar( QString( tr( "Export error: " ) ) + file.errorString() ); - return; - } - - // Write UTF-8 BOM - QByteArray line; - line.append( 0xEF ).append( 0xBB ).append( 0xBF ); - if ( file.write( line ) != line.size() ) { - errorMessageOnStatusBar( QString( tr( "Export error: " ) ) + file.errorString() ); - return; - } - - // Write Favorites - QString data; - ui.favoritesPaneWidget->getDataInPlainText( data ); - - line = data.toUtf8(); - if ( file.write( line ) != line.size() ) { - errorMessageOnStatusBar( QString( tr( "Export error: " ) ) + file.errorString() ); - return; + line = data.toUtf8(); + if ( file.write( line ) != line.size() ) { + errorMessageOnStatusBar( QString( tr( "Export error: " ) ) + file.errorString() ); + return; + } } - file.close(); + mainStatusBar->showMessage( tr( "Favorites export complete" ), 5000 ); } diff --git a/src/ui/mainwindow.hh b/src/ui/mainwindow.hh index a4a583b45..3fb494c50 100644 --- a/src/ui/mainwindow.hh +++ b/src/ui/mainwindow.hh @@ -430,7 +430,6 @@ private slots: void on_exportFavorites_triggered(); void on_importFavorites_triggered(); - void on_ExportFavoritesToList_triggered(); void updateSearchPaneAndBar( bool searchInDock ); diff --git a/src/ui/mainwindow.ui b/src/ui/mainwindow.ui index ec76f207d..17b73447f 100644 --- a/src/ui/mainwindow.ui +++ b/src/ui/mainwindow.ui @@ -125,7 +125,6 @@ - @@ -557,11 +556,6 @@ Ctrl+E - - - Export to list - -