Add option to automatically select current playing track

This commit is contained in:
Jonas Kvinge 2019-10-27 02:11:51 +01:00
parent 73164f7182
commit 3de85549b6
4 changed files with 21 additions and 3 deletions

View File

@ -161,6 +161,7 @@ PlaylistView::PlaylistView(QWidget *parent)
previous_background_image_x_(0),
previous_background_image_y_(0),
glow_enabled_(true),
select_track_(false),
currently_glowing_(false),
glow_intensity_step_(0),
inhibit_autoscroll_timer_(new QTimer(this)),
@ -1004,6 +1005,7 @@ void PlaylistView::ReloadSettings() {
#endif
glow_enabled_ = s.value("glow_effect", glow_effect).toBool();
bool editmetadatainline = s.value("editmetadatainline", false).toBool();
select_track_ = s.value("select_track", false).toBool();
s.endGroup();
s.beginGroup(Playlist::kSettingsGroup);
@ -1228,7 +1230,15 @@ void PlaylistView::CopyCurrentSongToClipboard() const {
}
void PlaylistView::SongChanged(const Song &song) {
song_playing_ = song;
if (select_track_ && playlist_) {
clearSelection();
QItemSelection selection(playlist_->index(playlist_->current_row(), 0), playlist_->index(playlist_->current_row(), playlist_->ColumnCount - 1));
selectionModel()->select(selection, QItemSelectionModel::Select);
}
}
void PlaylistView::Playing() {}

View File

@ -240,6 +240,8 @@ class PlaylistView : public QTreeView {
int previous_background_image_y_;
bool glow_enabled_;
bool select_track_;
bool currently_glowing_;
QBasicTimer glow_timer_;
int glow_intensity_step_;

View File

@ -66,6 +66,7 @@ void PlaylistSettingsPage::Load() {
ui_->checkbox_continueonerror->setChecked(s.value("continue_on_error", false).toBool());
ui_->checkbox_greyout_songs_startup->setChecked(s.value("greyout_songs_startup", true).toBool());
ui_->checkbox_greyout_songs_play->setChecked(s.value("greyout_songs_play", true).toBool());
ui_->checkbox_select_track->setChecked(s.value("select_track", false).toBool());
Playlist::Path path = Playlist::Path(s.value(Playlist::kPathType, Playlist::Path_Automatic).toInt());
switch (path) {
@ -113,6 +114,7 @@ void PlaylistSettingsPage::Save() {
s.setValue("continue_on_error", ui_->checkbox_continueonerror->isChecked());
s.setValue("greyout_songs_startup", ui_->checkbox_greyout_songs_startup->isChecked());
s.setValue("greyout_songs_play", ui_->checkbox_greyout_songs_play->isChecked());
s.setValue("select_track", ui_->checkbox_select_track->isChecked());
s.setValue(Playlist::kPathType, static_cast<int>(path));
s.setValue("editmetadatainline", ui_->checkbox_editmetadatainline->isChecked());
s.setValue(Playlist::kWriteMetadata, ui_->checkbox_writemetadata->isChecked());

View File

@ -19,9 +19,6 @@
<property name="text">
<string>Show a glowing animation on the current track</string>
</property>
<property name="checked">
<bool>true</bool>
</property>
</widget>
</item>
<item>
@ -52,6 +49,13 @@
</property>
</widget>
</item>
<item>
<widget class="QCheckBox" name="checkbox_select_track">
<property name="text">
<string>Automatically select current playing track</string>
</property>
</widget>
</item>
<item>
<widget class="QGroupBox" name="groupbox_paths">
<property name="title">