diff --git a/ChangeLog b/ChangeLog index d5d8af559..5a10b6016 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,11 @@ +2008-09-21 Paul Giblock + * include/config_mgr.h: + * include/setup_dialog.h: + * src/gui/main_window.cpp: + * src/gui/setup_dialog.cpp: + * src/core/config_mgr.cpp: + Add support for user-configurable backgound artwork + 2008-09-20 Paul Giblock * plugins/sf2_player/sf2_player.cpp: diff --git a/include/config_mgr.h b/include/config_mgr.h index 7f47bce74..bbe16b09d 100644 --- a/include/config_mgr.h +++ b/include/config_mgr.h @@ -153,6 +153,11 @@ public: } #endif + const QString & backgroundArtwork( void ) const + { + return( m_backgroundArtwork ); + } + inline const QStringList & recentlyOpenedProjects( void ) const { return( m_recentlyOpenedProjects ); @@ -176,6 +181,7 @@ public: void setLADSPADir( const QString & _fd ); void setSTKDir( const QString & _fd ); void setDefaultSoundfont( const QString & _sf ); + void setBackgroundArtwork( const QString & _ba ); private: @@ -200,6 +206,7 @@ private: #ifdef LMMS_HAVE_FLUIDSYNTH QString m_defaultSoundfont; #endif + QString m_backgroundArtwork; QStringList m_recentlyOpenedProjects; diff --git a/include/setup_dialog.h b/include/setup_dialog.h index 9c548706d..4c8b700e8 100644 --- a/include/setup_dialog.h +++ b/include/setup_dialog.h @@ -74,9 +74,10 @@ private slots: void setVSTDir( const QString & _vd ); void setArtworkDir( const QString & _ad ); void setFLDir( const QString & _fd ); - void setLADSPADir( const QString & _fd ); - void setSTKDir( const QString & _fd ); - void setDefaultSoundfont( const QString & _fd ); + void setLADSPADir( const QString & _ld ); + void setSTKDir( const QString & _sd ); + void setDefaultSoundfont( const QString & _sf ); + void setBackgroundArtwork( const QString & _ba ); // audio settings widget void audioInterfaceChanged( const QString & _driver ); @@ -100,6 +101,7 @@ private slots: void openLADSPADir( void ); void openSTKDir( void ); void openDefaultSoundfont( void ); + void openBackgroundArtwork( void ); void toggleDisableChActInd( bool _disabled ); void toggleManualChPiano( bool _enabled ); @@ -130,6 +132,7 @@ private: #ifdef LMMS_HAVE_STK QLineEdit * m_stkLineEdit; #endif + QLineEdit * m_baLineEdit; QString m_workingDir; QString m_vstDir; @@ -142,6 +145,7 @@ private: #ifdef LMMS_HAVE_STK QString m_stkDir; #endif + QString m_backgroundArtwork; bool m_disableChActInd; bool m_manualChPiano; diff --git a/src/core/config_mgr.cpp b/src/core/config_mgr.cpp index 6896e6678..f17637776 100644 --- a/src/core/config_mgr.cpp +++ b/src/core/config_mgr.cpp @@ -144,6 +144,16 @@ void configManager::setDefaultSoundfont( const QString & _sf ) +void configManager::setBackgroundArtwork( const QString & _ba ) +{ +#ifdef LMMS_HAVE_FLUIDSYNTH + m_backgroundArtwork = _ba; +#endif +} + + + + void configManager::addRecentlyOpenedProject( const QString & _file ) { m_recentlyOpenedProjects.removeAll( _file ); @@ -278,6 +288,7 @@ void configManager::loadConfigFile( void ) #ifdef LMMS_HAVE_FLUIDSYNTH setDefaultSoundfont( value( "paths", "defaultsf2" ) ); #endif + setBackgroundArtwork( value( "paths", "backgroundartwork" ) ); } cfg_file.close(); } @@ -350,6 +361,7 @@ void configManager::saveConfigFile( void ) #ifdef LMMS_HAVE_FLUIDSYNTH setValue( "paths", "defaultsf2", m_defaultSoundfont ); #endif + setValue( "paths", "backgroundartwork", m_backgroundArtwork ); QDomDocument doc( "lmms-config-file" ); diff --git a/src/gui/main_window.cpp b/src/gui/main_window.cpp index f1af1113e..2c2ef51d3 100644 --- a/src/gui/main_window.cpp +++ b/src/gui/main_window.cpp @@ -124,7 +124,23 @@ mainWindow::mainWindow( void ) : splitter ), ++id ); m_workspace = new QMdiArea( splitter ); - m_workspace->setBackground( Qt::NoBrush ); + + // Load background + QString bgArtwork = configManager::inst()->backgroundArtwork(); + QImage bgImage; + if( !bgArtwork.isEmpty() ) + { + bgImage = QImage( bgArtwork ); + } + if( !bgImage.isNull() ) + { + m_workspace->setBackground( bgImage ); + } + else + { + m_workspace->setBackground( Qt::NoBrush ); + } + m_workspace->setOption( QMdiArea::DontMaximizeSubWindowOnActivation ); m_workspace->setHorizontalScrollBarPolicy( Qt::ScrollBarAsNeeded ); m_workspace->setVerticalScrollBarPolicy( Qt::ScrollBarAsNeeded ); diff --git a/src/gui/setup_dialog.cpp b/src/gui/setup_dialog.cpp index c9ec0f8ff..c857aac87 100644 --- a/src/gui/setup_dialog.cpp +++ b/src/gui/setup_dialog.cpp @@ -27,6 +27,7 @@ #include #include +#include #include #include #include @@ -109,6 +110,7 @@ setupDialog::setupDialog( ConfigTabs _tab_to_open ) : #ifdef LMMS_HAVE_STK m_stkDir( configManager::inst()->stkDir() ), #endif + m_backgroundArtwork( configManager::inst()->backgroundArtwork() ), m_disableChActInd( configManager::inst()->value( "ui", "disablechannelactivityindicators" ).toInt() ), m_manualChPiano( configManager::inst()->value( "ui", @@ -235,14 +237,14 @@ setupDialog::setupDialog( ConfigTabs _tab_to_open ) : QWidget * paths = new QWidget( ws ); - int pathsHeight = 296; + int pathsHeight = 346; #ifdef LMMS_HAVE_STK pathsHeight += 50; #endif #ifdef LMMS_HAVE_FLUIDSYNTH pathsHeight += 50; #endif - paths->setFixedSize( 360, pathsHeight ); + paths->setFixedSize( 410, pathsHeight ); QVBoxLayout * dir_layout = new QVBoxLayout( paths ); dir_layout->setSpacing( 0 ); dir_layout->setMargin( 0 ); @@ -307,6 +309,28 @@ setupDialog::setupDialog( ConfigTabs _tab_to_open ) : + // background artwork file + tabWidget * backgroundArtwork_tw = new tabWidget( tr( + "Background artwork" ).toUpper(), paths ); + backgroundArtwork_tw->setFixedHeight( 48 ); + + m_baLineEdit = new QLineEdit( m_backgroundArtwork, + backgroundArtwork_tw ); + m_baLineEdit->setGeometry( 10, 20, 300, 16 ); + connect( m_baLineEdit, SIGNAL( textChanged( const QString & ) ), this, + SLOT( setBackgroundArtwork( const QString & ) ) ); + + QPushButton * backgroundartworkdir_select_btn = new QPushButton( + embed::getIconPixmap( "project_open", 16, 16 ), + "", backgroundArtwork_tw ); + backgroundartworkdir_select_btn->setFixedSize( 24, 24 ); + backgroundartworkdir_select_btn->move( 320, 16 ); + connect( backgroundartworkdir_select_btn, SIGNAL( clicked() ), this, + SLOT( openBackgroundArtwork() ) ); + + + + // FL Studio-dir tabWidget * fl_tw = new tabWidget( tr( @@ -393,6 +417,8 @@ setupDialog::setupDialog( ConfigTabs _tab_to_open ) : dir_layout->addSpacing( 10 ); dir_layout->addWidget( artwork_tw ); dir_layout->addSpacing( 10 ); + dir_layout->addWidget( backgroundArtwork_tw ); + dir_layout->addSpacing( 10 ); dir_layout->addWidget( fl_tw ); dir_layout->addSpacing( 10 ); dir_layout->addWidget( lad_tw ); @@ -718,6 +744,7 @@ void setupDialog::accept( void ) #ifdef LMMS_HAVE_STK configManager::inst()->setSTKDir( m_stkDir ); #endif + configManager::inst()->setBackgroundArtwork( m_backgroundArtwork ); // tell all audio-settings-widget to save their settings for( aswMap::iterator it = m_audioIfaceSetupWidgets.begin(); @@ -983,7 +1010,7 @@ void setupDialog::openDefaultSoundfont( void ) { #ifdef LMMS_HAVE_FLUIDSYNTH QString new_file = QFileDialog::getOpenFileName( this, - tr( "Choose defeault SoundFont" ), m_defaultSoundfont, + tr( "Choose default SoundFont" ), m_defaultSoundfont, "SoundFont2 Files (*.sf2)" ); if( new_file != QString::null ) @@ -996,6 +1023,38 @@ void setupDialog::openDefaultSoundfont( void ) +void setupDialog::openBackgroundArtwork( void ) +{ + QList fileTypesList = QImageReader::supportedImageFormats(); + QString fileTypes; + for( int i = 0; i < fileTypesList.count(); i++ ) + { + if( fileTypesList[i] != fileTypesList[i].toUpper() ) + { + if( !fileTypes.isEmpty() ) + { + fileTypes += " "; + } + fileTypes += "*." + QString( fileTypesList[i] ); + } + } + + QString dir = ( m_backgroundArtwork.isEmpty() ) ? + m_artworkDir : + m_backgroundArtwork; + QString new_file = QFileDialog::getOpenFileName( this, + tr( "Choose background artwork" ), dir, + "Image Files (" + fileTypes + ")" ); + + if( new_file != QString::null ) + { + m_baLineEdit->setText( new_file ); + } +} + + + + void setupDialog::setFLDir( const QString & _fd ) { m_flDir = _fd; @@ -1032,6 +1091,16 @@ void setupDialog::setDefaultSoundfont( const QString & _sf ) +void setupDialog::setBackgroundArtwork( const QString & _ba ) +{ +#ifdef LMMS_HAVE_FLUIDSYNTH + m_backgroundArtwork = _ba; +#endif +} + + + + void setupDialog::audioInterfaceChanged( const QString & _iface ) { for( aswMap::iterator it = m_audioIfaceSetupWidgets.begin();