void GamesProxyModel::saveFilterParameters(const QMap<int, QString> &allGameTypes) { QSettings settings; settings.beginGroup("filter_games"); settings.setValue("unavailable_games_visible", unavailableGamesVisible); settings.setValue( "password_protected_games_visible", passwordProtectedGamesVisible ); settings.setValue("game_name_filter", gameNameFilter); settings.setValue("creator_name_filter", creatorNameFilter); QMapIterator<int, QString> gameTypeIterator(allGameTypes); while (gameTypeIterator.hasNext()) { gameTypeIterator.next(); settings.setValue( "game_type/" + hashGameType(gameTypeIterator.value()), gameTypeFilter.contains(gameTypeIterator.key()) ); } settings.setValue("min_players", maxPlayersFilterMin); settings.setValue("max_players", maxPlayersFilterMax); }
void DlgFilterGames::actOk() { QSettings settings; settings.beginGroup("filter_games"); settings.setValue( "unavailable_games_visible", unavailableGamesVisibleCheckBox->isChecked() ); settings.setValue( "password_protected_games_visible", passwordProtectedGamesVisibleCheckBox->isChecked() ); settings.setValue("game_name_filter", gameNameFilterEdit->text()); settings.setValue("creator_name_filter", creatorNameFilterEdit->text()); QMapIterator<int, QString> gameTypeIterator(allGameTypes); QMapIterator<int, QCheckBox *> checkboxIterator(gameTypeFilterCheckBoxes); while (gameTypeIterator.hasNext()) { gameTypeIterator.next(); checkboxIterator.next(); settings.setValue( "game_type/" + hashGameType(gameTypeIterator.value()), checkboxIterator.value()->isChecked() ); } settings.setValue("min_players", maxPlayersFilterMinSpinBox->value()); settings.setValue("max_players", maxPlayersFilterMaxSpinBox->value()); accept(); }
DlgCreateGame::DlgCreateGame(const ServerInfo_Game &gameInfo, const QMap<int, QString> &_gameTypes, QWidget *parent) : QDialog(parent), room(0), gameTypes(_gameTypes) { sharedCtor(); descriptionEdit->setEnabled(false); maxPlayersEdit->setEnabled(false); passwordEdit->setEnabled(false); onlyBuddiesCheckBox->setEnabled(false); onlyRegisteredCheckBox->setEnabled(false); spectatorsAllowedCheckBox->setEnabled(false); spectatorsNeedPasswordCheckBox->setEnabled(false); spectatorsCanTalkCheckBox->setEnabled(false); spectatorsSeeEverythingCheckBox->setEnabled(false); descriptionEdit->setText(QString::fromStdString(gameInfo.description())); maxPlayersEdit->setValue(gameInfo.max_players()); onlyBuddiesCheckBox->setChecked(gameInfo.only_buddies()); onlyRegisteredCheckBox->setChecked(gameInfo.only_registered()); spectatorsAllowedCheckBox->setChecked(gameInfo.spectators_allowed()); spectatorsNeedPasswordCheckBox->setChecked(gameInfo.spectators_need_password()); spectatorsCanTalkCheckBox->setChecked(gameInfo.spectators_can_chat()); spectatorsSeeEverythingCheckBox->setChecked(gameInfo.spectators_omniscient()); QSet<int> types; for (int i = 0; i < gameInfo.game_types_size(); ++i) types.insert(gameInfo.game_types(i)); QMapIterator<int, QString> gameTypeIterator(gameTypes); while (gameTypeIterator.hasNext()) { gameTypeIterator.next(); QCheckBox *gameTypeCheckBox = gameTypeCheckBoxes.value(gameTypeIterator.key()); gameTypeCheckBox->setEnabled(false); gameTypeCheckBox->setChecked(types.contains(gameTypeIterator.key())); } connect(buttonBox, SIGNAL(accepted()), this, SLOT(accept())); setWindowTitle(tr("Game information")); }
void DlgCreateGame::sharedCtor() { descriptionLabel = new QLabel(tr("&Description:")); descriptionEdit = new QLineEdit; descriptionLabel->setBuddy(descriptionEdit); descriptionEdit->setMaxLength(60); maxPlayersLabel = new QLabel(tr("P&layers:")); maxPlayersEdit = new QSpinBox(); maxPlayersEdit->setMinimum(1); maxPlayersEdit->setMaximum(100); maxPlayersEdit->setValue(2); maxPlayersLabel->setBuddy(maxPlayersEdit); QGridLayout *generalGrid = new QGridLayout; generalGrid->addWidget(descriptionLabel, 0, 0); generalGrid->addWidget(descriptionEdit, 0, 1); generalGrid->addWidget(maxPlayersLabel, 1, 0); generalGrid->addWidget(maxPlayersEdit, 1, 1); QVBoxLayout *gameTypeLayout = new QVBoxLayout; QMapIterator<int, QString> gameTypeIterator(gameTypes); while (gameTypeIterator.hasNext()) { gameTypeIterator.next(); QCheckBox *gameTypeCheckBox = new QCheckBox(gameTypeIterator.value()); gameTypeLayout->addWidget(gameTypeCheckBox); gameTypeCheckBoxes.insert(gameTypeIterator.key(), gameTypeCheckBox); } QGroupBox *gameTypeGroupBox = new QGroupBox(tr("Game type")); gameTypeGroupBox->setLayout(gameTypeLayout); passwordLabel = new QLabel(tr("&Password:"******"Only &buddies can join")); onlyRegisteredCheckBox = new QCheckBox(tr("Only ®istered users can join")); if (room && room->getUserInfo()->user_level() & ServerInfo_User::IsRegistered) { onlyRegisteredCheckBox->setChecked(true); } else { onlyBuddiesCheckBox->setEnabled(false); onlyRegisteredCheckBox->setEnabled(false); } QGridLayout *joinRestrictionsLayout = new QGridLayout; joinRestrictionsLayout->addWidget(passwordLabel, 0, 0); joinRestrictionsLayout->addWidget(passwordEdit, 0, 1); joinRestrictionsLayout->addWidget(onlyBuddiesCheckBox, 1, 0, 1, 2); joinRestrictionsLayout->addWidget(onlyRegisteredCheckBox, 2, 0, 1, 2); QGroupBox *joinRestrictionsGroupBox = new QGroupBox(tr("Joining restrictions")); joinRestrictionsGroupBox->setLayout(joinRestrictionsLayout); spectatorsAllowedCheckBox = new QCheckBox(tr("&Spectators can watch")); spectatorsAllowedCheckBox->setChecked(true); connect(spectatorsAllowedCheckBox, SIGNAL(stateChanged(int)), this, SLOT(spectatorsAllowedChanged(int))); spectatorsNeedPasswordCheckBox = new QCheckBox(tr("Spectators &need a password to watch")); spectatorsCanTalkCheckBox = new QCheckBox(tr("Spectators can &chat")); spectatorsSeeEverythingCheckBox = new QCheckBox(tr("Spectators can see &hands")); QVBoxLayout *spectatorsLayout = new QVBoxLayout; spectatorsLayout->addWidget(spectatorsAllowedCheckBox); spectatorsLayout->addWidget(spectatorsNeedPasswordCheckBox); spectatorsLayout->addWidget(spectatorsCanTalkCheckBox); spectatorsLayout->addWidget(spectatorsSeeEverythingCheckBox); spectatorsGroupBox = new QGroupBox(tr("Spectators")); spectatorsGroupBox->setLayout(spectatorsLayout); QGridLayout *grid = new QGridLayout; grid->addLayout(generalGrid, 0, 0); grid->addWidget(spectatorsGroupBox, 1, 0); grid->addWidget(joinRestrictionsGroupBox, 0, 1); grid->addWidget(gameTypeGroupBox, 1, 1); buttonBox = new QDialogButtonBox(QDialogButtonBox::Ok); connect(buttonBox, SIGNAL(rejected()), this, SLOT(reject())); QVBoxLayout *mainLayout = new QVBoxLayout; mainLayout->addLayout(grid); mainLayout->addWidget(buttonBox); setLayout(mainLayout); setFixedHeight(sizeHint().height()); }