summaryrefslogtreecommitdiff
path: root/noncore/applets/keyhelper/keyhelperapplet/applet/KeyHelper.cpp
authoralwin <alwin>2005-02-28 09:40:30 (UTC)
committer alwin <alwin>2005-02-28 09:40:30 (UTC)
commit2b64a84d39eeed5681d0ee5068c7d11a01527750 (patch) (side-by-side diff)
treec8693340dbc5ef5e2f9afa90b690829ddff2c4bd /noncore/applets/keyhelper/keyhelperapplet/applet/KeyHelper.cpp
parent61fa699140c5efbb6ba0bf2a62f7e8fbf62976be (diff)
downloadopie-2b64a84d39eeed5681d0ee5068c7d11a01527750.zip
opie-2b64a84d39eeed5681d0ee5068c7d11a01527750.tar.gz
opie-2b64a84d39eeed5681d0ee5068c7d11a01527750.tar.bz2
other keymapping tool - not working this moment, I have to check it out
- the reason is that the config file is somewhat easier to understand than from zkbapplet and has a nice config tool. Please don't put it into any repositories this moment.
Diffstat (limited to 'noncore/applets/keyhelper/keyhelperapplet/applet/KeyHelper.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/applets/keyhelper/keyhelperapplet/applet/KeyHelper.cpp112
1 files changed, 112 insertions, 0 deletions
diff --git a/noncore/applets/keyhelper/keyhelperapplet/applet/KeyHelper.cpp b/noncore/applets/keyhelper/keyhelperapplet/applet/KeyHelper.cpp
new file mode 100644
index 0000000..4afdc1f
--- a/dev/null
+++ b/noncore/applets/keyhelper/keyhelperapplet/applet/KeyHelper.cpp
@@ -0,0 +1,112 @@
+#include "KeyHelper.h"
+#include <opie2/okeyfilter.h>
+
+KeyHelper::KeyHelper()
+{
+ qDebug("KeyHelper::KeyHelper()");
+ load();
+
+ m_oAction.setKeyModifiers(&m_oModifiers);
+ m_oAction.setKeyMappings(&m_oMappings);
+ m_oAction.setKeyExtensions(&m_oExtensions);
+ m_oAction.setKeyRepeater(&m_oRepeater);
+ m_oExtensions.setKeyModifiers(&m_oModifiers);
+}
+
+KeyHelper::~KeyHelper()
+{
+ unset();
+ qDebug("KeyHelper::~KeyHelper()");
+}
+
+bool KeyHelper::filter(int unicode, int keycode, int modifiers,
+ bool isPress, bool autoRepeat)
+{
+ m_oAction.setAction(unicode, keycode, modifiers,
+ isPress, autoRepeat);
+ return(m_oAction.doAction());
+}
+
+void KeyHelper::unset()
+{
+ Opie::Core::OKeyFilter::inst()->remHandler(this);;
+}
+
+void KeyHelper::set()
+{
+ Opie::Core::OKeyFilter::inst()->addHandler(this);
+ m_oModifiers.resetStates();
+}
+
+void KeyHelper::enable()
+{
+ m_oAction.enable();
+}
+
+void KeyHelper::disable()
+{
+ m_oAction.disable();
+ m_oRepeater.stop();
+}
+
+bool KeyHelper::load(const QString& file)
+{
+ KeycfgReader oReader;
+ oReader.setKeyModifiers(&m_oModifiers);
+ oReader.setKeyMappings(&m_oMappings);
+ oReader.setKeyExtensions(&m_oExtensions);
+ oReader.setKeyRepeater(&m_oRepeater);
+
+ bool success;
+ if(file.length() == 0){
+ success = oReader.load();
+ } else if(file[0] == '/'){
+ success = oReader.load(file);
+ } else {
+ //QString filepath = QString(::getenv("HOME")) + "/Settings/" + file;
+ QString filepath = QDir::homeDirPath() + "/Settings/" + file;
+ success = oReader.load(filepath);
+ }
+ if(success == false){
+ qDebug("config xml load error");
+ setDefault();
+ }
+ return(success);
+}
+
+bool KeyHelper::reload(const QString& file)
+{
+ m_oModifiers.reset();
+ m_oMappings.reset();
+ m_oExtensions.reset();
+ m_oRepeater.reset();
+
+ return(load(file));
+}
+
+void KeyHelper::setDefault()
+{
+ /* default settings */
+ m_oExtensions.assign("switch", Qt::Key_F12,
+ m_oModifiers.getMask("Shift"), KeyNames::getCode("Shift"));
+ m_oExtensions.assign("select", Qt::Key_F11,
+ m_oModifiers.getMask("Shift"), KeyNames::getCode("Shift"));
+}
+
+void KeyHelper::statistics()
+{
+ m_oModifiers.statistics();
+ m_oMappings.statistics();
+ m_oExtensions.statistics();
+ m_oRepeater.statistics();
+}
+
+void KeyHelper::dumpkeymap()
+{
+ const QWSServer::KeyMap* m = QWSServer::keyMap();
+ qWarning("KeyHelper::dumpkeymap()");
+ while(m->key_code != 0){
+ qWarning(" [%04x][%04x][%04x][%04x]", m->key_code, m->unicode, m->shift_unicode, m->ctrl_unicode);
+ m++;
+ }
+}