diff --git a/cockatrice/src/gameselector.cpp b/cockatrice/src/gameselector.cpp index a04cd694..849bb97b 100644 --- a/cockatrice/src/gameselector.cpp +++ b/cockatrice/src/gameselector.cpp @@ -17,7 +17,7 @@ #include "pb/serverinfo_game.pb.h" #include "pb/response.pb.h" -GameSelector::GameSelector(AbstractClient *_client, const TabSupervisor *_tabSupervisor, TabRoom *_room, const QMap &_rooms, const QMap &_gameTypes, QWidget *parent) +GameSelector::GameSelector(AbstractClient *_client, const TabSupervisor *_tabSupervisor, TabRoom *_room, const QMap &_rooms, const QMap &_gameTypes, const bool restoresettings, QWidget *parent) : QGroupBox(parent), client(_client), tabSupervisor(_tabSupervisor), room(_room) { gameListView = new QTreeView; @@ -36,7 +36,8 @@ GameSelector::GameSelector(AbstractClient *_client, const TabSupervisor *_tabSup if (room) gameTypeMap = gameListModel->getGameTypes().value(room->getRoomId()); - gameListProxyModel->loadFilterParameters(gameTypeMap); + if (restoresettings) + gameListProxyModel->loadFilterParameters(gameTypeMap); #if QT_VERSION < 0x050000 gameListView->header()->setResizeMode(0, QHeaderView::ResizeToContents); diff --git a/cockatrice/src/gameselector.h b/cockatrice/src/gameselector.h index 8e043850..af4d28b9 100644 --- a/cockatrice/src/gameselector.h +++ b/cockatrice/src/gameselector.h @@ -36,7 +36,7 @@ private: QPushButton *filterButton, *clearFilterButton, *createButton, *joinButton, *spectateButton; GameTypeMap gameTypeMap; public: - GameSelector(AbstractClient *_client, const TabSupervisor *_tabSupervisor, TabRoom *_room, const QMap &_rooms, const QMap &_gameTypes, QWidget *parent = 0); + GameSelector(AbstractClient *_client, const TabSupervisor *_tabSupervisor, TabRoom *_room, const QMap &_rooms, const QMap &_gameTypes, const bool restoresettings, QWidget *parent = 0); void retranslateUi(); void processGameInfo(const ServerInfo_Game &info); }; diff --git a/cockatrice/src/tab_room.cpp b/cockatrice/src/tab_room.cpp index 57531e6e..1451eb53 100644 --- a/cockatrice/src/tab_room.cpp +++ b/cockatrice/src/tab_room.cpp @@ -34,13 +34,13 @@ TabRoom::TabRoom(TabSupervisor *_tabSupervisor, AbstractClient *_client, ServerI const int gameTypeListSize = info.gametype_list_size(); for (int i = 0; i < gameTypeListSize; ++i) gameTypes.insert(info.gametype_list(i).game_type_id(), QString::fromStdString(info.gametype_list(i).description())); - + QMap tempMap; tempMap.insert(info.room_id(), gameTypes); - gameSelector = new GameSelector(client, tabSupervisor, this, QMap(), tempMap); + gameSelector = new GameSelector(client, tabSupervisor, this, QMap(), tempMap, true); userList = new UserList(tabSupervisor, client, UserList::RoomList); connect(userList, SIGNAL(openMessageDialog(const QString &, bool)), this, SIGNAL(openMessageDialog(const QString &, bool))); - + chatView = new ChatView(tabSupervisor, 0, true); connect(chatView, SIGNAL(openMessageDialog(QString, bool)), this, SIGNAL(openMessageDialog(QString, bool))); connect(chatView, SIGNAL(showCardInfoPopup(QPoint, QString)), this, SLOT(showCardInfoPopup(QPoint, QString))); @@ -50,7 +50,7 @@ TabRoom::TabRoom(TabSupervisor *_tabSupervisor, AbstractClient *_client, ServerI sayEdit = new QLineEdit; sayLabel->setBuddy(sayEdit); connect(sayEdit, SIGNAL(returnPressed()), this, SLOT(sendMessage())); - + QMenu *chatSettingsMenu = new QMenu(this); aClearChat = chatSettingsMenu->addAction(QString()); @@ -60,32 +60,32 @@ TabRoom::TabRoom(TabSupervisor *_tabSupervisor, AbstractClient *_client, ServerI aOpenChatSettings = chatSettingsMenu->addAction(QString()); connect(aOpenChatSettings, SIGNAL(triggered()), this, SLOT(actOpenChatSettings())); - + QToolButton *chatSettingsButton = new QToolButton; chatSettingsButton->setIcon(QIcon(":/resources/icon_settings.svg")); chatSettingsButton->setMenu(chatSettingsMenu); chatSettingsButton->setPopupMode(QToolButton::InstantPopup); - + QHBoxLayout *sayHbox = new QHBoxLayout; sayHbox->addWidget(sayLabel); sayHbox->addWidget(sayEdit); sayHbox->addWidget(chatSettingsButton); - + QVBoxLayout *chatVbox = new QVBoxLayout; chatVbox->addWidget(chatView); chatVbox->addLayout(sayHbox); - + chatGroupBox = new QGroupBox; chatGroupBox->setLayout(chatVbox); - + QSplitter *splitter = new QSplitter(Qt::Vertical); splitter->addWidget(gameSelector); splitter->addWidget(chatGroupBox); - + QHBoxLayout *hbox = new QHBoxLayout; hbox->addWidget(splitter, 3); hbox->addWidget(userList, 1); - + aLeaveRoom = new QAction(this); connect(aLeaveRoom, SIGNAL(triggered()), this, SLOT(actLeaveRoom())); @@ -95,12 +95,12 @@ TabRoom::TabRoom(TabSupervisor *_tabSupervisor, AbstractClient *_client, ServerI retranslateUi(); setLayout(hbox); - + const int userListSize = info.user_list_size(); for (int i = 0; i < userListSize; ++i) userList->processUserInfo(info.user_list(i), true); userList->sortItems(); - + const int gameListSize = info.game_list_size(); for (int i = 0; i < gameListSize; ++i) gameSelector->processGameInfo(info.game_list(i)); @@ -147,10 +147,10 @@ void TabRoom::sendMessage() { if (sayEdit->text().isEmpty()) return; - + Command_RoomSay cmd; cmd.set_message(sayEdit->text().toStdString()); - + PendingCommand *pend = prepareRoomCommand(cmd); connect(pend, SIGNAL(finished(Response, CommandContainer, QVariant)), this, SLOT(sayFinished(const Response &))); sendRoomCommand(pend); diff --git a/cockatrice/src/user_context_menu.cpp b/cockatrice/src/user_context_menu.cpp index df324653..6116a428 100644 --- a/cockatrice/src/user_context_menu.cpp +++ b/cockatrice/src/user_context_menu.cpp @@ -31,7 +31,7 @@ UserContextMenu::UserContextMenu(const TabSupervisor *_tabSupervisor, QWidget *p aRemoveFromIgnoreList = new QAction(QString(), this); aKick = new QAction(QString(), this); aBan = new QAction(QString(), this); - + retranslateUi(); } @@ -52,7 +52,7 @@ void UserContextMenu::gamesOfUserReceived(const Response &resp, const CommandCon { const Response_GetGamesOfUser &response = resp.GetExtension(Response_GetGamesOfUser::ext); const Command_GetGamesOfUser &cmd = commandContainer.session_command(0).GetExtension(Command_GetGamesOfUser::ext); - + QMap gameTypeMap; QMap roomMap; const int roomListSize = response.room_list_size(); @@ -67,12 +67,12 @@ void UserContextMenu::gamesOfUserReceived(const Response &resp, const CommandCon } gameTypeMap.insert(roomInfo.room_id(), tempMap); } - - GameSelector *selector = new GameSelector(client, tabSupervisor, 0, roomMap, gameTypeMap); + + GameSelector *selector = new GameSelector(client, tabSupervisor, 0, roomMap, gameTypeMap, false); const int gameListSize = response.game_list_size(); for (int i = 0; i < gameListSize; ++i) selector->processGameInfo(response.game_list(i)); - + selector->setWindowTitle(tr("%1's games").arg(QString::fromStdString(cmd.user_name()))); selector->setAttribute(Qt::WA_DeleteOnClose); selector->show(); @@ -81,7 +81,7 @@ void UserContextMenu::gamesOfUserReceived(const Response &resp, const CommandCon void UserContextMenu::banUser_processUserInfoResponse(const Response &r) { const Response_GetUserInfo &response = r.GetExtension(Response_GetUserInfo::ext); - + // The dialog needs to be non-modal in order to not block the event queue of the client. BanDialog *dlg = new BanDialog(response.user_info(), static_cast(parent())); connect(dlg, SIGNAL(accepted()), this, SLOT(banUser_dialogFinished())); @@ -91,21 +91,21 @@ void UserContextMenu::banUser_processUserInfoResponse(const Response &r) void UserContextMenu::banUser_dialogFinished() { BanDialog *dlg = static_cast(sender()); - + Command_BanFromServer cmd; cmd.set_user_name(dlg->getBanName().toStdString()); cmd.set_address(dlg->getBanIP().toStdString()); cmd.set_minutes(dlg->getMinutes()); cmd.set_reason(dlg->getReason().toStdString()); cmd.set_visible_reason(dlg->getVisibleReason().toStdString()); - + client->sendCommand(client->prepareModeratorCommand(cmd)); } void UserContextMenu::showContextMenu(const QPoint &pos, const QString &userName, UserLevelFlags userLevel, bool online, int playerId) { aUserName->setText(userName); - + QMenu *menu = new QMenu(static_cast(parent())); menu->addAction(aUserName); menu->addSeparator(); @@ -141,7 +141,7 @@ void UserContextMenu::showContextMenu(const QPoint &pos, const QString &userName aRemoveFromIgnoreList->setEnabled(anotherUser); aKick->setEnabled(anotherUser); aBan->setEnabled(anotherUser); - + QAction *actionClicked = menu->exec(pos); if (actionClicked == aDetails) { UserInfoBox *infoWidget = new UserInfoBox(client, true, static_cast(parent()), Qt::Dialog | Qt::WindowTitleHint | Qt::CustomizeWindowHint | Qt::WindowCloseButtonHint); @@ -152,34 +152,34 @@ void UserContextMenu::showContextMenu(const QPoint &pos, const QString &userName else if (actionClicked == aShowGames) { Command_GetGamesOfUser cmd; cmd.set_user_name(userName.toStdString()); - + PendingCommand *pend = client->prepareSessionCommand(cmd); connect(pend, SIGNAL(finished(Response, CommandContainer, QVariant)), this, SLOT(gamesOfUserReceived(Response, CommandContainer))); - + client->sendCommand(pend); } else if (actionClicked == aAddToBuddyList) { Command_AddToList cmd; cmd.set_list("buddy"); cmd.set_user_name(userName.toStdString()); - + client->sendCommand(client->prepareSessionCommand(cmd)); } else if (actionClicked == aRemoveFromBuddyList) { Command_RemoveFromList cmd; cmd.set_list("buddy"); cmd.set_user_name(userName.toStdString()); - + client->sendCommand(client->prepareSessionCommand(cmd)); } else if (actionClicked == aAddToIgnoreList) { Command_AddToList cmd; cmd.set_list("ignore"); cmd.set_user_name(userName.toStdString()); - + client->sendCommand(client->prepareSessionCommand(cmd)); } else if (actionClicked == aRemoveFromIgnoreList) { Command_RemoveFromList cmd; cmd.set_list("ignore"); cmd.set_user_name(userName.toStdString()); - + client->sendCommand(client->prepareSessionCommand(cmd)); } else if (actionClicked == aKick) { Command_KickFromGame cmd; @@ -188,12 +188,12 @@ void UserContextMenu::showContextMenu(const QPoint &pos, const QString &userName } else if (actionClicked == aBan) { Command_GetUserInfo cmd; cmd.set_user_name(userName.toStdString()); - + PendingCommand *pend = client->prepareSessionCommand(cmd); connect(pend, SIGNAL(finished(Response, CommandContainer, QVariant)), this, SLOT(banUser_processUserInfoResponse(Response))); - + client->sendCommand(pend); } - + delete menu; }