Commit 9ac90274 authored by Martin Tobias Holmedahl Sandsmark's avatar Martin Tobias Holmedahl Sandsmark
Browse files

Port part away from KFileDialog

parent d5bdca64
...@@ -35,6 +35,7 @@ ...@@ -35,6 +35,7 @@
#include <QScrollBar> #include <QScrollBar>
#include <QInputDialog> #include <QInputDialog>
#include <QWidgetAction> #include <QWidgetAction>
#include <QFileDialog>
#include <kaboutapplicationdialog.h> #include <kaboutapplicationdialog.h>
#include <kactioncollection.h> #include <kactioncollection.h>
...@@ -43,7 +44,6 @@ ...@@ -43,7 +44,6 @@
#include <kstandardaction.h> #include <kstandardaction.h>
#include <kpluginfactory.h> #include <kpluginfactory.h>
#include <KPluginMetaData> #include <KPluginMetaData>
#include <kfiledialog.h>
#include <kmessagebox.h> #include <kmessagebox.h>
#include <knuminput.h> #include <knuminput.h>
#include <kio/netaccess.h> #include <kio/netaccess.h>
...@@ -1182,7 +1182,10 @@ bool Part::slotImportPSFile() ...@@ -1182,7 +1182,10 @@ bool Part::slotImportPSFile()
return false; return false;
} }
QUrl url = KFileDialog::getOpenUrl( QUrl(), QStringLiteral("application/postscript"), this->widget() ); QMimeDatabase mimeDatabase;
QString filter = i18n("Postscript files (%1)", mimeDatabase.mimeTypeForName(QStringLiteral("application/postscript")).globPatterns().join(QLatin1Char(' ')));
QUrl url = QFileDialog::getOpenFileUrl( widget(), QString(), QUrl(), filter );
if ( url.isLocalFile() ) if ( url.isLocalFile() )
{ {
QTemporaryFile tf(QDir::tempPath() + QLatin1String("/okular_XXXXXX.pdf")); QTemporaryFile tf(QDir::tempPath() + QLatin1String("/okular_XXXXXX.pdf"));
...@@ -2219,9 +2222,7 @@ void Part::slotSaveFileAs() ...@@ -2219,9 +2222,7 @@ void Part::slotSaveFileAs()
} }
} }
QUrl saveUrl = KFileDialog::getSaveUrl( url(), QUrl saveUrl = QFileDialog::getSaveFileUrl( widget(), QString(), url() );
QString(), widget(), QString(),
KFileDialog::ConfirmOverwrite );
if ( !saveUrl.isValid() || saveUrl.isEmpty() ) if ( !saveUrl.isValid() || saveUrl.isEmpty() )
return; return;
...@@ -2278,9 +2279,8 @@ void Part::slotSaveCopyAs() ...@@ -2278,9 +2279,8 @@ void Part::slotSaveCopyAs()
if ( m_embedMode == PrintPreviewMode ) if ( m_embedMode == PrintPreviewMode )
return; return;
QUrl saveUrl = KFileDialog::getSaveUrl( QUrl(QStringLiteral("kfiledialog:///okular/") + url().fileName()), QUrl saveUrl = QFileDialog::getSaveFileUrl( widget(), QString(), url());
QString(), widget(), QString(),
KFileDialog::ConfirmOverwrite );
if ( saveUrl.isValid() && !saveUrl.isEmpty() ) if ( saveUrl.isValid() && !saveUrl.isEmpty() )
{ {
// make use of the already downloaded (in case of remote URLs) file, // make use of the already downloaded (in case of remote URLs) file,
...@@ -2610,22 +2610,24 @@ void Part::slotExportAs(QAction * act) ...@@ -2610,22 +2610,24 @@ void Part::slotExportAs(QAction * act)
if ( ( id < 0 ) || ( id >= acts.count() ) ) if ( ( id < 0 ) || ( id >= acts.count() ) )
return; return;
QString filter; QMimeDatabase mimeDatabase;
QMimeType mimeType;
switch ( id ) switch ( id )
{ {
case 0: case 0:
filter = QStringLiteral("text/plain"); mimeType = mimeDatabase.mimeTypeForName(QStringLiteral("text/plain"));
break; break;
case 1: case 1:
filter = QStringLiteral("application/vnd.kde.okular-archive"); mimeType = mimeDatabase.mimeTypeForName(QStringLiteral("application/vnd.kde.okular-archive"));
break; break;
default: default:
filter = m_exportFormats.at( id - 2 ).mimeType().name(); mimeType = m_exportFormats.at( id - 2 ).mimeType();
break; break;
} }
QString fileName = KFileDialog::getSaveFileName( url(), QString filter = i18nc("File type name and pattern", "%1 (%2)", mimeType.comment(), mimeType.globPatterns().join(QLatin1Char(' ')));
filter, widget(), QString(),
KFileDialog::ConfirmOverwrite ); QString fileName = QFileDialog::getSaveFileName( widget(), QString(), QString(), filter);
if ( !fileName.isEmpty() ) if ( !fileName.isEmpty() )
{ {
bool saved = false; bool saved = false;
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment