diff --git a/include/mainwindow.h b/include/mainwindow.h index 5c956c6..7bd5791 100644 --- a/include/mainwindow.h +++ b/include/mainwindow.h @@ -22,6 +22,7 @@ public: public slots: void reloadConfig(); + void stop(); signals: void newStatusMessage(const QString&); @@ -33,6 +34,7 @@ private: Ui::Soundboard *ui; std::vector soundbuttons; + QxtGlobalShortcut* stopGlobal = nullptr; Config config; }; #endif // MAINWINDOW_H diff --git a/include/sounddevice.h b/include/sounddevice.h index d42e4a8..701d753 100644 --- a/include/sounddevice.h +++ b/include/sounddevice.h @@ -38,7 +38,6 @@ private: struct SoundData { std::list playbacks; //liste der decoder unsigned int decoderCount = 0; - unsigned int musicdecoderCount = 0; ma_mutex* mutex; }; diff --git a/soundboard.json.example b/soundboard.json.example index d06991e..80bf2d4 100644 --- a/soundboard.json.example +++ b/soundboard.json.example @@ -13,7 +13,8 @@ "key": "", "offset": 0, "length": 0, - "volume": 1.0 + "volume": 1.0, + "width": 6 } ] ] diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp index 8d72af7..20c81c9 100644 --- a/src/mainwindow.cpp +++ b/src/mainwindow.cpp @@ -11,13 +11,18 @@ MainWindow::MainWindow(QWidget* parent) : QMainWindow(parent), ui(new Ui::Soundb reloadConfig(); + QKeySequence seq("Num+,"); + stopGlobal = new QxtGlobalShortcut(seq); QObject::connect(ui->reloadButton, SIGNAL(clicked()), this, SLOT(reloadConfig())); + QObject::connect(ui->stopButton, SIGNAL( clicked() ), this, SLOT( stop() )); + QObject::connect(stopGlobal, SIGNAL( activated() ), this, SLOT( stop() )); QObject::connect(this, SIGNAL(newStatusMessage(const QString&)), ui->statusbar, SLOT(showMessage(const QString&))); } MainWindow::~MainWindow() { delete ui; + delete stopGlobal; Sound::deinit(); } @@ -42,6 +47,10 @@ void MainWindow::reloadConfig() { Log::info << "realodConfig() done"; } +void MainWindow::stop() { + Sound::instance().stopAll(); +} + void MainWindow::loadSoundFromConfig() { Sound& sound = Sound::instance(); // init sound sound.reset(); diff --git a/src/soundbutton.cpp b/src/soundbutton.cpp index 2d90c08..206a844 100644 --- a/src/soundbutton.cpp +++ b/src/soundbutton.cpp @@ -78,5 +78,5 @@ void SoundButton::play() { void SoundButton::setDisabled() { disabled = true; - button->setText(QString::fromStdString(name + " DISABLED")); + button->setEnabled(false); } \ No newline at end of file diff --git a/src/sounddevice.cpp b/src/sounddevice.cpp index 5c69cf0..a27ebed 100644 --- a/src/sounddevice.cpp +++ b/src/sounddevice.cpp @@ -148,6 +148,7 @@ void SoundDevice::stop() { delete pb; } data.playbacks.clear(); + data.decoderCount = 0; ma_mutex_unlock(data.mutex); if(deviceRunning) diff --git a/ui/mainwindow.ui b/ui/mainwindow.ui index aa2efa8..5c686e9 100644 --- a/ui/mainwindow.ui +++ b/ui/mainwindow.ui @@ -23,7 +23,7 @@ 561 - + QLayout::SetMaximumSize @@ -42,6 +42,19 @@ reload Config + + + + 160 + 10 + 100 + 27 + + + + Stop + +