8 files changed, 24 insertions, 12 deletions
diff --git a/noncore/applets/keyhelper/.cvsignore b/noncore/applets/keyhelper/.cvsignore new file mode 100644 index 0000000..9f2b524 --- a/dev/null +++ b/noncore/applets/keyhelper/.cvsignore | |||
@@ -0,0 +1,5 @@ | |||
1 | Makefile* | ||
2 | moc* | ||
3 | .moc* | ||
4 | .obj | ||
5 | .moc | ||
diff --git a/noncore/applets/keyhelper/keyhelperapplet/.cvsignore b/noncore/applets/keyhelper/keyhelperapplet/.cvsignore new file mode 100644 index 0000000..9f2b524 --- a/dev/null +++ b/noncore/applets/keyhelper/keyhelperapplet/.cvsignore | |||
@@ -0,0 +1,5 @@ | |||
1 | Makefile* | ||
2 | moc* | ||
3 | .moc* | ||
4 | .obj | ||
5 | .moc | ||
diff --git a/noncore/applets/keyhelper/keyhelperapplet/anylnk/AnyLnk.cpp b/noncore/applets/keyhelper/keyhelperapplet/anylnk/AnyLnk.cpp index 3c2298e..fc02862 100644 --- a/noncore/applets/keyhelper/keyhelperapplet/anylnk/AnyLnk.cpp +++ b/noncore/applets/keyhelper/keyhelperapplet/anylnk/AnyLnk.cpp | |||
@@ -1,94 +1,88 @@ | |||
1 | #include "AnyLnk.h" | 1 | #include "AnyLnk.h" |
2 | #include "KHUtil.h" | 2 | #include "KHUtil.h" |
3 | 3 | ||
4 | void AnyLnk::loadPixmap() | 4 | void AnyLnk::loadPixmap() |
5 | { | 5 | { |
6 | if(m_params.count() >= 3){ | 6 | if(m_params.count() >= 3){ |
7 | QString& str = m_params[2]; | 7 | m_pixmap = Opie::Core::OResource::loadPixmap( m_params[2], Opie::Core::OResource::SmallIcon ); |
8 | QImage image = Resource::loadImage(str); | ||
9 | if(image.isNull() == false){ | ||
10 | const QSize& size = AppLnkManager::getIconSize(); | ||
11 | m_pixmap.convertFromImage( | ||
12 | image.smoothScale(size.width(), size.height()) ); | ||
13 | } | ||
14 | } | 8 | } |
15 | } | 9 | } |
16 | 10 | ||
17 | void AnyLnk::parseText() | 11 | void AnyLnk::parseText() |
18 | { | 12 | { |
19 | if(m_params.count() >= 2){ | 13 | if(m_params.count() >= 2){ |
20 | QString& str = m_params[1]; | 14 | QString& str = m_params[1]; |
21 | if(str != QString::null && str.length() > 0){ | 15 | if(str != QString::null && str.length() > 0){ |
22 | replaceKeyword(str); | 16 | replaceKeyword(str); |
23 | replaceDate(str); | 17 | replaceDate(str); |
24 | } | 18 | } |
25 | } | 19 | } |
26 | } | 20 | } |
27 | 21 | ||
28 | void AnyLnk::replaceText(QString& str, const QString& s1, const QString& s2) | 22 | void AnyLnk::replaceText(QString& str, const QString& s1, const QString& s2) |
29 | { | 23 | { |
30 | int index = 0; | 24 | int index = 0; |
31 | int idx; | 25 | int idx; |
32 | int len = s1.length(); | 26 | int len = s1.length(); |
33 | idx = str.find(s1, index); | 27 | idx = str.find(s1, index); |
34 | for(;;){ | 28 | for(;;){ |
35 | idx = str.find(s1, index); | 29 | idx = str.find(s1, index); |
36 | if(idx < 0) break; | 30 | if(idx < 0) break; |
37 | str.replace(idx, len, s2); | 31 | str.replace(idx, len, s2); |
38 | index = idx; | 32 | index = idx; |
39 | } | 33 | } |
40 | } | 34 | } |
41 | 35 | ||
42 | void AnyLnk::replaceDate(QString& str) | 36 | void AnyLnk::replaceDate(QString& str) |
43 | { | 37 | { |
44 | time_t t; | 38 | time_t t; |
45 | struct tm lct; | 39 | struct tm lct; |
46 | char buf[4096]; | 40 | char buf[4096]; |
47 | int nLen; | 41 | int nLen; |
48 | QString group; | 42 | QString group; |
49 | 43 | ||
50 | t = ::time(NULL); | 44 | t = ::time(NULL); |
51 | ::localtime_r(&t, &lct); | 45 | ::localtime_r(&t, &lct); |
52 | 46 | ||
53 | ConfigEx& cfg = ConfigEx::getInstance("keyhelper"); | 47 | ConfigEx& cfg = ConfigEx::getInstance("keyhelper"); |
54 | group = cfg.getGroup(); | 48 | group = cfg.getGroup(); |
55 | cfg.setGroup("Global"); | 49 | cfg.setGroup("Global"); |
56 | QString charset = cfg.readEntry("SystemCharSet", "eucJP"); | 50 | QString charset = cfg.readEntry("SystemCharSet", "eucJP"); |
57 | if(charset.length() == 0){ | 51 | if(charset.length() == 0){ |
58 | charset = "eucJP"; | 52 | charset = "eucJP"; |
59 | } | 53 | } |
60 | cfg.setGroup(group); | 54 | cfg.setGroup(group); |
61 | 55 | ||
62 | QTextCodec* codec = QTextCodec::codecForName(charset); | 56 | QTextCodec* codec = QTextCodec::codecForName(charset); |
63 | if(codec == NULL){ | 57 | if(codec == NULL){ |
64 | codec = QTextCodec::codecForLocale(); | 58 | codec = QTextCodec::codecForLocale(); |
65 | } | 59 | } |
66 | QTextDecoder* decoder = codec->makeDecoder(); | 60 | QTextDecoder* decoder = codec->makeDecoder(); |
67 | QTextEncoder* encoder = codec->makeEncoder(); | 61 | QTextEncoder* encoder = codec->makeEncoder(); |
68 | nLen = str.length(); | 62 | nLen = str.length(); |
69 | QCString localeString = encoder->fromUnicode(str, nLen); | 63 | QCString localeString = encoder->fromUnicode(str, nLen); |
70 | 64 | ||
71 | memset(buf, '\0', sizeof(buf)); | 65 | memset(buf, '\0', sizeof(buf)); |
72 | int n = ::strftime(buf, sizeof(buf), localeString, &lct); | 66 | int n = ::strftime(buf, sizeof(buf), localeString, &lct); |
73 | if(n > 0){ | 67 | if(n > 0){ |
74 | str = decoder->toUnicode(buf, n); | 68 | str = decoder->toUnicode(buf, n); |
75 | } | 69 | } |
76 | delete decoder; | 70 | delete decoder; |
77 | delete encoder; | 71 | delete encoder; |
78 | } | 72 | } |
79 | 73 | ||
80 | void AnyLnk::replaceKeyword(QString& str) | 74 | void AnyLnk::replaceKeyword(QString& str) |
81 | { | 75 | { |
82 | QString txt; | 76 | QString txt; |
83 | /* clipboard text */ | 77 | /* clipboard text */ |
84 | QClipboard* cb = QApplication::clipboard(); | 78 | QClipboard* cb = QApplication::clipboard(); |
85 | if(cb == NULL){ | 79 | if(cb == NULL){ |
86 | txt == ""; | 80 | txt == ""; |
87 | } else { | 81 | } else { |
88 | txt = cb->text(); | 82 | txt = cb->text(); |
89 | } | 83 | } |
90 | replaceText(str, "%clipboard%", txt); | 84 | replaceText(str, "%clipboard%", txt); |
91 | /* current app */ | 85 | /* current app */ |
92 | txt = KHUtil::currentApp(); | 86 | txt = KHUtil::currentApp(); |
93 | replaceText(str, "%currentapp%", txt); | 87 | replaceText(str, "%currentapp%", txt); |
94 | } | 88 | } |
diff --git a/noncore/applets/keyhelper/keyhelperapplet/anylnk/AnyLnk.h b/noncore/applets/keyhelper/keyhelperapplet/anylnk/AnyLnk.h index 9853942..d170e6d 100644 --- a/noncore/applets/keyhelper/keyhelperapplet/anylnk/AnyLnk.h +++ b/noncore/applets/keyhelper/keyhelperapplet/anylnk/AnyLnk.h | |||
@@ -1,45 +1,46 @@ | |||
1 | #ifndef _ANYLNK_H_ | 1 | #ifndef _ANYLNK_H_ |
2 | #define _ANYLNK_H_ | 2 | #define _ANYLNK_H_ |
3 | 3 | ||
4 | #include <time.h> | 4 | #include <time.h> |
5 | 5 | ||
6 | #include <qstring.h> | 6 | #include <qstring.h> |
7 | #include <qstringlist.h> | 7 | #include <qstringlist.h> |
8 | #include <qpixmap.h> | 8 | #include <qpixmap.h> |
9 | #include <qimage.h> | 9 | #include <qimage.h> |
10 | #include <qclipboard.h> | 10 | #include <qclipboard.h> |
11 | #include <qtextcodec.h> | 11 | #include <qtextcodec.h> |
12 | 12 | ||
13 | #include <qpe/qpeapplication.h> | 13 | #include <qpe/qpeapplication.h> |
14 | #include <qpe/resource.h> | 14 | |
15 | #include <opie2/oresource.h> | ||
15 | 16 | ||
16 | #include "AppLnkManager.h" | 17 | #include "AppLnkManager.h" |
17 | #include "ConfigEx.h" | 18 | #include "ConfigEx.h" |
18 | 19 | ||
19 | class AnyLnk | 20 | class AnyLnk |
20 | { | 21 | { |
21 | public: | 22 | public: |
22 | AnyLnk(){} | 23 | AnyLnk(){} |
23 | AnyLnk(const QStringList& params){ | 24 | AnyLnk(const QStringList& params){ |
24 | m_params = params; | 25 | m_params = params; |
25 | loadPixmap(); | 26 | loadPixmap(); |
26 | } | 27 | } |
27 | virtual ~AnyLnk(){ | 28 | virtual ~AnyLnk(){ |
28 | } | 29 | } |
29 | virtual bool isValid() = 0; | 30 | virtual bool isValid() = 0; |
30 | virtual void execute() = 0; | 31 | virtual void execute() = 0; |
31 | virtual QString name() = 0; | 32 | virtual QString name() = 0; |
32 | virtual const QPixmap& pixmap() = 0; | 33 | virtual const QPixmap& pixmap() = 0; |
33 | 34 | ||
34 | protected: | 35 | protected: |
35 | QStringList m_params; | 36 | QStringList m_params; |
36 | QPixmap m_pixmap; | 37 | QPixmap m_pixmap; |
37 | 38 | ||
38 | virtual void loadPixmap(); | 39 | virtual void loadPixmap(); |
39 | virtual void parseText(); | 40 | virtual void parseText(); |
40 | virtual void replaceText(QString& str, const QString& s1, const QString& s2); | 41 | virtual void replaceText(QString& str, const QString& s1, const QString& s2); |
41 | virtual void replaceDate(QString& str); | 42 | virtual void replaceDate(QString& str); |
42 | virtual void replaceKeyword(QString& str); | 43 | virtual void replaceKeyword(QString& str); |
43 | }; | 44 | }; |
44 | 45 | ||
45 | #endif /* _ANYLNK_H_ */ | 46 | #endif /* _ANYLNK_H_ */ |
diff --git a/noncore/applets/keyhelper/keyhelperapplet/anylnk/AppLnkWrapper.cpp b/noncore/applets/keyhelper/keyhelperapplet/anylnk/AppLnkWrapper.cpp index 1c3dbfe..dc6dd77 100644 --- a/noncore/applets/keyhelper/keyhelperapplet/anylnk/AppLnkWrapper.cpp +++ b/noncore/applets/keyhelper/keyhelperapplet/anylnk/AppLnkWrapper.cpp | |||
@@ -1,43 +1,43 @@ | |||
1 | #ifndef _APPLNK_WRAPPER_H_ | 1 | #ifndef _APPLNK_WRAPPER_H_ |
2 | #define _APPLNK_WRAPPER_H_ | 2 | #define _APPLNK_WRAPPER_H_ |
3 | 3 | ||
4 | #include <qpe/qpeapplication.h> | 4 | #include <qpe/qpeapplication.h> |
5 | #include <qpe/applnk.h> | 5 | #include <qpe/applnk.h> |
6 | #include "AnyLnk.h" | 6 | #include "AnyLnk.h" |
7 | 7 | ||
8 | class AppLnkWrapper : public AnyLnk | 8 | class AppLnkWrapper : public AnyLnk |
9 | { | 9 | { |
10 | public: | 10 | public: |
11 | AppLnkWrapper(){} | 11 | AppLnkWrapper(){} |
12 | AppLnkWrapper(const QStringList& params) | 12 | AppLnkWrapper(const QStringList& params) |
13 | : AnyLnk(params) | 13 | : AnyLnk(params) |
14 | { | 14 | { |
15 | m_pLnk = new AppLnk(QPEApplication::qpeDir() | 15 | m_pLnk = new AppLnk(QPEApplication::qpeDir() |
16 | + "apps/" + m_params[0] + ".desktop"); | 16 | + "apps/" + m_params[0] + ".desktop"); |
17 | } | 17 | } |
18 | virtual ~AppLnkWrapper(){ | 18 | virtual ~AppLnkWrapper(){ |
19 | delete m_pLnk; | 19 | delete m_pLnk; |
20 | } | 20 | } |
21 | 21 | ||
22 | virtual bool isValid() { | 22 | virtual bool isValid() { |
23 | return(m_pLnk->isValid()); | 23 | return(m_pLnk->isValid()); |
24 | } | 24 | } |
25 | virtual void execute(){ | 25 | virtual void execute(){ |
26 | parseText(); | 26 | parseText(); |
27 | m_pLnk->execute(m_params[1]); | 27 | m_pLnk->execute(m_params[1]); |
28 | } | 28 | } |
29 | virtual QString name() { | 29 | virtual QString name() { |
30 | return(m_pLnk->name()); | 30 | return(m_pLnk->name()); |
31 | } | 31 | } |
32 | virtual const QPixmap& pixmap(){ | 32 | virtual const QPixmap& pixmap(){ |
33 | if(m_pixmap.isNull()){ | 33 | if(m_pixmap.isNull()){ |
34 | return(m_pLnk->pixmap()); | 34 | return(m_pLnk->pixmap()); |
35 | } else { | 35 | } else { |
36 | return(m_pixmap); | 36 | return(m_pixmap); |
37 | } | 37 | } |
38 | } | 38 | } |
39 | protected: | 39 | protected: |
40 | AppLnk* m_pLnk; | 40 | AppLnk* m_pLnk; |
41 | }; | 41 | }; |
42 | 42 | ||
43 | #endif /* _APPLNK_WRAPPER_H_ */ \ No newline at end of file | 43 | #endif /* _APPLNK_WRAPPER_H_ */ |
diff --git a/noncore/applets/keyhelper/keyhelperapplet/applet/KeyHelperWidget.cpp b/noncore/applets/keyhelper/keyhelperapplet/applet/KeyHelperWidget.cpp index 7beb511..9fac51b 100644 --- a/noncore/applets/keyhelper/keyhelperapplet/applet/KeyHelperWidget.cpp +++ b/noncore/applets/keyhelper/keyhelperapplet/applet/KeyHelperWidget.cpp | |||
@@ -1,107 +1,107 @@ | |||
1 | #include "KeyHelperWidget.h" | 1 | #include "KeyHelperWidget.h" |
2 | #include "QSafeDataStream.h" | 2 | #include "QSafeDataStream.h" |
3 | #include "KHUtil.h" | 3 | #include "KHUtil.h" |
4 | 4 | ||
5 | QWidget* g_Widget = NULL; | 5 | QWidget* g_Widget = NULL; |
6 | int g_level = 0; | 6 | int g_level = 0; |
7 | 7 | ||
8 | static const char* _version_ = "1.2.2"; | 8 | static const char* _version_ = "1.2.2"; |
9 | 9 | ||
10 | KeyHelperWidget::KeyHelperWidget(QWidget* parent, const char* name) | 10 | KeyHelperWidget::KeyHelperWidget(QWidget* parent, const char* name) |
11 | : QLabel(parent, name),disabled(Resource::loadPixmap("zkb-disabled")) | 11 | : QLabel(parent, name),disabled(Opie::Core::OResource::loadPixmap("zkb-disabled")) |
12 | { | 12 | { |
13 | qDebug("KeyHelperWidget::KeyHelperWidget()"); | 13 | qDebug("KeyHelperWidget::KeyHelperWidget()"); |
14 | g_Widget = this; | 14 | g_Widget = this; |
15 | m_defHandler = NULL; | 15 | m_defHandler = NULL; |
16 | //m_reset = false; | 16 | //m_reset = false; |
17 | m_reset = true; | 17 | m_reset = true; |
18 | m_useFilter = false; | 18 | m_useFilter = false; |
19 | m_pHelper = NULL; | 19 | m_pHelper = NULL; |
20 | m_status = false; | 20 | m_status = false; |
21 | 21 | ||
22 | //unset(); | 22 | //unset(); |
23 | initDebugLevel(); | 23 | initDebugLevel(); |
24 | 24 | ||
25 | m_pHelper = new KeyHelper(); | 25 | m_pHelper = new KeyHelper(); |
26 | 26 | ||
27 | //qApp->installEventFilter(this); | 27 | //qApp->installEventFilter(this); |
28 | 28 | ||
29 | connect(qwsServer, | 29 | connect(qwsServer, |
30 | SIGNAL(windowEvent(QWSWindow*, QWSServer::WindowEvent)), | 30 | SIGNAL(windowEvent(QWSWindow*, QWSServer::WindowEvent)), |
31 | this, | 31 | this, |
32 | SLOT(windowEvent(QWSWindow*, QWSServer::WindowEvent))); | 32 | SLOT(windowEvent(QWSWindow*, QWSServer::WindowEvent))); |
33 | 33 | ||
34 | m_pChannel = new QCopChannel("QPE/KeyHelper", this); | 34 | m_pChannel = new QCopChannel("QPE/KeyHelper", this); |
35 | connect(m_pChannel, SIGNAL(received(const QCString&, const QByteArray&)), | 35 | connect(m_pChannel, SIGNAL(received(const QCString&, const QByteArray&)), |
36 | this, SLOT(receiveMessage(const QCString&, const QByteArray&))); | 36 | this, SLOT(receiveMessage(const QCString&, const QByteArray&))); |
37 | m_pSysChannel = new QCopChannel("QPE/System", this); | 37 | m_pSysChannel = new QCopChannel("QPE/System", this); |
38 | connect(m_pSysChannel, SIGNAL(received(const QCString&, const QByteArray&)), | 38 | connect(m_pSysChannel, SIGNAL(received(const QCString&, const QByteArray&)), |
39 | this, SLOT(sysMessage(const QCString&, const QByteArray&))); | 39 | this, SLOT(sysMessage(const QCString&, const QByteArray&))); |
40 | 40 | ||
41 | //AppLnkManager::init(); | 41 | //AppLnkManager::init(); |
42 | setFixedWidth ( AppLnk::smallIconSize() ); | 42 | setFixedWidth ( AppLnk::smallIconSize() ); |
43 | setFixedHeight ( AppLnk::smallIconSize() ); | 43 | setFixedHeight ( AppLnk::smallIconSize() ); |
44 | setPixmap(disabled); | 44 | setPixmap(disabled); |
45 | init(); | 45 | init(); |
46 | } | 46 | } |
47 | 47 | ||
48 | KeyHelperWidget::~KeyHelperWidget() | 48 | KeyHelperWidget::~KeyHelperWidget() |
49 | { | 49 | { |
50 | qDebug("KeyHelperWidget::~KeyHelperWidget()"); | 50 | qDebug("KeyHelperWidget::~KeyHelperWidget()"); |
51 | disconnect(qwsServer, | 51 | disconnect(qwsServer, |
52 | SIGNAL(windowEvent(QWSWindow*, QWSServer::WindowEvent)), | 52 | SIGNAL(windowEvent(QWSWindow*, QWSServer::WindowEvent)), |
53 | this, | 53 | this, |
54 | SLOT(windowEvent(QWSWindow*, QWSServer::WindowEvent))); | 54 | SLOT(windowEvent(QWSWindow*, QWSServer::WindowEvent))); |
55 | disconnect(m_pChannel, SIGNAL(received(const QCString&, const QByteArray&)), | 55 | disconnect(m_pChannel, SIGNAL(received(const QCString&, const QByteArray&)), |
56 | this, SLOT(receiveMessage(const QCString&, const QByteArray&))); | 56 | this, SLOT(receiveMessage(const QCString&, const QByteArray&))); |
57 | unset(); | 57 | unset(); |
58 | if (m_pHelper) delete m_pHelper; | 58 | if (m_pHelper) delete m_pHelper; |
59 | if (m_pChannel) delete m_pChannel; | 59 | if (m_pChannel) delete m_pChannel; |
60 | if (m_pSysChannel) delete m_pSysChannel; | 60 | if (m_pSysChannel) delete m_pSysChannel; |
61 | m_pHelper = NULL; | 61 | m_pHelper = NULL; |
62 | setDebugLevel(0); | 62 | setDebugLevel(0); |
63 | } | 63 | } |
64 | 64 | ||
65 | void KeyHelperWidget::mouseReleaseEvent(QMouseEvent*) | 65 | void KeyHelperWidget::mouseReleaseEvent(QMouseEvent*) |
66 | { | 66 | { |
67 | ConfigEx::getInstance("keyhelper").setConfig("keyhelper"); | 67 | ConfigEx::getInstance("keyhelper").setConfig("keyhelper"); |
68 | } | 68 | } |
69 | 69 | ||
70 | void KeyHelperWidget::receiveMessage( | 70 | void KeyHelperWidget::receiveMessage( |
71 | const QCString& msg, const QByteArray& data) | 71 | const QCString& msg, const QByteArray& data) |
72 | { | 72 | { |
73 | if(m_pHelper == NULL){ | 73 | if(m_pHelper == NULL){ |
74 | return; | 74 | return; |
75 | } | 75 | } |
76 | QSafeDataStream stream(data, IO_ReadOnly); | 76 | QSafeDataStream stream(data, IO_ReadOnly); |
77 | if(msg == "event(int,int,int,int,int)"){ | 77 | if(msg == "event(int,int,int,int,int)"){ |
78 | int unicode; | 78 | int unicode; |
79 | int keycode; | 79 | int keycode; |
80 | int modifiers; | 80 | int modifiers; |
81 | int isPress; | 81 | int isPress; |
82 | int autoRepeat; | 82 | int autoRepeat; |
83 | stream >> unicode >> keycode >> modifiers >> isPress >> autoRepeat; | 83 | stream >> unicode >> keycode >> modifiers >> isPress >> autoRepeat; |
84 | doEvent(unicode, keycode, modifiers, isPress, autoRepeat); | 84 | doEvent(unicode, keycode, modifiers, isPress, autoRepeat); |
85 | } else if(msg == "event(QString,int)"){ | 85 | } else if(msg == "event(QString,int)"){ |
86 | QString key; | 86 | QString key; |
87 | int isPress; | 87 | int isPress; |
88 | stream >> key >> isPress; | 88 | stream >> key >> isPress; |
89 | doEvent(key, isPress); | 89 | doEvent(key, isPress); |
90 | } else if(msg == "enable()"){ | 90 | } else if(msg == "enable()"){ |
91 | enable(); | 91 | enable(); |
92 | } else if(msg == "disable()"){ | 92 | } else if(msg == "disable()"){ |
93 | disable(); | 93 | disable(); |
94 | } else if(msg == "pause()"){ | 94 | } else if(msg == "pause()"){ |
95 | pause(); | 95 | pause(); |
96 | } else if(msg == "restart()"){ | 96 | } else if(msg == "restart()"){ |
97 | restart(); | 97 | restart(); |
98 | } else if(msg == "reload()"){ | 98 | } else if(msg == "reload()"){ |
99 | m_xmlfile = QString::null; | 99 | m_xmlfile = QString::null; |
100 | doReload(); | 100 | doReload(); |
101 | } else if(msg == "reload(QString)"){ | 101 | } else if(msg == "reload(QString)"){ |
102 | stream >> m_xmlfile; | 102 | stream >> m_xmlfile; |
103 | doReload(false); | 103 | doReload(false); |
104 | } else if(msg == "version()"){ | 104 | } else if(msg == "version()"){ |
105 | version(); | 105 | version(); |
106 | } else if(msg == "repeater(int)"){ | 106 | } else if(msg == "repeater(int)"){ |
107 | int mode; | 107 | int mode; |
@@ -201,193 +201,193 @@ void KeyHelperWidget::doEvent(const QString& key, int isPress) | |||
201 | if(pos > 0){ | 201 | if(pos > 0){ |
202 | modifiers |= Qt::AltButton; | 202 | modifiers |= Qt::AltButton; |
203 | keyname.remove(pos, 4); | 203 | keyname.remove(pos, 4); |
204 | } | 204 | } |
205 | if(keyname.length() > 1){ | 205 | if(keyname.length() > 1){ |
206 | unicode = 0xffff; | 206 | unicode = 0xffff; |
207 | keycode = KeyNames::getCode(keyname); | 207 | keycode = KeyNames::getCode(keyname); |
208 | /* get unicode */ | 208 | /* get unicode */ |
209 | const QWSServer::KeyMap* m; | 209 | const QWSServer::KeyMap* m; |
210 | for(m=QWSServer::keyMap(); m->key_code != 0; m++){ | 210 | for(m=QWSServer::keyMap(); m->key_code != 0; m++){ |
211 | if(m->key_code == keycode){ | 211 | if(m->key_code == keycode){ |
212 | if(modifiers & Qt::ControlButton){ | 212 | if(modifiers & Qt::ControlButton){ |
213 | unicode = m->ctrl_unicode; | 213 | unicode = m->ctrl_unicode; |
214 | } else if(modifiers & Qt::ShiftButton){ | 214 | } else if(modifiers & Qt::ShiftButton){ |
215 | unicode = m->shift_unicode; | 215 | unicode = m->shift_unicode; |
216 | } else { | 216 | } else { |
217 | unicode = m->unicode; | 217 | unicode = m->unicode; |
218 | } | 218 | } |
219 | break; | 219 | break; |
220 | } | 220 | } |
221 | } | 221 | } |
222 | } else { | 222 | } else { |
223 | const QWSServer::KeyMap* m; | 223 | const QWSServer::KeyMap* m; |
224 | keycode = 0; | 224 | keycode = 0; |
225 | unicode = keyname[0].unicode(); | 225 | unicode = keyname[0].unicode(); |
226 | /* check unicode */ | 226 | /* check unicode */ |
227 | for(m=QWSServer::keyMap(); keycode == 0 && m->key_code != 0; m++){ | 227 | for(m=QWSServer::keyMap(); keycode == 0 && m->key_code != 0; m++){ |
228 | if(m->unicode == unicode){ | 228 | if(m->unicode == unicode){ |
229 | keycode = m->key_code; | 229 | keycode = m->key_code; |
230 | break; | 230 | break; |
231 | } | 231 | } |
232 | } | 232 | } |
233 | /* check shift_unicode */ | 233 | /* check shift_unicode */ |
234 | for(m=QWSServer::keyMap(); keycode == 0 && m->key_code != 0; m++){ | 234 | for(m=QWSServer::keyMap(); keycode == 0 && m->key_code != 0; m++){ |
235 | if(m->shift_unicode == unicode){ | 235 | if(m->shift_unicode == unicode){ |
236 | keycode = m->key_code; | 236 | keycode = m->key_code; |
237 | modifiers |= Qt::ShiftButton; | 237 | modifiers |= Qt::ShiftButton; |
238 | break; | 238 | break; |
239 | } | 239 | } |
240 | } | 240 | } |
241 | /* check ctrl_unicode */ | 241 | /* check ctrl_unicode */ |
242 | for(m=QWSServer::keyMap(); keycode == 0 && m->key_code != 0; m++){ | 242 | for(m=QWSServer::keyMap(); keycode == 0 && m->key_code != 0; m++){ |
243 | if(m->ctrl_unicode == unicode){ | 243 | if(m->ctrl_unicode == unicode){ |
244 | keycode = m->key_code; | 244 | keycode = m->key_code; |
245 | modifiers |= Qt::ControlButton; | 245 | modifiers |= Qt::ControlButton; |
246 | break; | 246 | break; |
247 | } | 247 | } |
248 | } | 248 | } |
249 | } | 249 | } |
250 | doEvent(unicode, keycode, modifiers, isPress, 0); | 250 | doEvent(unicode, keycode, modifiers, isPress, 0); |
251 | } | 251 | } |
252 | 252 | ||
253 | void KeyHelperWidget::sysMessage( | 253 | void KeyHelperWidget::sysMessage( |
254 | const QCString& msg, const QByteArray& data) | 254 | const QCString& msg, const QByteArray& data) |
255 | { | 255 | { |
256 | QSafeDataStream stream(data, IO_ReadOnly); | 256 | QSafeDataStream stream(data, IO_ReadOnly); |
257 | if(msg == "linkChanged(QString)"){ | 257 | if(msg == "linkChanged(QString)"){ |
258 | ConfigEx& cfg = ConfigEx::getInstance("keyhelper"); | 258 | ConfigEx& cfg = ConfigEx::getInstance("keyhelper"); |
259 | QString oldgroup = cfg.getGroup(); | 259 | QString oldgroup = cfg.getGroup(); |
260 | if(cfg.readNumEntry("DetectLinkChange", 1) == 1){ | 260 | if(cfg.readNumEntry("DetectLinkChange", 1) == 1){ |
261 | AppLnkManager::init(true); | 261 | AppLnkManager::init(true); |
262 | reload(); | 262 | reload(); |
263 | } | 263 | } |
264 | cfg.setGroup(oldgroup); | 264 | cfg.setGroup(oldgroup); |
265 | } | 265 | } |
266 | } | 266 | } |
267 | 267 | ||
268 | void MsgHandler(QtMsgType type, const char* msg) | 268 | void MsgHandler(QtMsgType type, const char* msg) |
269 | { | 269 | { |
270 | switch(type){ | 270 | switch(type){ |
271 | case QtDebugMsg: | 271 | case QtDebugMsg: |
272 | if(g_level >= 2){ | 272 | if(g_level >= 2){ |
273 | syslog(LOG_LOCAL5|LOG_DEBUG, | 273 | syslog(LOG_LOCAL5|LOG_DEBUG, |
274 | "<2>%s", msg); | 274 | "<2>%s", msg); |
275 | } | 275 | } |
276 | break; | 276 | break; |
277 | case QtWarningMsg: | 277 | case QtWarningMsg: |
278 | if(g_level >= 1){ | 278 | if(g_level >= 1){ |
279 | syslog(LOG_LOCAL5|LOG_DEBUG, | 279 | syslog(LOG_LOCAL5|LOG_DEBUG, |
280 | "<1>%s", msg); | 280 | "<1>%s", msg); |
281 | } | 281 | } |
282 | break; | 282 | break; |
283 | default: | 283 | default: |
284 | break; | 284 | break; |
285 | } | 285 | } |
286 | } | 286 | } |
287 | 287 | ||
288 | void KeyHelperWidget::initDebugLevel() | 288 | void KeyHelperWidget::initDebugLevel() |
289 | { | 289 | { |
290 | ConfigEx& cfg = ConfigEx::getInstance("keyhelper"); | 290 | ConfigEx& cfg = ConfigEx::getInstance("keyhelper"); |
291 | cfg.setGroup("Global"); | 291 | cfg.setGroup("Global"); |
292 | 292 | ||
293 | int level = cfg.readNumEntry("DebugLevel", 0); | 293 | int level = cfg.readNumEntry("DebugLevel", 0); |
294 | setDebugLevel(level); | 294 | setDebugLevel(level); |
295 | } | 295 | } |
296 | 296 | ||
297 | void KeyHelperWidget::setDebugLevel(int level) | 297 | void KeyHelperWidget::setDebugLevel(int /*level*/) |
298 | { | 298 | { |
299 | #ifdef QT_QWS_EBX | 299 | #ifdef QT_QWS_EBX |
300 | static bool noDebug = true; | 300 | static bool noDebug = true; |
301 | g_level = level; | 301 | g_level = level; |
302 | if(g_level > 0){ | 302 | if(g_level > 0){ |
303 | if(noDebug){ | 303 | if(noDebug){ |
304 | m_defHandler = qInstallMsgHandler(MsgHandler); | 304 | m_defHandler = qInstallMsgHandler(MsgHandler); |
305 | noDebug = false; | 305 | noDebug = false; |
306 | } | 306 | } |
307 | } else { | 307 | } else { |
308 | qInstallMsgHandler(m_defHandler); | 308 | qInstallMsgHandler(m_defHandler); |
309 | noDebug = true; | 309 | noDebug = true; |
310 | } | 310 | } |
311 | #endif | 311 | #endif |
312 | } | 312 | } |
313 | 313 | ||
314 | void KeyHelperWidget::enable() | 314 | void KeyHelperWidget::enable() |
315 | { | 315 | { |
316 | m_enable = true; | 316 | m_enable = true; |
317 | m_pHelper->enable(); | 317 | m_pHelper->enable(); |
318 | //set(); | 318 | //set(); |
319 | QTimer::singleShot(0, this, SLOT(set())); | 319 | QTimer::singleShot(0, this, SLOT(set())); |
320 | } | 320 | } |
321 | 321 | ||
322 | void KeyHelperWidget::disable() | 322 | void KeyHelperWidget::disable() |
323 | { | 323 | { |
324 | m_enable = false; | 324 | m_enable = false; |
325 | m_pHelper->disable(); | 325 | m_pHelper->disable(); |
326 | unset(); | 326 | unset(); |
327 | } | 327 | } |
328 | 328 | ||
329 | void KeyHelperWidget::pause() | 329 | void KeyHelperWidget::pause() |
330 | { | 330 | { |
331 | m_saved = m_enable; | 331 | m_saved = m_enable; |
332 | disable(); | 332 | disable(); |
333 | } | 333 | } |
334 | 334 | ||
335 | void KeyHelperWidget::restart() | 335 | void KeyHelperWidget::restart() |
336 | { | 336 | { |
337 | if(m_saved){ | 337 | if(m_saved){ |
338 | enable(); | 338 | enable(); |
339 | } | 339 | } |
340 | } | 340 | } |
341 | 341 | ||
342 | void KeyHelperWidget::reload() | 342 | void KeyHelperWidget::reload() |
343 | { | 343 | { |
344 | disable(); | 344 | disable(); |
345 | ConfigEx& cfg = ConfigEx::getInstance("keyhelper"); | 345 | ConfigEx& cfg = ConfigEx::getInstance("keyhelper"); |
346 | cfg.reload(); | 346 | cfg.reload(); |
347 | if(m_pHelper->reload(m_xmlfile) == false){ | 347 | if(m_pHelper->reload(m_xmlfile) == false){ |
348 | if(m_status){ | 348 | if(m_status){ |
349 | Global::statusMessage("KeyHelper: Load Error"); | 349 | Global::statusMessage("KeyHelper: Load Error"); |
350 | } | 350 | } |
351 | } | 351 | } |
352 | init(); | 352 | init(); |
353 | if(m_status){ | 353 | if(m_status){ |
354 | QCopEnvelope e("QPE/System", "notBusy(QString)"); | 354 | QCopEnvelope e("QPE/System", "notBusy(QString)"); |
355 | const QString app = KHUtil::currentApp(); | 355 | const QString app = KHUtil::currentApp(); |
356 | e << app; | 356 | e << app; |
357 | m_status = false; | 357 | m_status = false; |
358 | } | 358 | } |
359 | } | 359 | } |
360 | 360 | ||
361 | void KeyHelperWidget::version() | 361 | void KeyHelperWidget::version() |
362 | { | 362 | { |
363 | QString ver = "KeyHelper "; | 363 | QString ver = "KeyHelper "; |
364 | ver.append(_version_); | 364 | ver.append(_version_); |
365 | Global::statusMessage(ver); | 365 | Global::statusMessage(ver); |
366 | } | 366 | } |
367 | 367 | ||
368 | void KeyHelperWidget::init() | 368 | void KeyHelperWidget::init() |
369 | { | 369 | { |
370 | AppLnkManager::init(); | 370 | AppLnkManager::init(); |
371 | #if 0 | 371 | #if 0 |
372 | if(m_pHelper == NULL){ | 372 | if(m_pHelper == NULL){ |
373 | m_pHelper = new KeyHelper(); | 373 | m_pHelper = new KeyHelper(); |
374 | } | 374 | } |
375 | #endif | 375 | #endif |
376 | loadUseFilterApps(); | 376 | loadUseFilterApps(); |
377 | enable(); | 377 | enable(); |
378 | } | 378 | } |
379 | 379 | ||
380 | void KeyHelperWidget::set() | 380 | void KeyHelperWidget::set() |
381 | { | 381 | { |
382 | if(m_pHelper != NULL && m_enable == true && m_useFilter == false){ | 382 | if(m_pHelper != NULL && m_enable == true && m_useFilter == false){ |
383 | qWarning("KeyHelperWidget::set()"); | 383 | qWarning("KeyHelperWidget::set()"); |
384 | m_pHelper->set(); | 384 | m_pHelper->set(); |
385 | } | 385 | } |
386 | } | 386 | } |
387 | 387 | ||
388 | void KeyHelperWidget::unset() | 388 | void KeyHelperWidget::unset() |
389 | { | 389 | { |
390 | m_pHelper->unset(); | 390 | m_pHelper->unset(); |
391 | } | 391 | } |
392 | 392 | ||
393 | void KeyHelperWidget::loadUseFilterApps() | 393 | void KeyHelperWidget::loadUseFilterApps() |
diff --git a/noncore/applets/keyhelper/keyhelperapplet/applet/KeyHelperWidget.h b/noncore/applets/keyhelper/keyhelperapplet/applet/KeyHelperWidget.h index 4798c5c..0901081 100644 --- a/noncore/applets/keyhelper/keyhelperapplet/applet/KeyHelperWidget.h +++ b/noncore/applets/keyhelper/keyhelperapplet/applet/KeyHelperWidget.h | |||
@@ -1,75 +1,75 @@ | |||
1 | #ifndef _KEY_HELPER_WIDGET_H_ | 1 | #ifndef _KEY_HELPER_WIDGET_H_ |
2 | #define _KEY_HELPER_WIDGET_H_ | 2 | #define _KEY_HELPER_WIDGET_H_ |
3 | 3 | ||
4 | #include <qwidget.h> | 4 | #include <qwidget.h> |
5 | #include <qlabel.h> | 5 | #include <qlabel.h> |
6 | #include <qpixmap.h> | 6 | #include <qpixmap.h> |
7 | #include <qtimer.h> | 7 | #include <qtimer.h> |
8 | #include <qaccel.h> | 8 | #include <qaccel.h> |
9 | #include <opie2/otaskbarapplet.h> | 9 | #include <opie2/otaskbarapplet.h> |
10 | #include <opie2/okeyfilter.h> | 10 | #include <opie2/okeyfilter.h> |
11 | #include <opie2/oresource.h> | ||
11 | 12 | ||
12 | #include <qpe/qcopenvelope_qws.h> | 13 | #include <qpe/qcopenvelope_qws.h> |
13 | #include <qpe/qpeapplication.h> | 14 | #include <qpe/qpeapplication.h> |
14 | #include <qpe/global.h> | 15 | #include <qpe/global.h> |
15 | #include <qpe/resource.h> | ||
16 | #include "KeyHelper.h" | 16 | #include "KeyHelper.h" |
17 | #include "AppLnkManager.h" | 17 | #include "AppLnkManager.h" |
18 | #include "ConfigEx.h" | 18 | #include "ConfigEx.h" |
19 | 19 | ||
20 | #include <syslog.h> | 20 | #include <syslog.h> |
21 | 21 | ||
22 | Q_EXPORT void MsgHandler(QtMsgType type, const char* msg); | 22 | Q_EXPORT void MsgHandler(QtMsgType type, const char* msg); |
23 | 23 | ||
24 | class KeyHelperWidget : public QLabel | 24 | class KeyHelperWidget : public QLabel |
25 | { | 25 | { |
26 | Q_OBJECT | 26 | Q_OBJECT |
27 | public: | 27 | public: |
28 | KeyHelperWidget(QWidget* parent = 0, const char* name=0); | 28 | KeyHelperWidget(QWidget* parent = 0, const char* name=0); |
29 | ~KeyHelperWidget(); | 29 | ~KeyHelperWidget(); |
30 | static int position(); | 30 | static int position(); |
31 | 31 | ||
32 | virtual bool eventFilter(QObject* o, QEvent* e); | 32 | virtual bool eventFilter(QObject* o, QEvent* e); |
33 | 33 | ||
34 | public slots: | 34 | public slots: |
35 | //void windowEvent(QWSWindow* w, QWSServer::WindowEvent e); | 35 | //void windowEvent(QWSWindow* w, QWSServer::WindowEvent e); |
36 | protected: | 36 | protected: |
37 | QCopChannel* m_pChannel; | 37 | QCopChannel* m_pChannel; |
38 | QCopChannel* m_pSysChannel; | 38 | QCopChannel* m_pSysChannel; |
39 | QPixmap disabled; | 39 | QPixmap disabled; |
40 | 40 | ||
41 | protected slots: | 41 | protected slots: |
42 | void receiveMessage(const QCString& msg, const QByteArray& data); | 42 | void receiveMessage(const QCString& msg, const QByteArray& data); |
43 | void sysMessage(const QCString& msg, const QByteArray& data); | 43 | void sysMessage(const QCString& msg, const QByteArray& data); |
44 | void reload(); | 44 | void reload(); |
45 | void set(); | 45 | void set(); |
46 | void unset(); | 46 | void unset(); |
47 | void init(); | 47 | void init(); |
48 | void mouseReleaseEvent(QMouseEvent*); | 48 | void mouseReleaseEvent(QMouseEvent*); |
49 | 49 | ||
50 | private: | 50 | private: |
51 | void loadUseFilterApps(); | 51 | void loadUseFilterApps(); |
52 | void enable(); | 52 | void enable(); |
53 | void disable(); | 53 | void disable(); |
54 | void pause(); | 54 | void pause(); |
55 | void restart(); | 55 | void restart(); |
56 | void version(); | 56 | void version(); |
57 | void setDebugLevel(int level); | 57 | void setDebugLevel(int level); |
58 | void initDebugLevel(); | 58 | void initDebugLevel(); |
59 | 59 | ||
60 | bool m_reset; | 60 | bool m_reset; |
61 | bool m_useFilter; | 61 | bool m_useFilter; |
62 | bool m_status; | 62 | bool m_status; |
63 | QString m_xmlfile; | 63 | QString m_xmlfile; |
64 | msg_handler m_defHandler; | 64 | msg_handler m_defHandler; |
65 | bool m_enable; | 65 | bool m_enable; |
66 | bool m_saved; | 66 | bool m_saved; |
67 | QStringList m_apps; | 67 | QStringList m_apps; |
68 | KeyHelper* m_pHelper; | 68 | KeyHelper* m_pHelper; |
69 | private slots: | 69 | private slots: |
70 | void doReload(bool showstatus=true); | 70 | void doReload(bool showstatus=true); |
71 | void doEvent(int,int,int,int,int); | 71 | void doEvent(int,int,int,int,int); |
72 | void doEvent(const QString&, int); | 72 | void doEvent(const QString&, int); |
73 | }; | 73 | }; |
74 | 74 | ||
75 | #endif /* _KEY_HELPER_WIDGET_H_ */ | 75 | #endif /* _KEY_HELPER_WIDGET_H_ */ |
diff --git a/noncore/applets/keyhelper/keyhelperconf/.cvsignore b/noncore/applets/keyhelper/keyhelperconf/.cvsignore new file mode 100644 index 0000000..f4d9255 --- a/dev/null +++ b/noncore/applets/keyhelper/keyhelperconf/.cvsignore | |||
@@ -0,0 +1,7 @@ | |||
1 | Makefile* | ||
2 | moc* | ||
3 | .moc* | ||
4 | .obj | ||
5 | .moc | ||
6 | KHCWidgetBase.cpp | ||
7 | KHCWidgetBase.h \ No newline at end of file | ||