56 #include "msgunieditorpixmapwidget.h" |
55 #include "msgunieditorpixmapwidget.h" |
57 #include "msgunieditoraudiowidget.h" |
56 #include "msgunieditoraudiowidget.h" |
58 |
57 |
59 // Constants |
58 // Constants |
60 const QString BACKGROUND_FRAME("qtg_fr_btn_normal"); |
59 const QString BACKGROUND_FRAME("qtg_fr_btn_normal"); |
61 const QString SEND_ICON("qtg_mono_send"); |
|
62 |
60 |
63 const int KShowCounterLimit = 10; |
61 const int KShowCounterLimit = 10; |
64 const int BYTES_TO_KBYTES_FACTOR = 1024; |
62 const int BYTES_TO_KBYTES_FACTOR = 1024; |
65 |
63 |
66 //Localized Constants for item specific menu |
64 //Localized Constants for item specific menu |
106 mVideoSize(0), |
104 mVideoSize(0), |
107 mProcessImageOperation(0), |
105 mProcessImageOperation(0), |
108 mMediaResolver(0), |
106 mMediaResolver(0), |
109 mImageInfo(0), |
107 mImageInfo(0), |
110 mProcessingWidget(0), |
108 mProcessingWidget(0), |
111 mDraftMessage(false) |
109 mDraftMessage(false), |
|
110 mIsImageResizing(false) |
112 { |
111 { |
113 mTextEdit = new HbTextEdit(this); |
112 mTextEdit = new HbTextEdit(this); |
114 mTextEdit->setSmileysEnabled(true); |
|
115 mTextEdit->setPlaceholderText(LOC_HINT_TEXT); |
113 mTextEdit->setPlaceholderText(LOC_HINT_TEXT); |
116 HbStyle::setItemName(mTextEdit,"textEdit"); |
114 HbStyle::setItemName(mTextEdit,"textEdit"); |
117 connect(mTextEdit, SIGNAL(contentsChanged()), this, SLOT(onTextChanged())); |
115 connect(mTextEdit, SIGNAL(contentsChanged()), this, SLOT(onTextChanged())); |
118 |
|
119 // add "Send" action in VKB |
|
120 HbEditorInterface editorInterface(mTextEdit); |
|
121 HbAction *sendAction = new HbAction(HbIcon(SEND_ICON), QString(),this); |
|
122 connect(sendAction, SIGNAL(triggered()),this, SIGNAL(sendMessage())); |
|
123 editorInterface.addAction(sendAction); |
|
124 |
116 |
125 mMmsConformanceCheck = new MmsConformanceCheck; |
117 mMmsConformanceCheck = new MmsConformanceCheck; |
126 |
118 |
127 mCharCounter = new HbTextItem(this); |
119 mCharCounter = new HbTextItem(this); |
128 HbStyle::setItemName(mCharCounter, "charCounter"); |
120 HbStyle::setItemName(mCharCounter, "charCounter"); |
176 QString MsgUnifiedEditorBody::text() |
168 QString MsgUnifiedEditorBody::text() |
177 { |
169 { |
178 return mTextEdit->toPlainText(); |
170 return mTextEdit->toPlainText(); |
179 } |
171 } |
180 |
172 |
181 void MsgUnifiedEditorBody::setImage(QString& imagefile , bool draftMessage) |
173 void MsgUnifiedEditorBody::setImage(QString& imagefile, bool draftMessage) |
182 { |
174 { |
|
175 // do nothing if filepath is empty |
|
176 if (imagefile.isEmpty()) |
|
177 { |
|
178 return; |
|
179 } |
|
180 |
183 mDraftMessage = draftMessage; |
181 mDraftMessage = draftMessage; |
184 if (!mImageInfo) |
182 if (!mImageInfo) |
185 { |
183 { |
186 setImage(true); |
184 setImage(true); |
187 |
185 |
188 mImageFile = imagefile; |
186 mImageFile = imagefile; |
189 if (mPixmapItem) |
187 if (mPixmapItem) |
190 { |
188 { |
191 mPixmapItem->setParent(NULL); |
189 mPixmapItem->setParent(NULL); |
192 delete mPixmapItem; |
190 delete mPixmapItem; |
193 mPixmapItem = NULL; |
191 mPixmapItem = NULL; |
194 mImageSize = 0; |
192 mImageSize = 0; |
195 } |
193 } |
196 |
194 |
197 int error = KErrNone; |
195 int error = KErrNone; |
198 |
196 if (!mDraftMessage) |
199 if( !mProcessImageOperation ) |
197 { |
200 { |
198 // if image is in draft, no need to resize it because it is resized already |
201 TRAP(error,mProcessImageOperation = |
199 if (!mProcessImageOperation) |
202 CUniEditorProcessImageOperation::NewL(*this)); |
200 { |
203 } |
201 TRAP(error,mProcessImageOperation = |
204 if( !mMediaResolver && error == KErrNone ) |
202 CUniEditorProcessImageOperation::NewL(*this)); |
205 { |
203 } |
206 TRAP(error,mMediaResolver = CMsgMediaResolver::NewL()); |
204 if (!mMediaResolver && error == KErrNone) |
207 } |
205 { |
208 |
206 TRAP(error,mMediaResolver = CMsgMediaResolver::NewL()); |
209 if( error == KErrNone) |
207 } |
210 { |
208 |
211 mMediaResolver->SetCharacterSetRecognition(EFalse); |
209 if (error == KErrNone) |
212 HBufC *name = XQConversions::qStringToS60Desc(imagefile); |
210 { |
213 RFile file; |
211 mMediaResolver->SetCharacterSetRecognition(EFalse); |
214 TRAP(error, file = mMediaResolver->FileHandleL(*name)); |
212 HBufC *name = XQConversions::qStringToS60Desc(imagefile); |
215 if(error == KErrNone) |
213 RFile file; |
216 { |
214 TRAP(error, file = mMediaResolver->FileHandleL(*name)); |
217 TRAP(error,mImageInfo = static_cast<CMsgImageInfo*> |
|
218 (mMediaResolver->CreateMediaInfoL(file))); |
|
219 if (error == KErrNone) |
215 if (error == KErrNone) |
220 { |
216 { |
221 TRAP(error, mMediaResolver->ParseInfoDetailsL( |
217 TRAP(error,mImageInfo = static_cast<CMsgImageInfo*> |
222 mImageInfo, file)); |
218 (mMediaResolver->CreateMediaInfoL(file))); |
|
219 if (error == KErrNone) |
|
220 { |
|
221 TRAP(error, mMediaResolver->ParseInfoDetailsL( |
|
222 mImageInfo, file)); |
|
223 } |
|
224 file.Close(); |
|
225 } |
|
226 delete name; |
223 } |
227 } |
224 file.Close(); |
228 } |
225 } |
229 if (error == KErrNone && !mDraftMessage) |
226 delete name; |
230 { |
227 } |
|
228 |
|
229 if (error == KErrNone) |
|
230 { |
|
231 mSavedImageFile = imagefile; |
231 mSavedImageFile = imagefile; |
232 startResizeAnimation(); |
232 startResizeAnimation(); |
|
233 mIsImageResizing = true; |
233 mProcessImageOperation->Process(mImageInfo); |
234 mProcessImageOperation->Process(mImageInfo); |
234 } |
235 } |
235 else |
236 else |
236 { |
237 { |
237 delete mImageInfo; |
238 if (mImageInfo) |
238 mImageInfo = NULL; |
239 { |
|
240 delete mImageInfo; |
|
241 mImageInfo = NULL; |
|
242 } |
239 mSavedImageFile.clear(); |
243 mSavedImageFile.clear(); |
240 handleSetImage(); |
244 handleSetImage(); |
241 } |
245 } |
242 } |
246 |
243 } |
247 } |
|
248 } |
244 |
249 |
245 void MsgUnifiedEditorBody::handleSetImage() |
250 void MsgUnifiedEditorBody::handleSetImage() |
246 { |
251 { |
247 //check for insert conformance |
252 //check for insert conformance |
248 if(EInsertSuccess != mMmsConformanceCheck->checkModeForInsert(mImageFile)) |
253 if(EInsertSuccess != mMmsConformanceCheck->checkModeForInsert(mImageFile)) |
273 |
278 |
274 // repolish the body widget |
279 // repolish the body widget |
275 this->repolish(); |
280 this->repolish(); |
276 |
281 |
277 // emit signal to indicate addition of image |
282 // emit signal to indicate addition of image |
278 if(!mDraftMessage) |
283 emit contentChanged(); |
279 { |
|
280 emit contentChanged(); |
|
281 } |
|
282 } |
284 } |
283 |
285 |
284 void MsgUnifiedEditorBody::setAudio(QString& audiofile) |
286 void MsgUnifiedEditorBody::setAudio(QString& audiofile) |
285 { |
287 { |
|
288 // do nothing if filepath is empty |
|
289 if(audiofile.isEmpty()) |
|
290 { |
|
291 return; |
|
292 } |
|
293 |
286 //check for insert conformance |
294 //check for insert conformance |
287 if(EInsertSuccess != mMmsConformanceCheck->checkModeForInsert(audiofile)) |
295 if(EInsertSuccess != mMmsConformanceCheck->checkModeForInsert(audiofile)) |
288 return; |
296 return; |
289 |
297 |
290 setAudio(true); |
298 setAudio(true); |
663 HbTextItem* processingText = new HbTextItem(LOC_PROCESSING,mProcessingWidget); |
676 HbTextItem* processingText = new HbTextItem(LOC_PROCESSING,mProcessingWidget); |
664 processingText->setAlignment(Qt::AlignCenter); |
677 processingText->setAlignment(Qt::AlignCenter); |
665 processingLayout->addItem(processingText); |
678 processingLayout->addItem(processingText); |
666 |
679 |
667 HbIconItem* animationItem = new HbIconItem(ANIMATION_ICON,mProcessingWidget); |
680 HbIconItem* animationItem = new HbIconItem(ANIMATION_ICON,mProcessingWidget); |
|
681 animationItem->setAlignment(Qt::AlignHCenter); |
668 processingLayout->addItem(animationItem); |
682 processingLayout->addItem(animationItem); |
669 |
683 |
670 HbIconAnimator& iconAnimator = animationItem->animator(); |
684 HbIconAnimator& iconAnimator = animationItem->animator(); |
671 HbIconAnimationManager* iconAnimationManager = HbIconAnimationManager::global(); |
685 HbIconAnimationManager* iconAnimationManager = HbIconAnimationManager::global(); |
672 iconAnimationManager->addDefinitionFile(ANIMATION_FILE); |
686 iconAnimationManager->addDefinitionFile(ANIMATION_FILE); |