diff --git a/src/playlist/playlistheader.cpp b/src/playlist/playlistheader.cpp index df5701c7d..9d9872f72 100644 --- a/src/playlist/playlistheader.cpp +++ b/src/playlist/playlistheader.cpp @@ -47,6 +47,7 @@ PlaylistHeader::PlaylistHeader(Qt::Orientation orientation, PlaylistView *view, hide_action_ = menu_->addAction(tr("&Hide..."), this, SLOT(HideCurrent())); stretch_action_ = menu_->addAction(tr("&Stretch columns to fit window"), this, SLOT(ToggleStretchEnabled())); + reset_action_ = menu_->addAction(tr("&Reset columns to default"), this, SLOT(ResetColumns())); menu_->addSeparator(); QMenu *align_menu = new QMenu(tr("&Align text"), this); @@ -141,3 +142,6 @@ void PlaylistHeader::enterEvent(QEvent*) { emit MouseEntered(); } +void PlaylistHeader::ResetColumns() { + view_->ResetColumns(); +} diff --git a/src/playlist/playlistheader.h b/src/playlist/playlistheader.h index 42c239223..c1191d538 100644 --- a/src/playlist/playlistheader.h +++ b/src/playlist/playlistheader.h @@ -55,6 +55,7 @@ class PlaylistHeader : public StretchHeaderView { private slots: void HideCurrent(); void ToggleVisible(int section); + void ResetColumns(); void SetColumnAlignment(QAction *action); private: @@ -67,6 +68,7 @@ class PlaylistHeader : public StretchHeaderView { QMenu *menu_; QAction *hide_action_; QAction *stretch_action_; + QAction *reset_action_; QAction *align_left_action_; QAction *align_center_action_; QAction *align_right_action_; diff --git a/src/playlist/playlistview.cpp b/src/playlist/playlistview.cpp index 1180c9d82..83420eae0 100644 --- a/src/playlist/playlistview.cpp +++ b/src/playlist/playlistview.cpp @@ -291,26 +291,23 @@ void PlaylistView::LoadGeometry() { if (!header_->RestoreState(state)) { // Maybe we're upgrading from a version that persisted the state with QHeaderView. if (!header_->restoreState(state)) { - header_->HideSection(Playlist::Column_Disc); + header_->HideSection(Playlist::Column_AlbumArtist); + header_->HideSection(Playlist::Column_Performer); + header_->HideSection(Playlist::Column_Composer); header_->HideSection(Playlist::Column_Year); header_->HideSection(Playlist::Column_OriginalYear); + header_->HideSection(Playlist::Column_Disc); header_->HideSection(Playlist::Column_Genre); header_->HideSection(Playlist::Column_Filename); + header_->HideSection(Playlist::Column_BaseFilename); header_->HideSection(Playlist::Column_Filesize); header_->HideSection(Playlist::Column_DateCreated); header_->HideSection(Playlist::Column_DateModified); - header_->HideSection(Playlist::Column_AlbumArtist); - header_->HideSection(Playlist::Column_Composer); - header_->HideSection(Playlist::Column_Performer); - header_->HideSection(Playlist::Column_Grouping); header_->HideSection(Playlist::Column_PlayCount); header_->HideSection(Playlist::Column_SkipCount); header_->HideSection(Playlist::Column_LastPlayed); header_->HideSection(Playlist::Column_Comment); - header_->HideSection(Playlist::Column_BaseFilename); - - header_->HideSection(Playlist::Column_Samplerate); - header_->HideSection(Playlist::Column_Bitdepth); + header_->HideSection(Playlist::Column_Grouping); header_->moveSection(header_->visualIndex(Playlist::Column_Track), 0); setting_initial_header_layout_ = true; @@ -1229,3 +1226,20 @@ void PlaylistView::focusInEvent(QFocusEvent *event) { } } + +void PlaylistView::ResetColumns() { + + read_only_settings_ = true; + setting_initial_header_layout_ = true; + QSettings settings; + settings.beginGroup(Playlist::kSettingsGroup); + settings.remove("state"); + settings.endGroup(); + ReloadSettings(); + LoadGeometry(); + ReloadSettings(); + read_only_settings_ = false; + SaveGeometry(); + SetPlaylist(playlist_); + +} diff --git a/src/playlist/playlistview.h b/src/playlist/playlistview.h index ca3d1253a..4ad38b18b 100644 --- a/src/playlist/playlistview.h +++ b/src/playlist/playlistview.h @@ -124,6 +124,8 @@ class PlaylistView : public QTreeView { void drawRow(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index) const; void setModel(QAbstractItemModel *model); + void ResetColumns(); + public slots: void ReloadSettings(); void StopGlowing();