NewGameDialog::NewGameDialog(EngineManager* engineManager, QWidget* parent) : QDialog(parent), m_engineManager(engineManager), ui(new Ui::NewGameDialog) { Q_ASSERT(engineManager != 0); ui->setupUi(this); m_engines = new EngineConfigurationModel(m_engineManager, this); connect(ui->m_configureWhiteEngineButton, SIGNAL(clicked(bool)), this, SLOT(configureWhiteEngine())); connect(ui->m_configureBlackEngineButton, SIGNAL(clicked(bool)), this, SLOT(configureBlackEngine())); connect(ui->m_timeControlBtn, SIGNAL(clicked()), this, SLOT(showTimeControlDialog())); m_proxyModel = new EngineConfigurationProxyModel(this); m_proxyModel->setSourceModel(m_engines); m_proxyModel->setSortCaseSensitivity(Qt::CaseInsensitive); m_proxyModel->sort(0); m_proxyModel->setDynamicSortFilter(true); StringValidator* engineValidator = new StringValidator(this); engineValidator->setModel(m_proxyModel); ui->m_whiteEngineComboBox->setModel(m_proxyModel); ui->m_whiteEngineComboBox->setValidator(engineValidator); ui->m_blackEngineComboBox->setModel(m_proxyModel); ui->m_blackEngineComboBox->setValidator(engineValidator); ui->m_variantComboBox->addItems(Chess::BoardFactory::variants()); connect(ui->m_variantComboBox, SIGNAL(currentIndexChanged(QString)), this, SLOT(onVariantChanged(QString))); int index = ui->m_variantComboBox->findText("standard"); ui->m_variantComboBox->setCurrentIndex(index); m_timeControl.setMovesPerTc(40); m_timeControl.setTimePerTc(300000); ui->m_timeControlBtn->setText(m_timeControl.toVerboseString()); }
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); }