2018-10-07 03:40:25 +00:00
|
|
|
#pragma once
|
2018-07-09 18:05:31 +00:00
|
|
|
|
2019-08-28 04:13:40 +00:00
|
|
|
#include <array>
|
|
|
|
|
2018-07-18 07:39:26 +00:00
|
|
|
#include <QLabel>
|
2019-08-28 00:51:38 +00:00
|
|
|
#include <QMouseEvent>
|
2018-07-28 04:34:29 +00:00
|
|
|
#include <QPushButton>
|
2018-08-16 06:26:44 +00:00
|
|
|
#include <QSlider>
|
2019-08-28 00:51:38 +00:00
|
|
|
#include <QStatusBar>
|
2018-07-18 07:39:26 +00:00
|
|
|
|
|
|
|
class StatusBarFocus;
|
2018-07-09 18:05:31 +00:00
|
|
|
|
2018-12-08 05:20:09 +00:00
|
|
|
class FXButton : public QPushButton {
|
|
|
|
Q_OBJECT
|
2018-08-16 06:26:44 +00:00
|
|
|
public:
|
2018-12-08 05:20:09 +00:00
|
|
|
explicit FXButton(QWidget* parent = Q_NULLPTR);
|
2019-08-25 04:37:47 +00:00
|
|
|
void mouseReleaseEvent(QMouseEvent* event) override { event->ignore(); }
|
|
|
|
void mouseMoveEvent(QMouseEvent* event) override { event->ignore(); }
|
|
|
|
void focusOutEvent(QFocusEvent* event) override { event->ignore(); }
|
|
|
|
void keyPressEvent(QKeyEvent* event) override { event->ignore(); }
|
2018-08-16 06:26:44 +00:00
|
|
|
};
|
|
|
|
|
2018-12-08 05:20:09 +00:00
|
|
|
class StatusBarWidget : public QStatusBar {
|
|
|
|
friend class StatusBarFocus;
|
|
|
|
Q_OBJECT
|
|
|
|
QLabel m_normalMessage;
|
|
|
|
QPushButton m_killButton;
|
|
|
|
FXButton m_fxButton;
|
2019-08-28 04:13:40 +00:00
|
|
|
std::array<QIcon, 4> m_volumeIcons;
|
2018-12-08 05:20:09 +00:00
|
|
|
QLabel m_volumeIcon;
|
|
|
|
QSlider m_volumeSlider;
|
|
|
|
QLabel m_aIcon;
|
|
|
|
QSlider m_aSlider;
|
|
|
|
QLabel m_bIcon;
|
|
|
|
QSlider m_bSlider;
|
|
|
|
int m_lastVolIdx = 0;
|
|
|
|
QLabel m_voiceCount;
|
|
|
|
int m_cachedVoiceCount = -1;
|
|
|
|
StatusBarFocus* m_curFocus = nullptr;
|
|
|
|
void setKillVisible(bool vis) {
|
|
|
|
m_killButton.setVisible(vis);
|
|
|
|
m_voiceCount.setVisible(vis);
|
|
|
|
}
|
|
|
|
|
2018-07-09 18:05:31 +00:00
|
|
|
public:
|
2018-12-08 05:20:09 +00:00
|
|
|
explicit StatusBarWidget(QWidget* parent = Q_NULLPTR);
|
2019-08-28 00:51:38 +00:00
|
|
|
~StatusBarWidget() override;
|
|
|
|
|
2018-12-08 05:20:09 +00:00
|
|
|
void setNormalMessage(const QString& message) { m_normalMessage.setText(message); }
|
|
|
|
void setVoiceCount(int voices);
|
2019-08-25 08:13:33 +00:00
|
|
|
|
|
|
|
template <typename Receiver>
|
|
|
|
void connectKillClicked(const Receiver* receiver, void (Receiver::*method)()) {
|
|
|
|
connect(&m_killButton, &QPushButton::clicked, receiver, method);
|
2018-12-08 05:20:09 +00:00
|
|
|
}
|
2019-08-25 08:13:33 +00:00
|
|
|
template <typename Receiver>
|
|
|
|
void connectFXPressed(const Receiver* receiver, void (Receiver::*method)()) {
|
|
|
|
connect(&m_fxButton, &FXButton::pressed, receiver, method);
|
2018-12-08 05:20:09 +00:00
|
|
|
}
|
|
|
|
void setFXDown(bool down) { m_fxButton.setDown(down); }
|
2019-08-25 08:13:33 +00:00
|
|
|
|
|
|
|
template <typename Receiver>
|
|
|
|
void connectVolumeSlider(const Receiver* receiver, void (Receiver::*method)(int)) {
|
|
|
|
connect(&m_volumeSlider, qOverload<int>(&QSlider::valueChanged), receiver, method);
|
2018-12-08 05:20:09 +00:00
|
|
|
}
|
2019-08-25 08:13:33 +00:00
|
|
|
template <typename Receiver>
|
|
|
|
void connectASlider(const Receiver* receiver, void (Receiver::*method)(int)) {
|
|
|
|
connect(&m_aSlider, qOverload<int>(&QSlider::valueChanged), receiver, method);
|
2018-12-08 05:20:09 +00:00
|
|
|
}
|
2019-08-25 08:13:33 +00:00
|
|
|
template <typename Receiver>
|
|
|
|
void connectBSlider(const Receiver* receiver, void (Receiver::*method)(int)) {
|
|
|
|
connect(&m_bSlider, qOverload<int>(&QSlider::valueChanged), receiver, method);
|
2018-12-08 05:20:09 +00:00
|
|
|
}
|
|
|
|
void setVolumeValue(int vol) { m_volumeSlider.setValue(vol); }
|
2018-08-16 06:26:44 +00:00
|
|
|
|
|
|
|
private slots:
|
2018-12-08 05:20:09 +00:00
|
|
|
void volumeChanged(int vol);
|
2018-07-09 18:05:31 +00:00
|
|
|
};
|
|
|
|
|
2018-12-08 05:20:09 +00:00
|
|
|
class StatusBarFocus : public QObject {
|
|
|
|
Q_OBJECT
|
|
|
|
QString m_message;
|
|
|
|
|
2018-07-18 07:39:26 +00:00
|
|
|
public:
|
2018-12-08 05:20:09 +00:00
|
|
|
explicit StatusBarFocus(StatusBarWidget* statusWidget) : QObject(statusWidget) {}
|
2019-08-25 04:37:47 +00:00
|
|
|
~StatusBarFocus() override { exit(); }
|
2018-12-08 05:20:09 +00:00
|
|
|
void setMessage(const QString& message);
|
|
|
|
void enter();
|
|
|
|
void exit();
|
2018-07-18 07:39:26 +00:00
|
|
|
};
|