1 | /* smplayer, GUI front-end for mplayer.
|
---|
2 | Copyright (C) 2006-2016 Ricardo Villalba <rvm@users.sourceforge.net>
|
---|
3 |
|
---|
4 | This program is free software; you can redistribute it and/or modify
|
---|
5 | it under the terms of the GNU General Public License as published by
|
---|
6 | the Free Software Foundation; either version 2 of the License, or
|
---|
7 | (at your option) any later version.
|
---|
8 |
|
---|
9 | This program is distributed in the hope that it will be useful,
|
---|
10 | but WITHOUT ANY WARRANTY; without even the implied warranty of
|
---|
11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
---|
12 | GNU General Public License for more details.
|
---|
13 |
|
---|
14 | You should have received a copy of the GNU General Public License
|
---|
15 | along with this program; if not, write to the Free Software
|
---|
16 | Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
---|
17 | */
|
---|
18 |
|
---|
19 | #ifndef FAVORITES_H
|
---|
20 | #define FAVORITES_H
|
---|
21 |
|
---|
22 | #include <QMenu>
|
---|
23 | #include <QString>
|
---|
24 | #include <QList>
|
---|
25 |
|
---|
26 | class QAction;
|
---|
27 | class QWidget;
|
---|
28 |
|
---|
29 | class Favorite
|
---|
30 | {
|
---|
31 | public:
|
---|
32 | Favorite() { is_subentry = false; }
|
---|
33 | Favorite(QString name, QString file, QString icon = QString::null, bool subentry = false)
|
---|
34 | {
|
---|
35 | _name = name; _file = file; _icon = icon; is_subentry = subentry;
|
---|
36 | };
|
---|
37 | virtual ~Favorite() {};
|
---|
38 |
|
---|
39 | void setName(QString name) { _name = name; };
|
---|
40 | void setFile(QString file) { _file = file; };
|
---|
41 | void setIcon(QString file) {
|
---|
42 | // Fix wrong icon
|
---|
43 | if (file == ":/icons-png/openfolder.png" ||
|
---|
44 | file == ":/default-theme/openfolder.png.png")
|
---|
45 | {
|
---|
46 | file = ":/default-theme/openfolder.png";
|
---|
47 | }
|
---|
48 | _icon = file;
|
---|
49 | };
|
---|
50 | void setSubentry(bool b) { is_subentry = b; }
|
---|
51 |
|
---|
52 | QString name() { return _name; };
|
---|
53 | QString file() { return _file; }
|
---|
54 | QString icon() { return _icon; };
|
---|
55 | bool isSubentry() { return is_subentry; };
|
---|
56 |
|
---|
57 | protected:
|
---|
58 | QString _name, _file, _icon;
|
---|
59 | bool is_subentry; // Not a favorite file, but a new favorite list
|
---|
60 | };
|
---|
61 |
|
---|
62 | typedef QList<Favorite> FavoriteList;
|
---|
63 |
|
---|
64 | class Favorites : public QMenu
|
---|
65 | {
|
---|
66 | Q_OBJECT
|
---|
67 | public:
|
---|
68 | Favorites(QString filename, QWidget * parent = 0);
|
---|
69 | ~Favorites();
|
---|
70 |
|
---|
71 | QAction * editAct() { return edit_act; };
|
---|
72 | QAction * jumpAct() { return jump_act; };
|
---|
73 | QAction * nextAct() { return next_act; };
|
---|
74 | QAction * previousAct() { return previous_act; };
|
---|
75 | QAction * addCurrentAct() { return add_current_act; };
|
---|
76 |
|
---|
77 | public slots:
|
---|
78 | void next();
|
---|
79 | void previous();
|
---|
80 |
|
---|
81 | void getCurrentMedia(const QString & filename, const QString & title);
|
---|
82 |
|
---|
83 | signals:
|
---|
84 | void activated(QString filemane);
|
---|
85 | //! Signal to resend the data to child
|
---|
86 | void sendCurrentMedia(const QString & filename, const QString & title);
|
---|
87 |
|
---|
88 | protected:
|
---|
89 | virtual void save();
|
---|
90 | virtual void load();
|
---|
91 | virtual void updateMenu();
|
---|
92 | virtual void populateMenu();
|
---|
93 | virtual Favorites * createNewObject(QString filename, QWidget * parent);
|
---|
94 | void delete_children();
|
---|
95 |
|
---|
96 | int findFile(QString filename);
|
---|
97 |
|
---|
98 | // Mark current action in the menu
|
---|
99 | void markCurrent();
|
---|
100 | bool anyItemAvailable();
|
---|
101 |
|
---|
102 | protected slots:
|
---|
103 | void triggered_slot(QAction * action);
|
---|
104 | virtual void edit();
|
---|
105 | virtual void jump();
|
---|
106 | virtual void addCurrentPlaying(); // Adds to menu current (or last played) file
|
---|
107 |
|
---|
108 | protected:
|
---|
109 | virtual void retranslateStrings();
|
---|
110 | virtual void changeEvent(QEvent * event);
|
---|
111 |
|
---|
112 | protected:
|
---|
113 | FavoriteList f_list;
|
---|
114 | QString _filename;
|
---|
115 | QAction * edit_act;
|
---|
116 | QAction * jump_act;
|
---|
117 | QAction * next_act;
|
---|
118 | QAction * previous_act;
|
---|
119 | QAction * add_current_act;
|
---|
120 |
|
---|
121 | QWidget * parent_widget;
|
---|
122 |
|
---|
123 | // Current (or last) file clicked
|
---|
124 | QString current_file;
|
---|
125 |
|
---|
126 | // Last item selected in the jump dialog
|
---|
127 | int last_item;
|
---|
128 |
|
---|
129 | QString received_file_playing;
|
---|
130 | QString received_title;
|
---|
131 |
|
---|
132 | QList<Favorites*> child;
|
---|
133 | };
|
---|
134 |
|
---|
135 | #endif
|
---|
136 |
|
---|