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 2020-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 PLAYLISTTABBAR_H
|
|
|
|
#define PLAYLISTTABBAR_H
|
|
|
|
|
|
|
|
#include "config.h"
|
|
|
|
|
2018-05-01 00:41:33 +02:00
|
|
|
#include <QObject>
|
2018-02-27 18:06:05 +01:00
|
|
|
#include <QBasicTimer>
|
2018-05-01 00:41:33 +02:00
|
|
|
#include <QList>
|
|
|
|
#include <QString>
|
2018-02-27 18:06:05 +01:00
|
|
|
#include <QIcon>
|
|
|
|
#include <QTabBar>
|
2018-05-01 00:41:33 +02:00
|
|
|
|
2020-02-08 15:03:11 +01:00
|
|
|
class QWidget;
|
|
|
|
class QMenu;
|
|
|
|
class QAction;
|
2018-05-01 00:41:33 +02:00
|
|
|
class QEvent;
|
|
|
|
class QContextMenuEvent;
|
|
|
|
class QDragEnterEvent;
|
|
|
|
class QDragLeaveEvent;
|
|
|
|
class QDragMoveEvent;
|
|
|
|
class QDropEvent;
|
|
|
|
class QMouseEvent;
|
|
|
|
class QTimerEvent;
|
2018-02-27 18:06:05 +01:00
|
|
|
|
|
|
|
class PlaylistManager;
|
|
|
|
class RenameTabLineEdit;
|
|
|
|
|
|
|
|
class PlaylistTabBar : public QTabBar {
|
|
|
|
Q_OBJECT
|
|
|
|
|
|
|
|
public:
|
2020-04-07 16:49:15 +02:00
|
|
|
explicit PlaylistTabBar(QWidget *parent = nullptr);
|
2018-02-27 18:06:05 +01:00
|
|
|
|
|
|
|
static const int kDragHoverTimeout = 500;
|
|
|
|
static const char *kSettingsGroup;
|
|
|
|
|
|
|
|
void SetActions(QAction *new_playlist, QAction *load_playlist);
|
|
|
|
void SetManager(PlaylistManager *manager);
|
|
|
|
|
|
|
|
// We use IDs to refer to tabs so the tabs can be moved around (and their indexes change).
|
2021-01-26 16:48:04 +01:00
|
|
|
int index_of(const int id) const;
|
2018-02-27 18:06:05 +01:00
|
|
|
int current_id() const;
|
|
|
|
int id_of(int index) const;
|
|
|
|
|
|
|
|
// Utility functions that use IDs rather than indexes
|
2021-01-26 16:48:04 +01:00
|
|
|
void set_current_id(const int id);
|
|
|
|
void set_icon_by_id(const int id, const QIcon &icon);
|
|
|
|
void set_text_by_id(const int id, const QString &text);
|
2018-02-27 18:06:05 +01:00
|
|
|
|
2021-01-26 16:48:04 +01:00
|
|
|
void RemoveTab(const int id);
|
|
|
|
void InsertTab(const int id, const int index, const QString &text, const bool favorite);
|
2018-02-27 18:06:05 +01:00
|
|
|
|
2020-04-07 16:49:15 +02:00
|
|
|
signals:
|
2018-02-27 18:06:05 +01:00
|
|
|
void CurrentIdChanged(int id);
|
2021-01-26 16:48:04 +01:00
|
|
|
void Rename(int id, QString name);
|
2018-02-27 18:06:05 +01:00
|
|
|
void Close(int id);
|
|
|
|
void Save(int id);
|
2021-01-26 16:48:04 +01:00
|
|
|
void PlaylistOrderChanged(QList<int> ids);
|
2018-02-27 18:06:05 +01:00
|
|
|
void PlaylistFavorited(int id, bool favorite);
|
|
|
|
|
2020-04-07 16:49:15 +02:00
|
|
|
protected:
|
2020-06-15 21:55:05 +02:00
|
|
|
void contextMenuEvent(QContextMenuEvent *e) override;
|
|
|
|
void mouseReleaseEvent(QMouseEvent *e) override;
|
|
|
|
void mouseDoubleClickEvent(QMouseEvent *e) override;
|
|
|
|
void dragEnterEvent(QDragEnterEvent *e) override;
|
|
|
|
void dragMoveEvent(QDragMoveEvent *e) override;
|
|
|
|
void dragLeaveEvent(QDragLeaveEvent *e) override;
|
|
|
|
void dropEvent(QDropEvent *e) override;
|
|
|
|
void timerEvent(QTimerEvent *e) override;
|
|
|
|
bool event(QEvent *e) override;
|
2018-02-27 18:06:05 +01:00
|
|
|
|
2020-04-07 16:49:15 +02:00
|
|
|
private slots:
|
2021-01-26 16:48:04 +01:00
|
|
|
void CurrentIndexChanged(const int index);
|
|
|
|
void RenameSlot();
|
2018-02-27 18:06:05 +01:00
|
|
|
void RenameInline();
|
|
|
|
void HideEditor();
|
2021-01-26 16:48:04 +01:00
|
|
|
void CloseSlot();
|
|
|
|
void CloseFromTabIndex(const int index);
|
2018-02-27 18:06:05 +01:00
|
|
|
// Used when playlist's favorite flag isn't changed from the favorite widget (e.g. from the playlistlistcontainer): will update the favorite widget
|
2021-01-26 16:48:04 +01:00
|
|
|
void PlaylistFavoritedSlot(const int id, const bool favorite);
|
2018-02-27 18:06:05 +01:00
|
|
|
// Used to signal that the playlist manager is done starting up
|
|
|
|
void PlaylistManagerInitialized();
|
|
|
|
void TabMoved();
|
2021-01-26 16:48:04 +01:00
|
|
|
void SaveSlot();
|
2018-02-27 18:06:05 +01:00
|
|
|
|
2020-04-07 16:49:15 +02:00
|
|
|
private:
|
2018-02-27 18:06:05 +01:00
|
|
|
PlaylistManager *manager_;
|
|
|
|
|
|
|
|
QMenu *menu_;
|
|
|
|
int menu_index_;
|
|
|
|
QAction *new_;
|
|
|
|
QAction *rename_;
|
|
|
|
QAction *close_;
|
|
|
|
QAction *save_;
|
|
|
|
|
|
|
|
QBasicTimer drag_hover_timer_;
|
|
|
|
int drag_hover_tab_;
|
|
|
|
|
|
|
|
bool suppress_current_changed_;
|
|
|
|
bool initialized_;
|
|
|
|
|
|
|
|
// Editor for inline renaming
|
|
|
|
RenameTabLineEdit *rename_editor_;
|
|
|
|
};
|
|
|
|
|
|
|
|
#endif // PLAYLISTTABBAR_H
|