Debian Codegraph @

kysdk-soundeffects/test/testsoundeffects/widget.cpp

raw
1 /*
2 *
3 * Copyright (C) 2023, KylinSoft Co., Ltd.
4 *
5 * This library is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU Lesser General Public
7 * License as published by the Free Software Foundation; either
8 * version 3 of the License, or (at your option) any later version.
9 *
10 * This library 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 GNU
13 * Lesser General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this library. If not, see <https://www.gnu.org/licenses/>.
17 *
18 * Authors: Zhenyu Wang <[email protected]>
19 *
20 */
21
22 #include "widget.h"
23 #include <QStringList>
24 #include <QStringListModel>
25 #include <QComboBox>
26 #include <QDebug>
27 #include "ksoundeffects.h"
28 using namespace kdk;
29
30 Widget::Widget(QWidget *parent)
31 : QWidget(parent)
32 {
33 setFixedSize(600,500);
34 QStringList list;
35 list << "SoundType::AUDIO_VOLUME_CHANGE"
36 << "SoundType::BATTERY_LOW"
37 << "SoundType::COMPLETE"
38 << "SoundType::DEVICE_ADDED_FAILED"
39 << "SoundType::DEVICE_ADDED"
40 << "SoundType::DEVICE_REMOVED"
41 << "SoundType::DIALOG_ERROR"
42 << "SoundType::DIALOG_WARNING"
43 << "SoundType::NOTIFICATION_GENERAL"
44 << "SoundType::NOTIFICATION_SPECIAL"
45 << "SoundType::OPERATION_FILE"
46 << "SoundType::OPERATION_UNSUPPORTED"
47 << "SoundType::POWER_PLUG"
48 << "SoundType::SCREEN_CAPTURE"
49 << "SoundType::SCREEN_RECORD"
50 << "SoundType::START_UP"
51 << "SoundType::TRASH_EMPTY";
52
53 QStringListModel *model = new QStringListModel();
54 model->setStringList(list);
55 QComboBox* combox= new QComboBox(this);
56
57 combox->setModel(model);
58
59 connect(combox,&QComboBox::currentTextChanged,this,[=](QString text){
60 if(text == "SoundType::AUDIO_VOLUME_CHANGE")
61 kdk::KSoundEffects::playSound(SoundType::AUDIO_VOLUME_CHANGE);
62 else if(text == "SoundType::BATTERY_LOW")
63 kdk::KSoundEffects::playSound(SoundType::BATTERY_LOW);
64 else if(text == "SoundType::COMPLETE")
65 kdk::KSoundEffects::playSound(SoundType::COMPLETE);
66 else if(text == "SoundType::DEVICE_ADDED_FAILED")
67 kdk::KSoundEffects::playSound(SoundType::DEVICE_ADDED_FAILED);
68 else if(text == "SoundType::DEVICE_ADDED")
69 kdk::KSoundEffects::playSound(SoundType::DEVICE_ADDED);
70 else if(text == "SoundType::DEVICE_REMOVED")
71 kdk::KSoundEffects::playSound(SoundType::DEVICE_REMOVED);
72 else if(text == "SoundType::DIALOG_ERROR")
73 kdk::KSoundEffects::playSound(SoundType::DIALOG_ERROR);
74 else if(text == "SoundType::DIALOG_WARNING")
75 kdk::KSoundEffects::playSound(SoundType::DIALOG_WARNING);
76 else if(text == "SoundType::NOTIFICATION_GENERAL")
77 kdk::KSoundEffects::playSound(SoundType::NOTIFICATION_GENERAL);
78 else if(text == "SoundType::NOTIFICATION_SPECIAL")
79 kdk::KSoundEffects::playSound(SoundType::NOTIFICATION_SPECIAL);
80 else if(text == "SoundType::OPERATION_FILE")
81 kdk::KSoundEffects::playSound(SoundType::OPERATION_FILE);
82 else if(text == "SoundType::OPERATION_UNSUPPORTED")
83 kdk::KSoundEffects::playSound(SoundType::OPERATION_UNSUPPORTED);
84 else if(text == "SoundType::POWER_PLUG")
85 kdk::KSoundEffects::playSound(SoundType::POWER_PLUG);
86 else if(text == "SoundType::SCREEN_CAPTURE")
87 kdk::KSoundEffects::playSound(SoundType::SCREEN_CAPTURE);
88 else if(text == "SoundType::SCREEN_RECORD")
89 kdk::KSoundEffects::playSound(SoundType::SCREEN_RECORD);
90 else if(text == "SoundType::START_UP")
91 kdk::KSoundEffects::playSound(SoundType::START_UP);
92 else if(text == "SoundType::TRASH_EMPTY")
93 kdk::KSoundEffects::playSound(SoundType::TRASH_EMPTY);
94 });
95 }
96
97 Widget::~Widget()
98 {
99 }
100