From a170f7209a7489d647121cf0be247d40c14eeb00 Mon Sep 17 00:00:00 2001 From: Tobias Doerffel Date: Fri, 19 Sep 2008 15:42:32 +0000 Subject: [PATCH] fixed paths when starting with no configuration file git-svn-id: https://lmms.svn.sf.net/svnroot/lmms/trunk/lmms@1636 0778d3d1-df1d-0410-868b-ea421aaaa00d --- ChangeLog | 22 +++++++ include/config_mgr.h | 2 +- src/core/config_mgr.cpp | 138 ++++++++++++++++++++-------------------- src/core/main.cpp | 6 +- 4 files changed, 92 insertions(+), 76 deletions(-) diff --git a/ChangeLog b/ChangeLog index 2279565b4..2f55d9e56 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,25 @@ +2008-09-19 Tobias Doerffel + + * include/config_mgr.h: + * src/core/config_mgr.cpp: + * src/core/main.cpp: + fixed paths when starting with no configuration file + + * src/core/timeline.cpp: + * src/core/track.cpp: + * data/themes/default/playpos_marker.png: + * data/themes/default/loop_points_on.png: + * data/themes/default/style.css: + * data/themes/default/loop_point_disabled.png: + * data/themes/default/autoscroll_off.png: + * data/themes/default/loop_point.png: + * data/themes/default/autoscroll_on.png: + * data/themes/default/loop_points_off.png: + improved visual appearence of timeline + + * CMakeLists.txt: + improved detection of Qt4 translation directory + 2008-09-18 Tobias Doerffel * src/gui/fx_mixer_view.cpp: diff --git a/include/config_mgr.h b/include/config_mgr.h index b9d2d5abb..7f47bce74 100644 --- a/include/config_mgr.h +++ b/include/config_mgr.h @@ -165,7 +165,7 @@ public: void setValue( const QString & _class, const QString & _attribute, const QString & _value ); - bool loadConfigFile( void ); + void loadConfigFile( void ); void saveConfigFile( void ); diff --git a/src/core/config_mgr.cpp b/src/core/config_mgr.cpp index 76a0d1f1e..c6860326d 100644 --- a/src/core/config_mgr.cpp +++ b/src/core/config_mgr.cpp @@ -202,7 +202,7 @@ void configManager::setValue( const QString & _class, -bool configManager::loadConfigFile( void ) +void configManager::loadConfigFile( void ) { // read the XML file and create DOM tree QFile cfg_file( m_lmmsRcFile ); @@ -210,79 +210,78 @@ bool configManager::loadConfigFile( void ) if( cfg_file.open( QIODevice::ReadOnly ) ) { - if( !dom_tree.setContent( &cfg_file ) ) + if( dom_tree.setContent( &cfg_file ) ) { - // return( FALSE ); + // get the head information from the DOM + QDomElement root = dom_tree.documentElement(); + + QDomNode node = root.firstChild(); + + // create the settings-map out of the DOM + while( !node.isNull() ) + { + if( node.isElement() && + node.toElement().hasAttributes () ) + { + stringPairVector attr; + QDomNamedNodeMap node_attr = + node.toElement().attributes(); + for( int i = 0; i < node_attr.count(); + ++i ) + { + QDomNode n = node_attr.item( i ); + if( n.isAttr() ) + { + attr.push_back( qMakePair( n.toAttr().name(), + n.toAttr().value() ) ); + } + } + m_settings[node.nodeName()] = attr; + } + else if( node.nodeName() == "recentfiles" ) + { + m_recentlyOpenedProjects.clear(); + QDomNode n = node.firstChild(); + while( !n.isNull() ) + { + if( n.isElement() && n.toElement().hasAttributes() ) + { + m_recentlyOpenedProjects << + n.toElement().attribute( "path" ); + } + n = n.nextSibling(); + } + } + node = node.nextSibling(); + } + + if( value( "paths", "artwork" ) != "" ) + { + m_artworkDir = value( "paths", "artwork" ); + if( !QDir( m_artworkDir ).exists() ) + { + m_artworkDir = defaultArtworkDir(); + } + if( m_artworkDir.right( 1 ) != + QDir::separator() ) + { + m_artworkDir += QDir::separator(); + } + } + setWorkingDir( value( "paths", "workingdir" ) ); + setVSTDir( value( "paths", "vstdir" ) ); + setFLDir( value( "paths", "fldir" ) ); + setLADSPADir( value( "paths", "laddir" ) ); + #ifdef LMMS_HAVE_STK + setSTKDir( value( "paths", "stkdir" ) ); + #endif + #ifdef LMMS_HAVE_FLUIDSYNTH + setDefaultSoundfont( value( "paths", "defaultsf2" ) ); + #endif } cfg_file.close(); } - // get the head information from the DOM - QDomElement root = dom_tree.documentElement(); - - QDomNode node = root.firstChild(); - - // create the settings-map out of the DOM - while( !node.isNull() ) - { - if( node.isElement() && node.toElement().hasAttributes () ) - { - stringPairVector attr; - QDomNamedNodeMap node_attr = - node.toElement().attributes(); - for( int i = 0; i < node_attr.count(); ++i ) - { - QDomNode n = node_attr.item( i ); - if( n.isAttr() ) - { - attr.push_back( qMakePair( - n.toAttr().name(), - n.toAttr().value() ) ); - } - } - m_settings[node.nodeName()] = attr; - } - else if( node.nodeName() == "recentfiles" ) - { - m_recentlyOpenedProjects.clear(); - QDomNode n = node.firstChild(); - while( !n.isNull() ) - { - if( n.isElement() && - n.toElement().hasAttributes() ) - { - m_recentlyOpenedProjects << - n.toElement(). - attribute( "path" ); - } - n = n.nextSibling(); - } - } - node = node.nextSibling(); - } - - if( value( "paths", "artwork" ) != "" ) - { - m_artworkDir = value( "paths", "artwork" ); - if( QDir( m_artworkDir ).exists() == FALSE ) - { - m_artworkDir = defaultArtworkDir(); - } - if( m_artworkDir.right( 1 ) != QDir::separator() ) - { - m_artworkDir += QDir::separator(); - } - } - setWorkingDir( value( "paths", "workingdir" ) ); - setVSTDir( value( "paths", "vstdir" ) ); - setFLDir( value( "paths", "fldir" ) ); - setLADSPADir( value( "paths", "laddir" ) ); -#ifdef LMMS_HAVE_STK - setSTKDir( value( "paths", "stkdir" ) ); -#endif -#ifdef LMMS_HAVE_FLUIDSYNTH - setDefaultSoundfont( value( "paths", "defaultsf2" ) ); -#endif if( m_vstDir == "" ) { @@ -333,7 +332,6 @@ bool configManager::loadConfigFile( void ) QDir().mkpath( userSamplesDir() ); QDir().mkpath( userPresetsDir() ); } - return( TRUE ); } diff --git a/src/core/main.cpp b/src/core/main.cpp index 8594ef146..54b053b53 100644 --- a/src/core/main.cpp +++ b/src/core/main.cpp @@ -335,11 +335,7 @@ int main( int argc, char * * argv ) #endif #endif - if( !configManager::inst()->loadConfigFile() ) - { - printf( "could not load config file!\n" ); - return( EXIT_FAILURE ); - } + configManager::inst()->loadConfigFile(); if( render_out.isEmpty() && file_to_save.isEmpty() ) {