1
/* smplayer, GUI front-end for mplayer.
2
Copyright (C) 2007 Ricardo Villalba <rvm@escomposlinux.org>
4
This program is free software; you can redistribute it and/or modify
5
it under the terms of the GNU General Public License as published by
6
the Free Software Foundation; either version 2 of the License, or
7
(at your option) any later version.
9
This program is distributed in the hope that it will be useful,
10
but WITHOUT ANY WARRANTY; without even the implied warranty of
11
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12
GNU General Public License for more details.
14
You should have received a copy of the GNU General Public License
15
along with this program; if not, write to the Free Software
16
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20
Note: most of the code in this class has been taken from the source
21
code of Qt-3 Designer (propertyeditor.h and propertyeditor.cpp).
22
Copyright (C) 2000 Trolltech AS.
26
#include "keychooser.h"
27
#include <qkeysequence.h>
30
KeyChooser::KeyChooser( QWidget * parent, const char * name )
31
: QLineEdit(parent, name)
34
k1=0; k2=0; k3=0; k4=0;
38
KeyChooser::~KeyChooser() {
41
void KeyChooser::clear() {
43
k1=0; k2=0; k3=0; k4=0;
47
void KeyChooser::keyPressEvent( QKeyEvent * e ) {
49
int nextKey = e->key();
52
nextKey == Qt::Key_Control ||
53
nextKey == Qt::Key_Shift ||
54
nextKey == Qt::Key_Meta ||
55
nextKey == Qt::Key_Alt )
61
nextKey |= translateModifiers( e->state() );
79
QKeySequence ks( k1, k2, k3, k4 );
83
qDebug("KeyChooser::keyPressEvent: num = %d", num);
86
bool KeyChooser::event( QEvent * e ) {
87
if ( e->type() == QEvent::KeyPress ) {
88
QKeyEvent *k = (QKeyEvent *)e;
90
(k->key() == Qt::Key_Up ||
91
k->key() == Qt::Key_Down) )
92
return QLineEdit::event(e); //FALSE;
95
} else if ( (e->type() == QEvent::FocusIn) ||
96
(e->type() == QEvent::MouseButtonPress) ) {
97
mouseEnter = (e->type() == QEvent::MouseButtonPress);
101
// Lets eat accelerators now..
102
if ( e->type() == QEvent::Accel ||
103
e->type() == QEvent::AccelOverride ||
104
e->type() == QEvent::KeyRelease )
108
return QLineEdit::event(e);
111
int KeyChooser::translateModifiers( int state ) {
113
if ( state & Qt::ShiftButton )
115
if ( state & Qt::ControlButton )
117
if ( state & Qt::MetaButton )
119
if ( state & Qt::AltButton )