Пример #1
0
void KdeSpellerSettings::loadImpl()
{
	Speller *speller = KdeSpellerLayer::spellerInstance();
	ConfigGroup group = Config().group("speller");
	m_ui->autodetect->setChecked(group.value("autodetect", false));
	QString lang = suggestLanguage(group.value("language", QString()), speller);
	if (!lang.isEmpty())
		m_ui->dictionaryComboBox->setCurrentByDictionary(lang);
}
Пример #2
0
void KdeSpellerLayer::loadSettings()
{
	ConfigGroup group = Config().group("speller");
	m_autodetect = group.value("autodetect", false);
	QString lang = KdeSpellerSettings::suggestLanguage(group.value("language", QString()), speller());
	if (!lang.isEmpty())
		m_dictionary = lang;
	else if (!speller()->availableDictionaries().isEmpty())
		m_dictionary = speller()->availableDictionaries().begin().value();
	speller()->setLanguage(m_dictionary);
	emit dictionaryChanged();
}
Пример #3
0
void ProtocolChooserWidget::loadImpl()
{
	clear();
	ConfigGroup group = Config().group("protocols");
	QVariantMap selected = group.value("list", QVariantMap());
	QStandardItem *parent_item = m_model->invisibleRootItem();

	ExtensionInfoList exts = extensionList();
	for (int i = 0; i < exts.size(); i++) {
		const ExtensionInfo &info = exts.at(i);
		const QMetaObject *meta = info.generator()->metaObject();
		QString name = QString::fromLatin1(MetaObjectBuilder::info(meta, "Protocol"));
		if (name.isEmpty())
			continue;

		if (!m_protocol_items.contains(name)) {
			ServiceItem *item = new ServiceItem(Icon("applications-system") ,name);
			item->setData(true,ServiceItem::ExclusiveRole);
			parent_item->appendRow(item);
			m_protocol_items.insert(name,item);
		}
		QIcon icon = Icon("applications-system");
		//TODO Make normal names for the implementation of protocols
		ServiceItem *item = new ServiceItem(icon,info.name());
		//ServiceItem *item = new ServiceItem(icon,info.name());

		item->setToolTip(ServiceChooser::html(info));
		item->setCheckable(true);
		item->setData(info.description().toString(),DescriptionRole);
		if (selected.value(name).toString() == ServiceChooser::className(info))
			item->setCheckState(Qt::Checked);
		item->setData(ServiceChooser::className(info),ServiceItem::ExtentionInfoRole);
		m_protocol_items.value(name)->appendRow(item);
	}
}
Пример #4
0
void YandexNarodAuthorizator::requestAuthorization()
{
	if (m_stage > Need) {
		if (m_stage == Already)
			emit result(Success);
		return;
	}
	ConfigGroup group = Config().group("yandex");
	QString login = group.value("login", QString());
	QString password = group.value("passwd", QString(), Config::Crypted);
	if (login.isEmpty() || password.isEmpty()) {
		PasswordDialog *dialog = PasswordDialog::request(
									 tr("Yandex.Disk authorizarion"),
									 tr("Enter your Yandex login and password"));
		dialog->setLoginEditVisible(true);
		dialog->setSaveButtonVisible(false);
		connect(dialog, SIGNAL(finished(int)), SLOT(onDialogFinished(int)));
		return;
	}
	return requestAuthorization(login, password);
}
Пример #5
0
YandexNarodManager::YandexNarodManager()
{
	setupUi(this);
	this->setWindowTitle(tr("Yandex.Narod file manager"));
	this->setWindowIcon(QIcon(":/icons/yandexnarodplugin.png"));
	frameProgress->hide();
	frameFileActions->hide();
	listWidget->clear();

	netman = new YandexNarodNetMan(this);
	connect(netman, SIGNAL(statusText(QString)), labelStatus, SLOT(setText(QString)));
	connect(netman, SIGNAL(progressMax(int)), progressBar, SLOT(setMaximum(int)));
	connect(netman, SIGNAL(progressValue(int)), progressBar, SLOT(setValue(int)));
	connect(netman, SIGNAL(newFileItem(FileItem)), this, SLOT(newFileItem(FileItem)));
	connect(netman, SIGNAL(finished()), this, SLOT(netmanFinished()));

	QPixmap iconimage(":/icons/yandexnarod-icons-files.png");
	for (int i=0; i<(iconimage.width()/16); i++) {
		QIcon icon(iconimage.copy((i*16),0,16,16));
		fileicons.append(icon);
	}

	fileiconstyles["b-icon-music"] = 0;
	fileiconstyles["b-icon-video"] = 1;
	fileiconstyles["b-icon-arc"] = 2;
	fileiconstyles["b-icon-doc"] = 3;
	fileiconstyles["b-icon-soft"] = 4;
	fileiconstyles["b-icon-unknown"] = 5;
	fileiconstyles["b-icon-picture"] = 14;

	uploadwidget=0;

	ConfigGroup group = Config().group("yandex").group("narod");

	QByteArray geometry = group.value("managerGeometry", QByteArray());
	if (!geometry.isEmpty())
		restoreGeometry(geometry);
	else
		centerizeWidget(this);

	setAttribute(Qt::WA_QuitOnClose, false);
	setAttribute(Qt::WA_DeleteOnClose, true);
}
Пример #6
0
void ServiceChoooserWidget::loadImpl()
{
	clear();
	ConfigGroup group = Config().group("services");
	QVariantMap selected = group.value("list", QVariantMap());
	QStandardItem *parent_item = m_model->invisibleRootItem();

	ExtensionInfoList exts = extensionList();
	QStringList helper;
	for (int i = 0; i < exts.size(); ++i) {
		const ExtensionInfo &info = exts.at(i);
		const char *serviceName = MetaObjectBuilder::info(info.generator()->metaObject(), "Service");

		if (serviceName && *serviceName) {
			if (!m_service_items.contains(serviceName)) {
				QString localizedName = QT_TRANSLATE_NOOP("Service",serviceName).toString();
				int index = qLowerBound(helper, localizedName) - helper.constBegin();
				helper.insert(index, localizedName);
				ServiceItem *item = new ServiceItem(Icon(serviceIcon(serviceName)),localizedName);
				item->setData(true,ServiceItem::ExclusiveRole);
				parent_item->insertRow(index, item);
				m_service_items.insert(serviceName,item);
			}
			QIcon icon = !info.icon().name().isEmpty() ?
						 info.icon() :
						 Icon("applications-system");
			ServiceItem *item = new ServiceItem(icon,info.name());

			item->setToolTip(ServiceChoooser::html(info));
			item->setCheckable(true);
			item->setData(info.description().toString(),DescriptionRole);
			if (selected.value(serviceName).toString() == ServiceChoooser::className(info))
				item->setCheckState(Qt::Checked);
			item->setData(qVariantFromValue(info), ServiceItem::ExtentionInfoRole);

			m_service_items.value(serviceName)->appendRow(item);
		}
	}
}
Пример #7
0
void ChatAppearance::loadImpl()
{
	if (!m_controller) {
		NotificationRequest request(Notification::System);
		request.setObject(this);
		request.setText(tr("Unable to create chat session"));
		request.send();
		return;
	}
	ConfigGroup quickChat = Config("appearance/qmlChat");
	ui->openGLBox->setChecked(quickChat.value("openGL",false));
	quickChat.beginGroup(QLatin1String("style"));
	m_currentStyleName = quickChat.value<QString>("name","default");
	quickChat.endGroup();
	getThemes();
	int index = ui->chatBox->findText(m_currentStyleName);
	isLoad = true;

	index = index == -1 ? 0 : index;
	if(index == ui->chatBox->currentIndex())
		onThemeChanged(index);
	else
		ui->chatBox->setCurrentIndex(index);
}
Пример #8
0
void GlobalConfig::readOptions()
{
    int i, count;

    // source options
    ConfigGroup* sourceConfig = ConfigStorage::group("Source");
    QStringList dirs;
    dirs = sourceConfig->value("Dirs", QStringList()).toStringList();
    if (dirs.count()>0) _generalSourceDirs = dirs;
    count = sourceConfig->value("Count", 0).toInt();
    _objectSourceDirs.clear();
    for (i=1;i<=count;i++) {
	QString n = sourceConfig->value(QString("Object%1").arg(i),
					QString()).toString();
	dirs = sourceConfig->value(QString("Dirs%1").arg(i),
				   QStringList()).toStringList();

	if (n.isEmpty() || (dirs.count()==0)) continue;

	_objectSourceDirs.insert(n, dirs);
    }
    delete sourceConfig;

    // general options
    ConfigGroup* generalConfig = ConfigStorage::group("GeneralSettings");
    _showPercentage   = generalConfig->value("ShowPercentage",
					     DEFAULT_SHOWPERCENTAGE).toBool();
    _showExpanded     = generalConfig->value("ShowExpanded",
					     DEFAULT_SHOWEXPANDED).toBool();
    _showCycles       = generalConfig->value("ShowCycles",
					     DEFAULT_SHOWCYCLES).toBool();
    _cycleCut         = generalConfig->value("CycleCut",
					     DEFAULT_CYCLECUT).toDouble();
    _percentPrecision = generalConfig->value("PercentPrecision",
					     DEFAULT_PERCENTPRECISION).toInt();
    _maxSymbolLength  = generalConfig->value("MaxSymbolLength",
					     DEFAULT_MAXSYMBOLLENGTH).toInt();
    _maxSymbolCount   = generalConfig->value("MaxSymbolCount",
					     DEFAULT_MAXSYMBOLCOUNT).toInt();
    _maxListCount     = generalConfig->value("MaxListCount",
					     DEFAULT_MAXLISTCOUNT).toInt();
    _context          = generalConfig->value("Context",
					     DEFAULT_CONTEXT).toInt();
    _noCostInside     = generalConfig->value("NoCostInside",
					     DEFAULT_NOCOSTINSIDE).toInt();
    _hideTemplates    = generalConfig->value("HideTemplates",
		                             DEFAULT_HIDETEMPLATES).toBool();
    delete generalConfig;

    // event types
    if (EventType::knownTypeCount() >0) return; // already read
    ConfigGroup* etConfig = ConfigStorage::group("EventTypes");
    int etCount = etConfig->value("Count", 0).toInt();

    for (int i=1;i<=etCount;i++) {
	QString n = etConfig->value(QString("Name%1").arg(i),
				    QString()).toString();
	QString l = etConfig->value(QString("Longname%1").arg(i),
				    QString()).toString();
	if (l.isEmpty()) l = knownLongName(n);
	QString f = etConfig->value(QString("Formula%1").arg(i),
				    QString()).toString();
	if (f.isEmpty()) f = knownFormula(n);

	EventType::add(new EventType(n, l, f));
    }

    // this does only add yet non-existing types
    addDefaultTypes();

    delete etConfig;
}
Пример #9
0
void ChatAppearance::makeSettings() {
	m_current_variables.clear();
	if (settingsWidget)
		delete settingsWidget;
	settingsWidget = new QWidget(this);
	QFormLayout *layout = new QFormLayout(settingsWidget);
	layout->setLabelAlignment(Qt::AlignLeft|Qt::AlignVCenter);
	QSizePolicy sizePolicy(QSizePolicy::Fixed, QSizePolicy::Expanding);
	settingsWidget->setLayout(layout);
	QString category = "webkitstyle";
	StyleVariants variants = ChatStyleGenerator::listVariants(ThemeManager::path(category, m_current_style_name)
															  .append("/Contents/Resources/Variants"));
	if (!variants.isEmpty()) {
		QLabel *label = new QLabel(tr("Style variant:"), settingsWidget);
		label->setSizePolicy(sizePolicy);
		QComboBox *variantBox = new QComboBox(settingsWidget);
		layout->addRow(label, variantBox);
		StyleVariants::const_iterator it;
		for (it=variants.begin(); it!=variants.end(); it++)
			variantBox->addItem(it.key());
		connect(variantBox, SIGNAL(currentIndexChanged(QString)), SLOT(onVariantChanged(QString)));
		int index = isLoad ? variantBox->findText(m_current_variant) : 0;
		m_current_variant = variantBox->itemText(index);
		variantBox->setCurrentIndex(index);
		onVariantChanged(m_current_variant);
	}
	Config achat(QStringList()
				 << "appearance/adiumChat"
				 << ThemeManager::path(category,m_current_style_name)
				 .append("/Contents/Resources/custom.json"));
	ConfigGroup variables = achat;
	int count = variables.beginArray(m_current_style_name);
	for (int num = 0; num < count; num++) {
		ConfigGroup parameter = variables.arrayElement(num);
		QString type = parameter.value("type", QString());
		QString text = parameter.value("label", QString());
		text = parameter.value(QString("label-").append(QLocale().name()), text);
		CustomChatStyle style;
		style.parameter = parameter.value("parameter", QString());
		style.selector = parameter.value("selector", QString());
		style.value = parameter.value("value", QString());
		if (type == "font") {
			QLabel *label = new QLabel(text % ":", settingsWidget);
			label->setSizePolicy(sizePolicy);
			ChatFont *fontField = new ChatFont(style, settingsWidget);
			layout->addRow(label, fontField);
			connect(fontField, SIGNAL(changeValue()), SLOT(onVariableChanged()));
			if (ChatVariable *widget = qobject_cast<ChatVariable*>(fontField))
				m_current_variables.append(widget);
		} else if (type == "color") {
			QLabel *label = new QLabel(text % ":", settingsWidget);
			label->setSizePolicy(sizePolicy);
			ChatColor *colorField = new ChatColor(style, settingsWidget);
			layout->addRow(label, colorField);
			connect(colorField, SIGNAL(changeValue()), SLOT(onVariableChanged()));
			if (ChatVariable *widget = qobject_cast<ChatVariable*>(colorField))
				m_current_variables.append(widget);
		} else if (type == "numeric") {
			QLabel *label = new QLabel(text % ":", settingsWidget);
			label->setSizePolicy(sizePolicy);
			double min = parameter.value<double>("min", 0);
			double max = parameter.value<double>("max", 0);
			double step = parameter.value<double>("step", 1);
			ChatNumeric *numField = new ChatNumeric(style, min, max, step, settingsWidget);
			layout->addRow(label, numField);
			connect(numField, SIGNAL(changeValue()), SLOT(onVariableChanged()));
			if (ChatVariable *widget = qobject_cast<ChatVariable*>(numField))
				m_current_variables.append(widget);
		} else if (type == "boolean") {
			QString trueValue = parameter.value("true", QString());
			QString falseValue = parameter.value("false", QString());
			ChatBoolean *boolField = new ChatBoolean(style, trueValue, falseValue, settingsWidget);
			boolField->setText(text);
			layout->addRow(boolField);
			connect(boolField, SIGNAL(changeValue()), SLOT(onVariableChanged()));
			if (ChatVariable *widget = qobject_cast<ChatVariable*>(boolField))
				m_current_variables.append(widget);
		}
	}
	onVariableChanged();
	QSpacerItem *space = new QSpacerItem(20, 40, QSizePolicy::Minimum, QSizePolicy::MinimumExpanding);
	layout->addItem(space);
	ui->scrollAreaLayout->addWidget(settingsWidget);
}
Пример #10
0
void GlobalConfig::readOptions()
{
    int i, count;

    // color options
    _colors.clear();
    // colors for default event types:
    //  red for L2 misses, green for L1 misses, blue for normal accesses
    colorSetting("EventType-I2mr")->_color = QColor(240, 0, 0);
    colorSetting("EventType-D2mr")->_color = QColor(180,40,40);
    colorSetting("EventType-D2mw")->_color = QColor(120,80,80);

    colorSetting("EventType-I1mr")->_color = QColor(0, 240, 0);
    colorSetting("EventType-D1mr")->_color = QColor(40,180,40);
    colorSetting("EventType-D1mw")->_color = QColor(80,120,80);

    colorSetting("EventType-Ir")->_color = QColor(0, 0, 240);
    colorSetting("EventType-Dr")->_color = QColor(40,40,180);
    colorSetting("EventType-Dw")->_color = QColor(80,80,120);

    ConfigGroup* colorConfig = ConfigStorage::group("CostColors");
    count = colorConfig->value("Count", 0).toInt();
    for (i=1;i<=count;i++) {
	QString n = colorConfig->value(QString("Name%1").arg(i),
				       QString()).toString();
	QColor color = colorConfig->value<QColor>(QString("Color%1").arg(i),
						  QColor(Qt::black));

	if (n.isEmpty()) continue;

	ConfigColorSetting* cs = new ConfigColorSetting(n,color);
	_colors.insert(n, cs);
    }
    delete colorConfig;

    // source options
    ConfigGroup* sourceConfig = ConfigStorage::group("Source");
    QStringList dirs;
    dirs = sourceConfig->value("Dirs", QStringList()).toStringList();
    if (dirs.count()>0) _generalSourceDirs = dirs;
    count = sourceConfig->value("Count", 0).toInt();
    _objectSourceDirs.clear();
    for (i=1;i<=count;i++) {
	QString n = sourceConfig->value(QString("Object%1").arg(i),
					QString()).toString();
	dirs = sourceConfig->value(QString("Dirs%1").arg(i),
				   QStringList()).toStringList();

	if (n.isEmpty() || (dirs.count()==0)) continue;

	_objectSourceDirs.insert(n, dirs);
    }
    delete sourceConfig;

    // general options
    ConfigGroup* generalConfig = ConfigStorage::group("GeneralSettings");
    _showPercentage   = generalConfig->value("ShowPercentage",
					     DEFAULT_SHOWPERCENTAGE).toBool();
    _showExpanded     = generalConfig->value("ShowExpanded",
					     DEFAULT_SHOWEXPANDED).toBool();
    _showCycles       = generalConfig->value("ShowCycles",
					     DEFAULT_SHOWCYCLES).toBool();
    _cycleCut         = generalConfig->value("CycleCut",
					     DEFAULT_CYCLECUT).toDouble();
    _percentPrecision = generalConfig->value("PercentPrecision",
					     DEFAULT_PERCENTPRECISION).toInt();
    _maxSymbolLength  = generalConfig->value("MaxSymbolLength",
					     DEFAULT_MAXSYMBOLLENGTH).toInt();
    _maxSymbolCount   = generalConfig->value("MaxSymbolCount",
					     DEFAULT_MAXSYMBOLCOUNT).toInt();
    _maxListCount     = generalConfig->value("MaxListCount",
					     DEFAULT_MAXLISTCOUNT).toInt();
    _context          = generalConfig->value("Context",
					     DEFAULT_CONTEXT).toInt();
    _noCostInside     = generalConfig->value("NoCostInside",
					     DEFAULT_NOCOSTINSIDE).toInt();
    _hideTemplates    = generalConfig->value("HideTemplates",
		                             DEFAULT_HIDETEMPLATES).toBool();
    delete generalConfig;

    // event types
    if (EventType::knownTypeCount() >0) return; // already read
    ConfigGroup* etConfig = ConfigStorage::group("EventTypes");
    int etCount = etConfig->value("Count", 0).toInt();

    if (etCount == 0) {
	addDefaultTypes();
	return;
    }

    for (int i=1;i<=etCount;i++) {
	QString n = etConfig->value(QString("Name%1").arg(i),
				    QString()).toString();
	QString l = etConfig->value(QString("Longname%1").arg(i),
				    QString()).toString();
	if (l.isEmpty()) l = knownLongName(n);
	QString f = etConfig->value(QString("Formula%1").arg(i),
				    QString()).toString();
	if (f.isEmpty()) f = knownFormula(n);

	EventType::add(new EventType(n, l, f));
    }
    delete etConfig;
}