|
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 // INCLUDES |
|
19 #include <HbTextEdit> |
|
20 #include <HbTextItem> |
|
21 #include <HbFrameItem> |
|
22 #include <HbFrameDrawer> |
|
23 #include <HbIconItem> |
|
24 #include <HbAction> |
|
25 #include <HbMainWindow> |
|
26 #include <HbDeviceProfile> |
|
27 #include <QImageReader> |
|
28 #include <QFileInfo> |
|
29 #include <MsgMediaResolver.h> |
|
30 #include <MsgImageInfo.h> |
|
31 #include <HbIconAnimationManager> |
|
32 #include <HbIconAnimator> |
|
33 #include <HbIcon> |
|
34 #include <QGraphicsLinearLayout> |
|
35 #include <HbNotificationDialog> |
|
36 |
|
37 #include <csmsaccount.h> |
|
38 #include <smutset.h> |
|
39 #include <xqaiwrequest.h> |
|
40 #include <xqrequestinfo.h> |
|
41 #include <xqsharablefile.h> |
|
42 #include <xqappmgr.h> |
|
43 #include <xqconversions.h> |
|
44 #include <hbmessagebox.h> |
|
45 #include <hbcolorscheme.h> |
|
46 #include <QColor> |
|
47 // USER INCLUDES |
|
48 #include "msgunieditorbody.h" |
|
49 #include "UniEditorGenUtils.h" |
|
50 #include "UniSendingSettings.h" |
|
51 #include "msgunieditormonitor.h" |
|
52 |
|
53 #include "mmsconformancecheck.h" |
|
54 #include "unieditorpluginloader.h" |
|
55 #include "unieditorplugininterface.h" |
|
56 #include "convergedmessage.h" |
|
57 #include "msgmediautil.h" |
|
58 #include "msgunieditorpixmapwidget.h" |
|
59 #include "msgunieditoraudiowidget.h" |
|
60 |
|
61 // Constants |
|
62 const QString BACKGROUND_FRAME("qtg_fr_messaging_char_count"); |
|
63 const QString CHAR_COUNTER_COLOR("qtc_messaging_char_count"); |
|
64 |
|
65 const int KShowCounterLimit = 10; |
|
66 const int BYTES_TO_KBYTES_FACTOR = 1024; |
|
67 |
|
68 //Localized Constants for item specific menu |
|
69 #define LOC_TITLE hbTrId("txt_messaging_title_messaging") |
|
70 #define LOC_UNABLE_TO_ADD_CONTENT hbTrId("txt_messaging_dpopinfo_unable_to_add_more_content") |
|
71 #define LOC_UNABLE_TO_ATTACH_ITEM hbTrId("txt_messaging_dpopinfo_unable_to_attach_item_avai") |
|
72 #define LOC_PROCESSING hbTrId("txt_messaging_formlabel_loading") |
|
73 #define LOC_HINT_TEXT hbTrId("txt_messaging_formlabel_enter_message_here") |
|
74 #define LOC_ATTACHED_PHOTO_SIZE hbTrId("txt_messaging_dpopinfo_attached_photo_size_is_l1") |
|
75 |
|
76 const QString ANIMATION_ICON("qtg_anim_loading"); |
|
77 const QString ANIMATION_FILE(":/qtg_anim_loading.axml"); |
|
78 // LOCAL FUNCTIONS |
|
79 |
|
80 //--------------------------------------------------------------- |
|
81 // showInsertFailureNote |
|
82 // @return fullPath of unified editor's temporary dir |
|
83 //--------------------------------------------------------------- |
|
84 void showInsertFailureNote() |
|
85 { |
|
86 int availableSize = |
|
87 (MsgUnifiedEditorMonitor::maxMmsSize() - MsgUnifiedEditorMonitor::messageSize()) |
|
88 /BYTES_TO_KBYTES_FACTOR; |
|
89 QString displayStr = QString(LOC_UNABLE_TO_ATTACH_ITEM) |
|
90 .arg(availableSize); |
|
91 |
|
92 HbMessageBox::information(displayStr, 0, 0, HbMessageBox::Ok); |
|
93 } |
|
94 |
|
95 |
|
96 MsgUnifiedEditorBody::MsgUnifiedEditorBody( QGraphicsItem *parent ) : |
|
97 MsgUnifiedEditorBaseWidget(parent), |
|
98 mHasImage(false), |
|
99 mHasAudio(false), |
|
100 mTextEdit(0), |
|
101 mPixmapItem(0), |
|
102 mAudioItem(0), |
|
103 mImageSize(0), |
|
104 mAudioSize(0), |
|
105 mVideoSize(0), |
|
106 mProcessImageOperation(0), |
|
107 mMediaResolver(0), |
|
108 mImageInfo(0), |
|
109 mProcessingWidget(0), |
|
110 mDraftMessage(false), |
|
111 mIsImageResizing(false) |
|
112 { |
|
113 mTextEdit = new HbTextEdit(this); |
|
114 mTextEdit->setPlaceholderText(LOC_HINT_TEXT); |
|
115 mTextEdit->setFontSpec(HbFontSpec(HbFontSpec::Secondary)); |
|
116 HbStyle::setItemName(mTextEdit,"textEdit"); |
|
117 connect(mTextEdit, SIGNAL(contentsChanged()), this, SLOT(onTextChanged())); |
|
118 |
|
119 mMmsConformanceCheck = new MmsConformanceCheck; |
|
120 |
|
121 mCharCounter = new HbTextItem(this); |
|
122 HbStyle::setItemName(mCharCounter, "charCounter"); |
|
123 mCharCounter->setZValue(1.5); |
|
124 |
|
125 QColor color = HbColorScheme::color(CHAR_COUNTER_COLOR); |
|
126 mCharCounter->setTextColor(color); |
|
127 |
|
128 mBackgroundItem = new HbFrameItem(this); |
|
129 HbStyle::setItemName(mBackgroundItem, "charCounterFrame"); |
|
130 |
|
131 mBackgroundItem->frameDrawer().setFrameType(HbFrameDrawer::ThreePiecesHorizontal); |
|
132 mBackgroundItem->frameDrawer().setFillWholeRect(true); |
|
133 |
|
134 mBackgroundItem->frameDrawer().setFrameGraphicsName(BACKGROUND_FRAME); |
|
135 |
|
136 mPluginLoader = new UniEditorPluginLoader(this); |
|
137 |
|
138 mPluginInterface = |
|
139 mPluginLoader->getUniEditorPlugin(ConvergedMessage::Sms); |
|
140 |
|
141 TRAP_IGNORE( |
|
142 CSmsSettings* settings = CSmsSettings::NewLC(); |
|
143 CSmsAccount* account = CSmsAccount::NewLC(); |
|
144 account->LoadSettingsL( *settings ); |
|
145 |
|
146 if( settings->CharacterSet() == TSmsDataCodingScheme::ESmsAlphabetUCS2) |
|
147 { |
|
148 mCharSupportType = TUniSendingSettings::EUniCharSupportFull; |
|
149 } |
|
150 else |
|
151 { |
|
152 mCharSupportType = TUniSendingSettings::EUniCharSupportReduced; |
|
153 } |
|
154 |
|
155 CleanupStack::PopAndDestroy( account ); |
|
156 CleanupStack::PopAndDestroy( settings ); |
|
157 ); |
|
158 |
|
159 mCharCounter->setVisible(false); |
|
160 mBackgroundItem->setVisible(false); |
|
161 } |
|
162 |
|
163 MsgUnifiedEditorBody::~MsgUnifiedEditorBody() |
|
164 { |
|
165 delete mMmsConformanceCheck; |
|
166 delete mProcessImageOperation; |
|
167 delete mMediaResolver; |
|
168 delete mImageInfo; |
|
169 } |
|
170 |
|
171 QString MsgUnifiedEditorBody::text() |
|
172 { |
|
173 return mTextEdit->toPlainText(); |
|
174 } |
|
175 |
|
176 void MsgUnifiedEditorBody::setImage(QString& imagefile, bool draftMessage) |
|
177 { |
|
178 // do nothing if filepath is empty |
|
179 if (imagefile.isEmpty()) |
|
180 { |
|
181 return; |
|
182 } |
|
183 |
|
184 mDraftMessage = draftMessage; |
|
185 if (!mImageInfo) |
|
186 { |
|
187 setImage(true); |
|
188 |
|
189 mImageFile = imagefile; |
|
190 if (mPixmapItem) |
|
191 { |
|
192 mPixmapItem->setParent(NULL); |
|
193 delete mPixmapItem; |
|
194 mPixmapItem = NULL; |
|
195 mImageSize = 0; |
|
196 } |
|
197 |
|
198 int error = KErrNone; |
|
199 if (!mDraftMessage) |
|
200 { |
|
201 // if image is in draft, no need to resize it because it is resized already |
|
202 if (!mProcessImageOperation) |
|
203 { |
|
204 TRAP(error,mProcessImageOperation = |
|
205 CUniEditorProcessImageOperation::NewL(*this)); |
|
206 } |
|
207 if (!mMediaResolver && error == KErrNone) |
|
208 { |
|
209 TRAP(error,mMediaResolver = CMsgMediaResolver::NewL()); |
|
210 } |
|
211 |
|
212 if (error == KErrNone) |
|
213 { |
|
214 mMediaResolver->SetCharacterSetRecognition(EFalse); |
|
215 HBufC *name = XQConversions::qStringToS60Desc(imagefile); |
|
216 RFile file; |
|
217 TRAP(error, file = mMediaResolver->FileHandleL(*name)); |
|
218 if (error == KErrNone) |
|
219 { |
|
220 TRAP(error,mImageInfo = static_cast<CMsgImageInfo*> |
|
221 (mMediaResolver->CreateMediaInfoL(file))); |
|
222 if (error == KErrNone) |
|
223 { |
|
224 TRAP(error, mMediaResolver->ParseInfoDetailsL( |
|
225 mImageInfo, file)); |
|
226 } |
|
227 file.Close(); |
|
228 } |
|
229 delete name; |
|
230 } |
|
231 } |
|
232 if (error == KErrNone && !mDraftMessage) |
|
233 { |
|
234 mSavedImageFile = imagefile; |
|
235 startResizeAnimation(); |
|
236 mIsImageResizing = true; |
|
237 mProcessImageOperation->Process(mImageInfo); |
|
238 } |
|
239 else |
|
240 { |
|
241 if (mImageInfo) |
|
242 { |
|
243 delete mImageInfo; |
|
244 mImageInfo = NULL; |
|
245 } |
|
246 mSavedImageFile.clear(); |
|
247 handleSetImage(); |
|
248 } |
|
249 |
|
250 } |
|
251 } |
|
252 |
|
253 void MsgUnifiedEditorBody::handleSetImage() |
|
254 { |
|
255 //check for insert conformance |
|
256 if(EInsertSuccess != mMmsConformanceCheck->checkModeForInsert(mImageFile)) |
|
257 return; |
|
258 |
|
259 int msgSize = messageSize(); |
|
260 QFileInfo fileinfo(mImageFile); |
|
261 int imageSize = fileinfo.size() + KEstimatedMimeHeaderSize; |
|
262 if ( (imageSize + msgSize) <= MsgUnifiedEditorMonitor::maxMmsSize()) |
|
263 { |
|
264 mImageSize = imageSize; |
|
265 } |
|
266 else |
|
267 { |
|
268 mImageFile.clear(); |
|
269 setImage(false); |
|
270 //Show appropriate note and leave |
|
271 showInsertFailureNote(); |
|
272 return; |
|
273 } |
|
274 |
|
275 mPixmapItem = new MsgUnifiedEditorPixmapWidget(this); |
|
276 mPixmapItem->hide(); |
|
277 HbStyle::setItemName(mPixmapItem, "pixmap"); |
|
278 mPixmapItem->setAlignment(Qt::AlignHCenter | Qt::AlignTop); |
|
279 mPixmapItem->populate(mImageFile); |
|
280 connect(mPixmapItem,SIGNAL(remove()),this,SLOT(removeMedia())); |
|
281 |
|
282 // repolish the body widget |
|
283 this->repolish(); |
|
284 |
|
285 // emit signal to indicate addition of image |
|
286 emit contentChanged(); |
|
287 } |
|
288 |
|
289 void MsgUnifiedEditorBody::setAudio(QString& audiofile) |
|
290 { |
|
291 // do nothing if filepath is empty |
|
292 if(audiofile.isEmpty()) |
|
293 { |
|
294 return; |
|
295 } |
|
296 |
|
297 //check for insert conformance |
|
298 if(EInsertSuccess != mMmsConformanceCheck->checkModeForInsert(audiofile)) |
|
299 return; |
|
300 |
|
301 setAudio(true); |
|
302 mAudioFile = audiofile; |
|
303 if(mAudioItem) |
|
304 { |
|
305 mAudioItem->setParent(NULL); |
|
306 delete mAudioItem; |
|
307 mAudioItem = NULL; |
|
308 mAudioSize = 0; |
|
309 } |
|
310 |
|
311 int msgSize = messageSize(); |
|
312 QFileInfo fileinfo(mAudioFile); |
|
313 int audioSize = fileinfo.size() + KEstimatedMimeHeaderSize; |
|
314 if((audioSize + msgSize) <= MsgUnifiedEditorMonitor::maxMmsSize() ) |
|
315 { |
|
316 mAudioSize = audioSize; |
|
317 } |
|
318 else |
|
319 { |
|
320 mAudioFile.clear(); |
|
321 setAudio(false); |
|
322 //Show appropriate note and leave |
|
323 showInsertFailureNote(); |
|
324 return; |
|
325 } |
|
326 |
|
327 mAudioItem = new MsgUniFiedEditorAudioWidget(this); |
|
328 mAudioItem->hide(); |
|
329 HbStyle::setItemName(mAudioItem,"audioItem"); |
|
330 mAudioItem->populate(mAudioFile); |
|
331 connect(mAudioItem,SIGNAL(remove()),this,SLOT(removeMedia())); |
|
332 |
|
333 // repolish the body widget |
|
334 this->repolish(); |
|
335 |
|
336 // emit signal to indicate addition of audio |
|
337 emit contentChanged(); |
|
338 } |
|
339 |
|
340 void MsgUnifiedEditorBody::setText(QString& text) |
|
341 { |
|
342 if(!text.isEmpty()) |
|
343 { |
|
344 mTextEdit->setPlainText(text); |
|
345 } |
|
346 } |
|
347 |
|
348 const QStringList MsgUnifiedEditorBody::mediaContent() |
|
349 { |
|
350 QStringList mediaFiles; |
|
351 // Pick mImageFile only if mSavedImageFile is empty |
|
352 // as it means we are not in middle of resizing |
|
353 if (mHasImage && mSavedImageFile.isEmpty()) |
|
354 mediaFiles << mImageFile; |
|
355 if(mHasAudio) |
|
356 mediaFiles << mAudioFile; |
|
357 |
|
358 return mediaFiles; |
|
359 } |
|
360 |
|
361 QSizeF MsgUnifiedEditorBody::sizeHint(Qt::SizeHint which, const QSizeF &constraint) const |
|
362 { |
|
363 QSizeF szHint = HbWidget::sizeHint(which,constraint); |
|
364 |
|
365 HbMainWindow* mMainWindow = this->mainWindow(); |
|
366 if(!mMainWindow) |
|
367 { |
|
368 return szHint; |
|
369 } |
|
370 |
|
371 qreal leftMargin = 0.0; |
|
372 qreal rightMargin = 0.0; |
|
373 qreal chromeHeight = 0.0; |
|
374 qreal toolbarHeight = 0.0; |
|
375 qreal bodyItemSpacing = 0.0; |
|
376 |
|
377 style()->parameter("hb-param-margin-gene-left",leftMargin); |
|
378 style()->parameter("hb-param-margin-gene-right",rightMargin); |
|
379 style()->parameter("hb-param-widget-chrome-height",chromeHeight); |
|
380 style()->parameter("hb-param-widget-toolbar-height",toolbarHeight); |
|
381 style()->parameter("hb-param-margin-gene-middle-vertical",bodyItemSpacing); |
|
382 |
|
383 HbDeviceProfile prf = HbDeviceProfile::profile(mMainWindow); |
|
384 qreal unt = prf.unitValue(); |
|
385 |
|
386 // Note: With NGA, the orientation change does not cause HW to switch orientation. |
|
387 // So, the HW resolution also remains unchanged. We need to swap values of width & |
|
388 // height to map portrait resolution to landscape resolution. |
|
389 qreal maxWidth = 0.0, maxHeight = 0.0; |
|
390 |
|
391 // Landscape |
|
392 if(mMainWindow->orientation() == Qt::Horizontal) |
|
393 { |
|
394 maxHeight = mMainWindow->width()-chromeHeight-toolbarHeight; |
|
395 maxWidth = (mMainWindow->height()-leftMargin-rightMargin-(2*unt))/2; |
|
396 } |
|
397 else |
|
398 { |
|
399 maxWidth = mMainWindow->width()-leftMargin-rightMargin; |
|
400 maxHeight = mMainWindow->height()-chromeHeight-toolbarHeight; |
|
401 } |
|
402 szHint.setHeight(maxHeight); |
|
403 |
|
404 // add space for audio |
|
405 if(mAudioItem) |
|
406 { |
|
407 if(mMainWindow->orientation() == Qt::Horizontal) |
|
408 { |
|
409 mAudioItem->setStretched(true); |
|
410 } |
|
411 else |
|
412 { |
|
413 mAudioItem->setStretched(false); |
|
414 } |
|
415 QSizeF audioSize = mAudioItem->effectiveSizeHint(which, constraint); |
|
416 szHint.rheight() += (audioSize.height() + bodyItemSpacing); |
|
417 mAudioItem->show(); |
|
418 } |
|
419 |
|
420 if(mPixmapItem || mProcessingWidget) |
|
421 { |
|
422 QSizeF imageSize(0.0,0.0); |
|
423 QSizeF defaultImageSize(QImageReader(mImageFile).size()); |
|
424 |
|
425 if(!defaultImageSize.isEmpty()) |
|
426 { |
|
427 imageSize.setWidth(maxWidth); |
|
428 if(mMainWindow->orientation() == Qt::Vertical) |
|
429 { |
|
430 szHint.rheight() += bodyItemSpacing; |
|
431 } |
|
432 |
|
433 qreal newHeight = 0.0; |
|
434 if(defaultImageSize.width() <= imageSize.width()) |
|
435 { |
|
436 // resize not needed |
|
437 newHeight = qMin(defaultImageSize.height(), maxHeight); |
|
438 imageSize.setHeight(newHeight); |
|
439 } |
|
440 else |
|
441 { |
|
442 // keep aspect-ratio and resize |
|
443 newHeight = imageSize.width()*(defaultImageSize.height()/defaultImageSize.width()); |
|
444 newHeight = qMin(newHeight,maxHeight); |
|
445 imageSize.setHeight(newHeight); |
|
446 } |
|
447 |
|
448 if(newHeight == maxHeight) |
|
449 { |
|
450 qreal newWidth = defaultImageSize.width()*newHeight/defaultImageSize.height(); |
|
451 imageSize.setWidth(newWidth); |
|
452 } |
|
453 |
|
454 if(mPixmapItem) |
|
455 { |
|
456 mPixmapItem->setPreferredSize(imageSize); |
|
457 mPixmapItem->setSize(imageSize); |
|
458 if(mMainWindow->orientation() == Qt::Horizontal) |
|
459 { |
|
460 QPointF currPos = mPixmapItem->pos(); |
|
461 currPos.setX(leftMargin+((maxWidth-imageSize.width())/2)); |
|
462 mPixmapItem->setPos(currPos); |
|
463 } |
|
464 mPixmapItem->show(); |
|
465 } |
|
466 |
|
467 if(mProcessingWidget) |
|
468 { |
|
469 imageSize.setHeight(mProcessingWidget->preferredHeight()); |
|
470 mProcessingWidget->setPreferredSize(imageSize); |
|
471 mProcessingWidget->show(); |
|
472 } |
|
473 szHint.rheight() += imageSize.height(); |
|
474 } |
|
475 } |
|
476 |
|
477 |
|
478 mTextEdit->setMinimumHeight(maxHeight); |
|
479 szHint.rheight() += bodyItemSpacing; |
|
480 return szHint; |
|
481 } |
|
482 |
|
483 void MsgUnifiedEditorBody::removeMedia() |
|
484 { |
|
485 QObject* senderObject = sender(); |
|
486 |
|
487 MsgUnifiedEditorPixmapWidget* pixmap = |
|
488 qobject_cast<MsgUnifiedEditorPixmapWidget*>(senderObject); |
|
489 |
|
490 MsgUniFiedEditorAudioWidget* audio = |
|
491 qobject_cast<MsgUniFiedEditorAudioWidget*>(senderObject); |
|
492 |
|
493 if(pixmap) //remove image |
|
494 { |
|
495 mImageFile.clear(); |
|
496 if(mPixmapItem) |
|
497 { |
|
498 mPixmapItem->setParent(NULL); |
|
499 delete mPixmapItem; |
|
500 mPixmapItem = NULL; |
|
501 } |
|
502 setImage(false); |
|
503 mImageSize = 0; |
|
504 } |
|
505 else if(audio)//remove audio item |
|
506 { |
|
507 mAudioFile.clear(); |
|
508 if(mAudioItem) |
|
509 { |
|
510 mAudioItem->setParent(NULL); |
|
511 delete mAudioItem; |
|
512 mAudioItem = NULL; |
|
513 } |
|
514 setAudio(false); |
|
515 mAudioSize = 0; |
|
516 } |
|
517 |
|
518 this->repolish(); |
|
519 |
|
520 emit contentChanged(); |
|
521 } |
|
522 |
|
523 bool MsgUnifiedEditorBody::hasImage() |
|
524 { |
|
525 return mHasImage; |
|
526 } |
|
527 |
|
528 void MsgUnifiedEditorBody::setImage(bool image) |
|
529 { |
|
530 mHasImage = image; |
|
531 } |
|
532 |
|
533 bool MsgUnifiedEditorBody::hasAudio() |
|
534 { |
|
535 return mHasAudio; |
|
536 } |
|
537 |
|
538 void MsgUnifiedEditorBody::setAudio(bool audio) |
|
539 { |
|
540 mHasAudio = audio; |
|
541 } |
|
542 |
|
543 int MsgUnifiedEditorBody::bodySize() |
|
544 { |
|
545 int bodysize = 0; |
|
546 |
|
547 if( mImageSize || mTextEdit->toPlainText().size() || |
|
548 mAudioSize || mVideoSize ) |
|
549 { |
|
550 |
|
551 UniEditorGenUtils* genUtils = q_check_ptr(new UniEditorGenUtils); |
|
552 |
|
553 bodysize += mImageSize + mAudioSize + mVideoSize + |
|
554 genUtils->UTF8Size(mTextEdit->toPlainText()) + |
|
555 KEstimatedMimeHeaderSize + KEstimatedMmsSmilHeaderSize; |
|
556 delete genUtils; |
|
557 } |
|
558 return bodysize; |
|
559 } |
|
560 |
|
561 int MsgUnifiedEditorBody::messageSize() |
|
562 { |
|
563 int estimatedMediaSize = bodySize(); |
|
564 if(!estimatedMediaSize) |
|
565 { |
|
566 // This is the first media content to be inserted |
|
567 estimatedMediaSize = KEstimatedMmsSmilHeaderSize; |
|
568 } |
|
569 |
|
570 return estimatedMediaSize + MsgUnifiedEditorMonitor::subjectSize() + MsgUnifiedEditorMonitor::containerSize(); |
|
571 } |
|
572 |
|
573 void MsgUnifiedEditorBody::onTextChanged() |
|
574 { |
|
575 QString string = text(); |
|
576 |
|
577 if( string.size() > mPrevBuffer.size() && |
|
578 MsgUnifiedEditorMonitor::messageType() == ConvergedMessage::Mms ) |
|
579 { |
|
580 // reject any text input if mms size limit is reached |
|
581 int futureSize = bodySize() + |
|
582 MsgUnifiedEditorMonitor::containerSize() + MsgUnifiedEditorMonitor::subjectSize(); |
|
583 if(futureSize > MsgUnifiedEditorMonitor::maxMmsSize()) |
|
584 { |
|
585 mTextEdit->setPlainText(mPrevBuffer); |
|
586 HbMessageBox::information(LOC_UNABLE_TO_ADD_CONTENT, 0, 0, HbMessageBox::Ok); |
|
587 mTextEdit->setCursorPosition(mPrevBuffer.length()); |
|
588 return; |
|
589 } |
|
590 else if(!mPrevBuffer.isEmpty()) |
|
591 { |
|
592 //Save the previous buffer |
|
593 mPrevBuffer = string; |
|
594 // emit signal to indicate change in content |
|
595 emit contentChanged(); |
|
596 return; |
|
597 } |
|
598 } |
|
599 |
|
600 //Check done for optimization |
|
601 //Only if content is deleted we need to call encodingsettings again |
|
602 if (mPrevBuffer.isEmpty() || string.size() <= mPrevBuffer.size()) |
|
603 { |
|
604 mPluginInterface->setEncodingSettings(EFalse, ESmsEncodingNone, |
|
605 mCharSupportType); |
|
606 } |
|
607 |
|
608 TInt numOfRemainingChars; |
|
609 TInt numOfPDUs; |
|
610 TBool unicodeMode; |
|
611 TSmsEncoding alternativeEncodingType; |
|
612 mPluginInterface->getNumPDUs(string, numOfRemainingChars, numOfPDUs, |
|
613 unicodeMode, alternativeEncodingType); |
|
614 |
|
615 //Save the unicode value returned |
|
616 mUnicode = unicodeMode; |
|
617 //Save the old buffer |
|
618 mPrevBuffer = string; |
|
619 |
|
620 // emit signal to indicate change in content |
|
621 emit contentChanged(); |
|
622 |
|
623 if(MsgUnifiedEditorMonitor::messageType() == ConvergedMessage::Sms) |
|
624 { |
|
625 //Set char counter value |
|
626 QString display = QString("%1(%2)").arg(numOfRemainingChars).arg( |
|
627 numOfPDUs); |
|
628 mCharCounter->setText(display); |
|
629 |
|
630 if (numOfPDUs > 1 || numOfRemainingChars <= KShowCounterLimit) |
|
631 { |
|
632 mCharCounter->setVisible(true); |
|
633 mBackgroundItem->setVisible(true); |
|
634 } |
|
635 else |
|
636 { |
|
637 mCharCounter->setVisible(false); |
|
638 mBackgroundItem->setVisible(false); |
|
639 } |
|
640 } |
|
641 } |
|
642 |
|
643 void MsgUnifiedEditorBody::EditorOperationEvent( |
|
644 TUniEditorProcessImageOperationEvent aEvent, TFileName aFileName) |
|
645 { |
|
646 delete mImageInfo; |
|
647 mImageInfo = NULL; |
|
648 |
|
649 if (aEvent == EUniEditorProcessImageOperationComplete && |
|
650 aFileName.Length() > 0) |
|
651 { |
|
652 mImageFile = XQConversions::s60DescToQString(aFileName); |
|
653 |
|
654 QSize modifiedSize(QImageReader(mImageFile).size()); |
|
655 QString information = LOC_ATTACHED_PHOTO_SIZE.arg(modifiedSize.width()).arg(modifiedSize.height()); |
|
656 HbNotificationDialog::launchDialog(information); |
|
657 } |
|
658 else |
|
659 { |
|
660 mImageFile = mSavedImageFile; |
|
661 } |
|
662 mSavedImageFile.clear(); |
|
663 |
|
664 // image resize is complete. reset the image resize flag |
|
665 mIsImageResizing = false; |
|
666 //handle the processed image from ProcessImage Operation |
|
667 handleSetImage(); |
|
668 |
|
669 stopResizeAnimation(); |
|
670 } |
|
671 |
|
672 void MsgUnifiedEditorBody::startResizeAnimation() |
|
673 { |
|
674 // emit signal to indicate disable the send tool button. |
|
675 emit enableSendButton(false); |
|
676 |
|
677 |
|
678 QGraphicsLinearLayout* processingLayout = new QGraphicsLinearLayout(Qt::Vertical); |
|
679 |
|
680 mProcessingWidget = new HbWidget(this); |
|
681 HbStyle::setItemName(mProcessingWidget,"pixmap"); |
|
682 mProcessingWidget->hide(); |
|
683 mProcessingWidget->setLayout(processingLayout); |
|
684 |
|
685 HbTextItem* processingText = new HbTextItem(LOC_PROCESSING,mProcessingWidget); |
|
686 processingText->setFontSpec(HbFontSpec(HbFontSpec::Secondary)); |
|
687 processingText->setAlignment(Qt::AlignCenter); |
|
688 processingLayout->addItem(processingText); |
|
689 |
|
690 HbIconItem* animationItem = new HbIconItem(ANIMATION_ICON,mProcessingWidget); |
|
691 animationItem->setAlignment(Qt::AlignHCenter); |
|
692 processingLayout->addItem(animationItem); |
|
693 |
|
694 HbIconAnimator& iconAnimator = animationItem->animator(); |
|
695 HbIconAnimationManager* iconAnimationManager = HbIconAnimationManager::global(); |
|
696 iconAnimationManager->addDefinitionFile(ANIMATION_FILE); |
|
697 |
|
698 iconAnimator.startAnimation(); |
|
699 |
|
700 this->repolish(); |
|
701 } |
|
702 |
|
703 void MsgUnifiedEditorBody::stopResizeAnimation() |
|
704 { |
|
705 if(mProcessingWidget) |
|
706 { |
|
707 delete mProcessingWidget; |
|
708 mProcessingWidget = NULL; |
|
709 } |
|
710 |
|
711 } |
|
712 |
|
713 // --------------------------------------------------------- |
|
714 // MsgUnifiedEditorBody::isUnicode |
|
715 // --------------------------------------------------------- |
|
716 // |
|
717 bool MsgUnifiedEditorBody::isUnicode() |
|
718 { |
|
719 return mUnicode; |
|
720 } |
|
721 |
|
722 // --------------------------------------------------------- |
|
723 // MsgUnifiedEditorBody::disableCharCounter |
|
724 // --------------------------------------------------------- |
|
725 // |
|
726 void MsgUnifiedEditorBody::disableCharCounter() |
|
727 { |
|
728 mCharCounter->setVisible(false); |
|
729 mBackgroundItem->setVisible(false); |
|
730 } |
|
731 |
|
732 // --------------------------------------------------------- |
|
733 // MsgUnifiedEditorBody::enableCharCounter |
|
734 // --------------------------------------------------------- |
|
735 // |
|
736 void MsgUnifiedEditorBody::enableCharCounter() |
|
737 { |
|
738 mPluginInterface->setEncodingSettings(EFalse, ESmsEncodingNone, |
|
739 mCharSupportType); |
|
740 |
|
741 TInt numOfRemainingChars; |
|
742 TInt numOfPDUs; |
|
743 TBool unicodeMode; |
|
744 TSmsEncoding alternativeEncodingType; |
|
745 QString string = mTextEdit->toPlainText(); |
|
746 mPluginInterface->getNumPDUs(string, |
|
747 numOfRemainingChars, numOfPDUs, unicodeMode, |
|
748 alternativeEncodingType); |
|
749 |
|
750 //Save the unicode value returned |
|
751 mUnicode = unicodeMode; |
|
752 |
|
753 //Set char counter value |
|
754 QString display = QString("%1(%2)").arg(numOfRemainingChars).arg( |
|
755 numOfPDUs); |
|
756 mCharCounter->setText(display); |
|
757 |
|
758 if (numOfPDUs > 1 || numOfRemainingChars <= KShowCounterLimit) |
|
759 { |
|
760 mCharCounter->setVisible(true); |
|
761 mBackgroundItem->setVisible(true); |
|
762 } |
|
763 else |
|
764 { |
|
765 mCharCounter->setVisible(false); |
|
766 mBackgroundItem->setVisible(false); |
|
767 } |
|
768 |
|
769 } |
|
770 |
|
771 //--------------------------------------------------------------- |
|
772 // MsgUnifiedEditorBody :: setFocus |
|
773 // @see header file |
|
774 //--------------------------------------------------------------- |
|
775 void MsgUnifiedEditorBody::setFocus() |
|
776 { |
|
777 mTextEdit->setFocus(Qt::MouseFocusReason); |
|
778 } |
|
779 // EOF |