forked from simulationcraft/simc
-
Notifications
You must be signed in to change notification settings - Fork 0
/
EnumeratedTab.cpp
63 lines (53 loc) · 1.61 KB
/
EnumeratedTab.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
// ==========================================================================
// Dedmonwakeen's Raid DPS/TPS Simulator.
// Send questions to [email protected]
// ==========================================================================
#include "EnumeratedTab.hpp"
#include <QKeyEvent>
SC_enumeratedTabBase::SC_enumeratedTabBase( QWidget* parent ) : QTabWidget( parent )
{
}
void SC_enumeratedTabBase::addIgnoreKeyPressEvent( Qt::Key k, const QList<Qt::KeyboardModifier>& s )
{
QPair<Qt::Key, QList<Qt::KeyboardModifier> > p( k, s );
if ( !ignoreKeys.contains( p ) )
ignoreKeys.push_back( p );
}
bool SC_enumeratedTabBase::removeIgnoreKeyPressEvent( Qt::Key k, const QList<Qt::KeyboardModifier>& s )
{
QPair<Qt::Key, QList<Qt::KeyboardModifier> > p( k, s );
return ignoreKeys.removeAll( p );
}
void SC_enumeratedTabBase::removeAllIgnoreKeyPressEvent()
{
QList<QPair<Qt::Key, QList<Qt::KeyboardModifier> > > emptyList;
ignoreKeys = emptyList;
}
void SC_enumeratedTabBase::keyPressEvent( QKeyEvent* e )
{
int k = e->key();
Qt::KeyboardModifiers m = e->modifiers();
for ( const auto& [ key, modifiers ] : ignoreKeys )
{
if ( key == k )
{
bool passModifiers = true;
for ( const auto& modifier : modifiers )
{
if ( !m.testFlag( modifier ) )
{
passModifiers = false;
break;
}
}
if ( passModifiers )
{
// key combination matches, send key to base classe's base
QWidget::keyPressEvent( e );
return;
}
}
}
// no key match
QTabWidget::keyPressEvent( e );
}