1
0
mirror of https://github.com/clementine-player/Clementine synced 2025-01-31 19:45:31 +01:00

Add an option for not being asked before closing a playlist

This commit is contained in:
Arnaud Bienner 2013-07-27 19:59:15 +02:00
parent fc1880161c
commit f75c0a2b97
4 changed files with 34 additions and 3 deletions

View File

@ -33,6 +33,8 @@
#include <QPushButton>
#include <QToolTip>
const char* PlaylistTabBar::kSettingsGroup = "PlaylistTabBar";
PlaylistTabBar::PlaylistTabBar(QWidget *parent)
: QTabBar(parent),
manager_(NULL),
@ -94,7 +96,7 @@ void PlaylistTabBar::mouseReleaseEvent(QMouseEvent* e) {
if (e->button() == Qt::MidButton) {
// Update menu index
menu_index_ = tabAt(e->pos());
Close(false);
Close();
}
QTabBar::mouseReleaseEvent(e);
@ -151,12 +153,17 @@ void PlaylistTabBar::HideEditor() {
manager_->SetCurrentPlaylist(manager_->current()->id());
}
void PlaylistTabBar::Close(bool ask_for_delete) {
void PlaylistTabBar::Close() {
if (menu_index_ == -1)
return;
const int playlist_id = tabData(menu_index_).toInt();
QSettings s;
s.beginGroup(kSettingsGroup);
const bool ask_for_delete = s.value("warm_close_playlist", true).toBool();
if (ask_for_delete && !manager_->IsPlaylistFavorite(playlist_id)) {
if (QMessageBox::question(this,
tr("Remove playlist"),

View File

@ -34,6 +34,7 @@ public:
PlaylistTabBar(QWidget *parent = 0);
static const int kDragHoverTimeout = 500;
static const char* kSettingsGroup;
void SetActions(QAction* new_playlist, QAction* load_playlist);
void SetManager(PlaylistManager* manager);
@ -76,7 +77,7 @@ private slots:
void Rename();
void RenameInline();
void HideEditor();
void Close(bool ask_for_delete = true);
void Close();
void CloseFromTabIndex(int index);
// Used when playlist's favorite flag isn't changed from the favorite widget
// (e.g. from the playlistlistcontainer): will update the favorite widget

View File

@ -19,6 +19,7 @@
#include "mainwindow.h"
#include "ui_behavioursettingspage.h"
#include "playlist/playlist.h"
#include "playlist/playlisttabbar.h"
#include <QDir>
@ -124,6 +125,10 @@ void BehaviourSettingsPage::Load() {
s.beginGroup(Playlist::kSettingsGroup);
ui_->b_grey_out_deleted_->setChecked(s.value("greyoutdeleted", false).toBool());
s.endGroup();
s.beginGroup(PlaylistTabBar::kSettingsGroup);
ui_->b_warm_close_playlist_->setChecked(s.value("warm_close_playlist", true).toBool());
s.endGroup();
}
void BehaviourSettingsPage::Save() {
@ -159,6 +164,10 @@ void BehaviourSettingsPage::Save() {
s.beginGroup(Playlist::kSettingsGroup);
s.setValue("greyoutdeleted", ui_->b_grey_out_deleted_->isChecked());
s.endGroup();
s.beginGroup(PlaylistTabBar::kSettingsGroup);
s.setValue("warm_close_playlist", ui_->b_warm_close_playlist_->isChecked());
s.endGroup();
}
void BehaviourSettingsPage::ShowTrayIconToggled(bool on) {

View File

@ -31,6 +31,20 @@
</property>
</widget>
</item>
<item>
<widget class="Line" name="line">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
</widget>
</item>
<item>
<widget class="QCheckBox" name="b_warm_close_playlist_">
<property name="text">
<string>Warm me when closing a playlist tab</string>
</property>
</widget>
</item>
<item>
<widget class="QGroupBox" name="groupBox_3">
<property name="title">