summaryrefslogtreecommitdiff
path: root/core
authormickeyl <mickeyl>2004-01-04 14:22:59 (UTC)
committer mickeyl <mickeyl>2004-01-04 14:22:59 (UTC)
commit5c4c2a789c19e727bb9ca323ea1fec1b7d1bd057 (patch) (unidiff)
treec2e1b4a090ca53efd3b3e0c20d12a633e01470d4 /core
parent84f039ef3799c5310a4f94057b9d76d4ee55f499 (diff)
downloadopie-5c4c2a789c19e727bb9ca323ea1fec1b7d1bd057.zip
opie-5c4c2a789c19e727bb9ca323ea1fec1b7d1bd057.tar.gz
opie-5c4c2a789c19e727bb9ca323ea1fec1b7d1bd057.tar.bz2
more patches to multikey+applet courtesy Anton Kachalov <mouse@altlinux.ru>
Diffstat (limited to 'core') (more/less context) (ignore whitespace changes)
-rw-r--r--core/applets/multikeyapplet/multikey.cpp22
-rw-r--r--core/applets/multikeyapplet/multikey.h2
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
@@ -24,7 +24,7 @@
24#include <qfileinfo.h> 24#include <qfileinfo.h>
25#include <qcopchannel_qws.h> 25#include <qcopchannel_qws.h>
26 26
27Multikey::Multikey( QWidget *parent ) : QLabel( parent ), current("EN") 27Multikey::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 &)),
@@ -34,13 +34,27 @@ Multikey::Multikey( QWidget *parent ) : QLabel( parent ), current("EN")
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
40void Multikey::mousePressEvent( QMouseEvent * ) 41void Multikey::mousePressEvent(QMouseEvent *ev)
41{ 42{
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 {
54 lang = lang < sw_maps.count()-1 ? lang+1 : 0;
55 }
56
42 QCopEnvelope e("MultiKey/Keyboard", "setmultikey(QString)"); 57 QCopEnvelope e("MultiKey/Keyboard", "setmultikey(QString)");
43 lang = lang < sw_maps.count()-1 ? lang+1 : 0;
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]);
@@ -60,6 +74,7 @@ void Multikey::message(const QCString &message, const QByteArray &data)
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;
@@ -90,6 +105,7 @@ void Multikey::message(const QCString &message, const QByteArray &data)
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 }
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
@@ -16,6 +16,7 @@
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
21class Multikey : public QLabel 22class Multikey : public QLabel
@@ -31,6 +32,7 @@ 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};