Ejemplo n.º 1
0
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();
}
Ejemplo n.º 2
0
XMPP::Status makeLastStatus(int x)
{
	PsiOptions* o = PsiOptions::instance();
	if (lastPriorityNotEmpty()) {
		return makeStatus(x, o->getOption("options.status.last-message").toString(), o->getOption("options.status.last-priority").toInt());
	}
	else {
		return makeStatus(x, o->getOption("options.status.last-message").toString());
	}
}
Ejemplo n.º 3
0
void OptionsTabToolbars::restoreOptions()
{
	if (!w)
		return;

	LookFeelToolbarsUI *d = (LookFeelToolbarsUI *)w;

	PsiOptions *o = PsiOptions::instance();

	QStringList toolbarBases = o->getChildOptionNames("options.ui.contactlist.toolbars", true, true);

	foreach(QString base, toolbarBases) {
		ToolbarPrefs tb;
		tb.id = o->getOption(base + ".key").toString();
		tb.name = o->getOption(base + ".name").toString();
		tb.on = o->getOption(base + ".visible").toBool();
		tb.locked = o->getOption(base + ".locked").toBool();
		// tb.stretchable = o->getOption(base + ".stretchable").toBool();
		tb.dock = (Qt::Dock)o->getOption(base + ".dock.position").toInt(); //FIXME
		// tb.index = o->getOption(base + ".dock.index").toInt();
		tb.nl = o->getOption(base + ".dock.nl").toBool();
		// tb.extraOffset = o->getOption(base + ".dock.extra-offset").toInt();
		tb.keys = o->getOption(base + ".actions").toStringList();

		p->toolbars[base] = tb;
		d->cb_toolbars->addItem(tb.name, base);
	}
Ejemplo n.º 4
0
void OptionsTabToolbars::applyOptions()
{
	if (!w)
		return;

	PsiOptions *o = PsiOptions::instance();
	o->removeOption("options.ui.contactlist.toolbars", true);
	foreach (const ToolbarPrefs &toolbar, p->toolbars) {
		PsiToolBar::structToOptions(o, toolbar);
	}
}
Ejemplo n.º 5
0
/**
 * \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);	
}
Ejemplo n.º 7
0
void OptionsTabToolbars::applyOptions()
{
	if (!w)
		return;

	LookFeelToolbarsUI *d = (LookFeelToolbarsUI *)w;

	PsiOptions *o = PsiOptions::instance();
	o->removeOption("options.ui.contactlist.toolbars", true);
	QMap<QString, ToolbarPrefs>::Iterator it = p->toolbars.begin();
	for (; it != p->toolbars.end(); ++it) {
		PsiToolBar::structToOptions(o, it.data());
	}
}
Ejemplo n.º 8
0
void StatusPreset::filterStatus()
{
    PsiOptions* o = PsiOptions::instance();
    switch (status_) {
    case XMPP::Status::FFC:
        if (!o->getOption("options.ui.menu.status.chat").toBool()) {
            status_ = XMPP::Status::Online;
        }
        break;
    case XMPP::Status::XA:
        if (!o->getOption("options.ui.menu.status.xa").toBool()) {
            status_ = XMPP::Status::Away;
        }
        break;
    case XMPP::Status::Invisible:
        if (!o->getOption("options.ui.menu.status.invisible").toBool()) {
            status_ = XMPP::Status::DND;
        }
        break;
    default:
        break;
    }
}
Ejemplo n.º 9
0
Archivo: main.cpp Proyecto: gislan/psi
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()));
		}
	}
}