forked from MrBesen/soundboard
disable buttons
This commit is contained in:
parent
d9d2da16dc
commit
c5d1e24df9
|
@ -32,6 +32,8 @@ public slots:
|
|||
void play();
|
||||
|
||||
private:
|
||||
void setDisabled();
|
||||
|
||||
static uint64_t nextid;
|
||||
|
||||
uint64_t id;
|
||||
|
@ -42,6 +44,8 @@ private:
|
|||
uint64_t lengthms = 0; // ignored when length = 0
|
||||
float volume = 1.f;
|
||||
|
||||
bool disabled = false;
|
||||
|
||||
QxtGlobalShortcut* globalShortcut = nullptr;
|
||||
QPushButton* button = nullptr;
|
||||
};
|
|
@ -2,6 +2,8 @@
|
|||
|
||||
#include "sound.h"
|
||||
|
||||
#include <Log.h>
|
||||
|
||||
uint64_t SoundButton::nextid = 0;
|
||||
|
||||
SoundButton::SoundButton(const std::string& filename, const std::string& name_, const std::string& keycombo) : id(nextid++), file(filename), keycombo(keycombo) {
|
||||
|
@ -63,6 +65,18 @@ QPushButton* SoundButton::getButton() {
|
|||
}
|
||||
|
||||
void SoundButton::play() {
|
||||
if(disabled) return;
|
||||
|
||||
uint64_t endms = (lengthms == 0 ? 0 : startms + lengthms);
|
||||
Sound::instance().addPlayback(file, volume, startms, endms);
|
||||
try {
|
||||
Sound::instance().addPlayback(file, volume, startms, endms);
|
||||
} catch(const std::exception& e) {
|
||||
Log::error << "Catched Exception when plaing Audio File: " << file;
|
||||
setDisabled();
|
||||
}
|
||||
}
|
||||
|
||||
void SoundButton::setDisabled() {
|
||||
disabled = true;
|
||||
button->setText(QString::fromStdString(name + " DISABLED"));
|
||||
}
|
Loading…
Reference in New Issue