| 5aacaa9 by Michael Leibowitz at 2010-08-27 |
1 |
/* -*- Mode: C++ -*- |
|
2 |
* meegotouchcp-telephony: a telephony control panel applet |
|
3 |
* Copyright (c) 2010, Intel Corporation. |
|
4 |
* |
|
5 |
* This program is licensed under the terms and conditions of the |
|
6 |
* Apache License, version 2.0. The full text of the Apache License is at |
|
7 |
* http://www.apache.org/licenses/LICENSE-2.0 |
|
8 |
* |
|
9 |
*/ |
|
10 |
|
|
11 |
#include "telephonywidget.h" |
|
12 |
#include "propertyeditor.h" |
| 920d59d by Michael Leibowitz at 2010-09-16 |
13 |
#include "callsettingspropertyeditor.h" |
| 5aacaa9 by Michael Leibowitz at 2010-08-27 |
14 |
|
| 920d59d by Michael Leibowitz at 2010-09-16 |
15 |
#include <modemproxy.h> |
| 5aacaa9 by Michael Leibowitz at 2010-08-27 |
16 |
#include <managerproxy.h> |
|
17 |
#include <MButton> |
|
18 |
#include <QDebug> |
|
19 |
#include <QSignalMapper> |
|
20 |
|
|
21 |
//% "String telling user their current phone number %1 contains the phone number" |
|
22 |
const QString TelephonyWidget::numberTemplate = qtTrId("My number: %1"); |
|
23 |
|
|
24 |
TelephonyWidget::TelephonyWidget(QGraphicsWidget *parent) : DcpWidget(parent) |
|
25 |
{ |
| 49e960a by Michael Leibowitz at 2010-09-17 |
26 |
m_layout = new QGraphicsLinearLayout(Qt::Vertical); |
| 5aacaa9 by Michael Leibowitz at 2010-08-27 |
27 |
QSignalMapper *mapper = new QSignalMapper(this); |
|
28 |
|
|
29 |
ManagerProxy *manager = ManagerProxy::instance(); |
|
30 |
ModemProxy *modem = manager->modem(); //FIXME, when API is changed |
|
31 |
//to multiple modems, this |
|
32 |
//needs change |
| 920d59d by Michael Leibowitz at 2010-09-16 |
33 |
SettingsManager *settingsManager = new SettingsManager(modem->path()); |
| 49e960a by Michael Leibowitz at 2010-09-17 |
34 |
ForwardingManager *forwardingManager = new ForwardingManager(modem->path()); |
| 920d59d by Michael Leibowitz at 2010-09-16 |
35 |
|
| 5aacaa9 by Michael Leibowitz at 2010-08-27 |
36 |
m_networkProxy = new NetworkProxy(modem->path()); |
|
37 |
m_simManager = new SimManager(modem->path()); |
|
38 |
m_radioSettingsProxy = new RadioSettingsProxy(modem->path()); |
|
39 |
|
| d676841 by Michael Leibowitz at 2010-09-23 |
40 |
//% "My number:" |
|
41 |
QString myNumber = qtTrId("qtn_my_number"); |
| b64151c by Michael Leibowitz at 2010-09-15 |
42 |
AbstractPropertyEditor *numberPropertyEditor = |
|
43 |
PropertyEditorFactory::createEditor(m_simManager, |
|
44 |
"subscriberNumbers", |
| d676841 by Michael Leibowitz at 2010-09-23 |
45 |
myNumber, |
| b64151c by Michael Leibowitz at 2010-09-15 |
46 |
"SubscriberNumberPropertyEditor"); |
|
47 |
Q_ASSERT(numberPropertyEditor); |
| 49e960a by Michael Leibowitz at 2010-09-17 |
48 |
m_layout->addItem(numberPropertyEditor); |
| 920d59d by Michael Leibowitz at 2010-09-16 |
49 |
|
| d676841 by Michael Leibowitz at 2010-09-23 |
50 |
//% "Send My Caller ID" |
|
51 |
QString sendCallerId = qtTrId("qtn_send_caller_id"); |
| 920d59d by Michael Leibowitz at 2010-09-16 |
52 |
AbstractPropertyEditor *hideCallerIdEditor = |
|
53 |
PropertyEditorFactory::createEditor(settingsManager, |
|
54 |
"hideCallerId", |
|
55 |
sendCallerId, |
|
56 |
"CallSettingsPropertyEditor"); |
|
57 |
Q_ASSERT(hideCallerIdEditor); |
| 49e960a by Michael Leibowitz at 2010-09-17 |
58 |
m_layout->addItem(hideCallerIdEditor); |
| 5aacaa9 by Michael Leibowitz at 2010-08-27 |
59 |
|
| d676841 by Michael Leibowitz at 2010-09-23 |
60 |
//% "Hear Call Waiting" |
|
61 |
QString hearCallWaiting = qtTrId("qtn_hear_call_waiting"); |
| 920d59d by Michael Leibowitz at 2010-09-16 |
62 |
AbstractPropertyEditor *callWaitingEditor = |
|
63 |
PropertyEditorFactory::createEditor(settingsManager, |
|
64 |
"voiceCallWaiting", |
|
65 |
hearCallWaiting, |
|
66 |
"CallSettingsPropertyEditor"); |
|
67 |
Q_ASSERT(callWaitingEditor); |
| 49e960a by Michael Leibowitz at 2010-09-17 |
68 |
m_layout->addItem(callWaitingEditor); |
| 920d59d by Michael Leibowitz at 2010-09-16 |
69 |
|
| d676841 by Michael Leibowitz at 2010-09-23 |
70 |
//% "3g" |
|
71 |
QString threeG = qtTrId("qtn_three_gee"); |
| 920d59d by Michael Leibowitz at 2010-09-16 |
72 |
AbstractPropertyEditor *technologyPropertyEditor = |
|
73 |
PropertyEditorFactory::createEditor(m_radioSettingsProxy, |
|
74 |
"technologyPreference", |
|
75 |
threeG, |
|
76 |
"RadioSettingsPropertyEditor"); |
|
77 |
Q_ASSERT(technologyPropertyEditor); |
| 49e960a by Michael Leibowitz at 2010-09-17 |
78 |
m_layout->addItem(technologyPropertyEditor); |
| 5aacaa9 by Michael Leibowitz at 2010-08-27 |
79 |
|
| 920d59d by Michael Leibowitz at 2010-09-16 |
80 |
m_nagItem = new MGConfItem("/apps/dialer/supressContactNag", this); |
|
81 |
connect(m_nagItem, SIGNAL(valueChanged()), |
|
82 |
SLOT(nagChanged())); |
| 49e960a by Michael Leibowitz at 2010-09-17 |
83 |
MWidget *widget = new MWidget(); |
| 920d59d by Michael Leibowitz at 2010-09-16 |
84 |
QGraphicsLinearLayout *nagLayout = new QGraphicsLinearLayout(Qt::Horizontal); |
| 49e960a by Michael Leibowitz at 2010-09-17 |
85 |
widget->setLayout(nagLayout); |
|
86 |
//% "Prompt to add contact" |
|
87 |
MLabel *label = new MLabel(qtTrId("qtn_contact_nag")); |
| 920d59d by Michael Leibowitz at 2010-09-16 |
88 |
label->setWordWrap(true); |
|
89 |
nagLayout->addItem(label); |
|
90 |
m_nagButton = new MButton(); |
|
91 |
m_nagButton->setViewType(MButton::switchType); |
|
92 |
m_nagButton->setCheckable(true); |
|
93 |
nagChanged(); |
|
94 |
connect(m_nagButton, SIGNAL(toggled(bool)), |
|
95 |
SLOT(nagButtonToggled(bool))); |
|
96 |
nagLayout->addItem(m_nagButton); |
|
97 |
nagLayout->setAlignment(m_nagButton, Qt::AlignVCenter); |
| 49e960a by Michael Leibowitz at 2010-09-17 |
98 |
m_layout->addItem(widget); |
|
99 |
|
|
100 |
//% "Forward All Calls" |
|
101 |
QString forwardAllCalls = qtTrId("qtn_forward_all_calls"); |
|
102 |
m_unconditional = dynamic_cast<CallForwardingPropertyEditor*>(PropertyEditorFactory::createEditor(forwardingManager, |
|
103 |
"voiceUnconditional", |
|
104 |
forwardAllCalls, |
|
105 |
"CallForwardingPropertyEditor")); |
|
106 |
Q_ASSERT(m_unconditional); |
|
107 |
connect(m_unconditional, SIGNAL(toggled(bool)), |
|
108 |
SLOT(unconditionalToggled(bool))); |
|
109 |
//% "Call Forwarding" |
|
110 |
m_forwardingButton = new MButton(qtTrId("qtn_call_forwarding_button")); |
|
111 |
mapper->setMapping(m_forwardingButton, 2); |
|
112 |
connect(m_forwardingButton, SIGNAL(clicked()), |
|
113 |
mapper, SLOT(map())); |
|
114 |
m_layout->addItem(m_unconditional); |
| 920d59d by Michael Leibowitz at 2010-09-16 |
115 |
|
|
116 |
//% "Set Speed Dial" |
|
117 |
MButton *button = new MButton(qtTrId("qtn_speed_dial_button")); |
|
118 |
button->setObjectName("speedDialButton"); |
|
119 |
mapper->setMapping(button, 3); //FIXME: move to #define or static const int |
| 5aacaa9 by Michael Leibowitz at 2010-08-27 |
120 |
connect(button, SIGNAL(clicked()), |
|
121 |
mapper, SLOT(map())); |
| 49e960a by Michael Leibowitz at 2010-09-17 |
122 |
m_layout->addItem(button); |
| 5aacaa9 by Michael Leibowitz at 2010-08-27 |
123 |
|
| abafe9e by Michael Leibowitz at 2010-09-17 |
124 |
//% "Call Barring Settings" |
|
125 |
button = new MButton(qtTrId("qtn_barring_settings_button")); |
| 5aacaa9 by Michael Leibowitz at 2010-08-27 |
126 |
button->setObjectName("barringSettingsButton"); |
|
127 |
mapper->setMapping(button, 5); //FIXME: not defined |
|
128 |
connect(button, SIGNAL(clicked()), |
|
129 |
mapper, SLOT(map())); |
| 49e960a by Michael Leibowitz at 2010-09-17 |
130 |
m_layout->addItem(button); |
| 5aacaa9 by Michael Leibowitz at 2010-08-27 |
131 |
|
|
132 |
connect(mapper, SIGNAL(mapped(int)), |
|
133 |
SLOT(mapped(int))); |
|
134 |
|
|
135 |
|
| 49e960a by Michael Leibowitz at 2010-09-17 |
136 |
m_layout->addStretch(); |
| 5aacaa9 by Michael Leibowitz at 2010-08-27 |
137 |
|
| 49e960a by Michael Leibowitz at 2010-09-17 |
138 |
setLayout(m_layout); |
| 5aacaa9 by Michael Leibowitz at 2010-08-27 |
139 |
} |
|
140 |
|
|
141 |
TelephonyWidget::~TelephonyWidget() |
|
142 |
{ |
|
143 |
qDebug() << "TelephonyWidget::~TelephonyWidget()"; |
| 49e960a by Michael Leibowitz at 2010-09-17 |
144 |
if (m_forwardingButton) { |
|
145 |
m_forwardingButton->deleteLater(); |
|
146 |
} |
| 5aacaa9 by Michael Leibowitz at 2010-08-27 |
147 |
} |
|
148 |
|
|
149 |
bool TelephonyWidget::back() |
|
150 |
{ |
|
151 |
return true; |
|
152 |
} |
|
153 |
|
|
154 |
QString TelephonyWidget::title() const |
|
155 |
{ |
|
156 |
return "Dialer Settings"; |
|
157 |
} |
|
158 |
|
|
159 |
void TelephonyWidget::mapped(int widgetNumber) |
|
160 |
{ |
|
161 |
qDebug() << "TelephonyWidget::mapped(" << widgetNumber << ")"; |
|
162 |
changeWidget(widgetNumber); |
|
163 |
} |
|
164 |
|
|
165 |
|
|
166 |
void TelephonyWidget::subscriberNumbersChanged(const QStringList &subscriberNumbers) |
|
167 |
{ |
|
168 |
if (subscriberNumbers.count()) { |
|
169 |
m_phoneNumberLabel->setText(numberTemplate.arg(subscriberNumbers[0])); |
|
170 |
} else { |
|
171 |
qWarning() << "subscriberNumbersChanged but still count is zero"; |
|
172 |
} |
|
173 |
} |
| 920d59d by Michael Leibowitz at 2010-09-16 |
174 |
|
|
175 |
void TelephonyWidget::nagButtonToggled(bool checked) |
|
176 |
{ |
|
177 |
m_nagItem->set(checked); |
|
178 |
} |
|
179 |
|
|
180 |
void TelephonyWidget::nagChanged() |
|
181 |
{ |
|
182 |
m_nagButton->setChecked(m_nagItem->value().toBool()); |
|
183 |
} |
| 49e960a by Michael Leibowitz at 2010-09-17 |
184 |
|
|
185 |
void TelephonyWidget::unconditionalToggled(bool checked) |
|
186 |
{ |
|
187 |
if (checked) { |
|
188 |
m_forwardingButton->hide(); |
|
189 |
m_layout->removeItem(m_forwardingButton); |
|
190 |
|
|
191 |
} else { |
|
192 |
m_forwardingButton->show(); |
|
193 |
m_layout->insertItem(6, m_forwardingButton); |
|
194 |
} |
|
195 |
} |