Skip to content

Commit 5f325d1

Browse files
qtui: Use bold font for currently playing song
Suggested in #979.
1 parent bbb9485 commit 5f325d1

File tree

4 files changed

+25
-0
lines changed

4 files changed

+25
-0
lines changed

src/qtui/playlist-qt.cc

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,8 @@ PlaylistWidget::PlaylistWidget(QWidget * parent, Playlist playlist)
3838
model(new PlaylistModel(this, playlist)),
3939
proxyModel(new PlaylistProxyModel(this, playlist))
4040
{
41+
model->setFont(font());
42+
4143
/* setting up filtering model */
4244
proxyModel->setSourceModel(model);
4345

@@ -126,6 +128,14 @@ void PlaylistWidget::activate(const QModelIndex & index)
126128
}
127129
}
128130

131+
void PlaylistWidget::changeEvent(QEvent * event)
132+
{
133+
if (event->type() == QEvent::FontChange)
134+
model->setFont(font());
135+
136+
audqt::TreeView::changeEvent(event);
137+
}
138+
129139
void PlaylistWidget::contextMenuEvent(QContextMenuEvent * event)
130140
{
131141
if (contextMenu)

src/qtui/playlist-qt.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,7 @@ class PlaylistWidget : public audqt::TreeView
7070
void updateSelection(int rowsBefore, int rowsAfter);
7171

7272
void activate(const QModelIndex & index);
73+
void changeEvent(QEvent * event);
7374
void contextMenuEvent(QContextMenuEvent * event);
7475
void keyPressEvent(QKeyEvent * event);
7576
void mouseMoveEvent(QMouseEvent * event);

src/qtui/playlist_model.cc

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,12 @@ int PlaylistModel::columnCount(const QModelIndex & parent) const
6464
return 1 + n_cols;
6565
}
6666

67+
void PlaylistModel::setFont(const QFont & font)
68+
{
69+
m_bold = font;
70+
m_bold.setBold(true);
71+
}
72+
6773
QVariant PlaylistModel::alignment(int col) const
6874
{
6975
switch (col)
@@ -121,6 +127,11 @@ QVariant PlaylistModel::data(const QModelIndex & index, int role) const
121127
return QString("%1").arg(val);
122128
}
123129

130+
case Qt::FontRole:
131+
if (index.row() == m_playlist.get_position())
132+
return m_bold;
133+
break;
134+
124135
case Qt::TextAlignmentRole:
125136
return alignment(col);
126137

src/qtui/playlist_model.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,9 +70,12 @@ class PlaylistModel : public QAbstractListModel
7070
void entriesRemoved(int row, int count);
7171
void entriesChanged(int row, int count);
7272

73+
void setFont(const QFont & font);
74+
7375
private:
7476
Playlist m_playlist;
7577
int m_rows;
78+
QFont m_bold;
7679

7780
QVariant alignment(int col) const;
7881
QString queuePos(int row) const;

0 commit comments

Comments
 (0)