Use new QFileDialog::DontUseCustomDirectoryIcons flag for faster file dialogs

In Qt 4.8.6 there's a new option QFileDialog::DontUseCustomDirectoryIcons
promising much better performance when there are many folders.

Closes #511.
This commit is contained in:
Tobias Doerffel
2013-09-13 21:29:53 +02:00
parent 3fce2dd666
commit 7633affa20
8 changed files with 39 additions and 5 deletions

View File

@@ -2,7 +2,7 @@
* patman.cpp - a GUS-compatible patch instrument plugin
*
* Copyright (c) 2007-2008 Javier Serrano Polo <jasp00/at/users.sourceforge.net>
* Copyright (c) 2009-2011 Tobias Doerffel <tobydox/at/users.sourceforge.net>
* Copyright (c) 2009-2013 Tobias Doerffel <tobydox/at/users.sourceforge.net>
*
* This file is part of Linux MultiMedia Studio - http://lmms.sourceforge.net
*
@@ -511,6 +511,9 @@ PatmanView::~PatmanView()
void PatmanView::openFile( void )
{
QFileDialog ofd( NULL, tr( "Open patch file" ) );
#if QT_VERSION >= 0x040806
ofd.setOption( QFileDialog::DontUseCustomDirectoryIcons );
#endif
ofd.setFileMode( QFileDialog::ExistingFiles );
QStringList types;

View File

@@ -1046,6 +1046,9 @@ void sf2InstrumentView::showFileDialog()
sf2Instrument * k = castModel<sf2Instrument>();
QFileDialog ofd( NULL, tr( "Open SoundFont file" ) );
#if QT_VERSION >= 0x040806
ofd.setOption( QFileDialog::DontUseCustomDirectoryIcons );
#endif
ofd.setFileMode( QFileDialog::ExistingFiles );
QStringList types;

View File

@@ -1,7 +1,7 @@
/*
* vestige.cpp - instrument-plugin for hosting VST-instruments
*
* Copyright (c) 2005-2012 Tobias Doerffel <tobydox/at/users.sourceforge.net>
* Copyright (c) 2005-2013 Tobias Doerffel <tobydox/at/users.sourceforge.net>
*
* This file is part of Linux MultiMedia Studio - http://lmms.sourceforge.net
*
@@ -607,6 +607,9 @@ void VestigeInstrumentView::modelChanged()
void VestigeInstrumentView::openPlugin()
{
QFileDialog ofd( NULL, tr( "Open VST-plugin" ) );
#if QT_VERSION >= 0x040806
ofd.setOption( QFileDialog::DontUseCustomDirectoryIcons );
#endif
QString dir;
if( m_vi->m_pluginDLL != "" )

View File

@@ -1,7 +1,7 @@
/*
* VstPlugin.cpp - implementation of VstPlugin class
*
* Copyright (c) 2005-2012 Tobias Doerffel <tobydox/at/users.sourceforge.net>
* Copyright (c) 2005-2013 Tobias Doerffel <tobydox/at/users.sourceforge.net>
*
* This file is part of Linux MultiMedia Studio - http://lmms.sourceforge.net
*
@@ -512,6 +512,9 @@ void VstPlugin::openPreset( )
QFileDialog ofd( NULL, tr( "Open Preset" ), "",
tr( "Vst Plugin Preset (*.fxp *.fxb)" ) );
#if QT_VERSION >= 0x040806
ofd.setOption( QFileDialog::DontUseCustomDirectoryIcons );
#endif
ofd.setFileMode( QFileDialog::ExistingFiles );
if( ofd.exec () == QDialog::Accepted &&
!ofd.selectedFiles().isEmpty() )
@@ -571,6 +574,9 @@ void VstPlugin::savePreset( )
QFileDialog sfd( NULL, tr( "Save Preset" ), presName.section(": ", 1, 1) + tr(".fxp"),
tr( "Vst Plugin Preset (*.fxp *.fxb)" ) );
#if QT_VERSION >= 0x040806
sfd.setOption( QFileDialog::DontUseCustomDirectoryIcons );
#endif
if( p_name != "" ) // remember last directory
{
sfd.setDirectory( QFileInfo( p_name ).absolutePath() );

View File

@@ -1,7 +1,7 @@
/*
* sample_buffer.cpp - container-class sampleBuffer
*
* Copyright (c) 2005-2010 Tobias Doerffel <tobydox/at/users.sourceforge.net>
* Copyright (c) 2005-2013 Tobias Doerffel <tobydox/at/users.sourceforge.net>
*
* This file is part of Linux MultiMedia Studio - http://lmms.sourceforge.net
*
@@ -742,6 +742,9 @@ void sampleBuffer::visualize( QPainter & _p, const QRect & _dr,
QString sampleBuffer::openAudioFile() const
{
QFileDialog ofd( NULL, tr( "Open audio file" ) );
#if QT_VERSION >= 0x040806
ofd.setOption( QFileDialog::DontUseCustomDirectoryIcons );
#endif
QString dir;
if( !m_audioFile.isEmpty() )

View File

@@ -1241,6 +1241,9 @@ void song::importProject()
" (*.h2song);;" +
tr("All file types") +
" (*.*)");
#if QT_VERSION >= 0x040806
ofd.setOption( QFileDialog::DontUseCustomDirectoryIcons );
#endif
ofd.setFileMode( QFileDialog::ExistingFiles );
if( ofd.exec () == QDialog::Accepted && !ofd.selectedFiles().isEmpty() )
@@ -1296,6 +1299,9 @@ void song::exportProject(bool multiExport)
}
QFileDialog efd( engine::mainWindow() );
#if QT_VERSION >= 0x040806
efd.setOption( QFileDialog::DontUseCustomDirectoryIcons );
#endif
if (multiExport)
{
efd.setFileMode( QFileDialog::Directory);

View File

@@ -688,6 +688,9 @@ void MainWindow::openProject( void )
{
QFileDialog ofd( this, tr( "Open project" ), "",
tr( "MultiMedia Project (*.mmp *.mmpz *.xml)" ) );
#if QT_VERSION >= 0x040806
ofd.setOption( QFileDialog::DontUseCustomDirectoryIcons );
#endif
ofd.setDirectory( configManager::inst()->userProjectsDir() );
ofd.setFileMode( QFileDialog::ExistingFiles );
if( ofd.exec () == QDialog::Accepted &&
@@ -751,6 +754,9 @@ bool MainWindow::saveProjectAs( void )
QFileDialog sfd( this, tr( "Save project" ), "",
tr( "MultiMedia Project (*.mmp *.mmpz);;"
"MultiMedia Project Template (*.mpt)" ) );
#if QT_VERSION >= 0x040806
sfd.setOption( QFileDialog::DontUseCustomDirectoryIcons );
#endif
sfd.setAcceptMode( QFileDialog::AcceptSave );
sfd.setFileMode( QFileDialog::AnyFile );
QString f = engine::getSong()->projectFileName();

View File

@@ -1010,7 +1010,11 @@ void setupDialog::openWorkingDir()
{
QString new_dir = QFileDialog::getExistingDirectory( this,
tr( "Choose LMMS working directory" ),
m_workingDir );
m_workingDir
#if QT_VERSION >= 0x040806
, QFileDialog::DontUseCustomDirectoryIcons
#endif
);
if( new_dir != QString::null )
{
m_wdLineEdit->setText( new_dir );