amuse/Editor/StatusBarWidget.hpp

70 lines
2.1 KiB
C++
Raw Normal View History

#ifndef AMUSE_STATUSBAR_WIDGET_HPP
#define AMUSE_STATUSBAR_WIDGET_HPP
#include <QStatusBar>
2018-07-18 07:39:26 +00:00
#include <QLabel>
2018-07-28 04:34:29 +00:00
#include <QPushButton>
2018-08-16 06:26:44 +00:00
#include <QSlider>
#include <QMouseEvent>
#include <cmath>
2018-07-18 07:39:26 +00:00
class StatusBarFocus;
2018-08-16 06:26:44 +00:00
class FXButton : public QPushButton
{
Q_OBJECT
public:
explicit FXButton(QWidget* parent = Q_NULLPTR);
void mouseReleaseEvent(QMouseEvent* event) { event->ignore(); }
void mouseMoveEvent(QMouseEvent* event) { event->ignore(); }
void focusOutEvent(QFocusEvent* event) { event->ignore(); }
void keyPressEvent(QKeyEvent* event) { event->ignore(); }
};
class StatusBarWidget : public QStatusBar
{
2018-07-18 07:39:26 +00:00
friend class StatusBarFocus;
Q_OBJECT
2018-07-28 04:34:29 +00:00
QLabel m_normalMessage;
QPushButton m_killButton;
2018-08-16 06:26:44 +00:00
FXButton m_fxButton;
QIcon m_volumeIcons[4];
QLabel m_volumeIcon;
QSlider m_volumeSlider;
int m_lastVolIdx = 0;
2018-07-28 04:34:29 +00:00
QLabel m_voiceCount;
int m_cachedVoiceCount = -1;
2018-07-18 07:39:26 +00:00
StatusBarFocus* m_curFocus = nullptr;
2018-07-28 04:34:29 +00:00
void setKillVisible(bool vis) { m_killButton.setVisible(vis); m_voiceCount.setVisible(vis); }
public:
2018-08-16 06:26:44 +00:00
explicit StatusBarWidget(QWidget* parent = Q_NULLPTR);
2018-07-28 04:34:29 +00:00
void setNormalMessage(const QString& message) { m_normalMessage.setText(message); }
2018-08-16 06:26:44 +00:00
void setVoiceCount(int voices);
2018-07-28 04:34:29 +00:00
void connectKillClicked(const QObject* receiver, const char* method)
{ connect(&m_killButton, SIGNAL(clicked(bool)), receiver, method); }
2018-08-16 06:26:44 +00:00
void connectFXPressed(const QObject* receiver, const char* method)
{ connect(&m_fxButton, SIGNAL(pressed()), receiver, method); }
void setFXDown(bool down) { m_fxButton.setDown(down); }
void connectVolumeSlider(const QObject* receiver, const char* method)
{ connect(&m_volumeSlider, SIGNAL(valueChanged(int)), receiver, method); }
void setVolumeValue(int vol) { m_volumeSlider.setValue(vol); }
private slots:
void volumeChanged(int vol);
};
2018-07-18 07:39:26 +00:00
class StatusBarFocus : public QObject
{
Q_OBJECT
QString m_message;
public:
explicit StatusBarFocus(StatusBarWidget* statusWidget)
: QObject(statusWidget) {}
~StatusBarFocus() { exit(); }
2018-08-16 06:26:44 +00:00
void setMessage(const QString& message);
void enter();
void exit();
2018-07-18 07:39:26 +00:00
};
#endif //AMUSE_STATUSBAR_WIDGET_HPP