| 584 | |
| 585 | |
| 586 | void ConfigManager::saveConfigFile() |
| 587 | { |
| 588 | setValue( "paths", "artwork", m_artworkDir ); |
| 589 | setValue( "paths", "workingdir", m_workingDir ); |
| 590 | setValue( "paths", "vstdir", m_vstDir ); |
| 591 | setValue( "paths", "gigdir", m_gigDir ); |
| 592 | setValue( "paths", "sf2dir", m_sf2Dir ); |
| 593 | setValue( "paths", "laddir", m_ladDir ); |
| 594 | #ifdef LMMS_HAVE_STK |
| 595 | setValue( "paths", "stkdir", m_stkDir ); |
| 596 | #endif |
| 597 | #ifdef LMMS_HAVE_FLUIDSYNTH |
| 598 | setValue( "paths", "defaultsf2", m_defaultSoundfont ); |
| 599 | #endif |
| 600 | setValue( "paths", "backgroundartwork", m_backgroundArtwork ); |
| 601 | |
| 602 | QDomDocument doc( "lmms-config-file" ); |
| 603 | |
| 604 | QDomElement lmms_config = doc.createElement( "lmms" ); |
| 605 | lmms_config.setAttribute( "version", m_version ); |
| 606 | doc.appendChild( lmms_config ); |
| 607 | |
| 608 | for( settingsMap::iterator it = m_settings.begin(); |
| 609 | it != m_settings.end(); ++it ) |
| 610 | { |
| 611 | QDomElement n = doc.createElement( it.key() ); |
| 612 | for( stringPairVector::iterator it2 = ( *it ).begin(); |
| 613 | it2 != ( *it ).end(); ++it2 ) |
| 614 | { |
| 615 | n.setAttribute( ( *it2 ).first, ( *it2 ).second ); |
| 616 | } |
| 617 | lmms_config.appendChild( n ); |
| 618 | } |
| 619 | |
| 620 | QDomElement recent_files = doc.createElement( "recentfiles" ); |
| 621 | |
| 622 | for( QStringList::iterator it = m_recentlyOpenedProjects.begin(); |
| 623 | it != m_recentlyOpenedProjects.end(); ++it ) |
| 624 | { |
| 625 | QDomElement n = doc.createElement( "file" ); |
| 626 | n.setAttribute( "path", *it ); |
| 627 | recent_files.appendChild( n ); |
| 628 | } |
| 629 | lmms_config.appendChild( recent_files ); |
| 630 | |
| 631 | QString xml = "<?xml version=\"1.0\"?>\n" + doc.toString( 2 ); |
| 632 | |
| 633 | QFile outfile( m_lmmsRcFile ); |
| 634 | if( !outfile.open( QIODevice::WriteOnly | QIODevice::Truncate ) ) |
| 635 | { |
| 636 | QString title, message; |
| 637 | title = MainWindow::tr( "Could not open file" ); |
| 638 | message = MainWindow::tr( "Could not open file %1 " |
| 639 | "for writing.\nPlease make " |
| 640 | "sure you have write " |
| 641 | "permission to the file and " |
| 642 | "the directory containing the " |
| 643 | "file and try again!" |