summaryrefslogtreecommitdiff
authoralwin <alwin>2005-03-01 07:34:24 (UTC)
committer alwin <alwin>2005-03-01 07:34:24 (UTC)
commite12f0049687c84c24f0b7b737b65df2ed6a500a5 (patch) (side-by-side diff)
treed35007beb337e020e997eec7758fdd88a3f3d56c
parent73faad9d936d5af7a331411a9572fd362907e023 (diff)
downloadopie-e12f0049687c84c24f0b7b737b65df2ed6a500a5.zip
opie-e12f0049687c84c24f0b7b737b65df2ed6a500a5.tar.gz
opie-e12f0049687c84c24f0b7b737b65df2ed6a500a5.tar.bz2
*** empty log message ***
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/applets/keyhelper/keyhelperapplet/applet/KeyHelper.cpp2
-rw-r--r--noncore/applets/keyhelper/keyhelperapplet/config/KeycfgReader.cpp2
2 files changed, 3 insertions, 1 deletions
diff --git a/noncore/applets/keyhelper/keyhelperapplet/applet/KeyHelper.cpp b/noncore/applets/keyhelper/keyhelperapplet/applet/KeyHelper.cpp
index 4afdc1f..4723699 100644
--- a/noncore/applets/keyhelper/keyhelperapplet/applet/KeyHelper.cpp
+++ b/noncore/applets/keyhelper/keyhelperapplet/applet/KeyHelper.cpp
@@ -1,112 +1,114 @@
#include "KeyHelper.h"
#include <opie2/okeyfilter.h>
+#include <opie2/odebug.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)
{
+ odebug << "KeyHelper <<< "<<unicode<<" - "<<keycode<<" - "<<modifiers<<"\n";
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++;
}
}
diff --git a/noncore/applets/keyhelper/keyhelperapplet/config/KeycfgReader.cpp b/noncore/applets/keyhelper/keyhelperapplet/config/KeycfgReader.cpp
index 44b4b2f..14e8a37 100644
--- a/noncore/applets/keyhelper/keyhelperapplet/config/KeycfgReader.cpp
+++ b/noncore/applets/keyhelper/keyhelperapplet/config/KeycfgReader.cpp
@@ -1,70 +1,70 @@
#include "KeycfgReader.h"
KeycfgReader::KeycfgReader()
{
qDebug("KeycfgReader::KeycfgReader()");
}
KeycfgReader::~KeycfgReader()
{
qDebug("KeycfgReader::~KeycfgReader()");
}
bool KeycfgReader::load()
{
QString file;
ConfigEx& cfg = ConfigEx::getInstance("keyhelper");
cfg.setGroup("Global");
file = cfg.readEntry("XmlFile");
if(file.length() == 0 || !QFile::exists(file)){
/* default */
- file = QDir::homeDirPath() + "/Settings/keyhelper.xml";
+ file = QString(getenv( "HOME" )) + QString("/Settings/keyhelper.xml");
}
return(load(file));
}
bool KeycfgReader::load(const QString& path)
{
bool success = false;
KeyNames::reset();
QXmlSimpleReader parser;
KeycfgHandler handler(&parser);
KeycfgErrorHandler errhandler;
QFile file(path);
qWarning("KeycfgReader::load()[%s]", path.latin1());
if(file.exists()){
QXmlInputSource source(file);
handler.setKeyModifiers(m_pModifiers);
handler.setKeyMappings(m_pMappings);
handler.setKeyExtensions(m_pExtensions);
handler.setKeyRepeater(m_pRepeater);
parser.setContentHandler(&handler);
parser.setErrorHandler(&errhandler);
success = parser.parse(source);
file.close();
}
if(success){
m_pModifiers->statistics();
m_pMappings->statistics();
m_pExtensions->statistics();
m_pRepeater->statistics();
} else {
m_pModifiers->reset();
m_pMappings->reset();
m_pExtensions->reset();
m_pRepeater->reset();
}
KeyNames::clearCode();
return(success);
}