summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMartin T. H. Sandsmark <martin.sandsmark@kde.org>2016-07-13 00:16:05 (GMT)
committerMartin T. H. Sandsmark <martin.sandsmark@kde.org>2016-08-13 19:28:30 (GMT)
commit8f86818b5cf4bffb38ce9b3f725b4c38f20df598 (patch)
treebcb8aad49a6742b01543402f06e0b53b69af6fd2
parent411bdee0ebaf67d603b2c8c9eab81768939e1bd5 (diff)
Make the open dialog a bit more usable without the Plasma QPA
Without the Plasma QPA now the file open dialog just lets you select a single random filetype to view at the time. REVIEW: 128435
-rw-r--r--shell/shell.cpp25
1 files changed, 19 insertions, 6 deletions
diff --git a/shell/shell.cpp b/shell/shell.cpp
index bca7206..38f60b7 100644
--- a/shell/shell.cpp
+++ b/shell/shell.cpp
@@ -432,13 +432,26 @@ void Shell::fileOpen()
QPointer<QFileDialog> dlg( new QFileDialog( this ));
dlg->setDirectoryUrl( startDir );
dlg->setAcceptMode( QFileDialog::AcceptOpen );
+ dlg->setOption( QFileDialog::HideNameFilterDetails, true );
+
+ QMimeDatabase mimeDatabase;
+ QSet<QString> globPatterns;
+ QStringList namePatterns;
+ foreach ( const QString &mimeName, m_fileformats ) {
+ QMimeType mimeType = mimeDatabase.mimeTypeForName( mimeName );
+ globPatterns.unite( mimeType.globPatterns().toSet() ) ;
+
+ namePatterns.append( mimeType.comment() +
+ QStringLiteral(" (") +
+ mimeType.globPatterns().join( QLatin1Char(' ') ) +
+ QStringLiteral(")")
+ );
+ }
+ namePatterns.prepend( i18n("All files (*)") );
+ namePatterns.prepend( i18n("All supported files (%s)", globPatterns.toList().join( QLatin1Char(' ') ) ) );
+ dlg->setNameFilters( namePatterns );
- if ( m_fileformatsscanned && m_fileformats.isEmpty() )
- dlg->setNameFilter( { i18n( "All Files (*)" ) } );
- else
- dlg->setMimeTypeFilters( m_fileformats );
-
- dlg->setWindowTitle( i18n( "Open Document" ) );
+ dlg->setWindowTitle( i18n("Open Document") );
if ( !dlg->exec() || !dlg)
return;