[112] | 1 | /* smplayer, GUI front-end for mplayer.
|
---|
[188] | 2 | Copyright (C) 2006-2017 Ricardo Villalba <rvm@users.sourceforge.net>
|
---|
[112] | 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 |
|
---|
[176] | 21 | #ifndef ACTIONSEDITOR_H
|
---|
| 22 | #define ACTIONSEDITOR_H
|
---|
[112] | 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();
|
---|
[176] | 80 | static bool containsShortcut(const QString & accel, const QString & shortcut);
|
---|
[112] | 81 |
|
---|
| 82 | protected slots:
|
---|
| 83 | #if !USE_SHORTCUTGETTER
|
---|
| 84 | void recordAction(QTableWidgetItem*);
|
---|
| 85 | void validateAction(QTableWidgetItem*);
|
---|
| 86 | #else
|
---|
| 87 | void editShortcut();
|
---|
| 88 | #endif
|
---|
| 89 |
|
---|
| 90 | private:
|
---|
| 91 | QTableWidget *actionsTable;
|
---|
| 92 | QList<QAction*> actionsList;
|
---|
| 93 | QPushButton *saveButton;
|
---|
| 94 | QPushButton *loadButton;
|
---|
| 95 | QString latest_dir;
|
---|
| 96 |
|
---|
| 97 | #if USE_SHORTCUTGETTER
|
---|
| 98 | QPushButton *editButton;
|
---|
| 99 | #else
|
---|
| 100 | QString oldAccelText;
|
---|
| 101 | bool dont_validate;
|
---|
| 102 | #endif
|
---|
| 103 | };
|
---|
| 104 |
|
---|
| 105 | #endif
|
---|