Skip to content

Commit

Permalink
qtui: Collapse infobar vis when hidden. Closes: #990.
Browse files Browse the repository at this point in the history
  • Loading branch information
jlindgren90 committed May 29, 2020
1 parent 2948491 commit 114b669
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions src/qtui/info_bar.cc
Original file line number Diff line number Diff line change
Expand Up @@ -181,6 +181,8 @@ void InfoVis::enable(bool enabled)
aud_visualizer_remove(this);
clear();
}

setVisible(enabled);
}

InfoBar::InfoBar(QWidget * parent)
Expand Down Expand Up @@ -211,6 +213,7 @@ InfoBar::InfoBar(QWidget * parent)

void InfoBar::resizeEvent(QResizeEvent *)
{
// re-ellipsize text on next paintEvent
for (SongData & d : sd)
d.title.setText(QString());

Expand All @@ -221,7 +224,8 @@ void InfoBar::paintEvent(QPaintEvent *)
{
QPainter p(this);

p.fillRect(0, 0, width() - ps.VisWidth, ps.Height, m_vis->gradient());
int viswidth = m_vis->isVisible() ? ps.VisWidth : 0;
p.fillRect(0, 0, width() - viswidth, ps.Height, m_vis->gradient());

for (SongData & d : sd)
{
Expand All @@ -244,7 +248,7 @@ void InfoBar::paintEvent(QPaintEvent *)
QFontMetrics metrics = p.fontMetrics();
d.title = QStaticText(metrics.elidedText(
d.orig_title, Qt::ElideRight,
width() - ps.VisWidth - ps.Height - ps.Spacing));
width() - viswidth - ps.Height - ps.Spacing));
}

p.setPen(QColor(255, 255, 255));
Expand Down Expand Up @@ -329,5 +333,10 @@ void InfoBar::playback_stop_cb()

void InfoBar::update_vis()
{
// re-ellipsize text on next paintEvent
for (SongData & d : sd)
d.title.setText(QString());

m_vis->enable(aud_get_bool("qtui", "infoarea_show_vis"));
update();
}

0 comments on commit 114b669

Please sign in to comment.