Files
lmms/include/ConfigManager.h
saker 9a0add49fb Core Refactor: Replace `QVector with std::vector` (#6477)
* Replace QVector with std::vector in AudioEngine

* Replace QVector with std::vector in AudioEngineWorkerThread

* Replace QVector with std::vector in AudioJack

* Replace QVector with std::vector in AutomatableModel

* Replace QVector with std::vector in AutomationClip

* Replace QVector with std::vector in AutomationEditor

* Replace QVector with std::vector in ConfigManager

* Replace QVector with std::vector in Controller

* Replace QVector with std::vector in ControllerConnection

* Replace QVector with std::vector in EffectChain

* Replace QVector with std::vector in EnvelopeAndLfoParameters

* Replace QVector with std::vector in InstrumentFunctions

* Replace QVector with std::vector in MidiClient

* Replace QVector with std::vector in Mixer

* Replace QVector with std::vector in Note

* Replace QVector with std::vector in PeakController

* Replace QVector with std::vector in PianoRoll

* Replace QVector with std::vector in PluginFactory

* Replace QVector with std::vector in RenderManager

* Replace QVector with std::vector in StepRecorder

* Replace QVector with std::vector in Track

* Replace QVector with std::vector in TrackContainer

* Replace QVector with std::vector in Song

* Adapt QVector to std::vector changes in ControllerConnectionDialog

* Phase 2: Use std::abs in panning.h
Without this, the QVector changes will make the code not compile.

* Phase 2: Replace QVector with std::vector in PeakControllerEffect

* Phase 2: Replace QVector with std::vector in AutomatableModel

* Phase 2: Replace QVector with std::vector in AutomationClip

* Phase 2: Replace QVector with std::vector in ControllerConnection

* Phase 2: Replace QVector with std::vector in EffectChain

* Phase 2: Replace QVector with std::vector in Mixer

* Phase 2: Replace QVector with std::vector in PeakController

* Phase 2: Replace QVector with std::vector in RenderManager

* Phase 2: Replace QVector with std::vector in Song

* Phase 2: Replace QVector with std::vector in StepRecorder

* Phase 2: Replace QVector with std::vector in Track

* Phase 2: Replace QVector with std::vector in TrackContainer

* Phase 2: Adapt QVector changes in EffectRackView

* Phase 2: Adapt QVector changes in AutomationClipView

* Phase 2: Adapt QVector changes in ClipView

* Phase 2: Adapt QVector changes in AutomationEditor

* Phase 2: Adapt QVector changes in PianoRoll

* Phase 2: Adapt QVector changes in TrackContainerView

* Phase 2: Adapt QVector changes in TrackContentWidget

* Phase 2: Adapt QVector changes in InstrumentTrack

* Phase 2: Adapt QVector changes in MidiClip

* Phase 2: Adapt QVector changes in SampleTrack

* Fix segmentation fault in ConfigManager::value

* Fix unintended faulty std::vector insert in AutomationClip::resolveAllIDs

* Resolve trailing whitespace in src/core/StepRecorder.cpp

Co-authored-by: Hyunjin Song <tteu.ingog@gmail.com>

* Use std::next and std::prev in EffectChain::moveUp/moveDown

* Introduce static "combineAllTracks" function in AutomationClip

* Adjust variable name in Song::automatedValuesAt

* Adjust removal of long step notes in StepRecorder::removeNotesReleasedForTooLong

* Iterate over m_chords by const reference in src/core/InstrumentFunctions.cpp

Co-authored-by: Hyunjin Song <tteu.ingog@gmail.com>

* Fix StepRecorder::removeNotesReleasedForTooLong again

* Combine the ConfigManager::value overloads using std::optional

* Revise StepRecorder::removeNotesReleasedForTooLong

* Remove redundant std::optional in ConfigManager::value

* Remove trailing whitespace in ConfigManager::value

* Fix: Prevent incorrect use of std::distance when element not found

* Chore: Remove trailing whitespace in edited files

* Only set the id attribute if the controller was found

Co-authored-by: Hyunjin Song <tteu.ingog@gmail.com>

* Remove extra indents from 84b8fe8a559855ed263b74cc582eab3655250c5f

* Fix compilation issues

* Add LMMS_ prefix for header guard in Track.h

* Undo changes made to MixerView::deleteUnusedChannels

* Simplify code to handle failure of finding tracks
Co-authored-by: Hyunjin Song <tteu.ingog@gmail.com>

* Split ternary operator into separate if statement
Co-authored-by: Hyunjin Song <tteu.ingog@gmail.com>

* Undo changes to indentation in MixerRoute

* Do general clean-up
Some of the changes made:
+ Use auto where benefical
+ Fix bug in AutomatableModel::globalAutomationValueAt (for loop should be looping over clips variable, not clipsInRange)
+ Undo out of focus whitespace changes

* Always assign to m_steps regardless if clip is found or not
Even when the clip is not found (i.e., currentClip is -1), m_steps still
gets assigned to.

* Insert at the end of tracks vector in src/core/Mixer.cpp

Co-authored-by: Dominic Clark <mrdomclark@gmail.com>

* Insert at the end of tracks vector in src/core/Mixer.cpp (2)

Co-authored-by: Dominic Clark <mrdomclark@gmail.com>

* Remove redundant template parameter

* Use std::array for zoomLevels

---------

Co-authored-by: Hyunjin Song <tteu.ingog@gmail.com>
Co-authored-by: Dominic Clark <mrdomclark@gmail.com>
2023-08-22 12:08:56 +09:00

314 lines
6.3 KiB
C++

/*
* ConfigManager.h - class ConfigManager, a class for managing LMMS-configuration
*
* Copyright (c) 2005-2008 Tobias Doerffel <tobydox/at/users.sourceforge.net>
*
* This file is part of LMMS - https://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 LMMS_CONFIG_MANAGER_H
#define LMMS_CONFIG_MANAGER_H
#include "lmmsconfig.h"
#include <QMap>
#include <QPair>
#include <QStringList>
#include <QObject>
#include <vector>
#include "lmms_export.h"
namespace lmms
{
class Engine;
const QString PROJECTS_PATH = "projects/";
const QString TEMPLATE_PATH = "templates/";
const QString PRESETS_PATH = "presets/";
const QString SAMPLES_PATH = "samples/";
const QString GIG_PATH = "samples/gig/";
const QString SF2_PATH = "samples/soundfonts/";
const QString LADSPA_PATH ="plugins/ladspa/";
const QString DEFAULT_THEME_PATH = "themes/default/";
const QString TRACK_ICON_PATH = "track_icons/";
const QString LOCALE_PATH = "locale/";
const QString PORTABLE_MODE_FILE = "/portable_mode.txt";
class LMMS_EXPORT ConfigManager : public QObject
{
Q_OBJECT
using UpgradeMethod = void(ConfigManager::*)();
public:
static inline ConfigManager * inst()
{
if(s_instanceOfMe == nullptr )
{
s_instanceOfMe = new ConfigManager();
}
return s_instanceOfMe;
}
const QString & workingDir() const
{
return m_workingDir;
}
void initPortableWorkingDir();
void initInstalledWorkingDir();
void initDevelopmentWorkingDir();
const QString & dataDir() const
{
return m_dataDir;
}
QString factoryProjectsDir() const
{
return dataDir() + PROJECTS_PATH;
}
QString factoryTemplatesDir() const
{
return factoryProjectsDir() + TEMPLATE_PATH;
}
QString factoryPresetsDir() const
{
return dataDir() + PRESETS_PATH;
}
QString factorySamplesDir() const
{
return dataDir() + SAMPLES_PATH;
}
QString userProjectsDir() const
{
return workingDir() + PROJECTS_PATH;
}
QString userTemplateDir() const
{
return workingDir() + TEMPLATE_PATH;
}
QString userPresetsDir() const
{
return workingDir() + PRESETS_PATH;
}
QString userSamplesDir() const
{
return workingDir() + SAMPLES_PATH;
}
const QString & vstDir() const
{
return m_vstDir;
}
const QString & ladspaDir() const
{
return m_ladspaDir;
}
const QString & sf2Dir() const
{
return m_sf2Dir;
}
#ifdef LMMS_HAVE_FLUIDSYNTH
const QString & sf2File() const
{
return m_sf2File;
}
#endif
#ifdef LMMS_HAVE_STK
const QString & stkDir() const
{
return m_stkDir;
}
#endif
const QString & gigDir() const
{
return m_gigDir;
}
QString userVstDir() const
{
return m_vstDir;
}
QString userLadspaDir() const
{
return workingDir() + LADSPA_PATH;
}
QString userSf2Dir() const
{
return workingDir() + SF2_PATH;
}
QString userGigDir() const
{
return workingDir() + GIG_PATH;
}
QString defaultThemeDir() const
{
return m_dataDir + DEFAULT_THEME_PATH;
}
QString themeDir() const
{
return m_themeDir;
}
const QString & backgroundPicFile() const
{
return m_backgroundPicFile;
}
QString trackIconsDir() const
{
return m_dataDir + TRACK_ICON_PATH;
}
const QString recoveryFile() const
{
return m_workingDir + "recover.mmp";
}
inline const QStringList & recentlyOpenedProjects() const
{
return m_recentlyOpenedProjects;
}
QString localeDir() const
{
return m_dataDir + LOCALE_PATH;
}
const QString & version() const
{
return m_version;
}
// Used when the configversion attribute is not present in a configuration file.
// Returns the appropriate config file version based on the LMMS version.
unsigned int legacyConfigVersion();
QString defaultVersion() const;
static QStringList availableVstEmbedMethods();
QString vstEmbedMethod() const;
// Returns true if the working dir (e.g. ~/lmms) exists on disk.
bool hasWorkingDir() const;
void addRecentlyOpenedProject(const QString & _file);
QString value(const QString& cls, const QString& attribute, const QString& defaultVal = "") const;
void setValue(const QString & cls, const QString & attribute,
const QString & value);
void deleteValue(const QString & cls, const QString & attribute);
void loadConfigFile(const QString & configFile = "");
void saveConfigFile();
void setWorkingDir(const QString & workingDir);
void setVSTDir(const QString & vstDir);
void setLADSPADir(const QString & ladspaDir);
void setSF2Dir(const QString & sf2Dir);
void setSF2File(const QString & sf2File);
void setSTKDir(const QString & stkDir);
void setGIGDir(const QString & gigDir);
void setThemeDir(const QString & themeDir);
void setBackgroundPicFile(const QString & backgroundPicFile);
// Creates the working directory & subdirectories on disk.
void createWorkingDir();
signals:
void valueChanged( QString cls, QString attribute, QString value );
private:
static ConfigManager * s_instanceOfMe;
ConfigManager();
ConfigManager(const ConfigManager & _c);
~ConfigManager() override;
void upgrade_1_1_90();
void upgrade_1_1_91();
void upgrade_1_2_2();
void upgrade();
// List of all upgrade methods
static const std::vector<UpgradeMethod> UPGRADE_METHODS;
QString m_workingDir;
QString m_dataDir;
QString m_vstDir;
QString m_ladspaDir;
QString m_sf2Dir;
#ifdef LMMS_HAVE_FLUIDSYNTH
QString m_sf2File;
#endif
#ifdef LMMS_HAVE_STK
QString m_stkDir;
#endif
QString m_gigDir;
QString m_themeDir;
QString m_backgroundPicFile;
QString m_lmmsRcFile;
QString m_version;
unsigned int m_configVersion;
QStringList m_recentlyOpenedProjects;
using stringPairVector = std::vector<QPair<QString, QString>>;
using settingsMap = QMap<QString, stringPairVector>;
settingsMap m_settings;
friend class Engine;
};
} // namespace lmms
#endif // LMMS_CONFIG_MANAGER_H