mirror of
https://github.com/strawberrymusicplayer/strawberry
synced 2024-12-09 15:25:18 +01:00
Add option to reset playlist columns
This commit is contained in:
parent
23205bef65
commit
bca1a98938
@ -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();
|
||||
}
|
||||
|
@ -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_;
|
||||
|
@ -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_);
|
||||
|
||||
}
|
||||
|
@ -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();
|
||||
|
Loading…
Reference in New Issue
Block a user