1
0
mirror of https://github.com/strawberrymusicplayer/strawberry synced 2024-12-27 00:34:16 +01:00

Add option to reset playlist columns

This commit is contained in:
Jonas Kvinge 2018-11-19 00:18:48 +01:00
parent 23205bef65
commit bca1a98938
4 changed files with 31 additions and 9 deletions

View File

@ -47,6 +47,7 @@ PlaylistHeader::PlaylistHeader(Qt::Orientation orientation, PlaylistView *view,
hide_action_ = menu_->addAction(tr("&Hide..."), this, SLOT(HideCurrent())); hide_action_ = menu_->addAction(tr("&Hide..."), this, SLOT(HideCurrent()));
stretch_action_ = menu_->addAction(tr("&Stretch columns to fit window"), this, SLOT(ToggleStretchEnabled())); 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(); menu_->addSeparator();
QMenu *align_menu = new QMenu(tr("&Align text"), this); QMenu *align_menu = new QMenu(tr("&Align text"), this);
@ -141,3 +142,6 @@ void PlaylistHeader::enterEvent(QEvent*) {
emit MouseEntered(); emit MouseEntered();
} }
void PlaylistHeader::ResetColumns() {
view_->ResetColumns();
}

View File

@ -55,6 +55,7 @@ class PlaylistHeader : public StretchHeaderView {
private slots: private slots:
void HideCurrent(); void HideCurrent();
void ToggleVisible(int section); void ToggleVisible(int section);
void ResetColumns();
void SetColumnAlignment(QAction *action); void SetColumnAlignment(QAction *action);
private: private:
@ -67,6 +68,7 @@ class PlaylistHeader : public StretchHeaderView {
QMenu *menu_; QMenu *menu_;
QAction *hide_action_; QAction *hide_action_;
QAction *stretch_action_; QAction *stretch_action_;
QAction *reset_action_;
QAction *align_left_action_; QAction *align_left_action_;
QAction *align_center_action_; QAction *align_center_action_;
QAction *align_right_action_; QAction *align_right_action_;

View File

@ -291,26 +291,23 @@ void PlaylistView::LoadGeometry() {
if (!header_->RestoreState(state)) { if (!header_->RestoreState(state)) {
// Maybe we're upgrading from a version that persisted the state with QHeaderView. // Maybe we're upgrading from a version that persisted the state with QHeaderView.
if (!header_->restoreState(state)) { 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_Year);
header_->HideSection(Playlist::Column_OriginalYear); header_->HideSection(Playlist::Column_OriginalYear);
header_->HideSection(Playlist::Column_Disc);
header_->HideSection(Playlist::Column_Genre); header_->HideSection(Playlist::Column_Genre);
header_->HideSection(Playlist::Column_Filename); header_->HideSection(Playlist::Column_Filename);
header_->HideSection(Playlist::Column_BaseFilename);
header_->HideSection(Playlist::Column_Filesize); header_->HideSection(Playlist::Column_Filesize);
header_->HideSection(Playlist::Column_DateCreated); header_->HideSection(Playlist::Column_DateCreated);
header_->HideSection(Playlist::Column_DateModified); 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_PlayCount);
header_->HideSection(Playlist::Column_SkipCount); header_->HideSection(Playlist::Column_SkipCount);
header_->HideSection(Playlist::Column_LastPlayed); header_->HideSection(Playlist::Column_LastPlayed);
header_->HideSection(Playlist::Column_Comment); header_->HideSection(Playlist::Column_Comment);
header_->HideSection(Playlist::Column_BaseFilename); header_->HideSection(Playlist::Column_Grouping);
header_->HideSection(Playlist::Column_Samplerate);
header_->HideSection(Playlist::Column_Bitdepth);
header_->moveSection(header_->visualIndex(Playlist::Column_Track), 0); header_->moveSection(header_->visualIndex(Playlist::Column_Track), 0);
setting_initial_header_layout_ = true; 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_);
}

View File

@ -124,6 +124,8 @@ class PlaylistView : public QTreeView {
void drawRow(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index) const; void drawRow(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index) const;
void setModel(QAbstractItemModel *model); void setModel(QAbstractItemModel *model);
void ResetColumns();
public slots: public slots:
void ReloadSettings(); void ReloadSettings();
void StopGlowing(); void StopGlowing();