From 5c4c2a789c19e727bb9ca323ea1fec1b7d1bd057 Mon Sep 17 00:00:00 2001 From: mickeyl Date: Sun, 04 Jan 2004 14:22:59 +0000 Subject: more patches to multikey+applet courtesy Anton Kachalov --- (limited to 'core/applets') 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 @@ #include #include -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 &)), @@ -34,13 +34,27 @@ Multikey::Multikey( QWidget *parent ) : QLabel( parent ), current("EN") lang = 0; QCopEnvelope e("MultiKey/Keyboard", "getmultikey()"); setText("EN"); + popupMenu.insertItem("EN", -1); show(); } -void Multikey::mousePressEvent( QMouseEvent * ) +void Multikey::mousePressEvent(QMouseEvent *ev) { + 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)"); - lang = lang < sw_maps.count()-1 ? lang+1 : 0; //qDebug("Lang=%d, count=%d, lab=%s", lang, sw_maps.count(), labels[lang].ascii()); e << sw_maps[lang]; setText(labels[lang]); @@ -60,6 +74,7 @@ void Multikey::message(const QCString &message, const QByteArray &data) lang = 0; labels.clear(); sw_maps.clear(); + popupMenu.clear(); for (uint i = 0; i < sw.count(); ++i) { QString keymap_map; @@ -90,6 +105,7 @@ void Multikey::message(const QCString &message, const QByteArray &data) } 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(); } 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 @@ #include #include +#include #include class Multikey : public QLabel @@ -31,6 +32,7 @@ protected: void mousePressEvent( QMouseEvent * ); QStringList sw_maps; QStringList labels; + QPopupMenu popupMenu; QString current; uint lang; }; -- cgit v0.9.0.2