mirror of
git://git.savannah.nongnu.org/eliot.git
synced 2024-12-25 21:59:30 +01:00
Remove all uses of KeyEventFilter.
Use the standard QShortcut instead (possibly combined with a QSignalMapper).
This commit is contained in:
parent
89efeffd9b
commit
820cd1509c
4 changed files with 54 additions and 65 deletions
|
@ -23,11 +23,11 @@
|
|||
#include <QtGui/QStandardItemModel>
|
||||
#include <QtGui/QSortFilterProxyModel>
|
||||
#include <QtGui/QMenu>
|
||||
#include <QtGui/QShortcut>
|
||||
|
||||
#include "arbit_assignments.h"
|
||||
#include "qtcommon.h"
|
||||
#include "custom_popup.h"
|
||||
#include "misc_helpers.h"
|
||||
#include "prefs_dialog.h"
|
||||
|
||||
#include "public_game.h"
|
||||
|
@ -76,35 +76,36 @@ ArbitAssignments::ArbitAssignments(QWidget *parent, PublicGame *iGame)
|
|||
treeViewPlayers->setColumnWidth(6, 25);
|
||||
treeViewPlayers->setColumnWidth(7, 25);
|
||||
|
||||
KeyEventFilter *filter = new KeyEventFilter(this, Qt::Key_A);
|
||||
QObject::connect(filter, SIGNAL(keyPressed(int, int)),
|
||||
QShortcut *shortcut;
|
||||
shortcut = new QShortcut(QString("A"), treeViewPlayers);
|
||||
shortcut->setContext(Qt::WidgetWithChildrenShortcut);
|
||||
QObject::connect(shortcut, SIGNAL(activated()),
|
||||
this, SLOT(selectAllPlayers()));
|
||||
treeViewPlayers->installEventFilter(filter);
|
||||
|
||||
filter = new KeyEventFilter(this, Qt::Key_Delete);
|
||||
QObject::connect(filter, SIGNAL(keyPressed(int, int)),
|
||||
shortcut = new QShortcut(QKeySequence::Delete, treeViewPlayers);
|
||||
shortcut->setContext(Qt::WidgetWithChildrenShortcut);
|
||||
QObject::connect(shortcut, SIGNAL(activated()),
|
||||
this, SLOT(suppressMove()));
|
||||
treeViewPlayers->installEventFilter(filter);
|
||||
|
||||
filter = new KeyEventFilter(this, Qt::Key_T);
|
||||
QObject::connect(filter, SIGNAL(keyPressed(int, int)),
|
||||
shortcut = new QShortcut(QString("T"), treeViewPlayers);
|
||||
shortcut->setContext(Qt::WidgetWithChildrenShortcut);
|
||||
QObject::connect(shortcut, SIGNAL(activated()),
|
||||
this, SLOT(assignTopMove()));
|
||||
treeViewPlayers->installEventFilter(filter);
|
||||
|
||||
filter = new KeyEventFilter(this, Qt::Key_S);
|
||||
QObject::connect(filter, SIGNAL(keyPressed(int, int)),
|
||||
shortcut = new QShortcut(QString("S"), treeViewPlayers);
|
||||
shortcut->setContext(Qt::WidgetWithChildrenShortcut);
|
||||
QObject::connect(shortcut, SIGNAL(activated()),
|
||||
this, SLOT(addRemoveSolo()));
|
||||
treeViewPlayers->installEventFilter(filter);
|
||||
|
||||
filter = new KeyEventFilter(this, Qt::Key_W);
|
||||
QObject::connect(filter, SIGNAL(keyPressed(int, int)),
|
||||
shortcut = new QShortcut(QString("W"), treeViewPlayers);
|
||||
shortcut->setContext(Qt::WidgetWithChildrenShortcut);
|
||||
QObject::connect(shortcut, SIGNAL(activated()),
|
||||
this, SLOT(addRemoveWarning()));
|
||||
treeViewPlayers->installEventFilter(filter);
|
||||
|
||||
filter = new KeyEventFilter(this, Qt::Key_P);
|
||||
QObject::connect(filter, SIGNAL(keyPressed(int, int)),
|
||||
shortcut = new QShortcut(QString("P"), treeViewPlayers);
|
||||
shortcut->setContext(Qt::WidgetWithChildrenShortcut);
|
||||
QObject::connect(shortcut, SIGNAL(activated()),
|
||||
this, SLOT(addRemovePenalty()));
|
||||
treeViewPlayers->installEventFilter(filter);
|
||||
|
||||
// Display a preview of the master word when clicked
|
||||
QObject::connect(labelMasterMove, SIGNAL(clicked()),
|
||||
|
|
|
@ -21,7 +21,9 @@
|
|||
#include <QtGui/QStandardItemModel>
|
||||
#include <QtGui/QSortFilterProxyModel>
|
||||
#include <QtGui/QMenu>
|
||||
#include <QtGui/QShortcut>
|
||||
#include <QtCore/QSettings>
|
||||
#include <QtCore/QSignalMapper>
|
||||
|
||||
#include "arbitration_widget.h"
|
||||
#include "arbit_assignments.h"
|
||||
|
@ -30,7 +32,6 @@
|
|||
#include "validator_factory.h"
|
||||
#include "play_word_mediator.h"
|
||||
#include "custom_popup.h"
|
||||
#include "misc_helpers.h"
|
||||
#include "play_model.h"
|
||||
|
||||
#include "public_game.h"
|
||||
|
@ -115,30 +116,30 @@ ArbitrationWidget::ArbitrationWidget(QWidget *parent,
|
|||
treeViewResults->setColumnWidth(1, 40);
|
||||
treeViewResults->setColumnWidth(2, 70);
|
||||
|
||||
KeyEventFilter *masterFilter = new KeyEventFilter(this, Qt::Key_M, Qt::SHIFT);
|
||||
QObject::connect(masterFilter, SIGNAL(keyPressed(int, int)),
|
||||
QShortcut *shortcut;
|
||||
shortcut = new QShortcut(QString("Shift+M"), treeViewResults);
|
||||
shortcut->setContext(Qt::WidgetWithChildrenShortcut);
|
||||
QObject::connect(shortcut, SIGNAL(activated()),
|
||||
m_assignmentsWidget, SLOT(assignMasterMove()));
|
||||
treeViewResults->installEventFilter(masterFilter);
|
||||
|
||||
KeyEventFilter *selectAllFilter = new KeyEventFilter(this, Qt::Key_A, Qt::SHIFT);
|
||||
QObject::connect(selectAllFilter, SIGNAL(keyPressed(int, int)),
|
||||
shortcut = new QShortcut(QString("Shift+A"), treeViewResults);
|
||||
shortcut->setContext(Qt::WidgetWithChildrenShortcut);
|
||||
QObject::connect(shortcut, SIGNAL(activated()),
|
||||
m_assignmentsWidget, SLOT(selectAllPlayers()));
|
||||
treeViewResults->installEventFilter(selectAllFilter);
|
||||
|
||||
KeyEventFilter *numFilter = new KeyEventFilter(this, Qt::Key_0);
|
||||
numFilter->addKey(Qt::Key_1);
|
||||
numFilter->addKey(Qt::Key_2);
|
||||
numFilter->addKey(Qt::Key_3);
|
||||
numFilter->addKey(Qt::Key_4);
|
||||
numFilter->addKey(Qt::Key_5);
|
||||
numFilter->addKey(Qt::Key_6);
|
||||
numFilter->addKey(Qt::Key_7);
|
||||
numFilter->addKey(Qt::Key_8);
|
||||
numFilter->addKey(Qt::Key_9);
|
||||
numFilter->setIgnoreModifiers();
|
||||
QObject::connect(numFilter, SIGNAL(keyPressed(int, int)),
|
||||
this, SLOT(selectTableNumber(int)));
|
||||
treeViewResults->installEventFilter(numFilter);
|
||||
// React to digits (0 to 9)
|
||||
m_signalMapper = new QSignalMapper(this);
|
||||
for (int i = 0; i <= 9; ++i)
|
||||
{
|
||||
QString numStr = QString("%1").arg(i);
|
||||
shortcut = new QShortcut(numStr, treeViewResults);
|
||||
shortcut->setContext(Qt::WidgetWithChildrenShortcut);
|
||||
QObject::connect(shortcut, SIGNAL(activated()),
|
||||
m_signalMapper, SLOT(map()));
|
||||
m_signalMapper->setMapping(shortcut, numStr);
|
||||
}
|
||||
QObject::connect(m_signalMapper, SIGNAL(mapped(const QString&)),
|
||||
this, SLOT(selectTableNumber(const QString&)));
|
||||
|
||||
// Validate manual rack changes
|
||||
QObject::connect(lineEditRack, SIGNAL(textEdited(const QString&)),
|
||||
|
@ -619,23 +620,10 @@ void ArbitrationWidget::selectAndFocusResult(int iRowNum, bool logical)
|
|||
}
|
||||
|
||||
|
||||
void ArbitrationWidget::selectTableNumber(int key)
|
||||
void ArbitrationWidget::selectTableNumber(const QString &iKey)
|
||||
{
|
||||
QString keyStr = "";
|
||||
if (key == Qt::Key_0) keyStr = "0";
|
||||
else if (key == Qt::Key_1) keyStr = "1";
|
||||
else if (key == Qt::Key_2) keyStr = "2";
|
||||
else if (key == Qt::Key_3) keyStr = "3";
|
||||
else if (key == Qt::Key_4) keyStr = "4";
|
||||
else if (key == Qt::Key_5) keyStr = "5";
|
||||
else if (key == Qt::Key_6) keyStr = "6";
|
||||
else if (key == Qt::Key_7) keyStr = "7";
|
||||
else if (key == Qt::Key_8) keyStr = "8";
|
||||
else if (key == Qt::Key_9) keyStr = "9";
|
||||
ASSERT(keyStr != "", "Unexpected key");
|
||||
|
||||
// Build (and retrieve) the table number
|
||||
QString tableNum = m_keyAccum->addText(keyStr);
|
||||
QString tableNum = m_keyAccum->addText(iKey);
|
||||
|
||||
// Select the player with this table number
|
||||
LOG_DEBUG("Selecting player with table number: " + lfq(tableNum));
|
||||
|
|
|
@ -38,6 +38,7 @@ class QSortFilterProxyModel;
|
|||
class QMenu;
|
||||
class QPoint;
|
||||
class QValidator;
|
||||
class QSignalMapper;
|
||||
|
||||
class ArbitrationWidget: public QWidget, private Ui::ArbitrationWidget
|
||||
{
|
||||
|
@ -74,7 +75,7 @@ private slots:
|
|||
void updateCoordText(const Coord&);
|
||||
void updatePlayModel(const QString&);
|
||||
void populateResultsMenu(QMenu &iMenu, const QPoint &iPoint);
|
||||
void selectTableNumber(int key);
|
||||
void selectTableNumber(const QString &iKey);
|
||||
void endOfTurnRefresh();
|
||||
|
||||
private:
|
||||
|
@ -101,6 +102,9 @@ private:
|
|||
/// Container for the moves manually entered in the interface
|
||||
QVector<Move> m_addedMoves;
|
||||
|
||||
/// Signal mapper used to react to some shortcuts (digits for the table number)
|
||||
QSignalMapper *m_signalMapper;
|
||||
|
||||
/// Accumulator used to build the table number
|
||||
KeyAccumulator *m_keyAccum;
|
||||
|
||||
|
|
|
@ -28,11 +28,11 @@
|
|||
#include <QtGui/QKeyEvent>
|
||||
#include <QtGui/QMenu>
|
||||
#include <QtGui/QAction>
|
||||
#include <QtGui/QShortcut>
|
||||
#include <QtCore/QSettings>
|
||||
|
||||
#include "players_table_helper.h"
|
||||
#include "custom_popup.h"
|
||||
#include "misc_helpers.h"
|
||||
#include "qtcommon.h"
|
||||
#include "debug.h"
|
||||
|
||||
|
@ -158,17 +158,13 @@ void PlayersTableHelper::addPopupRemoveAction()
|
|||
{
|
||||
QAction *removeAction = new QAction(_q("Remove selected player(s)"), this);
|
||||
removeAction->setStatusTip(_q("Remove the selected player(s) from the list"));
|
||||
removeAction->setShortcut(Qt::Key_Delete);
|
||||
removeAction->setShortcut(QKeySequence::Delete);
|
||||
QObject::connect(removeAction, SIGNAL(triggered()),
|
||||
this, SLOT(removeSelectedRows()));
|
||||
// Add the action to the popup menu...
|
||||
addPopupAction(removeAction);
|
||||
|
||||
// Install a custom event filter, to remove the selection when the
|
||||
// "Delete" key is pressed
|
||||
KeyEventFilter *filter = new KeyEventFilter(this, Qt::Key_Delete);
|
||||
m_tablePlayers->installEventFilter(filter);
|
||||
QObject::connect(filter, SIGNAL(keyPressed(int, int)),
|
||||
this, SLOT(removeSelectedRows()));
|
||||
// ... and to the table itself
|
||||
m_tablePlayers->addAction(removeAction);
|
||||
}
|
||||
|
||||
|
||||
|
|
Loading…
Reference in a new issue