gui.cpp

changeset 78
c190fe218506
parent 77
7c2f500405fe
child 79
f8917e9d07f6
equal deleted inserted replaced
77:7c2f500405fe 78:c190fe218506
44 QAction* settings; 44 QAction* settings;
45 QAction* help, *about, *aboutQt; 45 QAction* help, *about, *aboutQt;
46 }; 46 };
47 47
48 // Key-binding configurations 48 // Key-binding configurations
49 cfg (str, key_newFile, "ctrl-n"); 49 cfg (keyseq, key_newFile, (Qt::CTRL | Qt::Key_N));
50 cfg (str, key_open, "ctrl-o"); 50 cfg (keyseq, key_open, (Qt::CTRL | Qt::Key_O));
51 cfg (str, key_save, "ctrl-s"); 51 cfg (keyseq, key_save, (Qt::CTRL | Qt::Key_S));
52 cfg (str, key_saveAs, "ctrl-shift-s"); 52 cfg (keyseq, key_saveAs, (Qt::CTRL | Qt::SHIFT | Qt::Key_S));
53 cfg (str, key_exit, "ctrl-q"); 53 cfg (keyseq, key_exit, (Qt::CTRL | Qt::Key_Q));
54 cfg (str, key_cut, "ctrl-x"); 54 cfg (keyseq, key_cut, (Qt::CTRL | Qt::Key_X));
55 cfg (str, key_copy, "ctrl-c"); 55 cfg (keyseq, key_copy, (Qt::CTRL | Qt::Key_C));
56 cfg (str, key_paste, "ctrl-v"); 56 cfg (keyseq, key_paste, (Qt::CTRL | Qt::Key_V));
57 cfg (str, key_del, "del"); 57 cfg (keyseq, key_del, (Qt::Key_Delete));
58 cfg (str, key_newSubfile, ""); 58 cfg (keyseq, key_newSubfile, 0);
59 cfg (str, key_newLine, ""); 59 cfg (keyseq, key_newLine, 0);
60 cfg (str, key_newTriangle, ""); 60 cfg (keyseq, key_newTriangle, 0);
61 cfg (str, key_newQuad, ""); 61 cfg (keyseq, key_newQuad, 0);
62 cfg (str, key_newCondLine, ""); 62 cfg (keyseq, key_newCondLine, 0);
63 cfg (str, key_newComment, ""); 63 cfg (keyseq, key_newComment, 0);
64 cfg (str, key_newVertex, ""); 64 cfg (keyseq, key_newVertex, 0);
65 cfg (str, key_splitQuads, ""); 65 cfg (keyseq, key_splitQuads, 0);
66 cfg (str, key_setContents, ""); 66 cfg (keyseq, key_setContents, 0);
67 cfg (str, key_inlineContents, "ctrl-i"); 67 cfg (keyseq, key_inlineContents, (Qt::CTRL | Qt::Key_I));
68 cfg (str, key_deepInline, "ctrl-shift-i"); 68 cfg (keyseq, key_deepInline, (Qt::CTRL | Qt::SHIFT | Qt::Key_I));
69 cfg (str, key_makeBorders, "ctrl-shift-b"); 69 cfg (keyseq, key_makeBorders, (Qt::CTRL | Qt::SHIFT | Qt::Key_B));
70 cfg (str, key_settings, ""); 70 cfg (keyseq, key_settings, 0);
71 cfg (str, key_help, "f1"); 71 cfg (keyseq, key_help, (Qt::Key_F1));
72 cfg (str, key_about, ""); 72 cfg (keyseq, key_about, 0);
73 cfg (str, key_aboutQt, ""); 73 cfg (keyseq, key_aboutQt, 0);
74 cfg (str, key_setColor, ""); 74 cfg (keyseq, key_setColor, 0);
75
76 // =============================================================================
77 // Metadata for actions
78 typedef struct {
79 QAction** const qAct;
80 strconfig* const cfg;
81 } actionmeta;
82 75
83 vector<LDObject*> g_Clipboard; 76 vector<LDObject*> g_Clipboard;
84 vector<actionmeta> g_ActionMeta; 77 vector<actionmeta> g_ActionMeta;
85 78
86 cfg (bool, lv_colorize, true); 79 cfg (bool, lv_colorize, true);
172 165
173 MAKE_ACTION (help, "Help", "help", "Shows the " APPNAME_DISPLAY " help manual.") 166 MAKE_ACTION (help, "Help", "help", "Shows the " APPNAME_DISPLAY " help manual.")
174 MAKE_ACTION (about, sAboutText, "ldforge", "Shows information about " APPNAME_DISPLAY ".") 167 MAKE_ACTION (about, sAboutText, "ldforge", "Shows information about " APPNAME_DISPLAY ".")
175 MAKE_ACTION (aboutQt, "About Qt", "aboutQt", "Shows information about Qt.") 168 MAKE_ACTION (aboutQt, "About Qt", "aboutQt", "Shows information about Qt.")
176 169
177 // Keyboard shortcuts 170 // Apply the shortcuts now
178 ACTION (newFile)->setShortcut (Qt::CTRL | Qt::Key_N); 171 for (actionmeta meta : g_ActionMeta)
179 ACTION (open)->setShortcut (Qt::CTRL | Qt::Key_O); 172 (*meta.qAct)->setShortcut (*meta.conf);
180 ACTION (save)->setShortcut (Qt::CTRL | Qt::Key_S);
181 ACTION (saveAs)->setShortcut (Qt::CTRL | Qt::SHIFT | Qt::Key_S);
182
183 ACTION (cut)->setShortcut (Qt::CTRL | Qt::Key_X);
184 ACTION (copy)->setShortcut (Qt::CTRL | Qt::Key_C);
185 ACTION (paste)->setShortcut (Qt::CTRL | Qt::Key_V);
186 ACTION (del)->setShortcut (Qt::Key_Delete);
187 173
188 // things not implemented yet 174 // things not implemented yet
189 QAction* const qaDisabledActions[] = { 175 QAction* const qaDisabledActions[] = {
190 ACTION (newSubfile), 176 ACTION (newSubfile),
191 ACTION (about), 177 ACTION (about),
304 } 290 }
305 291
306 // ============================================================================= 292 // =============================================================================
307 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * 293 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
308 // ============================================================================= 294 // =============================================================================
309 void ForgeWindow::slot_new () { 295 void ForgeWindow::slot_newFile () {
310 // newFile (); 296 // newFile ();
311 NewPartDialog::StaticDialog (); 297 NewPartDialog::StaticDialog ();
312 } 298 }
313 299
314 void ForgeWindow::slot_open () { 300 void ForgeWindow::slot_open () {
442 } 428 }
443 429
444 // ============================================================================= 430 // =============================================================================
445 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * 431 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
446 // ============================================================================= 432 // =============================================================================
447 void ForgeWindow::slot_delete () { 433 void ForgeWindow::slot_del () {
448 deleteSelection (); 434 deleteSelection ();
449 refresh (); 435 refresh ();
450 } 436 }
451 437
452 // ============================================================================= 438 // =============================================================================
488 } 474 }
489 475
490 refresh (); 476 refresh ();
491 } 477 }
492 478
493 void ForgeWindow::slot_inline () { 479 void ForgeWindow::slot_inlineContents () {
494 doInline (false); 480 doInline (false);
495 } 481 }
496 482
497 void ForgeWindow::slot_deepInline () { 483 void ForgeWindow::slot_deepInline () {
498 doInline (true); 484 doInline (true);

mercurial