From c90c389a8a8d9d8661e9772ec4144c5cf2039f23 Mon Sep 17 00:00:00 2001 From: toma Date: Wed, 25 Nov 2009 17:56:58 +0000 Subject: Copy the KDE 3.5 branch to branches/trinity for new KDE 3.5 features. BUG:215923 git-svn-id: svn://anonsvn.kde.org/home/kde/branches/trinity/kdegames@1054174 283d02a7-25f6-0310-bc7c-ecb5cbfe19da --- libksirtet/lib/keys.cpp | 104 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 104 insertions(+) create mode 100644 libksirtet/lib/keys.cpp (limited to 'libksirtet/lib/keys.cpp') diff --git a/libksirtet/lib/keys.cpp b/libksirtet/lib/keys.cpp new file mode 100644 index 00000000..879f0bfa --- /dev/null +++ b/libksirtet/lib/keys.cpp @@ -0,0 +1,104 @@ +#include "keys.h" +#include "keys.moc" + +#include +#include +#include + + +KeyData::KeyData(uint maxNb, uint nbActions, const ActionData *data, + QObject *parent) + : QObject(parent), _maxNb(maxNb) +{ + _data.duplicate(data, nbActions); + + for (uint n=0; nsetEnabled(false); + if ( slot==0 ) { + SpecialData data; + data.enabled = false; + data.pressed = new QSignal(this); + data.pressed->connect(receiver, _data[k].slot); + data.released = new QSignal(this); + data.released->connect(receiver, _data[k].slotRelease); + _specActions[a] = data; + } + } + _cols[index]->readShortcutSettings(group()); +} + +void KeyData::setEnabled(uint index, bool enabled) +{ + for (uint k=0; k<_cols[index]->count(); k++) { + QMap::Iterator it = + _specActions.find(_cols[index]->action(k)); + if ( it==_specActions.end() ) + _cols[index]->action(k)->setEnabled(enabled); + else (*it).enabled = enabled; + } +} + +void KeyData::addKeys(KKeyDialog &d) +{ + for (uint i=0; i<_cols.size(); i++) + d.insert(_cols[i], i18n("Shortcuts for player #%1/%2").arg(i+1) + .arg(_cols.size())); +} + +void KeyData::save() +{ + for (uint i=0; i<_cols.size(); i++) + _cols[i]->writeShortcutSettings(group()); +} + +void KeyData::keyEvent(QKeyEvent *e, bool pressed) +{ + if ( e->isAutoRepeat() ) return; + + KKey key(e); + QMap::Iterator it = _specActions.begin(); + for(; it!=_specActions.end(); ++it) { + if ( !it.data().enabled ) continue; + if ( !it.key()->shortcut().contains(key) ) continue; + if (pressed) it.data().pressed->activate(); + else it.data().released->activate(); + } + e->ignore(); +} -- cgit v1.2.1