Invert "Show" games, so all games are visible by default (#5521)

This commit is contained in:
Zach H 2025-01-25 02:03:36 -05:00 committed by GitHub
parent b48fe8b99c
commit f6c31bf901
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
8 changed files with 113 additions and 173 deletions

View file

@ -6,12 +6,10 @@
#include <QDialogButtonBox> #include <QDialogButtonBox>
#include <QGridLayout> #include <QGridLayout>
#include <QGroupBox> #include <QGroupBox>
#include <QHBoxLayout>
#include <QLabel> #include <QLabel>
#include <QLineEdit> #include <QLineEdit>
#include <QPushButton> #include <QPushButton>
#include <QSpinBox> #include <QSpinBox>
#include <QVBoxLayout>
DlgFilterGames::DlgFilterGames(const QMap<int, QString> &_allGameTypes, DlgFilterGames::DlgFilterGames(const QMap<int, QString> &_allGameTypes,
const GamesProxyModel *_gamesProxyModel, const GamesProxyModel *_gamesProxyModel,
@ -24,19 +22,19 @@ DlgFilterGames::DlgFilterGames(const QMap<int, QString> &_allGameTypes,
{QTime(1, 0), tr("1 hour")}, {QTime(1, 0), tr("1 hour")},
{QTime(2, 0), tr("2 hours")}}) {QTime(2, 0), tr("2 hours")}})
{ {
showBuddiesOnlyGames = new QCheckBox(tr("Show '&buddies only' games")); hideBuddiesOnlyGames = new QCheckBox(tr("Hide 'buddies only' games"));
showBuddiesOnlyGames->setChecked(gamesProxyModel->getShowBuddiesOnlyGames()); hideBuddiesOnlyGames->setChecked(gamesProxyModel->getHideBuddiesOnlyGames());
showFullGames = new QCheckBox(tr("Show &full games")); hideFullGames = new QCheckBox(tr("Hide full games"));
showFullGames->setChecked(gamesProxyModel->getShowFullGames()); hideFullGames->setChecked(gamesProxyModel->getHideFullGames());
showGamesThatStarted = new QCheckBox(tr("Show games &that have started")); hideGamesThatStarted = new QCheckBox(tr("Hide games that have started"));
showGamesThatStarted->setChecked(gamesProxyModel->getShowGamesThatStarted()); hideGamesThatStarted->setChecked(gamesProxyModel->getHideGamesThatStarted());
showPasswordProtectedGames = new QCheckBox(tr("Show &password protected games")); hidePasswordProtectedGames = new QCheckBox(tr("Hide password protected games"));
showPasswordProtectedGames->setChecked(gamesProxyModel->getShowPasswordProtectedGames()); hidePasswordProtectedGames->setChecked(gamesProxyModel->getHidePasswordProtectedGames());
hideIgnoredUserGames = new QCheckBox(tr("Hide '&ignored user' games")); hideIgnoredUserGames = new QCheckBox(tr("Hide 'ignored user' games"));
hideIgnoredUserGames->setChecked(gamesProxyModel->getHideIgnoredUserGames()); hideIgnoredUserGames->setChecked(gamesProxyModel->getHideIgnoredUserGames());
maxGameAgeComboBox = new QComboBox(); maxGameAgeComboBox = new QComboBox();
@ -108,10 +106,10 @@ DlgFilterGames::DlgFilterGames(const QMap<int, QString> &_allGameTypes,
maxPlayersGroupBox->setLayout(maxPlayersFilterLayout); maxPlayersGroupBox->setLayout(maxPlayersFilterLayout);
auto *restrictionsLayout = new QGridLayout; auto *restrictionsLayout = new QGridLayout;
restrictionsLayout->addWidget(showFullGames, 0, 0); restrictionsLayout->addWidget(hideFullGames, 0, 0);
restrictionsLayout->addWidget(showGamesThatStarted, 1, 0); restrictionsLayout->addWidget(hideGamesThatStarted, 1, 0);
restrictionsLayout->addWidget(showPasswordProtectedGames, 2, 0); restrictionsLayout->addWidget(hidePasswordProtectedGames, 2, 0);
restrictionsLayout->addWidget(showBuddiesOnlyGames, 3, 0); restrictionsLayout->addWidget(hideBuddiesOnlyGames, 3, 0);
restrictionsLayout->addWidget(hideIgnoredUserGames, 4, 0); restrictionsLayout->addWidget(hideIgnoredUserGames, 4, 0);
auto *restrictionsGroupBox = new QGroupBox(tr("Restrictions")); auto *restrictionsGroupBox = new QGroupBox(tr("Restrictions"));
@ -185,34 +183,24 @@ void DlgFilterGames::toggleSpectatorCheckboxEnabledness(bool spectatorsEnabled)
showOnlyIfSpectatorsCanSeeHands->setDisabled(!spectatorsEnabled); showOnlyIfSpectatorsCanSeeHands->setDisabled(!spectatorsEnabled);
} }
bool DlgFilterGames::getShowFullGames() const bool DlgFilterGames::getHideFullGames() const
{ {
return showFullGames->isChecked(); return hideFullGames->isChecked();
} }
bool DlgFilterGames::getShowGamesThatStarted() const bool DlgFilterGames::getHideGamesThatStarted() const
{ {
return showGamesThatStarted->isChecked(); return hideGamesThatStarted->isChecked();
} }
bool DlgFilterGames::getShowBuddiesOnlyGames() const bool DlgFilterGames::getHideBuddiesOnlyGames() const
{ {
return showBuddiesOnlyGames->isChecked(); return hideBuddiesOnlyGames->isChecked();
} }
void DlgFilterGames::setShowBuddiesOnlyGames(bool _showBuddiesOnlyGames) bool DlgFilterGames::getHidePasswordProtectedGames() const
{ {
showBuddiesOnlyGames->setChecked(_showBuddiesOnlyGames); return hidePasswordProtectedGames->isChecked();
}
bool DlgFilterGames::getShowPasswordProtectedGames() const
{
return showPasswordProtectedGames->isChecked();
}
void DlgFilterGames::setShowPasswordProtectedGames(bool _passwordProtectedGamesHidden)
{
showPasswordProtectedGames->setChecked(_passwordProtectedGamesHidden);
} }
bool DlgFilterGames::getHideIgnoredUserGames() const bool DlgFilterGames::getHideIgnoredUserGames() const
@ -220,31 +208,16 @@ bool DlgFilterGames::getHideIgnoredUserGames() const
return hideIgnoredUserGames->isChecked(); return hideIgnoredUserGames->isChecked();
} }
void DlgFilterGames::setHideIgnoredUserGames(bool _hideIgnoredUserGames)
{
hideIgnoredUserGames->setChecked(_hideIgnoredUserGames);
}
QString DlgFilterGames::getGameNameFilter() const QString DlgFilterGames::getGameNameFilter() const
{ {
return gameNameFilterEdit->text(); return gameNameFilterEdit->text();
} }
void DlgFilterGames::setGameNameFilter(const QString &_gameNameFilter)
{
gameNameFilterEdit->setText(_gameNameFilter);
}
QString DlgFilterGames::getCreatorNameFilter() const QString DlgFilterGames::getCreatorNameFilter() const
{ {
return creatorNameFilterEdit->text(); return creatorNameFilterEdit->text();
} }
void DlgFilterGames::setCreatorNameFilter(const QString &_creatorNameFilter)
{
creatorNameFilterEdit->setText(_creatorNameFilter);
}
QSet<int> DlgFilterGames::getGameTypeFilter() const QSet<int> DlgFilterGames::getGameTypeFilter() const
{ {
QSet<int> result; QSet<int> result;
@ -257,15 +230,6 @@ QSet<int> DlgFilterGames::getGameTypeFilter() const
return result; return result;
} }
void DlgFilterGames::setGameTypeFilter(const QSet<int> &_gameTypeFilter)
{
QMapIterator<int, QCheckBox *> i(gameTypeFilterCheckBoxes);
while (i.hasNext()) {
i.next();
i.value()->setChecked(_gameTypeFilter.contains(i.key()));
}
}
int DlgFilterGames::getMaxPlayersFilterMin() const int DlgFilterGames::getMaxPlayersFilterMin() const
{ {
return maxPlayersFilterMinSpinBox->value(); return maxPlayersFilterMinSpinBox->value();
@ -285,13 +249,6 @@ QTime DlgFilterGames::getMaxGameAge() const
return gameAgeMap.keys().at(index); return gameAgeMap.keys().at(index);
} }
void DlgFilterGames::setMaxPlayersFilter(int _maxPlayersFilterMin, int _maxPlayersFilterMax)
{
maxPlayersFilterMinSpinBox->setValue(_maxPlayersFilterMin);
maxPlayersFilterMaxSpinBox->setValue(_maxPlayersFilterMax == -1 ? maxPlayersFilterMaxSpinBox->maximum()
: _maxPlayersFilterMax);
}
bool DlgFilterGames::getShowOnlyIfSpectatorsCanWatch() const bool DlgFilterGames::getShowOnlyIfSpectatorsCanWatch() const
{ {
return showOnlyIfSpectatorsCanWatch->isChecked(); return showOnlyIfSpectatorsCanWatch->isChecked();

View file

@ -21,10 +21,10 @@ class DlgFilterGames : public QDialog
Q_OBJECT Q_OBJECT
private: private:
QGroupBox *generalGroupBox; QGroupBox *generalGroupBox;
QCheckBox *showBuddiesOnlyGames; QCheckBox *hideBuddiesOnlyGames;
QCheckBox *showFullGames; QCheckBox *hideFullGames;
QCheckBox *showGamesThatStarted; QCheckBox *hideGamesThatStarted;
QCheckBox *showPasswordProtectedGames; QCheckBox *hidePasswordProtectedGames;
QCheckBox *hideIgnoredUserGames; QCheckBox *hideIgnoredUserGames;
QLineEdit *gameNameFilterEdit; QLineEdit *gameNameFilterEdit;
QLineEdit *creatorNameFilterEdit; QLineEdit *creatorNameFilterEdit;
@ -50,12 +50,12 @@ public:
const GamesProxyModel *_gamesProxyModel, const GamesProxyModel *_gamesProxyModel,
QWidget *parent = nullptr); QWidget *parent = nullptr);
bool getShowFullGames() const; bool getHideFullGames() const;
bool getShowGamesThatStarted() const; bool getHideGamesThatStarted() const;
bool getShowPasswordProtectedGames() const; bool getHidePasswordProtectedGames() const;
void setShowPasswordProtectedGames(bool _passwordProtectedGamesHidden); void setShowPasswordProtectedGames(bool _passwordProtectedGamesHidden);
bool getShowBuddiesOnlyGames() const; bool getHideBuddiesOnlyGames() const;
void setShowBuddiesOnlyGames(bool _showBuddiesOnlyGames); void setHideBuddiesOnlyGames(bool _hideBuddiesOnlyGames);
bool getHideIgnoredUserGames() const; bool getHideIgnoredUserGames() const;
void setHideIgnoredUserGames(bool _hideIgnoredUserGames); void setHideIgnoredUserGames(bool _hideIgnoredUserGames);
QString getGameNameFilter() const; QString getGameNameFilter() const;

