soundboard/include/soundbutton.h

52 lines
1.0 KiB
C
Raw Normal View History

2021-12-13 14:48:43 +01:00
#pragma once
#include <string>
#include <cstdint>
2021-12-15 14:39:39 +01:00
#include <QPushButton>
2021-12-13 14:48:43 +01:00
#include "qxtglobalshortcut.h"
2021-12-15 14:39:39 +01:00
class SoundButton : public QPushButton
{
2021-12-13 14:48:43 +01:00
Q_OBJECT
public:
2021-12-15 14:39:39 +01:00
explicit SoundButton(const std::string& filename, const std::string& name_ = "", const std::string& keycombo = "", QWidget* parent = nullptr);
2021-12-13 14:48:43 +01:00
~SoundButton();
const std::string& getName() const;
const std::string& getFile() const;
const std::string& getKeyCombo() const;
2021-12-13 17:28:32 +01:00
uint64_t getStartMS() const;
uint64_t getLengthMS() const;
float getVolume() const;
void setStartMS(uint64_t startms);
void setLengthMS(uint64_t lengthms);
void setVolume(float v);
2021-12-15 14:39:39 +01:00
void setHighlighted(bool highlighted);
2021-12-13 14:48:43 +01:00
public slots:
void play();
private:
2021-12-14 10:32:23 +01:00
void setDisabled();
2021-12-15 14:39:39 +01:00
QString getInfo() const;
2021-12-14 10:32:23 +01:00
2021-12-13 14:48:43 +01:00
static uint64_t nextid;
2021-12-13 17:28:32 +01:00
2021-12-13 14:48:43 +01:00
uint64_t id;
std::string name;
std::string file;
std::string keycombo;
2021-12-13 17:28:32 +01:00
uint64_t startms = 0;
uint64_t lengthms = 0; // ignored when length = 0
float volume = 1.f;
2021-12-13 14:48:43 +01:00
2021-12-14 10:32:23 +01:00
bool disabled = false;
2021-12-13 14:48:43 +01:00
QxtGlobalShortcut* globalShortcut = nullptr;
};