Commit a34ceb32bc889d7ec84d3eb8860d88137d8aa2d1

Authored by 김태훈
1 parent bbd7d8f297
Exists in master and in 2 other branches fhd, fhd-demo

볼륨 설정에 따라 음향 볼륨 설정

app/gui/oven_control/soundplayer.cpp
1 1 #include "soundplayer.h"
2 2 #include "system.h"
3 3  
  4 +#include "config.h"
  5 +
4 6 namespace {
5 7 QThread playThread;
6 8 }
... ... @@ -27,7 +29,6 @@ void SoundPlayWorker::play(const QString &filename)
27 29 map[filename] = current;
28 30 }
29 31  
30   - System::setVolume(70);
31 32 current->play();
32 33 }
33 34  
... ... @@ -46,10 +47,14 @@ void SoundPlayWorker::playClick()
46 47 click->setVolume(1.0);
47 48 }
48 49  
49   - System::setVolume(80);
50 50 click->play();
51 51 }
52 52  
  53 +void SoundPlayWorker::setVolume(int volume)
  54 +{
  55 + System::setVolume(volume);
  56 +}
  57 +
53 58 SoundPlayer *SoundPlayer::instance = 0;
54 59 SoundPlayer::SoundPlayer()
55 60 {
... ... @@ -57,6 +62,7 @@ SoundPlayer::SoundPlayer()
57 62  
58 63 SoundPlayWorker *w = new SoundPlayWorker;
59 64 w->moveToThread(&playThread);
  65 + connect(this, SIGNAL(setVolume(int)), w, SLOT(setVolume(int)));
60 66 connect(this, SIGNAL(operate(QString)), w, SLOT(play(QString)));
61 67 connect(this, SIGNAL(click()), w, SLOT(playClick()));
62 68  
... ... @@ -65,11 +71,75 @@ SoundPlayer::SoundPlayer()
65 71  
66 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 106 emit operate(filename);
69 107 }
70 108  
71 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 143 emit click();
74 144 }
75 145  
... ...
app/gui/oven_control/soundplayer.h
... ... @@ -16,6 +16,7 @@ public:
16 16 public slots:
17 17 void play(const QString &filename);
18 18 void playClick();
  19 + void setVolume(int volume);
19 20  
20 21 private:
21 22 QMap<QString, QSound *> map;
... ... @@ -31,6 +32,7 @@ class SoundPlayer : public QObject
31 32 void play(const QString &filename);
32 33 void emitClick();
33 34  
  35 +
34 36 static SoundPlayer *instance;
35 37  
36 38 public:
... ... @@ -41,6 +43,7 @@ public:
41 43 static void playError2();
42 44  
43 45 signals:
  46 + void setVolume(int);
44 47 void operate(const QString &);
45 48 void click();
46 49 };
... ...