Merge pull request #32 from lioncash/status-bar

StatusBarWidget: Use std::array where applicable
This commit is contained in:
Phillip Stephens 2019-08-28 22:29:44 -07:00 committed by GitHub
commit 5ee32c105b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 13 additions and 9 deletions

View File

@ -14,10 +14,9 @@ StatusBarWidget::StatusBarWidget(QWidget* parent)
m_killButton.setVisible(false); m_killButton.setVisible(false);
m_killButton.setToolTip(tr("Immediately kill active voices")); m_killButton.setToolTip(tr("Immediately kill active voices"));
m_voiceCount.setVisible(false); m_voiceCount.setVisible(false);
m_volumeIcons[0] = QIcon(QStringLiteral(":/icons/IconVolume0.svg")); for (size_t i = 0; i < m_volumeIcons.size(); i++) {
m_volumeIcons[1] = QIcon(QStringLiteral(":/icons/IconVolume1.svg")); m_volumeIcons[i] = QIcon(QStringLiteral(":/icons/IconVolume%1.svg").arg(i));
m_volumeIcons[2] = QIcon(QStringLiteral(":/icons/IconVolume2.svg")); }
m_volumeIcons[3] = QIcon(QStringLiteral(":/icons/IconVolume3.svg"));
m_aIcon.setFixedSize(16, 16); m_aIcon.setFixedSize(16, 16);
m_aIcon.setPixmap(QIcon(QStringLiteral(":/icons/IconA.svg")).pixmap(16, 16)); m_aIcon.setPixmap(QIcon(QStringLiteral(":/icons/IconA.svg")).pixmap(16, 16));
QString aTip = tr("Aux A send level for all voices"); QString aTip = tr("Aux A send level for all voices");
@ -62,11 +61,14 @@ void StatusBarWidget::setVoiceCount(int voices) {
} }
void StatusBarWidget::volumeChanged(int vol) { void StatusBarWidget::volumeChanged(int vol) {
int idx = int(std::round(vol * (3.f / 100.f))); const int idx = int(std::round(vol * (3.f / 100.f)));
if (idx != m_lastVolIdx) {
if (idx == m_lastVolIdx) {
return;
}
m_lastVolIdx = idx; m_lastVolIdx = idx;
m_volumeIcon.setPixmap(m_volumeIcons[idx].pixmap(16, 16)); m_volumeIcon.setPixmap(m_volumeIcons[idx].pixmap(16, 16));
}
} }
void StatusBarFocus::setMessage(const QString& message) { void StatusBarFocus::setMessage(const QString& message) {

View File

@ -1,5 +1,7 @@
#pragma once #pragma once
#include <array>
#include <QLabel> #include <QLabel>
#include <QMouseEvent> #include <QMouseEvent>
#include <QPushButton> #include <QPushButton>
@ -24,7 +26,7 @@ class StatusBarWidget : public QStatusBar {
QLabel m_normalMessage; QLabel m_normalMessage;
QPushButton m_killButton; QPushButton m_killButton;
FXButton m_fxButton; FXButton m_fxButton;
QIcon m_volumeIcons[4]; std::array<QIcon, 4> m_volumeIcons;
QLabel m_volumeIcon; QLabel m_volumeIcon;
QSlider m_volumeSlider; QSlider m_volumeSlider;
QLabel m_aIcon; QLabel m_aIcon;