diff --git a/cockatrice/cockatrice.qrc b/cockatrice/cockatrice.qrc index 704e28cb7..d9e177fa4 100644 --- a/cockatrice/cockatrice.qrc +++ b/cockatrice/cockatrice.qrc @@ -2,6 +2,7 @@ resources/back.svg resources/lock.svg + resources/faded_lock.svg resources/icon_delete.svg resources/icon_tab_changed.svg resources/icon_config_general.svg diff --git a/cockatrice/resources/faded_lock.svg b/cockatrice/resources/faded_lock.svg new file mode 100644 index 000000000..afcd35360 --- /dev/null +++ b/cockatrice/resources/faded_lock.svg @@ -0,0 +1,944 @@ + + + + + + + + + padlock + + + + icon + + lock + security + secure + padlock + signs_and_symbols + + + + + AJ Ashton + + + + + AJ Ashton + + + + + AJ Ashton + + + + image/svg+xml + + + en + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/cockatrice/src/gamesmodel.cpp b/cockatrice/src/gamesmodel.cpp index 49b8886e2..416d49727 100644 --- a/cockatrice/src/gamesmodel.cpp +++ b/cockatrice/src/gamesmodel.cpp @@ -79,12 +79,15 @@ QVariant GamesModel::data(const QModelIndex &index, int role) const return QVariant(); if (role == Qt::UserRole) return index.row(); - if (role != Qt::DisplayRole && role != SORT_ROLE && role != Qt::DecorationRole && role != Qt::TextAlignmentRole) + if (role != Qt::DisplayRole && role != SORT_ROLE && role != Qt::DecorationRole && role != Qt::TextAlignmentRole && role != Qt::ForegroundRole) return QVariant(); if ((index.row() >= gameList.size()) || (index.column() >= columnCount())) return QVariant(); const ServerInfo_Game &g = gameList[index.row()]; + if (role == Qt::ForegroundRole && !isGameAvailable(g)) + return QColor(130, 130, 130); + switch (index.column()) { case ROOM: return rooms.value(g.room_id()); @@ -151,7 +154,7 @@ QVariant GamesModel::data(const QModelIndex &index, int role) const return result.join(", "); } case Qt::DecorationRole:{ - return g.with_password() ? QIcon(":/resources/lock.svg") : QVariant(); + return g.with_password() ? QIcon(isGameAvailable(g) ? ":/resources/lock.svg" : ":/resources/faded_lock.svg") : QVariant(); case Qt::TextAlignmentRole: return Qt::AlignLeft; default: @@ -168,7 +171,6 @@ QVariant GamesModel::data(const QModelIndex &index, int role) const default: return QVariant(); } - case SPECTATORS: switch(role) { case SORT_ROLE: @@ -193,6 +195,10 @@ QVariant GamesModel::data(const QModelIndex &index, int role) const } } +bool GamesModel::isGameAvailable(const ServerInfo_Game &g) const { + return g.player_count() != g.max_players() && !g.started(); +} + QVariant GamesModel::headerData(int section, Qt::Orientation orientation, int role) const { if ((role != Qt::DisplayRole) || (orientation != Qt::Horizontal)) diff --git a/cockatrice/src/gamesmodel.h b/cockatrice/src/gamesmodel.h index dc23f9214..d522204d4 100644 --- a/cockatrice/src/gamesmodel.h +++ b/cockatrice/src/gamesmodel.h @@ -38,6 +38,7 @@ public: int startTimeColIndex() { return 1; } const QMap &getGameTypes() { return gameTypes; } + bool isGameAvailable(const ServerInfo_Game &g) const; }; class GamesProxyModel : public QSortFilterProxyModel {