View file

@ -151,10 +151,10 @@ void GameSelector::actSetFilter()
if (!dlg.exec()) if (!dlg.exec())
return; return;
gameListProxyModel->setShowBuddiesOnlyGames(dlg.getShowBuddiesOnlyGames()); gameListProxyModel->setHideBuddiesOnlyGames(dlg.getHideBuddiesOnlyGames());
gameListProxyModel->setShowFullGames(dlg.getShowFullGames()); gameListProxyModel->setHideFullGames(dlg.getHideFullGames());
gameListProxyModel->setShowGamesThatStarted(dlg.getShowGamesThatStarted()); gameListProxyModel->setHideGamesThatStarted(dlg.getHideGamesThatStarted());
gameListProxyModel->setShowPasswordProtectedGames(dlg.getShowPasswordProtectedGames()); gameListProxyModel->setHidePasswordProtectedGames(dlg.getHidePasswordProtectedGames());
gameListProxyModel->setHideIgnoredUserGames(dlg.getHideIgnoredUserGames()); gameListProxyModel->setHideIgnoredUserGames(dlg.getHideIgnoredUserGames());
gameListProxyModel->setGameNameFilter(dlg.getGameNameFilter()); gameListProxyModel->setGameNameFilter(dlg.getGameNameFilter());
gameListProxyModel->setCreatorNameFilter(dlg.getCreatorNameFilter()); gameListProxyModel->setCreatorNameFilter(dlg.getCreatorNameFilter());

