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) (side-by-side diff)
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 @@
#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 &)),
@@ -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 <qlabel.h>
#include <qstringlist.h>
+#include <qpopupmenu.h>
#include <qcopchannel_qws.h>
class Multikey : public QLabel
@@ -31,6 +32,7 @@ protected:
void mousePressEvent( QMouseEvent * );
QStringList sw_maps;
QStringList labels;
+ QPopupMenu popupMenu;
QString current;
uint lang;
};