From 697aebc056a0ca31087dd92ad711117f35c2d6d8 Mon Sep 17 00:00:00 2001 From: Colin Wallace Date: Sun, 23 Aug 2015 16:54:40 -0700 Subject: [PATCH 1/4] Consolidate midi config widgets & move them out of the core --- include/MidiAlsaRaw.h | 17 +++------ include/MidiAlsaSeq.h | 21 ++++------- include/MidiApple.h | 24 +++++-------- include/MidiClient.h | 26 -------------- include/MidiDummy.h | 31 +++++----------- include/MidiOss.h | 18 +++------- include/MidiSetupWidget.h | 56 +++++++++++++++++++++++++++++ include/MidiWinMM.h | 25 ++++++------- include/SetupDialog.h | 3 +- src/core/midi/MidiAlsaRaw.cpp | 36 +------------------ src/core/midi/MidiAlsaSeq.cpp | 39 -------------------- src/core/midi/MidiApple.cpp | 16 --------- src/core/midi/MidiOss.cpp | 35 ------------------ src/core/midi/MidiWinMM.cpp | 23 ------------ src/gui/CMakeLists.txt | 1 + src/gui/MidiSetupWidget.cpp | 68 +++++++++++++++++++++++++++++++++++ src/gui/SetupDialog.cpp | 12 +++---- 17 files changed, 175 insertions(+), 276 deletions(-) create mode 100644 include/MidiSetupWidget.h create mode 100644 src/gui/MidiSetupWidget.cpp diff --git a/include/MidiAlsaRaw.h b/include/MidiAlsaRaw.h index 2c1a938e6..dd86dfaaa 100644 --- a/include/MidiAlsaRaw.h +++ b/include/MidiAlsaRaw.h @@ -51,23 +51,14 @@ public: inline static QString name() { - return QT_TRANSLATE_NOOP( "setupWidget", + return QT_TRANSLATE_NOOP( "MidiSetupWidget", "ALSA Raw-MIDI (Advanced Linux Sound Architecture)" ); } - - class setupWidget : public MidiClientRaw::setupWidget + inline static QString configSection() { - public: - setupWidget( QWidget * _parent ); - virtual ~setupWidget(); - - virtual void saveSettings(); - - private: - QLineEdit * m_device; - - } ; + return "MidiAlsaRaw"; + } protected: diff --git a/include/MidiAlsaSeq.h b/include/MidiAlsaSeq.h index 9e399a011..c2607c80c 100644 --- a/include/MidiAlsaSeq.h +++ b/include/MidiAlsaSeq.h @@ -54,11 +54,16 @@ public: inline static QString name() { - return QT_TRANSLATE_NOOP( "setupWidget", + return QT_TRANSLATE_NOOP( "MidiSetupWidget", "ALSA-Sequencer (Advanced Linux Sound " "Architecture)" ); } + inline static QString configSection() + { + return "Midialsaseq"; + } + virtual void processOutEvent( const MidiEvent & _me, @@ -107,20 +112,6 @@ public: } - class setupWidget : public MidiClient::setupWidget - { - public: - setupWidget( QWidget * _parent ); - virtual ~setupWidget(); - - virtual void saveSettings(); - - private: - QLineEdit * m_device; - - } ; - - private slots: void changeQueueTempo( bpm_t _bpm ); void updatePortList(); diff --git a/include/MidiApple.h b/include/MidiApple.h index d392df110..3536be928 100644 --- a/include/MidiApple.h +++ b/include/MidiApple.h @@ -45,12 +45,18 @@ public: MidiApple(); virtual ~MidiApple(); - static QString probeDevice(); - + inline static QString probeDevice() + { + return QString::Null(); // no midi device name + } inline static QString name() { - return QT_TRANSLATE_NOOP( "setupWidget", "Apple MIDI" ); + return QT_TRANSLATE_NOOP( "MidiSetupWidget", "Apple MIDI" ); + } + inline static QString configSection() + { + return QString::Null(); // no configuration settings } virtual void processOutEvent( const MidiEvent & _me, @@ -106,18 +112,6 @@ public: } - class setupWidget : public MidiClient::setupWidget - { - public: - setupWidget( QWidget * _parent ); - virtual ~setupWidget(); - - void saveSettings() - { - } - } ; - - private:// slots: void updateDeviceList(); diff --git a/include/MidiClient.h b/include/MidiClient.h index 09e4a07ae..c3de096a3 100644 --- a/include/MidiClient.h +++ b/include/MidiClient.h @@ -106,32 +106,6 @@ public: // any other working static MidiClient * openMidiClient(); - - class setupWidget : public TabWidget - { - public: - setupWidget( const QString & _caption, QWidget * _parent ) : - TabWidget( TabWidget::tr( "Settings for %1" ).arg( - tr( _caption.toLatin1() ) ).toUpper(), - _parent ) - { - } - - virtual ~setupWidget() - { - } - - virtual void saveSettings() = 0; - - virtual void show() - { - parentWidget()->show(); - QWidget::show(); - } - - } ; - - protected: QVector m_midiPorts; diff --git a/include/MidiDummy.h b/include/MidiDummy.h index c2c07911d..704b1bc45 100644 --- a/include/MidiDummy.h +++ b/include/MidiDummy.h @@ -40,34 +40,19 @@ public: inline static QString name() { - return( QT_TRANSLATE_NOOP( "setupWidget", + return( QT_TRANSLATE_NOOP( "MidiSetupWidget", "Dummy (no MIDI support)" ) ); } - - class setupWidget : public MidiClient::setupWidget + inline static QString probeDevice() { - public: - setupWidget( QWidget * _parent ) : - MidiClientRaw::setupWidget( MidiDummy::name(), _parent ) - { - } + return QString::Null(); // no midi device name + } - virtual ~setupWidget() - { - } - - virtual void saveSettings() - { - } - - virtual void show() - { - parentWidget()->hide(); - QWidget::show(); - } - - } ; + inline static QString configSection() + { + return QString::Null(); // no configuration settings + } protected: diff --git a/include/MidiOss.h b/include/MidiOss.h index 83bc6e672..a7ad740ac 100644 --- a/include/MidiOss.h +++ b/include/MidiOss.h @@ -49,24 +49,14 @@ public: inline static QString name() { - return( QT_TRANSLATE_NOOP( "setupWidget", + return( QT_TRANSLATE_NOOP( "MidiSetupWidget", "OSS Raw-MIDI (Open Sound System)" ) ); } - - class setupWidget : public MidiClientRaw::setupWidget + inline static QString configSection() { - public: - setupWidget( QWidget * _parent ); - virtual ~setupWidget(); - - virtual void saveSettings(); - - private: - QLineEdit * m_device; - - } ; - + return "midioss"; + } protected: virtual void sendByte( const unsigned char c ); diff --git a/include/MidiSetupWidget.h b/include/MidiSetupWidget.h new file mode 100644 index 000000000..5957333f4 --- /dev/null +++ b/include/MidiSetupWidget.h @@ -0,0 +1,56 @@ +/* + * MidiSetupWidget - class for configuring midi sources in the settings window + * + * Copyright (c) 2005-2014 Tobias Doerffel + * + * This file is part of LMMS - http://lmms.io + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public + * License along with this program (see COPYING); if not, write to the + * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301 USA. + * + */ + +#ifndef MIDISETUPWIDGET_H +#define MIDISETUPWIDGET_H + +#include + +#include "TabWidget.h" + +class QLineEdit; + +class MidiSetupWidget : public TabWidget +{ + MidiSetupWidget( const QString & caption, const QString & configSection, + const QString & devName, QWidget * parent ); +public: + // create a widget with editors for all of @MidiClientType's fields + template static MidiSetupWidget* create( QWidget * parent ) + { + QString configSection = MidiClientType::configSection(); + QString dev = MidiClientType::probeDevice(); + return new MidiSetupWidget(MidiClientType::name(), configSection, dev, parent); + } + + void saveSettings(); + + void show(); +private: + QString m_configSection; + QLineEdit *m_device; + +}; + +#endif diff --git a/include/MidiWinMM.h b/include/MidiWinMM.h index 9e5838034..93c74966e 100644 --- a/include/MidiWinMM.h +++ b/include/MidiWinMM.h @@ -45,12 +45,20 @@ public: MidiWinMM(); virtual ~MidiWinMM(); - static QString probeDevice(); + inline static QString probeDevice() + { + return QString::Null(); // no midi device name + } inline static QString name() { - return QT_TRANSLATE_NOOP( "setupWidget", "WinMM MIDI" ); + return QT_TRANSLATE_NOOP( "MidiSetupWidget", "WinMM MIDI" ); + } + + inline static QString configSection() + { + return QString::Null(); // no configuration settings } @@ -104,19 +112,6 @@ public: } - class setupWidget : public MidiClient::setupWidget - { - public: - setupWidget( QWidget * _parent ); - virtual ~setupWidget(); - - virtual void saveSettings() - { - } - - } ; - - private:// slots: void updateDeviceList(); diff --git a/include/SetupDialog.h b/include/SetupDialog.h index d5e1b6e57..d8857cab2 100644 --- a/include/SetupDialog.h +++ b/include/SetupDialog.h @@ -32,6 +32,7 @@ #include "lmmsconfig.h" #include "AudioDevice.h" #include "MidiClient.h" +#include "MidiSetupWidget.h" #include "AudioDeviceSetupWidget.h" @@ -181,7 +182,7 @@ private: bool m_disableAutoQuit; typedef QMap AswMap; - typedef QMap MswMap; + typedef QMap MswMap; typedef QMap trMap; QComboBox * m_audioInterfaces; diff --git a/src/core/midi/MidiAlsaRaw.cpp b/src/core/midi/MidiAlsaRaw.cpp index 534a7dd9f..8675264c8 100644 --- a/src/core/midi/MidiAlsaRaw.cpp +++ b/src/core/midi/MidiAlsaRaw.cpp @@ -22,9 +22,6 @@ * */ -#include -#include - #include "MidiAlsaRaw.h" #include "ConfigManager.h" #include "gui_templates.h" @@ -80,7 +77,7 @@ MidiAlsaRaw::~MidiAlsaRaw() QString MidiAlsaRaw::probeDevice() { - QString dev = ConfigManager::inst()->value( "MidiAlsaRaw", "Device" ); + QString dev = ConfigManager::inst()->value( "MidiAlsaRaw", "device" ); if( dev == "" ) { if( getenv( "MIDIDEV" ) != NULL ) @@ -173,36 +170,5 @@ void MidiAlsaRaw::run() } - - - -MidiAlsaRaw::setupWidget::setupWidget( QWidget * _parent ) : - MidiClientRaw::setupWidget( MidiAlsaRaw::name(), _parent ) -{ - m_device = new QLineEdit( MidiAlsaRaw::probeDevice(), this ); - m_device->setGeometry( 10, 20, 160, 20 ); - - QLabel * dev_lbl = new QLabel( tr( "DEVICE" ), this ); - dev_lbl->setFont( pointSize<7>( dev_lbl->font() ) ); - dev_lbl->setGeometry( 10, 40, 160, 10 ); -} - - - - -MidiAlsaRaw::setupWidget::~setupWidget() -{ -} - - - - -void MidiAlsaRaw::setupWidget::saveSettings() -{ - ConfigManager::inst()->setValue( "MidiAlsaRaw", "Device", - m_device->text() ); -} - - #endif diff --git a/src/core/midi/MidiAlsaSeq.cpp b/src/core/midi/MidiAlsaSeq.cpp index 09523d77b..7c173efb1 100644 --- a/src/core/midi/MidiAlsaSeq.cpp +++ b/src/core/midi/MidiAlsaSeq.cpp @@ -22,9 +22,6 @@ * */ -#include -#include - #include "MidiAlsaSeq.h" #include "ConfigManager.h" #include "Engine.h" @@ -702,41 +699,5 @@ void MidiAlsaSeq::updatePortList() } - - - - - -MidiAlsaSeq::setupWidget::setupWidget( QWidget * _parent ) : - MidiClient::setupWidget( MidiAlsaSeq::name(), _parent ) -{ - m_device = new QLineEdit( MidiAlsaSeq::probeDevice(), this ); - m_device->setGeometry( 10, 20, 160, 20 ); - - QLabel * dev_lbl = new QLabel( tr( "DEVICE" ), this ); - dev_lbl->setFont( pointSize<7>( dev_lbl->font() ) ); - dev_lbl->setGeometry( 10, 40, 160, 10 ); -} - - - - -MidiAlsaSeq::setupWidget::~setupWidget() -{ -} - - - - -void MidiAlsaSeq::setupWidget::saveSettings() -{ - ConfigManager::inst()->setValue( "Midialsaseq", "device", - m_device->text() ); -} - - - - - #endif diff --git a/src/core/midi/MidiApple.cpp b/src/core/midi/MidiApple.cpp index 32a635e7a..1c9907045 100644 --- a/src/core/midi/MidiApple.cpp +++ b/src/core/midi/MidiApple.cpp @@ -26,8 +26,6 @@ #include "MidiApple.h" -#include -#include #include #include @@ -624,20 +622,6 @@ char * MidiApple::getFullName(MIDIEndpointRef &endpoint_ref) } - -MidiApple::setupWidget::setupWidget( QWidget* parent ) : -MidiClient::setupWidget( MidiApple::name(), parent ) -{ -} - - - -MidiApple::setupWidget::~setupWidget() -{ -} - - - #endif diff --git a/src/core/midi/MidiOss.cpp b/src/core/midi/MidiOss.cpp index d9777587f..02c8f8975 100644 --- a/src/core/midi/MidiOss.cpp +++ b/src/core/midi/MidiOss.cpp @@ -28,9 +28,6 @@ #ifdef LMMS_HAVE_OSS -#include -#include - #ifdef LMMS_HAVE_STDLIB_H #include @@ -111,38 +108,6 @@ void MidiOss::run() } - - - -MidiOss::setupWidget::setupWidget( QWidget * _parent ) : - MidiClientRaw::setupWidget( MidiOss::name(), _parent ) -{ - m_device = new QLineEdit( MidiOss::probeDevice(), this ); - m_device->setGeometry( 10, 20, 160, 20 ); - - QLabel * dev_lbl = new QLabel( tr( "DEVICE" ), this ); - dev_lbl->setFont( pointSize<7>( dev_lbl->font() ) ); - dev_lbl->setGeometry( 10, 40, 160, 10 ); -} - - - - -MidiOss::setupWidget::~setupWidget() -{ -} - - - - -void MidiOss::setupWidget::saveSettings() -{ - ConfigManager::inst()->setValue( "midioss", "device", - m_device->text() ); -} - - - #endif diff --git a/src/core/midi/MidiWinMM.cpp b/src/core/midi/MidiWinMM.cpp index 01badfd5d..e2ee75426 100644 --- a/src/core/midi/MidiWinMM.cpp +++ b/src/core/midi/MidiWinMM.cpp @@ -22,9 +22,6 @@ * */ -#include -#include - #include "MidiWinMM.h" #include "ConfigManager.h" #include "Engine.h" @@ -307,25 +304,5 @@ void MidiWinMM::openDevices() } - - -MidiWinMM::setupWidget::setupWidget( QWidget* parent ) : - MidiClient::setupWidget( MidiWinMM::name(), parent ) -{ -} - - - - -MidiWinMM::setupWidget::~setupWidget() -{ -} - - - - - - - #endif diff --git a/src/gui/CMakeLists.txt b/src/gui/CMakeLists.txt index a5897adf9..16df0b77b 100644 --- a/src/gui/CMakeLists.txt +++ b/src/gui/CMakeLists.txt @@ -20,6 +20,7 @@ SET(LMMS_SRCS gui/LmmsPalette.cpp gui/LmmsStyle.cpp gui/MainWindow.cpp + gui/MidiSetupWidget.cpp gui/ModelView.cpp gui/PeakControllerDialog.cpp gui/PianoView.cpp diff --git a/src/gui/MidiSetupWidget.cpp b/src/gui/MidiSetupWidget.cpp new file mode 100644 index 000000000..b6ec08c41 --- /dev/null +++ b/src/gui/MidiSetupWidget.cpp @@ -0,0 +1,68 @@ +/* + * MidiSetupWidget - class for configuring midi sources in the settings window + * + * Copyright (c) 2005-2014 Tobias Doerffel + * + * This file is part of LMMS - http://lmms.io + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public + * License along with this program (see COPYING); if not, write to the + * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301 USA. + * + */ + +#include "MidiSetupWidget.h" + +#include + +#include "ConfigManager.h" +#include "gui_templates.h" + +MidiSetupWidget::MidiSetupWidget( const QString & caption, const QString & configSection, + const QString & devName, QWidget * parent ) : + TabWidget( TabWidget::tr( "Settings for %1" ).arg( + tr( caption.toLatin1() ) ).toUpper(), parent ), + m_configSection(configSection), + m_device(nullptr) +{ + // supply devName=QString::Null() (distinct from QString("")) + // to indicate that there is no editable DEVICE field + if (!devName.isNull()) + { + m_device = new QLineEdit( devName, this ); + m_device->setGeometry( 10, 20, 160, 20 ); + + QLabel * dev_lbl = new QLabel( tr( "DEVICE" ), this ); + dev_lbl->setFont( pointSize<7>( dev_lbl->font() ) ); + dev_lbl->setGeometry( 10, 40, 160, 10 ); + } +} + +void MidiSetupWidget::saveSettings() +{ + if (!m_configSection.isEmpty() && m_device) + { + ConfigManager::inst()->setValue( m_configSection, "device", + m_device->text() ); + } +} + +void MidiSetupWidget::show() +{ + // the setup widget should only be visible if the device has some configurable attributes + bool visible = !m_configSection.isEmpty(); + parentWidget()->setVisible(visible); + QWidget::setVisible(visible); +} + diff --git a/src/gui/SetupDialog.cpp b/src/gui/SetupDialog.cpp index 1006c84a3..b43e5707f 100644 --- a/src/gui/SetupDialog.cpp +++ b/src/gui/SetupDialog.cpp @@ -817,28 +817,28 @@ SetupDialog::SetupDialog( ConfigTabs _tab_to_open ) : #ifdef LMMS_HAVE_ALSA m_midiIfaceSetupWidgets[MidiAlsaSeq::name()] = - new MidiAlsaSeq::setupWidget( msw ); + MidiSetupWidget::create( msw ); m_midiIfaceSetupWidgets[MidiAlsaRaw::name()] = - new MidiAlsaRaw::setupWidget( msw ); + MidiSetupWidget::create( msw ); #endif #ifdef LMMS_HAVE_OSS m_midiIfaceSetupWidgets[MidiOss::name()] = - new MidiOss::setupWidget( msw ); + MidiSetupWidget::create( msw ); #endif #ifdef LMMS_BUILD_WIN32 m_midiIfaceSetupWidgets[MidiWinMM::name()] = - new MidiWinMM::setupWidget( msw ); + MidiSetupWidget::create( msw ); #endif #ifdef LMMS_BUILD_APPLE m_midiIfaceSetupWidgets[MidiApple::name()] = - new MidiApple::setupWidget( msw ); + MidiSetupWidget::create( msw ); #endif m_midiIfaceSetupWidgets[MidiDummy::name()] = - new MidiDummy::setupWidget( msw ); + MidiSetupWidget::create( msw ); for( MswMap::iterator it = m_midiIfaceSetupWidgets.begin(); From 0f2da6f68bd70de9f594d931bf9b1609938f2e40 Mon Sep 17 00:00:00 2001 From: Colin Wallace Date: Sun, 23 Aug 2015 21:35:43 -0700 Subject: [PATCH 2/4] Provide upgrade path to copy the MidiAlsaRaw 'Device' property to new 'device' --- include/ConfigManager.h | 4 ++- src/core/ConfigManager.cpp | 51 ++++++++++++++++++++++++++++++++++---- 2 files changed, 49 insertions(+), 6 deletions(-) diff --git a/include/ConfigManager.h b/include/ConfigManager.h index 3ad94e185..8d213b3d7 100644 --- a/include/ConfigManager.h +++ b/include/ConfigManager.h @@ -228,6 +228,7 @@ public: const QString & _attribute ) const; void setValue( const QString & _class, const QString & _attribute, const QString & _value ); + void deleteValue( const QString & cls, const QString & attribute); void loadConfigFile(); void saveConfigFile(); @@ -256,7 +257,8 @@ private: ConfigManager( const ConfigManager & _c ); ~ConfigManager(); - + void upgrade_1_1_90(); + void upgrade_1_2_0(); void upgrade(); const QString m_lmmsRcFile; diff --git a/src/core/ConfigManager.cpp b/src/core/ConfigManager.cpp index 34cf6e0ea..0dc5a25e4 100644 --- a/src/core/ConfigManager.cpp +++ b/src/core/ConfigManager.cpp @@ -104,7 +104,31 @@ ConfigManager::~ConfigManager() } +void ConfigManager::upgrade_1_1_90() +{ + // Remove trailing " (bad latency!)" string which was once saved with PulseAudio + if( value( "mixer", "audiodev" ).startsWith( "PulseAudio (" ) ) + { + setValue("mixer", "audiodev", "PulseAudio"); + } +} +void ConfigManager::upgrade_1_2_0() +{ + // MidiAlsaRaw used to store the device info as "Device" instead of "device" + if ( value( "MidiAlsaRaw", "device" ).isNull() ) + { + // copy "device" = "Device" and then delete the old "Device" (further down) + QString oldDevice = value( "MidiAlsaRaw", "Device" ); + setValue("MidiAlsaRaw", "device", oldDevice); + } + if ( !value( "MidiAlsaRaw", "device" ).isNull() ) + { + // delete the old "Device" in the case that we just copied it to "device" + // or if the user somehow set both the "Device" and "device" fields + deleteValue("MidiAlsaRaw", "Device"); + } +} void ConfigManager::upgrade() { @@ -116,13 +140,14 @@ void ConfigManager::upgrade() ProjectVersion createdWith = m_version; - // Remove trailing " (bad latency!)" string which was once saved with PulseAudio if ( createdWith.setCompareType(Build) < "1.1.90" ) { - if( value( "mixer", "audiodev" ).startsWith( "PulseAudio (" ) ) - { - setValue("mixer", "audiodev", "PulseAudio"); - } + upgrade_1_1_90(); + } + + if ( createdWith.setCompareType(Build) < "1.2.0" ) + { + upgrade_1_2_0(); } // Don't use old themes as they break the UI (i.e. 0.4 != 1.0, etc) @@ -295,6 +320,22 @@ void ConfigManager::setValue( const QString & _class, } +void ConfigManager::deleteValue( const QString & cls, const QString & attribute) +{ + if( m_settings.contains( cls ) ) + { + for( stringPairVector::iterator it = m_settings[cls].begin(); + it != m_settings[cls].end(); ++it ) + { + if( ( *it ).first == attribute ) + { + m_settings[cls].erase(it); + return; + } + } + } +} + void ConfigManager::loadConfigFile() { From f6b696fa0fd4f144e54c3eb2839293a74708be7f Mon Sep 17 00:00:00 2001 From: Colin Wallace Date: Tue, 25 Aug 2015 18:59:11 -0700 Subject: [PATCH 3/4] Don't use underscore parameter names in value, setValue functions --- include/ConfigManager.h | 8 ++++---- src/core/ConfigManager.cpp | 30 +++++++++++++++--------------- 2 files changed, 19 insertions(+), 19 deletions(-) diff --git a/include/ConfigManager.h b/include/ConfigManager.h index 8d213b3d7..0e73ebc2e 100644 --- a/include/ConfigManager.h +++ b/include/ConfigManager.h @@ -224,10 +224,10 @@ public: void addRecentlyOpenedProject( const QString & _file ); - const QString & value( const QString & _class, - const QString & _attribute ) const; - void setValue( const QString & _class, const QString & _attribute, - const QString & _value ); + const QString & value( const QString & cls, + const QString & attribute ) const; + void setValue( const QString & cls, const QString & attribute, + const QString & value ); void deleteValue( const QString & cls, const QString & attribute); void loadConfigFile(); diff --git a/src/core/ConfigManager.cpp b/src/core/ConfigManager.cpp index 0dc5a25e4..523e0748c 100644 --- a/src/core/ConfigManager.cpp +++ b/src/core/ConfigManager.cpp @@ -277,16 +277,16 @@ void ConfigManager::addRecentlyOpenedProject( const QString & _file ) -const QString & ConfigManager::value( const QString & _class, - const QString & _attribute ) const +const QString & ConfigManager::value( const QString & cls, + const QString & attribute ) const { - if( m_settings.contains( _class ) ) + if( m_settings.contains( cls ) ) { for( stringPairVector::const_iterator it = - m_settings[_class].begin(); - it != m_settings[_class].end(); ++it ) + m_settings[cls].begin(); + it != m_settings[cls].end(); ++it ) { - if( ( *it ).first == _attribute ) + if( ( *it ).first == attribute ) { return ( *it ).second ; } @@ -299,24 +299,24 @@ const QString & ConfigManager::value( const QString & _class, -void ConfigManager::setValue( const QString & _class, - const QString & _attribute, - const QString & _value ) +void ConfigManager::setValue( const QString & cls, + const QString & attribute, + const QString & value ) { - if( m_settings.contains( _class ) ) + if( m_settings.contains( cls ) ) { - for( stringPairVector::iterator it = m_settings[_class].begin(); - it != m_settings[_class].end(); ++it ) + for( stringPairVector::iterator it = m_settings[cls].begin(); + it != m_settings[cls].end(); ++it ) { - if( ( *it ).first == _attribute ) + if( ( *it ).first == attribute ) { - ( *it ).second = _value; + ( *it ).second = value; return; } } } // not in map yet, so we have to add it... - m_settings[_class].push_back( qMakePair( _attribute, _value ) ); + m_settings[cls].push_back( qMakePair( attribute, value ) ); } From 39133ab0ea393b6acbd1552b14f6b40a7c2d5e17 Mon Sep 17 00:00:00 2001 From: Colin Wallace Date: Sat, 5 Sep 2015 21:38:36 -0700 Subject: [PATCH 4/4] Move update_1_2_0() functionality into upgrade_1_1_90(); Next release candidate will be named 1.1.90 --- include/ConfigManager.h | 1 - src/core/ConfigManager.cpp | 9 +-------- 2 files changed, 1 insertion(+), 9 deletions(-) diff --git a/include/ConfigManager.h b/include/ConfigManager.h index 0e73ebc2e..7e5b73c3d 100644 --- a/include/ConfigManager.h +++ b/include/ConfigManager.h @@ -258,7 +258,6 @@ private: ~ConfigManager(); void upgrade_1_1_90(); - void upgrade_1_2_0(); void upgrade(); const QString m_lmmsRcFile; diff --git a/src/core/ConfigManager.cpp b/src/core/ConfigManager.cpp index 523e0748c..692489bf3 100644 --- a/src/core/ConfigManager.cpp +++ b/src/core/ConfigManager.cpp @@ -111,10 +111,7 @@ void ConfigManager::upgrade_1_1_90() { setValue("mixer", "audiodev", "PulseAudio"); } -} -void ConfigManager::upgrade_1_2_0() -{ // MidiAlsaRaw used to store the device info as "Device" instead of "device" if ( value( "MidiAlsaRaw", "device" ).isNull() ) { @@ -130,6 +127,7 @@ void ConfigManager::upgrade_1_2_0() } } + void ConfigManager::upgrade() { // Skip the upgrade if versions match @@ -144,11 +142,6 @@ void ConfigManager::upgrade() { upgrade_1_1_90(); } - - if ( createdWith.setCompareType(Build) < "1.2.0" ) - { - upgrade_1_2_0(); - } // Don't use old themes as they break the UI (i.e. 0.4 != 1.0, etc) if ( createdWith.setCompareType(Minor) != LMMS_VERSION )