Add keyboard shorcuts to focus and unfocus chat (#3898)

* Added keyboard shorcuts to focus and unfocus chat

* Fixed format

* Changed the Esc behavior to work on any QLineEdit in the main Window and ignore shortcut conflicts

* Fixed a conflict with shortcuts

* Configurable unfocus shortcut and format fixes

* minor style fix
This commit is contained in:
Xenos6666 2020-03-17 02:48:05 +01:00 committed by GitHub
parent 7285f24a29
commit 63b4f9b2f0
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
25 changed files with 235 additions and 107 deletions

View file

@ -1,17 +1,4 @@
#include <QAction>
#include <QCompleter>
#include <QDebug>
#include <QDockWidget>
#include <QFileDialog>
#include <QHBoxLayout>
#include <QLabel>
#include <QMenu>
#include <QMessageBox>
#include <QSplitter>
#include <QStackedWidget>
#include <QTimer>
#include <QToolButton>
#include <QWidget>
#include "tab_game.h"
#include "abstractclient.h"
#include "arrowitem.h"
@ -24,22 +11,10 @@
#include "dlg_load_remote_deck.h"
#include "gamescene.h"
#include "gameview.h"
#include "get_pb_extension.h"
#include "lineeditcompleter.h"
#include "main.h"
#include "messagelogwidget.h"
#include "phasestoolbar.h"
#include "pictureloader.h"
#include "player.h"
#include "playerlistwidget.h"
#include "replay_timeline_widget.h"
#include "settingscache.h"
#include "tab_game.h"
#include "tab_supervisor.h"
#include "window_sets.h"
#include "zoneviewwidget.h"
#include "zoneviewzone.h"
#include "get_pb_extension.h"
#include "pb/command_concede.pb.h"
#include "pb/command_deck_select.pb.h"
#include "pb/command_delete_arrow.pb.h"
@ -70,6 +45,31 @@
#include "pb/game_replay.pb.h"
#include "pb/response_deck_download.pb.h"
#include "pending_command.h"
#include "phasestoolbar.h"
#include "pictureloader.h"
#include "player.h"
#include "playerlistwidget.h"
#include "replay_timeline_widget.h"
#include "settingscache.h"
#include "tab_supervisor.h"
#include "window_sets.h"
#include "zoneviewwidget.h"
#include "zoneviewzone.h"
#include <QAction>
#include <QCompleter>
#include <QDebug>
#include <QDockWidget>
#include <QFileDialog>
#include <QHBoxLayout>
#include <QLabel>
#include <QMenu>
#include <QMessageBox>
#include <QSplitter>
#include <QStackedWidget>
#include <QTimer>
#include <QToolButton>
#include <QWidget>
#include <google/protobuf/descriptor.h>
ToggleButton::ToggleButton(QWidget *parent) : QPushButton(parent), state(false)
@ -248,6 +248,9 @@ void TabGame::refreshShortcuts()
if (aResetLayout) {
aResetLayout->setShortcuts(settingsCache->shortcuts().getShortcut("Player/aResetLayout"));
}
if (aFocusChat) {
aFocusChat->setShortcuts(settingsCache->shortcuts().getShortcut("tab_game/aFocusChat"));
}
}
void DeckViewContainer::loadLocalDeck()
@ -531,6 +534,9 @@ void TabGame::retranslateUi()
if (aCloseReplay) {
aCloseReplay->setText(tr("C&lose replay"));
}
if (aFocusChat) {
aFocusChat->setText(tr("&Focus Chat"));
}
if (sayLabel) {
sayLabel->setText(tr("&Say:"));
}
@ -971,8 +977,6 @@ void TabGame::startGame(bool resuming)
playerListWidget->setGameStarted(true, resuming);
gameInfo.set_started(true);
static_cast<GameScene *>(gameView->scene())->rearrange();
if (sayEdit && players.size() > 1)
sayEdit->setFocus();
}
void TabGame::stopGame()
@ -1413,6 +1417,8 @@ void TabGame::createMenuItems()
connect(aConcede, SIGNAL(triggered()), this, SLOT(actConcede()));
aLeaveGame = new QAction(this);
connect(aLeaveGame, SIGNAL(triggered()), this, SLOT(actLeaveGame()));
aFocusChat = new QAction(this);
connect(aFocusChat, SIGNAL(triggered()), sayEdit, SLOT(setFocus()));
aCloseReplay = nullptr;
phasesMenu = new TearOffMenu(this);
@ -1440,6 +1446,7 @@ void TabGame::createMenuItems()
gameMenu->addSeparator();
gameMenu->addAction(aGameInfo);
gameMenu->addAction(aConcede);
gameMenu->addAction(aFocusChat);
gameMenu->addAction(aLeaveGame);
addTabMenu(gameMenu);
}
@ -1456,6 +1463,7 @@ void TabGame::createReplayMenuItems()
aResetLayout = nullptr;
aGameInfo = nullptr;
aConcede = nullptr;
aFocusChat = nullptr;
aLeaveGame = nullptr;
aCloseReplay = new QAction(this);
connect(aCloseReplay, SIGNAL(triggered()), this, SLOT(actLeaveGame()));