41 #include <QAction> |
41 #include <QAction> |
42 |
42 |
43 #include "ststest.h" |
43 #include "ststest.h" |
44 #include <XQSystemToneService> |
44 #include <XQSystemToneService> |
45 |
45 |
46 STSTest::STSTest( QWidget *parent, Qt::WFlags f ) |
46 STSTest::STSTest( QWidget *parent) |
47 : |
47 : |
48 QWidget(parent, f), |
48 QMainWindow(parent), |
49 sts(new XQSystemToneService()) |
49 sts(new XQSystemToneService()) |
50 { |
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 |
51 callbackCleanTimer.setSingleShot(true); |
56 callbackCleanTimer.setSingleShot(true); |
52 connect(&callbackCleanTimer, SIGNAL(timeout()), this, SLOT(cleanCallback())); |
57 connect(&callbackCleanTimer, SIGNAL(timeout()), this, SLOT(cleanCallback())); |
53 |
58 |
54 QPushButton *quitButton = new QPushButton("QUIT"); |
59 QPushButton *quitButton = new QPushButton("QUIT", this); |
55 connect(quitButton, SIGNAL(clicked()), qApp, SLOT(quit())); |
60 connect(quitButton, SIGNAL(clicked()), qApp, SLOT(quit())); |
56 |
61 |
57 QPushButton *playToneButton = new QPushButton("Play Tone"); |
62 QPushButton *playToneButton = new QPushButton("Play Tone", this); |
58 connect(playToneButton, SIGNAL(clicked()), this, SLOT(playTone())); |
63 connect(playToneButton, SIGNAL(clicked()), this, SLOT(playTone())); |
59 |
64 |
60 QPushButton *playAlarmButton = new QPushButton("Play Alarm"); |
65 QPushButton *playAlarmButton = new QPushButton("Play Alarm", this); |
61 connect(playAlarmButton, SIGNAL(clicked()), this, SLOT(playAlarm())); |
66 connect(playAlarmButton, SIGNAL(clicked()), this, SLOT(playAlarm())); |
62 |
67 |
63 QPushButton *stopAlarmButton = new QPushButton("Stop Alarm"); |
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); |
64 connect(stopAlarmButton, SIGNAL(clicked()), this, SLOT(stopAlarm())); |
72 connect(stopAlarmButton, SIGNAL(clicked()), this, SLOT(stopAlarm())); |
65 |
73 |
66 |
74 |
67 connect(sts, SIGNAL(toneStarted()), this, SLOT(startCallback())); |
75 connect(sts, SIGNAL(toneStarted()), this, SLOT(startCallback())); |
68 connect(sts, SIGNAL(alarmStarted(unsigned int)), this, SLOT(startCallback(unsigned int))); |
76 connect(sts, SIGNAL(alarmStarted(unsigned int)), this, SLOT(startCallback(unsigned int))); |
69 connect(sts, SIGNAL(alarmFinished(unsigned int)), this, SLOT(stopCallback(unsigned int))); |
77 connect(sts, SIGNAL(alarmFinished(unsigned int)), this, SLOT(stopCallback(unsigned int))); |
70 |
78 |
71 |
79 qDebug() << QString("[sts] STSTest::STSTest 3"); |
72 box = new QComboBox(); |
80 |
73 spinBox = new QSpinBox(); |
81 box = new QComboBox(this); |
74 |
82 spinBox = new QSpinBox(this); |
75 QVBoxLayout *vl = new QVBoxLayout; |
83 |
76 QGridLayout *gl = new QGridLayout(); |
84 layout->setMargin(10); |
77 |
85 layout->setSpacing(0); |
78 vl->setMargin(10); |
86 qDebug() << QString("[sts] STSTest::STSTest 4"); |
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 QList<QPair<int, QString> > tonesList; |
87 |
88 |
88 |
89 |
89 // alarms |
90 // alarms |
90 tonesList.append(QPair<int,QString>(XQSystemToneService::CalendarAlarmTone, "[A] Calendar Alarm")); |
91 tonesList.append(QPair<int,QString>(XQSystemToneService::CalendarAlarmTone, "[A] Calendar Alarm")); |
129 |
130 |
130 tonesList.append(QPair<int,QString>(XQSystemToneService::VoiceStartTone, "[T] Voice Start")); |
131 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::VoiceErrorTone, "[T] Voice Error")); |
132 tonesList.append(QPair<int,QString>(XQSystemToneService::VoiceAbortTone, "[T] Voice Abort")); |
133 tonesList.append(QPair<int,QString>(XQSystemToneService::VoiceAbortTone, "[T] Voice Abort")); |
133 |
134 |
134 vl->addLayout(gl); |
135 qDebug() << QString("[sts] STSTest::STSTest 5"); |
135 |
|
136 QListIterator<QPair<int, QString> > iter(tonesList); |
136 QListIterator<QPair<int, QString> > iter(tonesList); |
137 |
|
138 gl->setDefaultPositioning(4, Qt::Horizontal); |
|
139 |
|
140 while (iter.hasNext()) { |
137 while (iter.hasNext()) { |
141 QPair<int, QString> item = iter.next(); |
138 QPair<int, QString> item = iter.next(); |
142 box->addItem(item.second, item.first); |
139 box->addItem(item.second, item.first); |
143 } |
140 } |
144 |
141 |
145 vl->addStretch(4); |
142 layout->addStretch(4); |
146 vl->addWidget(box); |
143 layout->addWidget(box); |
147 |
144 |
148 vl->addStretch(1); |
145 qDebug() << QString("[sts] STSTest::STSTest 6"); |
149 vl->addWidget(playToneButton); |
146 layout->addStretch(1); |
150 vl->addStretch(1); |
147 layout->addWidget(playToneButton); |
151 vl->addWidget(playAlarmButton); |
148 layout->addStretch(1); |
152 vl->addStretch(1); |
149 layout->addWidget(playAlarmButton); |
153 vl->addWidget(currCtxLabel = new QLabel("Last context: ?")); |
150 layout->addStretch(1); |
154 vl->addStretch(2); |
151 layout->addWidget(playAlarmAsToneButton); |
155 vl->addWidget(stopAlarmButton); |
152 layout->addStretch(1); |
156 vl->addStretch(1); |
153 currCtxLabel = new QLabel("Last context: ?", this); |
157 vl->addWidget(new QLabel("Context:")); |
154 layout->addWidget(currCtxLabel); |
158 vl->addWidget(spinBox); |
155 layout->addStretch(2); |
159 |
156 layout->addWidget(stopAlarmButton); |
160 vl->addStretch(1); |
157 layout->addStretch(1); |
161 vl->addWidget(callbackLabel = new QLabel("SIGNALS: ---")); |
158 layout->addWidget(new QLabel("Context:", this)); |
162 |
159 layout->addWidget(spinBox); |
163 vl->addStretch(4); |
160 |
164 vl->addWidget(quitButton); |
161 layout->addStretch(1); |
165 |
162 callbackLabel = new QLabel("SIGNALS: ---", this); |
166 setLayout(vl); |
163 layout->addWidget(callbackLabel); |
167 //showMaximized(); |
164 |
168 showFullScreen(); |
165 layout->addStretch(4); |
|
166 layout->addWidget(quitButton); |
|
167 |
|
168 |
|
169 window->setLayout(layout); |
|
170 setCentralWidget(window); |
|
171 window->show();; |
|
172 |
169 } |
173 } |
170 |
174 |
171 STSTest::~STSTest() |
175 STSTest::~STSTest() |
172 { |
176 { |
173 delete sts; |
177 delete sts; |
194 sts->playAlarm((XQSystemToneService::AlarmType)id, ctx); |
198 sts->playAlarm((XQSystemToneService::AlarmType)id, ctx); |
195 |
199 |
196 currCtxLabel->setText(QString("Last context: %1").arg(ctx)); |
200 currCtxLabel->setText(QString("Last context: %1").arg(ctx)); |
197 } |
201 } |
198 |
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 |
199 void STSTest::stopAlarm() |
215 void STSTest::stopAlarm() |
200 { |
216 { |
201 int ctx = spinBox->value(); |
217 int ctx = spinBox->value(); |
202 |
218 |
203 qDebug("Silence! (%d)", ctx); |
219 qDebug("Silence! (%d)", ctx); |