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 
22 class QTableWidget;
23 class QTableWidgetItem;
24 class CASingleAction;
25 class QSettings;
26 class QLineEdit;
27 class QPushButton;
28 
29 class CAActionsEditor : public QWidget
30 {
31  Q_OBJECT
32 
33 public:
34 
35  // Definition of file type
36  enum fileType
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 
71 public 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 
86 protected:
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 
99 protected 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 
109 private:
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
119  QString oldAccelText;
120  QString oldMidiText;
121  bool dont_validate; // Lock validate during update
122 //#endif
123 };
124 
125 class ShortcutGetter : public QDialog
126 {
127  Q_OBJECT
128 
129 public:
130  ShortcutGetter(QWidget *parent = 0);
131 
132  QString exec(const QString& s);
133 
134 protected slots:
135  void setCaptureKeyboard(bool b);
136 
137 protected:
138  bool captureKeyboard() { return capture; }
139 
140  bool event(QEvent *e);
141  bool eventFilter(QObject *o, QEvent *e);
142  void setText();
143 
144 private:
145  bool bStop;
147  QStringList lKeys;
148  bool capture;
149 };
150 
151 
152 #endif
CAActionsEditor::oldAccelText
QString oldAccelText
Definition: actionseditor.h:119
CAActionsEditor::FT_MIDI
@ FT_MIDI
Definition: actionseditor.h:40
CAActionsEditor::clear
void clear()
Definition: actionseditor.cpp:186
QObject
CAActionsEditor::saveActionsTable
void saveActionsTable()
Definition: actionseditor.cpp:441
CAActionsEditor::FT_SHORTCUT
@ FT_SHORTCUT
Definition: actionseditor.h:39
COL_COMMAND
@ COL_COMMAND
Definition: actionseditor.cpp:47
CAActionsEditor::editButton
QPushButton * editButton
Definition: actionseditor.h:117
CAActionsEditor::applyChanges
void applyChanges()
Definition: actionseditor.cpp:285
settings.h
COL_SHORTCUT
@ COL_SHORTCUT
Definition: actionseditor.cpp:49
CAActionsEditor::retranslateStrings
virtual void retranslateStrings()
Definition: actionseditor.cpp:165
ShortcutGetter::setCaptureKeyboard
void setCaptureKeyboard(bool b)
Definition: actionseditor.cpp:781
CACanorus::settings
static CASettings * settings()
Definition: canorus.h:65
CAActionsEditor::updateView
void updateView()
Definition: actionseditor.cpp:209
CAActionsEditor::actionsNames
static QStringList actionsNames(QWidget *widget)
Definition: actionseditor.cpp:676
QDialog
CASingleAction::getCommandName
QString getCommandName(bool ampersand=false)
Definition: singleaction.h:26
CAActionsEditor::dont_validate
bool dont_validate
Definition: actionseditor.h:121
CAActionsEditor::validateAction
void validateAction(QTableWidgetItem *)
Definition: actionseditor.cpp:328
ShortcutGetter::ShortcutGetter
ShortcutGetter(QWidget *parent=0)
Definition: actionseditor.cpp:738
QSettings
CAActionsEditor::editShortcut
void editShortcut()
Definition: actionseditor.cpp:368
COL_DESCRIPTION
@ COL_DESCRIPTION
Definition: actionseditor.cpp:48
CAActionsEditor::isEmpty
bool isEmpty()
Definition: actionseditor.cpp:182
CAActionsEditor::findActionAccel
int findActionAccel(const QString &accel, int ignoreRow=-1)
Definition: actionseditor.cpp:389
COL_NUM
#define COL_NUM
Definition: actionseditor.cpp:42
actionCol
actionCol
Definition: actionseditor.cpp:46
CAActionsEditor::getFType
enum fileType getFType(const QString &suffix)
Definition: actionseditor.cpp:302
CASingleAction::getShortCutAsString
QString getShortCutAsString()
Definition: singleaction.h:28
COL_MIDISCUT
@ COL_MIDISCUT
Definition: actionseditor.cpp:51
CASingleAction::getMidiKeySequence
QString getMidiKeySequence()
Definition: singleaction.h:29
CAActionsEditor::findActionMidi
int findActionMidi(const QString &midi, int ignoreRow=-1)
Definition: actionseditor.cpp:401
CAActionsEditor::oldMidiText
QString oldMidiText
Definition: actionseditor.h:120
ShortcutGetter::exec
QString exec(const QString &s)
Definition: actionseditor.cpp:788
CASingleAction
Definition: singleaction.h:19
CASingleAction::getAction
QAction * getAction()
Definition: singleaction.h:32
CAActionsEditor::addActions
void addActions(const QList< CASingleAction * > &actionList)
Definition: actionseditor.cpp:190
ShortcutGetter::capture
bool capture
Definition: actionseditor.h:148
actionseditor.h
ShortcutGetter::captureKeyboard
bool captureKeyboard()
Definition: actionseditor.h:138
keyToString
static QString keyToString(int k)
Definition: actionseditor.cpp:706
CAActionsEditor::findAction
static CASingleAction * findAction(QWidget *widget, const QString &name)
Definition: actionseditor.cpp:661
CAActionsEditor::loadFromConfig
static void loadFromConfig(QWidget *widget, QSettings *set)
Definition: actionseditor.cpp:628
COL_MIDI
@ COL_MIDI
Definition: actionseditor.cpp:50
ShortcutGetter::setText
void setText()
Definition: actionseditor.cpp:873
ShortcutGetter::bStop
bool bStop
Definition: actionseditor.h:145
ShortcutGetter::leKey
QLineEdit * leKey
Definition: actionseditor.h:146
CAActionsEditor
Definition: actionseditor.h:30
CAActionsEditor::~CAActionsEditor
~CAActionsEditor()
Definition: actionseditor.cpp:162
CAActionsEditor::actionsTable
QTableWidget * actionsTable
Definition: actionseditor.h:110
CAActionsEditor::changeEvent
virtual void changeEvent(QEvent *event)
Definition: actionseditor.cpp:698
CAActionsEditor::saveToConfig
static void saveToConfig(QWidget *widget, QSettings *set)
Definition: actionseditor.cpp:598
CAActionsEditor::CAActionsEditor
CAActionsEditor(QWidget *parent=0, Qt::WindowFlags f=0)
Definition: actionseditor.cpp:98
CASingleAction::setShortCutAsString
void setShortCutAsString(QString oShortCut)
Definition: singleaction.cpp:50
ShortcutGetter
Definition: actionseditor.h:126
CAActionsEditor::hasConflicts
bool hasConflicts(bool bMidi=false)
Definition: actionseditor.cpp:413
ShortcutGetter::eventFilter
bool eventFilter(QObject *o, QEvent *e)
Definition: actionseditor.cpp:862
CAActionsEditor::FT_MIDISCUT
@ FT_MIDISCUT
Definition: actionseditor.h:41
canorus.h
singleaction.h
CASettings::latestShortcutsDirectory
QDir latestShortcutsDirectory()
Definition: settings.h:148
CAActionsEditor::latest_dir
QString latest_dir
Definition: actionseditor.h:114
modToString
static QStringList modToString(Qt::KeyboardModifiers k)
Definition: actionseditor.cpp:715
CAActionsEditor::loadActionsTable
void loadActionsTable()
Definition: actionseditor.cpp:509
CASingleAction::getMidiShortCutCombined
bool getMidiShortCutCombined()
Definition: singleaction.h:30
CAActionsEditor::recordAction
void recordAction(QTableWidgetItem *)
Definition: actionseditor.cpp:315
ShortcutGetter::event
bool event(QEvent *e)
Definition: actionseditor.cpp:799
CAActionsEditor::m_actionsList
QList< CASingleAction * > m_actionsList
Definition: actionseditor.h:111
QLineEdit
CASingleAction::getDescription
QString getDescription()
Definition: singleaction.h:27
ShortcutGetter::lKeys
QStringList lKeys
Definition: actionseditor.h:147
CAActionsEditor::loadButton
QPushButton * loadButton
Definition: actionseditor.h:113
CAActionsEditor::fileType
fileType
Definition: actionseditor.h:37
CAActionsEditor::findActionCommand
int findActionCommand(const QString &name)
Definition: actionseditor.cpp:382
CAActionsEditor::saveButton
QPushButton * saveButton
Definition: actionseditor.h:112