From d9995f55488e0bd79ae8cbd8796e3ad7dc6a4612 Mon Sep 17 00:00:00 2001 From: Dave French Date: Sun, 8 Mar 2015 17:57:55 +0000 Subject: [PATCH] Add default path for SF2 added a default path for sf create folder add folder to setup dialog sf player now uses this location --- include/ConfigManager.h | 8 ++++++ include/SetupDialog.h | 6 ++++- plugins/sf2_player/sf2_player.cpp | 4 +-- src/core/ConfigManager.cpp | 9 +++++++ src/gui/SetupDialog.cpp | 44 ++++++++++++++++++++++++++++++- 5 files changed, 67 insertions(+), 4 deletions(-) diff --git a/include/ConfigManager.h b/include/ConfigManager.h index 5eeda6a80..026a64d02 100644 --- a/include/ConfigManager.h +++ b/include/ConfigManager.h @@ -44,6 +44,7 @@ const QString PROJECTS_PATH = "projects/"; const QString PRESETS_PATH = "presets/"; const QString SAMPLES_PATH = "samples/"; const QString GIG_PATH = "samples/gig"; +const QString SF2_PATH = "samples/sf2"; const QString DEFAULT_THEME_PATH = "themes/default/"; const QString TRACK_ICON_PATH = "track_icons/"; const QString LOCALE_PATH = "locale/"; @@ -137,6 +138,11 @@ public: return m_gigDir; } + const QString & sf2Dir() const + { + return m_sf2Dir; + } + const QString & pluginDir() const { return m_pluginDir; @@ -212,6 +218,7 @@ public: void setDefaultSoundfont( const QString & _sf ); void setBackgroundArtwork( const QString & _ba ); void setGIGDir( const QString & gd ); + void setSF2Dir( const QString & sfd ); private: @@ -233,6 +240,7 @@ private: QString m_flDir; QString m_ladDir; QString m_gigDir; + QString m_sf2Dir; QString m_version; #ifdef LMMS_HAVE_STK QString m_stkDir; diff --git a/include/SetupDialog.h b/include/SetupDialog.h index 2744c2756..3357bf54c 100644 --- a/include/SetupDialog.h +++ b/include/SetupDialog.h @@ -72,7 +72,8 @@ private slots: // path settings widget void setWorkingDir( const QString & _wd ); void setVSTDir( const QString & _vd ); - void setGIGDir( const QString & _gd); + void setGIGDir( const QString & _gd ); + void setSF2Dir( const QString & _sfd ); void setArtworkDir( const QString & _ad ); void setFLDir( const QString & _fd ); void setLADSPADir( const QString & _ld ); @@ -99,6 +100,7 @@ private slots: void openWorkingDir(); void openVSTDir(); void openGIGDir(); + void openSF2Dir(); void openArtworkDir(); void openFLDir(); void openLADSPADir(); @@ -142,6 +144,7 @@ private: QLineEdit * m_fdLineEdit; QLineEdit * m_ladLineEdit; QLineEdit * m_gigLineEdit; + QLineEdit * m_sf2LineEdit; #ifdef LMMS_HAVE_FLUIDSYNTH QLineEdit * m_sfLineEdit; #endif @@ -156,6 +159,7 @@ private: QString m_flDir; QString m_ladDir; QString m_gigDir; + QString m_sf2Dir; #ifdef LMMS_HAVE_FLUIDSYNTH QString m_defaultSoundfont; #endif diff --git a/plugins/sf2_player/sf2_player.cpp b/plugins/sf2_player/sf2_player.cpp index f2acd2f07..90264abed 100644 --- a/plugins/sf2_player/sf2_player.cpp +++ b/plugins/sf2_player/sf2_player.cpp @@ -1068,7 +1068,7 @@ void sf2InstrumentView::showFileDialog() QString f = k->m_filename; if( QFileInfo( f ).isRelative() ) { - f = ConfigManager::inst()->userSamplesDir() + f; + f = ConfigManager::inst()->sf2Dir() + f; if( QFileInfo( f ).exists() == false ) { f = ConfigManager::inst()->factorySamplesDir() + k->m_filename; @@ -1079,7 +1079,7 @@ void sf2InstrumentView::showFileDialog() } else { - ofd.setDirectory( ConfigManager::inst()->userSamplesDir() ); + ofd.setDirectory( ConfigManager::inst()->sf2Dir() ); } m_fileDialogButton->setEnabled( false ); diff --git a/src/core/ConfigManager.cpp b/src/core/ConfigManager.cpp index 6e77640b5..a7328e5ee 100644 --- a/src/core/ConfigManager.cpp +++ b/src/core/ConfigManager.cpp @@ -68,6 +68,7 @@ ConfigManager::ConfigManager() : m_vstDir( m_workingDir + "vst" + QDir::separator() ), m_flDir( QDir::home().absolutePath() ), m_gigDir( m_workingDir + GIG_PATH ), + m_sf2Dir( m_workingDir + SF2_PATH ), m_version( defaultVersion() ) { } @@ -185,6 +186,11 @@ void ConfigManager::setGIGDir(const QString &gd) m_gigDir = gd; } +void ConfigManager::setSF2Dir(const QString &sfd) +{ + m_sf2Dir = sfd; +} + @@ -347,6 +353,7 @@ void ConfigManager::loadConfigFile() setWorkingDir( value( "paths", "workingdir" ) ); setGIGDir( value( "paths", "gigdir" ) == "" ? gigDir() : value( "paths", "gigdir" ) ); + setSF2Dir( value( "paths", "sf2dir" ) == "" ? sf2Dir() : value( "paths", "sf2dir" ) ); setVSTDir( value( "paths", "vstdir" ) ); setFLDir( value( "paths", "fldir" ) ); setLADSPADir( value( "paths", "laddir" ) ); @@ -434,6 +441,7 @@ void ConfigManager::loadConfigFile() QDir().mkpath( userSamplesDir() ); QDir().mkpath( userPresetsDir() ); QDir().mkpath( userGigDir() ); + QDir().mkpath( sf2Dir() ); } upgrade(); @@ -449,6 +457,7 @@ void ConfigManager::saveConfigFile() setValue( "paths", "vstdir", m_vstDir ); setValue( "paths", "fldir", m_flDir ); setValue( "paths", "gigdir", m_gigDir ); + setValue( "paths", "sf2dir", m_sf2Dir ); setValue( "paths", "laddir", m_ladDir ); #ifdef LMMS_HAVE_STK setValue( "paths", "stkdir", m_stkDir ); diff --git a/src/gui/SetupDialog.cpp b/src/gui/SetupDialog.cpp index 064a263e8..9cbd1a6fa 100644 --- a/src/gui/SetupDialog.cpp +++ b/src/gui/SetupDialog.cpp @@ -107,6 +107,7 @@ SetupDialog::SetupDialog( ConfigTabs _tab_to_open ) : m_flDir( QDir::toNativeSeparators( ConfigManager::inst()->flDir() ) ), m_ladDir( QDir::toNativeSeparators( ConfigManager::inst()->ladspaDir() ) ), m_gigDir( QDir::toNativeSeparators( ConfigManager::inst()->gigDir() ) ), + m_sf2Dir( QDir::toNativeSeparators( ConfigManager::inst()->sf2Dir() ) ), #ifdef LMMS_HAVE_FLUIDSYNTH m_defaultSoundfont( QDir::toNativeSeparators( ConfigManager::inst()->defaultSoundfont() ) ), #endif @@ -392,7 +393,7 @@ SetupDialog::SetupDialog( ConfigTabs _tab_to_open ) : QVBoxLayout *pathSelectorLayout = new QVBoxLayout; pathScroll->setVerticalScrollBarPolicy( Qt::ScrollBarAlwaysOn ); pathScroll->setHorizontalScrollBarPolicy( Qt::ScrollBarAlwaysOff ); - pathScroll->resize( 360, pathsHeight - 50 ); + pathScroll->resize( 362, pathsHeight - 50 ); pathScroll->move( 0, 30 ); pathSelectors->resize( 360, pathsHeight - 50 ); @@ -521,6 +522,27 @@ SetupDialog::SetupDialog( ConfigTabs _tab_to_open ) : connect( gigdir_select_btn, SIGNAL( clicked() ), this, SLOT( openGIGDir() ) ); + // sf2-dir + TabWidget * sf2_tw = new TabWidget( tr( + "SF2 directory" ).toUpper(), + pathSelectors ); + sf2_tw->setFixedHeight( 48 ); + + m_sf2LineEdit = new QLineEdit( m_sf2Dir, sf2_tw ); + m_sf2LineEdit->setGeometry( 10, 20, txtLength, 16 ); + connect( m_sf2LineEdit, SIGNAL( textChanged( const QString & ) ), this, + SLOT( setSF2Dir( const QString & ) ) ); + + QPushButton * sf2dir_select_btn = new QPushButton( + embed::getIconPixmap( "project_open", 16, 16 ), + "", sf2_tw ); + sf2dir_select_btn->setFixedSize( 24, 24 ); + sf2dir_select_btn->move( btnStart, 16 ); + connect( sf2dir_select_btn, SIGNAL( clicked() ), this, + SLOT( openSF2Dir() ) ); + + + // LADSPA-dir TabWidget * lad_tw = new TabWidget( tr( "LADSPA plugin directories" ).toUpper(), @@ -588,6 +610,8 @@ SetupDialog::SetupDialog( ConfigTabs _tab_to_open ) : pathSelectorLayout->addSpacing( 10 ); pathSelectorLayout->addWidget( gig_tw ); pathSelectorLayout->addSpacing( 10 ); + pathSelectorLayout->addWidget( sf2_tw ); + pathSelectorLayout->addSpacing( 10 ); pathSelectorLayout->addWidget( artwork_tw ); pathSelectorLayout->addSpacing( 10 ); pathSelectorLayout->addWidget( backgroundArtwork_tw ); @@ -610,6 +634,7 @@ SetupDialog::SetupDialog( ConfigTabs _tab_to_open ) : dir_layout->addWidget( pathSelectors ); pathScroll->setWidget( pathSelectors ); + pathScroll->setWidgetResizable( true ); @@ -954,6 +979,7 @@ void SetupDialog::accept() ConfigManager::inst()->setWorkingDir( m_workingDir ); ConfigManager::inst()->setVSTDir( m_vstDir ); ConfigManager::inst()->setGIGDir( m_gigDir ); + ConfigManager::inst()->setSF2Dir( m_sf2Dir ); ConfigManager::inst()->setArtworkDir( m_artworkDir ); ConfigManager::inst()->setFLDir( m_flDir ); ConfigManager::inst()->setLADSPADir( m_ladDir ); @@ -1188,6 +1214,17 @@ void SetupDialog::openGIGDir() } } +void SetupDialog::openSF2Dir() +{ + QString new_dir = FileDialog::getExistingDirectory( this, + tr( "Choose your SF2 directory" ), + m_sf2Dir ); + if( new_dir != QString::null ) + { + m_sf2LineEdit->setText( new_dir ); + } +} + @@ -1220,7 +1257,12 @@ void SetupDialog::setVSTDir( const QString & _vd ) void SetupDialog::setGIGDir(const QString &_gd) { + m_gigDir = _gd; +} +void SetupDialog::setSF2Dir(const QString &_sfd) +{ + m_sf2Dir = _sfd; }