| 513 | |
| 514 | |
| 515 | void PatmanView::openFile( void ) |
| 516 | { |
| 517 | FileDialog ofd( NULL, tr( "Open patch file" ) ); |
| 518 | ofd.setFileMode( FileDialog::ExistingFiles ); |
| 519 | |
| 520 | QStringList types; |
| 521 | types << tr( "Patch-Files (*.pat)" ); |
| 522 | ofd.setNameFilters( types ); |
| 523 | |
| 524 | if( m_pi->m_patchFile == "" ) |
| 525 | { |
| 526 | if( QDir( "/usr/share/midi/freepats" ).exists() ) |
| 527 | { |
| 528 | ofd.setDirectory( "/usr/share/midi/freepats" ); |
| 529 | } |
| 530 | else |
| 531 | { |
| 532 | ofd.setDirectory( |
| 533 | ConfigManager::inst()->userSamplesDir() ); |
| 534 | } |
| 535 | } |
| 536 | else if( QFileInfo( m_pi->m_patchFile ).isRelative() ) |
| 537 | { |
| 538 | QString f = ConfigManager::inst()->userSamplesDir() |
| 539 | + m_pi->m_patchFile; |
| 540 | if( QFileInfo( f ).exists() == false ) |
| 541 | { |
| 542 | f = ConfigManager::inst()->factorySamplesDir() |
| 543 | + m_pi->m_patchFile; |
| 544 | } |
| 545 | |
| 546 | ofd.selectFile( f ); |
| 547 | } |
| 548 | else |
| 549 | { |
| 550 | ofd.selectFile( m_pi->m_patchFile ); |
| 551 | } |
| 552 | |
| 553 | if( ofd.exec() == QDialog::Accepted && !ofd.selectedFiles().isEmpty() ) |
| 554 | { |
| 555 | QString f = ofd.selectedFiles()[0]; |
| 556 | if( f != "" ) |
| 557 | { |
| 558 | m_pi->setFile( f ); |
| 559 | Engine::getSong()->setModified(); |
| 560 | } |
| 561 | } |
| 562 | } |
| 563 | |
| 564 | |
| 565 | |