author | mickeyl <mickeyl> | 2004-03-01 14:44:21 (UTC) |
---|---|---|
committer | mickeyl <mickeyl> | 2004-03-01 14:44:21 (UTC) |
commit | 7a819ad4bc09aa88521044bfbb06ab37a4c2ef66 (patch) (unidiff) | |
tree | 30adbbdd3d1eedaadd3671a17d960d161ddbfbe0 | |
parent | dbf8c3e1fc4416f2fd719b7d278984591a2366de (diff) | |
download | opie-7a819ad4bc09aa88521044bfbb06ab37a4c2ef66.zip opie-7a819ad4bc09aa88521044bfbb06ab37a4c2ef66.tar.gz opie-7a819ad4bc09aa88521044bfbb06ab37a4c2ef66.tar.bz2 |
libopie1-->libopie2
-rw-r--r-- | core/applets/multikeyapplet/config.in | 2 | ||||
-rw-r--r-- | core/applets/multikeyapplet/multikey.cpp | 15 | ||||
-rw-r--r-- | core/applets/multikeyapplet/multikey.h | 1 | ||||
-rw-r--r-- | core/applets/multikeyapplet/multikeyapplet.pro | 6 |
4 files changed, 19 insertions, 5 deletions
diff --git a/core/applets/multikeyapplet/config.in b/core/applets/multikeyapplet/config.in index fc7affe..2e1a9e2 100644 --- a/core/applets/multikeyapplet/config.in +++ b/core/applets/multikeyapplet/config.in | |||
@@ -1,4 +1,4 @@ | |||
1 | config MULTIKEYAPPLET | 1 | config MULTIKEYAPPLET |
2 | boolean "opie-multikeyapplet (Applet to switch OnScreen keyboard layout)" | 2 | boolean "opie-multikeyapplet (Applet to switch OnScreen keyboard layout)" |
3 | default "y" | 3 | default "y" |
4 | depends ( LIBQPE || LIBQPE-X11 ) && LIBOPIE && MULTIKEY | 4 | depends ( LIBQPE || LIBQPE-X11 ) && MULTIKEY |
diff --git a/core/applets/multikeyapplet/multikey.cpp b/core/applets/multikeyapplet/multikey.cpp index d304f54..b36ee12 100644 --- a/core/applets/multikeyapplet/multikey.cpp +++ b/core/applets/multikeyapplet/multikey.cpp | |||
@@ -1,136 +1,149 @@ | |||
1 | /********************************************************************** | 1 | /********************************************************************** |
2 | ** Copyright (C) 2004 Anton Kachalov mouse@altlinux.ru | 2 | ** Copyright (C) 2004 Anton Kachalov mouse@altlinux.ru |
3 | ** All rights reserved. | 3 | ** All rights reserved. |
4 | ** | 4 | ** |
5 | ** This file may be distributed and/or modified under the terms of the | 5 | ** This file may be distributed and/or modified under the terms of the |
6 | ** GNU General Public License version 2 as published by the Free Software | 6 | ** GNU General Public License version 2 as published by the Free Software |
7 | ** Foundation and appearing in the file LICENSE.GPL included in the | 7 | ** Foundation and appearing in the file LICENSE.GPL included in the |
8 | ** packaging of this file. | 8 | ** packaging of this file. |
9 | ** | 9 | ** |
10 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE | 10 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE |
11 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. | 11 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. |
12 | ** | 12 | ** |
13 | **********************************************************************/ | 13 | **********************************************************************/ |
14 | 14 | ||
15 | #include "multikey.h" | 15 | #include "multikey.h" |
16 | 16 | ||
17 | /* OPIE */ | ||
18 | #include <opie2/otaskbarapplet.h> | ||
17 | #include <qpe/global.h> | 19 | #include <qpe/global.h> |
18 | #include <qpe/config.h> | 20 | #include <qpe/config.h> |
19 | #include <qpe/qcopenvelope_qws.h> | 21 | #include <qpe/qcopenvelope_qws.h> |
20 | #include <qpe/qpeapplication.h> | 22 | #include <qpe/qpeapplication.h> |
21 | 23 | ||
24 | /* QT */ | ||
22 | #include <qlabel.h> | 25 | #include <qlabel.h> |
23 | #include <qdir.h> | 26 | #include <qdir.h> |
24 | #include <qfileinfo.h> | 27 | #include <qfileinfo.h> |
25 | #include <qcopchannel_qws.h> | 28 | #include <qcopchannel_qws.h> |
26 | 29 | ||
27 | Multikey::Multikey(QWidget *parent) : QLabel(parent), popupMenu(this), current("EN") | 30 | Multikey::Multikey(QWidget *parent) : QLabel(parent), popupMenu(this), current("EN") |
28 | { | 31 | { |
29 | QCopChannel* swChannel = new QCopChannel("MultiKey/Switcher", this); | 32 | QCopChannel* swChannel = new QCopChannel("MultiKey/Switcher", this); |
30 | connect( swChannel, SIGNAL(received(const QCString &, const QByteArray &)), | 33 | connect( swChannel, SIGNAL(received(const QCString &, const QByteArray &)), |
31 | this, SLOT(message(const QCString &, const QByteArray &))); | 34 | this, SLOT(message(const QCString &, const QByteArray &))); |
32 | 35 | ||
33 | setFont( QFont( "Helvetica", 10, QFont::Normal ) ); | 36 | setFont( QFont( "Helvetica", 10, QFont::Normal ) ); |
34 | QPEApplication::setStylusOperation(this, QPEApplication::RightOnHold); | 37 | QPEApplication::setStylusOperation(this, QPEApplication::RightOnHold); |
35 | lang = 0; | 38 | lang = 0; |
36 | QCopEnvelope e("MultiKey/Keyboard", "getmultikey()"); | 39 | QCopEnvelope e("MultiKey/Keyboard", "getmultikey()"); |
37 | setText("EN"); | 40 | setText("EN"); |
38 | popupMenu.insertItem("EN", 0); | 41 | popupMenu.insertItem("EN", 0); |
39 | show(); | 42 | show(); |
40 | } | 43 | } |
41 | 44 | ||
42 | void Multikey::mousePressEvent(QMouseEvent *ev) | 45 | void Multikey::mousePressEvent(QMouseEvent *ev) |
43 | { | 46 | { |
44 | if (!sw_maps.count()) | 47 | if (!sw_maps.count()) |
45 | return; | 48 | return; |
46 | 49 | ||
47 | if (ev->button() == RightButton) { | 50 | if (ev->button() == RightButton) { |
48 | 51 | ||
49 | QPoint p = mapToGlobal(QPoint(0, 0)); | 52 | QPoint p = mapToGlobal(QPoint(0, 0)); |
50 | QSize s = popupMenu.sizeHint(); | 53 | QSize s = popupMenu.sizeHint(); |
51 | int opt = popupMenu.exec(QPoint(p.x() + (width() / 2) - (s.width() / 2), | 54 | int opt = popupMenu.exec(QPoint(p.x() + (width() / 2) - (s.width() / 2), |
52 | p.y() - s.height()), 0); | 55 | p.y() - s.height()), 0); |
53 | 56 | ||
54 | if (opt == -1) | 57 | if (opt == -1) |
55 | return; | 58 | return; |
56 | lang = opt; | 59 | lang = opt; |
57 | 60 | ||
58 | QCopEnvelope e("MultiKey/Keyboard", "setmultikey(QString)"); | 61 | QCopEnvelope e("MultiKey/Keyboard", "setmultikey(QString)"); |
59 | e << sw_maps[lang]; | 62 | e << sw_maps[lang]; |
60 | setText(labels[lang]); | 63 | setText(labels[lang]); |
61 | } | 64 | } |
62 | QWidget::mousePressEvent(ev); | 65 | QWidget::mousePressEvent(ev); |
63 | } | 66 | } |
64 | 67 | ||
65 | void Multikey::mouseReleaseEvent(QMouseEvent *ev) | 68 | void Multikey::mouseReleaseEvent(QMouseEvent *ev) |
66 | { | 69 | { |
67 | if (!sw_maps.count()) | 70 | if (!sw_maps.count()) |
68 | return; | 71 | return; |
69 | 72 | ||
70 | lang = lang < sw_maps.count()-1 ? lang+1 : 0; | 73 | lang = lang < sw_maps.count()-1 ? lang+1 : 0; |
71 | QCopEnvelope e("MultiKey/Keyboard", "setmultikey(QString)"); | 74 | QCopEnvelope e("MultiKey/Keyboard", "setmultikey(QString)"); |
72 | //qDebug("Lang=%d, count=%d, lab=%s", lang, sw_maps.count(), labels[lang].ascii()); | 75 | //qDebug("Lang=%d, count=%d, lab=%s", lang, sw_maps.count(), labels[lang].ascii()); |
73 | e << sw_maps[lang]; | 76 | e << sw_maps[lang]; |
74 | setText(labels[lang]); | 77 | setText(labels[lang]); |
75 | } | 78 | } |
76 | 79 | ||
77 | void Multikey::message(const QCString &message, const QByteArray &data) | 80 | void Multikey::message(const QCString &message, const QByteArray &data) |
78 | { | 81 | { |
79 | if ( message == "setsw(QString,QString)" ) { | 82 | if ( message == "setsw(QString,QString)" ) { |
80 | 83 | ||
81 | QDataStream stream(data, IO_ReadOnly); | 84 | QDataStream stream(data, IO_ReadOnly); |
82 | QString maps, current_map; | 85 | QString maps, current_map; |
83 | stream >> maps >> current_map; | 86 | stream >> maps >> current_map; |
84 | QStringList sw = QStringList::split(QChar('|'), maps); | 87 | QStringList sw = QStringList::split(QChar('|'), maps); |
85 | sw.append(current_map); | 88 | sw.append(current_map); |
86 | 89 | ||
87 | QDir map_dir(QPEApplication::qpeDir() + "/share/multikey/", "*.keymap"); | 90 | QDir map_dir(QPEApplication::qpeDir() + "/share/multikey/", "*.keymap"); |
88 | lang = 0; | 91 | lang = 0; |
89 | labels.clear(); | 92 | labels.clear(); |
90 | sw_maps.clear(); | 93 | sw_maps.clear(); |
91 | popupMenu.clear(); | 94 | popupMenu.clear(); |
92 | 95 | ||
93 | for (uint i = 0; i < sw.count(); ++i) { | 96 | for (uint i = 0; i < sw.count(); ++i) { |
94 | QString keymap_map; | 97 | QString keymap_map; |
95 | if (sw[i][0] != '/') { | 98 | if (sw[i][0] != '/') { |
96 | 99 | ||
97 | keymap_map = map_dir.absPath() + "/" + sw[i]; | 100 | keymap_map = map_dir.absPath() + "/" + sw[i]; |
98 | } else { | 101 | } else { |
99 | 102 | ||
100 | if ((map_dir.exists(QFileInfo(sw[i]).fileName(), false) | 103 | if ((map_dir.exists(QFileInfo(sw[i]).fileName(), false) |
101 | && i != sw.count()-1) || !QFile::exists(sw[i])) { | 104 | && i != sw.count()-1) || !QFile::exists(sw[i])) { |
102 | continue; | 105 | continue; |
103 | } | 106 | } |
104 | keymap_map = sw[i]; | 107 | keymap_map = sw[i]; |
105 | } | 108 | } |
106 | 109 | ||
107 | QFile map(keymap_map); | 110 | QFile map(keymap_map); |
108 | if (map.open(IO_ReadOnly)) { | 111 | if (map.open(IO_ReadOnly)) { |
109 | QString line; | 112 | QString line; |
110 | 113 | ||
111 | map.readLine(line, 1024); | 114 | map.readLine(line, 1024); |
112 | while (!map.atEnd()) { | 115 | while (!map.atEnd()) { |
113 | 116 | ||
114 | if (line.find(QRegExp("^sw\\s*=\\s*")) != -1) { | 117 | if (line.find(QRegExp("^sw\\s*=\\s*")) != -1) { |
115 | 118 | ||
116 | if (i != sw.count()-1) { | 119 | if (i != sw.count()-1) { |
117 | if (keymap_map == current_map) { | 120 | if (keymap_map == current_map) { |
118 | lang = i; | 121 | lang = i; |
119 | } | 122 | } |
120 | sw_maps.append(keymap_map); | 123 | sw_maps.append(keymap_map); |
121 | labels.append(line.right(line.length() - line.find(QChar('=')) - 1).stripWhiteSpace()); | 124 | labels.append(line.right(line.length() - line.find(QChar('=')) - 1).stripWhiteSpace()); |
122 | popupMenu.insertItem(labels[labels.count()-1], labels.count()-1); | 125 | popupMenu.insertItem(labels[labels.count()-1], labels.count()-1); |
123 | } else { | 126 | } else { |
124 | current = line.right(line.length() - line.find(QChar('=')) - 1).stripWhiteSpace(); | 127 | current = line.right(line.length() - line.find(QChar('=')) - 1).stripWhiteSpace(); |
125 | } | 128 | } |
126 | break; | 129 | break; |
127 | } | 130 | } |
128 | map.readLine(line, 1024); | 131 | map.readLine(line, 1024); |
129 | } | 132 | } |
130 | map.close(); | 133 | map.close(); |
131 | } | 134 | } |
132 | } | 135 | } |
133 | 136 | ||
134 | setText(current); | 137 | setText(current); |
135 | } | 138 | } |
136 | } | 139 | } |
140 | |||
141 | int Multikey::position() | ||
142 | { | ||
143 | return 10; | ||
144 | } | ||
145 | |||
146 | Q_EXPORT_INTERFACE() | ||
147 | { | ||
148 | Q_CREATE_INSTANCE( OTaskbarAppletWrapper<Multikey> ); | ||
149 | } | ||
diff --git a/core/applets/multikeyapplet/multikey.h b/core/applets/multikeyapplet/multikey.h index 1c5aa0c..acddfc8 100644 --- a/core/applets/multikeyapplet/multikey.h +++ b/core/applets/multikeyapplet/multikey.h | |||
@@ -1,43 +1,44 @@ | |||
1 | /********************************************************************** | 1 | /********************************************************************** |
2 | ** Copyright (C) 2004 Anton Kachalov mouse@altlinux.ru | 2 | ** Copyright (C) 2004 Anton Kachalov mouse@altlinux.ru |
3 | ** All rights reserved. | 3 | ** All rights reserved. |
4 | ** | 4 | ** |
5 | ** This file may be distributed and/or modified under the terms of the | 5 | ** This file may be distributed and/or modified under the terms of the |
6 | ** GNU General Public License version 2 as published by the Free Software | 6 | ** GNU General Public License version 2 as published by the Free Software |
7 | ** Foundation and appearing in the file LICENSE.GPL included in the | 7 | ** Foundation and appearing in the file LICENSE.GPL included in the |
8 | ** packaging of this file. | 8 | ** packaging of this file. |
9 | ** | 9 | ** |
10 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE | 10 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE |
11 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. | 11 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. |
12 | ** | 12 | ** |
13 | **********************************************************************/ | 13 | **********************************************************************/ |
14 | #ifndef __MULTIKEY_H__ | 14 | #ifndef __MULTIKEY_H__ |
15 | #define __MULTIKEY_H__ | 15 | #define __MULTIKEY_H__ |
16 | 16 | ||
17 | #include <qlabel.h> | 17 | #include <qlabel.h> |
18 | #include <qstringlist.h> | 18 | #include <qstringlist.h> |
19 | #include <qpopupmenu.h> | 19 | #include <qpopupmenu.h> |
20 | #include <qcopchannel_qws.h> | 20 | #include <qcopchannel_qws.h> |
21 | 21 | ||
22 | class Multikey: public QLabel | 22 | class Multikey: public QLabel |
23 | { | 23 | { |
24 | Q_OBJECT | 24 | Q_OBJECT |
25 | public: | 25 | public: |
26 | Multikey(QWidget *parent); | 26 | Multikey(QWidget *parent); |
27 | static int position(); | ||
27 | 28 | ||
28 | protected: | 29 | protected: |
29 | void mousePressEvent(QMouseEvent *ev); | 30 | void mousePressEvent(QMouseEvent *ev); |
30 | void mouseReleaseEvent(QMouseEvent *ev); | 31 | void mouseReleaseEvent(QMouseEvent *ev); |
31 | 32 | ||
32 | public slots: | 33 | public slots: |
33 | void message(const QCString &message, const QByteArray &data); | 34 | void message(const QCString &message, const QByteArray &data); |
34 | 35 | ||
35 | protected: | 36 | protected: |
36 | QStringList sw_maps; | 37 | QStringList sw_maps; |
37 | QStringList labels; | 38 | QStringList labels; |
38 | QPopupMenu popupMenu; | 39 | QPopupMenu popupMenu; |
39 | QString current; | 40 | QString current; |
40 | uint lang; | 41 | uint lang; |
41 | }; | 42 | }; |
42 | 43 | ||
43 | #endif /* __MULTIKEY_H__ */ | 44 | #endif /* __MULTIKEY_H__ */ |
diff --git a/core/applets/multikeyapplet/multikeyapplet.pro b/core/applets/multikeyapplet/multikeyapplet.pro index 4be1f74..86e41c0 100644 --- a/core/applets/multikeyapplet/multikeyapplet.pro +++ b/core/applets/multikeyapplet/multikeyapplet.pro | |||
@@ -1,13 +1,13 @@ | |||
1 | TEMPLATE= lib | 1 | TEMPLATE= lib |
2 | CONFIG += qt plugin warn_on release | 2 | CONFIG += qt plugin warn_on release |
3 | HEADERS= multikey.h multikeyappletimpl.h | 3 | HEADERS= multikey.h |
4 | SOURCES= multikey.cpp multikeyappletimpl.cpp | 4 | SOURCES= multikey.cpp |
5 | TARGET = multikeyapplet | 5 | TARGET = multikeyapplet |
6 | DESTDIR = $(OPIEDIR)/plugins/applets | 6 | DESTDIR = $(OPIEDIR)/plugins/applets |
7 | INCLUDEPATH += $(OPIEDIR)/include | 7 | INCLUDEPATH += $(OPIEDIR)/include |
8 | DEPENDPATH += ../$(OPIEDIR)/include .. | 8 | DEPENDPATH += ../$(OPIEDIR)/include .. |
9 | LIBS += -lqpe -lopie | 9 | LIBS += -lqpe |
10 | VERSION = 1.0.0 | 10 | VERSION = 1.0.0 |
11 | 11 | ||
12 | include ( $(OPIEDIR)/include.pro ) | 12 | include ( $(OPIEDIR)/include.pro ) |
13 | target.path = $$prefix/plugins/applets | 13 | target.path = $$prefix/plugins/applets |