void ProfileNewDlg::slotCreate() { name = le_name->text(); if(profileExists(name)) { QMessageBox::information(this, CAP(tr("New Profile")), tr("There is already an existing profile with this name. Please choose another.")); return; } if(!profileNew(name)) { QMessageBox::information(this, CAP(tr("New Profile")), tr("Unable to create the profile. Please do not use any special characters.")); return; } // save config PsiOptions o; if (!o.newProfile()) { qWarning("ERROR: Failed to new profile default options"); } o.setOption("options.messages.default-outgoing-message-type" ,rb_message->isChecked() ? "message": "chat"); o.setOption("options.ui.emoticons.use-emoticons" ,ck_useEmoticons->isChecked()); o.save(pathToProfile(name, ApplicationInfo::ConfigLocation) + "/options.xml"); accept(); }
PsiMain::PsiMain(QObject *par) :QObject(par) { pcon = 0; // load simple registry settings QSettings sUser(QSettings::UserScope, "psi-im.org", "Psi"); lastProfile = sUser.value("last_profile").toString(); lastLang = sUser.value("last_lang").toString(); autoOpen = sUser.value("auto_open", QVariant(false)).toBool(); QSettings s(ApplicationInfo::homeDir() + "/psirc", QSettings::IniFormat); lastProfile = s.value("last_profile", lastProfile).toString(); lastLang = s.value("last_lang", lastLang).toString(); autoOpen = s.value("auto_open", autoOpen).toBool(); if(lastLang.isEmpty()) { lastLang = QTextCodec::locale(); //printf("guessing locale: [%s]\n", lastLang.latin1()); } TranslationManager::instance()->loadTranslation(lastLang); if(autoOpen && !lastProfile.isEmpty() && profileExists(lastProfile)) { // Auto-open the last profile activeProfile = lastProfile; QTimer::singleShot(0, this, SLOT(sessionStart())); } else if (!lastProfile.isEmpty() && !getProfilesList().isEmpty()) { // Select a profile QTimer::singleShot(0, this, SLOT(chooseProfile())); } else if (getProfilesList().count() == 1) { // Open the (only) profile activeProfile = getProfilesList()[0]; QTimer::singleShot(0, this, SLOT(sessionStart())); } else if (!getProfilesList().isEmpty()) { // Select a profile QTimer::singleShot(0, this, SLOT(chooseProfile())); } else { // Create & open the default profile if (!profileExists("default") && !profileNew("default")) { QMessageBox::critical(0, tr("Error"), tr("There was an error creating the default profile.")); QTimer::singleShot(0, this, SLOT(bail())); } else { PsiOptions o; if (!o.newProfile()) { qWarning("ERROR: Failed to new profile default options"); } o.save(pathToProfile("default") + "/options.xml"); lastProfile = activeProfile = "default"; autoOpen = true; QTimer::singleShot(0, this, SLOT(sessionStart())); } } }