42
|
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: BtDeviceDialogWidget class declaration.
|
|
15 |
*
|
|
16 |
*/
|
|
17 |
|
|
18 |
|
|
19 |
#include "btrecvprgrsdialogwidget.h"
|
|
20 |
#include "bluetoothdevicedialogs.h"
|
|
21 |
|
|
22 |
const char* DOCML_BT_RECV_PRGRS_DIALOG = ":/docml/bt-recv-progress-dialog.docml";
|
|
23 |
|
|
24 |
|
|
25 |
BTRecvPrgrsDialogWidget::BTRecvPrgrsDialogWidget(const QVariantMap ¶meters)
|
|
26 |
{
|
|
27 |
mLoader = 0;
|
|
28 |
constructDialog(parameters);
|
|
29 |
}
|
|
30 |
|
|
31 |
BTRecvPrgrsDialogWidget::~BTRecvPrgrsDialogWidget()
|
|
32 |
{
|
|
33 |
if(mLoader)
|
|
34 |
{
|
|
35 |
delete mLoader;
|
|
36 |
mLoader = NULL;
|
|
37 |
}
|
|
38 |
}
|
|
39 |
|
|
40 |
bool BTRecvPrgrsDialogWidget::setDeviceDialogParameters(const QVariantMap ¶meters)
|
|
41 |
{
|
|
42 |
mProgressBar->setMinimum(0);
|
|
43 |
mProgressBar->setMaximum(mFileSz);
|
|
44 |
mProgressBar->setProgressValue(parameters.value("progress").toInt());
|
|
45 |
return true;
|
|
46 |
}
|
|
47 |
|
|
48 |
int BTRecvPrgrsDialogWidget::deviceDialogError() const
|
|
49 |
{
|
|
50 |
return 0;
|
|
51 |
}
|
|
52 |
|
|
53 |
void BTRecvPrgrsDialogWidget::closeDeviceDialog(bool byClient)
|
|
54 |
{
|
|
55 |
Q_UNUSED(byClient);
|
|
56 |
mDialog->close();
|
|
57 |
}
|
|
58 |
|
|
59 |
HbPopup* BTRecvPrgrsDialogWidget::deviceDialogWidget() const
|
|
60 |
{
|
|
61 |
return mDialog;
|
|
62 |
}
|
|
63 |
|
|
64 |
QObject* BTRecvPrgrsDialogWidget::signalSender() const
|
|
65 |
{
|
|
66 |
return const_cast<BTRecvPrgrsDialogWidget*>(this);
|
|
67 |
}
|
|
68 |
|
|
69 |
bool BTRecvPrgrsDialogWidget::constructDialog(const QVariantMap ¶meters)
|
|
70 |
{
|
|
71 |
mLoader = new HbDocumentLoader();
|
|
72 |
bool ok = false;
|
|
73 |
|
|
74 |
mLoader->load(DOCML_BT_RECV_PRGRS_DIALOG, &ok);
|
|
75 |
if(ok)
|
|
76 |
{
|
|
77 |
mDialog = qobject_cast<HbDialog*>(mLoader->findWidget("senddialog"));
|
|
78 |
mHeading = qobject_cast<HbLabel*>(mLoader->findWidget("heading"));
|
|
79 |
|
|
80 |
mFileName = qobject_cast<HbLabel*>(mLoader->findWidget("fileName"));
|
|
81 |
mFileSize = qobject_cast<HbLabel*>(mLoader->findWidget("fileSize"));
|
|
82 |
mFileCount = qobject_cast<HbLabel*>(mLoader->findWidget("fileCount_label"));
|
|
83 |
mFileCount->setVisible(false);
|
|
84 |
|
|
85 |
//TODO - set icon based on the file icon.
|
|
86 |
|
|
87 |
mHide = qobject_cast<HbAction*>(mLoader->findObject("hideaction"));
|
|
88 |
mCancel = qobject_cast<HbAction*>(mLoader->findObject("cancelaction"));
|
|
89 |
|
|
90 |
mProgressBar = qobject_cast<HbProgressBar*>(mLoader->findWidget("horizontalProgressBar"));
|
|
91 |
|
|
92 |
int dialogType = parameters.value(QString::number(TBluetoothDialogParams::EDialogTitle)).toInt();
|
|
93 |
switch(dialogType)
|
|
94 |
{
|
|
95 |
case TBluetoothDialogParams::EReceive:
|
|
96 |
{
|
|
97 |
QString headingStr(hbTrId("txt_bt_title_receiving_files_from_1"));
|
|
98 |
QString senderName(parameters.value(QString::number(TBluetoothDeviceDialog::EDeviceName)).toString());
|
|
99 |
mHeading->setPlainText(headingStr.arg(senderName));
|
|
100 |
}break;
|
|
101 |
|
|
102 |
default:
|
|
103 |
break;
|
|
104 |
}
|
|
105 |
mDialog->setHeadingWidget(mHeading);
|
|
106 |
|
|
107 |
mFileName->setPlainText(parameters.value(QString::number(TBluetoothDeviceDialog::EReceivingFileName)).toString());
|
|
108 |
|
|
109 |
mFileSz = parameters.value(QString::number(TBluetoothDeviceDialog::EReceivingFileSize)).toInt();
|
|
110 |
mProgressBar->setMinimum(0);
|
|
111 |
mProgressBar->setMaximum(mFileSz);
|
|
112 |
mProgressBar->setProgressValue(0);
|
|
113 |
|
|
114 |
//Format the file size into a more readable format
|
|
115 |
if ( mFileSz >> 20 ) // size in MB
|
|
116 |
{
|
|
117 |
float sizeInMB = 0;
|
|
118 |
sizeInMB = ((float)mFileSz ) / (1024*1024);
|
|
119 |
QString fileSzMb;
|
|
120 |
fileSzMb.setNum(sizeInMB);
|
47
|
121 |
//TODO - check for localization
|
42
|
122 |
fileSzMb.append(QString(" Mb"));
|
|
123 |
mFileSize->setPlainText(fileSzMb);
|
|
124 |
}
|
|
125 |
|
|
126 |
else if( mFileSz >> 10 ) // size in KB
|
|
127 |
{
|
|
128 |
TInt64 sizeInKB = 0;
|
|
129 |
sizeInKB = mFileSz >> 10;
|
|
130 |
QString fileSzKb;
|
|
131 |
fileSzKb.setNum(sizeInKB);
|
47
|
132 |
//TODO - check for localization
|
42
|
133 |
fileSzKb.append(QString(" Kb"));
|
|
134 |
mFileSize->setPlainText(fileSzKb);
|
|
135 |
}
|
|
136 |
|
|
137 |
else // size is unknown or less than 1K
|
|
138 |
{
|
|
139 |
QString fileSzB;
|
|
140 |
fileSzB.setNum(mFileSz);
|
47
|
141 |
//TODO - check for localization
|
42
|
142 |
fileSzB.append(QString(" Bytes"));
|
|
143 |
mFileSize->setPlainText(fileSzB);
|
|
144 |
}
|
|
145 |
|
|
146 |
//Set the received file count
|
|
147 |
int fCnt = parameters.value(QString::number(TBluetoothDeviceDialog::EReceivedFileCount)).toInt();
|
|
148 |
if(fCnt > 0)
|
|
149 |
{
|
|
150 |
mFileCount->setVisible(true);
|
|
151 |
|
47
|
152 |
QString fCntStr(hbTrId("txt_bt_info_ln_files_already_received", fCnt));
|
|
153 |
mFileCount->setPlainText(fCntStr);
|
42
|
154 |
}
|
|
155 |
}
|
|
156 |
|
|
157 |
mDialog->setBackgroundFaded(false);
|
|
158 |
mDialog->setDismissPolicy(HbPopup::NoDismiss);
|
|
159 |
mDialog->setTimeout(HbPopup::NoTimeout);
|
|
160 |
|
|
161 |
connect(mHide, SIGNAL(triggered()), this, SLOT(hideClicked()));
|
|
162 |
connect(mCancel, SIGNAL(triggered()), this, SLOT(cancelClicked()));
|
|
163 |
|
|
164 |
return true;
|
|
165 |
}
|
|
166 |
|
|
167 |
void BTRecvPrgrsDialogWidget::hideClicked()
|
|
168 |
{
|
|
169 |
QVariantMap data;
|
47
|
170 |
data.insert(QString("actionResult"), QVariant(TBluetoothDialogParams::EHide));
|
42
|
171 |
emit deviceDialogData(data);
|
|
172 |
emit deviceDialogClosed();
|
|
173 |
}
|
|
174 |
|
|
175 |
void BTRecvPrgrsDialogWidget::cancelClicked()
|
|
176 |
{
|
|
177 |
QVariantMap data;
|
47
|
178 |
data.insert(QString("actionResult"), QVariant(TBluetoothDialogParams::ECancelReceive));
|
42
|
179 |
emit deviceDialogData(data);
|
|
180 |
emit deviceDialogClosed();
|
|
181 |
}
|
|
182 |
|