| 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 | /* This is based on qq14-actioneditor-code.zip from Qt */
|
|---|
| 20 |
|
|---|
| 21 | #ifndef _ACTIONSEDITOR_H_
|
|---|
| 22 | #define _ACTIONSEDITOR_H_
|
|---|
| 23 |
|
|---|
| 24 | #include <QWidget>
|
|---|
| 25 | #include <QList>
|
|---|
| 26 | #include <QStringList>
|
|---|
| 27 | #include "guiconfig.h"
|
|---|
| 28 |
|
|---|
| 29 | class QTableWidget;
|
|---|
| 30 | class QTableWidgetItem;
|
|---|
| 31 | class QAction;
|
|---|
| 32 | class QSettings;
|
|---|
| 33 | class QPushButton;
|
|---|
| 34 |
|
|---|
| 35 | class ActionsEditor : public QWidget
|
|---|
| 36 | {
|
|---|
| 37 | Q_OBJECT
|
|---|
| 38 |
|
|---|
| 39 | public:
|
|---|
| 40 | ActionsEditor( QWidget * parent = 0, Qt::WindowFlags f = 0 );
|
|---|
| 41 | ~ActionsEditor();
|
|---|
| 42 |
|
|---|
| 43 | // Clear the actionlist
|
|---|
| 44 | void clear();
|
|---|
| 45 |
|
|---|
| 46 | // There are no actions yet?
|
|---|
| 47 | bool isEmpty();
|
|---|
| 48 |
|
|---|
| 49 | void addActions(QWidget * widget);
|
|---|
| 50 |
|
|---|
| 51 | // Static functions
|
|---|
| 52 | static QAction * findAction(QObject *o, const QString & name);
|
|---|
| 53 | static QStringList actionsNames(QObject *o);
|
|---|
| 54 |
|
|---|
| 55 | static void saveToConfig(QObject *o, QSettings *set);
|
|---|
| 56 | static void loadFromConfig(QObject *o, QSettings *set);
|
|---|
| 57 |
|
|---|
| 58 | #if USE_MULTIPLE_SHORTCUTS
|
|---|
| 59 | static QString shortcutsToString(QList <QKeySequence> shortcuts_list);
|
|---|
| 60 | static QList <QKeySequence> stringToShortcuts(QString shortcuts);
|
|---|
| 61 | #endif
|
|---|
| 62 |
|
|---|
| 63 | public slots:
|
|---|
| 64 | void applyChanges();
|
|---|
| 65 | void saveActionsTable();
|
|---|
| 66 | bool saveActionsTable(const QString & filename);
|
|---|
| 67 | void loadActionsTable();
|
|---|
| 68 | bool loadActionsTable(const QString & filename);
|
|---|
| 69 |
|
|---|
| 70 | void updateView();
|
|---|
| 71 |
|
|---|
| 72 | protected:
|
|---|
| 73 | virtual void retranslateStrings();
|
|---|
| 74 | virtual void changeEvent ( QEvent * event ) ;
|
|---|
| 75 |
|
|---|
| 76 | // Find in table, not in actionslist
|
|---|
| 77 | int findActionName(const QString & name);
|
|---|
| 78 | int findActionAccel(const QString & accel, int ignoreRow = -1);
|
|---|
| 79 | bool hasConflicts();
|
|---|
| 80 |
|
|---|
| 81 | protected slots:
|
|---|
| 82 | #if !USE_SHORTCUTGETTER
|
|---|
| 83 | void recordAction(QTableWidgetItem*);
|
|---|
| 84 | void validateAction(QTableWidgetItem*);
|
|---|
| 85 | #else
|
|---|
| 86 | void editShortcut();
|
|---|
| 87 | #endif
|
|---|
| 88 |
|
|---|
| 89 | private:
|
|---|
| 90 | QTableWidget *actionsTable;
|
|---|
| 91 | QList<QAction*> actionsList;
|
|---|
| 92 | QPushButton *saveButton;
|
|---|
| 93 | QPushButton *loadButton;
|
|---|
| 94 | QString latest_dir;
|
|---|
| 95 |
|
|---|
| 96 | #if USE_SHORTCUTGETTER
|
|---|
| 97 | QPushButton *editButton;
|
|---|
| 98 | #else
|
|---|
| 99 | QString oldAccelText;
|
|---|
| 100 | bool dont_validate;
|
|---|
| 101 | #endif
|
|---|
| 102 | };
|
|---|
| 103 |
|
|---|
| 104 | #endif
|
|---|