Periodically save current playlist tab
Building on the previous commit, we save the current playlist (tab) periodically as well. Signed-off-by: Antonio Russo <antonio.e.russo@gmail.com>
This commit is contained in:
parent
e66fdd86da
commit
ccaa59cc66
@ -16,6 +16,7 @@
|
||||
*/
|
||||
|
||||
#include "core/appearance.h"
|
||||
#include "core/application.h"
|
||||
#include "core/logging.h"
|
||||
#include "core/player.h"
|
||||
#include "core/timeconstants.h"
|
||||
@ -43,6 +44,7 @@ const int PlaylistContainer::kFilterDelayPlaylistSizeThreshold = 5000;
|
||||
|
||||
PlaylistContainer::PlaylistContainer(QWidget* parent)
|
||||
: QWidget(parent),
|
||||
app_(nullptr),
|
||||
ui_(new Ui_PlaylistContainer),
|
||||
manager_(nullptr),
|
||||
undo_(nullptr),
|
||||
@ -52,7 +54,8 @@ PlaylistContainer::PlaylistContainer(QWidget* parent)
|
||||
tab_bar_visible_(false),
|
||||
tab_bar_animation_(new QTimeLine(500, this)),
|
||||
no_matches_label_(nullptr),
|
||||
filter_timer_(new QTimer(this)) {
|
||||
filter_timer_(new QTimer(this)),
|
||||
dirty_(false) {
|
||||
ui_->setupUi(this);
|
||||
|
||||
no_matches_label_ = new QLabel(ui_->playlist);
|
||||
@ -96,6 +99,7 @@ PlaylistContainer::PlaylistContainer(QWidget* parent)
|
||||
ui_->tab_bar->setMaximumHeight(0);
|
||||
|
||||
// Connections
|
||||
connect(ui_->tab_bar, SIGNAL(currentChanged(int)), SLOT(DirtyTabBar()));
|
||||
connect(ui_->tab_bar, SIGNAL(Save(int)), SLOT(SavePlaylist(int)));
|
||||
|
||||
// set up timer for delayed filter updates
|
||||
@ -111,10 +115,17 @@ PlaylistContainer::PlaylistContainer(QWidget* parent)
|
||||
}
|
||||
|
||||
PlaylistContainer::~PlaylistContainer() {
|
||||
Save();
|
||||
delete ui_;
|
||||
}
|
||||
|
||||
void PlaylistContainer::SetApplication(Application* app) {
|
||||
Q_ASSERT(app);
|
||||
app_ = app;
|
||||
SetManager(app_->playlist_manager());
|
||||
ui_->playlist->SetApplication(app_);
|
||||
connect(app_, SIGNAL(SaveSettings(QSettings*)), SLOT(Save(QSettings*)));
|
||||
}
|
||||
|
||||
PlaylistView* PlaylistContainer::view() const { return ui_->playlist; }
|
||||
|
||||
void PlaylistContainer::SetActions(QAction* new_playlist,
|
||||
@ -334,10 +345,18 @@ void PlaylistContainer::GoToPreviousPlaylistTab() {
|
||||
manager_->SetCurrentPlaylist(id_previous);
|
||||
}
|
||||
|
||||
void PlaylistContainer::Save() {
|
||||
if (starting_up_) return;
|
||||
void PlaylistContainer::DirtyTabBar() {
|
||||
dirty_ = true;
|
||||
app_->DirtySettings();
|
||||
}
|
||||
|
||||
settings_.setValue("current_playlist", ui_->tab_bar->current_id());
|
||||
void PlaylistContainer::Save(QSettings* settings_) {
|
||||
if (starting_up_ || !dirty_) return;
|
||||
dirty_ = false;
|
||||
|
||||
settings_->beginGroup(kSettingsGroup);
|
||||
settings_->setValue("current_playlist", ui_->tab_bar->current_id());
|
||||
settings_->endGroup();
|
||||
}
|
||||
|
||||
void PlaylistContainer::SetTabBarVisible(bool visible) {
|
||||
|
@ -23,6 +23,7 @@
|
||||
|
||||
class Ui_PlaylistContainer;
|
||||
|
||||
class Application;
|
||||
class LineEditInterface;
|
||||
class Playlist;
|
||||
class PlaylistManager;
|
||||
@ -41,6 +42,7 @@ class PlaylistContainer : public QWidget {
|
||||
|
||||
static const char* kSettingsGroup;
|
||||
|
||||
void SetApplication(Application* app);
|
||||
void SetActions(QAction* new_playlist, QAction* load_playlist,
|
||||
QAction* save_playlist, QAction* next_playlist,
|
||||
QAction* previous_playlist);
|
||||
@ -83,7 +85,8 @@ signals:
|
||||
void ActivePaused();
|
||||
void ActiveStopped();
|
||||
|
||||
void Save();
|
||||
void DirtyTabBar();
|
||||
void Save(QSettings* settings_);
|
||||
|
||||
void SetTabBarVisible(bool visible);
|
||||
void SetTabBarHeight(int height);
|
||||
@ -103,6 +106,7 @@ signals:
|
||||
static const int kFilterDelayMs;
|
||||
static const int kFilterDelayPlaylistSizeThreshold;
|
||||
|
||||
Application* app_;
|
||||
Ui_PlaylistContainer* ui_;
|
||||
|
||||
PlaylistManager* manager_;
|
||||
@ -119,6 +123,8 @@ signals:
|
||||
QLabel* no_matches_label_;
|
||||
|
||||
QTimer* filter_timer_;
|
||||
|
||||
bool dirty_;
|
||||
};
|
||||
|
||||
#endif // PLAYLISTCONTAINER_H
|
||||
|
@ -325,8 +325,7 @@ MainWindow::MainWindow(Application* app, SystemTrayIcon* tray_icon, OSD* osd,
|
||||
|
||||
connect(ui_->playlist, SIGNAL(ViewSelectionModelChanged()),
|
||||
SLOT(PlaylistViewSelectionModelChanged()));
|
||||
ui_->playlist->SetManager(app_->playlist_manager());
|
||||
ui_->playlist->view()->SetApplication(app_);
|
||||
ui_->playlist->SetApplication(app_);
|
||||
|
||||
library_view_->view()->setModel(library_sort_model_);
|
||||
library_view_->view()->SetApplication(app_);
|
||||
|
Loading…
x
Reference in New Issue
Block a user