diff --git a/.clang-format b/.clang-format index a20feb82..f2a5fa55 100644 --- a/.clang-format +++ b/.clang-format @@ -22,4 +22,6 @@ AllowShortFunctionsOnASingleLine: None BinPackParameters: false AllowAllParametersOfDeclarationOnNextLine: false IndentCaseLabels: true -PointerAlignment: Right \ No newline at end of file +PointerAlignment: Right +SortIncludes: true +IncludeBlocks: Regroup diff --git a/cockatrice/CMakeLists.txt b/cockatrice/CMakeLists.txt index 38421170..1c1a97e4 100644 --- a/cockatrice/CMakeLists.txt +++ b/cockatrice/CMakeLists.txt @@ -86,7 +86,6 @@ SET(cockatrice_SOURCES src/deckstats_interface.cpp src/tappedout_interface.cpp src/chatview/chatview.cpp - src/chatview/userlistProxy.h src/userlist.cpp src/userinfobox.cpp src/user_context_menu.cpp @@ -123,6 +122,7 @@ SET(cockatrice_SOURCES src/carddbparser/cockatricexml3.cpp src/carddbparser/cockatricexml4.cpp src/filter_string.cpp + src/customlineedit.cpp ${VERSION_STRING_CPP} ) diff --git a/cockatrice/src/customlineedit.cpp b/cockatrice/src/customlineedit.cpp new file mode 100644 index 00000000..342cc6cd --- /dev/null +++ b/cockatrice/src/customlineedit.cpp @@ -0,0 +1,72 @@ + +#include "customlineedit.h" + +#include "settingscache.h" +#include "shortcutssettings.h" + +#include +#include +#include +#include + +LineEditUnfocusable::LineEditUnfocusable(QWidget *parent) : QLineEdit(parent) +{ + installEventFilter(this); +} + +LineEditUnfocusable::LineEditUnfocusable(const QString &contents, QWidget *parent) : QLineEdit(contents, parent) +{ + installEventFilter(this); +} + +bool LineEditUnfocusable::isUnfocusShortcut(QKeyEvent *event) +{ + QString modifier; + QString keyNoMod; + + if (event->modifiers() & Qt::ShiftModifier) + modifier += "Shift+"; + if (event->modifiers() & Qt::ControlModifier) + modifier += "Ctrl+"; + if (event->modifiers() & Qt::AltModifier) + modifier += "Alt+"; + if (event->modifiers() & Qt::MetaModifier) + modifier += "Meta+"; + + keyNoMod = QKeySequence(event->key()).toString(); + + QKeySequence key(modifier + keyNoMod); + QList unfocusShortcut = settingsCache->shortcuts().getShortcut("Textbox/unfocusTextBox"); + + for (QList::iterator i = unfocusShortcut.begin(); i != unfocusShortcut.end(); ++i) { + if (key.matches(*i) == QKeySequence::ExactMatch) + return true; + } + return false; +} + +void LineEditUnfocusable::keyPressEvent(QKeyEvent *event) +{ + if (isUnfocusShortcut(event)) { + clearFocus(); + + return; + } + + QLineEdit::keyPressEvent(event); +} + +bool LineEditUnfocusable::eventFilter(QObject *watched, QEvent *event) +{ + if (event->type() == QEvent::ShortcutOverride) { + QKeyEvent *keyEvent = static_cast(event); + + if (isUnfocusShortcut(keyEvent)) { + event->accept(); + + return true; + } + } + + return QLineEdit::eventFilter(watched, event); +} diff --git a/cockatrice/src/customlineedit.h b/cockatrice/src/customlineedit.h new file mode 100644 index 00000000..fcd824e0 --- /dev/null +++ b/cockatrice/src/customlineedit.h @@ -0,0 +1,27 @@ + +#ifndef CUSTOMLINEEDIT_H +#define CUSTOMLINEEDIT_H + +#include + +class QKeyEvent; +class QWidget; +class QString; + +// Should be used when the there is a risk of conflict between line editor +// shortcuts and other shortcuts +class LineEditUnfocusable : public QLineEdit +{ +public: + LineEditUnfocusable(QWidget *parent = nullptr); + LineEditUnfocusable(const QString &contents, QWidget *parent = nullptr); + +private: + bool isUnfocusShortcut(QKeyEvent *key); + +protected: + void keyPressEvent(QKeyEvent *event) override; + bool eventFilter(QObject *watched, QEvent *event) override; +}; + +#endif diff --git a/cockatrice/src/filterbuilder.cpp b/cockatrice/src/filterbuilder.cpp index 03a4632c..68e73968 100644 --- a/cockatrice/src/filterbuilder.cpp +++ b/cockatrice/src/filterbuilder.cpp @@ -1,12 +1,12 @@ #include "filterbuilder.h" +#include "cardfilter.h" +#include "customlineedit.h" + #include #include -#include #include -#include "cardfilter.h" - FilterBuilder::FilterBuilder(QWidget *parent) : QWidget(parent) { filterCombo = new QComboBox; @@ -23,7 +23,7 @@ FilterBuilder::FilterBuilder(QWidget *parent) : QWidget(parent) ok->setObjectName("ok"); ok->setMaximumSize(20, 20); - edit = new QLineEdit; + edit = new LineEditUnfocusable; edit->setObjectName("edit"); edit->setPlaceholderText(tr("Type your filter here")); edit->setClearButtonEnabled(true); diff --git a/cockatrice/src/filterbuilder.h b/cockatrice/src/filterbuilder.h index 375d4e91..be048836 100644 --- a/cockatrice/src/filterbuilder.h +++ b/cockatrice/src/filterbuilder.h @@ -5,7 +5,7 @@ class QCheckBox; class QComboBox; -class QLineEdit; +class LineEditUnfocusable; class CardFilter; class FilterBuilder : public QWidget @@ -15,7 +15,7 @@ class FilterBuilder : public QWidget private: QComboBox *typeCombo; QComboBox *filterCombo; - QLineEdit *edit; + LineEditUnfocusable *edit; CardFilter *fltr; void destroyFilter(); diff --git a/cockatrice/src/lineeditcompleter.cpp b/cockatrice/src/lineeditcompleter.cpp index e3eec7e7..f8cad38a 100644 --- a/cockatrice/src/lineeditcompleter.cpp +++ b/cockatrice/src/lineeditcompleter.cpp @@ -1,21 +1,21 @@ #include "lineeditcompleter.h" + #include #include #include #include -#include #include #include #include #include -LineEditCompleter::LineEditCompleter(QWidget *parent) : QLineEdit(parent), c(nullptr) +LineEditCompleter::LineEditCompleter(QWidget *parent) : LineEditUnfocusable(parent), c(nullptr) { } void LineEditCompleter::focusOutEvent(QFocusEvent *e) { - QLineEdit::focusOutEvent(e); + LineEditUnfocusable::focusOutEvent(e); if (c->popup()->isVisible()) { // Remove Popup c->popup()->hide(); @@ -73,7 +73,7 @@ void LineEditCompleter::keyPressEvent(QKeyEvent *event) break; } - QLineEdit::keyPressEvent(event); + LineEditUnfocusable::keyPressEvent(event); // return if the completer is null or if the most recently typed char was '@'. // Only want the popup AFTER typing the first char of the mention. if (!c || text().right(1).contains("@")) { @@ -130,4 +130,4 @@ void LineEditCompleter::setCompletionList(QStringList completionList) if (model == NULL) model = new QStringListModel(); model->setStringList(completionList); -} \ No newline at end of file +} diff --git a/cockatrice/src/lineeditcompleter.h b/cockatrice/src/lineeditcompleter.h index fd8e2e34..5be1562d 100644 --- a/cockatrice/src/lineeditcompleter.h +++ b/cockatrice/src/lineeditcompleter.h @@ -1,12 +1,13 @@ #ifndef LINEEDITCOMPLETER_H #define LINEEDITCOMPLETER_H +#include "customlineedit.h" + #include #include -#include #include -class LineEditCompleter : public QLineEdit +class LineEditCompleter : public LineEditUnfocusable { Q_OBJECT private: @@ -25,4 +26,4 @@ public: void setCompletionList(QStringList); }; -#endif \ No newline at end of file +#endif diff --git a/cockatrice/src/shortcutssettings.h b/cockatrice/src/shortcutssettings.h index 68b9bbcb..a7f2b9e4 100644 --- a/cockatrice/src/shortcutssettings.h +++ b/cockatrice/src/shortcutssettings.h @@ -529,6 +529,12 @@ private: {"Player/aRotateViewCCW", ShortcutKey(QT_TRANSLATE_NOOP("shortcutsTab", "Rotate view counterclockwise"), parseSequenceString(""), ShortcutGroup::Drawing)}, + {"Textbox/unfocusTextBox", ShortcutKey(QT_TRANSLATE_NOOP("shortcutsTab", "Unfocus text box"), + parseSequenceString("Esc"), + ShortcutGroup::Chat_room)}, + {"tab_game/aFocusChat", ShortcutKey(QT_TRANSLATE_NOOP("shortcutsTab", "Focus Chat"), + parseSequenceString("Shift+Return"), + ShortcutGroup::Chat_room)}, {"tab_room/aClearChat", ShortcutKey(QT_TRANSLATE_NOOP("shortcutsTab", "Clear chat"), parseSequenceString("F12"), ShortcutGroup::Chat_room)}, diff --git a/cockatrice/src/tab_deck_editor.cpp b/cockatrice/src/tab_deck_editor.cpp index 3af5dedc..f7a36d51 100644 --- a/cockatrice/src/tab_deck_editor.cpp +++ b/cockatrice/src/tab_deck_editor.cpp @@ -1,4 +1,5 @@ #include "tab_deck_editor.h" + #include "abstractclient.h" #include "carddatabasemodel.h" #include "cardframe.h" @@ -16,6 +17,7 @@ #include "settingscache.h" #include "tab_supervisor.h" #include "tappedout_interface.h" + #include #include #include @@ -28,6 +30,7 @@ #include #include #include +#include #include #include #include @@ -50,7 +53,7 @@ void SearchLineEdit::keyPressEvent(QKeyEvent *event) { if (treeView && ((event->key() == Qt::Key_Up) || (event->key() == Qt::Key_Down))) QCoreApplication::sendEvent(treeView, event); - QLineEdit::keyPressEvent(event); + LineEditUnfocusable::keyPressEvent(event); } void TabDeckEditor::createDeckDock() @@ -79,7 +82,7 @@ void TabDeckEditor::createDeckDock() nameLabel = new QLabel(); nameLabel->setObjectName("nameLabel"); - nameEdit = new QLineEdit; + nameEdit = new LineEditUnfocusable; nameEdit->setObjectName("nameEdit"); nameLabel->setBuddy(nameEdit); connect(nameEdit, SIGNAL(textChanged(const QString &)), this, SLOT(updateName(const QString &))); @@ -121,7 +124,7 @@ void TabDeckEditor::createDeckDock() auto *hashSizePolicy = new QSizePolicy(); hashSizePolicy->setHorizontalPolicy(QSizePolicy::Fixed); hashLabel1->setSizePolicy(*hashSizePolicy); - hashLabel = new QLineEdit; + hashLabel = new LineEditUnfocusable; hashLabel->setObjectName("hashLabel"); hashLabel->setReadOnly(true); hashLabel->setFrame(false); diff --git a/cockatrice/src/tab_deck_editor.h b/cockatrice/src/tab_deck_editor.h index 089fb54b..bc40c408 100644 --- a/cockatrice/src/tab_deck_editor.h +++ b/cockatrice/src/tab_deck_editor.h @@ -1,13 +1,13 @@ #ifndef WINDOW_DECKEDITOR_H #define WINDOW_DECKEDITOR_H +#include "carddatabase.h" +#include "customlineedit.h" #include "keysignals.h" #include "tab.h" + #include #include -#include - -#include "carddatabase.h" class CardDatabaseModel; class CardDatabaseDisplayModel; @@ -27,7 +27,7 @@ class QVBoxLayout; class QPushButton; class QDockWidget; -class SearchLineEdit : public QLineEdit +class SearchLineEdit : public LineEditUnfocusable { private: QTreeView *treeView; @@ -36,7 +36,7 @@ protected: void keyPressEvent(QKeyEvent *event) override; public: - SearchLineEdit() : QLineEdit(), treeView(nullptr) + SearchLineEdit() : LineEditUnfocusable(), treeView(nullptr) { } void setTreeView(QTreeView *_treeView) @@ -117,11 +117,11 @@ private: KeySignals searchKeySignals; QLabel *nameLabel; - QLineEdit *nameEdit; + LineEditUnfocusable *nameEdit; QLabel *commentsLabel; QTextEdit *commentsEdit; QLabel *hashLabel1; - QLineEdit *hashLabel; + LineEditUnfocusable *hashLabel; FilterTreeModel *filterModel; QTreeView *filterView; KeySignals filterViewKeySignals; diff --git a/cockatrice/src/tab_game.cpp b/cockatrice/src/tab_game.cpp index 734031e2..82a3307d 100644 --- a/cockatrice/src/tab_game.cpp +++ b/cockatrice/src/tab_game.cpp @@ -1,17 +1,4 @@ -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include +#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 +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include #include 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(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())); diff --git a/cockatrice/src/tab_game.h b/cockatrice/src/tab_game.h index 13369177..d99a68cd 100644 --- a/cockatrice/src/tab_game.h +++ b/cockatrice/src/tab_game.h @@ -5,6 +5,7 @@ #include "pb/serverinfo_game.pb.h" #include "tab.h" #include "tearoffmenu.h" + #include #include #include @@ -19,7 +20,6 @@ class MessageLogWidget; class QTimer; class QSplitter; class QLabel; -class QLineEdit; class QPushButton; class QToolButton; class QMenu; @@ -170,6 +170,7 @@ private: *aReverseTurn, *aRemoveLocalArrows, *aRotateViewCW, *aRotateViewCCW, *aResetLayout, *aResetReplayLayout; QAction *aCardInfoDockVisible, *aCardInfoDockFloating, *aMessageLayoutDockVisible, *aMessageLayoutDockFloating, *aPlayerListDockVisible, *aPlayerListDockFloating, *aReplayDockVisible, *aReplayDockFloating; + QAction *aFocusChat; QList phaseActions; Player *addPlayer(int playerId, const ServerInfo_User &info); diff --git a/cockatrice/src/tab_logs.cpp b/cockatrice/src/tab_logs.cpp index 91d2ed17..2960f91d 100644 --- a/cockatrice/src/tab_logs.cpp +++ b/cockatrice/src/tab_logs.cpp @@ -1,21 +1,22 @@ #include "tab_logs.h" + #include "abstractclient.h" +#include "customlineedit.h" #include "pb/moderator_commands.pb.h" #include "pb/response_viewlog_history.pb.h" #include "pending_command.h" #include "window_sets.h" + #include #include #include #include #include -#include #include #include #include #include #include - #include #include @@ -147,19 +148,19 @@ void TabLog::createDock() { labelFindUserName = new QLabel(tr("Username: ")); - findUsername = new QLineEdit(""); + findUsername = new LineEditUnfocusable(""); findUsername->setAlignment(Qt::AlignCenter); labelFindIPAddress = new QLabel(tr("IP Address: ")); - findIPAddress = new QLineEdit(""); + findIPAddress = new LineEditUnfocusable(""); findIPAddress->setAlignment(Qt::AlignCenter); labelFindGameName = new QLabel(tr("Game Name: ")); - findGameName = new QLineEdit(""); + findGameName = new LineEditUnfocusable(""); findGameName->setAlignment(Qt::AlignCenter); labelFindGameID = new QLabel(tr("GameID: ")); - findGameID = new QLineEdit(""); + findGameID = new LineEditUnfocusable(""); findGameID->setAlignment(Qt::AlignCenter); labelMessage = new QLabel(tr("Message: ")); - findMessage = new QLineEdit(""); + findMessage = new LineEditUnfocusable(""); findMessage->setAlignment(Qt::AlignCenter); mainRoom = new QCheckBox(tr("Main Room")); @@ -340,4 +341,4 @@ void TabLog::restartLayout() searchDock->setFloating(false); addDockWidget(Qt::LeftDockWidgetArea, searchDock); searchDock->setVisible(true); -} \ No newline at end of file +} diff --git a/cockatrice/src/tab_logs.h b/cockatrice/src/tab_logs.h index aacf99c6..d31d6840 100644 --- a/cockatrice/src/tab_logs.h +++ b/cockatrice/src/tab_logs.h @@ -2,14 +2,15 @@ #define TAB_LOG_H #include "tab.h" + #include class AbstractClient; +class LineEditUnfocusable; class QGroupBox; class QPushButton; class QSpinBox; -class QLineEdit; class QCheckBox; class QRadioButton; class QLabel; @@ -29,7 +30,7 @@ private: AbstractClient *client; QLabel *labelFindUserName, *labelFindIPAddress, *labelFindGameName, *labelFindGameID, *labelMessage, *labelMaximum, *labelDescription; - QLineEdit *findUsername, *findIPAddress, *findGameName, *findGameID, *findMessage; + LineEditUnfocusable *findUsername, *findIPAddress, *findGameName, *findGameID, *findMessage; QCheckBox *mainRoom, *gameRoom, *privateChat; QRadioButton *pastDays, *today, *lastHour; QSpinBox *maximumResults, *pastXDays; diff --git a/cockatrice/src/tab_message.cpp b/cockatrice/src/tab_message.cpp index e65efd6b..7395dc93 100644 --- a/cockatrice/src/tab_message.cpp +++ b/cockatrice/src/tab_message.cpp @@ -1,20 +1,21 @@ #include "tab_message.h" + #include "abstractclient.h" #include "chatview/chatview.h" +#include "customlineedit.h" #include "main.h" -#include "settingscache.h" -#include "soundengine.h" -#include -#include -#include -#include -#include -#include - #include "pb/event_user_message.pb.h" #include "pb/serverinfo_user.pb.h" #include "pb/session_commands.pb.h" #include "pending_command.h" +#include "settingscache.h" +#include "soundengine.h" + +#include +#include +#include +#include +#include TabMessage::TabMessage(TabSupervisor *_tabSupervisor, AbstractClient *_client, @@ -27,7 +28,7 @@ TabMessage::TabMessage(TabSupervisor *_tabSupervisor, connect(chatView, SIGNAL(showCardInfoPopup(QPoint, QString)), this, SLOT(showCardInfoPopup(QPoint, QString))); connect(chatView, SIGNAL(deleteCardInfoPopup(QString)), this, SLOT(deleteCardInfoPopup(QString))); connect(chatView, SIGNAL(addMentionTag(QString)), this, SLOT(addMentionTag(QString))); - sayEdit = new QLineEdit; + sayEdit = new LineEditUnfocusable; connect(sayEdit, SIGNAL(returnPressed()), this, SLOT(sendMessage())); QVBoxLayout *vbox = new QVBoxLayout; diff --git a/cockatrice/src/tab_message.h b/cockatrice/src/tab_message.h index 4892c229..79653ffc 100644 --- a/cockatrice/src/tab_message.h +++ b/cockatrice/src/tab_message.h @@ -5,7 +5,7 @@ class AbstractClient; class ChatView; -class QLineEdit; +class LineEditUnfocusable; class Event_UserMessage; class Response; class ServerInfo_User; @@ -21,7 +21,7 @@ private: bool userOnline; ChatView *chatView; - QLineEdit *sayEdit; + LineEditUnfocusable *sayEdit; QAction *aLeave; signals: diff --git a/cockatrice/src/tab_room.cpp b/cockatrice/src/tab_room.cpp index 4dc739a0..9931821c 100644 --- a/cockatrice/src/tab_room.cpp +++ b/cockatrice/src/tab_room.cpp @@ -1,4 +1,5 @@ #include "tab_room.h" + #include "abstractclient.h" #include "chatview/chatview.h" #include "dlg_settings.h" @@ -16,10 +17,10 @@ #include "tab_supervisor.h" #include "tab_userlists.h" #include "userlist.h" + #include #include #include -#include #include #include #include @@ -323,4 +324,4 @@ PendingCommand *TabRoom::prepareRoomCommand(const ::google::protobuf::Message &c void TabRoom::sendRoomCommand(PendingCommand *pend) { client->sendCommand(pend); -} \ No newline at end of file +} diff --git a/cockatrice/src/tab_room.h b/cockatrice/src/tab_room.h index 75fc03b4..c5e41a1b 100644 --- a/cockatrice/src/tab_room.h +++ b/cockatrice/src/tab_room.h @@ -3,10 +3,10 @@ #include "lineeditcompleter.h" #include "tab.h" + #include #include #include -#include #include namespace google @@ -20,7 +20,6 @@ class AbstractClient; class UserList; class QLabel; class ChatView; -class QLineEdit; class QPushButton; class QTextTable; class QCompleter; diff --git a/cockatrice/src/tab_server.cpp b/cockatrice/src/tab_server.cpp index 67a0c66f..aae93506 100644 --- a/cockatrice/src/tab_server.cpp +++ b/cockatrice/src/tab_server.cpp @@ -1,26 +1,26 @@ #include "tab_server.h" + #include "abstractclient.h" +#include "pb/event_list_rooms.pb.h" +#include "pb/event_server_message.pb.h" +#include "pb/response_join_room.pb.h" +#include "pb/session_commands.pb.h" +#include "pending_command.h" #include "tab_supervisor.h" #include "userlist.h" + #include #include #include #include #include #include -#include #include #include #include #include #include -#include "pb/event_list_rooms.pb.h" -#include "pb/event_server_message.pb.h" -#include "pb/response_join_room.pb.h" -#include "pb/session_commands.pb.h" -#include "pending_command.h" - RoomSelector::RoomSelector(AbstractClient *_client, QWidget *parent) : QGroupBox(parent), client(_client) { roomList = new QTreeWidget; diff --git a/cockatrice/src/tab_userlists.cpp b/cockatrice/src/tab_userlists.cpp index ef2da9b2..ad0ec8dc 100644 --- a/cockatrice/src/tab_userlists.cpp +++ b/cockatrice/src/tab_userlists.cpp @@ -1,13 +1,7 @@ #include "tab_userlists.h" -#include "abstractclient.h" -#include "soundengine.h" -#include "userinfobox.h" -#include "userlist.h" -#include -#include -#include -#include +#include "abstractclient.h" +#include "customlineedit.h" #include "pb/event_add_to_list.pb.h" #include "pb/event_remove_from_list.pb.h" #include "pb/event_user_joined.pb.h" @@ -15,6 +9,13 @@ #include "pb/response_list_users.pb.h" #include "pb/session_commands.pb.h" #include "pending_command.h" +#include "soundengine.h" +#include "userinfobox.h" +#include "userlist.h" + +#include +#include +#include TabUserLists::TabUserLists(TabSupervisor *_tabSupervisor, AbstractClient *_client, @@ -58,7 +59,7 @@ TabUserLists::TabUserLists(TabSupervisor *_tabSupervisor, vbox->addWidget(allUsersList); QHBoxLayout *addToBuddyList = new QHBoxLayout; - addBuddyEdit = new QLineEdit; + addBuddyEdit = new LineEditUnfocusable; addBuddyEdit->setPlaceholderText(tr("Add to Buddy List")); connect(addBuddyEdit, SIGNAL(returnPressed()), this, SLOT(addToBuddyList())); QPushButton *addBuddyButton = new QPushButton("Add"); @@ -67,7 +68,7 @@ TabUserLists::TabUserLists(TabSupervisor *_tabSupervisor, addToBuddyList->addWidget(addBuddyButton); QHBoxLayout *addToIgnoreList = new QHBoxLayout; - addIgnoreEdit = new QLineEdit; + addIgnoreEdit = new LineEditUnfocusable; addIgnoreEdit->setPlaceholderText(tr("Add to Ignore List")); connect(addIgnoreEdit, SIGNAL(returnPressed()), this, SLOT(addToIgnoreList())); QPushButton *addIgnoreButton = new QPushButton("Add"); diff --git a/cockatrice/src/tab_userlists.h b/cockatrice/src/tab_userlists.h index 08295755..caa9166f 100644 --- a/cockatrice/src/tab_userlists.h +++ b/cockatrice/src/tab_userlists.h @@ -3,11 +3,11 @@ #include "pb/serverinfo_user.pb.h" #include "tab.h" -#include class AbstractClient; class UserList; class UserInfoBox; +class LineEditUnfocusable; class Event_ListRooms; class Event_UserJoined; @@ -41,8 +41,8 @@ private: UserList *buddyList; UserList *ignoreList; UserInfoBox *userInfoBox; - QLineEdit *addBuddyEdit; - QLineEdit *addIgnoreEdit; + LineEditUnfocusable *addBuddyEdit; + LineEditUnfocusable *addIgnoreEdit; void addToList(const std::string &listName, const QString &userName); public: diff --git a/cockatrice/src/userlist.cpp b/cockatrice/src/userlist.cpp index 9910f656..879027f9 100644 --- a/cockatrice/src/userlist.cpp +++ b/cockatrice/src/userlist.cpp @@ -1,4 +1,5 @@ #include "userlist.h" + #include "abstractclient.h" #include "gameselector.h" #include "pb/moderator_commands.pb.h" @@ -10,12 +11,14 @@ #include "tab_supervisor.h" #include "tab_userlists.h" #include "user_context_menu.h" + #include #include #include #include #include #include +#include #include #include #include diff --git a/cockatrice/src/window_sets.cpp b/cockatrice/src/window_sets.cpp index 364641f2..5d0c5f79 100644 --- a/cockatrice/src/window_sets.cpp +++ b/cockatrice/src/window_sets.cpp @@ -1,4 +1,6 @@ #include "window_sets.h" + +#include "customlineedit.h" #include "main.h" #include "pictureloader.h" #include "setsmodel.h" @@ -16,7 +18,6 @@ #include #include #include - #include #define SORT_RESET -1 @@ -60,10 +61,10 @@ WndSets::WndSets(QWidget *parent) : QMainWindow(parent) setsEditToolBar->addAction(aBottom); // search field - searchField = new QLineEdit; + searchField = new LineEditUnfocusable; searchField->setObjectName("searchEdit"); searchField->setPlaceholderText(tr("Search by set name, code, or type")); - searchField->addAction(QPixmap("theme:icons/search"), QLineEdit::LeadingPosition); + searchField->addAction(QPixmap("theme:icons/search"), LineEditUnfocusable::LeadingPosition); searchField->setClearButtonEnabled(true); setFocusProxy(searchField); diff --git a/cockatrice/src/window_sets.h b/cockatrice/src/window_sets.h index 5f95ae1c..c9dd7f5e 100644 --- a/cockatrice/src/window_sets.h +++ b/cockatrice/src/window_sets.h @@ -4,11 +4,11 @@ #include #include #include -#include #include #include class CardDatabase; +class LineEditUnfocusable; class QGroupBox; class QItemSelection; class QPushButton; @@ -35,7 +35,7 @@ private: QGroupBox *sortWarning; QLabel *sortWarningText; QPushButton *sortWarningButton; - QLineEdit *searchField; + LineEditUnfocusable *searchField; QGridLayout *mainLayout; QHBoxLayout *filterBox; int sortIndex;