author | Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com> |
Mon, 04 Oct 2010 00:13:15 +0300 | |
changeset 72 | 6f657153cbc5 |
parent 70 | a15d9966050f |
permissions | -rw-r--r-- |
31 | 1 |
/* |
2 |
* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). |
|
3 |
* All rights reserved. |
|
4 |
* This component and the accompanying materials are made available |
|
5 |
* under the terms of "Eclipse Public License v1.0" |
|
6 |
* which accompanies this distribution, and is available |
|
7 |
* at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
8 |
* |
|
9 |
* Initial Contributors: |
|
10 |
* Nokia Corporation - initial contribution. |
|
11 |
* |
|
12 |
* Contributors: |
|
13 |
* |
|
14 |
* Description: |
|
15 |
* |
|
16 |
*/ |
|
17 |
||
18 |
#include "msgeditorwidget.h" |
|
19 |
||
20 |
// SYSTEM INCLUDES |
|
21 |
#include <HbStyle> |
|
22 |
#include <HbPushButton> |
|
23 |
#include <HbTextItem> |
|
24 |
#include <qgraphicsscene.h> |
|
25 |
#include <HbFrameDrawer> |
|
26 |
#include <HbFrameItem> |
|
27 |
#include <HbAction> |
|
28 |
#include <csmsaccount.h> |
|
29 |
#include <smutset.h> |
|
30 |
#include <hbmessagebox.h> |
|
52
12db4185673b
Revision: 201031
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
44
diff
changeset
|
31 |
#include <hbcolorscheme.h> |
12db4185673b
Revision: 201031
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
44
diff
changeset
|
32 |
#include <QColor> |
31 | 33 |
#include <QTimer> |
34 |
#include "unieditorpluginloader.h" |
|
35 |
#include "unieditorplugininterface.h" |
|
34
84197e66a4bd
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
31
diff
changeset
|
36 |
#include "UniSendingSettings.h" |
84197e66a4bd
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
31
diff
changeset
|
37 |
#include "UniEditorGenUtils.h" |
31 | 38 |
#include "debugtraces.h" |
39 |
||
40 |
// LOCAL CONSTANTS |
|
41 |
||
42 |
const QString SEND_ICON("qtg_mono_send"); |
|
34
84197e66a4bd
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
31
diff
changeset
|
43 |
const QString BACKGROUND("qtg_fr_input_v_bg"); |
52
12db4185673b
Revision: 201031
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
44
diff
changeset
|
44 |
const QString BACKGROUND_FRAME("qtg_fr_messaging_char_count"); |
12db4185673b
Revision: 201031
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
44
diff
changeset
|
45 |
const QString CHAR_COUNTER_COLOR("qtc_messaging_char_count"); |
31 | 46 |
|
52
12db4185673b
Revision: 201031
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
44
diff
changeset
|
47 |
const QString SEND_BUTTON_NORMAL("qtg_fr_btn_green_normal"); |
12db4185673b
Revision: 201031
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
44
diff
changeset
|
48 |
const QString SEND_BUTTON_PRESSED("qtg_fr_btn_green_pressed"); |
12db4185673b
Revision: 201031
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
44
diff
changeset
|
49 |
const QString SEND_BUTTON_DISABLED("qtg_fr_btn_disabled"); |
12db4185673b
Revision: 201031
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
44
diff
changeset
|
50 |
|
12db4185673b
Revision: 201031
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
44
diff
changeset
|
51 |
const QString SEND_BUTTON_NORMAL_COLOR("qtc_callhandling_answer_normal"); |
12db4185673b
Revision: 201031
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
44
diff
changeset
|
52 |
const QString SEND_BUTTON_PRESSED_COLOR("qtc_callhandling_answer_pressed"); |
12db4185673b
Revision: 201031
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
44
diff
changeset
|
53 |
const QString SEND_BUTTON_DISABLED_COLOR("qtc_button_disabled"); |
31 | 54 |
|
55 |
#define LOC_SMS_CHAR_LIMIT_REACHED hbTrId("txt_messaging_dialog_sms_character_count_exceeded") |
|
34
84197e66a4bd
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
31
diff
changeset
|
56 |
#define LOC_HINT_TEXT hbTrId("txt_messaging_formlabel_enter_message_here") |
84197e66a4bd
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
31
diff
changeset
|
57 |
|
31 | 58 |
|
59 |
const TInt KShowCounterLimit = 10; |
|
60 |
||
61 |
QGraphicsItem* FOCUSITEM = 0; |
|
62 |
||
63 |
//--------------------------------------------------------------- |
|
64 |
// MsgEditorWidget::MsgEditorWidget |
|
65 |
// @see header |
|
66 |
//--------------------------------------------------------------- |
|
67 |
MsgEditorWidget::MsgEditorWidget(QGraphicsItem *parent) : |
|
72
6f657153cbc5
Revision: 201037
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
70
diff
changeset
|
68 |
HbWidget(parent), mMsgEditor(0), mSendButton(0), mPluginInterface(0), mPluginLoader(0), |
6f657153cbc5
Revision: 201037
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
70
diff
changeset
|
69 |
mSmsCharLimitReached(false) |
31 | 70 |
{ |
71 |
//setting background. |
|
72 |
HbFrameItem* backGround = new HbFrameItem(this); |
|
73 |
backGround->frameDrawer().setFrameGraphicsName(BACKGROUND); |
|
74 |
backGround->frameDrawer().setFrameType(HbFrameDrawer::ThreePiecesVertical); |
|
75 |
backGround->frameDrawer().setFillWholeRect(true); |
|
76 |
this->setBackgroundItem(backGround); |
|
77 |
||
78 |
// Initialize the widget. |
|
79 |
init(); |
|
80 |
} |
|
81 |
||
82 |
//--------------------------------------------------------------- |
|
83 |
// MsgEditorWidget::init |
|
84 |
// @see header |
|
85 |
//--------------------------------------------------------------- |
|
86 |
void MsgEditorWidget::init() |
|
87 |
{ |
|
88 |
// Create mandatory element of mesh layout. |
|
89 |
mMsgEditor = new MsgEditor(this); |
|
90 |
mMsgEditor->setMaxRows(3); // NOTE: Don't remove this line. |
|
91 |
HbStyle::setItemName(mMsgEditor, "msgEditor"); |
|
92 |
||
43
35b64624a9e7
Revision: 201023
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
34
diff
changeset
|
93 |
mSendButton = new HbPushButton(this); |
35b64624a9e7
Revision: 201023
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
34
diff
changeset
|
94 |
HbStyle::setItemName(mSendButton, "sendButton"); |
35b64624a9e7
Revision: 201023
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
34
diff
changeset
|
95 |
mSendButton->setEnabled(false); |
35b64624a9e7
Revision: 201023
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
34
diff
changeset
|
96 |
|
35b64624a9e7
Revision: 201023
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
34
diff
changeset
|
97 |
HbFrameItem* backGround = new HbFrameItem(this); |
35b64624a9e7
Revision: 201023
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
34
diff
changeset
|
98 |
backGround->frameDrawer().setFrameType(HbFrameDrawer::NinePieces); |
35b64624a9e7
Revision: 201023
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
34
diff
changeset
|
99 |
mSendButton->setBackgroundItem(backGround); |
52
12db4185673b
Revision: 201031
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
44
diff
changeset
|
100 |
updateButtonBackgroundAndColor(SEND_BUTTON_DISABLED,SEND_BUTTON_DISABLED_COLOR); |
31 | 101 |
mSendButton->setIcon(HbIcon(SEND_ICON)); |
102 |
||
103 |
mCharCounter = new HbTextItem(this); |
|
104 |
HbStyle::setItemName(mCharCounter, "charCounter"); |
|
105 |
mCharCounter->setZValue(1.5); |
|
106 |
||
52
12db4185673b
Revision: 201031
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
44
diff
changeset
|
107 |
QColor color = HbColorScheme::color(CHAR_COUNTER_COLOR); |
12db4185673b
Revision: 201031
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
44
diff
changeset
|
108 |
mCharCounter->setTextColor(color); |
12db4185673b
Revision: 201031
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
44
diff
changeset
|
109 |
|
31 | 110 |
mBackgroundItem = new HbFrameItem(this); |
111 |
HbStyle::setItemName(mBackgroundItem, "charCounterFrame"); |
|
112 |
||
52
12db4185673b
Revision: 201031
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
44
diff
changeset
|
113 |
mBackgroundItem->frameDrawer().setFrameType(HbFrameDrawer::ThreePiecesHorizontal); |
31 | 114 |
mBackgroundItem->frameDrawer().setFillWholeRect(true); |
115 |
||
116 |
mBackgroundItem->frameDrawer().setFrameGraphicsName( |
|
117 |
BACKGROUND_FRAME); |
|
118 |
||
119 |
//Create editor utils object |
|
52
12db4185673b
Revision: 201031
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
44
diff
changeset
|
120 |
mEditorUtils = q_check_ptr(new UniEditorGenUtils()); |
12db4185673b
Revision: 201031
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
44
diff
changeset
|
121 |
|
31 | 122 |
FOCUSITEM = mSendButton; |
123 |
||
124 |
||
125 |
connect(mSendButton, SIGNAL(clicked()),this, SLOT(onClicked())); |
|
126 |
connect(mSendButton, SIGNAL(pressed()),this, SLOT(onPressed())); |
|
127 |
connect(mSendButton, SIGNAL(released()),this, SLOT(onReleased())); |
|
128 |
connect(mMsgEditor, SIGNAL(replyStarted()),this, SIGNAL(replyStarted())); |
|
129 |
connect(mMsgEditor, SIGNAL(textChanged(QString)),this,SLOT(onTextChanged(QString))); |
|
130 |
||
131 |
} |
|
132 |
||
133 |
//--------------------------------------------------------------- |
|
134 |
// MsgEditorWidget::~MsgEditorWidget |
|
135 |
// @see header |
|
136 |
//--------------------------------------------------------------- |
|
137 |
MsgEditorWidget::~MsgEditorWidget() |
|
138 |
{ |
|
139 |
delete mEditorUtils; |
|
140 |
} |
|
141 |
||
142 |
//--------------------------------------------------------------- |
|
143 |
// MsgEditorWidget::content |
|
144 |
// @see header |
|
145 |
//--------------------------------------------------------------- |
|
146 |
QString MsgEditorWidget::content() const |
|
147 |
{ |
|
148 |
return mMsgEditor->text(); |
|
149 |
} |
|
150 |
||
151 |
//--------------------------------------------------------------- |
|
152 |
// MsgEditorWidget::setContent |
|
153 |
// @see header |
|
154 |
//--------------------------------------------------------------- |
|
155 |
void MsgEditorWidget::setContent(const QString &text) |
|
156 |
{ |
|
157 |
mMsgEditor->setText(text); |
|
158 |
} |
|
159 |
||
160 |
//--------------------------------------------------------------- |
|
161 |
// MsgEditorWidget::clear |
|
162 |
// @see header |
|
163 |
//--------------------------------------------------------------- |
|
164 |
void MsgEditorWidget::clear() |
|
165 |
{ |
|
166 |
mMsgEditor->setText(QString()); |
|
167 |
mMsgEditor->setCursorVisibility(Hb::TextCursorHidden); |
|
168 |
} |
|
169 |
||
170 |
//--------------------------------------------------------------- |
|
171 |
// MsgEditorWidget::onTextChanged |
|
172 |
// @see header |
|
173 |
//--------------------------------------------------------------- |
|
174 |
void MsgEditorWidget::onTextChanged(const QString& str) |
|
175 |
{ |
|
176 |
//If char limit is already reached we are about to show the sms limit dialog |
|
177 |
//So we need not process the additional character entered |
|
178 |
if(mSmsCharLimitReached) |
|
179 |
{ |
|
180 |
return; |
|
181 |
} |
|
182 |
if(str.length() > 0 ) |
|
183 |
{ |
|
184 |
if(!mSendButton->isEnabled()) |
|
185 |
{ |
|
186 |
mSendButton->setFocusProxy(mMsgEditor); |
|
187 |
mSendButton->setEnabled(true); |
|
52
12db4185673b
Revision: 201031
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
44
diff
changeset
|
188 |
updateButtonBackgroundAndColor(SEND_BUTTON_NORMAL,SEND_BUTTON_NORMAL_COLOR); |
31 | 189 |
} |
190 |
} |
|
191 |
else |
|
192 |
{ |
|
193 |
if(mSendButton->isEnabled()) |
|
194 |
{ |
|
195 |
mSendButton->setFocusProxy(0); |
|
196 |
mSendButton->setEnabled(false); |
|
52
12db4185673b
Revision: 201031
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
44
diff
changeset
|
197 |
updateButtonBackgroundAndColor(SEND_BUTTON_DISABLED,SEND_BUTTON_DISABLED_COLOR); |
31 | 198 |
} |
199 |
} |
|
200 |
||
201 |
//Check done for optimization |
|
202 |
//Only if content is deleted we need to call encodingsettings again |
|
72
6f657153cbc5
Revision: 201037
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
70
diff
changeset
|
203 |
if (mPrevBuffer.isEmpty() || str.size() <= mPrevBuffer.size()) |
31 | 204 |
{ |
72
6f657153cbc5
Revision: 201037
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
70
diff
changeset
|
205 |
mPluginInterface->setEncodingSettings(EFalse,ESmsEncodingNone,mCharSupportType); |
31 | 206 |
} |
207 |
||
208 |
TInt numOfRemainingChars; |
|
209 |
TInt numOfPDUs; |
|
210 |
TBool unicodeMode; |
|
211 |
TSmsEncoding alternativeEncodingType; |
|
212 |
QString string = str; |
|
213 |
mPluginInterface->getNumPDUs(string, numOfRemainingChars, numOfPDUs, |
|
214 |
unicodeMode, alternativeEncodingType); |
|
215 |
||
216 |
//Set char counter value |
|
217 |
QString display = QString("%1(%2)").arg(numOfRemainingChars).arg(numOfPDUs); |
|
218 |
mCharCounter->setText(display); |
|
219 |
||
220 |
if(numOfPDUs > 1 || numOfRemainingChars <= KShowCounterLimit ) |
|
221 |
{ |
|
222 |
mCharCounter->setVisible(true); |
|
223 |
mBackgroundItem->setVisible(true); |
|
224 |
} |
|
225 |
else |
|
226 |
{ |
|
227 |
mCharCounter->setVisible(false); |
|
228 |
mBackgroundItem->setVisible(false); |
|
229 |
} |
|
230 |
||
231 |
//Check if sms segment limit has been reached |
|
232 |
bool unicode = (unicodeMode) ? true : false; |
|
233 |
int contentSize = mEditorUtils->UTF8Size(string); |
|
234 |
int maxSmsSize = 0; |
|
235 |
TRAP_IGNORE(maxSmsSize = mEditorUtils->MaxSmsMsgSizeL(unicode)); |
|
236 |
||
237 |
if(contentSize > maxSmsSize) |
|
238 |
{ |
|
239 |
//Give breathing time for ITUT to complete its processing |
|
240 |
//without this there is a crash as ITUT cant complete its processing |
|
241 |
mSmsCharLimitReached = true; |
|
242 |
QTimer::singleShot(50, this, SLOT(handleSmsCharLimitReached())); |
|
243 |
if(mPrevBuffer.isEmpty()) |
|
244 |
{ |
|
245 |
//Chop the last char and set it to the editor |
|
246 |
string.chop(1); |
|
247 |
mPrevBuffer = string; |
|
248 |
} |
|
249 |
} |
|
250 |
else |
|
251 |
{ |
|
252 |
//Save the previous buffer |
|
253 |
mPrevBuffer = string; |
|
254 |
} |
|
255 |
} |
|
256 |
||
257 |
//--------------------------------------------------------------- |
|
258 |
// MsgEditorWidget::handleSmsCharLimitReached |
|
259 |
// @see header |
|
260 |
//--------------------------------------------------------------- |
|
261 |
void MsgEditorWidget::handleSmsCharLimitReached() |
|
262 |
{ |
|
263 |
mSmsCharLimitReached = false; |
|
264 |
||
265 |
HbMessageBox::question(LOC_SMS_CHAR_LIMIT_REACHED, |
|
44
36f374c67aa8
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
43
diff
changeset
|
266 |
this,SLOT(onSmsCharLimitReached(HbAction*)), |
36f374c67aa8
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
43
diff
changeset
|
267 |
HbMessageBox::Ok | HbMessageBox::Cancel); |
31 | 268 |
|
269 |
||
270 |
} |
|
271 |
||
272 |
//--------------------------------------------------------------- |
|
273 |
// MsgEditor::onClicked |
|
274 |
// @see header |
|
275 |
//--------------------------------------------------------------- |
|
276 |
void MsgEditorWidget::onClicked() |
|
277 |
{ |
|
278 |
mSendButton->setFocusProxy(0); |
|
279 |
mMsgEditor->setFocusProxy(mSendButton); |
|
280 |
||
281 |
this->scene()->clearFocus(); |
|
282 |
this->scene()->setFocusItem(mSendButton); |
|
283 |
||
284 |
mMsgEditor->setFocusProxy(0); |
|
285 |
||
286 |
mMsgEditor->setCursorVisibility(Hb::TextCursorHidden); |
|
287 |
||
288 |
emit sendMessage(); |
|
289 |
} |
|
290 |
||
291 |
//--------------------------------------------------------------- |
|
52
12db4185673b
Revision: 201031
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
44
diff
changeset
|
292 |
// MsgEditor::updateButtonBackgroundAndColor |
31 | 293 |
// @see header |
294 |
//--------------------------------------------------------------- |
|
52
12db4185673b
Revision: 201031
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
44
diff
changeset
|
295 |
void MsgEditorWidget::updateButtonBackgroundAndColor(const QString& bg,const QString& iconColor) |
43
35b64624a9e7
Revision: 201023
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
34
diff
changeset
|
296 |
{ |
35b64624a9e7
Revision: 201023
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
34
diff
changeset
|
297 |
HbFrameItem* drawer = static_cast<HbFrameItem*>(mSendButton->backgroundItem()); |
35b64624a9e7
Revision: 201023
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
34
diff
changeset
|
298 |
if(drawer) |
35b64624a9e7
Revision: 201023
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
34
diff
changeset
|
299 |
{ |
35b64624a9e7
Revision: 201023
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
34
diff
changeset
|
300 |
drawer->frameDrawer().setFrameGraphicsName(bg); |
35b64624a9e7
Revision: 201023
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
34
diff
changeset
|
301 |
} |
52
12db4185673b
Revision: 201031
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
44
diff
changeset
|
302 |
QColor color = HbColorScheme::color(iconColor); |
12db4185673b
Revision: 201031
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
44
diff
changeset
|
303 |
|
12db4185673b
Revision: 201031
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
44
diff
changeset
|
304 |
if(color.isValid()) |
12db4185673b
Revision: 201031
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
44
diff
changeset
|
305 |
{ |
12db4185673b
Revision: 201031
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
44
diff
changeset
|
306 |
mSendButton->icon().setColor(color); |
12db4185673b
Revision: 201031
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
44
diff
changeset
|
307 |
} |
43
35b64624a9e7
Revision: 201023
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
34
diff
changeset
|
308 |
} |
35b64624a9e7
Revision: 201023
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
34
diff
changeset
|
309 |
|
31 | 310 |
|
311 |
//--------------------------------------------------------------- |
|
312 |
// MsgEditor::onPressed |
|
313 |
// @see header |
|
314 |
//--------------------------------------------------------------- |
|
315 |
void MsgEditorWidget::onPressed() |
|
316 |
{ |
|
52
12db4185673b
Revision: 201031
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
44
diff
changeset
|
317 |
updateButtonBackgroundAndColor(SEND_BUTTON_PRESSED,SEND_BUTTON_PRESSED_COLOR); |
31 | 318 |
} |
319 |
||
320 |
//--------------------------------------------------------------- |
|
321 |
// MsgEditor::onReleased |
|
322 |
// @see header |
|
323 |
//--------------------------------------------------------------- |
|
324 |
void MsgEditorWidget::onReleased() |
|
325 |
{ |
|
52
12db4185673b
Revision: 201031
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
44
diff
changeset
|
326 |
updateButtonBackgroundAndColor(SEND_BUTTON_NORMAL,SEND_BUTTON_NORMAL_COLOR); |
31 | 327 |
} |
328 |
||
329 |
//--------------------------------------------------------------- |
|
330 |
// MsgEditor::setEncodingSettingsL |
|
331 |
// @see header |
|
332 |
//--------------------------------------------------------------- |
|
333 |
void MsgEditorWidget::setEncodingSettingsL() |
|
334 |
{ |
|
335 |
if( mPluginLoader ) |
|
336 |
{ |
|
337 |
delete mPluginLoader; |
|
338 |
} |
|
339 |
mPluginLoader = new UniEditorPluginLoader(this); |
|
340 |
||
341 |
mPluginInterface = |
|
342 |
mPluginLoader->getUniEditorPlugin(ConvergedMessage::Sms); |
|
343 |
||
52
12db4185673b
Revision: 201031
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
44
diff
changeset
|
344 |
QT_TRAP_THROWING( CSmsSettings* settings = CSmsSettings::NewLC(); |
12db4185673b
Revision: 201031
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
44
diff
changeset
|
345 |
CSmsAccount* account = CSmsAccount::NewLC(); |
12db4185673b
Revision: 201031
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
44
diff
changeset
|
346 |
account->LoadSettingsL( *settings ); |
31 | 347 |
|
52
12db4185673b
Revision: 201031
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
44
diff
changeset
|
348 |
if( settings->CharacterSet() == TSmsDataCodingScheme::ESmsAlphabetUCS2) |
12db4185673b
Revision: 201031
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
44
diff
changeset
|
349 |
{ |
12db4185673b
Revision: 201031
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
44
diff
changeset
|
350 |
mCharSupportType = TUniSendingSettings::EUniCharSupportFull; |
12db4185673b
Revision: 201031
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
44
diff
changeset
|
351 |
} |
12db4185673b
Revision: 201031
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
44
diff
changeset
|
352 |
else |
12db4185673b
Revision: 201031
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
44
diff
changeset
|
353 |
{ |
12db4185673b
Revision: 201031
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
44
diff
changeset
|
354 |
mCharSupportType = TUniSendingSettings::EUniCharSupportReduced; |
12db4185673b
Revision: 201031
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
44
diff
changeset
|
355 |
} |
31 | 356 |
|
52
12db4185673b
Revision: 201031
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
44
diff
changeset
|
357 |
CleanupStack::PopAndDestroy( account ); |
12db4185673b
Revision: 201031
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
44
diff
changeset
|
358 |
CleanupStack::PopAndDestroy( settings )); |
31 | 359 |
|
360 |
//Set the mPrevBuffer to NULL initially |
|
361 |
mPrevBuffer = QString(); |
|
362 |
||
363 |
mSmsCharLimitReached = false; |
|
364 |
||
365 |
mCharCounter->setVisible(false); |
|
366 |
mBackgroundItem->setVisible(false); |
|
367 |
} |
|
368 |
||
369 |
//--------------------------------------------------------------- |
|
370 |
// MsgEditor::MsgEditor |
|
371 |
// @see header |
|
372 |
//--------------------------------------------------------------- |
|
373 |
MsgEditor::MsgEditor(QGraphicsItem *parent) |
|
374 |
:HbLineEdit(parent) |
|
375 |
{ |
|
52
12db4185673b
Revision: 201031
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
44
diff
changeset
|
376 |
this->setFontSpec(HbFontSpec(HbFontSpec::Secondary)); |
34
84197e66a4bd
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
31
diff
changeset
|
377 |
this->setPlaceholderText(LOC_HINT_TEXT); |
31 | 378 |
} |
379 |
||
380 |
//--------------------------------------------------------------- |
|
381 |
// MsgEditor::focusInEvent |
|
382 |
// @see header |
|
383 |
//--------------------------------------------------------------- |
|
384 |
void MsgEditor::focusInEvent(QFocusEvent *event) |
|
70
a15d9966050f
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
52
diff
changeset
|
385 |
{ |
a15d9966050f
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
52
diff
changeset
|
386 |
HbLineEdit::focusInEvent(event); |
a15d9966050f
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
52
diff
changeset
|
387 |
FOCUSITEM->setFocusProxy(this); |
a15d9966050f
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
52
diff
changeset
|
388 |
setCursorVisibility(Hb::TextCursorVisible); |
a15d9966050f
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
52
diff
changeset
|
389 |
emit replyStarted(); |
a15d9966050f
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
52
diff
changeset
|
390 |
} |
31 | 391 |
|
392 |
//--------------------------------------------------------------- |
|
393 |
// MsgEditor::focusOutEvent |
|
394 |
// @see header |
|
395 |
//--------------------------------------------------------------- |
|
396 |
void MsgEditor::focusOutEvent(QFocusEvent * event) |
|
397 |
{ |
|
398 |
FOCUSITEM->setFocusProxy(0); |
|
399 |
setCursorVisibility(Hb::TextCursorHidden); |
|
400 |
HbLineEdit::focusOutEvent(event); |
|
401 |
} |
|
402 |
||
403 |
//--------------------------------------------------------------- |
|
404 |
// MsgEditor::onSmsCharLimitReached |
|
405 |
// @see header |
|
406 |
//--------------------------------------------------------------- |
|
407 |
void MsgEditorWidget::onSmsCharLimitReached(HbAction* action) |
|
408 |
{ |
|
409 |
HbMessageBox *dlg = qobject_cast<HbMessageBox*> (sender()); |
|
410 |
if (action == dlg->actions().at(0)) { |
|
411 |
||
412 |
//Launch UniEditor |
|
413 |
emit smsCharLimitReached(); |
|
414 |
} |
|
415 |
else { |
|
416 |
//Set the previous content |
|
417 |
setContent( QString(mPrevBuffer)); |
|
418 |
} |
|
419 |
} |
|
420 |
||
421 |
// EOF |