author | mickeyl <mickeyl> | 2004-01-04 14:22:59 (UTC) |
---|---|---|
committer | mickeyl <mickeyl> | 2004-01-04 14:22:59 (UTC) |
commit | 5c4c2a789c19e727bb9ca323ea1fec1b7d1bd057 (patch) (unidiff) | |
tree | c2e1b4a090ca53efd3b3e0c20d12a633e01470d4 /core | |
parent | 84f039ef3799c5310a4f94057b9d76d4ee55f499 (diff) | |
download | opie-5c4c2a789c19e727bb9ca323ea1fec1b7d1bd057.zip opie-5c4c2a789c19e727bb9ca323ea1fec1b7d1bd057.tar.gz opie-5c4c2a789c19e727bb9ca323ea1fec1b7d1bd057.tar.bz2 |
more patches to multikey+applet courtesy Anton Kachalov <mouse@altlinux.ru>
-rw-r--r-- | core/applets/multikeyapplet/multikey.cpp | 22 | ||||
-rw-r--r-- | core/applets/multikeyapplet/multikey.h | 2 |
2 files changed, 21 insertions, 3 deletions
diff --git a/core/applets/multikeyapplet/multikey.cpp b/core/applets/multikeyapplet/multikey.cpp index 0a056b0..f1227ef 100644 --- a/core/applets/multikeyapplet/multikey.cpp +++ b/core/applets/multikeyapplet/multikey.cpp | |||
@@ -21,29 +21,43 @@ | |||
21 | 21 | ||
22 | #include <qlabel.h> | 22 | #include <qlabel.h> |
23 | #include <qdir.h> | 23 | #include <qdir.h> |
24 | #include <qfileinfo.h> | 24 | #include <qfileinfo.h> |
25 | #include <qcopchannel_qws.h> | 25 | #include <qcopchannel_qws.h> |
26 | 26 | ||
27 | Multikey::Multikey( QWidget *parent ) : QLabel( parent ), current("EN") | 27 | Multikey::Multikey(QWidget *parent) : QLabel(parent), popupMenu(this), current("EN") |
28 | { | 28 | { |
29 | QCopChannel* swChannel = new QCopChannel("MultiKey/Switcher", this); | 29 | QCopChannel* swChannel = new QCopChannel("MultiKey/Switcher", this); |
30 | connect( swChannel, SIGNAL(received(const QCString &, const QByteArray &)), | 30 | connect( swChannel, SIGNAL(received(const QCString &, const QByteArray &)), |
31 | this, SLOT(message(const QCString &, const QByteArray &))); | 31 | this, SLOT(message(const QCString &, const QByteArray &))); |
32 | 32 | ||
33 | setFont( QFont( "Helvetica", 10, QFont::Normal ) ); | 33 | setFont( QFont( "Helvetica", 10, QFont::Normal ) ); |
34 | lang = 0; | 34 | lang = 0; |
35 | QCopEnvelope e("MultiKey/Keyboard", "getmultikey()"); | 35 | QCopEnvelope e("MultiKey/Keyboard", "getmultikey()"); |
36 | setText("EN"); | 36 | setText("EN"); |
37 | popupMenu.insertItem("EN", -1); | ||
37 | show(); | 38 | show(); |
38 | } | 39 | } |
39 | 40 | ||
40 | void Multikey::mousePressEvent( QMouseEvent * ) | 41 | void Multikey::mousePressEvent(QMouseEvent *ev) |
41 | { | 42 | { |
42 | QCopEnvelope e("MultiKey/Keyboard", "setmultikey(QString)"); | 43 | if (ev->button() == RightButton) { |
44 | |||
45 | QPoint p = mapToGlobal(QPoint(0, 0)); | ||
46 | QSize s = popupMenu.sizeHint(); | ||
47 | int opt = popupMenu.exec(QPoint(p.x() + (width() / 2) - (s.width() / 2), | ||
48 | p.y() - s.height()), 0); | ||
49 | |||
50 | if (opt == -1) | ||
51 | return; | ||
52 | lang = opt; | ||
53 | } else { | ||
43 | lang = lang < sw_maps.count()-1 ? lang+1 : 0; | 54 | lang = lang < sw_maps.count()-1 ? lang+1 : 0; |
55 | } | ||
56 | |||
57 | QCopEnvelope e("MultiKey/Keyboard", "setmultikey(QString)"); | ||
44 | //qDebug("Lang=%d, count=%d, lab=%s", lang, sw_maps.count(), labels[lang].ascii()); | 58 | //qDebug("Lang=%d, count=%d, lab=%s", lang, sw_maps.count(), labels[lang].ascii()); |
45 | e << sw_maps[lang]; | 59 | e << sw_maps[lang]; |
46 | setText(labels[lang]); | 60 | setText(labels[lang]); |
47 | } | 61 | } |
48 | 62 | ||
49 | void Multikey::message(const QCString &message, const QByteArray &data) | 63 | void Multikey::message(const QCString &message, const QByteArray &data) |
@@ -57,12 +71,13 @@ void Multikey::message(const QCString &message, const QByteArray &data) | |||
57 | sw.append(current_map); | 71 | sw.append(current_map); |
58 | 72 | ||
59 | QDir map_dir(QPEApplication::qpeDir() + "/share/multikey/", "*.keymap"); | 73 | QDir map_dir(QPEApplication::qpeDir() + "/share/multikey/", "*.keymap"); |
60 | lang = 0; | 74 | lang = 0; |
61 | labels.clear(); | 75 | labels.clear(); |
62 | sw_maps.clear(); | 76 | sw_maps.clear(); |
77 | popupMenu.clear(); | ||
63 | 78 | ||
64 | for (uint i = 0; i < sw.count(); ++i) { | 79 | for (uint i = 0; i < sw.count(); ++i) { |
65 | QString keymap_map; | 80 | QString keymap_map; |
66 | if (sw[i][0] != '/') { | 81 | if (sw[i][0] != '/') { |
67 | 82 | ||
68 | keymap_map = map_dir.absPath() + "/" + sw[i]; | 83 | keymap_map = map_dir.absPath() + "/" + sw[i]; |
@@ -87,12 +102,13 @@ void Multikey::message(const QCString &message, const QByteArray &data) | |||
87 | if (i != sw.count()-1) { | 102 | if (i != sw.count()-1) { |
88 | if (keymap_map == current_map) { | 103 | if (keymap_map == current_map) { |
89 | lang = i; | 104 | lang = i; |
90 | } | 105 | } |
91 | sw_maps.append(keymap_map); | 106 | sw_maps.append(keymap_map); |
92 | labels.append(line.right(line.length() - line.find(QChar('=')) - 1).stripWhiteSpace()); | 107 | labels.append(line.right(line.length() - line.find(QChar('=')) - 1).stripWhiteSpace()); |
108 | popupMenu.insertItem(labels[labels.count()-1], labels.count()-1); | ||
93 | } else { | 109 | } else { |
94 | current = line.right(line.length() - line.find(QChar('=')) - 1).stripWhiteSpace(); | 110 | current = line.right(line.length() - line.find(QChar('=')) - 1).stripWhiteSpace(); |
95 | } | 111 | } |
96 | break; | 112 | break; |
97 | } | 113 | } |
98 | map.readLine(line, 1024); | 114 | map.readLine(line, 1024); |
diff --git a/core/applets/multikeyapplet/multikey.h b/core/applets/multikeyapplet/multikey.h index 2cb7b29..b525074 100644 --- a/core/applets/multikeyapplet/multikey.h +++ b/core/applets/multikeyapplet/multikey.h | |||
@@ -13,12 +13,13 @@ | |||
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 <qcopchannel_qws.h> | 20 | #include <qcopchannel_qws.h> |
20 | 21 | ||
21 | class Multikey : public QLabel | 22 | class Multikey : public QLabel |
22 | { | 23 | { |
23 | Q_OBJECT | 24 | Q_OBJECT |
24 | public: | 25 | public: |
@@ -28,11 +29,12 @@ public slots: | |||
28 | void message(const QCString &message, const QByteArray &data); | 29 | void message(const QCString &message, const QByteArray &data); |
29 | 30 | ||
30 | protected: | 31 | protected: |
31 | void mousePressEvent( QMouseEvent * ); | 32 | void mousePressEvent( QMouseEvent * ); |
32 | QStringList sw_maps; | 33 | QStringList sw_maps; |
33 | QStringList labels; | 34 | QStringList labels; |
35 | QPopupMenu popupMenu; | ||
34 | QString current; | 36 | QString current; |
35 | uint lang; | 37 | uint lang; |
36 | }; | 38 | }; |
37 | 39 | ||
38 | #endif /* __MULTIKEY_H__ */ | 40 | #endif /* __MULTIKEY_H__ */ |