Ejemplo n.º 1
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);
	}
}
Ejemplo n.º 2
0
ConfigGroup *
ConfigGroup::FindSubgroup(const wxChar *szName) const
{
  size_t i,
       lo = 0,
       hi = m_aSubgroups.Count();
  int res;
  ConfigGroup *pGroup;

  while ( lo < hi ) {
    i = (lo + hi)/2;
    pGroup = m_aSubgroups[i];

    #if wxCONFIG_CASE_SENSITIVE
      res = wxStrcmp(pGroup->Name(), szName);
    #else
      res = wxStricmp(pGroup->Name(), szName);
    #endif

    if ( res > 0 )
      hi = i;
    else if ( res < 0 )
      lo = i + 1;
    else
      return pGroup;
  }

  return NULL;
}
Ejemplo n.º 3
0
YandexNarodManager::~YandexNarodManager()
{
	delete netman;
	ConfigGroup group = Config().group("yandex").group("narod");
	group.setValue("managerGeometry", saveGeometry());
	group.sync();
}
Ejemplo n.º 4
0
void KdeSpellerSettings::saveImpl()
{
	QString lang = m_ui->dictionaryComboBox->currentDictionary();
	ConfigGroup group = Config().group("speller");
	group.setValue("autodetect", m_ui->autodetect->isChecked());
	group.setValue("language", lang);
	KdeSpellerLayer::spellerInstance()->setLanguage(lang);
}
Ejemplo n.º 5
0
void SzarpConfigs::CreateOneElementGroups(ConfigList* config_groups, ConfigNameHash& titles) {
	for (ConfigNameHash::iterator i = titles.begin(); i != titles.end() ; ++i) {
		const wxString& prefix = i->first;
		ConfigGroup* confgroup = new ConfigGroup;
		confgroup->AppendConfig(prefix, titles[prefix]);
		confgroup->group_name = titles[prefix];
		config_groups->push_back(confgroup);
	}
}
Ejemplo n.º 6
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);
}
Ejemplo n.º 7
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();
}
Ejemplo n.º 8
0
void SzarpConfigs::CreateGroups(ConfigList* result, MPW& prefix_map, ConfigNameHash &titles) {
	for (MPW::iterator i = prefix_map.begin(); i != prefix_map.end(); ++i) {
		const set<wxString>& prefixes = i->first;
		set<wxString, NoCaseCmp>& words = i->second;
		if (prefixes.size() <= 1) 
			continue;

		set<wxString>::iterator j;
		wxString title;
		for (j = prefixes.begin(); j != prefixes.end(); j++)  {
			ConfigNameHash::iterator k  = titles.find(*j);
			if (k != titles.end()) {
				title = k->second;
				break;
			}
		}

		if (j == prefixes.end())
			continue;

		ConfigGroup* confgroup = new ConfigGroup;
		wxString& group_name = confgroup->group_name;
			
		wxStringTokenizer tknz(title, 
					_T(" \t\r\n"), 
					wxTOKEN_STRTOK);
		while (tknz.HasMoreTokens()) {
			wxString token = tknz.GetNextToken();
			if (words.find(token) != words.end()) 
				group_name += token + _T(" ");
		}

		int prefix_count = 0;
		for (set<wxString>::iterator k = prefixes.begin(); k != prefixes.end(); k++) {
			ConfigNameHash::iterator l = titles.find(*k);
			if (l == titles.end())
				continue;
			prefix_count++;
			confgroup->AppendConfig(*k, l->second);
		}

		if (prefix_count <= 1) {
			delete confgroup;
			continue;
		}

		result->push_back(confgroup);
		for (set<wxString>::iterator k = prefixes.begin(); k != prefixes.end(); k++)  {
			titles.erase(*k);
		}
	}
}
Ejemplo n.º 9
0
/**
*  @brief
*    Returns the value of a configuration class variable
*/
String Config::GetVar(const String &sClass, const String &sVariable)
{
	// Get configuration class
	ConfigGroup *pClass = GetClass(sClass);
	if (pClass) {
		// Get attribute
		const DynVar *pDynVar = pClass->GetAttribute(sVariable);
		if (pDynVar)
			return pDynVar->GetString();
	}

	// Error!
	return "";
}
Ejemplo n.º 10
0
bool wxFileConfig::RenameGroup(const wxString& oldName,
                               const wxString& newName)
{
    // check that the group exists
    ConfigGroup *group = m_pCurrentGroup->FindSubgroup(oldName);
    if ( !group )
        return FALSE;

    // check that the new group doesn't already exist
    if ( m_pCurrentGroup->FindSubgroup(newName) )
        return FALSE;

    group->Rename(newName);

    return TRUE;
}
Ejemplo n.º 11
0
bool wxFileConfig::DeleteEntry(const wxString& key, bool bGroupIfEmptyAlso)
{
  wxConfigPathChanger path(this, key);

  if ( !m_pCurrentGroup->DeleteEntry(path.Name()) )
    return FALSE;

  if ( bGroupIfEmptyAlso && m_pCurrentGroup->IsEmpty() ) {
    if ( m_pCurrentGroup != m_pRootGroup ) {
      ConfigGroup *pGroup = m_pCurrentGroup;
      SetPath(wxT(".."));  // changes m_pCurrentGroup!
      m_pCurrentGroup->DeleteSubgroupByName(pGroup->Name());
    }
    //else: never delete the root group
  }

  return TRUE;
}
Ejemplo n.º 12
0
/**
*  @brief
*    Set the value of a configuration class variable
*/
bool Config::SetVar(const String &sClass, const String &sVariable, const String &sValue)
{
	// Get configuration class
	ConfigGroup *pClass = GetClass(sClass);
	if (pClass) {
		// Get attribute
		DynVar *pDynVar = pClass->GetAttribute(sVariable);
		if (pDynVar) {
			pDynVar->SetString(sValue);

			// Done
			return true;
		}
	}

	// Error!
	return false;
}
Ejemplo n.º 13
0
/**
*  @brief
*    Set default configuration settings
*/
bool Config::SetDefault(const String &sClass, const String &sVariable)
{
	// Set all classes to default settings?
	if (sClass.GetLength())
		return SetClassDefault(sClass, sVariable);
	else {
		// Set a class to default settings
		bool bResult = true; // No error by default
		Iterator<ConfigGroup*> cIterator = m_lstConfig.GetIterator();
		while (cIterator.HasNext()) {
			ConfigGroup *pClass = cIterator.Next();
			if (!SetClassDefault(pClass->GetClass()->GetClassName(), sVariable))
				bResult = false; // Something went wrong
		}

		// Done
		return bResult;
	}
}
Ejemplo n.º 14
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);
}
Ejemplo n.º 15
0
/**
*  @brief
*    Set a class to default configuration settings
*/
bool Config::SetClassDefault(const String &sClass, const String &sVariable)
{
	// Get class
	ConfigGroup *pClass = GetClass(sClass);
	if (!pClass || !pClass->GetClass())
		return false; // Error!

	// Set all variables to default?
	if (sVariable.GetLength()) {
		// Get attribute
		DynVar *pDynVar = pClass->GetAttribute(sVariable);
		if (pDynVar)
			pDynVar->SetDefault();
	} else {
		pClass->SetDefaultValues();
	}

	// Done
	return true;
}
Ejemplo n.º 16
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);
}
Ejemplo n.º 17
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);
		}
	}
}
Ejemplo n.º 18
0
// Return the line which contains "[our name]". If we're still not in the list,
// add our line to it immediately after the last line of our parent group if we
// have it or in the very beginning if we're the root group.
LineList *ConfigGroup::GetGroupLine()
{
  if ( m_pLine == NULL ) {
    ConfigGroup *pParent = Parent();

    // this group wasn't present in local config file, add it now
    if ( pParent != NULL ) {
      wxString strFullName;
      strFullName << wxT("[")
                  // +1: no '/'
                  << FilterOutEntryName(GetFullName().c_str() + 1)
                  << wxT("]");
      m_pLine = m_pConfig->LineListInsert(strFullName,
                                          pParent->GetLastGroupLine());
      pParent->SetLastGroup(this);  // we're surely after all the others
    }
    else {
      // we return NULL, so that LineListInsert() will insert us in the
      // very beginning
    }
  }

  return m_pLine;
}
Ejemplo n.º 19
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);
}
Ejemplo n.º 20
0
// constructor
ConfigGroup::ConfigGroup(const string& name, ConfigGroup& parent) : m_parent(&parent)
{
	m_name = name;
	m_path = parent.get_path() + name + "/";
	parent.m_children.insert(pair<string, ConfigGroup*>(name, this));
}
Ejemplo n.º 21
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;
}
Ejemplo n.º 22
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;
}
Ejemplo n.º 23
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);
}
Ejemplo n.º 24
0
void GlobalConfig::saveOptions()
{
    // source options
    ConfigGroup* sourceConfig = ConfigStorage::group("Source");
    sourceConfig->setValue("Dirs", _generalSourceDirs);
    QHashIterator<QString,QStringList> it( _objectSourceDirs );
    int count = 1;
    while( it.hasNext() ) {
	it.next();
	sourceConfig->setValue( QString("Object%1").arg(count),
				it.key() );
	sourceConfig->setValue( QString("Dirs%1").arg(count),
				it.value() );
	count++;
    }
    sourceConfig->setValue("Count", count-1);
    delete sourceConfig;

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

    // event types
    ConfigGroup* etConfig = ConfigStorage::group("EventTypes");
    int etCount = EventType::knownTypeCount();
    etConfig->setValue( "Count", etCount);
    for (int i=0; i<etCount; i++) {
	EventType* t = EventType::knownType(i);
	etConfig->setValue( QString("Name%1").arg(i+1), t->name());
	etConfig->setValue( QString("Longname%1").arg(i+1),
			    t->longName(),
			    knownLongName(t->name()) );
	etConfig->setValue( QString("Formula%1").arg(i+1),
			    t->formula(), knownFormula(t->name()) );
    }
    delete etConfig;
}