From 2271af81c41adf8faecfa26e8f1cb491ebaa221f Mon Sep 17 00:00:00 2001 From: Dave French Date: Fri, 6 Mar 2015 18:56:15 +0000 Subject: [PATCH] Added a Gig directory to user lmms folder Added option to set gig folder in setup dialog Gig player now opens at this location --- include/ConfigManager.h | 13 +++++++++++ include/SetupDialog.h | 4 ++++ plugins/GigPlayer/GigPlayer.cpp | 4 ++-- src/core/ConfigManager.cpp | 10 +++++++++ src/gui/SetupDialog.cpp | 39 +++++++++++++++++++++++++++++++++ 5 files changed, 68 insertions(+), 2 deletions(-) diff --git a/include/ConfigManager.h b/include/ConfigManager.h index 36fbdebb5..5eeda6a80 100644 --- a/include/ConfigManager.h +++ b/include/ConfigManager.h @@ -43,6 +43,7 @@ class Engine; const QString PROJECTS_PATH = "projects/"; const QString PRESETS_PATH = "presets/"; const QString SAMPLES_PATH = "samples/"; +const QString GIG_PATH = "samples/gig"; const QString DEFAULT_THEME_PATH = "themes/default/"; const QString TRACK_ICON_PATH = "track_icons/"; const QString LOCALE_PATH = "locale/"; @@ -86,6 +87,11 @@ public: return workingDir() + SAMPLES_PATH; } + QString userGigDir() const + { + return workingDir() + GIG_PATH; + } + QString factoryProjectsDir() const { return dataDir() + PROJECTS_PATH; @@ -126,6 +132,11 @@ public: return m_dataDir + LOCALE_PATH; } + const QString & gigDir() const + { + return m_gigDir; + } + const QString & pluginDir() const { return m_pluginDir; @@ -200,6 +211,7 @@ public: void setSTKDir( const QString & _fd ); void setDefaultSoundfont( const QString & _sf ); void setBackgroundArtwork( const QString & _ba ); + void setGIGDir( const QString & gd ); private: @@ -220,6 +232,7 @@ private: QString m_vstDir; QString m_flDir; QString m_ladDir; + QString m_gigDir; QString m_version; #ifdef LMMS_HAVE_STK QString m_stkDir; diff --git a/include/SetupDialog.h b/include/SetupDialog.h index 77b4cc753..2744c2756 100644 --- a/include/SetupDialog.h +++ b/include/SetupDialog.h @@ -72,6 +72,7 @@ private slots: // path settings widget void setWorkingDir( const QString & _wd ); void setVSTDir( const QString & _vd ); + void setGIGDir( const QString & _gd); void setArtworkDir( const QString & _ad ); void setFLDir( const QString & _fd ); void setLADSPADir( const QString & _ld ); @@ -97,6 +98,7 @@ private slots: void openWorkingDir(); void openVSTDir(); + void openGIGDir(); void openArtworkDir(); void openFLDir(); void openLADSPADir(); @@ -139,6 +141,7 @@ private: QLineEdit * m_adLineEdit; QLineEdit * m_fdLineEdit; QLineEdit * m_ladLineEdit; + QLineEdit * m_gigLineEdit; #ifdef LMMS_HAVE_FLUIDSYNTH QLineEdit * m_sfLineEdit; #endif @@ -152,6 +155,7 @@ private: QString m_artworkDir; QString m_flDir; QString m_ladDir; + QString m_gigDir; #ifdef LMMS_HAVE_FLUIDSYNTH QString m_defaultSoundfont; #endif diff --git a/plugins/GigPlayer/GigPlayer.cpp b/plugins/GigPlayer/GigPlayer.cpp index 8d17b1f2e..22d539a63 100644 --- a/plugins/GigPlayer/GigPlayer.cpp +++ b/plugins/GigPlayer/GigPlayer.cpp @@ -1069,7 +1069,7 @@ void GigInstrumentView::showFileDialog() if( QFileInfo( f ).isRelative() ) { - f = ConfigManager::inst()->userSamplesDir() + f; + f = ConfigManager::inst()->gigDir() + f; if( QFileInfo( f ).exists() == false ) { @@ -1082,7 +1082,7 @@ void GigInstrumentView::showFileDialog() } else { - ofd.setDirectory( ConfigManager::inst()->userSamplesDir() ); + ofd.setDirectory( ConfigManager::inst()->gigDir() ); } m_fileDialogButton->setEnabled( false ); diff --git a/src/core/ConfigManager.cpp b/src/core/ConfigManager.cpp index 1254977f0..6e77640b5 100644 --- a/src/core/ConfigManager.cpp +++ b/src/core/ConfigManager.cpp @@ -67,6 +67,7 @@ ConfigManager::ConfigManager() : #endif m_vstDir( m_workingDir + "vst" + QDir::separator() ), m_flDir( QDir::home().absolutePath() ), + m_gigDir( m_workingDir + GIG_PATH ), m_version( defaultVersion() ) { } @@ -179,6 +180,11 @@ void ConfigManager::setBackgroundArtwork( const QString & _ba ) #endif } +void ConfigManager::setGIGDir(const QString &gd) +{ + m_gigDir = gd; +} + @@ -339,6 +345,8 @@ void ConfigManager::loadConfigFile() } } setWorkingDir( value( "paths", "workingdir" ) ); + + setGIGDir( value( "paths", "gigdir" ) == "" ? gigDir() : value( "paths", "gigdir" ) ); setVSTDir( value( "paths", "vstdir" ) ); setFLDir( value( "paths", "fldir" ) ); setLADSPADir( value( "paths", "laddir" ) ); @@ -425,6 +433,7 @@ void ConfigManager::loadConfigFile() QDir().mkpath( userProjectsDir() ); QDir().mkpath( userSamplesDir() ); QDir().mkpath( userPresetsDir() ); + QDir().mkpath( userGigDir() ); } upgrade(); @@ -439,6 +448,7 @@ void ConfigManager::saveConfigFile() setValue( "paths", "workingdir", m_workingDir ); setValue( "paths", "vstdir", m_vstDir ); setValue( "paths", "fldir", m_flDir ); + setValue( "paths", "gigdir", m_gigDir ); 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 c58a50c32..edd8b63ff 100644 --- a/src/gui/SetupDialog.cpp +++ b/src/gui/SetupDialog.cpp @@ -106,6 +106,7 @@ SetupDialog::SetupDialog( ConfigTabs _tab_to_open ) : m_artworkDir( QDir::toNativeSeparators( ConfigManager::inst()->artworkDir() ) ), m_flDir( QDir::toNativeSeparators( ConfigManager::inst()->flDir() ) ), m_ladDir( QDir::toNativeSeparators( ConfigManager::inst()->ladspaDir() ) ), + m_gigDir( QDir::toNativeSeparators( ConfigManager::inst()->gigDir() ) ), #ifdef LMMS_HAVE_FLUIDSYNTH m_defaultSoundfont( QDir::toNativeSeparators( ConfigManager::inst()->defaultSoundfont() ) ), #endif @@ -501,6 +502,25 @@ SetupDialog::SetupDialog( ConfigTabs _tab_to_open ) : connect( vstdir_select_btn, SIGNAL( clicked() ), this, SLOT( openVSTDir() ) ); + // gig-dir + TabWidget * gig_tw = new TabWidget( tr( + "GIG directory" ).toUpper(), + pathSelectors ); + gig_tw->setFixedHeight( 48 ); + + m_gigLineEdit = new QLineEdit( m_gigDir, gig_tw ); + m_gigLineEdit->setGeometry( 10, 20, txtLength, 16 ); + connect( m_gigLineEdit, SIGNAL( textChanged( const QString & ) ), this, + SLOT( setGIGDir( const QString & ) ) ); + + QPushButton * gigdir_select_btn = new QPushButton( + embed::getIconPixmap( "project_open", 16, 16 ), + "", gig_tw ); + gigdir_select_btn->setFixedSize( 24, 24 ); + gigdir_select_btn->move( btnStart, 16 ); + connect( gigdir_select_btn, SIGNAL( clicked() ), this, + SLOT( openGIGDir() ) ); + // LADSPA-dir TabWidget * lad_tw = new TabWidget( tr( "LADSPA plugin directories" ).toUpper(), @@ -566,6 +586,8 @@ SetupDialog::SetupDialog( ConfigTabs _tab_to_open ) : pathSelectorLayout->addWidget( lmms_wd_tw ); pathSelectorLayout->addSpacing( 10 ); + pathSelectorLayout->addWidget( gig_tw ); + pathSelectorLayout->addSpacing( 10 ); pathSelectorLayout->addWidget( artwork_tw ); pathSelectorLayout->addSpacing( 10 ); pathSelectorLayout->addWidget( backgroundArtwork_tw ); @@ -931,6 +953,7 @@ void SetupDialog::accept() ConfigManager::inst()->setWorkingDir( m_workingDir ); ConfigManager::inst()->setVSTDir( m_vstDir ); + ConfigManager::inst()->setGIGDir( m_gigDir ); ConfigManager::inst()->setArtworkDir( m_artworkDir ); ConfigManager::inst()->setFLDir( m_flDir ); ConfigManager::inst()->setLADSPADir( m_ladDir ); @@ -1154,6 +1177,17 @@ void SetupDialog::openWorkingDir() } } +void SetupDialog::openGIGDir() +{ + QString new_dir = FileDialog::getExistingDirectory( this, + tr( "Choose your GIG directory" ), + m_gigDir ); + if( new_dir != QString::null ) + { + m_gigLineEdit->setText( new_dir ); + } +} + @@ -1184,6 +1218,11 @@ void SetupDialog::setVSTDir( const QString & _vd ) m_vstDir = _vd; } +void SetupDialog::setGIGDir(const QString &_gd) +{ + +} +