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