summaryrefslogtreecommitdiff
path: root/core/applets/multikeyapplet/multikey.cpp
Unidiff
Diffstat (limited to 'core/applets/multikeyapplet/multikey.cpp') (more/less context) (show whitespace changes)
-rw-r--r--core/applets/multikeyapplet/multikey.cpp22
1 files changed, 19 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
@@ -25,5 +25,5 @@
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);
@@ -35,11 +35,25 @@ Multikey::Multikey( QWidget *parent ) : QLabel( parent ), current("EN")
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{
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];
@@ -61,4 +75,5 @@ void Multikey::message(const QCString &message, const QByteArray &data)
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) {
@@ -91,4 +106,5 @@ void Multikey::message(const QCString &message, const QByteArray &data)
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();