summaryrefslogtreecommitdiff
path: root/core/applets
authormickeyl <mickeyl>2004-10-29 12:38:37 (UTC)
committer mickeyl <mickeyl>2004-10-29 12:38:37 (UTC)
commitdca4423e3b0966fe26ba4183e5b6ad4666c61e86 (patch) (unidiff)
tree8a06619edc609164f45b6a2d92ec3fe264fc3fb1 /core/applets
parente1ab37a7bc09619958037be7ecddc67fd334227d (diff)
downloadopie-dca4423e3b0966fe26ba4183e5b6ad4666c61e86.zip
opie-dca4423e3b0966fe26ba4183e5b6ad4666c61e86.tar.gz
opie-dca4423e3b0966fe26ba4183e5b6ad4666c61e86.tar.bz2
- no longer hardcode the font size
- add fixme for initial keyboard setting
Diffstat (limited to 'core/applets') (more/less context) (ignore whitespace changes)
-rw-r--r--core/applets/multikeyapplet/multikey.cpp6
1 files changed, 3 insertions, 3 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,95 +1,95 @@
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);
81 QString maps, current_map; 81 QString maps, current_map;
82 stream >> maps >> current_map; 82 stream >> maps >> current_map;
83 QStringList sw = QStringList::split(QChar('|'), maps); 83 QStringList sw = QStringList::split(QChar('|'), maps);
84 sw.append(current_map); 84 sw.append(current_map);
85 85
86 QDir map_dir(QPEApplication::qpeDir() + "share/multikey/", "*.keymap"); 86 QDir map_dir(QPEApplication::qpeDir() + "share/multikey/", "*.keymap");
87 lang = 0; 87 lang = 0;
88 labels.clear(); 88 labels.clear();
89 sw_maps.clear(); 89 sw_maps.clear();
90 popupMenu.clear(); 90 popupMenu.clear();
91 91
92 for (uint i = 0; i < sw.count(); ++i) { 92 for (uint i = 0; i < sw.count(); ++i) {
93 QString keymap_map; 93 QString keymap_map;
94 if (sw[i][0] != '/') { 94 if (sw[i][0] != '/') {
95 95