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