MCPcopy Create free account
hub / github.com/LMMS/lmms / openAudioFile

Method openAudioFile

src/core/SampleBuffer.cpp:989–1050  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

987
988
989QString SampleBuffer::openAudioFile() const
990{
991 FileDialog ofd( NULL, tr( "Open audio file" ) );
992
993 QString dir;
994 if( !m_audioFile.isEmpty() )
995 {
996 QString f = m_audioFile;
997 if( QFileInfo( f ).isRelative() )
998 {
999 f = ConfigManager::inst()->userSamplesDir() + f;
1000 if( QFileInfo( f ).exists() == false )
1001 {
1002 f = ConfigManager::inst()->factorySamplesDir() +
1003 m_audioFile;
1004 }
1005 }
1006 dir = QFileInfo( f ).absolutePath();
1007 }
1008 else
1009 {
1010 dir = ConfigManager::inst()->userSamplesDir();
1011 }
1012 // change dir to position of previously opened file
1013 ofd.setDirectory( dir );
1014 ofd.setFileMode( FileDialog::ExistingFiles );
1015
1016 // set filters
1017 QStringList types;
1018 types << tr( "All Audio-Files (*.wav *.ogg *.ds *.flac *.spx *.voc "
1019 "*.aif *.aiff *.au *.raw)" )
1020 << tr( "Wave-Files (*.wav)" )
1021 << tr( "OGG-Files (*.ogg)" )
1022 << tr( "DrumSynth-Files (*.ds)" )
1023 << tr( "FLAC-Files (*.flac)" )
1024 << tr( "SPEEX-Files (*.spx)" )
1025 //<< tr( "MP3-Files (*.mp3)" )
1026 //<< tr( "MIDI-Files (*.mid)" )
1027 << tr( "VOC-Files (*.voc)" )
1028 << tr( "AIFF-Files (*.aif *.aiff)" )
1029 << tr( "AU-Files (*.au)" )
1030 << tr( "RAW-Files (*.raw)" )
1031 //<< tr( "MOD-Files (*.mod)" )
1032 ;
1033 ofd.setNameFilters( types );
1034 if( !m_audioFile.isEmpty() )
1035 {
1036 // select previously opened file
1037 ofd.selectFile( QFileInfo( m_audioFile ).fileName() );
1038 }
1039
1040 if( ofd.exec () == QDialog::Accepted )
1041 {
1042 if( ofd.selectedFiles().isEmpty() )
1043 {
1044 return QString::null;
1045 }
1046 return tryToMakeRelative( ofd.selectedFiles()[0] );

Callers 3

openAndSetAudioFileMethod · 0.95
mouseDoubleClickEventMethod · 0.45

Calls 3

existsMethod · 0.80
instFunction · 0.50
isEmptyMethod · 0.45

Tested by

no test coverage detected