1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289
|
/*
* 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 CONFIG_MGR_H
#define CONFIG_MGR_H
#include "lmmsconfig.h"
#include <QtCore/QMap>
#include <QtCore/QPair>
#include <QtCore/QStringList>
#include <QtCore/QVector>
#include <QtCore/QObject>
#include "export.h"
class LmmsCore;
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/";
class EXPORT ConfigManager : public QObject
{
Q_OBJECT
public:
static inline ConfigManager * inst()
{
if( s_instanceOfMe == NULL )
{
s_instanceOfMe = new ConfigManager();
}
return s_instanceOfMe;
}
const QString & dataDir() const
{
return m_dataDir;
}
const QString & workingDir() const
{
return m_workingDir;
}
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;
}
QString userGigDir() const
{
return workingDir() + GIG_PATH;
}
QString userSf2Dir() const
{
return workingDir() + SF2_PATH;
}
QString userLadspaDir() const
{
return workingDir() + LADSPA_PATH;
}
QString userVstDir() const
{
return m_vstDir;
}
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 defaultVersion() const;
QString defaultArtworkDir() const
{
return m_dataDir + DEFAULT_THEME_PATH;
}
QString artworkDir() const
{
return m_artworkDir;
}
QString trackIconsDir() const
{
return m_dataDir + TRACK_ICON_PATH;
}
QString localeDir() const
{
return m_dataDir + LOCALE_PATH;
}
const QString & gigDir() const
{
return m_gigDir;
}
const QString & sf2Dir() const
{
return m_sf2Dir;
}
const QString & vstDir() const
{
return m_vstDir;
}
const QString & ladspaDir() const
{
return m_ladDir;
}
const QString recoveryFile() const
{
return m_workingDir + "recover.mmp";
}
const QString & version() const
{
return m_version;
}
#ifdef LMMS_HAVE_STK
const QString & stkDir() const
{
return m_stkDir;
}
#endif
#ifdef LMMS_HAVE_FLUIDSYNTH
const QString & defaultSoundfont() const
{
return m_defaultSoundfont;
}
#endif
const QString & backgroundArtwork() const
{
return m_backgroundArtwork;
}
inline const QStringList & recentlyOpenedProjects() const
{
return m_recentlyOpenedProjects;
}
static QStringList availabeVstEmbedMethods();
QString vstEmbedMethod() const;
// returns true if the working dir (e.g. ~/lmms) exists on disk
bool hasWorkingDir() const;
void addRecentlyOpenedProject( const QString & _file );
const QString & value( const QString & cls,
const QString & attribute ) const;
const 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 & _wd );
void setVSTDir( const QString & _vd );
void setArtworkDir( const QString & _ad );
void setLADSPADir( const QString & _fd );
void setVersion( const QString & _cv );
void setSTKDir( const QString & _fd );
void setDefaultSoundfont( const QString & _sf );
void setBackgroundArtwork( const QString & _ba );
void setGIGDir( const QString & gd );
void setSF2Dir( const QString & sfd );
// 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();
void upgrade_1_1_90();
void upgrade_1_1_91();
void upgrade();
QString m_lmmsRcFile;
QString m_workingDir;
QString m_dataDir;
QString m_artworkDir;
QString m_vstDir;
QString m_ladDir;
QString m_gigDir;
QString m_sf2Dir;
QString m_version;
#ifdef LMMS_HAVE_STK
QString m_stkDir;
#endif
#ifdef LMMS_HAVE_FLUIDSYNTH
QString m_defaultSoundfont;
#endif
QString m_backgroundArtwork;
QStringList m_recentlyOpenedProjects;
typedef QVector<QPair<QString, QString> > stringPairVector;
typedef QMap<QString, stringPairVector> settingsMap;
settingsMap m_settings;
friend class LmmsCore;
} ;
#endif
|