39 #include <xqaiwrequest.h> |
39 #include <xqaiwrequest.h> |
40 #include <xqrequestinfo.h> |
40 #include <xqrequestinfo.h> |
41 #include <xqsharablefile.h> |
41 #include <xqsharablefile.h> |
42 #include <xqappmgr.h> |
42 #include <xqappmgr.h> |
43 #include <xqconversions.h> |
43 #include <xqconversions.h> |
|
44 #include <hbmessagebox.h> |
|
45 #include <hbcolorscheme.h> |
|
46 #include <QColor> |
44 // USER INCLUDES |
47 // USER INCLUDES |
45 #include "msgunieditorbody.h" |
48 #include "msgunieditorbody.h" |
46 #include "UniEditorGenUtils.h" |
49 #include "UniEditorGenUtils.h" |
47 #include "UniSendingSettings.h" |
50 #include "UniSendingSettings.h" |
48 #include "msgunieditormonitor.h" |
51 #include "msgunieditormonitor.h" |
54 #include "msgmediautil.h" |
57 #include "msgmediautil.h" |
55 #include "msgunieditorpixmapwidget.h" |
58 #include "msgunieditorpixmapwidget.h" |
56 #include "msgunieditoraudiowidget.h" |
59 #include "msgunieditoraudiowidget.h" |
57 |
60 |
58 // Constants |
61 // Constants |
59 const QString BACKGROUND_FRAME("qtg_fr_btn_normal"); |
62 const QString BACKGROUND_FRAME("qtg_fr_messaging_char_count"); |
|
63 const QString CHAR_COUNTER_COLOR("qtc_messaging_char_count"); |
60 |
64 |
61 const int KShowCounterLimit = 10; |
65 const int KShowCounterLimit = 10; |
62 const int BYTES_TO_KBYTES_FACTOR = 1024; |
66 const int BYTES_TO_KBYTES_FACTOR = 1024; |
63 |
67 |
64 //Localized Constants for item specific menu |
68 //Localized Constants for item specific menu |
65 #define LOC_TITLE hbTrId("txt_messaging_title_messaging") |
69 #define LOC_TITLE hbTrId("txt_messaging_title_messaging") |
66 #define LOC_UNABLE_TO_ADD_CONTENT hbTrId("txt_messaging_dpopinfo_unable_to_add_more_content") |
70 #define LOC_UNABLE_TO_ADD_CONTENT hbTrId("txt_messaging_dpopinfo_unable_to_add_more_content") |
67 #define LOC_UNABLE_TO_ATTACH_ITEM hbTrId("txt_messaging_dpopinfo_unable_to_attach_item_avai") |
71 #define LOC_UNABLE_TO_ATTACH_ITEM hbTrId("txt_messaging_dpopinfo_unable_to_attach_item_avai") |
68 #define LOC_PROCESSING hbTrId("txt_messaging_formlabel_loading") |
72 #define LOC_PROCESSING hbTrId("txt_messaging_formlabel_loading") |
69 #define LOC_HINT_TEXT hbTrId("txt_messaging_formlabel_enter_message_here") |
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") |
70 |
75 |
71 const QString ANIMATION_ICON("qtg_anim_loading"); |
76 const QString ANIMATION_ICON("qtg_anim_loading"); |
72 const QString ANIMATION_FILE(":/qtg_anim_loading.axml"); |
77 const QString ANIMATION_FILE(":/qtg_anim_loading.axml"); |
73 // LOCAL FUNCTIONS |
78 // LOCAL FUNCTIONS |
74 |
79 |
81 int availableSize = |
86 int availableSize = |
82 (MsgUnifiedEditorMonitor::maxMmsSize() - MsgUnifiedEditorMonitor::messageSize()) |
87 (MsgUnifiedEditorMonitor::maxMmsSize() - MsgUnifiedEditorMonitor::messageSize()) |
83 /BYTES_TO_KBYTES_FACTOR; |
88 /BYTES_TO_KBYTES_FACTOR; |
84 QString displayStr = QString(LOC_UNABLE_TO_ATTACH_ITEM) |
89 QString displayStr = QString(LOC_UNABLE_TO_ATTACH_ITEM) |
85 .arg(availableSize); |
90 .arg(availableSize); |
86 HbNotificationDialog* dlg = new HbNotificationDialog(); |
91 |
87 dlg->setFocusPolicy(Qt::NoFocus); |
92 HbMessageBox::information(displayStr, 0, 0, HbMessageBox::Ok); |
88 dlg->setDismissPolicy(HbPopup::TapAnywhere); |
|
89 dlg->setAttribute(Qt::WA_DeleteOnClose, true); |
|
90 dlg->setText(displayStr); |
|
91 dlg->show(); |
|
92 } |
93 } |
93 |
94 |
94 |
95 |
95 MsgUnifiedEditorBody::MsgUnifiedEditorBody( QGraphicsItem *parent ) : |
96 MsgUnifiedEditorBody::MsgUnifiedEditorBody( QGraphicsItem *parent ) : |
96 MsgUnifiedEditorBaseWidget(parent), |
97 MsgUnifiedEditorBaseWidget(parent), |
109 mDraftMessage(false), |
110 mDraftMessage(false), |
110 mIsImageResizing(false) |
111 mIsImageResizing(false) |
111 { |
112 { |
112 mTextEdit = new HbTextEdit(this); |
113 mTextEdit = new HbTextEdit(this); |
113 mTextEdit->setPlaceholderText(LOC_HINT_TEXT); |
114 mTextEdit->setPlaceholderText(LOC_HINT_TEXT); |
|
115 mTextEdit->setFontSpec(HbFontSpec(HbFontSpec::Secondary)); |
114 HbStyle::setItemName(mTextEdit,"textEdit"); |
116 HbStyle::setItemName(mTextEdit,"textEdit"); |
115 connect(mTextEdit, SIGNAL(contentsChanged()), this, SLOT(onTextChanged())); |
117 connect(mTextEdit, SIGNAL(contentsChanged()), this, SLOT(onTextChanged())); |
116 |
118 |
117 mMmsConformanceCheck = new MmsConformanceCheck; |
119 mMmsConformanceCheck = new MmsConformanceCheck; |
118 |
120 |
119 mCharCounter = new HbTextItem(this); |
121 mCharCounter = new HbTextItem(this); |
120 HbStyle::setItemName(mCharCounter, "charCounter"); |
122 HbStyle::setItemName(mCharCounter, "charCounter"); |
121 mCharCounter->setZValue(1.5); |
123 mCharCounter->setZValue(1.5); |
122 mCharCounter->setText("160(1)"); |
124 |
123 |
125 QColor color = HbColorScheme::color(CHAR_COUNTER_COLOR); |
|
126 mCharCounter->setTextColor(color); |
|
127 |
124 mBackgroundItem = new HbFrameItem(this); |
128 mBackgroundItem = new HbFrameItem(this); |
125 HbStyle::setItemName(mBackgroundItem, "charCounterFrame"); |
129 HbStyle::setItemName(mBackgroundItem, "charCounterFrame"); |
126 |
130 |
127 mBackgroundItem->frameDrawer().setFrameType(HbFrameDrawer::NinePieces); |
131 mBackgroundItem->frameDrawer().setFrameType(HbFrameDrawer::ThreePiecesHorizontal); |
128 mBackgroundItem->frameDrawer().setFillWholeRect(true); |
132 mBackgroundItem->frameDrawer().setFillWholeRect(true); |
129 |
133 |
130 mBackgroundItem->frameDrawer().setFrameGraphicsName( |
134 mBackgroundItem->frameDrawer().setFrameGraphicsName(BACKGROUND_FRAME); |
131 BACKGROUND_FRAME); |
|
132 |
135 |
133 mPluginLoader = new UniEditorPluginLoader(this); |
136 mPluginLoader = new UniEditorPluginLoader(this); |
134 |
137 |
135 mPluginInterface = |
138 mPluginInterface = |
136 mPluginLoader->getUniEditorPlugin(ConvergedMessage::Sms); |
139 mPluginLoader->getUniEditorPlugin(ConvergedMessage::Sms); |
542 int bodysize = 0; |
545 int bodysize = 0; |
543 |
546 |
544 if( mImageSize || mTextEdit->toPlainText().size() || |
547 if( mImageSize || mTextEdit->toPlainText().size() || |
545 mAudioSize || mVideoSize ) |
548 mAudioSize || mVideoSize ) |
546 { |
549 { |
547 UniEditorGenUtils* uniEditorGenUtils = new UniEditorGenUtils; |
550 |
|
551 UniEditorGenUtils* genUtils = q_check_ptr(new UniEditorGenUtils); |
|
552 |
548 bodysize += mImageSize + mAudioSize + mVideoSize + |
553 bodysize += mImageSize + mAudioSize + mVideoSize + |
549 uniEditorGenUtils->UTF8Size(mTextEdit->toPlainText()) + |
554 genUtils->UTF8Size(mTextEdit->toPlainText()) + |
550 KEstimatedMimeHeaderSize + KEstimatedMmsSmilHeaderSize; |
555 KEstimatedMimeHeaderSize + KEstimatedMmsSmilHeaderSize; |
551 delete uniEditorGenUtils; |
556 delete genUtils; |
552 } |
557 } |
553 return bodysize; |
558 return bodysize; |
554 } |
559 } |
555 |
560 |
556 int MsgUnifiedEditorBody::messageSize() |
561 int MsgUnifiedEditorBody::messageSize() |
576 int futureSize = bodySize() + |
581 int futureSize = bodySize() + |
577 MsgUnifiedEditorMonitor::containerSize() + MsgUnifiedEditorMonitor::subjectSize(); |
582 MsgUnifiedEditorMonitor::containerSize() + MsgUnifiedEditorMonitor::subjectSize(); |
578 if(futureSize > MsgUnifiedEditorMonitor::maxMmsSize()) |
583 if(futureSize > MsgUnifiedEditorMonitor::maxMmsSize()) |
579 { |
584 { |
580 mTextEdit->setPlainText(mPrevBuffer); |
585 mTextEdit->setPlainText(mPrevBuffer); |
581 HbNotificationDialog::launchDialog(LOC_UNABLE_TO_ADD_CONTENT); |
586 HbMessageBox::information(LOC_UNABLE_TO_ADD_CONTENT, 0, 0, HbMessageBox::Ok); |
582 mTextEdit->setCursorPosition(mPrevBuffer.length()); |
587 mTextEdit->setCursorPosition(mPrevBuffer.length()); |
583 return; |
588 return; |
584 } |
589 } |
585 else if(!mPrevBuffer.isEmpty()) |
590 else if(!mPrevBuffer.isEmpty()) |
586 { |
591 { |
643 |
648 |
644 if (aEvent == EUniEditorProcessImageOperationComplete && |
649 if (aEvent == EUniEditorProcessImageOperationComplete && |
645 aFileName.Length() > 0) |
650 aFileName.Length() > 0) |
646 { |
651 { |
647 mImageFile = XQConversions::s60DescToQString(aFileName); |
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); |
648 } |
657 } |
649 else |
658 else |
650 { |
659 { |
651 mImageFile = mSavedImageFile; |
660 mImageFile = mSavedImageFile; |
652 } |
661 } |
672 HbStyle::setItemName(mProcessingWidget,"pixmap"); |
681 HbStyle::setItemName(mProcessingWidget,"pixmap"); |
673 mProcessingWidget->hide(); |
682 mProcessingWidget->hide(); |
674 mProcessingWidget->setLayout(processingLayout); |
683 mProcessingWidget->setLayout(processingLayout); |
675 |
684 |
676 HbTextItem* processingText = new HbTextItem(LOC_PROCESSING,mProcessingWidget); |
685 HbTextItem* processingText = new HbTextItem(LOC_PROCESSING,mProcessingWidget); |
|
686 processingText->setFontSpec(HbFontSpec(HbFontSpec::Secondary)); |
677 processingText->setAlignment(Qt::AlignCenter); |
687 processingText->setAlignment(Qt::AlignCenter); |
678 processingLayout->addItem(processingText); |
688 processingLayout->addItem(processingText); |
679 |
689 |
680 HbIconItem* animationItem = new HbIconItem(ANIMATION_ICON,mProcessingWidget); |
690 HbIconItem* animationItem = new HbIconItem(ANIMATION_ICON,mProcessingWidget); |
681 animationItem->setAlignment(Qt::AlignHCenter); |
691 animationItem->setAlignment(Qt::AlignHCenter); |
717 { |
727 { |
718 mCharCounter->setVisible(false); |
728 mCharCounter->setVisible(false); |
719 mBackgroundItem->setVisible(false); |
729 mBackgroundItem->setVisible(false); |
720 } |
730 } |
721 |
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 |
722 //--------------------------------------------------------------- |
771 //--------------------------------------------------------------- |
723 // MsgUnifiedEditorBody :: setFocus |
772 // MsgUnifiedEditorBody :: setFocus |
724 // @see header file |
773 // @see header file |
725 //--------------------------------------------------------------- |
774 //--------------------------------------------------------------- |
726 void MsgUnifiedEditorBody::setFocus() |
775 void MsgUnifiedEditorBody::setFocus() |