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 
49  void sig_open_file(int tab_idx);
50  void sig_open_dir(int tab_idx);
51 
52  void sig_tab_reset(int tab_idx);
53  void sig_tab_save(int tab_idx);
54  void sig_tab_save_as(int tab_idx, const QString& name);
55  void sig_tab_rename(int tab_idx, const QString& name);
56  void sig_tab_clear(int tab_idx);
57 
58  void sig_tab_delete(int tab_idx);
59  void sig_cur_idx_changed(int tab_idx);
60  void sig_add_tab_clicked();
61  void sig_metadata_dropped(int tab_idx, const MetaDataList& v_md);
62 
63 
64 public:
65  PlaylistTabBar(QWidget *parent=nullptr);
66 
67  virtual ~PlaylistTabBar();
68 
69  void show_menu_items(PlaylistMenuEntries entries);
70  void setTabsClosable(bool b);
71 
72  bool was_drag_from_playlist() const;
73  int get_drag_origin_tab() const;
74 
75  QString get_shortcut_text(const QString &shortcut_identifier) const override;
76 
77 
78 private:
79  PlaylistTabMenu* _menu=nullptr;
80  int _tab_before_dd;
81  bool _drag_from_playlist;
82  int _drag_origin_tab;
83 
84 
85 private:
86  void mousePressEvent(QMouseEvent* e) override;
87  void wheelEvent(QWheelEvent* e) override;
88  void dragEnterEvent(QDragEnterEvent* e) override;
89  void dragMoveEvent(QDragMoveEvent* e) override;
90  void dragLeaveEvent(QDragLeaveEvent* e) override;
91  void dropEvent(QDropEvent* e) override;
92 
93  void init_shortcuts();
94 
95 private slots:
96  void open_file_pressed();
97  void open_dir_pressed();
98  void reset_pressed();
99  void save_pressed();
100  void save_as_pressed();
101  void clear_pressed();
102  void delete_pressed();
103  void close_pressed();
104  void close_others_pressed();
105  void rename_pressed();
106 
107 };
108 
109 #endif // PLAYLISTTABBAR_H
Definition: PlaylistTabBar.h:39
Definition: MetaDataList.h:44
Definition: PlaylistTabMenu.h:33
Interface that should be implemented when using configurable shortcuts.
Definition: ShortcutWidget.h:33