From b025b4113a9dc2fa80cd71c37879e7b11ecd7823 Mon Sep 17 00:00:00 2001 From: Pino Toscano Date: Sat, 26 Dec 2009 20:47:58 +0000 Subject: [PATCH] activate the overwriting confirmation in all the other file save dialogs svn path=/trunk/KDE/kdegraphics/okular/; revision=1066352 --- ui/guiutils.cpp | 18 +++++++----------- ui/pageview.cpp | 3 ++- ui/propertiesdialog.cpp | 19 ++++++++----------- 3 files changed, 17 insertions(+), 23 deletions(-) diff --git a/ui/guiutils.cpp b/ui/guiutils.cpp index a65934301..7fbac26de 100644 --- a/ui/guiutils.cpp +++ b/ui/guiutils.cpp @@ -200,23 +200,19 @@ KIconLoader* iconLoader() void saveEmbeddedFile( Okular::EmbeddedFile *ef, QWidget *parent ) { const QString caption = i18n( "Where do you want to save %1?", ef->name() ); - const QString path = KFileDialog::getSaveFileName( ef->name(), QString(), parent, caption ); + const QString path = KFileDialog::getSaveFileName( ef->name(), QString(), parent, caption, + KFileDialog::ConfirmOverwrite ); if ( path.isEmpty() ) return; QFile f( path ); - if ( !f.exists() || KMessageBox::warningContinueCancel( parent, i18n( "A file named \"%1\" already exists. Are you sure you want to overwrite it?", path ), QString(), KGuiItem( i18nc( "@action:button", "&Overwrite" ) ) ) == KMessageBox::Continue ) + if ( !f.open( QIODevice::WriteOnly ) ) { - if ( f.open( QIODevice::WriteOnly ) ) - { - f.write( ef->data() ); - f.close(); - } - else - { - KMessageBox::error( parent, i18n( "Could not open \"%1\" for writing. File was not saved.", path ) ); - } + KMessageBox::error( parent, i18n( "Could not open \"%1\" for writing. File was not saved.", path ) ); + return; } + f.write( ef->data() ); + f.close(); } } diff --git a/ui/pageview.cpp b/ui/pageview.cpp index d87673c81..61944316f 100644 --- a/ui/pageview.cpp +++ b/ui/pageview.cpp @@ -2024,7 +2024,8 @@ void PageView::mouseReleaseEvent( QMouseEvent * e ) else if ( choice == imageToFile ) { // [3] save pixmap to file - QString fileName = KFileDialog::getSaveFileName( KUrl(), "image/png image/jpeg", this ); + QString fileName = KFileDialog::getSaveFileName( KUrl(), "image/png image/jpeg", this, QString(), + KFileDialog::ConfirmOverwrite ); if ( fileName.isEmpty() ) d->messageWindow->display( i18n( "File not saved." ), PageViewMessage::Warning ); else diff --git a/ui/propertiesdialog.cpp b/ui/propertiesdialog.cpp index e7a46a130..d953e04b8 100644 --- a/ui/propertiesdialog.cpp +++ b/ui/propertiesdialog.cpp @@ -259,22 +259,19 @@ void PropertiesDialog::showFontsMenu(const QPoint &pos) { Okular::FontInfo fi = index.data(FontInfoRole).value(); const QString caption = i18n( "Where do you want to save %1?", fi.name() ); - const QString path = KFileDialog::getSaveFileName( fi.name(), QString(), this, caption ); + const QString path = KFileDialog::getSaveFileName( fi.name(), QString(), this, caption, KFileDialog::ConfirmOverwrite ); if ( path.isEmpty() ) return; QFile f( path ); - if ( !f.exists() || KMessageBox::warningContinueCancel( this, i18n( "A file named \"%1\" already exists. Are you sure you want to overwrite it?", path ), QString(), KGuiItem( i18nc( "@action:button", "&Overwrite" ) ) ) == KMessageBox::Continue ) + if ( f.open( QIODevice::WriteOnly ) ) { - if ( f.open( QIODevice::WriteOnly ) ) - { - f.write( m_document->fontData(fi) ); - f.close(); - } - else - { - KMessageBox::error( this, i18n( "Could not open \"%1\" for writing. File was not saved.", path ) ); - } + f.write( m_document->fontData(fi) ); + f.close(); + } + else + { + KMessageBox::error( this, i18n( "Could not open \"%1\" for writing. File was not saved.", path ) ); } } }