gui_actions.cpp

changeset 170
2247a32e63a8
parent 168
96691a009dff
child 172
a65547b84ef8
equal deleted inserted replaced
169:f562323760a2 170:2247a32e63a8
168 168
169 // ============================================================================= 169 // =============================================================================
170 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * 170 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
171 // ============================================================================= 171 // =============================================================================
172 MAKE_ACTION (about, "About " APPNAME, "ldforge", 172 MAKE_ACTION (about, "About " APPNAME, "ldforge",
173 "Shows information about " APPNAME ".", CTRL (F1)) 173 "Shows information about " APPNAME ".", (0))
174 { 174 {
175 AboutDialog dlg; 175 AboutDialog dlg;
176 dlg.exec (); 176 dlg.exec ();
177 } 177 }
178 178
179 MAKE_ACTION (aboutQt, "About Qt", "qt", "Shows information about Qt.", CTRL_SHIFT (F1)) { 179 MAKE_ACTION (aboutQt, "About Qt", "qt", "Shows information about Qt.", (0)) {
180 QMessageBox::aboutQt (g_win); 180 QMessageBox::aboutQt (g_win);
181 } 181 }
182 182
183 // ============================================================================= 183 // =============================================================================
184 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * 184 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
398 g_win->R ()->endPlaneDraw (false); 398 g_win->R ()->endPlaneDraw (false);
399 } 399 }
400 400
401 MAKE_ACTION (doneDraw, "Done Drawing", "draw-done", "Done drawing geometry", KEY (Enter)) { 401 MAKE_ACTION (doneDraw, "Done Drawing", "draw-done", "Done drawing geometry", KEY (Enter)) {
402 g_win->R ()->endPlaneDraw (true); 402 g_win->R ()->endPlaneDraw (true);
403 }
404
405 // =============================================================================
406 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
407 // =============================================================================
408 void setGroup (const LDObject::Group group) {
409 for (LDObject* obj : g_win->sel ())
410 obj->setGroup (group);
411
412 g_win->refresh ();
413 }
414
415 // =============================================================================
416 void selGroup (const LDObject::Group group) {
417 for (LDObject* obj : g_curfile->m_objs) {
418 if (obj->group () != group)
419 continue; // wrong group
420
421 bool selected = false;
422 for (LDObject* selobj : g_win->sel ()) {
423 if (selobj == obj) {
424 selected = true;
425 break;
426 }
427 }
428
429 if (selected)
430 continue; // already selected
431
432 g_win->sel ().push_back (obj);
433 }
434
435 g_win->refresh ();
436 }
437
438 #define GROUP_ACTION(N, KEY) \
439 MAKE_ACTION (group##N, "Group " #N, "group", "Set group of selected objects to " #N, CTRL_SHIFT (KEY)) { \
440 setGroup (LDObject::N); \
441 } \
442 \
443 MAKE_ACTION (selGroup##N, "Select Group " #N, "group", "Select the contents of group " #N, SHIFT (F##KEY)) { \
444 selGroup (LDObject::N); \
445 }
446
447 GROUP_ACTION (A, 1)
448 GROUP_ACTION (B, 2)
449 GROUP_ACTION (C, 3)
450 GROUP_ACTION (D, 4)
451
452 MAKE_ACTION (ungroup, "Ungroup", "ungroup", "Unset the group of selected objects", CTRL_SHIFT (0)) {
453 setGroup (LDObject::NoGroup);
454 }
455
456 // =============================================================================
457 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
458 // =============================================================================
459 MAKE_ACTION (visibility, "Toggle Visibility", "visibility", "Toggles visibility/hiding on objects.", (0)) {
460 for (LDObject* obj : g_win->sel ())
461 obj->setHidden (!obj->hidden ());
462
463 g_win->refresh ();
403 } 464 }
404 465
405 // ============================================================================= 466 // =============================================================================
406 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * 467 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
407 // ============================================================================= 468 // =============================================================================

mercurial