Add an option for not being asked before closing a playlist
This commit is contained in:
parent
fc1880161c
commit
f75c0a2b97
@ -33,6 +33,8 @@
|
|||||||
#include <QPushButton>
|
#include <QPushButton>
|
||||||
#include <QToolTip>
|
#include <QToolTip>
|
||||||
|
|
||||||
|
const char* PlaylistTabBar::kSettingsGroup = "PlaylistTabBar";
|
||||||
|
|
||||||
PlaylistTabBar::PlaylistTabBar(QWidget *parent)
|
PlaylistTabBar::PlaylistTabBar(QWidget *parent)
|
||||||
: QTabBar(parent),
|
: QTabBar(parent),
|
||||||
manager_(NULL),
|
manager_(NULL),
|
||||||
@ -94,7 +96,7 @@ void PlaylistTabBar::mouseReleaseEvent(QMouseEvent* e) {
|
|||||||
if (e->button() == Qt::MidButton) {
|
if (e->button() == Qt::MidButton) {
|
||||||
// Update menu index
|
// Update menu index
|
||||||
menu_index_ = tabAt(e->pos());
|
menu_index_ = tabAt(e->pos());
|
||||||
Close(false);
|
Close();
|
||||||
}
|
}
|
||||||
|
|
||||||
QTabBar::mouseReleaseEvent(e);
|
QTabBar::mouseReleaseEvent(e);
|
||||||
@ -151,12 +153,17 @@ void PlaylistTabBar::HideEditor() {
|
|||||||
manager_->SetCurrentPlaylist(manager_->current()->id());
|
manager_->SetCurrentPlaylist(manager_->current()->id());
|
||||||
}
|
}
|
||||||
|
|
||||||
void PlaylistTabBar::Close(bool ask_for_delete) {
|
void PlaylistTabBar::Close() {
|
||||||
if (menu_index_ == -1)
|
if (menu_index_ == -1)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
const int playlist_id = tabData(menu_index_).toInt();
|
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 (ask_for_delete && !manager_->IsPlaylistFavorite(playlist_id)) {
|
||||||
if (QMessageBox::question(this,
|
if (QMessageBox::question(this,
|
||||||
tr("Remove playlist"),
|
tr("Remove playlist"),
|
||||||
|
@ -34,6 +34,7 @@ public:
|
|||||||
PlaylistTabBar(QWidget *parent = 0);
|
PlaylistTabBar(QWidget *parent = 0);
|
||||||
|
|
||||||
static const int kDragHoverTimeout = 500;
|
static const int kDragHoverTimeout = 500;
|
||||||
|
static const char* kSettingsGroup;
|
||||||
|
|
||||||
void SetActions(QAction* new_playlist, QAction* load_playlist);
|
void SetActions(QAction* new_playlist, QAction* load_playlist);
|
||||||
void SetManager(PlaylistManager* manager);
|
void SetManager(PlaylistManager* manager);
|
||||||
@ -76,7 +77,7 @@ private slots:
|
|||||||
void Rename();
|
void Rename();
|
||||||
void RenameInline();
|
void RenameInline();
|
||||||
void HideEditor();
|
void HideEditor();
|
||||||
void Close(bool ask_for_delete = true);
|
void Close();
|
||||||
void CloseFromTabIndex(int index);
|
void CloseFromTabIndex(int index);
|
||||||
// Used when playlist's favorite flag isn't changed from the favorite widget
|
// Used when playlist's favorite flag isn't changed from the favorite widget
|
||||||
// (e.g. from the playlistlistcontainer): will update the favorite widget
|
// (e.g. from the playlistlistcontainer): will update the favorite widget
|
||||||
|
@ -19,6 +19,7 @@
|
|||||||
#include "mainwindow.h"
|
#include "mainwindow.h"
|
||||||
#include "ui_behavioursettingspage.h"
|
#include "ui_behavioursettingspage.h"
|
||||||
#include "playlist/playlist.h"
|
#include "playlist/playlist.h"
|
||||||
|
#include "playlist/playlisttabbar.h"
|
||||||
|
|
||||||
#include <QDir>
|
#include <QDir>
|
||||||
|
|
||||||
@ -124,6 +125,10 @@ void BehaviourSettingsPage::Load() {
|
|||||||
s.beginGroup(Playlist::kSettingsGroup);
|
s.beginGroup(Playlist::kSettingsGroup);
|
||||||
ui_->b_grey_out_deleted_->setChecked(s.value("greyoutdeleted", false).toBool());
|
ui_->b_grey_out_deleted_->setChecked(s.value("greyoutdeleted", false).toBool());
|
||||||
s.endGroup();
|
s.endGroup();
|
||||||
|
|
||||||
|
s.beginGroup(PlaylistTabBar::kSettingsGroup);
|
||||||
|
ui_->b_warm_close_playlist_->setChecked(s.value("warm_close_playlist", true).toBool());
|
||||||
|
s.endGroup();
|
||||||
}
|
}
|
||||||
|
|
||||||
void BehaviourSettingsPage::Save() {
|
void BehaviourSettingsPage::Save() {
|
||||||
@ -159,6 +164,10 @@ void BehaviourSettingsPage::Save() {
|
|||||||
s.beginGroup(Playlist::kSettingsGroup);
|
s.beginGroup(Playlist::kSettingsGroup);
|
||||||
s.setValue("greyoutdeleted", ui_->b_grey_out_deleted_->isChecked());
|
s.setValue("greyoutdeleted", ui_->b_grey_out_deleted_->isChecked());
|
||||||
s.endGroup();
|
s.endGroup();
|
||||||
|
|
||||||
|
s.beginGroup(PlaylistTabBar::kSettingsGroup);
|
||||||
|
s.setValue("warm_close_playlist", ui_->b_warm_close_playlist_->isChecked());
|
||||||
|
s.endGroup();
|
||||||
}
|
}
|
||||||
|
|
||||||
void BehaviourSettingsPage::ShowTrayIconToggled(bool on) {
|
void BehaviourSettingsPage::ShowTrayIconToggled(bool on) {
|
||||||
|
@ -31,6 +31,20 @@
|
|||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</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>
|
<item>
|
||||||
<widget class="QGroupBox" name="groupBox_3">
|
<widget class="QGroupBox" name="groupBox_3">
|
||||||
<property name="title">
|
<property name="title">
|
||||||
|
Loading…
x
Reference in New Issue
Block a user