1 /*
2 For general Scribus (>=1.3.2) copyright and licensing information please refer
3 to the COPYING file provided with the program. Following this notice may exist
4 a copyright and/or license notice that predates the release of Scribus 1.3.2
5 for which a new license (GPL+exception) is in place.
6 */
7 
8 #ifndef PREFS_KEYBOARDSHORTCUTS_H
9 #define PREFS_KEYBOARDSHORTCUTS_H
10 
11 #include <QMap>
12 #include <QPair>
13 #include <QString>
14 #include <QStringList>
15 #include <QKeyEvent>
16 #include <QEvent>
17 
18 #include "ui_prefs_keyboardshortcutsbase.h"
19 #include "prefs_pane.h"
20 #include "scribusapi.h"
21 #include "scribusstructs.h"
22 
23 
24 class SCRIBUS_API Prefs_KeyboardShortcuts : public Prefs_Pane, Ui::Prefs_KeyboardShortcuts
25 {
26 	Q_OBJECT
27 
28 	public:
29 		Prefs_KeyboardShortcuts(QWidget* parent, ScribusDoc* doc=nullptr);
30 		~Prefs_KeyboardShortcuts();
31 
32 		void restoreDefaults(struct ApplicationPrefs *prefsData) override;
33 		void saveGuiToPrefs(struct ApplicationPrefs *prefsData) const override;
34 
35 		bool event( QEvent* ev ) override;
36 		void keyPressEvent(QKeyEvent *k) override;
37 		void keyReleaseEvent(QKeyEvent *k) override;
38 
39 		static QString getKeyText(const QKeySequence& KeyC);
40 		static QString getTrKeyText(const QKeySequence& KeyC);
41 
42 	public slots:
43 		void languageChange();
44 
45 protected:
46 	QMap<QString,Keys> keyMap;
47 	QMap<QString,Keys>::Iterator currentKeyMapRow;
48 	QMap<QString, QString> keySetList;
49 	QMap<QTreeWidgetItem*, QString> lviToActionMap;
50 	QList<QTreeWidgetItem*> lviToMenuMap;
51 	QVector< QPair<QString, QStringList> >* defMenus;
52 	QVector< QPair<QString, QStringList> >* defNonMenuActions;
53 	QTreeWidgetItem * selectedLVI;
54 	int keyCode;
55 
56 	void insertActions();
57 	void importKeySet(const QString&);
58 	bool exportKeySet(const QString&);
59 	QStringList scanForSets();
60 	bool checkKey(int code);
61 	QString getAction(int code);
62 
63 protected slots:
64 	void setKeyText();
65 	void dispKey(QTreeWidgetItem* current, QTreeWidgetItem* previous=0);
66 	void setNoKey();
67 	void loadKeySetFile();
68 	void importKeySetFile();
69 	void exportKeySetFile();
70 	void resetKeySet();
71 	void clearSearchString();
72 	void applySearch( const QString & newss );
73 };
74 
75 #endif // PREFS_KEYBOARDSHORTCUTS_H
76