42
|
1 |
/*
|
|
2 |
* Copyright (c) 2010 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 "btdevicedialogrecvquerywidget.h"
|
|
20 |
#include "bluetoothdevicedialogs.h"
|
70
|
21 |
#include "btdevicedialogpluginerrors.h"
|
42
|
22 |
#include <btuiiconutil.h>
|
|
23 |
|
|
24 |
const char* DOCML_BT_RECV_QUERY_DIALOG = ":/docml/bt-receive-auth-dialog.docml";
|
|
25 |
|
|
26 |
|
|
27 |
BTRecvQueryDialogWidget::BTRecvQueryDialogWidget(const QVariantMap ¶meters)
|
70
|
28 |
:mLoader(0),
|
|
29 |
mError(NoError)
|
42
|
30 |
{
|
|
31 |
constructDialog(parameters);
|
|
32 |
}
|
|
33 |
|
|
34 |
BTRecvQueryDialogWidget::~BTRecvQueryDialogWidget()
|
|
35 |
{
|
|
36 |
if(mLoader)
|
|
37 |
{
|
|
38 |
delete mLoader;
|
|
39 |
mLoader = NULL;
|
|
40 |
}
|
|
41 |
}
|
|
42 |
|
|
43 |
bool BTRecvQueryDialogWidget::setDeviceDialogParameters(const QVariantMap ¶meters)
|
|
44 |
{
|
|
45 |
Q_UNUSED(parameters);
|
70
|
46 |
if(!mError)
|
|
47 |
{
|
|
48 |
return true;
|
|
49 |
}
|
|
50 |
else
|
|
51 |
{
|
|
52 |
return false;
|
|
53 |
}
|
42
|
54 |
}
|
|
55 |
|
|
56 |
int BTRecvQueryDialogWidget::deviceDialogError() const
|
|
57 |
{
|
70
|
58 |
return mError;
|
42
|
59 |
}
|
|
60 |
|
|
61 |
void BTRecvQueryDialogWidget::closeDeviceDialog(bool byClient)
|
|
62 |
{
|
|
63 |
Q_UNUSED(byClient);
|
|
64 |
mDialog->close();
|
57
|
65 |
emit deviceDialogClosed();
|
42
|
66 |
}
|
|
67 |
|
|
68 |
HbPopup* BTRecvQueryDialogWidget::deviceDialogWidget() const
|
|
69 |
{
|
|
70 |
return mDialog;
|
|
71 |
}
|
|
72 |
|
|
73 |
QObject* BTRecvQueryDialogWidget::signalSender() const
|
|
74 |
{
|
|
75 |
return const_cast<BTRecvQueryDialogWidget*>(this);
|
|
76 |
}
|
|
77 |
|
70
|
78 |
void BTRecvQueryDialogWidget::constructDialog(const QVariantMap ¶meters)
|
42
|
79 |
{
|
|
80 |
mLoader = new HbDocumentLoader();
|
|
81 |
bool ok = false;
|
|
82 |
|
|
83 |
mLoader->load(DOCML_BT_RECV_QUERY_DIALOG, &ok);
|
|
84 |
if(ok)
|
|
85 |
{
|
57
|
86 |
mDialog = qobject_cast<HbDialog*>(mLoader->findWidget("receiveAuthorizationDialog"));
|
|
87 |
mHeading = qobject_cast<HbLabel*>(mLoader->findWidget("receiveAuthorizationHeading"));
|
42
|
88 |
|
|
89 |
mDeviceName = qobject_cast<HbLabel*>(mLoader->findWidget("deviceName"));
|
|
90 |
mDeviceType = qobject_cast<HbLabel*>(mLoader->findWidget("deviceType"));
|
|
91 |
mDeviceIcon = qobject_cast<HbLabel*>(mLoader->findWidget("deviceIcon"));
|
|
92 |
|
|
93 |
int classOfDevice = parameters.value(QString::number(TBluetoothDeviceDialog::EDeviceClass)).toDouble();
|
|
94 |
HbIcon icon = getBadgedDeviceTypeIcon(classOfDevice);
|
|
95 |
mDeviceIcon->setIcon(icon);
|
|
96 |
|
|
97 |
mDeviceName->setPlainText(parameters.value(QString::number(TBluetoothDeviceDialog::EDeviceName)).toString());
|
|
98 |
mDeviceType->setPlainText(getDeviceTypeString(classOfDevice));
|
|
99 |
|
57
|
100 |
mYesAction = qobject_cast<HbAction*>(mLoader->findObject("yesAction"));
|
|
101 |
mNoAction = qobject_cast<HbAction*>(mLoader->findObject("noAction"));
|
42
|
102 |
|
57
|
103 |
mAuthorizeUser = qobject_cast<HbCheckBox*>(mLoader->findWidget("authorizeUser"));
|
42
|
104 |
|
|
105 |
int dialogType = parameters.value(QString::number(TBluetoothDialogParams::EDialogTitle)).toInt();
|
|
106 |
switch(dialogType)
|
|
107 |
{
|
|
108 |
case TBluetoothDialogParams::EReceive:
|
|
109 |
{
|
|
110 |
mHeading->setPlainText(hbTrId("txt_bt_title_receive_messages_from"));
|
|
111 |
}break;
|
|
112 |
|
|
113 |
case TBluetoothDialogParams::EReceiveFromPairedDevice:
|
|
114 |
{
|
|
115 |
mHeading->setPlainText(hbTrId("txt_bt_title_receive_messages_from_paired_device"));
|
57
|
116 |
mAuthorizeUser->setCheckState(Qt::Checked);
|
42
|
117 |
}break;
|
|
118 |
|
|
119 |
case TBluetoothDialogParams::EConnect:
|
|
120 |
{
|
|
121 |
mHeading->setPlainText(hbTrId("txt_bt_title_connect_to"));
|
57
|
122 |
mAuthorizeUser->setCheckState(Qt::Checked);
|
42
|
123 |
}break;
|
|
124 |
case TBluetoothDialogParams::EPairingRequest:
|
|
125 |
mHeading->setPlainText(hbTrId("txt_bt_title_pair_with"));
|
57
|
126 |
mAuthorizeUser->setCheckState(Qt::Checked);
|
42
|
127 |
break;
|
|
128 |
default:
|
|
129 |
break;
|
|
130 |
|
|
131 |
}
|
|
132 |
mDialog->setHeadingWidget(mHeading);
|
70
|
133 |
|
|
134 |
mDialog->setBackgroundFaded(false);
|
|
135 |
mDialog->setDismissPolicy(HbPopup::NoDismiss);
|
|
136 |
mDialog->setTimeout(HbPopup::NoTimeout);
|
|
137 |
|
|
138 |
connect(mYesAction, SIGNAL(triggered()), this, SLOT(yesClicked()));
|
|
139 |
connect(mNoAction, SIGNAL(triggered()), this, SLOT(noClicked()));
|
|
140 |
connect(mAuthorizeUser, SIGNAL(clicked(bool)), this, SLOT(checkBoxStateChanged(bool)));
|
42
|
141 |
}
|
70
|
142 |
else
|
|
143 |
{
|
|
144 |
mError = DocMLLoadingError;
|
|
145 |
}
|
42
|
146 |
}
|
|
147 |
|
|
148 |
void BTRecvQueryDialogWidget::yesClicked()
|
|
149 |
{
|
|
150 |
QVariantMap data;
|
|
151 |
data.insert(QString("actionResult"), QVariant(true));
|
|
152 |
emit deviceDialogData(data);
|
|
153 |
emit deviceDialogClosed();
|
|
154 |
}
|
|
155 |
|
|
156 |
void BTRecvQueryDialogWidget::noClicked()
|
|
157 |
{
|
|
158 |
QVariantMap data;
|
|
159 |
data.insert(QString("actionResult"), QVariant(false));
|
|
160 |
emit deviceDialogData(data);
|
|
161 |
emit deviceDialogClosed();
|
|
162 |
}
|
|
163 |
|
|
164 |
void BTRecvQueryDialogWidget::checkBoxStateChanged(bool checked)
|
|
165 |
{
|
|
166 |
QVariantMap data;
|
|
167 |
data.insert(QString("checkBoxState"), QVariant(checked));
|
|
168 |
emit deviceDialogData(data);
|
|
169 |
}
|
|
170 |
|
|
171 |
|
|
172 |
|