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.cpp4
1 files changed, 2 insertions, 2 deletions
diff --git a/core/applets/multikeyapplet/multikey.cpp b/core/applets/multikeyapplet/multikey.cpp
index 8cb9083..f3d8375 100644
--- a/core/applets/multikeyapplet/multikey.cpp
+++ b/core/applets/multikeyapplet/multikey.cpp
@@ -1,80 +1,80 @@
1/********************************************************************** 1/**********************************************************************
2** Copyright (C) 2004 Anton Kachalov mouse@altlinux.ru 2** Copyright (C) 2004 Anton Kachalov mouse@altlinux.ru
3** All rights reserved. 3** All rights reserved.
4** 4**
5** This file may be distributed and/or modified under the terms of the 5** This file may be distributed and/or modified under the terms of the
6** GNU General Public License version 2 as published by the Free Software 6** GNU General Public License version 2 as published by the Free Software
7** Foundation and appearing in the file LICENSE.GPL included in the 7** Foundation and appearing in the file LICENSE.GPL included in the
8** packaging of this file. 8** packaging of this file.
9** 9**
10** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE 10** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
11** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. 11** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
12** 12**
13**********************************************************************/ 13**********************************************************************/
14 14
15#include "multikey.h" 15#include "multikey.h"
16 16
17/* OPIE */ 17/* OPIE */
18#include <opie2/otaskbarapplet.h> 18#include <opie2/otaskbarapplet.h>
19#include <qpe/qcopenvelope_qws.h> 19#include <qpe/qcopenvelope_qws.h>
20#include <qpe/qpeapplication.h> 20#include <qpe/qpeapplication.h>
21using namespace Opie::Ui;
21 22
22/* QT */ 23/* QT */
23#include <qdir.h> 24#include <qdir.h>
24 25
25using namespace Opie::Ui; 26//FIXME: Better read appropriate initial setting from LOCALE, not hardcode it "EN"
26Multikey::Multikey(QWidget *parent) : QLabel(parent), popupMenu(this), current("EN") 27Multikey::Multikey(QWidget *parent) : QLabel(parent), popupMenu(this), current("EN")
27{ 28{
28 QCopChannel* swChannel = new QCopChannel("MultiKey/Switcher", this); 29 QCopChannel* swChannel = new QCopChannel("MultiKey/Switcher", this);
29 connect( swChannel, SIGNAL(received(const QCString&,const QByteArray&)), 30 connect( swChannel, SIGNAL(received(const QCString&,const QByteArray&)),
30 this, SLOT(message(const QCString&,const QByteArray&))); 31 this, SLOT(message(const QCString&,const QByteArray&)));
31 32
32 setFont( QFont( "Helvetica", 10, QFont::Normal ) );
33 QPEApplication::setStylusOperation(this, QPEApplication::RightOnHold); 33 QPEApplication::setStylusOperation(this, QPEApplication::RightOnHold);
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", 0); 37 popupMenu.insertItem("EN", 0);
38 show(); 38 show();
39} 39}
40 40
41void Multikey::mousePressEvent(QMouseEvent *ev) 41void Multikey::mousePressEvent(QMouseEvent *ev)
42{ 42{
43 if (!sw_maps.count()) 43 if (!sw_maps.count())
44 return; 44 return;
45 45
46 if (ev->button() == RightButton) { 46 if (ev->button() == RightButton) {
47 47
48 QPoint p = mapToGlobal(QPoint(0, 0)); 48 QPoint p = mapToGlobal(QPoint(0, 0));
49 QSize s = popupMenu.sizeHint(); 49 QSize s = popupMenu.sizeHint();
50 int opt = popupMenu.exec(QPoint(p.x() + (width() / 2) - (s.width() / 2), 50 int opt = popupMenu.exec(QPoint(p.x() + (width() / 2) - (s.width() / 2),
51 p.y() - s.height()), 0); 51 p.y() - s.height()), 0);
52 52
53 if (opt == -1) 53 if (opt == -1)
54 return; 54 return;
55 lang = opt; 55 lang = opt;
56 56
57 QCopEnvelope e("MultiKey/Keyboard", "setmultikey(QString)"); 57 QCopEnvelope e("MultiKey/Keyboard", "setmultikey(QString)");
58 e << sw_maps[lang]; 58 e << sw_maps[lang];
59 setText(labels[lang]); 59 setText(labels[lang]);
60 } 60 }
61 QWidget::mousePressEvent(ev); 61 QWidget::mousePressEvent(ev);
62} 62}
63 63
64void Multikey::mouseReleaseEvent(QMouseEvent *ev) 64void Multikey::mouseReleaseEvent(QMouseEvent *ev)
65{ 65{
66 if (!sw_maps.count()) 66 if (!sw_maps.count())
67 return; 67 return;
68 68
69 lang = lang < sw_maps.count()-1 ? lang+1 : 0; 69 lang = lang < sw_maps.count()-1 ? lang+1 : 0;
70 QCopEnvelope e("MultiKey/Keyboard", "setmultikey(QString)"); 70 QCopEnvelope e("MultiKey/Keyboard", "setmultikey(QString)");
71 //odebug << "Lang=" << lang << ", count=" << sw_maps.count() << ", lab=" << labels[lang].ascii() << "" << oendl; 71 //odebug << "Lang=" << lang << ", count=" << sw_maps.count() << ", lab=" << labels[lang].ascii() << "" << oendl;
72 e << sw_maps[lang]; 72 e << sw_maps[lang];
73 setText(labels[lang]); 73 setText(labels[lang]);
74} 74}
75 75
76void Multikey::message(const QCString &message, const QByteArray &data) 76void Multikey::message(const QCString &message, const QByteArray &data)
77{ 77{
78 if ( message == "setsw(QString,QString)" ) { 78 if ( message == "setsw(QString,QString)" ) {
79 79
80 QDataStream stream(data, IO_ReadOnly); 80 QDataStream stream(data, IO_ReadOnly);