Sayonara Player
PlaylistTabBar.h
1 /* PlaylistTabBar.h */
2 
3 /* Copyright (C) 2011-2016 Lucio Carreras
4  *
5  * This file is part of sayonara player
6  *
7  * This program is free software: you can redistribute it and/or modify
8  * it under the terms of the GNU General Public License as published by
9  * the Free Software Foundation, either version 3 of the License, or
10  * (at your option) any later version.
11 
12  * This program is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15  * GNU General Public License for more details.
16 
17  * You should have received a copy of the GNU General Public License
18  * along with this program. If not, see <http://www.gnu.org/licenses/>.
19  */
20 
21 
22 
23 #ifndef PLAYLISTTABBAR_H
24 #define PLAYLISTTABBAR_H
25 
26 #include "PlaylistMenuEntry.h"
27 #include "GUI/Helper/Shortcuts/ShortcutWidget.h"
28 
29 #include <QInputDialog>
30 #include <QTabBar>
31 #include <QMouseEvent>
32 #include <QWheelEvent>
33 
34 
35 
36 class PlaylistTabMenu;
37 class MetaDataList;
38 
40  public QTabBar,
41  public ShortcutWidget
42 {
43 
44  Q_OBJECT
45 
46 
47 signals:
48  void sig_tab_reset(int tab_idx);
49  void sig_tab_save(int tab_idx);
50  void sig_tab_save_as(int tab_idx, const QString& name);
51  void sig_tab_rename(int tab_idx, const QString& name);
52  void sig_tab_clear(int tab_idx);
53 
54  void sig_tab_delete(int tab_idx);
55  void sig_cur_idx_changed(int tab_idx);
56  void sig_add_tab_clicked();
57  void sig_metadata_dropped(int tab_idx, const MetaDataList& v_md);
58 
59 
60 public:
61  PlaylistTabBar(QWidget *parent=nullptr);
62 
63  virtual ~PlaylistTabBar();
64 
65  void show_menu_items(PlaylistMenuEntries entries);
66  void setTabsClosable(bool b);
67 
68  bool was_drag_from_playlist() const;
69  int get_drag_origin_tab() const;
70 
71  QString get_shortcut_text(const QString &shortcut_identifier) const override;
72 
73 
74 
75 private:
76  PlaylistTabMenu* _menu=nullptr;
77  int _tab_before_dd;
78  bool _drag_from_playlist;
79  int _drag_origin_tab;
80 
81 
82 
83 private:
84  void mousePressEvent(QMouseEvent* e) override;
85  void wheelEvent(QWheelEvent* e) override;
86  void dragEnterEvent(QDragEnterEvent* e) override;
87  void dragMoveEvent(QDragMoveEvent* e) override;
88  void dragLeaveEvent(QDragLeaveEvent* e) override;
89  void dropEvent(QDropEvent* e) override;
90 
91  void init_shortcuts();
92 
93 private slots:
94  void reset_pressed();
95  void save_pressed();
96  void save_as_pressed();
97  void clear_pressed();
98  void delete_pressed();
99  void close_pressed();
100  void close_others_pressed();
101  void rename_pressed();
102 
103 };
104 
105 #endif // PLAYLISTTABBAR_H
Definition: PlaylistTabBar.h:39
Definition: MetaDataList.h:46
Definition: PlaylistTabMenu.h:33
Interface that should be implemented when using configurable shortcuts.
Definition: ShortcutWidget.h:33