author | hgs |
Wed, 21 Jul 2010 18:26:52 +0300 | |
changeset 33 | 8d5d7fcf9b59 |
parent 32 | 1f002146abb4 |
child 38 | bc103bfb69cf |
permissions | -rw-r--r-- |
12
ae8abd0db65c
Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
1 |
/*! |
ae8abd0db65c
Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
2 |
* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). |
ae8abd0db65c
Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
3 |
* All rights reserved. |
ae8abd0db65c
Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
4 |
* This component and the accompanying materials are made available |
ae8abd0db65c
Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
5 |
* under the terms of "Eclipse Public License v1.0" |
ae8abd0db65c
Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
6 |
* which accompanies this distribution, and is available |
ae8abd0db65c
Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
7 |
* at the URL "http://www.eclipse.org/legal/epl-v10.html". |
ae8abd0db65c
Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
8 |
* |
ae8abd0db65c
Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
9 |
* Initial Contributors: |
ae8abd0db65c
Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
10 |
* Nokia Corporation - initial contribution. |
ae8abd0db65c
Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
11 |
* |
ae8abd0db65c
Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
12 |
* Contributors: |
ae8abd0db65c
Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
13 |
* |
ae8abd0db65c
Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
14 |
* Description: Dialpad keypad |
ae8abd0db65c
Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
15 |
* |
ae8abd0db65c
Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
16 |
*/ |
ae8abd0db65c
Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
17 |
|
31
a2467631ae02
Revision: 201023
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
27
diff
changeset
|
18 |
#include <QLocale> |
a2467631ae02
Revision: 201023
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
27
diff
changeset
|
19 |
#include <QSignalMapper> |
a2467631ae02
Revision: 201023
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
27
diff
changeset
|
20 |
|
12
ae8abd0db65c
Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
21 |
#include <hbinstance.h> |
ae8abd0db65c
Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
22 |
#include <hbinputkeymapfactory.h> |
ae8abd0db65c
Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
23 |
#include <hbinputkeymap.h> |
ae8abd0db65c
Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
24 |
#include <hbinpututils.h> |
ae8abd0db65c
Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
25 |
#include <hbinputsettingproxy.h> |
ae8abd0db65c
Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
26 |
#include <hbinputlanguage.h> |
ae8abd0db65c
Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
27 |
#include <hbapplication.h> |
33 | 28 |
#include <hbcolorscheme.h> |
12
ae8abd0db65c
Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
29 |
#include <hblineedit.h> |
33 | 30 |
#include <hbfontspec.h> |
31 |
#include <hbevent.h> |
|
12
ae8abd0db65c
Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
32 |
|
33 | 33 |
#include "dialpadnumericbutton.h" |
12
ae8abd0db65c
Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
34 |
#include "dialpadkeypad.h" |
ae8abd0db65c
Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
35 |
#include "dialpadbutton.h" |
ae8abd0db65c
Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
36 |
#include "dialpadinputfield.h" |
ae8abd0db65c
Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
37 |
|
31
a2467631ae02
Revision: 201023
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
27
diff
changeset
|
38 |
static const int DialpadRowCount = 4; |
12
ae8abd0db65c
Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
39 |
static const int DialpadColumnCount = 3; |
32
1f002146abb4
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
31
diff
changeset
|
40 |
static const QLatin1String handsetIcon("qtg_mono_call"); |
1f002146abb4
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
31
diff
changeset
|
41 |
static const QLatin1String vmbxIcon("qtg_mono_voice_mailbox"); |
33 | 42 |
// layout values in units |
43 |
static const qreal DialpadPrimaryTextSize = 5.5; |
|
44 |
static const qreal DialpadSecondaryTextSize = 4.0; |
|
45 |
static const qreal DialpadIconSize = 4.0; |
|
46 |
static const qreal DialpadPrimaryTextLeftMargin = 1.5; |
|
47 |
static const qreal DialpadPrimarySecondaryMargin = 0.75; |
|
12
ae8abd0db65c
Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
48 |
|
31
a2467631ae02
Revision: 201023
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
27
diff
changeset
|
49 |
static const int DialpadKeyCodeTable[DialpadRowCount*DialpadColumnCount] = |
12
ae8abd0db65c
Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
50 |
{ |
ae8abd0db65c
Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
51 |
Qt::Key_1, Qt::Key_2, Qt::Key_3, |
ae8abd0db65c
Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
52 |
Qt::Key_4, Qt::Key_5, Qt::Key_6, |
ae8abd0db65c
Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
53 |
Qt::Key_7, Qt::Key_8, Qt::Key_9, |
31
a2467631ae02
Revision: 201023
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
27
diff
changeset
|
54 |
Qt::Key_Asterisk, Qt::Key_0, Qt::Key_NumberSign |
a2467631ae02
Revision: 201023
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
27
diff
changeset
|
55 |
// Qt::Key_Yes and Qt::Key_BackSpace are handled separately |
12
ae8abd0db65c
Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
56 |
}; |
ae8abd0db65c
Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
57 |
|
ae8abd0db65c
Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
58 |
DialpadKeypad::DialpadKeypad( |
13
e32024264ebb
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
12
diff
changeset
|
59 |
const HbMainWindow& mainWindow, |
12
ae8abd0db65c
Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
60 |
DialpadInputField& inputField, |
ae8abd0db65c
Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
61 |
QGraphicsItem* parent) : |
31
a2467631ae02
Revision: 201023
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
27
diff
changeset
|
62 |
HbInputButtonGroup(parent), |
13
e32024264ebb
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
12
diff
changeset
|
63 |
mMainWindow(mainWindow), |
33 | 64 |
mInputField(inputField), |
65 |
mMaxPrimaryLineWidth(0) |
|
12
ae8abd0db65c
Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
66 |
{ |
31
a2467631ae02
Revision: 201023
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
27
diff
changeset
|
67 |
setObjectName("keypad"); |
a2467631ae02
Revision: 201023
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
27
diff
changeset
|
68 |
|
a2467631ae02
Revision: 201023
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
27
diff
changeset
|
69 |
// create clicked signal mapper |
12
ae8abd0db65c
Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
70 |
mKeyClickedSignalMapper = new QSignalMapper(this); |
ae8abd0db65c
Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
71 |
connect(mKeyClickedSignalMapper,SIGNAL(mapped(int)), |
ae8abd0db65c
Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
72 |
SLOT(handleKeyClicked(int))); |
ae8abd0db65c
Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
73 |
|
31
a2467631ae02
Revision: 201023
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
27
diff
changeset
|
74 |
// connect backspace signals |
12
ae8abd0db65c
Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
75 |
connect(&mInputField.backspaceButton(),SIGNAL(clicked()), |
ae8abd0db65c
Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
76 |
mKeyClickedSignalMapper,SLOT(map())); |
ae8abd0db65c
Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
77 |
mKeyClickedSignalMapper->setMapping(&mInputField.backspaceButton(), |
ae8abd0db65c
Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
78 |
Qt::Key_Backspace); |
ae8abd0db65c
Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
79 |
|
ae8abd0db65c
Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
80 |
// create keypad |
31
a2467631ae02
Revision: 201023
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
27
diff
changeset
|
81 |
setGridSize(QSize(DialpadColumnCount, DialpadRowCount)); |
33 | 82 |
setButtonBorderSize(0); |
12
ae8abd0db65c
Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
83 |
|
31
a2467631ae02
Revision: 201023
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
27
diff
changeset
|
84 |
QList<HbInputButton*> buttons; |
12
ae8abd0db65c
Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
85 |
|
31
a2467631ae02
Revision: 201023
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
27
diff
changeset
|
86 |
for (int i = 0; i < DialpadRowCount * DialpadColumnCount; ++i) { |
33 | 87 |
DialpadNumericButton *item = new DialpadNumericButton( |
31
a2467631ae02
Revision: 201023
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
27
diff
changeset
|
88 |
DialpadKeyCodeTable[i], |
a2467631ae02
Revision: 201023
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
27
diff
changeset
|
89 |
QPoint(i % DialpadColumnCount, i / DialpadColumnCount)); |
a2467631ae02
Revision: 201023
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
27
diff
changeset
|
90 |
buttons.append(item); |
12
ae8abd0db65c
Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
91 |
|
31
a2467631ae02
Revision: 201023
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
27
diff
changeset
|
92 |
item->setType(HbInputButton::ButtonTypeNormal); |
a2467631ae02
Revision: 201023
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
27
diff
changeset
|
93 |
} |
a2467631ae02
Revision: 201023
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
27
diff
changeset
|
94 |
|
a2467631ae02
Revision: 201023
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
27
diff
changeset
|
95 |
setButtons(buttons); |
12
ae8abd0db65c
Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
96 |
|
31
a2467631ae02
Revision: 201023
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
27
diff
changeset
|
97 |
// connect keypad signals |
a2467631ae02
Revision: 201023
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
27
diff
changeset
|
98 |
QObject::connect(this, SIGNAL(buttonPressed(const QKeyEvent&)), |
a2467631ae02
Revision: 201023
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
27
diff
changeset
|
99 |
this, SLOT(sendKeyPressEvent(const QKeyEvent&))); |
a2467631ae02
Revision: 201023
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
27
diff
changeset
|
100 |
QObject::connect(this, SIGNAL(buttonReleased(const QKeyEvent&)), |
a2467631ae02
Revision: 201023
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
27
diff
changeset
|
101 |
this, SLOT(sendKeyReleaseEvent(const QKeyEvent&))); |
a2467631ae02
Revision: 201023
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
27
diff
changeset
|
102 |
QObject::connect(this, SIGNAL(buttonLongPressed(const QKeyEvent&)), |
a2467631ae02
Revision: 201023
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
27
diff
changeset
|
103 |
this, SLOT(sendLongPressEvent(const QKeyEvent&))); |
a2467631ae02
Revision: 201023
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
27
diff
changeset
|
104 |
QObject::connect(this, SIGNAL(pressedButtonChanged(const QKeyEvent&, |
a2467631ae02
Revision: 201023
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
27
diff
changeset
|
105 |
const QKeyEvent&)), |
a2467631ae02
Revision: 201023
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
27
diff
changeset
|
106 |
this, SLOT(handleKeyChangeEvent(const QKeyEvent&, |
a2467631ae02
Revision: 201023
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
27
diff
changeset
|
107 |
const QKeyEvent&))); |
12
ae8abd0db65c
Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
108 |
|
31
a2467631ae02
Revision: 201023
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
27
diff
changeset
|
109 |
// create call button (parent layouts this) |
a2467631ae02
Revision: 201023
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
27
diff
changeset
|
110 |
mCallButton = new DialpadButton(parent); |
a2467631ae02
Revision: 201023
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
27
diff
changeset
|
111 |
mCallButton->setButtonType(DialpadButton::CallButton); |
a2467631ae02
Revision: 201023
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
27
diff
changeset
|
112 |
mCallButton->setIcon(HbIcon(handsetIcon)); |
a2467631ae02
Revision: 201023
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
27
diff
changeset
|
113 |
QString buttonName; |
a2467631ae02
Revision: 201023
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
27
diff
changeset
|
114 |
buttonName.setNum(Qt::Key_Yes); |
a2467631ae02
Revision: 201023
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
27
diff
changeset
|
115 |
mCallButton->setObjectName(buttonName); |
a2467631ae02
Revision: 201023
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
27
diff
changeset
|
116 |
connect(mCallButton,SIGNAL(clicked()), |
a2467631ae02
Revision: 201023
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
27
diff
changeset
|
117 |
mKeyClickedSignalMapper,SLOT(map())); |
a2467631ae02
Revision: 201023
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
27
diff
changeset
|
118 |
connect(mCallButton,SIGNAL(longPress(QPointF)), |
a2467631ae02
Revision: 201023
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
27
diff
changeset
|
119 |
mKeyClickedSignalMapper,SLOT(map())); |
a2467631ae02
Revision: 201023
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
27
diff
changeset
|
120 |
mKeyClickedSignalMapper->setMapping(mCallButton, |
a2467631ae02
Revision: 201023
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
27
diff
changeset
|
121 |
Qt::Key_Yes); |
12
ae8abd0db65c
Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
122 |
|
ae8abd0db65c
Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
123 |
// set button texts |
ae8abd0db65c
Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
124 |
setButtonTexts(); |
31
a2467631ae02
Revision: 201023
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
27
diff
changeset
|
125 |
// set button icons |
33 | 126 |
button(0)->setIcon(HbIcon(vmbxIcon)); |
31
a2467631ae02
Revision: 201023
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
27
diff
changeset
|
127 |
|
12
ae8abd0db65c
Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
128 |
// update button texts when input language is changed |
ae8abd0db65c
Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
129 |
connect(HbInputSettingProxy::instance(), |
ae8abd0db65c
Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
130 |
SIGNAL(globalInputLanguageChanged(HbInputLanguage)), |
ae8abd0db65c
Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
131 |
this,SLOT(setButtonTexts())); |
33 | 132 |
|
133 |
updateColorArray(); |
|
134 |
||
135 |
mUnit = HbDeviceProfile::profile(this).unitValue(); |
|
12
ae8abd0db65c
Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
136 |
} |
ae8abd0db65c
Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
137 |
|
ae8abd0db65c
Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
138 |
DialpadKeypad::~DialpadKeypad() |
ae8abd0db65c
Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
139 |
{ |
ae8abd0db65c
Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
140 |
} |
ae8abd0db65c
Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
141 |
|
ae8abd0db65c
Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
142 |
void DialpadKeypad::setButtonTexts() |
ae8abd0db65c
Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
143 |
{ |
ae8abd0db65c
Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
144 |
HbInputLanguage inputLanguage = |
ae8abd0db65c
Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
145 |
HbInputSettingProxy::instance()->globalInputLanguage(); |
ae8abd0db65c
Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
146 |
const HbKeymap *keymap = |
ae8abd0db65c
Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
147 |
HbKeymapFactory::instance()->keymap(inputLanguage.language()); |
ae8abd0db65c
Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
148 |
|
ae8abd0db65c
Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
149 |
mGeneratedChar.clear(); |
ae8abd0db65c
Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
150 |
|
ae8abd0db65c
Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
151 |
if (keymap) { |
31
a2467631ae02
Revision: 201023
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
27
diff
changeset
|
152 |
int buttonCount = (DialpadRowCount*DialpadColumnCount); |
a2467631ae02
Revision: 201023
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
27
diff
changeset
|
153 |
for (int i = 0; i < buttonCount; i++) { |
a2467631ae02
Revision: 201023
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
27
diff
changeset
|
154 |
int keyCode = DialpadKeyCodeTable[i]; |
12
ae8abd0db65c
Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
155 |
|
ae8abd0db65c
Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
156 |
if (keyCode == Qt::Key_Asterisk) { |
ae8abd0db65c
Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
157 |
// asterisk is not localized |
ae8abd0db65c
Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
158 |
QChar asterisk('*'); |
33 | 159 |
button(i)->setText(asterisk); |
160 |
button(i)->setSecondaryText(QLatin1String("+")); |
|
12
ae8abd0db65c
Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
161 |
mGeneratedChar.insert(Qt::Key_Asterisk, asterisk); |
ae8abd0db65c
Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
162 |
continue; |
ae8abd0db65c
Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
163 |
} |
ae8abd0db65c
Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
164 |
|
ae8abd0db65c
Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
165 |
if (keyCode == Qt::Key_NumberSign) { |
ae8abd0db65c
Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
166 |
// number sign is not localized |
ae8abd0db65c
Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
167 |
QChar numberSign('#'); |
33 | 168 |
button(i)->setText(numberSign); |
12
ae8abd0db65c
Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
169 |
mGeneratedChar.insert(Qt::Key_NumberSign, numberSign); |
ae8abd0db65c
Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
170 |
continue; |
ae8abd0db65c
Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
171 |
} |
ae8abd0db65c
Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
172 |
|
ae8abd0db65c
Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
173 |
int index = i; |
ae8abd0db65c
Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
174 |
if (keyCode==Qt::Key_0) { |
ae8abd0db65c
Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
175 |
index = i-1; |
ae8abd0db65c
Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
176 |
} |
ae8abd0db65c
Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
177 |
|
ae8abd0db65c
Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
178 |
const HbMappedKey *key = |
ae8abd0db65c
Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
179 |
keymap->keyForIndex(HbKeyboardVirtual12Key, index); |
ae8abd0db65c
Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
180 |
|
ae8abd0db65c
Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
181 |
if (key) { |
ae8abd0db65c
Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
182 |
QChar numberChar = |
ae8abd0db65c
Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
183 |
HbInputUtils::findFirstNumberCharacterBoundToKey( |
ae8abd0db65c
Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
184 |
key, |
33 | 185 |
inputLanguage.language(), |
186 |
HbInputUtils::inputDigitType(inputLanguage.language())); |
|
12
ae8abd0db65c
Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
187 |
|
ae8abd0db65c
Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
188 |
// button text |
33 | 189 |
button(i)->setText(numberChar); |
12
ae8abd0db65c
Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
190 |
mGeneratedChar.insert(keyCode,numberChar); |
ae8abd0db65c
Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
191 |
|
ae8abd0db65c
Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
192 |
// additional text (letters) |
ae8abd0db65c
Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
193 |
int numberOfCharacters; |
ae8abd0db65c
Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
194 |
if (keyCode==Qt::Key_7 || keyCode == Qt::Key_9) { |
ae8abd0db65c
Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
195 |
numberOfCharacters = 4; |
ae8abd0db65c
Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
196 |
} else if (keyCode==Qt::Key_0||keyCode==Qt::Key_1) { |
ae8abd0db65c
Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
197 |
numberOfCharacters = 0; |
ae8abd0db65c
Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
198 |
} else { |
ae8abd0db65c
Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
199 |
numberOfCharacters = 3; |
ae8abd0db65c
Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
200 |
} |
ae8abd0db65c
Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
201 |
|
ae8abd0db65c
Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
202 |
QString characters = key->characters(HbModifierNone); |
ae8abd0db65c
Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
203 |
|
33 | 204 |
if (numberOfCharacters!=0 && keyCode!=Qt::Key_1) { |
205 |
button(i)->setSecondaryText(characters.left(numberOfCharacters)); |
|
12
ae8abd0db65c
Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
206 |
} |
ae8abd0db65c
Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
207 |
} |
ae8abd0db65c
Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
208 |
} |
ae8abd0db65c
Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
209 |
} |
ae8abd0db65c
Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
210 |
} |
ae8abd0db65c
Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
211 |
|
ae8abd0db65c
Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
212 |
void DialpadKeypad::handleKeyClicked(int key) |
ae8abd0db65c
Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
213 |
{ |
31
a2467631ae02
Revision: 201023
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
27
diff
changeset
|
214 |
// concerns only yes and backspace keys |
a2467631ae02
Revision: 201023
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
27
diff
changeset
|
215 |
postKeyEvent(QEvent::KeyPress, key); |
12
ae8abd0db65c
Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
216 |
postKeyEvent(QEvent::KeyRelease, key); |
ae8abd0db65c
Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
217 |
} |
ae8abd0db65c
Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
218 |
|
ae8abd0db65c
Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
219 |
void DialpadKeypad::postKeyEvent(QEvent::Type type, int key) |
ae8abd0db65c
Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
220 |
{ |
31
a2467631ae02
Revision: 201023
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
27
diff
changeset
|
221 |
// send simulated key to application |
12
ae8abd0db65c
Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
222 |
QKeyEvent *keyEvent = new QKeyEvent(type, key, Qt::NoModifier); |
13
e32024264ebb
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
12
diff
changeset
|
223 |
HbApplication::postEvent(const_cast<HbMainWindow*>(&mMainWindow),keyEvent); |
12
ae8abd0db65c
Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
224 |
} |
ae8abd0db65c
Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
225 |
|
ae8abd0db65c
Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
226 |
void DialpadKeypad::sendKeyEventToEditor(QEvent::Type type, int key) |
ae8abd0db65c
Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
227 |
{ |
31
a2467631ae02
Revision: 201023
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
27
diff
changeset
|
228 |
// send key event to editor |
12
ae8abd0db65c
Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
229 |
QKeyEvent keyEvent(type, key, Qt::NoModifier, mGeneratedChar.value(key)); |
ae8abd0db65c
Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
230 |
HbApplication::sendEvent(&mInputField.editor(), &keyEvent); |
ae8abd0db65c
Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
231 |
} |
ae8abd0db65c
Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
232 |
|
31
a2467631ae02
Revision: 201023
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
27
diff
changeset
|
233 |
void DialpadKeypad::sendKeyPressEvent(const QKeyEvent& event) |
a2467631ae02
Revision: 201023
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
27
diff
changeset
|
234 |
{ |
33 | 235 |
updateButtonLabels(); |
31
a2467631ae02
Revision: 201023
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
27
diff
changeset
|
236 |
mPressedNumericKey = event.key(); |
a2467631ae02
Revision: 201023
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
27
diff
changeset
|
237 |
postKeyEvent(QEvent::KeyPress, event.key()); |
a2467631ae02
Revision: 201023
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
27
diff
changeset
|
238 |
} |
a2467631ae02
Revision: 201023
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
27
diff
changeset
|
239 |
|
a2467631ae02
Revision: 201023
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
27
diff
changeset
|
240 |
void DialpadKeypad::sendKeyReleaseEvent(const QKeyEvent& event) |
12
ae8abd0db65c
Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
241 |
{ |
31
a2467631ae02
Revision: 201023
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
27
diff
changeset
|
242 |
if (mPressedNumericKey) { |
a2467631ae02
Revision: 201023
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
27
diff
changeset
|
243 |
// short press, update editor here |
a2467631ae02
Revision: 201023
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
27
diff
changeset
|
244 |
sendKeyEventToEditor(QEvent::KeyPress, event.key()); |
a2467631ae02
Revision: 201023
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
27
diff
changeset
|
245 |
} |
a2467631ae02
Revision: 201023
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
27
diff
changeset
|
246 |
|
a2467631ae02
Revision: 201023
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
27
diff
changeset
|
247 |
postKeyEvent(QEvent::KeyRelease, event.key()); |
a2467631ae02
Revision: 201023
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
27
diff
changeset
|
248 |
} |
a2467631ae02
Revision: 201023
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
27
diff
changeset
|
249 |
|
a2467631ae02
Revision: 201023
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
27
diff
changeset
|
250 |
void DialpadKeypad::sendLongPressEvent(const QKeyEvent& event) |
a2467631ae02
Revision: 201023
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
27
diff
changeset
|
251 |
{ |
a2467631ae02
Revision: 201023
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
27
diff
changeset
|
252 |
sendKeyEventToEditor(QEvent::KeyPress, event.key()); |
12
ae8abd0db65c
Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
253 |
mPressedNumericKey = 0; |
ae8abd0db65c
Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
254 |
} |
ae8abd0db65c
Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
255 |
|
31
a2467631ae02
Revision: 201023
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
27
diff
changeset
|
256 |
void DialpadKeypad::handleKeyChangeEvent( |
a2467631ae02
Revision: 201023
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
27
diff
changeset
|
257 |
const QKeyEvent& releaseEvent, |
a2467631ae02
Revision: 201023
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
27
diff
changeset
|
258 |
const QKeyEvent& pressEvent) |
12
ae8abd0db65c
Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
259 |
{ |
31
a2467631ae02
Revision: 201023
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
27
diff
changeset
|
260 |
Q_UNUSED(pressEvent) |
12
ae8abd0db65c
Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
261 |
|
31
a2467631ae02
Revision: 201023
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
27
diff
changeset
|
262 |
postKeyEvent(QEvent::KeyRelease, releaseEvent.key()); |
a2467631ae02
Revision: 201023
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
27
diff
changeset
|
263 |
cancelButtonPress(); |
12
ae8abd0db65c
Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
264 |
} |
ae8abd0db65c
Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
265 |
|
ae8abd0db65c
Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
266 |
void DialpadKeypad::setCallButtonEnabled(bool enabled) |
ae8abd0db65c
Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
267 |
{ |
31
a2467631ae02
Revision: 201023
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
27
diff
changeset
|
268 |
mCallButton->setEnabled(enabled); |
12
ae8abd0db65c
Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
269 |
} |
19
e44a8c097b15
Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
15
diff
changeset
|
270 |
|
e44a8c097b15
Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
15
diff
changeset
|
271 |
void DialpadKeypad::resetButtons() |
e44a8c097b15
Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
15
diff
changeset
|
272 |
{ |
31
a2467631ae02
Revision: 201023
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
27
diff
changeset
|
273 |
cancelButtonPress(); |
a2467631ae02
Revision: 201023
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
27
diff
changeset
|
274 |
mCallButton->setDown(false); |
19
e44a8c097b15
Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
15
diff
changeset
|
275 |
} |
31
a2467631ae02
Revision: 201023
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
27
diff
changeset
|
276 |
|
a2467631ae02
Revision: 201023
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
27
diff
changeset
|
277 |
DialpadButton& DialpadKeypad::callButton() const |
a2467631ae02
Revision: 201023
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
27
diff
changeset
|
278 |
{ |
a2467631ae02
Revision: 201023
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
27
diff
changeset
|
279 |
return *mCallButton; |
a2467631ae02
Revision: 201023
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
27
diff
changeset
|
280 |
} |
33 | 281 |
|
282 |
DialpadNumericButton* DialpadKeypad::button(int i) const |
|
283 |
{ |
|
284 |
return static_cast<DialpadNumericButton*>(HbInputButtonGroup::button(i)); |
|
285 |
} |
|
286 |
||
287 |
void DialpadKeypad::updateButtonLabels() |
|
288 |
{ |
|
289 |
// update numeric buttons according to button state (pressed/released) |
|
290 |
updateIconColor(); |
|
291 |
updateTextLayouts(rect().size()); |
|
292 |
} |
|
293 |
||
294 |
void DialpadKeypad::paint( |
|
295 |
QPainter* painter, |
|
296 |
const QStyleOptionGraphicsItem* option, |
|
297 |
QWidget* widget) |
|
298 |
{ |
|
299 |
Q_UNUSED(option); |
|
300 |
Q_UNUSED(widget); |
|
301 |
||
302 |
// Paints empty buttons |
|
303 |
HbInputButtonGroup::paint(painter,option,widget); |
|
304 |
||
305 |
qreal cellWidth = boundingRect().width() / gridSize().width(); |
|
306 |
qreal cellHeight = boundingRect().height() / gridSize().height(); |
|
307 |
||
308 |
// Draw icons |
|
309 |
for (int i = 0; i < DialpadRowCount * DialpadColumnCount; i++) { |
|
310 |
DialpadNumericButton *item = button(i); |
|
311 |
||
312 |
if (!item->icon().isNull()) { |
|
313 |
// icon is centered to button |
|
314 |
qreal x = (item->position().x() * cellWidth) + (cellWidth / 2) - |
|
315 |
((DialpadIconSize * mUnit) / 2); |
|
316 |
qreal y = (item->position().y() * cellHeight) + (cellHeight / 2) - |
|
317 |
((DialpadIconSize * mUnit) / 2); |
|
318 |
||
319 |
qreal width = DialpadIconSize * mUnit; |
|
320 |
qreal height = DialpadIconSize * mUnit; |
|
321 |
||
322 |
Qt::Alignment alignment = |
|
323 |
static_cast<Qt::Alignment>(Qt::AlignVCenter | Qt::AlignHCenter); |
|
324 |
item->icon().paint(painter, |
|
325 |
QRectF(x,y,width,height), |
|
326 |
Qt::KeepAspectRatio, |
|
327 |
alignment); |
|
328 |
} |
|
329 |
} |
|
330 |
||
331 |
// Draw texts |
|
332 |
QPen origPen = painter->pen(); |
|
333 |
for (int i = 0; i < mTextLayouts.count(); ++i) { |
|
334 |
if (i==SecondaryText) { |
|
335 |
// dimmed in normal state |
|
336 |
painter->setPen(mColors.at(Pressed+1)); |
|
337 |
} else { |
|
338 |
// otherwise normal or pressed color |
|
339 |
painter->setPen(mColors.at(i/TextTypeCount)); |
|
340 |
} |
|
341 |
mTextLayouts.at(i)->draw(painter, QPointF(0, 0)); |
|
342 |
} |
|
343 |
painter->setPen(origPen); |
|
344 |
} |
|
345 |
||
346 |
void DialpadKeypad::updateColorArray() |
|
347 |
{ |
|
348 |
mColors.clear(); |
|
349 |
||
350 |
QColor normalColor = HbColorScheme::color("qtc_input_button_normal"); |
|
351 |
mColors.insert(Normal, normalColor); |
|
352 |
||
353 |
QColor pressedColor = HbColorScheme::color("qtc_input_button_pressed"); |
|
354 |
mColors.insert(Pressed, pressedColor); |
|
355 |
||
356 |
// this is used for alphabets shown dimmed, use alpha until exact color |
|
357 |
// is specified |
|
358 |
QColor disabledColor = HbColorScheme::color("qtc_input_button_normal"); |
|
359 |
disabledColor.setAlpha(128); |
|
360 |
mColors.insert(Pressed+1, disabledColor); |
|
361 |
} |
|
362 |
||
363 |
void DialpadKeypad::updateIconColor() |
|
364 |
{ |
|
365 |
for (int i = 0; i < (DialpadRowCount * DialpadColumnCount); i++) { |
|
366 |
DialpadNumericButton *item = button(i); |
|
367 |
||
368 |
if (item->state()==HbInputButton::ButtonStatePressed) { |
|
369 |
item->icon().setColor(mColors.at(Pressed)); |
|
370 |
} else { |
|
371 |
item->icon().setColor(mColors.at(Normal)); |
|
372 |
} |
|
373 |
} |
|
374 |
} |
|
375 |
||
376 |
void DialpadKeypad::cancelButtonPress() |
|
377 |
{ |
|
378 |
HbInputButtonGroup::cancelButtonPress(); |
|
379 |
updateButtonLabels(); |
|
380 |
} |
|
381 |
||
382 |
void DialpadKeypad::setGeometry(const QRectF &rect) |
|
383 |
{ |
|
384 |
HbInputButtonGroup::setGeometry(rect); |
|
385 |
updateTextLayouts(rect.size()); |
|
386 |
} |
|
387 |
||
388 |
void DialpadKeypad::changeEvent(QEvent *event) |
|
389 |
{ |
|
390 |
HbInputButtonGroup::changeEvent(event); |
|
391 |
||
392 |
if (event->type() == HbEvent::ThemeChanged) { |
|
393 |
updateColorArray(); |
|
394 |
updateIconColor(); |
|
395 |
} |
|
396 |
} |
|
397 |
||
398 |
void DialpadKeypad::updateTextLayouts(const QSizeF &size) |
|
399 |
{ |
|
400 |
if (!size.width() && !size.height()) { |
|
401 |
return; |
|
402 |
} |
|
403 |
||
404 |
// get normal and pressed state texts |
|
405 |
QList<QString> textContent; |
|
406 |
resolveTextContent(textContent); |
|
407 |
||
408 |
// layout the texts |
|
409 |
createTextLayouts(size, textContent); |
|
410 |
} |
|
411 |
||
412 |
void DialpadKeypad::resolveTextContent(QList<QString> &content) |
|
413 |
{ |
|
414 |
QString normalState; |
|
415 |
QString normalStateSecondary; |
|
416 |
QString pressedState; |
|
417 |
QString pressedStateSecondary; |
|
418 |
||
419 |
for (int i = 0; i < (DialpadRowCount*DialpadColumnCount); i++) { |
|
420 |
DialpadNumericButton *item = button(i); |
|
421 |
if (item->state()==HbInputButton::ButtonStatePressed) { |
|
422 |
if (item->text().length()) { |
|
423 |
pressedState.append(item->text()); |
|
424 |
pressedState.append(QChar(QChar::LineSeparator)); |
|
425 |
} |
|
426 |
||
427 |
if (item->secondaryText().length()) { |
|
428 |
pressedStateSecondary.append(item->secondaryText()); |
|
429 |
pressedStateSecondary.append(QChar(QChar::LineSeparator)); |
|
430 |
} |
|
431 |
} else { // ButtonStateNormal |
|
432 |
if (item->text().length()) { |
|
433 |
normalState.append(item->text()); |
|
434 |
normalState.append(QChar(QChar::LineSeparator)); |
|
435 |
} |
|
436 |
||
437 |
if (item->secondaryText().length()) { |
|
438 |
normalStateSecondary.append(item->secondaryText()); |
|
439 |
normalStateSecondary.append(QChar(QChar::LineSeparator)); |
|
440 |
} |
|
441 |
} |
|
442 |
} |
|
443 |
||
444 |
content.insert(PrimaryText, normalState); |
|
445 |
content.insert(SecondaryText, normalStateSecondary); |
|
446 |
content.insert(TextTypeCount + Pressed, pressedState); |
|
447 |
content.insert(StateCount + SecondaryText, pressedStateSecondary); |
|
448 |
} |
|
449 |
||
450 |
void DialpadKeypad::createTextLayouts( |
|
451 |
const QSizeF &size, const QList<QString> &content) |
|
452 |
{ |
|
453 |
// clear old layouts |
|
454 |
qDeleteAll(mTextLayouts); |
|
455 |
mTextLayouts.clear(); |
|
456 |
||
457 |
if (content.count()==2) { |
|
458 |
// line width is measured only when all buttons are in normal state |
|
459 |
mMaxPrimaryLineWidth = 0; |
|
460 |
} |
|
461 |
||
462 |
QFont primaryfFont = HbFontSpec(HbFontSpec::Primary).font(); |
|
463 |
primaryfFont.setPixelSize(DialpadPrimaryTextSize * mUnit); |
|
464 |
||
465 |
QFont secondaryFont = HbFontSpec(HbFontSpec::Secondary).font(); |
|
466 |
secondaryFont.setPixelSize(DialpadSecondaryTextSize * mUnit); |
|
467 |
||
468 |
for (int i=0; i < (StateCount*TextTypeCount); i++ ) { |
|
469 |
QString text = content.at(i); |
|
470 |
||
471 |
if (!text.isNull()) { |
|
472 |
QTextLayout* textLayout; |
|
473 |
int type; |
|
474 |
||
475 |
if (i%TextTypeCount) { |
|
476 |
textLayout = new QTextLayout(text,secondaryFont); |
|
477 |
type = SecondaryText; |
|
478 |
} else { |
|
479 |
textLayout = new QTextLayout(text,primaryfFont); |
|
480 |
type = PrimaryText; |
|
481 |
} |
|
482 |
||
483 |
mTextLayouts.append(textLayout); |
|
484 |
||
485 |
textLayout->beginLayout(); |
|
486 |
||
487 |
int state = (i>=TextTypeCount) ? Pressed : Normal; |
|
488 |
||
489 |
layoutTextLines(size,*textLayout,state,type); |
|
490 |
||
491 |
textLayout->endLayout(); |
|
492 |
||
493 |
textLayout->setCacheEnabled(true); |
|
494 |
} |
|
495 |
} |
|
496 |
} |
|
497 |
||
498 |
void DialpadKeypad::layoutTextLines( |
|
499 |
const QSizeF &size, |
|
500 |
QTextLayout &textLayout, |
|
501 |
int state, |
|
502 |
int type) |
|
503 |
{ |
|
504 |
QFontMetricsF fontMetrics(textLayout.font()); |
|
505 |
qreal textHeight = fontMetrics.height(); |
|
506 |
||
507 |
qreal cellWidth = size.width() / gridSize().width(); |
|
508 |
qreal cellHeight = size.height() / gridSize().height(); |
|
509 |
qreal maxLineWidth = 0; |
|
510 |
||
511 |
for (int j = 0; j < (DialpadRowCount*DialpadColumnCount); j++) { |
|
512 |
DialpadNumericButton *item = button(j); |
|
513 |
||
514 |
if ((type==PrimaryText && item->text().isNull()) || |
|
515 |
(type==SecondaryText && item->secondaryText().isNull())) { |
|
516 |
continue; // no text for this button -> next button |
|
517 |
} |
|
518 |
||
519 |
if ( ( state==Normal && |
|
520 |
item->state()==HbInputButton::ButtonStateReleased ) || |
|
521 |
( state==Pressed && |
|
522 |
item->state()==HbInputButton::ButtonStatePressed ) ) { |
|
523 |
||
524 |
QTextLine line = textLayout.createLine(); |
|
525 |
||
526 |
qreal textPositionX = 0; |
|
527 |
qreal textPositionY = 0; |
|
528 |
||
529 |
if (line.isValid()) { |
|
530 |
line.setNumColumns(item->text().length()); |
|
531 |
// layout text line |
|
532 |
if (type==SecondaryText) { |
|
533 |
if (j==9) { |
|
534 |
// + is centered to button |
|
535 |
qreal lineWidth = fontMetrics.width(item->text()); |
|
536 |
textPositionX = (item->position().x() * cellWidth) + |
|
537 |
(cellWidth / 2) - |
|
538 |
(lineWidth / 2); |
|
539 |
textPositionY = (item->position().y() + |
|
540 |
(0.5 * item->size().height())) * |
|
541 |
cellHeight - (0.5 * textHeight); |
|
542 |
||
543 |
} else { |
|
544 |
textPositionX = (item->position().x() * cellWidth) + |
|
545 |
(DialpadPrimaryTextLeftMargin * mUnit) + |
|
546 |
mMaxPrimaryLineWidth + |
|
547 |
(DialpadPrimarySecondaryMargin * mUnit) |
|
548 |
+ buttonBorderSize(); |
|
549 |
textPositionY = (item->position().y() + |
|
550 |
(0.5 * item->size().height())) * |
|
551 |
cellHeight - (0.5 * textHeight); |
|
552 |
} |
|
553 |
} else { |
|
554 |
textPositionX = (item->position().x() * cellWidth) + |
|
555 |
(DialpadPrimaryTextLeftMargin * mUnit) |
|
556 |
+ buttonBorderSize(); |
|
557 |
textPositionY = (item->position().y() + |
|
558 |
(0.5 * item->size().height())) * |
|
559 |
cellHeight - (0.5 * textHeight); |
|
560 |
||
561 |
// store line width, for drawing secondary text |
|
562 |
qreal lineWidth = fontMetrics.width(item->text()); |
|
563 |
if (mMaxPrimaryLineWidth == 0 && (j>0 && j<10) && |
|
564 |
lineWidth > maxLineWidth) { |
|
565 |
maxLineWidth = lineWidth; |
|
566 |
} |
|
567 |
} |
|
568 |
} |
|
569 |
||
570 |
line.setPosition(QPointF(textPositionX, textPositionY)); |
|
571 |
} |
|
572 |
} |
|
573 |
||
574 |
mMaxPrimaryLineWidth = maxLineWidth; |
|
575 |
} |