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(); }
/** * \brief applyOptions, if options have changed, they will be applied by calling this function * \param opt, unused, totally ignored */ void OptionsTabShortcuts::applyOptions() { if ( !w ) return; OptShortcutsUI *d = (OptShortcutsUI *)w; PsiOptions *options = PsiOptions::instance(); int toplevelItemsCount = d->treeShortcuts->topLevelItemCount(); int shortcutItemsCount; int keyItemsCount; QTreeWidgetItem *topLevelItem; QTreeWidgetItem *shortcutItem; QTreeWidgetItem *keyItem; QString optionsPath; QString comment; QList<QString> children; QList<QKeySequence> keys; /* step through the Toplevel Items */ for(int topLevelIndex = 0 ; topLevelIndex < toplevelItemsCount; topLevelIndex++) { topLevelItem = d->treeShortcuts->topLevelItem(topLevelIndex); shortcutItemsCount = topLevelItem->childCount(); /* step through the Shortcut Items */ for(int shortcutItemIndex = 0; shortcutItemIndex < shortcutItemsCount; shortcutItemIndex++) { shortcutItem = topLevelItem->child(shortcutItemIndex); keyItemsCount = shortcutItem->childCount(); /* get the Options Path of the Shortcut Item */ optionsPath = shortcutItem->data(0, OPTIONSTREEPATH).toString(); /* just one Key Sequence */ if(keyItemsCount == 1) { /* so set the option to this keysequence directly */ keyItem = shortcutItem->child(0); options->setOption(optionsPath, QVariant(keyItem->text(1))); } else if(keyItemsCount > 1){ /* more than one, then collect them in a list */ QList<QVariant> keySequences; for(int keyItemIndex = 0; keyItemIndex < keyItemsCount; keyItemIndex++) { keyItem = shortcutItem->child(keyItemIndex); keySequences.append(QVariant(keyItem->text(1))); } options->setOption(optionsPath, QVariant(keySequences)); } else { /* zero key sequences, so set an empty string, so it will be written empty to the options.xml */ options->setOption(optionsPath, ""); } } } }
void PsiToolBar::structToOptions(const QString &base, ToolbarPrefs *tb) { PsiOptions *o = PsiOptions::instance(); o->setOption(base+".name",tb->name); o->setOption(base+".visible",tb->on); o->setOption(base+".locked",tb->locked); o->setOption(base+".stretchable",tb->stretchable); o->setOption(base+".actions",tb->keys); o->setOption(base+".dock.position",tb->dock); // LEGOPTFIXME o->setOption(base+".dock.index",tb->index); o->setOption(base+".dock.nl",tb->nl); o->setOption(base+".dock.extra-offset",tb->extraOffset); }