1
0
mirror of https://github.com/f4exb/sdrangel.git synced 2024-11-22 16:08:39 -05:00

Merge pull request #1331 from srcejon/dial_darken

Darken ValueDials when disabled
This commit is contained in:
Edouard Griffiths 2022-07-10 01:32:48 +02:00 committed by GitHub
commit dcd0ee2272
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 18 additions and 8 deletions

View File

@ -236,12 +236,17 @@ void ValueDial::paintEvent(QPaintEvent *)
painter.drawRect(2 + m_hightlightedDigit * m_digitWidth, 1, m_digitWidth - 1, height() - 1);
}
QColor secondaryForegroundColor = m_colorMapper.getSecondaryForegroundColor();
if (!isEnabled()) {
secondaryForegroundColor = secondaryForegroundColor.darker();
}
if (m_animationState == 0)
{
for (int i = 0; i < m_text.length(); i++)
{
painter.setClipRect(1 + i * m_digitWidth, 1, m_digitWidth, m_digitHeight * 2);
painter.setPen(m_colorMapper.getSecondaryForegroundColor());
painter.setPen(secondaryForegroundColor);
painter.drawText(QRect(1 + i * m_digitWidth, m_digitHeight * 0.6, m_digitWidth, m_digitHeight), Qt::AlignCenter, m_text.mid(i, 1));
if (m_text[i] != m_groupSeparator)
@ -257,7 +262,7 @@ void ValueDial::paintEvent(QPaintEvent *)
if ((m_cursor >= 0) && (m_cursorState))
{
painter.setPen(Qt::NoPen);
painter.setBrush(m_colorMapper.getSecondaryForegroundColor());
painter.setBrush(secondaryForegroundColor);
painter.drawRect(4 + m_cursor * m_digitWidth, 1 + m_digitHeight * 1.5, m_digitWidth - 5, m_digitHeight / 6);
}
}
@ -268,7 +273,7 @@ void ValueDial::paintEvent(QPaintEvent *)
if (m_text[i] == m_textNew[i])
{
painter.setClipRect(1 + i * m_digitWidth, 1, m_digitWidth, m_digitHeight * 2);
painter.setPen(m_colorMapper.getSecondaryForegroundColor());
painter.setPen(secondaryForegroundColor);
painter.drawText(QRect(1 + i * m_digitWidth, m_digitHeight * 0.6, m_digitWidth, m_digitHeight), Qt::AlignCenter, m_text.mid(i, 1));
if (m_text[i] != m_groupSeparator)
@ -282,7 +287,7 @@ void ValueDial::paintEvent(QPaintEvent *)
{
int h = m_digitHeight * 0.6 + m_digitHeight * m_animationState / 2.0;
painter.setClipRect(1 + i * m_digitWidth, 1, m_digitWidth, m_digitHeight * 2);
painter.setPen(m_colorMapper.getSecondaryForegroundColor());
painter.setPen(secondaryForegroundColor);
painter.drawText(QRect(1 + i * m_digitWidth, h, m_digitWidth, m_digitHeight), Qt::AlignCenter, m_text.mid(i, 1));
if (m_text[i] != m_groupSeparator)

View File

@ -278,12 +278,17 @@ void ValueDialZ::paintEvent(QPaintEvent*)
painter.drawRect(2 + m_hightlightedDigit * m_digitWidth, 1, m_digitWidth - 1, height() - 1);
}
QColor secondaryForegroundColor = m_colorMapper.getSecondaryForegroundColor();
if (!isEnabled()) {
secondaryForegroundColor = secondaryForegroundColor.darker();
}
if (m_animationState == 0)
{
for (int i = 0; i < m_text.length(); i++)
{
painter.setClipRect(1 + i * m_digitWidth, 1, m_digitWidth, m_digitHeight * 2);
painter.setPen(m_colorMapper.getSecondaryForegroundColor());
painter.setPen(secondaryForegroundColor);
painter.drawText(QRect(1 + i * m_digitWidth, m_digitHeight * 0.6, m_digitWidth, m_digitHeight), Qt::AlignCenter, m_text.mid(i, 1));
if ((m_text[i] != m_groupSeparator) && (m_text[i] != m_decSeparator))
@ -299,7 +304,7 @@ void ValueDialZ::paintEvent(QPaintEvent*)
if ((m_cursor >= 0) && (m_cursorState))
{
painter.setPen(Qt::NoPen);
painter.setBrush(m_colorMapper.getSecondaryForegroundColor());
painter.setBrush(secondaryForegroundColor);
painter.drawRect(4 + m_cursor * m_digitWidth, 1 + m_digitHeight * 1.5, m_digitWidth - 5, m_digitHeight / 6);
}
}
@ -310,7 +315,7 @@ void ValueDialZ::paintEvent(QPaintEvent*)
if (m_text[i] == m_textNew[i])
{
painter.setClipRect(1 + i * m_digitWidth, 1, m_digitWidth, m_digitHeight * 2);
painter.setPen(m_colorMapper.getSecondaryForegroundColor());
painter.setPen(secondaryForegroundColor);
painter.drawText(QRect(1 + i * m_digitWidth, m_digitHeight * 0.6, m_digitWidth, m_digitHeight), Qt::AlignCenter, m_text.mid(i, 1));
if ((m_text[i] != m_groupSeparator) && (m_text[i] != m_decSeparator))
@ -324,7 +329,7 @@ void ValueDialZ::paintEvent(QPaintEvent*)
{
int h = m_digitHeight * 0.6 + m_digitHeight * m_animationState / 2.0;
painter.setClipRect(1 + i * m_digitWidth, 1, m_digitWidth, m_digitHeight * 2);
painter.setPen(m_colorMapper.getSecondaryForegroundColor());
painter.setPen(secondaryForegroundColor);
painter.drawText(QRect(1 + i * m_digitWidth, h, m_digitWidth, m_digitHeight), Qt::AlignCenter, m_text.mid(i, 1));
if ((m_text[i] != m_groupSeparator) && (m_text[i] != m_decSeparator))