| 1 | /* |
|---|
| 2 | * Hydrogen |
|---|
| 3 | * Copyright(c) 2002-2008 by Alex >Comix< Cominu [comix@users.sourceforge.net] |
|---|
| 4 | * |
|---|
| 5 | * http://www.hydrogen-music.org |
|---|
| 6 | * |
|---|
| 7 | * This program is free software; you can redistribute it and/or modify |
|---|
| 8 | * it under the terms of the GNU General Public License as published by |
|---|
| 9 | * the Free Software Foundation; either version 2 of the License, or |
|---|
| 10 | * (at your option) any later version. |
|---|
| 11 | * |
|---|
| 12 | * This program is distributed in the hope that it will be useful, |
|---|
| 13 | * but WITHOUT ANY WARRANTY, without even the implied warranty of |
|---|
| 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|---|
| 15 | * GNU General Public License for more details. |
|---|
| 16 | * |
|---|
| 17 | * You should have received a copy of the GNU General Public License |
|---|
| 18 | * along with this program; if not, write to the Free Software |
|---|
| 19 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
|---|
| 20 | * |
|---|
| 21 | */ |
|---|
| 22 | |
|---|
| 23 | #include <stdlib.h> |
|---|
| 24 | #include <hydrogen/Preferences.h> |
|---|
| 25 | |
|---|
| 26 | #include <hydrogen/LocalFileMng.h> |
|---|
| 27 | |
|---|
| 28 | #ifndef WIN32 |
|---|
| 29 | #include <pwd.h> |
|---|
| 30 | #include <unistd.h> |
|---|
| 31 | #endif |
|---|
| 32 | #include <sys/types.h> |
|---|
| 33 | #include <sys/stat.h> |
|---|
| 34 | #include <stdlib.h> |
|---|
| 35 | #include <fstream> |
|---|
| 36 | #include <iostream> |
|---|
| 37 | #include <cstdio> |
|---|
| 38 | #include <list> |
|---|
| 39 | #include <hydrogen/midiMap.h> |
|---|
| 40 | |
|---|
| 41 | #include <hydrogen/data_path.h> |
|---|
| 42 | #include "config.h" |
|---|
| 43 | #include "version.h" |
|---|
| 44 | |
|---|
| 45 | #include "xml/tinyxml.h" |
|---|
| 46 | #include <QDir> |
|---|
| 47 | #include <QApplication> |
|---|
| 48 | |
|---|
| 49 | namespace H2Core |
|---|
| 50 | { |
|---|
| 51 | |
|---|
| 52 | Preferences* Preferences::instance = NULL; |
|---|
| 53 | |
|---|
| 54 | |
|---|
| 55 | /// Return an instance of Preferences |
|---|
| 56 | Preferences* Preferences::getInstance() |
|---|
| 57 | { |
|---|
| 58 | if ( instance == NULL ) { |
|---|
| 59 | instance = new Preferences(); |
|---|
| 60 | } |
|---|
| 61 | |
|---|
| 62 | return instance; |
|---|
| 63 | } |
|---|
| 64 | |
|---|
| 65 | |
|---|
| 66 | Preferences::Preferences() |
|---|
| 67 | : Object( "Preferences" ) |
|---|
| 68 | , demoPath( QString( DataPath::get_data_path() ) + "/demo_songs/" ) |
|---|
| 69 | , m_sLastNews( "" ) |
|---|
| 70 | { |
|---|
| 71 | INFOLOG( "INIT" ); |
|---|
| 72 | |
|---|
| 73 | //Default jack track-outputs are post fader |
|---|
| 74 | m_nJackTrackOutputMode = POST_FADER; |
|---|
| 75 | m_bJackTrackOuts = false; |
|---|
| 76 | // switch to enable / disable lash, only on h2 startup |
|---|
| 77 | m_brestartLash = false; |
|---|
| 78 | m_bsetLash = false; |
|---|
| 79 | |
|---|
| 80 | //server list |
|---|
| 81 | std::list<QString> sServerList; |
|---|
| 82 | |
|---|
| 83 | // //musicCategories |
|---|
| 84 | // std::list<QString> m_musicCategories; |
|---|
| 85 | |
|---|
| 86 | char * ladpath = getenv( "LADSPA_PATH" ); // read the Environment variable LADSPA_PATH |
|---|
| 87 | if ( ladpath ) { |
|---|
| 88 | INFOLOG( "Found LADSPA_PATH enviroment variable" ); |
|---|
| 89 | QString sLadspaPath = ladpath; |
|---|
| 90 | int pos; |
|---|
| 91 | while ( ( pos = sLadspaPath.indexOf( ":" ) ) != -1 ) { |
|---|
| 92 | QString sPath = sLadspaPath.left( pos ); |
|---|
| 93 | m_ladspaPathVect.push_back( sPath ); |
|---|
| 94 | sLadspaPath = sLadspaPath.mid( pos + 1, sLadspaPath.length() ); |
|---|
| 95 | } |
|---|
| 96 | m_ladspaPathVect.push_back( sLadspaPath ); |
|---|
| 97 | } else { |
|---|
| 98 | #ifdef Q_OS_MACX |
|---|
| 99 | m_ladspaPathVect.push_back( qApp->applicationDirPath() + "/../Resources/plugins" ); |
|---|
| 100 | m_ladspaPathVect.push_back( "/Library/Audio/Plug-Ins/LADSPA/" ); |
|---|
| 101 | m_ladspaPathVect.push_back( QDir::homePath().append( "/Library/Audio/Plug-Ins/LADSPA" )); |
|---|
| 102 | #else |
|---|
| 103 | m_ladspaPathVect.push_back( "/usr/lib/ladspa" ); |
|---|
| 104 | m_ladspaPathVect.push_back( "/usr/local/lib/ladspa" ); |
|---|
| 105 | #endif |
|---|
| 106 | |
|---|
| 107 | } |
|---|
| 108 | |
|---|
| 109 | |
|---|
| 110 | |
|---|
| 111 | |
|---|
| 112 | m_pDefaultUIStyle = new UIStyle(); |
|---|
| 113 | |
|---|
| 114 | #ifdef Q_OS_MACX |
|---|
| 115 | m_sPreferencesFilename = QDir::homePath().append( "/Library/Application Support/Hydrogen/hydrogen.conf" ); |
|---|
| 116 | m_sPreferencesDirectory = QDir::homePath().append( "/Library/Application Support/Hydrogen/" ); |
|---|
| 117 | m_sDataDirectory = QDir::homePath().append( "/Library/Application Support/Hydrogen/data/" ); |
|---|
| 118 | #else |
|---|
| 119 | m_sPreferencesFilename = QDir::homePath().append( "/.hydrogen/hydrogen.conf" ); |
|---|
| 120 | m_sPreferencesDirectory = QDir::homePath().append( "/.hydrogen/" ); |
|---|
| 121 | m_sDataDirectory = QDir::homePath().append( "/.hydrogen/data/" ); |
|---|
| 122 | #endif |
|---|
| 123 | |
|---|
| 124 | __lastsampleDirectory = QDir::homePath(); //audio file browser |
|---|
| 125 | __playsamplesonclicking = false; // audio file browser |
|---|
| 126 | |
|---|
| 127 | loadPreferences( true ); // Global settings |
|---|
| 128 | loadPreferences( false ); // User settings |
|---|
| 129 | } |
|---|
| 130 | |
|---|
| 131 | |
|---|
| 132 | |
|---|
| 133 | Preferences::~Preferences() |
|---|
| 134 | { |
|---|
| 135 | savePreferences(); |
|---|
| 136 | |
|---|
| 137 | INFOLOG( "DESTROY" ); |
|---|
| 138 | instance = NULL; |
|---|
| 139 | delete m_pDefaultUIStyle; |
|---|
| 140 | } |
|---|
| 141 | |
|---|
| 142 | |
|---|
| 143 | |
|---|
| 144 | |
|---|
| 145 | |
|---|
| 146 | |
|---|
| 147 | /// |
|---|
| 148 | /// Load the preferences file |
|---|
| 149 | /// |
|---|
| 150 | void Preferences::loadPreferences( bool bGlobal ) |
|---|
| 151 | { |
|---|
| 152 | bool recreate = false; // configuration file must be recreated? |
|---|
| 153 | |
|---|
| 154 | QString sPreferencesDirectory; |
|---|
| 155 | QString sPreferencesFilename; |
|---|
| 156 | QString sDataDirectory; |
|---|
| 157 | if ( bGlobal ) { |
|---|
| 158 | sPreferencesDirectory = DataPath::get_data_path(); |
|---|
| 159 | sPreferencesFilename = sPreferencesDirectory + "/hydrogen.default.conf"; |
|---|
| 160 | INFOLOG( "Loading preferences file (GLOBAL) [" + sPreferencesFilename + "]" ); |
|---|
| 161 | } else { |
|---|
| 162 | sPreferencesFilename = m_sPreferencesFilename; |
|---|
| 163 | sPreferencesDirectory = m_sPreferencesDirectory; |
|---|
| 164 | sDataDirectory = QDir::homePath().append( "/.hydrogen/data" ); |
|---|
| 165 | INFOLOG( "Loading preferences file (USER) [" + sPreferencesFilename + "]" ); |
|---|
| 166 | |
|---|
| 167 | |
|---|
| 168 | } |
|---|
| 169 | |
|---|
| 170 | |
|---|
| 171 | |
|---|
| 172 | // preferences directory exists? |
|---|
| 173 | QDir prefDir( sPreferencesDirectory ); |
|---|
| 174 | if ( !prefDir.exists() ) { |
|---|
| 175 | if ( bGlobal ) { |
|---|
| 176 | WARNINGLOG( "System configuration directory '" + sPreferencesDirectory + "' not found." ); |
|---|
| 177 | } else { |
|---|
| 178 | ERRORLOG( "Configuration directory '" + sPreferencesDirectory + "' not found." ); |
|---|
| 179 | createPreferencesDirectory(); |
|---|
| 180 | } |
|---|
| 181 | } |
|---|
| 182 | |
|---|
| 183 | // data directory exists? |
|---|
| 184 | QDir dataDir( sDataDirectory ); |
|---|
| 185 | if ( !dataDir.exists() ) { |
|---|
| 186 | WARNINGLOG( "Data directory not found." ); |
|---|
| 187 | createDataDirectory(); |
|---|
| 188 | } |
|---|
| 189 | |
|---|
| 190 | // soundLibrary directory exists? |
|---|
| 191 | QString sDir = sDataDirectory; |
|---|
| 192 | QString sDrumkitDir; |
|---|
| 193 | QString sSongDir; |
|---|
| 194 | QString sPatternDir; |
|---|
| 195 | |
|---|
| 196 | INFOLOG( "Creating soundLibrary directories in " + sDir ); |
|---|
| 197 | |
|---|
| 198 | sDrumkitDir = sDir + "/drumkits"; |
|---|
| 199 | sSongDir = sDir + "/songs"; |
|---|
| 200 | sPatternDir = sDir + "/patterns"; |
|---|
| 201 | |
|---|
| 202 | QDir drumkitDir( sDrumkitDir ); |
|---|
| 203 | QDir songDir( sSongDir ); |
|---|
| 204 | QDir patternDir( sPatternDir ); |
|---|
| 205 | |
|---|
| 206 | if ( ! drumkitDir.exists() || ! songDir.exists() || ! patternDir.exists() ) |
|---|
| 207 | { |
|---|
| 208 | createSoundLibraryDirectories(); |
|---|
| 209 | } |
|---|
| 210 | |
|---|
| 211 | // pref file exists? |
|---|
| 212 | std::ifstream input( sPreferencesFilename.toAscii() , std::ios::in | std::ios::binary ); |
|---|
| 213 | if ( input ) { |
|---|
| 214 | // read preferences file |
|---|
| 215 | TiXmlDocument doc( sPreferencesFilename.toAscii() ); |
|---|
| 216 | doc.LoadFile(); |
|---|
| 217 | |
|---|
| 218 | TiXmlNode* rootNode; |
|---|
| 219 | if ( ( rootNode = doc.FirstChild( "hydrogen_preferences" ) ) ) { |
|---|
| 220 | |
|---|
| 221 | // version |
|---|
| 222 | QString version = LocalFileMng::readXmlString( rootNode, "version", "" ); |
|---|
| 223 | if ( version == "" ) { |
|---|
| 224 | recreate = true; |
|---|
| 225 | } |
|---|
| 226 | |
|---|
| 227 | //////// GENERAL /////////// |
|---|
| 228 | //m_sLadspaPath = LocalFileMng::readXmlString( this, rootNode, "ladspaPath", m_sLadspaPath ); |
|---|
| 229 | m_bShowDevelWarning = LocalFileMng::readXmlBool( rootNode, "showDevelWarning", m_bShowDevelWarning ); |
|---|
| 230 | restoreLastSong = LocalFileMng::readXmlBool( rootNode, "restoreLastSong", restoreLastSong ); |
|---|
| 231 | m_bPatternModePlaysSelected = LocalFileMng::readXmlBool( rootNode, "patternModePlaysSelected", TRUE ); |
|---|
| 232 | m_bUseLash = LocalFileMng::readXmlBool( rootNode, "useLash", FALSE ); |
|---|
| 233 | |
|---|
| 234 | //restore the right m_bsetlash value |
|---|
| 235 | m_bsetLash = m_bUseLash; |
|---|
| 236 | |
|---|
| 237 | hearNewNotes = LocalFileMng::readXmlBool( rootNode, "hearNewNotes", hearNewNotes ); |
|---|
| 238 | recordEvents = LocalFileMng::readXmlBool( rootNode, "recordEvents", recordEvents ); |
|---|
| 239 | quantizeEvents = LocalFileMng::readXmlBool( rootNode, "quantizeEvents", quantizeEvents ); |
|---|
| 240 | |
|---|
| 241 | TiXmlNode* pRecentUsedSongsNode = rootNode->FirstChild( "recentUsedSongs" ); |
|---|
| 242 | if ( pRecentUsedSongsNode ) { |
|---|
| 243 | TiXmlNode* pSongNode = 0; |
|---|
| 244 | for ( pSongNode = pRecentUsedSongsNode->FirstChild( "song" ); pSongNode; pSongNode = pSongNode->NextSibling( "song" ) ) { |
|---|
| 245 | QString sFilename = pSongNode->FirstChild()->Value(); |
|---|
| 246 | m_recentFiles.push_back( sFilename ); |
|---|
| 247 | } |
|---|
| 248 | } else { |
|---|
| 249 | WARNINGLOG( "recentUsedSongs node not found" ); |
|---|
| 250 | } |
|---|
| 251 | |
|---|
| 252 | TiXmlNode* pRecentFXNode = rootNode->FirstChild( "recentlyUsedEffects" ); |
|---|
| 253 | if ( pRecentFXNode ) { |
|---|
| 254 | TiXmlNode* pFXNode = 0; |
|---|
| 255 | for ( pFXNode = pRecentFXNode->FirstChild( "FX" ); pFXNode; pFXNode = pFXNode->NextSibling( "FX" ) ) { |
|---|
| 256 | QString sFXName = pFXNode->FirstChild()->Value(); |
|---|
| 257 | m_recentFX.push_back( sFXName ); |
|---|
| 258 | } |
|---|
| 259 | } else { |
|---|
| 260 | WARNINGLOG( "recentlyUsedEffects node not found" ); |
|---|
| 261 | } |
|---|
| 262 | |
|---|
| 263 | sServerList.clear(); |
|---|
| 264 | TiXmlNode* pServerListNode = rootNode->FirstChild( "serverList" ); |
|---|
| 265 | if ( pServerListNode ) { |
|---|
| 266 | TiXmlNode* pServerNode = 0; |
|---|
| 267 | for ( pServerNode = pServerListNode->FirstChild( "server" ); pServerNode; pServerNode = pServerNode->NextSibling( "server" ) ) { |
|---|
| 268 | QString sFilename = pServerNode->FirstChild()->Value(); |
|---|
| 269 | sServerList.push_back( sFilename ); |
|---|
| 270 | } |
|---|
| 271 | } else { |
|---|
| 272 | WARNINGLOG( "serverList node not found" ); |
|---|
| 273 | } |
|---|
| 274 | |
|---|
| 275 | m_patternCategories.clear(); |
|---|
| 276 | TiXmlNode* pPatternCategoriesNode = rootNode->FirstChild( "patternCategories" ); |
|---|
| 277 | if ( pPatternCategoriesNode ) { |
|---|
| 278 | TiXmlNode* pCategoriesNode = 0; |
|---|
| 279 | for ( pCategoriesNode = pPatternCategoriesNode->FirstChild( "categories" ); pCategoriesNode; pCategoriesNode = pCategoriesNode->NextSibling( "categories" ) ) { |
|---|
| 280 | QString sFilename = pCategoriesNode->FirstChild()->Value(); |
|---|
| 281 | m_patternCategories.push_back( sFilename ); |
|---|
| 282 | } |
|---|
| 283 | } else { |
|---|
| 284 | WARNINGLOG( "patternCategories node not found" ); |
|---|
| 285 | } |
|---|
| 286 | |
|---|
| 287 | |
|---|
| 288 | |
|---|
| 289 | m_sLastNews = LocalFileMng::readXmlString( rootNode, "lastNews", "-", true ); |
|---|
| 290 | |
|---|
| 291 | /////////////// AUDIO ENGINE ////////////// |
|---|
| 292 | TiXmlNode* audioEngineNode; |
|---|
| 293 | if ( !( audioEngineNode = rootNode->FirstChild( "audio_engine" ) ) ) { |
|---|
| 294 | WARNINGLOG( "audio_engine node not found" ); |
|---|
| 295 | recreate = true; |
|---|
| 296 | } else { |
|---|
| 297 | m_sAudioDriver = LocalFileMng::readXmlString( audioEngineNode, "audio_driver", m_sAudioDriver ); |
|---|
| 298 | m_bUseMetronome = LocalFileMng::readXmlBool( audioEngineNode, "use_metronome", m_bUseMetronome ); |
|---|
| 299 | m_fMetronomeVolume = LocalFileMng::readXmlFloat( audioEngineNode, "metronome_volume", 0.5f ); |
|---|
| 300 | m_nMaxNotes = LocalFileMng::readXmlInt( audioEngineNode, "maxNotes", m_nMaxNotes ); |
|---|
| 301 | m_nBufferSize = LocalFileMng::readXmlInt( audioEngineNode, "buffer_size", m_nBufferSize ); |
|---|
| 302 | m_nSampleRate = LocalFileMng::readXmlInt( audioEngineNode, "samplerate", m_nSampleRate ); |
|---|
| 303 | |
|---|
| 304 | //// OSS DRIVER //// |
|---|
| 305 | TiXmlNode* ossDriverNode; |
|---|
| 306 | if ( !( ossDriverNode = audioEngineNode->FirstChild( "oss_driver" ) ) ) { |
|---|
| 307 | WARNINGLOG( "oss_driver node not found" ); |
|---|
| 308 | recreate = true; |
|---|
| 309 | } else { |
|---|
| 310 | m_sOSSDevice = LocalFileMng::readXmlString( ossDriverNode, "ossDevice", m_sOSSDevice ); |
|---|
| 311 | } |
|---|
| 312 | |
|---|
| 313 | //// JACK DRIVER //// |
|---|
| 314 | TiXmlNode* jackDriverNode; |
|---|
| 315 | if ( !( jackDriverNode = audioEngineNode->FirstChild( "jack_driver" ) ) ) { |
|---|
| 316 | WARNINGLOG( "jack_driver node not found" ); |
|---|
| 317 | recreate = true; |
|---|
| 318 | } else { |
|---|
| 319 | m_sJackPortName1 = LocalFileMng::readXmlString( jackDriverNode, "jack_port_name_1", m_sJackPortName1 ); |
|---|
| 320 | m_sJackPortName2 = LocalFileMng::readXmlString( jackDriverNode, "jack_port_name_2", m_sJackPortName2 ); |
|---|
| 321 | QString sMode = LocalFileMng::readXmlString( jackDriverNode, "jack_transport_mode", "NO_JACK_TRANSPORT" ); |
|---|
| 322 | if ( sMode == "NO_JACK_TRANSPORT" ) { |
|---|
| 323 | m_bJackTransportMode = NO_JACK_TRANSPORT; |
|---|
| 324 | } else if ( sMode == "USE_JACK_TRANSPORT" ) { |
|---|
| 325 | m_bJackTransportMode = USE_JACK_TRANSPORT; |
|---|
| 326 | } |
|---|
| 327 | |
|---|
| 328 | //jack time master |
|---|
| 329 | QString tmMode = LocalFileMng::readXmlString( jackDriverNode, "jack_transport_mode_master", "NO_JACK_TIME_MASTER" ); |
|---|
| 330 | if ( tmMode == "NO_JACK_TIME_MASTER" ) { |
|---|
| 331 | m_bJackMasterMode = NO_JACK_TIME_MASTER; |
|---|
| 332 | } else if ( tmMode == "USE_JACK_TIME_MASTER" ) { |
|---|
| 333 | m_bJackMasterMode = USE_JACK_TIME_MASTER; |
|---|
| 334 | } |
|---|
| 335 | //~ jack time master |
|---|
| 336 | |
|---|
| 337 | m_bJackTrackOuts = LocalFileMng::readXmlBool( jackDriverNode, "jack_track_outs", m_bJackTrackOuts ); |
|---|
| 338 | m_bJackConnectDefaults = LocalFileMng::readXmlBool( jackDriverNode, "jack_connect_defaults", m_bJackConnectDefaults ); |
|---|
| 339 | |
|---|
| 340 | m_nJackTrackOutputMode = LocalFileMng::readXmlInt( jackDriverNode, "jack_track_output_mode", m_nJackTrackOutputMode ); |
|---|
| 341 | m_nJackArdourTransportWorkaround = LocalFileMng::readXmlBool( jackDriverNode, "jack_ardour_transport_workaround", m_nJackArdourTransportWorkaround ); |
|---|
| 342 | } |
|---|
| 343 | |
|---|
| 344 | |
|---|
| 345 | /// ALSA AUDIO DRIVER /// |
|---|
| 346 | TiXmlNode* alsaAudioDriverNode; |
|---|
| 347 | if ( !( alsaAudioDriverNode = audioEngineNode->FirstChild( "alsa_audio_driver" ) ) ) { |
|---|
| 348 | WARNINGLOG( "alsa_audio_driver node not found" ); |
|---|
| 349 | recreate = true; |
|---|
| 350 | } else { |
|---|
| 351 | m_sAlsaAudioDevice = LocalFileMng::readXmlString( alsaAudioDriverNode, "alsa_audio_device", m_sAlsaAudioDevice ); |
|---|
| 352 | } |
|---|
| 353 | |
|---|
| 354 | /// MIDI DRIVER /// |
|---|
| 355 | TiXmlNode* midiDriverNode; |
|---|
| 356 | if ( !( midiDriverNode = audioEngineNode->FirstChild( "midi_driver" ) ) ) { |
|---|
| 357 | WARNINGLOG( "midi_driver node not found" ); |
|---|
| 358 | recreate = true; |
|---|
| 359 | } else { |
|---|
| 360 | m_sMidiDriver = LocalFileMng::readXmlString( midiDriverNode, "driverName", "ALSA" ); |
|---|
| 361 | m_sMidiPortName = LocalFileMng::readXmlString( midiDriverNode, "port_name", "None" ); |
|---|
| 362 | m_nMidiChannelFilter = LocalFileMng::readXmlInt( midiDriverNode, "channel_filter", -1 ); |
|---|
| 363 | m_bMidiNoteOffIgnore = LocalFileMng::readXmlBool( midiDriverNode, "ignore_note_off", true ); |
|---|
| 364 | } |
|---|
| 365 | |
|---|
| 366 | |
|---|
| 367 | |
|---|
| 368 | } |
|---|
| 369 | |
|---|
| 370 | /////////////// GUI ////////////// |
|---|
| 371 | TiXmlNode* guiNode; |
|---|
| 372 | if ( !( guiNode = rootNode->FirstChild( "gui" ) ) ) { |
|---|
| 373 | WARNINGLOG( "gui node not found" ); |
|---|
| 374 | recreate = true; |
|---|
| 375 | } else { |
|---|
| 376 | // QT Style |
|---|
| 377 | m_sQTStyle = LocalFileMng::readXmlString( guiNode, "QTStyle", m_sQTStyle, true ); |
|---|
| 378 | |
|---|
| 379 | // Application font family |
|---|
| 380 | applicationFontFamily = LocalFileMng::readXmlString( guiNode, "application_font_family", applicationFontFamily ); |
|---|
| 381 | |
|---|
| 382 | // Application font pointSize |
|---|
| 383 | applicationFontPointSize = LocalFileMng::readXmlInt( guiNode, "application_font_pointsize", applicationFontPointSize ); |
|---|
| 384 | |
|---|
| 385 | // mixer font family |
|---|
| 386 | mixerFontFamily = LocalFileMng::readXmlString( guiNode, "mixer_font_family", mixerFontFamily ); |
|---|
| 387 | |
|---|
| 388 | // mixer font pointSize |
|---|
| 389 | mixerFontPointSize = LocalFileMng::readXmlInt( guiNode, "mixer_font_pointsize", mixerFontPointSize ); |
|---|
| 390 | |
|---|
| 391 | // Mixer falloff speed |
|---|
| 392 | mixerFalloffSpeed = LocalFileMng::readXmlFloat( guiNode, "mixer_falloff_speed", 1.1f ); |
|---|
| 393 | |
|---|
| 394 | // pattern editor grid resolution |
|---|
| 395 | m_nPatternEditorGridResolution = LocalFileMng::readXmlInt( guiNode, "patternEditorGridResolution", m_nPatternEditorGridResolution ); |
|---|
| 396 | m_bPatternEditorUsingTriplets = LocalFileMng::readXmlBool( guiNode, "patternEditorUsingTriplets", m_bPatternEditorUsingTriplets ); |
|---|
| 397 | m_bShowInstrumentPeaks = LocalFileMng::readXmlBool( guiNode, "showInstrumentPeaks", m_bShowInstrumentPeaks ); |
|---|
| 398 | m_bIsFXTabVisible = LocalFileMng::readXmlBool( guiNode, "isFXTabVisible", m_bIsFXTabVisible ); |
|---|
| 399 | |
|---|
| 400 | |
|---|
| 401 | // pattern editor grid height |
|---|
| 402 | m_nPatternEditorGridHeight = LocalFileMng::readXmlInt( guiNode, "patternEditorGridHeight", m_nPatternEditorGridHeight ); |
|---|
| 403 | |
|---|
| 404 | // pattern editor grid width |
|---|
| 405 | m_nPatternEditorGridWidth = LocalFileMng::readXmlInt( guiNode, "patternEditorGridWidth", m_nPatternEditorGridWidth ); |
|---|
| 406 | |
|---|
| 407 | // mainForm window properties |
|---|
| 408 | setMainFormProperties( readWindowProperties( guiNode, "mainForm_properties", mainFormProperties ) ); |
|---|
| 409 | setMixerProperties( readWindowProperties( guiNode, "mixer_properties", mixerProperties ) ); |
|---|
| 410 | setPatternEditorProperties( readWindowProperties( guiNode, "patternEditor_properties", patternEditorProperties ) ); |
|---|
| 411 | setSongEditorProperties( readWindowProperties( guiNode, "songEditor_properties", songEditorProperties ) ); |
|---|
| 412 | setAudioEngineInfoProperties( readWindowProperties( guiNode, "audioEngineInfo_properties", audioEngineInfoProperties ) ); |
|---|
| 413 | |
|---|
| 414 | |
|---|
| 415 | |
|---|
| 416 | m_bFollowPlayhead = LocalFileMng::readXmlBool( guiNode, "followPlayhead", true ); |
|---|
| 417 | |
|---|
| 418 | |
|---|
| 419 | //beatcounter |
|---|
| 420 | QString bcMode = LocalFileMng::readXmlString( guiNode, "bc", "BC_OFF" ); |
|---|
| 421 | if ( bcMode == "BC_OFF" ) { |
|---|
| 422 | m_bbc = BC_OFF; |
|---|
| 423 | } else if ( bcMode == "BC_ON" ) { |
|---|
| 424 | m_bbc = BC_ON; |
|---|
| 425 | } |
|---|
| 426 | |
|---|
| 427 | |
|---|
| 428 | QString setPlay = LocalFileMng::readXmlString( guiNode, "setplay", "SET_PLAY_OFF" ); |
|---|
| 429 | if ( setPlay == "SET_PLAY_OFF" ) { |
|---|
| 430 | m_mmcsetplay = SET_PLAY_OFF; |
|---|
| 431 | } else if ( setPlay == "SET_PLAY_ON" ) { |
|---|
| 432 | m_mmcsetplay = SET_PLAY_ON; |
|---|
| 433 | } |
|---|
| 434 | |
|---|
| 435 | m_countOffset = LocalFileMng::readXmlInt( guiNode, "countoffset", 0 ); |
|---|
| 436 | m_startOffset = LocalFileMng::readXmlInt( guiNode, "playoffset", 0 ); |
|---|
| 437 | |
|---|
| 438 | //~ beatcounter |
|---|
| 439 | |
|---|
| 440 | for ( unsigned nFX = 0; nFX < MAX_FX; nFX++ ) { |
|---|
| 441 | QString sNodeName = "ladspaFX_properties" + to_string( nFX ); |
|---|
| 442 | setLadspaProperties( nFX, readWindowProperties( guiNode, sNodeName, m_ladspaProperties[nFX] ) ); |
|---|
| 443 | } |
|---|
| 444 | |
|---|
| 445 | TiXmlNode *pUIStyle = guiNode->FirstChild( "UI_Style" ); |
|---|
| 446 | if ( pUIStyle ) { |
|---|
| 447 | readUIStyle( *pUIStyle ); |
|---|
| 448 | } else { |
|---|
| 449 | WARNINGLOG( "UI_Style node not found" ); |
|---|
| 450 | recreate = true; |
|---|
| 451 | } |
|---|
| 452 | } |
|---|
| 453 | |
|---|
| 454 | /////////////// FILES ////////////// |
|---|
| 455 | TiXmlNode* filesNode; |
|---|
| 456 | if ( !( filesNode = rootNode->FirstChild( "files" ) ) ) { |
|---|
| 457 | WARNINGLOG( "files node not found" ); |
|---|
| 458 | recreate = true; |
|---|
| 459 | } else { |
|---|
| 460 | // last used song |
|---|
| 461 | lastSongFilename = LocalFileMng::readXmlString( filesNode, "lastSongFilename", lastSongFilename, true ); |
|---|
| 462 | m_sDefaultEditor = LocalFileMng::readXmlString( filesNode, "defaulteditor", m_sDefaultEditor, true ); |
|---|
| 463 | } |
|---|
| 464 | |
|---|
| 465 | // FIXME: hack hack hack! Isn't better to create a "release" method in MidiMap class instead of destroying a singleton? |
|---|
| 466 | if ( MidiMap::__instance != NULL) { |
|---|
| 467 | delete MidiMap::__instance; |
|---|
| 468 | } |
|---|
| 469 | MidiMap* mM = MidiMap::getInstance(); |
|---|
| 470 | |
|---|
| 471 | |
|---|
| 472 | TiXmlNode* pMidiEventMapNode = rootNode->FirstChild( "midiEventMap" ); |
|---|
| 473 | if ( pMidiEventMapNode ) { |
|---|
| 474 | TiXmlNode* pMidiEventNode = 0; |
|---|
| 475 | |
|---|
| 476 | for ( pMidiEventNode = pMidiEventMapNode->FirstChild( "midiEvent" ); pMidiEventNode; pMidiEventNode = pMidiEventNode->NextSibling( "midiEvent" ) ) { |
|---|
| 477 | |
|---|
| 478 | if( pMidiEventNode->FirstChild()->Value() == QString("mmcEvent")){ |
|---|
| 479 | QString event = pMidiEventNode->FirstChild("mmcEvent")->FirstChild()->Value(); |
|---|
| 480 | QString s_action = pMidiEventNode->FirstChild("action")->FirstChild()->Value(); |
|---|
| 481 | QString s_param = pMidiEventNode->FirstChild("parameter")->FirstChild()->Value(); |
|---|
| 482 | Action* pAction = new Action( s_action ); |
|---|
| 483 | pAction->setParameter1( s_param ); |
|---|
| 484 | mM->registerMMCEvent(event, pAction); |
|---|
| 485 | } |
|---|
| 486 | |
|---|
| 487 | if( pMidiEventNode->FirstChild()->Value() == QString("noteEvent")){ |
|---|
| 488 | QString event = pMidiEventNode->FirstChild("noteEvent")->FirstChild()->Value(); |
|---|
| 489 | QString s_action = pMidiEventNode->FirstChild("action")->FirstChild()->Value(); |
|---|
| 490 | QString s_param = pMidiEventNode->FirstChild("parameter")->FirstChild()->Value(); |
|---|
| 491 | QString s_eventParameter = pMidiEventNode->FirstChild("eventParameter")->FirstChild()->Value(); |
|---|
| 492 | Action* pAction = new Action( s_action ); |
|---|
| 493 | pAction->setParameter1( s_param ); |
|---|
| 494 | mM->registerNoteEvent(s_eventParameter.toInt(), pAction); |
|---|
| 495 | } |
|---|
| 496 | |
|---|
| 497 | if( pMidiEventNode->FirstChild()->Value() == QString("ccEvent") ){ |
|---|
| 498 | QString event = pMidiEventNode->FirstChild("ccEvent")->FirstChild()->Value(); |
|---|
| 499 | QString s_action = pMidiEventNode->FirstChild("action")->FirstChild()->Value(); |
|---|
| 500 | QString s_param = pMidiEventNode->FirstChild("parameter")->FirstChild()->Value(); |
|---|
| 501 | QString s_eventParameter = pMidiEventNode->FirstChild("eventParameter")->FirstChild()->Value(); |
|---|
| 502 | Action * pAction = new Action( s_action ); |
|---|
| 503 | pAction->setParameter1( s_param ); |
|---|
| 504 | mM->registerCCEvent( s_eventParameter.toInt(), pAction ); |
|---|
| 505 | } |
|---|
| 506 | |
|---|
| 507 | } |
|---|
| 508 | } else { |
|---|
| 509 | WARNINGLOG( "midiMap node not found" ); |
|---|
| 510 | } |
|---|
| 511 | |
|---|
| 512 | |
|---|
| 513 | |
|---|
| 514 | } // rootNode |
|---|
| 515 | else { |
|---|
| 516 | WARNINGLOG( "hydrogen_preferences node not found" ); |
|---|
| 517 | recreate = true; |
|---|
| 518 | } |
|---|
| 519 | } else { |
|---|
| 520 | if ( bGlobal ) { |
|---|
| 521 | WARNINGLOG( "System configuration file not found." ); |
|---|
| 522 | } else { |
|---|
| 523 | WARNINGLOG( "Configuration file not found." ); |
|---|
| 524 | recreate = true; |
|---|
| 525 | } |
|---|
| 526 | } |
|---|
| 527 | |
|---|
| 528 | |
|---|
| 529 | // The preferences file should be recreated? |
|---|
| 530 | if ( recreate == true ) { |
|---|
| 531 | WARNINGLOG( "Recreating configuration file." ); |
|---|
| 532 | savePreferences(); |
|---|
| 533 | } |
|---|
| 534 | |
|---|
| 535 | } |
|---|
| 536 | |
|---|
| 537 | |
|---|
| 538 | |
|---|
| 539 | /// |
|---|
| 540 | /// Save the preferences file |
|---|
| 541 | /// |
|---|
| 542 | void Preferences::savePreferences() |
|---|
| 543 | { |
|---|
| 544 | //string prefDir = QDir::homePath().append("/.hydrogen").toStdString(); |
|---|
| 545 | QString filename = m_sPreferencesFilename; |
|---|
| 546 | |
|---|
| 547 | INFOLOG( "Saving preferences file: " + filename ); |
|---|
| 548 | |
|---|
| 549 | TiXmlDocument doc( filename.toAscii() ); |
|---|
| 550 | |
|---|
| 551 | TiXmlElement rootNode( "hydrogen_preferences" ); |
|---|
| 552 | |
|---|
| 553 | // hydrogen version |
|---|
| 554 | LocalFileMng::writeXmlString( &rootNode, "version", QString( get_version().c_str() ) ); |
|---|
| 555 | |
|---|
| 556 | ////// GENERAL /////// |
|---|
| 557 | LocalFileMng::writeXmlString( &rootNode, "restoreLastSong", restoreLastSong ? "true": "false" ); |
|---|
| 558 | |
|---|
| 559 | LocalFileMng::writeXmlString( &rootNode, "patternModePlaysSelected", m_bPatternModePlaysSelected ? "true": "false" ); |
|---|
| 560 | |
|---|
| 561 | LocalFileMng::writeXmlString( &rootNode, "useLash", m_bsetLash ? "true": "false" ); |
|---|
| 562 | |
|---|
| 563 | //show development version warning |
|---|
| 564 | LocalFileMng::writeXmlString( &rootNode, "showDevelWarning", m_bShowDevelWarning ? "true": "false" ); |
|---|
| 565 | |
|---|
| 566 | // hear new notes in the pattern editor |
|---|
| 567 | LocalFileMng::writeXmlString( &rootNode, "hearNewNotes", hearNewNotes ? "true": "false" ); |
|---|
| 568 | |
|---|
| 569 | // key/midi event prefs |
|---|
| 570 | LocalFileMng::writeXmlString( &rootNode, "recordEvents", recordEvents ? "true": "false" ); |
|---|
| 571 | LocalFileMng::writeXmlString( &rootNode, "quantizeEvents", quantizeEvents ? "true": "false" ); |
|---|
| 572 | |
|---|
| 573 | // Recent used songs |
|---|
| 574 | TiXmlElement recentUsedSongsNode( "recentUsedSongs" ); |
|---|
| 575 | { |
|---|
| 576 | unsigned nSongs = 5; |
|---|
| 577 | if ( m_recentFiles.size() < 5 ) { |
|---|
| 578 | nSongs = m_recentFiles.size(); |
|---|
| 579 | } |
|---|
| 580 | for ( unsigned i = 0; i < nSongs; i++ ) { |
|---|
| 581 | LocalFileMng::writeXmlString( &recentUsedSongsNode, "song", m_recentFiles[ i ] ); |
|---|
| 582 | } |
|---|
| 583 | } |
|---|
| 584 | rootNode.InsertEndChild( recentUsedSongsNode ); |
|---|
| 585 | |
|---|
| 586 | TiXmlElement recentFXNode( "recentlyUsedEffects" ); |
|---|
| 587 | { |
|---|
| 588 | int nFX = 0; |
|---|
| 589 | QString FXname; |
|---|
| 590 | foreach( FXname, m_recentFX ) { |
|---|
| 591 | LocalFileMng::writeXmlString( &recentFXNode, "FX", FXname ); |
|---|
| 592 | if ( ++nFX > 10 ) break; |
|---|
| 593 | } |
|---|
| 594 | } |
|---|
| 595 | rootNode.InsertEndChild( recentFXNode ); |
|---|
| 596 | |
|---|
| 597 | |
|---|
| 598 | std::list<QString>::const_iterator cur_Server; |
|---|
| 599 | |
|---|
| 600 | TiXmlElement serverListNode( "serverList" ); |
|---|
| 601 | for( cur_Server = sServerList.begin(); cur_Server != sServerList.end(); ++cur_Server ){ |
|---|
| 602 | LocalFileMng::writeXmlString( &serverListNode , QString("server") , QString( *cur_Server ) ); |
|---|
| 603 | } |
|---|
| 604 | rootNode.InsertEndChild( serverListNode ); |
|---|
| 605 | |
|---|
| 606 | |
|---|
| 607 | std::list<QString>::const_iterator cur_patternCategories; |
|---|
| 608 | |
|---|
| 609 | TiXmlElement patternCategoriesNode( "patternCategories" ); |
|---|
| 610 | for( cur_patternCategories = m_patternCategories.begin(); cur_patternCategories != m_patternCategories.end(); ++cur_patternCategories ){ |
|---|
| 611 | LocalFileMng::writeXmlString( &patternCategoriesNode , QString("categories") , QString( *cur_patternCategories ) ); |
|---|
| 612 | } |
|---|
| 613 | rootNode.InsertEndChild( patternCategoriesNode ); |
|---|
| 614 | |
|---|
| 615 | |
|---|
| 616 | |
|---|
| 617 | |
|---|
| 618 | LocalFileMng::writeXmlString( &rootNode, "lastNews", m_sLastNews ); |
|---|
| 619 | |
|---|
| 620 | |
|---|
| 621 | //---- AUDIO ENGINE ---- |
|---|
| 622 | TiXmlElement audioEngineNode( "audio_engine" ); |
|---|
| 623 | { |
|---|
| 624 | // audio driver |
|---|
| 625 | LocalFileMng::writeXmlString( &audioEngineNode, "audio_driver", m_sAudioDriver ); |
|---|
| 626 | |
|---|
| 627 | // use metronome |
|---|
| 628 | LocalFileMng::writeXmlString( &audioEngineNode, "use_metronome", m_bUseMetronome ? "true": "false" ); |
|---|
| 629 | LocalFileMng::writeXmlString( &audioEngineNode, "metronome_volume", to_string( m_fMetronomeVolume ) ); |
|---|
| 630 | LocalFileMng::writeXmlString( &audioEngineNode, "maxNotes", to_string( m_nMaxNotes ) ); |
|---|
| 631 | LocalFileMng::writeXmlString( &audioEngineNode, "buffer_size", to_string( m_nBufferSize ) ); |
|---|
| 632 | LocalFileMng::writeXmlString( &audioEngineNode, "samplerate", to_string( m_nSampleRate ) ); |
|---|
| 633 | |
|---|
| 634 | //// OSS DRIVER //// |
|---|
| 635 | TiXmlElement ossDriverNode( "oss_driver" ); |
|---|
| 636 | { |
|---|
| 637 | LocalFileMng::writeXmlString( &ossDriverNode, "ossDevice", m_sOSSDevice ); |
|---|
| 638 | } |
|---|
| 639 | audioEngineNode.InsertEndChild( ossDriverNode ); |
|---|
| 640 | |
|---|
| 641 | //// JACK DRIVER //// |
|---|
| 642 | TiXmlElement jackDriverNode( "jack_driver" ); |
|---|
| 643 | { |
|---|
| 644 | LocalFileMng::writeXmlString( &jackDriverNode, "jack_port_name_1", m_sJackPortName1 ); // jack port name 1 |
|---|
| 645 | LocalFileMng::writeXmlString( &jackDriverNode, "jack_port_name_2", m_sJackPortName2 ); // jack port name 2 |
|---|
| 646 | |
|---|
| 647 | // jack transport slave |
|---|
| 648 | QString sMode; |
|---|
| 649 | if ( m_bJackTransportMode == NO_JACK_TRANSPORT ) { |
|---|
| 650 | sMode = "NO_JACK_TRANSPORT"; |
|---|
| 651 | } else if ( m_bJackTransportMode == USE_JACK_TRANSPORT ) { |
|---|
| 652 | sMode = "USE_JACK_TRANSPORT"; |
|---|
| 653 | } |
|---|
| 654 | LocalFileMng::writeXmlString( &jackDriverNode, "jack_transport_mode", sMode ); |
|---|
| 655 | |
|---|
| 656 | //jack time master |
|---|
| 657 | QString tmMode; |
|---|
| 658 | if ( m_bJackMasterMode == NO_JACK_TIME_MASTER ) { |
|---|
| 659 | tmMode = "NO_JACK_TIME_MASTER"; |
|---|
| 660 | } else if ( m_bJackMasterMode == USE_JACK_TIME_MASTER ) { |
|---|
| 661 | tmMode = "NO_JACK_TIME_MASTER"; |
|---|
| 662 | } |
|---|
| 663 | LocalFileMng::writeXmlString( &jackDriverNode, "jack_transport_mode_master", tmMode ); |
|---|
| 664 | //~ jack time master |
|---|
| 665 | |
|---|
| 666 | // jack default connection |
|---|
| 667 | QString jackConnectDefaultsString = "false"; |
|---|
| 668 | if ( m_bJackConnectDefaults ) { |
|---|
| 669 | jackConnectDefaultsString = "true"; |
|---|
| 670 | } |
|---|
| 671 | LocalFileMng::writeXmlString( &jackDriverNode, "jack_connect_defaults", jackConnectDefaultsString ); |
|---|
| 672 | |
|---|
| 673 | //pre-fader or post-fader track outputs ? |
|---|
| 674 | LocalFileMng::writeXmlString( &jackDriverNode, "jack_track_output_mode", to_string ( m_nJackTrackOutputMode )); |
|---|
| 675 | |
|---|
| 676 | // jack track outs |
|---|
| 677 | QString jackTrackOutsString = "false"; |
|---|
| 678 | if ( m_bJackTrackOuts ) { |
|---|
| 679 | jackTrackOutsString = "true"; |
|---|
| 680 | } |
|---|
| 681 | LocalFileMng::writeXmlString( &jackDriverNode, "jack_track_outs", jackTrackOutsString ); |
|---|
| 682 | QString jackArdourTransportWorkaroundString = |
|---|
| 683 | (m_nJackArdourTransportWorkaround) ? "true" : "false"; |
|---|
| 684 | LocalFileMng::writeXmlString( &jackDriverNode, "jack_ardour_transport_workaround", jackArdourTransportWorkaroundString ); |
|---|
| 685 | } |
|---|
| 686 | audioEngineNode.InsertEndChild( jackDriverNode ); |
|---|
| 687 | |
|---|
| 688 | //// ALSA AUDIO DRIVER //// |
|---|
| 689 | TiXmlElement alsaAudioDriverNode( "alsa_audio_driver" ); |
|---|
| 690 | { |
|---|
| 691 | LocalFileMng::writeXmlString( &alsaAudioDriverNode, "alsa_audio_device", m_sAlsaAudioDevice ); |
|---|
| 692 | } |
|---|
| 693 | audioEngineNode.InsertEndChild( alsaAudioDriverNode ); |
|---|
| 694 | |
|---|
| 695 | /// MIDI DRIVER /// |
|---|
| 696 | TiXmlElement midiDriverNode( "midi_driver" ); |
|---|
| 697 | { |
|---|
| 698 | LocalFileMng::writeXmlString( &midiDriverNode, "driverName", m_sMidiDriver ); |
|---|
| 699 | LocalFileMng::writeXmlString( &midiDriverNode, "port_name", m_sMidiPortName ); |
|---|
| 700 | LocalFileMng::writeXmlString( &midiDriverNode, "channel_filter", to_string( m_nMidiChannelFilter ) ); |
|---|
| 701 | |
|---|
| 702 | if ( m_bMidiNoteOffIgnore ) { |
|---|
| 703 | LocalFileMng::writeXmlString( &midiDriverNode, "ignore_note_off", "true" ); |
|---|
| 704 | } else { |
|---|
| 705 | LocalFileMng::writeXmlString( &midiDriverNode, "ignore_note_off", "false" ); |
|---|
| 706 | } |
|---|
| 707 | |
|---|
| 708 | if ( m_bMidiDiscardNoteAfterAction ) { |
|---|
| 709 | LocalFileMng::writeXmlString( &midiDriverNode, "discard_note_after_action", "true" ); |
|---|
| 710 | } else { |
|---|
| 711 | LocalFileMng::writeXmlString( &midiDriverNode, "discard_note_after_action", "false" ); |
|---|
| 712 | } |
|---|
| 713 | } |
|---|
| 714 | audioEngineNode.InsertEndChild( midiDriverNode ); |
|---|
| 715 | |
|---|
| 716 | |
|---|
| 717 | |
|---|
| 718 | } |
|---|
| 719 | rootNode.InsertEndChild( audioEngineNode ); |
|---|
| 720 | |
|---|
| 721 | //---- GUI ---- |
|---|
| 722 | TiXmlElement guiNode( "gui" ); |
|---|
| 723 | { |
|---|
| 724 | LocalFileMng::writeXmlString( &guiNode, "QTStyle", m_sQTStyle ); |
|---|
| 725 | LocalFileMng::writeXmlString( &guiNode, "application_font_family", applicationFontFamily ); |
|---|
| 726 | LocalFileMng::writeXmlString( &guiNode, "application_font_pointsize", to_string( applicationFontPointSize ) ); |
|---|
| 727 | LocalFileMng::writeXmlString( &guiNode, "mixer_font_family", mixerFontFamily ); |
|---|
| 728 | LocalFileMng::writeXmlString( &guiNode, "mixer_font_pointsize", to_string( mixerFontPointSize ) ); |
|---|
| 729 | LocalFileMng::writeXmlString( &guiNode, "mixer_falloff_speed", to_string( mixerFalloffSpeed ) ); |
|---|
| 730 | LocalFileMng::writeXmlString( &guiNode, "patternEditorGridResolution", to_string( m_nPatternEditorGridResolution ) ); |
|---|
| 731 | LocalFileMng::writeXmlString( &guiNode, "patternEditorGridHeight", to_string( m_nPatternEditorGridHeight ) ); |
|---|
| 732 | LocalFileMng::writeXmlString( &guiNode, "patternEditorGridWidth", to_string( m_nPatternEditorGridWidth ) ); |
|---|
| 733 | LocalFileMng::writeXmlBool( &guiNode, "patternEditorUsingTriplets", m_bPatternEditorUsingTriplets ); |
|---|
| 734 | LocalFileMng::writeXmlBool( &guiNode, "showInstrumentPeaks", m_bShowInstrumentPeaks ); |
|---|
| 735 | LocalFileMng::writeXmlBool( &guiNode, "isFXTabVisible", m_bIsFXTabVisible ); |
|---|
| 736 | |
|---|
| 737 | |
|---|
| 738 | // MainForm window properties |
|---|
| 739 | writeWindowProperties( guiNode, "mainForm_properties", mainFormProperties ); |
|---|
| 740 | writeWindowProperties( guiNode, "mixer_properties", mixerProperties ); |
|---|
| 741 | writeWindowProperties( guiNode, "patternEditor_properties", patternEditorProperties ); |
|---|
| 742 | writeWindowProperties( guiNode, "songEditor_properties", songEditorProperties ); |
|---|
| 743 | writeWindowProperties( guiNode, "drumkitManager_properties", drumkitManagerProperties ); |
|---|
| 744 | writeWindowProperties( guiNode, "audioEngineInfo_properties", audioEngineInfoProperties ); |
|---|
| 745 | for ( unsigned nFX = 0; nFX < MAX_FX; nFX++ ) { |
|---|
| 746 | QString sNode = "ladspaFX_properties" + to_string( nFX ); |
|---|
| 747 | writeWindowProperties( guiNode, sNode, m_ladspaProperties[nFX] ); |
|---|
| 748 | } |
|---|
| 749 | |
|---|
| 750 | LocalFileMng::writeXmlBool( &guiNode, "followPlayhead", m_bFollowPlayhead ); |
|---|
| 751 | |
|---|
| 752 | |
|---|
| 753 | //beatcounter |
|---|
| 754 | QString bcMode; |
|---|
| 755 | if ( m_bbc == BC_OFF ) { |
|---|
| 756 | bcMode = "BC_OFF"; |
|---|
| 757 | } else if ( m_bbc == BC_ON ) { |
|---|
| 758 | bcMode = "BC_ON"; |
|---|
| 759 | } |
|---|
| 760 | LocalFileMng::writeXmlString( &guiNode, "bc", bcMode ); |
|---|
| 761 | |
|---|
| 762 | |
|---|
| 763 | |
|---|
| 764 | QString setPlay; |
|---|
| 765 | if ( m_mmcsetplay == SET_PLAY_OFF ) { |
|---|
| 766 | setPlay = "SET_PLAY_OFF"; |
|---|
| 767 | } else if ( m_mmcsetplay == SET_PLAY_ON ) { |
|---|
| 768 | setPlay = "SET_PLAY_ON"; |
|---|
| 769 | } |
|---|
| 770 | LocalFileMng::writeXmlString( &guiNode, "setplay", setPlay ); |
|---|
| 771 | |
|---|
| 772 | LocalFileMng::writeXmlString( &guiNode, "countoffset", to_string(m_countOffset) ); |
|---|
| 773 | LocalFileMng::writeXmlString( &guiNode, "playoffset", to_string(m_startOffset) ); |
|---|
| 774 | //~ beatcounter |
|---|
| 775 | |
|---|
| 776 | // User interface style |
|---|
| 777 | writeUIStyle( guiNode ); |
|---|
| 778 | } |
|---|
| 779 | rootNode.InsertEndChild( guiNode ); |
|---|
| 780 | |
|---|
| 781 | //---- FILES ---- |
|---|
| 782 | TiXmlElement filesNode( "files" ); |
|---|
| 783 | { |
|---|
| 784 | // last used song |
|---|
| 785 | LocalFileMng::writeXmlString( &filesNode, "lastSongFilename", lastSongFilename ); |
|---|
| 786 | LocalFileMng::writeXmlString( &filesNode, "defaulteditor", m_sDefaultEditor ); |
|---|
| 787 | } |
|---|
| 788 | rootNode.InsertEndChild( filesNode ); |
|---|
| 789 | |
|---|
| 790 | MidiMap * mM = MidiMap::getInstance(); |
|---|
| 791 | std::map< QString, Action* > mmcMap = mM->getMMCMap(); |
|---|
| 792 | |
|---|
| 793 | //---- MidiMap ---- |
|---|
| 794 | TiXmlElement midiEventMapNode( "midiEventMap" ); |
|---|
| 795 | { |
|---|
| 796 | std::map< QString, Action* >::iterator dIter( mmcMap.begin() ); |
|---|
| 797 | for( dIter = mmcMap.begin(); dIter != mmcMap.end(); dIter++ ){ |
|---|
| 798 | |
|---|
| 799 | QString event = dIter->first; |
|---|
| 800 | Action * pAction = dIter->second; |
|---|
| 801 | |
|---|
| 802 | if ( pAction->getType() != "NOTHING" ){ |
|---|
| 803 | TiXmlElement midiEventNode( "midiEvent" ); |
|---|
| 804 | |
|---|
| 805 | LocalFileMng::writeXmlString( &midiEventNode, "mmcEvent" , event ); |
|---|
| 806 | LocalFileMng::writeXmlString( &midiEventNode, "action" , pAction->getType()); |
|---|
| 807 | LocalFileMng::writeXmlString( &midiEventNode, "parameter" , pAction->getParameter1() ); |
|---|
| 808 | |
|---|
| 809 | midiEventMapNode.InsertEndChild(midiEventNode); |
|---|
| 810 | } |
|---|
| 811 | } |
|---|
| 812 | |
|---|
| 813 | for( int note=0; note < 128; note++ ){ |
|---|
| 814 | Action * pAction = mM->getNoteAction( note ); |
|---|
| 815 | if( pAction != NULL && pAction->getType() != "NOTHING") { |
|---|
| 816 | TiXmlElement midiEventNode( "midiEvent" ); |
|---|
| 817 | |
|---|
| 818 | LocalFileMng::writeXmlString( &midiEventNode, "noteEvent" , QString("NOTE") ); |
|---|
| 819 | LocalFileMng::writeXmlString( &midiEventNode, "eventParameter" , QString::number( note ) ); |
|---|
| 820 | LocalFileMng::writeXmlString( &midiEventNode, "action" , pAction->getType() ); |
|---|
| 821 | LocalFileMng::writeXmlString( &midiEventNode, "parameter" , pAction->getParameter1() ); |
|---|
| 822 | |
|---|
| 823 | |
|---|
| 824 | midiEventMapNode.InsertEndChild(midiEventNode); |
|---|
| 825 | } |
|---|
| 826 | } |
|---|
| 827 | |
|---|
| 828 | for( int parameter=0; parameter < 128; parameter++ ){ |
|---|
| 829 | Action * pAction = mM->getCCAction( parameter ); |
|---|
| 830 | if( pAction != NULL && pAction->getType() != "NOTHING") |
|---|
| 831 | { |
|---|
| 832 | TiXmlElement midiEventNode( "midiEvent" ); |
|---|
| 833 | |
|---|
| 834 | LocalFileMng::writeXmlString( &midiEventNode, "ccEvent" , QString("CC") ); |
|---|
| 835 | LocalFileMng::writeXmlString( &midiEventNode, "eventParameter" , QString::number( parameter ) ); |
|---|
| 836 | |
|---|
| 837 | |
|---|
| 838 | LocalFileMng::writeXmlString( &midiEventNode, "action" , pAction->getType() ); |
|---|
| 839 | |
|---|
| 840 | LocalFileMng::writeXmlString( &midiEventNode, "parameter" , pAction->getParameter1() ); |
|---|
| 841 | |
|---|
| 842 | midiEventMapNode.InsertEndChild(midiEventNode); |
|---|
| 843 | } |
|---|
| 844 | } |
|---|
| 845 | } |
|---|
| 846 | |
|---|
| 847 | rootNode.InsertEndChild( midiEventMapNode ); |
|---|
| 848 | |
|---|
| 849 | doc.InsertEndChild( rootNode ); |
|---|
| 850 | doc.SaveFile(); |
|---|
| 851 | } |
|---|
| 852 | |
|---|
| 853 | |
|---|
| 854 | |
|---|
| 855 | /// |
|---|
| 856 | /// Create preferences directory |
|---|
| 857 | /// |
|---|
| 858 | void Preferences::createPreferencesDirectory() |
|---|
| 859 | { |
|---|
| 860 | QString prefDir = m_sPreferencesDirectory; |
|---|
| 861 | INFOLOG( "Creating preference file directory in " + prefDir ); |
|---|
| 862 | |
|---|
| 863 | QDir dir; |
|---|
| 864 | dir.mkdir( prefDir ); |
|---|
| 865 | } |
|---|
| 866 | |
|---|
| 867 | |
|---|
| 868 | |
|---|
| 869 | /// |
|---|
| 870 | /// Create data directory |
|---|
| 871 | /// |
|---|
| 872 | void Preferences::createDataDirectory() |
|---|
| 873 | { |
|---|
| 874 | QString sDir = m_sDataDirectory; |
|---|
| 875 | INFOLOG( "Creating data directory in " + sDir ); |
|---|
| 876 | |
|---|
| 877 | QDir dir; |
|---|
| 878 | dir.mkdir( sDir ); |
|---|
| 879 | // mkdir(dir.c_str(),S_IRWXU); |
|---|
| 880 | } |
|---|
| 881 | |
|---|
| 882 | void Preferences::createSoundLibraryDirectories() |
|---|
| 883 | { |
|---|
| 884 | QString sDir = m_sDataDirectory; |
|---|
| 885 | QString sDrumkitDir; |
|---|
| 886 | QString sSongDir; |
|---|
| 887 | QString sPatternDir; |
|---|
| 888 | QString sPlaylistDir; |
|---|
| 889 | |
|---|
| 890 | INFOLOG( "Creating soundLibrary directories in " + sDir ); |
|---|
| 891 | |
|---|
| 892 | sDrumkitDir = sDir + "/drumkits"; |
|---|
| 893 | sSongDir = sDir + "/songs"; |
|---|
| 894 | sPatternDir = sDir + "/patterns"; |
|---|
| 895 | sPlaylistDir = sDir + "/playlists"; |
|---|
| 896 | |
|---|
| 897 | QDir dir; |
|---|
| 898 | dir.mkdir( sDrumkitDir ); |
|---|
| 899 | dir.mkdir( sSongDir ); |
|---|
| 900 | dir.mkdir( sPatternDir ); |
|---|
| 901 | dir.mkdir( sPlaylistDir ); |
|---|
| 902 | } |
|---|
| 903 | |
|---|
| 904 | |
|---|
| 905 | void Preferences::setMostRecentFX( QString FX_name ) |
|---|
| 906 | { |
|---|
| 907 | int pos = m_recentFX.indexOf( FX_name ); |
|---|
| 908 | |
|---|
| 909 | if ( pos != -1 ) |
|---|
| 910 | m_recentFX.removeAt( pos ); |
|---|
| 911 | |
|---|
| 912 | m_recentFX.push_front( FX_name ); |
|---|
| 913 | } |
|---|
| 914 | |
|---|
| 915 | void Preferences::setRecentFiles( std::vector<QString> recentFiles ) |
|---|
| 916 | { |
|---|
| 917 | // find single filenames. (skip duplicates) |
|---|
| 918 | std::vector<QString> temp; |
|---|
| 919 | for ( unsigned i = 0; i < recentFiles.size(); i++ ) { |
|---|
| 920 | QString sFilename = recentFiles[ i ]; |
|---|
| 921 | |
|---|
| 922 | bool bExists = false; |
|---|
| 923 | for ( unsigned j = 0; j < temp.size(); j++ ) { |
|---|
| 924 | if ( sFilename == temp[ j ] ) { |
|---|
| 925 | bExists = true; |
|---|
| 926 | break; |
|---|
| 927 | } |
|---|
| 928 | } |
|---|
| 929 | if ( !bExists ) { |
|---|
| 930 | temp.push_back( sFilename ); |
|---|
| 931 | } |
|---|
| 932 | } |
|---|
| 933 | |
|---|
| 934 | m_recentFiles = temp; |
|---|
| 935 | } |
|---|
| 936 | |
|---|
| 937 | |
|---|
| 938 | |
|---|
| 939 | /// Read the xml nodes related to window properties |
|---|
| 940 | WindowProperties Preferences::readWindowProperties( TiXmlNode *parent, const QString& windowName, WindowProperties defaultProp ) |
|---|
| 941 | { |
|---|
| 942 | WindowProperties prop = defaultProp; |
|---|
| 943 | |
|---|
| 944 | TiXmlNode* windowPropNode; |
|---|
| 945 | if ( !( windowPropNode = parent->FirstChild( windowName.toAscii() ) ) ) { |
|---|
| 946 | WARNINGLOG( "Error reading configuration file: " + windowName + " node not found" ); |
|---|
| 947 | } else { |
|---|
| 948 | prop.visible = LocalFileMng::readXmlBool( windowPropNode, "visible", true ); |
|---|
| 949 | prop.x = LocalFileMng::readXmlInt( windowPropNode, "x", prop.x ); |
|---|
| 950 | prop.y = LocalFileMng::readXmlInt( windowPropNode, "y", prop.y ); |
|---|
| 951 | prop.width = LocalFileMng::readXmlInt( windowPropNode, "width", prop.width ); |
|---|
| 952 | prop.height = LocalFileMng::readXmlInt( windowPropNode, "height", prop.height ); |
|---|
| 953 | } |
|---|
| 954 | |
|---|
| 955 | return prop; |
|---|
| 956 | } |
|---|
| 957 | |
|---|
| 958 | |
|---|
| 959 | |
|---|
| 960 | /// Write the xml nodes related to window properties |
|---|
| 961 | void Preferences::writeWindowProperties( TiXmlNode& parent, const QString& windowName, const WindowProperties& prop ) |
|---|
| 962 | { |
|---|
| 963 | TiXmlElement windowPropNode( windowName.toAscii() ); |
|---|
| 964 | if ( prop.visible ) { |
|---|
| 965 | LocalFileMng::writeXmlString( &windowPropNode, "visible", "true" ); |
|---|
| 966 | } else { |
|---|
| 967 | LocalFileMng::writeXmlString( &windowPropNode, "visible", "false" ); |
|---|
| 968 | } |
|---|
| 969 | |
|---|
| 970 | LocalFileMng::writeXmlString( &windowPropNode, "x", to_string( prop.x ) ); |
|---|
| 971 | LocalFileMng::writeXmlString( &windowPropNode, "y", to_string( prop.y ) ); |
|---|
| 972 | LocalFileMng::writeXmlString( &windowPropNode, "width", to_string( prop.width ) ); |
|---|
| 973 | LocalFileMng::writeXmlString( &windowPropNode, "height", to_string( prop.height ) ); |
|---|
| 974 | parent.InsertEndChild( windowPropNode ); |
|---|
| 975 | } |
|---|
| 976 | |
|---|
| 977 | |
|---|
| 978 | |
|---|
| 979 | void Preferences::writeUIStyle( TiXmlNode& parent ) |
|---|
| 980 | { |
|---|
| 981 | TiXmlElement node( "UI_Style" ); |
|---|
| 982 | |
|---|
| 983 | // SONG EDITOR |
|---|
| 984 | TiXmlElement songEditorNode( "songEditor" ); |
|---|
| 985 | LocalFileMng::writeXmlString( &songEditorNode, "backgroundColor", m_pDefaultUIStyle->m_songEditor_backgroundColor.toStringFmt() ); |
|---|
| 986 | LocalFileMng::writeXmlString( &songEditorNode, "alternateRowColor", m_pDefaultUIStyle->m_songEditor_alternateRowColor.toStringFmt() ); |
|---|
| 987 | LocalFileMng::writeXmlString( &songEditorNode, "selectedRowColor", m_pDefaultUIStyle->m_songEditor_selectedRowColor.toStringFmt() ); |
|---|
| 988 | LocalFileMng::writeXmlString( &songEditorNode, "lineColor", m_pDefaultUIStyle->m_songEditor_lineColor.toStringFmt() ); |
|---|
| 989 | LocalFileMng::writeXmlString( &songEditorNode, "textColor", m_pDefaultUIStyle->m_songEditor_textColor.toStringFmt() ); |
|---|
| 990 | LocalFileMng::writeXmlString( &songEditorNode, "pattern1Color", m_pDefaultUIStyle->m_songEditor_pattern1Color.toStringFmt() ); |
|---|
| 991 | node.InsertEndChild( songEditorNode ); |
|---|
| 992 | |
|---|
| 993 | // PATTERN EDITOR |
|---|
| 994 | TiXmlElement patternEditorNode( "patternEditor" ); |
|---|
| 995 | LocalFileMng::writeXmlString( &patternEditorNode, "backgroundColor", m_pDefaultUIStyle->m_patternEditor_backgroundColor.toStringFmt() ); |
|---|
| 996 | LocalFileMng::writeXmlString( &patternEditorNode, "alternateRowColor", m_pDefaultUIStyle->m_patternEditor_alternateRowColor.toStringFmt() ); |
|---|
| 997 | LocalFileMng::writeXmlString( &patternEditorNode, "selectedRowColor", m_pDefaultUIStyle->m_patternEditor_selectedRowColor.toStringFmt() ); |
|---|
| 998 | LocalFileMng::writeXmlString( &patternEditorNode, "textColor", m_pDefaultUIStyle->m_patternEditor_textColor.toStringFmt() ); |
|---|
| 999 | LocalFileMng::writeXmlString( &patternEditorNode, "noteColor", m_pDefaultUIStyle->m_patternEditor_noteColor.toStringFmt() ); |
|---|
| 1000 | LocalFileMng::writeXmlString( &patternEditorNode, "lineColor", m_pDefaultUIStyle->m_patternEditor_lineColor.toStringFmt() ); |
|---|
| 1001 | LocalFileMng::writeXmlString( &patternEditorNode, "line1Color", m_pDefaultUIStyle->m_patternEditor_line1Color.toStringFmt() ); |
|---|
| 1002 | LocalFileMng::writeXmlString( &patternEditorNode, "line2Color", m_pDefaultUIStyle->m_patternEditor_line2Color.toStringFmt() ); |
|---|
| 1003 | LocalFileMng::writeXmlString( &patternEditorNode, "line3Color", m_pDefaultUIStyle->m_patternEditor_line3Color.toStringFmt() ); |
|---|
| 1004 | LocalFileMng::writeXmlString( &patternEditorNode, "line4Color", m_pDefaultUIStyle->m_patternEditor_line4Color.toStringFmt() ); |
|---|
| 1005 | LocalFileMng::writeXmlString( &patternEditorNode, "line5Color", m_pDefaultUIStyle->m_patternEditor_line5Color.toStringFmt() ); |
|---|
| 1006 | node.InsertEndChild( patternEditorNode ); |
|---|
| 1007 | |
|---|
| 1008 | parent.InsertEndChild( node ); |
|---|
| 1009 | } |
|---|
| 1010 | |
|---|
| 1011 | |
|---|
| 1012 | |
|---|
| 1013 | void Preferences::readUIStyle( TiXmlNode& parent ) |
|---|
| 1014 | { |
|---|
| 1015 | // SONG EDITOR |
|---|
| 1016 | TiXmlNode* pSongEditorNode = parent.FirstChild( "songEditor" ); |
|---|
| 1017 | if ( pSongEditorNode ) { |
|---|
| 1018 | m_pDefaultUIStyle->m_songEditor_backgroundColor = H2RGBColor( LocalFileMng::readXmlString( pSongEditorNode, "backgroundColor", m_pDefaultUIStyle->m_songEditor_backgroundColor.toStringFmt() ) ); |
|---|
| 1019 | m_pDefaultUIStyle->m_songEditor_alternateRowColor = H2RGBColor( LocalFileMng::readXmlString( pSongEditorNode, "alternateRowColor", m_pDefaultUIStyle->m_songEditor_alternateRowColor.toStringFmt() ) ); |
|---|
| 1020 | m_pDefaultUIStyle->m_songEditor_selectedRowColor = H2RGBColor( LocalFileMng::readXmlString( pSongEditorNode, "selectedRowColor", m_pDefaultUIStyle->m_songEditor_selectedRowColor.toStringFmt() ) ); |
|---|
| 1021 | m_pDefaultUIStyle->m_songEditor_lineColor = H2RGBColor( LocalFileMng::readXmlString( pSongEditorNode, "lineColor", m_pDefaultUIStyle->m_songEditor_lineColor.toStringFmt() ) ); |
|---|
| 1022 | m_pDefaultUIStyle->m_songEditor_textColor = H2RGBColor( LocalFileMng::readXmlString( pSongEditorNode, "textColor", m_pDefaultUIStyle->m_songEditor_textColor.toStringFmt() ) ); |
|---|
| 1023 | m_pDefaultUIStyle->m_songEditor_pattern1Color = H2RGBColor( LocalFileMng::readXmlString( pSongEditorNode, "pattern1Color", m_pDefaultUIStyle->m_songEditor_pattern1Color.toStringFmt() ) ); |
|---|
| 1024 | } else { |
|---|
| 1025 | WARNINGLOG( "songEditor node not found" ); |
|---|
| 1026 | } |
|---|
| 1027 | |
|---|
| 1028 | // PATTERN EDITOR |
|---|
| 1029 | TiXmlNode* pPatternEditorNode = parent.FirstChild( "patternEditor" ); |
|---|
| 1030 | if ( pPatternEditorNode ) { |
|---|
| 1031 | m_pDefaultUIStyle->m_patternEditor_backgroundColor = H2RGBColor( LocalFileMng::readXmlString( pPatternEditorNode, "backgroundColor", m_pDefaultUIStyle->m_patternEditor_backgroundColor.toStringFmt() ) ); |
|---|
| 1032 | m_pDefaultUIStyle->m_patternEditor_alternateRowColor = H2RGBColor( LocalFileMng::readXmlString( pPatternEditorNode, "alternateRowColor", m_pDefaultUIStyle->m_patternEditor_alternateRowColor.toStringFmt() ) ); |
|---|
| 1033 | m_pDefaultUIStyle->m_patternEditor_selectedRowColor = H2RGBColor( LocalFileMng::readXmlString( pPatternEditorNode, "selectedRowColor", m_pDefaultUIStyle->m_patternEditor_selectedRowColor.toStringFmt() ) ); |
|---|
| 1034 | m_pDefaultUIStyle->m_patternEditor_textColor = H2RGBColor( LocalFileMng::readXmlString( pPatternEditorNode, "textColor", m_pDefaultUIStyle->m_patternEditor_textColor.toStringFmt() ) ); |
|---|
| 1035 | m_pDefaultUIStyle->m_patternEditor_noteColor = H2RGBColor( LocalFileMng::readXmlString( pPatternEditorNode, "noteColor", m_pDefaultUIStyle->m_patternEditor_noteColor.toStringFmt() ) ); |
|---|
| 1036 | m_pDefaultUIStyle->m_patternEditor_lineColor = H2RGBColor( LocalFileMng::readXmlString( pPatternEditorNode, "lineColor", m_pDefaultUIStyle->m_patternEditor_lineColor.toStringFmt() ) ); |
|---|
| 1037 | m_pDefaultUIStyle->m_patternEditor_line1Color = H2RGBColor( LocalFileMng::readXmlString( pPatternEditorNode, "line1Color", m_pDefaultUIStyle->m_patternEditor_line1Color.toStringFmt() ) ); |
|---|
| 1038 | m_pDefaultUIStyle->m_patternEditor_line2Color = H2RGBColor( LocalFileMng::readXmlString( pPatternEditorNode, "line2Color", m_pDefaultUIStyle->m_patternEditor_line2Color.toStringFmt() ) ); |
|---|
| 1039 | m_pDefaultUIStyle->m_patternEditor_line3Color = H2RGBColor( LocalFileMng::readXmlString( pPatternEditorNode, "line3Color", m_pDefaultUIStyle->m_patternEditor_line3Color.toStringFmt() ) ); |
|---|
| 1040 | m_pDefaultUIStyle->m_patternEditor_line4Color = H2RGBColor( LocalFileMng::readXmlString( pPatternEditorNode, "line4Color", m_pDefaultUIStyle->m_patternEditor_line4Color.toStringFmt() ) ); |
|---|
| 1041 | m_pDefaultUIStyle->m_patternEditor_line5Color = H2RGBColor( LocalFileMng::readXmlString( pPatternEditorNode, "line5Color", m_pDefaultUIStyle->m_patternEditor_line5Color.toStringFmt() ) ); |
|---|
| 1042 | } else { |
|---|
| 1043 | WARNINGLOG( "patternEditor node not found" ); |
|---|
| 1044 | } |
|---|
| 1045 | } |
|---|
| 1046 | |
|---|
| 1047 | |
|---|
| 1048 | // ----------------------- |
|---|
| 1049 | |
|---|
| 1050 | |
|---|
| 1051 | |
|---|
| 1052 | |
|---|
| 1053 | WindowProperties::WindowProperties() |
|---|
| 1054 | : Object( "WindowProperties" ) |
|---|
| 1055 | { |
|---|
| 1056 | // infoLog( "INIT" ); |
|---|
| 1057 | x = 0; |
|---|
| 1058 | y = 0; |
|---|
| 1059 | width = 0; |
|---|
| 1060 | height = 0; |
|---|
| 1061 | visible = true; |
|---|
| 1062 | } |
|---|
| 1063 | |
|---|
| 1064 | |
|---|
| 1065 | |
|---|
| 1066 | WindowProperties::~WindowProperties() |
|---|
| 1067 | { |
|---|
| 1068 | // infoLog( "DESTROY" ); |
|---|
| 1069 | } |
|---|
| 1070 | |
|---|
| 1071 | |
|---|
| 1072 | |
|---|
| 1073 | |
|---|
| 1074 | // ::::::::::::::::::::::::::::::: |
|---|
| 1075 | |
|---|
| 1076 | |
|---|
| 1077 | |
|---|
| 1078 | UIStyle::UIStyle() |
|---|
| 1079 | : Object( "UIStyle" ) |
|---|
| 1080 | { |
|---|
| 1081 | // infoLog( "INIT" ); |
|---|
| 1082 | } |
|---|
| 1083 | |
|---|
| 1084 | |
|---|
| 1085 | |
|---|
| 1086 | // :::::::::::::::::::::::::::::::::::::: |
|---|
| 1087 | |
|---|
| 1088 | |
|---|
| 1089 | |
|---|
| 1090 | H2RGBColor::H2RGBColor( int r, int g, int b ) |
|---|
| 1091 | : Object( "H2RGBColor" ) |
|---|
| 1092 | , m_red( r ) |
|---|
| 1093 | , m_green( g ) |
|---|
| 1094 | , m_blue( b ) |
|---|
| 1095 | { |
|---|
| 1096 | // infoLog( "INIT" ); |
|---|
| 1097 | } |
|---|
| 1098 | |
|---|
| 1099 | |
|---|
| 1100 | |
|---|
| 1101 | H2RGBColor::~H2RGBColor() |
|---|
| 1102 | { |
|---|
| 1103 | // infoLog( "DESTROY" ); |
|---|
| 1104 | } |
|---|
| 1105 | |
|---|
| 1106 | |
|---|
| 1107 | |
|---|
| 1108 | H2RGBColor::H2RGBColor( const QString& sColor ) |
|---|
| 1109 | : Object( "H2RGBColor" ) |
|---|
| 1110 | { |
|---|
| 1111 | // infoLog( "INIT " + sColor ); |
|---|
| 1112 | QString temp = sColor; |
|---|
| 1113 | |
|---|
| 1114 | QStringList list = temp.split(","); |
|---|
| 1115 | m_red = list[0].toInt(); |
|---|
| 1116 | m_green = list[1].toInt(); |
|---|
| 1117 | m_blue = list[2].toInt(); |
|---|
| 1118 | |
|---|
| 1119 | /* |
|---|
| 1120 | int nPos = temp.indexOf( ',' ); |
|---|
| 1121 | QString sRed = temp.substr( 0, nPos ); |
|---|
| 1122 | temp.erase( 0, nPos + 1 ); |
|---|
| 1123 | |
|---|
| 1124 | nPos = temp.find( ',' ); |
|---|
| 1125 | QString sGreen = temp.substr( 0, nPos ); |
|---|
| 1126 | temp.erase( 0, nPos + 1 ); |
|---|
| 1127 | |
|---|
| 1128 | nPos = temp.find( ',' ); |
|---|
| 1129 | QString sBlue = temp.substr( 0, nPos ); |
|---|
| 1130 | |
|---|
| 1131 | m_red = atoi( sRed.c_str() ); |
|---|
| 1132 | m_green = atoi( sGreen.c_str() ); |
|---|
| 1133 | m_blue = atoi( sBlue.c_str() ); |
|---|
| 1134 | */ |
|---|
| 1135 | } |
|---|
| 1136 | |
|---|
| 1137 | |
|---|
| 1138 | |
|---|
| 1139 | QString H2RGBColor::toStringFmt() |
|---|
| 1140 | { |
|---|
| 1141 | char tmp[255]; |
|---|
| 1142 | sprintf( tmp, "%d,%d,%d", m_red, m_green, m_blue ); |
|---|
| 1143 | |
|---|
| 1144 | //string sRes = to_string( m_red ) + "," + to_string( m_green ) + "," + to_string( m_blue ); |
|---|
| 1145 | // return sRes; |
|---|
| 1146 | |
|---|
| 1147 | return QString( tmp ); |
|---|
| 1148 | } |
|---|
| 1149 | |
|---|
| 1150 | }; |
|---|