View file

@ -26,15 +26,6 @@ enum GameListColumn
SPECTATORS SPECTATORS
}; };
const bool DEFAULT_SHOW_FULL_GAMES = false;
const bool DEFAULT_SHOW_GAMES_THAT_STARTED = false;
const bool DEFAULT_SHOW_PASSWORD_PROTECTED_GAMES = true;
const bool DEFAULT_SHOW_BUDDIES_ONLY_GAMES = true;
const bool DEFAULT_HIDE_IGNORED_USER_GAMES = false;
const bool DEFAULT_SHOW_ONLY_IF_SPECTATORS_CAN_WATCH = false;
const bool DEFAULT_SHOW_SPECTATOR_PASSWORD_PROTECTED = true;
const bool DEFAULT_SHOW_ONLY_IF_SPECTATORS_CAN_CHAT = false;
const bool DEFAULT_SHOW_ONLY_IF_SPECTATORS_CAN_SEE_HANDS = false;
const int DEFAULT_MAX_PLAYERS_MIN = 1; const int DEFAULT_MAX_PLAYERS_MIN = 1;
const int DEFAULT_MAX_PLAYERS_MAX = 99; const int DEFAULT_MAX_PLAYERS_MAX = 99;
constexpr QTime DEFAULT_MAX_GAME_AGE = QTime(); constexpr QTime DEFAULT_MAX_GAME_AGE = QTime();
@ -293,9 +284,9 @@ GamesProxyModel::GamesProxyModel(QObject *parent, const UserListProxy *_userList
setDynamicSortFilter(true); setDynamicSortFilter(true);
} }
void GamesProxyModel::setShowBuddiesOnlyGames(bool _showBuddiesOnlyGames) void GamesProxyModel::setHideBuddiesOnlyGames(bool _showBuddiesOnlyGames)
{ {
showBuddiesOnlyGames = _showBuddiesOnlyGames; hideBuddiesOnlyGames = _showBuddiesOnlyGames;
invalidateFilter(); invalidateFilter();
} }
@ -305,21 +296,21 @@ void GamesProxyModel::setHideIgnoredUserGames(bool _hideIgnoredUserGames)
invalidateFilter(); invalidateFilter();
} }
void GamesProxyModel::setShowFullGames(bool _showFullGames) void GamesProxyModel::setHideFullGames(bool _showFullGames)
{ {
showFullGames = _showFullGames; hideFullGames = _showFullGames;
invalidateFilter(); invalidateFilter();
} }
void GamesProxyModel::setShowGamesThatStarted(bool _showGamesThatStarted) void GamesProxyModel::setHideGamesThatStarted(bool _showGamesThatStarted)
{ {
showGamesThatStarted = _showGamesThatStarted; hideGamesThatStarted = _showGamesThatStarted;
invalidateFilter(); invalidateFilter();
} }
void GamesProxyModel::setShowPasswordProtectedGames(bool _showPasswordProtectedGames) void GamesProxyModel::setHidePasswordProtectedGames(bool _showPasswordProtectedGames)
{ {
showPasswordProtectedGames = _showPasswordProtectedGames; hidePasswordProtectedGames = _showPasswordProtectedGames;
invalidateFilter(); invalidateFilter();
} }
@ -395,47 +386,43 @@ int GamesProxyModel::getNumFilteredGames() const
void GamesProxyModel::resetFilterParameters() void GamesProxyModel::resetFilterParameters()
{ {
showFullGames = DEFAULT_SHOW_FULL_GAMES; hideFullGames = false;
showGamesThatStarted = DEFAULT_SHOW_GAMES_THAT_STARTED; hideGamesThatStarted = false;
showPasswordProtectedGames = DEFAULT_SHOW_PASSWORD_PROTECTED_GAMES; hidePasswordProtectedGames = false;
showBuddiesOnlyGames = DEFAULT_SHOW_BUDDIES_ONLY_GAMES; hideBuddiesOnlyGames = false;
hideIgnoredUserGames = DEFAULT_HIDE_IGNORED_USER_GAMES; hideIgnoredUserGames = false;
gameNameFilter = QString(); gameNameFilter = QString();
creatorNameFilter = QString(); creatorNameFilter = QString();
gameTypeFilter.clear(); gameTypeFilter.clear();
maxPlayersFilterMin = DEFAULT_MAX_PLAYERS_MIN; maxPlayersFilterMin = DEFAULT_MAX_PLAYERS_MIN;
maxPlayersFilterMax = DEFAULT_MAX_PLAYERS_MAX; maxPlayersFilterMax = DEFAULT_MAX_PLAYERS_MAX;
maxGameAge = DEFAULT_MAX_GAME_AGE; maxGameAge = DEFAULT_MAX_GAME_AGE;
showOnlyIfSpectatorsCanWatch = DEFAULT_SHOW_ONLY_IF_SPECTATORS_CAN_WATCH; showOnlyIfSpectatorsCanWatch = false;
showSpectatorPasswordProtected = DEFAULT_SHOW_SPECTATOR_PASSWORD_PROTECTED; showSpectatorPasswordProtected = false;
showOnlyIfSpectatorsCanChat = DEFAULT_SHOW_ONLY_IF_SPECTATORS_CAN_CHAT; showOnlyIfSpectatorsCanChat = false;
showOnlyIfSpectatorsCanSeeHands = DEFAULT_SHOW_ONLY_IF_SPECTATORS_CAN_SEE_HANDS; showOnlyIfSpectatorsCanSeeHands = false;
invalidateFilter(); invalidateFilter();
} }
bool GamesProxyModel::areFilterParametersSetToDefaults() const bool GamesProxyModel::areFilterParametersSetToDefaults() const
{ {
return showFullGames == DEFAULT_SHOW_FULL_GAMES && showGamesThatStarted == DEFAULT_SHOW_GAMES_THAT_STARTED && return !hideFullGames && !hideGamesThatStarted && !hidePasswordProtectedGames && !hideBuddiesOnlyGames &&
showPasswordProtectedGames == DEFAULT_SHOW_PASSWORD_PROTECTED_GAMES && !hideIgnoredUserGames && gameNameFilter.isEmpty() && creatorNameFilter.isEmpty() &&
showBuddiesOnlyGames == DEFAULT_SHOW_BUDDIES_ONLY_GAMES && gameTypeFilter.isEmpty() && maxPlayersFilterMin == DEFAULT_MAX_PLAYERS_MIN &&
hideIgnoredUserGames == DEFAULT_HIDE_IGNORED_USER_GAMES && gameNameFilter.isEmpty() &&
creatorNameFilter.isEmpty() && gameTypeFilter.isEmpty() && maxPlayersFilterMin == DEFAULT_MAX_PLAYERS_MIN &&
maxPlayersFilterMax == DEFAULT_MAX_PLAYERS_MAX && maxGameAge == DEFAULT_MAX_GAME_AGE && maxPlayersFilterMax == DEFAULT_MAX_PLAYERS_MAX && maxGameAge == DEFAULT_MAX_GAME_AGE &&
showOnlyIfSpectatorsCanWatch == DEFAULT_SHOW_ONLY_IF_SPECTATORS_CAN_WATCH && !showOnlyIfSpectatorsCanWatch && !showSpectatorPasswordProtected && !showOnlyIfSpectatorsCanChat &&
showSpectatorPasswordProtected == DEFAULT_SHOW_SPECTATOR_PASSWORD_PROTECTED && !showOnlyIfSpectatorsCanSeeHands;
showOnlyIfSpectatorsCanChat == DEFAULT_SHOW_ONLY_IF_SPECTATORS_CAN_CHAT &&
showOnlyIfSpectatorsCanSeeHands == DEFAULT_SHOW_ONLY_IF_SPECTATORS_CAN_SEE_HANDS;
} }
void GamesProxyModel::loadFilterParameters(const QMap<int, QString> &allGameTypes) void GamesProxyModel::loadFilterParameters(const QMap<int, QString> &allGameTypes)
{ {
GameFiltersSettings &gameFilters = SettingsCache::instance().gameFilters(); GameFiltersSettings &gameFilters = SettingsCache::instance().gameFilters();
showFullGames = gameFilters.isShowFullGames(); hideFullGames = gameFilters.isHideFullGames();
showGamesThatStarted = gameFilters.isShowGamesThatStarted(); hideGamesThatStarted = gameFilters.isHideGamesThatStarted();
showPasswordProtectedGames = gameFilters.isShowPasswordProtectedGames(); hidePasswordProtectedGames = gameFilters.isHidePasswordProtectedGames();
hideIgnoredUserGames = gameFilters.isHideIgnoredUserGames(); hideIgnoredUserGames = gameFilters.isHideIgnoredUserGames();
showBuddiesOnlyGames = gameFilters.isShowBuddiesOnlyGames(); hideBuddiesOnlyGames = gameFilters.isHideBuddiesOnlyGames();
gameNameFilter = gameFilters.getGameNameFilter(); gameNameFilter = gameFilters.getGameNameFilter();
creatorNameFilter = gameFilters.getCreatorNameFilter(); creatorNameFilter = gameFilters.getCreatorNameFilter();
maxPlayersFilterMin = gameFilters.getMinPlayers(); maxPlayersFilterMin = gameFilters.getMinPlayers();
@ -460,10 +447,10 @@ void GamesProxyModel::loadFilterParameters(const QMap<int, QString> &allGameType
void GamesProxyModel::saveFilterParameters(const QMap<int, QString> &allGameTypes) void GamesProxyModel::saveFilterParameters(const QMap<int, QString> &allGameTypes)
{ {
GameFiltersSettings &gameFilters = SettingsCache::instance().gameFilters(); GameFiltersSettings &gameFilters = SettingsCache::instance().gameFilters();
gameFilters.setShowBuddiesOnlyGames(showBuddiesOnlyGames); gameFilters.setHideBuddiesOnlyGames(hideBuddiesOnlyGames);
gameFilters.setShowFullGames(showFullGames); gameFilters.setHideFullGames(hideFullGames);
gameFilters.setShowGamesThatStarted(showGamesThatStarted); gameFilters.setHideGamesThatStarted(hideGamesThatStarted);
gameFilters.setShowPasswordProtectedGames(showPasswordProtectedGames); gameFilters.setHidePasswordProtectedGames(hidePasswordProtectedGames);
gameFilters.setHideIgnoredUserGames(hideIgnoredUserGames); gameFilters.setHideIgnoredUserGames(hideIgnoredUserGames);
gameFilters.setGameNameFilter(gameNameFilter); gameFilters.setGameNameFilter(gameNameFilter);
gameFilters.setCreatorNameFilter(creatorNameFilter); gameFilters.setCreatorNameFilter(creatorNameFilter);
@ -505,20 +492,20 @@ bool GamesProxyModel::filterAcceptsRow(int sourceRow) const
const ServerInfo_Game &game = model->getGame(sourceRow); const ServerInfo_Game &game = model->getGame(sourceRow);
if (!showBuddiesOnlyGames && game.only_buddies()) { if (hideBuddiesOnlyGames && game.only_buddies()) {
return false; return false;
} }
if (hideIgnoredUserGames && userListProxy->isUserIgnored(QString::fromStdString(game.creator_info().name()))) { if (hideIgnoredUserGames && userListProxy->isUserIgnored(QString::fromStdString(game.creator_info().name()))) {
return false; return false;
} }
if (!showFullGames && game.player_count() == game.max_players()) if (hideFullGames && game.player_count() == game.max_players())
return false; return false;
if (!showGamesThatStarted && game.started()) if (hideGamesThatStarted && game.started())
return false; return false;
if (!userListProxy->isOwnUserRegistered()) if (!userListProxy->isOwnUserRegistered())
if (game.only_registered()) if (game.only_registered())
return false; return false;
if (!showPasswordProtectedGames && game.with_password()) if (hidePasswordProtectedGames && game.with_password())
return false; return false;
if (!gameNameFilter.isEmpty()) if (!gameNameFilter.isEmpty())
if (!QString::fromStdString(game.description()).contains(gameNameFilter, Qt::CaseInsensitive)) if (!QString::fromStdString(game.description()).contains(gameNameFilter, Qt::CaseInsensitive))

View file

@ -75,11 +75,11 @@ private:
// - loadFilterParameters() // - loadFilterParameters()
// - saveFilterParameters() // - saveFilterParameters()
// - filterAcceptsRow() // - filterAcceptsRow()
bool showBuddiesOnlyGames; bool hideBuddiesOnlyGames;
bool hideIgnoredUserGames; bool hideIgnoredUserGames;
bool showFullGames; bool hideFullGames;
bool showGamesThatStarted; bool hideGamesThatStarted;
bool showPasswordProtectedGames; bool hidePasswordProtectedGames;
QString gameNameFilter, creatorNameFilter; QString gameNameFilter, creatorNameFilter;
QSet<int> gameTypeFilter; QSet<int> gameTypeFilter;
quint32 maxPlayersFilterMin, maxPlayersFilterMax; quint32 maxPlayersFilterMin, maxPlayersFilterMax;
@ -90,31 +90,31 @@ private:
public: public:
explicit GamesProxyModel(QObject *parent = nullptr, const UserListProxy *_userListProxy = nullptr); explicit GamesProxyModel(QObject *parent = nullptr, const UserListProxy *_userListProxy = nullptr);
bool getShowBuddiesOnlyGames() const bool getHideBuddiesOnlyGames() const
{ {
return showBuddiesOnlyGames; return hideBuddiesOnlyGames;
} }
void setShowBuddiesOnlyGames(bool _showBuddiesOnlyGames); void setHideBuddiesOnlyGames(bool _showBuddiesOnlyGames);
bool getHideIgnoredUserGames() const bool getHideIgnoredUserGames() const
{ {
return hideIgnoredUserGames; return hideIgnoredUserGames;
} }
void setHideIgnoredUserGames(bool _hideIgnoredUserGames); void setHideIgnoredUserGames(bool _hideIgnoredUserGames);
bool getShowFullGames() const bool getHideFullGames() const
{ {
return showFullGames; return hideFullGames;
} }
void setShowFullGames(bool _showFullGames); void setHideFullGames(bool _showFullGames);
bool getShowGamesThatStarted() const bool getHideGamesThatStarted() const
{ {
return showGamesThatStarted; return hideGamesThatStarted;
} }
void setShowGamesThatStarted(bool _showGamesThatStarted); void setHideGamesThatStarted(bool _showGamesThatStarted);
bool getShowPasswordProtectedGames() const bool getHidePasswordProtectedGames() const
{ {
return showPasswordProtectedGames; return hidePasswordProtectedGames;
} }
void setShowPasswordProtectedGames(bool _showPasswordProtectedGames); void setHidePasswordProtectedGames(bool _showPasswordProtectedGames);
QString getGameNameFilter() const QString getGameNameFilter() const
{ {
return gameNameFilter; return gameNameFilter;

View file

@ -104,11 +104,7 @@ void SettingsCache::translateLegacySettings()
// Game filters // Game filters
legacySetting.beginGroup("filter_games"); legacySetting.beginGroup("filter_games");
gameFilters().setShowFullGames(legacySetting.value("unavailable_games_visible").toBool());
gameFilters().setShowGamesThatStarted(legacySetting.value("unavailable_games_visible").toBool());
gameFilters().setShowPasswordProtectedGames(legacySetting.value("show_password_protected_games").toBool());
gameFilters().setGameNameFilter(legacySetting.value("game_name_filter").toString()); gameFilters().setGameNameFilter(legacySetting.value("game_name_filter").toString());
gameFilters().setShowBuddiesOnlyGames(legacySetting.value("show_buddies_only_games").toBool());
gameFilters().setHideIgnoredUserGames(legacySetting.value("hide_ignored_user_games").toBool()); gameFilters().setHideIgnoredUserGames(legacySetting.value("hide_ignored_user_games").toBool());
gameFilters().setMinPlayers(legacySetting.value("min_players").toInt()); gameFilters().setMinPlayers(legacySetting.value("min_players").toInt());

View file

@ -17,48 +17,48 @@ QString GameFiltersSettings::hashGameType(const QString &gameType) const
return QCryptographicHash::hash(gameType.toUtf8(), QCryptographicHash::Md5).toHex(); return QCryptographicHash::hash(gameType.toUtf8(), QCryptographicHash::Md5).toHex();
} }
void GameFiltersSettings::setShowBuddiesOnlyGames(bool show) void GameFiltersSettings::setHideBuddiesOnlyGames(bool hide)
{ {
setValue(show, "show_buddies_only_games", "filter_games"); setValue(hide, "hide_buddies_only_games", "filter_games");
} }
bool GameFiltersSettings::isShowBuddiesOnlyGames() bool GameFiltersSettings::isHideBuddiesOnlyGames()
{ {
QVariant previous = getValue("show_buddies_only_games", "filter_games"); QVariant previous = getValue("hide_buddies_only_games", "filter_games");
return previous == QVariant() ? true : previous.toBool(); return previous == QVariant() || previous.toBool();
} }
void GameFiltersSettings::setShowFullGames(bool show) void GameFiltersSettings::setHideFullGames(bool hide)
{ {
setValue(show, "show_full_games", "filter_games"); setValue(hide, "hide_full_games", "filter_games");
} }
bool GameFiltersSettings::isShowFullGames() bool GameFiltersSettings::isHideFullGames()
{ {
QVariant previous = getValue("show_full_games", "filter_games"); QVariant previous = getValue("hide_full_games", "filter_games");
return previous == QVariant() ? false : previous.toBool(); return !(previous == QVariant()) && previous.toBool();
} }
void GameFiltersSettings::setShowGamesThatStarted(bool show) void GameFiltersSettings::setHideGamesThatStarted(bool hide)
{ {
setValue(show, "show_games_that_started", "filter_games"); setValue(hide, "hide_games_that_started", "filter_games");
} }
bool GameFiltersSettings::isShowGamesThatStarted() bool GameFiltersSettings::isHideGamesThatStarted()
{ {
QVariant previous = getValue("show_games_that_started", "filter_games"); QVariant previous = getValue("hide_games_that_started", "filter_games");
return previous == QVariant() ? false : previous.toBool(); return !(previous == QVariant()) && previous.toBool();
} }
void GameFiltersSettings::setShowPasswordProtectedGames(bool show) void GameFiltersSettings::setHidePasswordProtectedGames(bool hide)
{ {
setValue(show, "show_password_protected_games", "filter_games"); setValue(hide, "hide_password_protected_games", "filter_games");
} }
bool GameFiltersSettings::isShowPasswordProtectedGames() bool GameFiltersSettings::isHidePasswordProtectedGames()
{ {
QVariant previous = getValue("show_password_protected_games", "filter_games"); QVariant previous = getValue("hide_password_protected_games", "filter_games");
return previous == QVariant() ? true : previous.toBool(); return previous == QVariant() || previous.toBool();
} }
void GameFiltersSettings::setHideIgnoredUserGames(bool hide) void GameFiltersSettings::setHideIgnoredUserGames(bool hide)
@ -69,7 +69,7 @@ void GameFiltersSettings::setHideIgnoredUserGames(bool hide)
bool GameFiltersSettings::isHideIgnoredUserGames() bool GameFiltersSettings::isHideIgnoredUserGames()
{ {
QVariant previous = getValue("hide_ignored_user_games", "filter_games"); QVariant previous = getValue("hide_ignored_user_games", "filter_games");
return previous == QVariant() ? false : previous.toBool(); return !(previous == QVariant()) && previous.toBool();
} }
void GameFiltersSettings::setGameNameFilter(QString gameName) void GameFiltersSettings::setGameNameFilter(QString gameName)

View file

@ -9,10 +9,10 @@ class GameFiltersSettings : public SettingsManager
friend class SettingsCache; friend class SettingsCache;
public: public:
bool isShowBuddiesOnlyGames(); bool isHideBuddiesOnlyGames();
bool isShowFullGames(); bool isHideFullGames();
bool isShowGamesThatStarted(); bool isHideGamesThatStarted();
bool isShowPasswordProtectedGames(); bool isHidePasswordProtectedGames();
bool isHideIgnoredUserGames(); bool isHideIgnoredUserGames();
QString getGameNameFilter(); QString getGameNameFilter();
QString getCreatorNameFilter(); QString getCreatorNameFilter();
@ -25,11 +25,11 @@ public:
bool isShowOnlyIfSpectatorsCanChat(); bool isShowOnlyIfSpectatorsCanChat();
bool isShowOnlyIfSpectatorsCanSeeHands(); bool isShowOnlyIfSpectatorsCanSeeHands();
void setShowBuddiesOnlyGames(bool show); void setHideBuddiesOnlyGames(bool hide);
void setHideIgnoredUserGames(bool hide); void setHideIgnoredUserGames(bool hide);
void setShowFullGames(bool show); void setHideFullGames(bool hide);
void setShowGamesThatStarted(bool show); void setHideGamesThatStarted(bool hide);
void setShowPasswordProtectedGames(bool show); void setHidePasswordProtectedGames(bool hide);
void setGameNameFilter(QString gameName); void setGameNameFilter(QString gameName);
void setCreatorNameFilter(QString creatorName); void setCreatorNameFilter(QString creatorName);
void setMinPlayers(int min); void setMinPlayers(int min);