43 // ============================================================================= |
43 // ============================================================================= |
44 // Metadata for actions |
44 // Metadata for actions |
45 typedef struct { |
45 typedef struct { |
46 QAction** const qAct; |
46 QAction** const qAct; |
47 keyseqconfig* const conf; |
47 keyseqconfig* const conf; |
48 const char* const sDisplayName, *sIconName, *sDescription; |
48 const char* const name, *sDisplayName, *sIconName, *sDescription; |
49 void (*const handler) (); |
49 void (*const handler) (); |
50 } actionmeta; |
50 } actionmeta; |
51 |
51 |
52 extern vector<actionmeta> g_ActionMeta; |
52 extern vector<actionmeta> g_ActionMeta; |
53 |
53 |
57 #define MAKE_ACTION(NAME, DISPLAYNAME, ICONNAME, DESCR, DEFSHORTCUT) \ |
57 #define MAKE_ACTION(NAME, DISPLAYNAME, ICONNAME, DESCR, DEFSHORTCUT) \ |
58 QAction* ACTION (NAME); \ |
58 QAction* ACTION (NAME); \ |
59 cfg (keyseq, key_##NAME, DEFSHORTCUT); \ |
59 cfg (keyseq, key_##NAME, DEFSHORTCUT); \ |
60 static void actionHandler_##NAME (); \ |
60 static void actionHandler_##NAME (); \ |
61 static ActionAdder ActionAdderInstance_##NAME (&ACTION(NAME), DISPLAYNAME, \ |
61 static ActionAdder ActionAdderInstance_##NAME (&ACTION(NAME), DISPLAYNAME, \ |
62 ICONNAME, DESCR, &key_##NAME, actionHandler_##NAME); \ |
62 ICONNAME, DESCR, &key_##NAME, actionHandler_##NAME, #NAME); \ |
63 static void actionHandler_##NAME () |
63 static void actionHandler_##NAME () |
64 |
64 |
65 #define EXTERN_ACTION(NAME) extern QAction* ACTION (NAME); |
65 #define EXTERN_ACTION(NAME) extern QAction* ACTION (NAME); |
66 #define ACTION(N) LDForgeAction_##N |
66 #define ACTION(N) LDForgeAction_##N |
67 |
67 |
86 // it in g_ActionMeta. It is not supposed to be used directly! |
86 // it in g_ActionMeta. It is not supposed to be used directly! |
87 // ============================================================================= |
87 // ============================================================================= |
88 class ActionAdder { |
88 class ActionAdder { |
89 public: |
89 public: |
90 ActionAdder (QAction** qAct, const char* sDisplayName, const char* sIconName, |
90 ActionAdder (QAction** qAct, const char* sDisplayName, const char* sIconName, |
91 const char* sDescription, keyseqconfig* conf, void (*const handler) ()) |
91 const char* sDescription, keyseqconfig* conf, void (*const handler) (), |
|
92 const char* name) |
92 { |
93 { |
93 actionmeta meta = {qAct, conf, sDisplayName, sIconName, sDescription, handler}; |
94 actionmeta meta = {qAct, conf, name, sDisplayName, sIconName, sDescription, handler}; |
94 g_ActionMeta.push_back (meta); |
95 g_ActionMeta.push_back (meta); |
95 } |
96 } |
96 }; |
97 }; |
97 |
98 |
98 // ============================================================================= |
99 // ============================================================================= |
166 std::vector<QAction*> m_recentFiles; |
167 std::vector<QAction*> m_recentFiles; |
167 |
168 |
168 void createMenuActions (); |
169 void createMenuActions (); |
169 void createMenus (); |
170 void createMenus (); |
170 void createToolbars (); |
171 void createToolbars (); |
171 void initSingleToolBar (const char* sName); |
172 void initSingleToolBar (const char* name); |
|
173 void addToolBarAction (const char* name); |
|
174 |
|
175 void initMenu (const char* name); |
|
176 void addMenuAction (const char* name); |
172 |
177 |
173 private slots: |
178 private slots: |
174 void slot_selectionChanged (); |
179 void slot_selectionChanged (); |
175 void slot_action (); |
180 void slot_action (); |
176 void slot_recentFile (); |
181 void slot_recentFile (); |
183 QPixmap getIcon (const char* sIconName); |
188 QPixmap getIcon (const char* sIconName); |
184 std::vector<quickColorMetaEntry> parseQuickColorMeta (); |
189 std::vector<quickColorMetaEntry> parseQuickColorMeta (); |
185 bool confirm (str title, str msg); |
190 bool confirm (str title, str msg); |
186 bool confirm (str msg); |
191 bool confirm (str msg); |
187 void critical (str msg); |
192 void critical (str msg); |
|
193 QAction* const& findAction (str name); |
188 |
194 |
189 // ----------------------------------------------------------------------------- |
195 // ----------------------------------------------------------------------------- |
190 // Pointer to the instance of ForgeWindow. |
196 // Pointer to the instance of ForgeWindow. |
191 extern ForgeWindow* g_win; |
197 extern ForgeWindow* g_win; |
192 |
198 |