|
1 /* |
|
2 # |
|
3 # Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). |
|
4 # All rights reserved. |
|
5 # |
|
6 # This program is free software: you can redistribute it and/or modify |
|
7 # it under the terms of the GNU Lesser General Public License as published by |
|
8 # the Free Software Foundation, version 2.1 of the License. |
|
9 # |
|
10 # This program is distributed in the hope that it will be useful, |
|
11 # but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
12 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
13 # GNU Lesser General Public License for more details. |
|
14 # |
|
15 # You should have received a copy of the GNU Lesser General Public License |
|
16 # along with this program. If not, |
|
17 # see "http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html/". |
|
18 # |
|
19 # Description: |
|
20 # |
|
21 */ |
|
22 |
|
23 #include <QDebug> |
|
24 #include <QApplication> |
|
25 #include <QKeyEvent> |
|
26 #include <QLabel> |
|
27 #include <QVBoxLayout> |
|
28 #include <QGridLayout> |
|
29 #include <QStackedWidget> |
|
30 #include <QImageReader> |
|
31 #include <QDebug> |
|
32 #include <QTimer> |
|
33 #include <QPushButton> |
|
34 #include <QLineEdit> |
|
35 #include <QDebug> |
|
36 #include <QString> |
|
37 #include <QCheckBox> |
|
38 |
|
39 #include <QListView> |
|
40 #include <QMap> |
|
41 #include <QAction> |
|
42 |
|
43 #include "ststest.h" |
|
44 #include <XQSystemToneService> |
|
45 |
|
46 STSTest::STSTest( QWidget *parent) |
|
47 : |
|
48 QMainWindow(parent), |
|
49 sts(new XQSystemToneService()) |
|
50 { |
|
51 qDebug() << QString("[sts] STSTest::STSTest 1"); |
|
52 QWidget *window = new QWidget(this); |
|
53 qDebug() << QString("[sts] STSTest::STSTest 2"); |
|
54 QVBoxLayout* layout = new QVBoxLayout(this); |
|
55 |
|
56 callbackCleanTimer.setSingleShot(true); |
|
57 connect(&callbackCleanTimer, SIGNAL(timeout()), this, SLOT(cleanCallback())); |
|
58 |
|
59 QPushButton *quitButton = new QPushButton("QUIT", this); |
|
60 connect(quitButton, SIGNAL(clicked()), qApp, SLOT(quit())); |
|
61 |
|
62 QPushButton *playToneButton = new QPushButton("Play Tone", this); |
|
63 connect(playToneButton, SIGNAL(clicked()), this, SLOT(playTone())); |
|
64 |
|
65 QPushButton *playAlarmButton = new QPushButton("Play Alarm", this); |
|
66 connect(playAlarmButton, SIGNAL(clicked()), this, SLOT(playAlarm())); |
|
67 |
|
68 QPushButton *playAlarmAsToneButton = new QPushButton("Play Alarm as Tone", this); |
|
69 connect(playAlarmAsToneButton, SIGNAL(clicked()), this, SLOT(playAlarmAsTone())); |
|
70 |
|
71 QPushButton *stopAlarmButton = new QPushButton("Stop Alarm", this); |
|
72 connect(stopAlarmButton, SIGNAL(clicked()), this, SLOT(stopAlarm())); |
|
73 |
|
74 |
|
75 connect(sts, SIGNAL(toneStarted()), this, SLOT(startCallback())); |
|
76 connect(sts, SIGNAL(alarmStarted(unsigned int)), this, SLOT(startCallback(unsigned int))); |
|
77 connect(sts, SIGNAL(alarmFinished(unsigned int)), this, SLOT(stopCallback(unsigned int))); |
|
78 |
|
79 qDebug() << QString("[sts] STSTest::STSTest 3"); |
|
80 |
|
81 box = new QComboBox(this); |
|
82 spinBox = new QSpinBox(this); |
|
83 |
|
84 layout->setMargin(10); |
|
85 layout->setSpacing(0); |
|
86 qDebug() << QString("[sts] STSTest::STSTest 4"); |
|
87 QList<QPair<int, QString> > tonesList; |
|
88 |
|
89 |
|
90 // alarms |
|
91 tonesList.append(QPair<int,QString>(XQSystemToneService::CalendarAlarmTone, "[A] Calendar Alarm")); |
|
92 tonesList.append(QPair<int,QString>(XQSystemToneService::ClockAlarmTone, "[A] Clock Alarm")); |
|
93 tonesList.append(QPair<int,QString>(XQSystemToneService::ToDoAlarmTone, "[A] ToDo Alarm")); |
|
94 |
|
95 tonesList.append(QPair<int,QString>(XQSystemToneService::IncomingCallTone, "[A] Incoming Call")); |
|
96 tonesList.append(QPair<int,QString>(XQSystemToneService::IncomingCallLine2Tone, "[A] Incomming Call Line 2")); |
|
97 tonesList.append(QPair<int,QString>(XQSystemToneService::IncomingDataCallTone, "[A] Incomming Data Call")); |
|
98 |
|
99 // tones |
|
100 tonesList.append(QPair<int,QString>(XQSystemToneService::BurstModeTone, "[T] Burst Mode")); |
|
101 tonesList.append(QPair<int,QString>(XQSystemToneService::CaptureTone, "[T] Capture")); |
|
102 tonesList.append(QPair<int,QString>(XQSystemToneService::CallRecordingTone, "[T] Call Recording")); |
|
103 tonesList.append(QPair<int,QString>(XQSystemToneService::RecordingStartTone, "[T] Recording Start")); |
|
104 tonesList.append(QPair<int,QString>(XQSystemToneService::SelfTimerTone, "[T] Self Timer")); |
|
105 |
|
106 tonesList.append(QPair<int,QString>(XQSystemToneService::ConfirmationBeepTone, "[T] Confirmation Beep")); |
|
107 tonesList.append(QPair<int,QString>(XQSystemToneService::DefaultBeepTone, "[T] Default Beep")); |
|
108 tonesList.append(QPair<int,QString>(XQSystemToneService::ErrorBeepTone, "[T] Error Beep")); |
|
109 tonesList.append(QPair<int,QString>(XQSystemToneService::InformationBeepTone, "[T] Information Beep")); |
|
110 tonesList.append(QPair<int,QString>(XQSystemToneService::WarningBeepTone, "[T] Warning Beep")); |
|
111 tonesList.append(QPair<int,QString>(XQSystemToneService::IntegratedHandsFreeActivatedTone, "[T] Integrated Hands Free Act.")); |
|
112 |
|
113 tonesList.append(QPair<int,QString>(XQSystemToneService::TouchScreenTone, "[T] Touch Screen")); |
|
114 |
|
115 tonesList.append(QPair<int,QString>(XQSystemToneService::ChatAlertTone, "[T] Chat Alert")); |
|
116 tonesList.append(QPair<int,QString>(XQSystemToneService::EmailAlertTone, "[T] Email Alert")); |
|
117 tonesList.append(QPair<int,QString>(XQSystemToneService::MmsAlertTone, "[T] MMS Alert")); |
|
118 tonesList.append(QPair<int,QString>(XQSystemToneService::SmsAlertTone, "[T] SMS Alert")); |
|
119 tonesList.append(QPair<int,QString>(XQSystemToneService::DeliveryReportTone, "[T] Delivery Report")); |
|
120 tonesList.append(QPair<int,QString>(XQSystemToneService::MessageSendFailureTone, "[T] Message Send Failure")); |
|
121 |
|
122 tonesList.append(QPair<int,QString>(XQSystemToneService::BatteryLowTone, "[T] Battery Low")); |
|
123 tonesList.append(QPair<int,QString>(XQSystemToneService::BatteryRechargedTone, "[T] Battery Recharge")); |
|
124 tonesList.append(QPair<int,QString>(XQSystemToneService::PowerOnTone, "[T] Power On")); |
|
125 tonesList.append(QPair<int,QString>(XQSystemToneService::PowerOffTone, "[T] Power Off")); |
|
126 tonesList.append(QPair<int,QString>(XQSystemToneService::WakeUpTone, "[T] Wake Up")); |
|
127 tonesList.append(QPair<int,QString>(XQSystemToneService::WrongChargerTone, "[T] Wrong Charger")); |
|
128 |
|
129 tonesList.append(QPair<int,QString>(XQSystemToneService::AutomaticRedialCompleteTone, "[T] Automatic Redial Compl.")); |
|
130 |
|
131 tonesList.append(QPair<int,QString>(XQSystemToneService::VoiceStartTone, "[T] Voice Start")); |
|
132 tonesList.append(QPair<int,QString>(XQSystemToneService::VoiceErrorTone, "[T] Voice Error")); |
|
133 tonesList.append(QPair<int,QString>(XQSystemToneService::VoiceAbortTone, "[T] Voice Abort")); |
|
134 |
|
135 qDebug() << QString("[sts] STSTest::STSTest 5"); |
|
136 QListIterator<QPair<int, QString> > iter(tonesList); |
|
137 while (iter.hasNext()) { |
|
138 QPair<int, QString> item = iter.next(); |
|
139 box->addItem(item.second, item.first); |
|
140 } |
|
141 |
|
142 layout->addStretch(4); |
|
143 layout->addWidget(box); |
|
144 |
|
145 qDebug() << QString("[sts] STSTest::STSTest 6"); |
|
146 layout->addStretch(1); |
|
147 layout->addWidget(playToneButton); |
|
148 layout->addStretch(1); |
|
149 layout->addWidget(playAlarmButton); |
|
150 layout->addStretch(1); |
|
151 layout->addWidget(playAlarmAsToneButton); |
|
152 layout->addStretch(1); |
|
153 currCtxLabel = new QLabel("Last context: ?", this); |
|
154 layout->addWidget(currCtxLabel); |
|
155 layout->addStretch(2); |
|
156 layout->addWidget(stopAlarmButton); |
|
157 layout->addStretch(1); |
|
158 layout->addWidget(new QLabel("Context:", this)); |
|
159 layout->addWidget(spinBox); |
|
160 |
|
161 layout->addStretch(1); |
|
162 callbackLabel = new QLabel("SIGNALS: ---", this); |
|
163 layout->addWidget(callbackLabel); |
|
164 |
|
165 layout->addStretch(4); |
|
166 layout->addWidget(quitButton); |
|
167 |
|
168 |
|
169 window->setLayout(layout); |
|
170 setCentralWidget(window); |
|
171 window->show();; |
|
172 |
|
173 } |
|
174 |
|
175 STSTest::~STSTest() |
|
176 { |
|
177 delete sts; |
|
178 } |
|
179 |
|
180 void STSTest::playTone() |
|
181 { |
|
182 int id = box->itemData(box->currentIndex(), Qt::UserRole).toInt(); |
|
183 |
|
184 qDebug("Beep!!! (%d)", id); |
|
185 |
|
186 sts->playTone((XQSystemToneService::ToneType)id); |
|
187 |
|
188 currCtxLabel->setText(QString("Last context: -")); |
|
189 } |
|
190 |
|
191 void STSTest::playAlarm() |
|
192 { |
|
193 int id = box->itemData(box->currentIndex(), Qt::UserRole).toInt(); |
|
194 |
|
195 qDebug("Beep!!! (%d)", id); |
|
196 unsigned int ctx = 0; |
|
197 |
|
198 sts->playAlarm((XQSystemToneService::AlarmType)id, ctx); |
|
199 |
|
200 currCtxLabel->setText(QString("Last context: %1").arg(ctx)); |
|
201 } |
|
202 |
|
203 void STSTest::playAlarmAsTone() |
|
204 { |
|
205 int id = box->itemData(box->currentIndex(), Qt::UserRole).toInt(); |
|
206 |
|
207 qDebug("Beep!!! (%d)", id); |
|
208 unsigned int ctx = 0; |
|
209 |
|
210 sts->playAlarm((XQSystemToneService::ToneType)id, ctx); |
|
211 |
|
212 currCtxLabel->setText(QString("Last context: %1").arg(ctx)); |
|
213 } |
|
214 |
|
215 void STSTest::stopAlarm() |
|
216 { |
|
217 int ctx = spinBox->value(); |
|
218 |
|
219 qDebug("Silence! (%d)", ctx); |
|
220 sts->stopAlarm(ctx); |
|
221 } |
|
222 |
|
223 void STSTest::startCallback() |
|
224 { |
|
225 callbackLabel->setText(QString("SIGNALS: playing tone started...")); |
|
226 callbackCleanTimer.start(1000); |
|
227 } |
|
228 |
|
229 void STSTest::startCallback(unsigned int ctx) |
|
230 { |
|
231 callbackLabel->setText(QString("SIGNALS: (%1) playing alarm started...").arg(ctx)); |
|
232 callbackCleanTimer.start(1000); |
|
233 } |
|
234 |
|
235 void STSTest::stopCallback(unsigned int ctx) |
|
236 { |
|
237 callbackLabel->setText(QString("SIGNALS: (%1) playing alarm finished...").arg(ctx)); |
|
238 callbackCleanTimer.start(1000); |
|
239 } |
|
240 |
|
241 void STSTest::cleanCallback() |
|
242 { |
|
243 callbackLabel->setText("SIGNALS: ---"); |
|
244 } |
|
245 |
|
246 int main(int argc, char* argv[]) |
|
247 { |
|
248 QApplication app(argc, argv); |
|
249 |
|
250 STSTest* tester = new STSTest(); |
|
251 tester->showMaximized(); |
|
252 |
|
253 int rv = app.exec(); |
|
254 delete tester; |
|
255 return rv; |
|
256 } |
|
257 |