Commit a34ceb32bc889d7ec84d3eb8860d88137d8aa2d1
1 parent
bbd7d8f297
Exists in
master
and in
2 other branches
볼륨 설정에 따라 음향 볼륨 설정
Showing
2 changed files
with
75 additions
and
2 deletions
Show diff stats
app/gui/oven_control/soundplayer.cpp
| 1 | #include "soundplayer.h" | 1 | #include "soundplayer.h" |
| 2 | #include "system.h" | 2 | #include "system.h" |
| 3 | 3 | ||
| 4 | +#include "config.h" | ||
| 5 | + | ||
| 4 | namespace { | 6 | namespace { |
| 5 | QThread playThread; | 7 | QThread playThread; |
| 6 | } | 8 | } |
| @@ -27,7 +29,6 @@ void SoundPlayWorker::play(const QString &filename) | @@ -27,7 +29,6 @@ void SoundPlayWorker::play(const QString &filename) | ||
| 27 | map[filename] = current; | 29 | map[filename] = current; |
| 28 | } | 30 | } |
| 29 | 31 | ||
| 30 | - System::setVolume(70); | ||
| 31 | current->play(); | 32 | current->play(); |
| 32 | } | 33 | } |
| 33 | 34 | ||
| @@ -46,10 +47,14 @@ void SoundPlayWorker::playClick() | @@ -46,10 +47,14 @@ void SoundPlayWorker::playClick() | ||
| 46 | click->setVolume(1.0); | 47 | click->setVolume(1.0); |
| 47 | } | 48 | } |
| 48 | 49 | ||
| 49 | - System::setVolume(80); | ||
| 50 | click->play(); | 50 | click->play(); |
| 51 | } | 51 | } |
| 52 | 52 | ||
| 53 | +void SoundPlayWorker::setVolume(int volume) | ||
| 54 | +{ | ||
| 55 | + System::setVolume(volume); | ||
| 56 | +} | ||
| 57 | + | ||
| 53 | SoundPlayer *SoundPlayer::instance = 0; | 58 | SoundPlayer *SoundPlayer::instance = 0; |
| 54 | SoundPlayer::SoundPlayer() | 59 | SoundPlayer::SoundPlayer() |
| 55 | { | 60 | { |
| @@ -57,6 +62,7 @@ SoundPlayer::SoundPlayer() | @@ -57,6 +62,7 @@ SoundPlayer::SoundPlayer() | ||
| 57 | 62 | ||
| 58 | SoundPlayWorker *w = new SoundPlayWorker; | 63 | SoundPlayWorker *w = new SoundPlayWorker; |
| 59 | w->moveToThread(&playThread); | 64 | w->moveToThread(&playThread); |
| 65 | + connect(this, SIGNAL(setVolume(int)), w, SLOT(setVolume(int))); | ||
| 60 | connect(this, SIGNAL(operate(QString)), w, SLOT(play(QString))); | 66 | connect(this, SIGNAL(operate(QString)), w, SLOT(play(QString))); |
| 61 | connect(this, SIGNAL(click()), w, SLOT(playClick())); | 67 | connect(this, SIGNAL(click()), w, SLOT(playClick())); |
| 62 | 68 | ||
| @@ -65,11 +71,75 @@ SoundPlayer::SoundPlayer() | @@ -65,11 +71,75 @@ SoundPlayer::SoundPlayer() | ||
| 65 | 71 | ||
| 66 | void SoundPlayer::play(const QString &filename) | 72 | void SoundPlayer::play(const QString &filename) |
| 67 | { | 73 | { |
| 74 | + Define::config_item item = Config::getInstance()->getConfigValue(Define::config_marster_vol); | ||
| 75 | + switch (item.d32) | ||
| 76 | + { | ||
| 77 | + case 0: | ||
| 78 | + emit setVolume(0); | ||
| 79 | + break; | ||
| 80 | + case 1: | ||
| 81 | + emit setVolume(40); | ||
| 82 | + break; | ||
| 83 | + case 2: | ||
| 84 | + emit setVolume(50); | ||
| 85 | + break; | ||
| 86 | + case 3: | ||
| 87 | + emit setVolume(60); | ||
| 88 | + break; | ||
| 89 | + case 4: | ||
| 90 | + emit setVolume(70); | ||
| 91 | + break; | ||
| 92 | + case 5: | ||
| 93 | + emit setVolume(80); | ||
| 94 | + break; | ||
| 95 | + case 6: | ||
| 96 | + emit setVolume(90); | ||
| 97 | + break; | ||
| 98 | + case 7: | ||
| 99 | + emit setVolume(100); | ||
| 100 | + break; | ||
| 101 | + default: | ||
| 102 | + emit setVolume(0); | ||
| 103 | + break; | ||
| 104 | + } | ||
| 105 | + | ||
| 68 | emit operate(filename); | 106 | emit operate(filename); |
| 69 | } | 107 | } |
| 70 | 108 | ||
| 71 | void SoundPlayer::emitClick() | 109 | void SoundPlayer::emitClick() |
| 72 | { | 110 | { |
| 111 | + Define::config_item item = Config::getInstance()->getConfigValue(Define::config_marster_vol); | ||
| 112 | + switch (item.d32) | ||
| 113 | + { | ||
| 114 | + case 0: | ||
| 115 | + emit setVolume(0); | ||
| 116 | + break; | ||
| 117 | + case 1: | ||
| 118 | + emit setVolume(50); | ||
| 119 | + break; | ||
| 120 | + case 2: | ||
| 121 | + emit setVolume(60); | ||
| 122 | + break; | ||
| 123 | + case 3: | ||
| 124 | + emit setVolume(70); | ||
| 125 | + break; | ||
| 126 | + case 4: | ||
| 127 | + emit setVolume(80); | ||
| 128 | + break; | ||
| 129 | + case 5: | ||
| 130 | + emit setVolume(90); | ||
| 131 | + break; | ||
| 132 | + case 6: | ||
| 133 | + emit setVolume(95); | ||
| 134 | + break; | ||
| 135 | + case 7: | ||
| 136 | + emit setVolume(100); | ||
| 137 | + break; | ||
| 138 | + default: | ||
| 139 | + emit setVolume(0); | ||
| 140 | + break; | ||
| 141 | + } | ||
| 142 | + | ||
| 73 | emit click(); | 143 | emit click(); |
| 74 | } | 144 | } |
| 75 | 145 |
app/gui/oven_control/soundplayer.h
| @@ -16,6 +16,7 @@ public: | @@ -16,6 +16,7 @@ public: | ||
| 16 | public slots: | 16 | public slots: |
| 17 | void play(const QString &filename); | 17 | void play(const QString &filename); |
| 18 | void playClick(); | 18 | void playClick(); |
| 19 | + void setVolume(int volume); | ||
| 19 | 20 | ||
| 20 | private: | 21 | private: |
| 21 | QMap<QString, QSound *> map; | 22 | QMap<QString, QSound *> map; |
| @@ -31,6 +32,7 @@ class SoundPlayer : public QObject | @@ -31,6 +32,7 @@ class SoundPlayer : public QObject | ||
| 31 | void play(const QString &filename); | 32 | void play(const QString &filename); |
| 32 | void emitClick(); | 33 | void emitClick(); |
| 33 | 34 | ||
| 35 | + | ||
| 34 | static SoundPlayer *instance; | 36 | static SoundPlayer *instance; |
| 35 | 37 | ||
| 36 | public: | 38 | public: |
| @@ -41,6 +43,7 @@ public: | @@ -41,6 +43,7 @@ public: | ||
| 41 | static void playError2(); | 43 | static void playError2(); |
| 42 | 44 | ||
| 43 | signals: | 45 | signals: |
| 46 | + void setVolume(int); | ||
| 44 | void operate(const QString &); | 47 | void operate(const QString &); |
| 45 | void click(); | 48 | void click(); |
| 46 | }; | 49 | }; |