Diffstat (limited to 'core/applets/multikeyapplet/multikey.cpp') (more/less context) (show whitespace changes)
-rw-r--r-- | core/applets/multikeyapplet/multikey.cpp | 22 |
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 @@ -23,9 +23,9 @@ #include <qdir.h> #include <qfileinfo.h> #include <qcopchannel_qws.h> -Multikey::Multikey( QWidget *parent ) : QLabel( parent ), current("EN") +Multikey::Multikey(QWidget *parent) : QLabel(parent), popupMenu(this), current("EN") { QCopChannel* swChannel = new QCopChannel("MultiKey/Switcher", this); connect( swChannel, SIGNAL(received(const QCString &, const QByteArray &)), this, SLOT(message(const QCString &, const QByteArray &))); @@ -33,15 +33,29 @@ Multikey::Multikey( QWidget *parent ) : QLabel( parent ), current("EN") setFont( QFont( "Helvetica", 10, QFont::Normal ) ); lang = 0; QCopEnvelope e("MultiKey/Keyboard", "getmultikey()"); setText("EN"); + popupMenu.insertItem("EN", -1); show(); } -void Multikey::mousePressEvent( QMouseEvent * ) +void Multikey::mousePressEvent(QMouseEvent *ev) { - QCopEnvelope e("MultiKey/Keyboard", "setmultikey(QString)"); + if (ev->button() == RightButton) { + + QPoint p = mapToGlobal(QPoint(0, 0)); + QSize s = popupMenu.sizeHint(); + int opt = popupMenu.exec(QPoint(p.x() + (width() / 2) - (s.width() / 2), + p.y() - s.height()), 0); + + if (opt == -1) + return; + lang = opt; + } else { lang = lang < sw_maps.count()-1 ? lang+1 : 0; + } + + QCopEnvelope e("MultiKey/Keyboard", "setmultikey(QString)"); //qDebug("Lang=%d, count=%d, lab=%s", lang, sw_maps.count(), labels[lang].ascii()); e << sw_maps[lang]; setText(labels[lang]); } @@ -59,8 +73,9 @@ void Multikey::message(const QCString &message, const QByteArray &data) QDir map_dir(QPEApplication::qpeDir() + "/share/multikey/", "*.keymap"); lang = 0; labels.clear(); sw_maps.clear(); + popupMenu.clear(); for (uint i = 0; i < sw.count(); ++i) { QString keymap_map; if (sw[i][0] != '/') { @@ -89,8 +104,9 @@ void Multikey::message(const QCString &message, const QByteArray &data) lang = i; } sw_maps.append(keymap_map); labels.append(line.right(line.length() - line.find(QChar('=')) - 1).stripWhiteSpace()); + popupMenu.insertItem(labels[labels.count()-1], labels.count()-1); } else { current = line.right(line.length() - line.find(QChar('=')) - 1).stripWhiteSpace(); } break; |