| 1 | /* smplayer, GUI front-end for mplayer.
|
|---|
| 2 | Copyright (C) 2006-2010 Ricardo Villalba <rvm@escomposlinux.org>
|
|---|
| 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 <QObject>
|
|---|
| 23 | #include <QString>
|
|---|
| 24 | #include <QList>
|
|---|
| 25 |
|
|---|
| 26 | class QMenu;
|
|---|
| 27 | class QAction;
|
|---|
| 28 | class QWidget;
|
|---|
| 29 |
|
|---|
| 30 | class Favorite
|
|---|
| 31 | {
|
|---|
| 32 | public:
|
|---|
| 33 | Favorite() {}
|
|---|
| 34 | Favorite(QString name, QString file, QString icon = QString::null) { _name = name; _file = file; _icon = icon; };
|
|---|
| 35 | virtual ~Favorite() {};
|
|---|
| 36 |
|
|---|
| 37 | void setName(QString name) { _name = name; };
|
|---|
| 38 | void setFile(QString file) { _file = file; };
|
|---|
| 39 | void setIcon(QString file) { _icon = file; };
|
|---|
| 40 |
|
|---|
| 41 | QString name() { return _name; };
|
|---|
| 42 | QString file() { return _file; }
|
|---|
| 43 | QString icon() { return _icon; };
|
|---|
| 44 |
|
|---|
| 45 | protected:
|
|---|
| 46 | QString _name, _file, _icon;
|
|---|
| 47 | };
|
|---|
| 48 |
|
|---|
| 49 | typedef QList<Favorite> FavoriteList;
|
|---|
| 50 |
|
|---|
| 51 | class Favorites : public QObject
|
|---|
| 52 | {
|
|---|
| 53 | Q_OBJECT
|
|---|
| 54 | public:
|
|---|
| 55 | Favorites(QString filename, QWidget * parent = 0);
|
|---|
| 56 | ~Favorites();
|
|---|
| 57 |
|
|---|
| 58 | QMenu * menu();
|
|---|
| 59 | QAction * editAct() { return edit_act; };
|
|---|
| 60 | QAction * jumpAct() { return jump_act; };
|
|---|
| 61 | QAction * nextAct() { return next_act; };
|
|---|
| 62 | QAction * previousAct() { return previous_act; };
|
|---|
| 63 |
|
|---|
| 64 | public slots:
|
|---|
| 65 | void next();
|
|---|
| 66 | void previous();
|
|---|
| 67 |
|
|---|
| 68 | signals:
|
|---|
| 69 | void activated(QString filemane);
|
|---|
| 70 |
|
|---|
| 71 | protected:
|
|---|
| 72 | void save();
|
|---|
| 73 | void load();
|
|---|
| 74 | void createMenu();
|
|---|
| 75 | void updateMenu();
|
|---|
| 76 | void populateMenu();
|
|---|
| 77 |
|
|---|
| 78 | int findFile(QString filename);
|
|---|
| 79 |
|
|---|
| 80 | // Mark current action in the menu
|
|---|
| 81 | void markCurrent();
|
|---|
| 82 |
|
|---|
| 83 | protected slots:
|
|---|
| 84 | void triggered_slot(QAction * action);
|
|---|
| 85 | virtual void edit();
|
|---|
| 86 | virtual void jump();
|
|---|
| 87 |
|
|---|
| 88 | protected:
|
|---|
| 89 | FavoriteList f_list;
|
|---|
| 90 | QString _filename;
|
|---|
| 91 | QMenu * _menu;
|
|---|
| 92 | QAction * edit_act;
|
|---|
| 93 | QAction * jump_act;
|
|---|
| 94 | QAction * next_act;
|
|---|
| 95 | QAction * previous_act;
|
|---|
| 96 |
|
|---|
| 97 | QWidget * parent_widget;
|
|---|
| 98 |
|
|---|
| 99 | // Current (or last) file clicked
|
|---|
| 100 | QString current_file;
|
|---|
| 101 |
|
|---|
| 102 | // Last item selected in the jump dialog
|
|---|
| 103 | int last_item;
|
|---|
| 104 | };
|
|---|
| 105 |
|
|---|
| 106 | #endif
|
|---|
| 107 |
|
|---|