|
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, Qt::WFlags f ) |
|
47 : |
|
48 QWidget(parent, f), |
|
49 sts(new XQSystemToneService()) |
|
50 { |
|
51 callbackCleanTimer.setSingleShot(true); |
|
52 connect(&callbackCleanTimer, SIGNAL(timeout()), this, SLOT(cleanCallback())); |
|
53 |
|
54 QPushButton *quitButton = new QPushButton(tr("QUIT")); |
|
55 connect(quitButton, SIGNAL(clicked()), qApp, SLOT(quit())); |
|
56 |
|
57 QPushButton *playToneButton = new QPushButton(tr("Play Tone")); |
|
58 connect(playToneButton, SIGNAL(clicked()), this, SLOT(playTone())); |
|
59 |
|
60 QPushButton *playAlarmButton = new QPushButton(tr("Play Alarm")); |
|
61 connect(playAlarmButton, SIGNAL(clicked()), this, SLOT(playAlarm())); |
|
62 |
|
63 QPushButton *stopAlarmButton = new QPushButton(tr("Stop Alarm")); |
|
64 connect(stopAlarmButton, SIGNAL(clicked()), this, SLOT(stopAlarm())); |
|
65 |
|
66 |
|
67 connect(sts, SIGNAL(toneStarted()), this, SLOT(startCallback())); |
|
68 connect(sts, SIGNAL(alarmStarted(unsigned int)), this, SLOT(startCallback(unsigned int))); |
|
69 connect(sts, SIGNAL(alarmFinished(unsigned int)), this, SLOT(stopCallback(unsigned int))); |
|
70 |
|
71 |
|
72 box = new QComboBox(); |
|
73 spinBox = new QSpinBox(); |
|
74 |
|
75 QVBoxLayout *vl = new QVBoxLayout; |
|
76 QGridLayout *gl = new QGridLayout(); |
|
77 |
|
78 vl->setMargin(10); |
|
79 vl->setSpacing(0); |
|
80 |
|
81 // gl->setMargin(0); |
|
82 // gl->setSpacing(0); |
|
83 // gl->setDefaultPositioning(); |
|
84 |
|
85 |
|
86 QList<QPair<int, QString> > tonesList; |
|
87 |
|
88 |
|
89 // alarms |
|
90 tonesList.append(QPair<int,QString>(XQSystemToneService::CalendarAlarmTone, "[A] Calendar Alarm")); |
|
91 tonesList.append(QPair<int,QString>(XQSystemToneService::ClockAlarmTone, "[A] Clock Alarm")); |
|
92 tonesList.append(QPair<int,QString>(XQSystemToneService::ToDoAlarmTone, "[A] ToDo Alarm")); |
|
93 |
|
94 tonesList.append(QPair<int,QString>(XQSystemToneService::IncomingCallTone, "[A] Incoming Call")); |
|
95 tonesList.append(QPair<int,QString>(XQSystemToneService::IncomingCallLine2Tone, "[A] Incomming Call Line 2")); |
|
96 tonesList.append(QPair<int,QString>(XQSystemToneService::IncomingDataCallTone, "[A] Incomming Data Call")); |
|
97 |
|
98 // tones |
|
99 tonesList.append(QPair<int,QString>(XQSystemToneService::BurstModeTone, "[T] Burst Mode")); |
|
100 tonesList.append(QPair<int,QString>(XQSystemToneService::CaptureTone, "[T] Capture")); |
|
101 tonesList.append(QPair<int,QString>(XQSystemToneService::CallRecordingTone, "[T] Call Recording")); |
|
102 tonesList.append(QPair<int,QString>(XQSystemToneService::RecordingStartTone, "[T] Recording Start")); |
|
103 tonesList.append(QPair<int,QString>(XQSystemToneService::SelfTimerTone, "[T] Self Timer")); |
|
104 |
|
105 tonesList.append(QPair<int,QString>(XQSystemToneService::ConfirmationBeepTone, "[T] Confirmation Beep")); |
|
106 tonesList.append(QPair<int,QString>(XQSystemToneService::DefaultBeepTone, "[T] Default Beep")); |
|
107 tonesList.append(QPair<int,QString>(XQSystemToneService::ErrorBeepTone, "[T] Error Beep")); |
|
108 tonesList.append(QPair<int,QString>(XQSystemToneService::InformationBeepTone, "[T] Information Beep")); |
|
109 tonesList.append(QPair<int,QString>(XQSystemToneService::WarningBeepTone, "[T] Warning Beep")); |
|
110 tonesList.append(QPair<int,QString>(XQSystemToneService::IntegratedHandsFreeActivatedTone, "[T] Integrated Hands Free Act.")); |
|
111 |
|
112 tonesList.append(QPair<int,QString>(XQSystemToneService::TouchScreenTone, "[T] Touch Screen")); |
|
113 |
|
114 tonesList.append(QPair<int,QString>(XQSystemToneService::ChatAlertTone, "[T] Chat Alert")); |
|
115 tonesList.append(QPair<int,QString>(XQSystemToneService::EmailAlertTone, "[T] Email Alert")); |
|
116 tonesList.append(QPair<int,QString>(XQSystemToneService::MmsAlertTone, "[T] MMS Alert")); |
|
117 tonesList.append(QPair<int,QString>(XQSystemToneService::SmsAlertTone, "[T] SMS Alert")); |
|
118 tonesList.append(QPair<int,QString>(XQSystemToneService::DeliveryReportTone, "[T] Delivery Report")); |
|
119 tonesList.append(QPair<int,QString>(XQSystemToneService::MessageSendFailureTone, "[T] Message Send Failure")); |
|
120 |
|
121 tonesList.append(QPair<int,QString>(XQSystemToneService::BatteryLowTone, "[T] Battery Low")); |
|
122 tonesList.append(QPair<int,QString>(XQSystemToneService::BatteryRechargedTone, "[T] Battery Recharge")); |
|
123 tonesList.append(QPair<int,QString>(XQSystemToneService::PowerOnTone, "[T] Power On")); |
|
124 tonesList.append(QPair<int,QString>(XQSystemToneService::PowerOffTone, "[T] Power Off")); |
|
125 tonesList.append(QPair<int,QString>(XQSystemToneService::WakeUpTone, "[T] Wake Up")); |
|
126 tonesList.append(QPair<int,QString>(XQSystemToneService::WrongChargerTone, "[T] Wrong Charger")); |
|
127 |
|
128 tonesList.append(QPair<int,QString>(XQSystemToneService::AutomaticRedialCompleteTone, "[T] Automatic Redial Compl.")); |
|
129 |
|
130 tonesList.append(QPair<int,QString>(XQSystemToneService::VoiceStartTone, "[T] Voice Start")); |
|
131 tonesList.append(QPair<int,QString>(XQSystemToneService::VoiceErrorTone, "[T] Voice Error")); |
|
132 tonesList.append(QPair<int,QString>(XQSystemToneService::VoiceAbortTone, "[T] Voice Abort")); |
|
133 |
|
134 vl->addLayout(gl); |
|
135 |
|
136 QListIterator<QPair<int, QString> > iter(tonesList); |
|
137 |
|
138 gl->setDefaultPositioning(4, Qt::Horizontal); |
|
139 |
|
140 while (iter.hasNext()) { |
|
141 QPair<int, QString> item = iter.next(); |
|
142 box->addItem(item.second, item.first); |
|
143 } |
|
144 |
|
145 vl->addStretch(4); |
|
146 vl->addWidget(box); |
|
147 |
|
148 vl->addStretch(1); |
|
149 vl->addWidget(playToneButton); |
|
150 vl->addStretch(1); |
|
151 vl->addWidget(playAlarmButton); |
|
152 vl->addStretch(1); |
|
153 vl->addWidget(currCtxLabel = new QLabel("Last context: ?")); |
|
154 vl->addStretch(2); |
|
155 vl->addWidget(stopAlarmButton); |
|
156 vl->addStretch(1); |
|
157 vl->addWidget(new QLabel("Context:")); |
|
158 vl->addWidget(spinBox); |
|
159 |
|
160 vl->addStretch(1); |
|
161 vl->addWidget(callbackLabel = new QLabel("SIGNALS: ---")); |
|
162 |
|
163 vl->addStretch(4); |
|
164 vl->addWidget(quitButton); |
|
165 |
|
166 setLayout(vl); |
|
167 //showMaximized(); |
|
168 showFullScreen(); |
|
169 } |
|
170 |
|
171 STSTest::~STSTest() |
|
172 { |
|
173 delete sts; |
|
174 } |
|
175 |
|
176 void STSTest::playTone() |
|
177 { |
|
178 int id = box->itemData(box->currentIndex(), Qt::UserRole).toInt(); |
|
179 |
|
180 qDebug("Beep!!! (%d)", id); |
|
181 |
|
182 sts->playTone((XQSystemToneService::ToneType)id); |
|
183 |
|
184 currCtxLabel->setText(QString("Last context: -")); |
|
185 } |
|
186 |
|
187 void STSTest::playAlarm() |
|
188 { |
|
189 int id = box->itemData(box->currentIndex(), Qt::UserRole).toInt(); |
|
190 |
|
191 qDebug("Beep!!! (%d)", id); |
|
192 unsigned int ctx = 0; |
|
193 |
|
194 sts->playAlarm((XQSystemToneService::AlarmType)id, ctx); |
|
195 |
|
196 currCtxLabel->setText(QString("Last context: %1").arg(ctx)); |
|
197 } |
|
198 |
|
199 void STSTest::stopAlarm() |
|
200 { |
|
201 int ctx = spinBox->value(); |
|
202 |
|
203 qDebug("Silence! (%d)", ctx); |
|
204 sts->stopAlarm(ctx); |
|
205 } |
|
206 |
|
207 void STSTest::startCallback() |
|
208 { |
|
209 callbackLabel->setText(QString("SIGNALS: playing tone started...")); |
|
210 callbackCleanTimer.start(1000); |
|
211 } |
|
212 |
|
213 void STSTest::startCallback(unsigned int ctx) |
|
214 { |
|
215 callbackLabel->setText(QString("SIGNALS: (%1) playing alarm started...").arg(ctx)); |
|
216 callbackCleanTimer.start(1000); |
|
217 } |
|
218 |
|
219 void STSTest::stopCallback(unsigned int ctx) |
|
220 { |
|
221 callbackLabel->setText(QString("SIGNALS: (%1) playing alarm finished...").arg(ctx)); |
|
222 callbackCleanTimer.start(1000); |
|
223 } |
|
224 |
|
225 void STSTest::cleanCallback() |
|
226 { |
|
227 callbackLabel->setText("SIGNALS: ---"); |
|
228 } |
|
229 |
|
230 int main(int argc, char* argv[]) |
|
231 { |
|
232 QApplication a(argc, argv); |
|
233 |
|
234 STSTest* tester = new STSTest(); |
|
235 int rv = a.exec(); |
|
236 delete tester; |
|
237 return rv; |
|
238 } |
|
239 |