Canorus 0.0
actionseditor.h
Go to the documentation of this file.
1
14#ifndef _CAACTIONSEDITOR_H_
15#define _CAACTIONSEDITOR_H_
16
17#include <QDialog>
18#include <QList>
19#include <QStringList>
20#include "ui/singleaction.h"
21
22class QTableWidget;
23class QTableWidgetItem;
24class CASingleAction;
25class QSettings;
26class QLineEdit;
27class QPushButton;
28
29class CAActionsEditor : public QWidget
30{
31 Q_OBJECT
32
33public:
34
35 // Definition of file type
37 {
38 //FT_COMPLETE = 0, // All together like when stored in settings
39 FT_SHORTCUT = 1, // Keyboard shortcut
40 FT_MIDI = 2, // Midi command
41 FT_MIDISCUT = 3 // Requires Midi and Shortcut at one time to be used
42 };
43
44 // Constructor
45 // Parameters are standard QWidget parameters
46 CAActionsEditor( QWidget * parent = 0, Qt::WindowFlags f = 0 );
47 // Destructor
49
50 // Clear the actionlist
51 void clear();
52
53 // There are no actions yet?
54 bool isEmpty();
55
56 // See QWidget documentation
57 void addActions(const QList<CASingleAction *> &actionList);
58
59 // Static functions
60 static CASingleAction * findAction(QWidget *widget, const QString & name);
61 static QStringList actionsNames(QWidget *widget);
62
63 static void saveToConfig(QWidget *widget, QSettings *set);
64 static void loadFromConfig(QWidget *widget, QSettings *set);
65
66//#if USE_MULTIPLE_SHORTCUTS
67// static QString shortcutsToString(QList <QKeySequence> shortcuts_list);
68// static QList <QKeySequence> stringToShortcuts(QString shortcuts);
69//#endif
70
71public slots:
72 // save changes from editing (shortcut or midi command)
73 void applyChanges();
74 // Get file type from suffix
75 enum fileType getFType(const QString &suffix);
76 // save action profile (shortcuts or midi commands) separately to disc
77 void saveActionsTable();
78 bool saveActionsTable(const QString & filename, enum fileType type = FT_SHORTCUT);
79 // load action profile (shortcuts or midi commands) separately from disc
80 void loadActionsTable();
81 bool loadActionsTable(const QString & filename, enum fileType type = FT_SHORTCUT);
82
83 // Add all actions to the table widget
84 void updateView();
85
86protected:
87 // Translate strings dynamically
88 // Adapts save buttons according to column focus
89 virtual void retranslateStrings();
90 virtual void changeEvent ( QEvent * event ) ;
91
92 // Find in table, not in actionslist (command, shortcut or midi)
93 int findActionCommand(const QString & name);
94 int findActionAccel(const QString & accel, int ignoreRow = -1);
95 int findActionMidi(const QString & midi, int ignoreRow = -1);
96 // Check for Conflicts of shortcut or midi command
97 bool hasConflicts(bool bMidi = false);
98
99protected slots:
100//#if !USE_SHORTCUTGETTER
101 // Start recording (save current Text)
102 void recordAction(QTableWidgetItem*);
103 // Easy check of edited shortcut / midi command
104 void validateAction(QTableWidgetItem*);
105//#else
106 void editShortcut();
107//#endif
108
109private:
110 QTableWidget *actionsTable;
111 QList<CASingleAction *> m_actionsList;
112 QPushButton *saveButton;
113 QPushButton *loadButton;
114 QString latest_dir;
115
116//#if USE_SHORTCUTGETTER
117 QPushButton *editButton;
118//#else
120 QString oldMidiText;
121 bool dont_validate; // Lock validate during update
122//#endif
123};
124
126{
127 Q_OBJECT
128
129public:
130 ShortcutGetter(QWidget *parent = 0);
131
132 QString exec(const QString& s);
133
134protected slots:
135 void setCaptureKeyboard(bool b);
136
137protected:
138 bool captureKeyboard() { return capture; }
139
140 bool event(QEvent *e);
141 bool eventFilter(QObject *o, QEvent *e);
142 void setText();
143
144private:
145 bool bStop;
147 QStringList lKeys;
149};
150
151
152#endif
Definition: actionseditor.h:30
static void loadFromConfig(QWidget *widget, QSettings *set)
Definition: actionseditor.cpp:628
virtual void changeEvent(QEvent *event)
Definition: actionseditor.cpp:698
QString latest_dir
Definition: actionseditor.h:114
void clear()
Definition: actionseditor.cpp:186
void saveActionsTable()
Definition: actionseditor.cpp:441
QTableWidget * actionsTable
Definition: actionseditor.h:110
void loadActionsTable()
Definition: actionseditor.cpp:509
QPushButton * loadButton
Definition: actionseditor.h:113
void addActions(const QList< CASingleAction * > &actionList)
Definition: actionseditor.cpp:190
int findActionCommand(const QString &name)
Definition: actionseditor.cpp:382
static void saveToConfig(QWidget *widget, QSettings *set)
Definition: actionseditor.cpp:598
int findActionAccel(const QString &accel, int ignoreRow=-1)
Definition: actionseditor.cpp:389
void recordAction(QTableWidgetItem *)
Definition: actionseditor.cpp:315
bool dont_validate
Definition: actionseditor.h:121
QString oldMidiText
Definition: actionseditor.h:120
void validateAction(QTableWidgetItem *)
Definition: actionseditor.cpp:328
static QStringList actionsNames(QWidget *widget)
Definition: actionseditor.cpp:676
~CAActionsEditor()
Definition: actionseditor.cpp:162
void editShortcut()
Definition: actionseditor.cpp:368
static CASingleAction * findAction(QWidget *widget, const QString &name)
Definition: actionseditor.cpp:661
QString oldAccelText
Definition: actionseditor.h:119
bool isEmpty()
Definition: actionseditor.cpp:182
enum fileType getFType(const QString &suffix)
Definition: actionseditor.cpp:302
bool hasConflicts(bool bMidi=false)
Definition: actionseditor.cpp:413
void updateView()
Definition: actionseditor.cpp:209
QPushButton * saveButton
Definition: actionseditor.h:112
fileType
Definition: actionseditor.h:37
@ FT_SHORTCUT
Definition: actionseditor.h:39
@ FT_MIDISCUT
Definition: actionseditor.h:41
@ FT_MIDI
Definition: actionseditor.h:40
CAActionsEditor(QWidget *parent=0, Qt::WindowFlags f=0)
Definition: actionseditor.cpp:98
QPushButton * editButton
Definition: actionseditor.h:117
virtual void retranslateStrings()
Definition: actionseditor.cpp:165
int findActionMidi(const QString &midi, int ignoreRow=-1)
Definition: actionseditor.cpp:401
QList< CASingleAction * > m_actionsList
Definition: actionseditor.h:111
void applyChanges()
Definition: actionseditor.cpp:285
Definition: singleaction.h:19
Definition: actionseditor.h:126
bool event(QEvent *e)
Definition: actionseditor.cpp:799
QString exec(const QString &s)
Definition: actionseditor.cpp:788
void setText()
Definition: actionseditor.cpp:873
bool eventFilter(QObject *o, QEvent *e)
Definition: actionseditor.cpp:862
ShortcutGetter(QWidget *parent=0)
Definition: actionseditor.cpp:738
QLineEdit * leKey
Definition: actionseditor.h:146
bool capture
Definition: actionseditor.h:148
void setCaptureKeyboard(bool b)
Definition: actionseditor.cpp:781
bool bStop
Definition: actionseditor.h:145
QStringList lKeys
Definition: actionseditor.h:147
bool captureKeyboard()
Definition: actionseditor.h:138