2018-02-27 18:06:05 +01:00
|
|
|
/*
|
|
|
|
* Strawberry Music Player
|
|
|
|
* This file was part of Clementine.
|
|
|
|
* Copyright 2010, David Sansome <me@davidsansome.com>
|
2021-03-20 21:14:47 +01:00
|
|
|
* Copyright 2018-2021, Jonas Kvinge <jonas@jkvinge.net>
|
2018-02-27 18:06:05 +01:00
|
|
|
*
|
|
|
|
* Strawberry is free software: you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation, either version 3 of the License, or
|
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
|
|
|
* Strawberry is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with Strawberry. If not, see <http://www.gnu.org/licenses/>.
|
2018-08-09 18:39:44 +02:00
|
|
|
*
|
2018-02-27 18:06:05 +01:00
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef PLAYLISTCONTAINER_H
|
|
|
|
#define PLAYLISTCONTAINER_H
|
|
|
|
|
|
|
|
#include "config.h"
|
|
|
|
|
2018-05-01 00:41:33 +02:00
|
|
|
#include <QObject>
|
2018-02-27 18:06:05 +01:00
|
|
|
#include <QWidget>
|
2018-05-01 00:41:33 +02:00
|
|
|
#include <QString>
|
|
|
|
#include <QIcon>
|
2018-02-27 18:06:05 +01:00
|
|
|
#include <QSettings>
|
|
|
|
|
2020-02-08 15:03:11 +01:00
|
|
|
class QTimer;
|
|
|
|
class QTimeLine;
|
|
|
|
class QLabel;
|
|
|
|
class QAction;
|
|
|
|
class QEvent;
|
2018-05-01 00:41:33 +02:00
|
|
|
class QKeyEvent;
|
|
|
|
class QResizeEvent;
|
2018-02-27 18:06:05 +01:00
|
|
|
|
|
|
|
class Playlist;
|
|
|
|
class PlaylistManager;
|
|
|
|
class PlaylistView;
|
|
|
|
|
2018-05-01 00:41:33 +02:00
|
|
|
class Ui_PlaylistContainer;
|
2018-02-27 18:06:05 +01:00
|
|
|
|
|
|
|
class PlaylistContainer : public QWidget {
|
|
|
|
Q_OBJECT
|
|
|
|
|
|
|
|
public:
|
2020-04-07 16:49:15 +02:00
|
|
|
explicit PlaylistContainer(QWidget *parent = nullptr);
|
2020-06-15 21:55:05 +02:00
|
|
|
~PlaylistContainer() override;
|
2018-02-27 18:06:05 +01:00
|
|
|
|
|
|
|
static const char *kSettingsGroup;
|
|
|
|
|
2022-07-20 01:09:00 +02:00
|
|
|
void SetActions(QAction *new_playlist, QAction *load_playlist, QAction *save_playlist, QAction *clear_playlist, QAction *next_playlist, QAction *previous_playlist, QAction *save_all_playlists);
|
2018-02-27 18:06:05 +01:00
|
|
|
void SetManager(PlaylistManager *manager);
|
2020-01-04 06:38:25 +01:00
|
|
|
void ReloadSettings();
|
2018-02-27 18:06:05 +01:00
|
|
|
|
2021-09-27 21:42:30 +02:00
|
|
|
bool SearchFieldHasFocus() const;
|
|
|
|
void FocusSearchField();
|
|
|
|
|
2018-02-27 18:06:05 +01:00
|
|
|
PlaylistView *view() const;
|
|
|
|
|
2020-06-15 21:55:05 +02:00
|
|
|
bool eventFilter(QObject *objectWatched, QEvent *event) override;
|
2018-02-27 18:06:05 +01:00
|
|
|
|
2020-06-15 21:55:05 +02:00
|
|
|
signals:
|
2018-02-27 18:06:05 +01:00
|
|
|
void TabChanged(int id);
|
2021-01-26 16:48:04 +01:00
|
|
|
void Rename(int id, QString new_name);
|
2018-02-27 18:06:05 +01:00
|
|
|
|
|
|
|
void UndoRedoActionsChanged(QAction *undo, QAction *redo);
|
|
|
|
void ViewSelectionModelChanged();
|
|
|
|
|
|
|
|
protected:
|
|
|
|
// QWidget
|
2020-06-15 21:55:05 +02:00
|
|
|
void resizeEvent(QResizeEvent*) override;
|
2018-02-27 18:06:05 +01:00
|
|
|
|
|
|
|
private slots:
|
|
|
|
void NewPlaylist();
|
|
|
|
void LoadPlaylist();
|
2021-01-26 16:48:04 +01:00
|
|
|
void SaveCurrentPlaylist() { SavePlaylist(-1); }
|
|
|
|
void SavePlaylist(const int id);
|
2018-02-27 18:06:05 +01:00
|
|
|
void ClearPlaylist();
|
|
|
|
void GoToNextPlaylistTab();
|
|
|
|
void GoToPreviousPlaylistTab();
|
|
|
|
|
2020-08-09 14:00:56 +02:00
|
|
|
void SetViewModel(Playlist *playlist, const int scroll_position);
|
2021-01-26 16:48:04 +01:00
|
|
|
void PlaylistAdded(const int id, const QString &name, bool favorite);
|
|
|
|
void PlaylistClosed(const int id);
|
|
|
|
void PlaylistRenamed(const int id, const QString &new_name);
|
2018-02-27 18:06:05 +01:00
|
|
|
|
|
|
|
void Started();
|
|
|
|
|
|
|
|
void Save();
|
|
|
|
|
2021-01-26 16:48:04 +01:00
|
|
|
void SetTabBarVisible(const bool visible);
|
|
|
|
void SetTabBarHeight(const int height);
|
2018-02-27 18:06:05 +01:00
|
|
|
|
|
|
|
void SelectionChanged();
|
|
|
|
void MaybeUpdateFilter();
|
|
|
|
void UpdateFilter();
|
|
|
|
void FocusOnFilter(QKeyEvent *event);
|
|
|
|
|
|
|
|
void UpdateNoMatchesLabel();
|
|
|
|
|
2021-01-26 16:48:04 +01:00
|
|
|
public slots:
|
|
|
|
void ActivePlaying();
|
|
|
|
void ActivePaused();
|
|
|
|
void ActiveStopped();
|
|
|
|
|
2018-02-27 18:06:05 +01:00
|
|
|
private:
|
|
|
|
void UpdateActiveIcon(const QIcon &icon);
|
|
|
|
void RepositionNoMatchesLabel(bool force = false);
|
|
|
|
|
|
|
|
private:
|
|
|
|
static const int kFilterDelayMs;
|
|
|
|
static const int kFilterDelayPlaylistSizeThreshold;
|
|
|
|
|
|
|
|
Ui_PlaylistContainer *ui_;
|
|
|
|
|
|
|
|
PlaylistManager *manager_;
|
|
|
|
QAction *undo_;
|
|
|
|
QAction *redo_;
|
|
|
|
Playlist *playlist_;
|
|
|
|
|
|
|
|
QSettings settings_;
|
|
|
|
bool starting_up_;
|
|
|
|
|
|
|
|
bool tab_bar_visible_;
|
|
|
|
QTimeLine *tab_bar_animation_;
|
|
|
|
|
|
|
|
QLabel *no_matches_label_;
|
|
|
|
|
|
|
|
QTimer *filter_timer_;
|
|
|
|
};
|
|
|
|
|
|
|
|
#endif // PLAYLISTCONTAINER_H
|