本文整理汇总了C++中ConfigGroup::arrayElement方法的典型用法代码示例。如果您正苦于以下问题:C++ ConfigGroup::arrayElement方法的具体用法?C++ ConfigGroup::arrayElement怎么用?C++ ConfigGroup::arrayElement使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ConfigGroup
的用法示例。
在下文中一共展示了ConfigGroup::arrayElement方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: makeSettings
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);
}