| 338 | } |
| 339 | |
| 340 | void Settings::loadOrCreateProfile(const QString & profileName) |
| 341 | { |
| 342 | DEBUG_MID_LEVEL << Q_FUNC_INFO << profileName; |
| 343 | |
| 344 | |
| 345 | QMutexLocker locker(&m_mutex); |
| 346 | QString currentProfileFileName = m_currentProfile != NULL ? m_currentProfile->fileName() : NULL; |
| 347 | |
| 348 | if (currentProfileFileName != NULL |
| 349 | && currentProfileFileName.compare(getProfilesPath() + profileName + ".ini") == 0) |
| 350 | return; //nothing to change, profile is already loaded |
| 351 | |
| 352 | if (currentProfileFileName != NULL) |
| 353 | { |
| 354 | // Copy current settings to new one |
| 355 | QString profileNewPath = getProfilesPath() + profileName + ".ini"; |
| 356 | |
| 357 | if (currentProfileFileName != profileNewPath) |
| 358 | QFile::copy(currentProfileFileName, profileNewPath); |
| 359 | |
| 360 | delete m_currentProfile; |
| 361 | } |
| 362 | |
| 363 | |
| 364 | m_currentProfile = new QSettings(getProfilesPath() + profileName + ".ini", QSettings::IniFormat ); |
| 365 | m_currentProfile->setIniCodec("UTF-8"); |
| 366 | |
| 367 | locker.unlock(); |
| 368 | initCurrentProfile(false); |
| 369 | locker.relock(); |
| 370 | |
| 371 | DEBUG_LOW_LEVEL << "Settings file:" << m_currentProfile->fileName(); |
| 372 | |
| 373 | m_mainConfig->setValue(Main::Key::ProfileLast, profileName); |
| 374 | locker.unlock(); |
| 375 | m_this->profileLoaded(profileName); |
| 376 | } |
| 377 | |
| 378 | void Settings::renameCurrentProfile(const QString & profileName) |
| 379 | { |