1 | /* smplayer, GUI front-end for mplayer.
|
---|
2 | Copyright (C) 2006-2013 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) { _icon = file; };
|
---|
42 | void setSubentry(bool b) { is_subentry = b; }
|
---|
43 |
|
---|
44 | QString name() { return _name; };
|
---|
45 | QString file() { return _file; }
|
---|
46 | QString icon() { return _icon; };
|
---|
47 | bool isSubentry() { return is_subentry; };
|
---|
48 |
|
---|
49 | protected:
|
---|
50 | QString _name, _file, _icon;
|
---|
51 | bool is_subentry; // Not a favorite file, but a new favorite list
|
---|
52 | };
|
---|
53 |
|
---|
54 | typedef QList<Favorite> FavoriteList;
|
---|
55 |
|
---|
56 | class Favorites : public QMenu
|
---|
57 | {
|
---|
58 | Q_OBJECT
|
---|
59 | public:
|
---|
60 | Favorites(QString filename, QWidget * parent = 0);
|
---|
61 | ~Favorites();
|
---|
62 |
|
---|
63 | QAction * editAct() { return edit_act; };
|
---|
64 | QAction * jumpAct() { return jump_act; };
|
---|
65 | QAction * nextAct() { return next_act; };
|
---|
66 | QAction * previousAct() { return previous_act; };
|
---|
67 | QAction * addCurrentAct() { return add_current_act; };
|
---|
68 |
|
---|
69 | public slots:
|
---|
70 | void next();
|
---|
71 | void previous();
|
---|
72 |
|
---|
73 | void getCurrentMedia(const QString & filename, const QString & title);
|
---|
74 |
|
---|
75 | signals:
|
---|
76 | void activated(QString filemane);
|
---|
77 | //! Signal to resend the data to child
|
---|
78 | void sendCurrentMedia(const QString & filename, const QString & title);
|
---|
79 |
|
---|
80 | protected:
|
---|
81 | virtual void save();
|
---|
82 | virtual void load();
|
---|
83 | virtual void updateMenu();
|
---|
84 | virtual void populateMenu();
|
---|
85 | virtual Favorites * createNewObject(QString filename, QWidget * parent);
|
---|
86 | void delete_children();
|
---|
87 |
|
---|
88 | int findFile(QString filename);
|
---|
89 |
|
---|
90 | // Mark current action in the menu
|
---|
91 | void markCurrent();
|
---|
92 | bool anyItemAvailable();
|
---|
93 |
|
---|
94 | protected slots:
|
---|
95 | void triggered_slot(QAction * action);
|
---|
96 | virtual void edit();
|
---|
97 | virtual void jump();
|
---|
98 | virtual void addCurrentPlaying(); // Adds to menu current (or last played) file
|
---|
99 |
|
---|
100 | protected:
|
---|
101 | virtual void retranslateStrings();
|
---|
102 | virtual void changeEvent(QEvent * event);
|
---|
103 |
|
---|
104 | protected:
|
---|
105 | FavoriteList f_list;
|
---|
106 | QString _filename;
|
---|
107 | QAction * edit_act;
|
---|
108 | QAction * jump_act;
|
---|
109 | QAction * next_act;
|
---|
110 | QAction * previous_act;
|
---|
111 | QAction * add_current_act;
|
---|
112 |
|
---|
113 | QWidget * parent_widget;
|
---|
114 |
|
---|
115 | // Current (or last) file clicked
|
---|
116 | QString current_file;
|
---|
117 |
|
---|
118 | // Last item selected in the jump dialog
|
---|
119 | int last_item;
|
---|
120 |
|
---|
121 | QString received_file_playing;
|
---|
122 | QString received_title;
|
---|
123 |
|
---|
124 | QList<Favorites*> child;
|
---|
125 | };
|
---|
126 |
|
---|
127 | #endif
|
---|
128 |
|
---|