21 #include "common.h" |
21 #include "common.h" |
22 #include "gldraw.h" |
22 #include "gldraw.h" |
23 #include "gui.h" |
23 #include "gui.h" |
24 #include "file.h" |
24 #include "file.h" |
25 #include "config.h" |
25 #include "config.h" |
|
26 #include "misc.h" |
|
27 #include "colors.h" |
|
28 #include "zz_addObjectDialog.h" |
|
29 #include "zz_colorSelectDialog.h" |
|
30 #include "zz_configDialog.h" |
|
31 #include "zz_newPartDialog.h" |
26 #include "zz_setContentsDialog.h" |
32 #include "zz_setContentsDialog.h" |
27 #include "zz_configDialog.h" |
|
28 #include "zz_addObjectDialog.h" |
|
29 #include "misc.h" |
|
30 #include "zz_colorSelectDialog.h" |
|
31 #include "colors.h" |
|
32 |
33 |
33 #define MAKE_ACTION(OBJECT, DISPLAYNAME, IMAGENAME, DESCR) \ |
34 #define MAKE_ACTION(OBJECT, DISPLAYNAME, IMAGENAME, DESCR) \ |
34 qAct_##OBJECT = new QAction (QIcon ("./icons/" IMAGENAME ".png"), tr (DISPLAYNAME), this); \ |
35 qAct_##OBJECT = new QAction (QIcon ("./icons/" IMAGENAME ".png"), tr (DISPLAYNAME), this); \ |
35 qAct_##OBJECT->setStatusTip (tr (DESCR)); \ |
36 qAct_##OBJECT->setStatusTip (tr (DESCR)); \ |
36 connect (qAct_##OBJECT, SIGNAL (triggered ()), this, SLOT (slot_##OBJECT ())); |
37 connect (qAct_##OBJECT, SIGNAL (triggered ()), this, SLOT (slot_##OBJECT ())); |
84 // Long menu names go here so my cool action definition table doesn't get out of proportions |
85 // Long menu names go here so my cool action definition table doesn't get out of proportions |
85 char const* sNewCdLineText = "New Conditional Line", |
86 char const* sNewCdLineText = "New Conditional Line", |
86 *sNewQuadText = "New Quadrilateral", |
87 *sNewQuadText = "New Quadrilateral", |
87 *sAboutText = "About " APPNAME_DISPLAY; |
88 *sAboutText = "About " APPNAME_DISPLAY; |
88 |
89 |
89 MAKE_ACTION (new, "&New", "file-new", "Create a new part model.") |
90 MAKE_ACTION (new, "&New", "brick", "Create a new part model.") |
90 MAKE_ACTION (open, "&Open", "file-open", "Load a part model from a file.") |
91 MAKE_ACTION (open, "&Open", "file-open", "Load a part model from a file.") |
91 MAKE_ACTION (save, "&Save", "file-save", "Save the part model.") |
92 MAKE_ACTION (save, "&Save", "file-save", "Save the part model.") |
92 MAKE_ACTION (saveAs, "Save &As", "file-save-as", "Save the part to a specific file.") |
93 MAKE_ACTION (saveAs, "Save &As", "file-save-as", "Save the part to a specific file.") |
93 MAKE_ACTION (exit, "&Exit", "exit", "Close " APPNAME_DISPLAY ".") |
94 MAKE_ACTION (exit, "&Exit", "exit", "Close " APPNAME_DISPLAY ".") |
94 |
95 |
245 |
246 |
246 // ============================================================================= |
247 // ============================================================================= |
247 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * |
248 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * |
248 // ============================================================================= |
249 // ============================================================================= |
249 void ForgeWindow::slot_new () { |
250 void ForgeWindow::slot_new () { |
250 newFile (); |
251 // newFile (); |
|
252 NewPartDialog::StaticDialog (); |
251 } |
253 } |
252 |
254 |
253 void ForgeWindow::slot_open () { |
255 void ForgeWindow::slot_open () { |
254 str zName; |
256 str zName; |
255 zName += QFileDialog::getOpenFileName (this, "Open File", |
257 zName += QFileDialog::getOpenFileName (this, "Open File", |
331 vector<LDObject*> objs = getSelectedObjects (); |
333 vector<LDObject*> objs = getSelectedObjects (); |
332 |
334 |
333 if (objs.size() == 0) |
335 if (objs.size() == 0) |
334 return false; |
336 return false; |
335 |
337 |
336 // Clear the clipboard. However, its contents are dynamically allocated |
338 // Clear the clipboard first. |
337 // clones of LDObjects (cannot use pointers to real objects because the |
|
338 // cut operation deletes them!), so we have to delete said objects first. |
|
339 for (LDObject* obj : g_Clipboard) |
339 for (LDObject* obj : g_Clipboard) |
340 delete obj; |
340 delete obj; |
341 |
341 |
342 g_Clipboard.clear (); |
342 g_Clipboard.clear (); |
343 |
343 |
344 for (std::size_t i = 0; i < objs.size(); ++i) |
344 // Now, copy the contents into the clipboard. The objects should be |
345 g_Clipboard.push_back (objs[i]->makeClone ()); |
345 // separate objects so that modifying the existing ones does not affect |
|
346 // the clipboard. Thus, we add clones of the objects to the clipboard, not |
|
347 // the objects themselves. |
|
348 for (ulong i = 0; i < objs.size(); ++i) |
|
349 g_Clipboard.push_back (objs[i]->clone ()); |
346 |
350 |
347 return true; |
351 return true; |
348 } |
352 } |
349 |
353 |
350 // ============================================================================= |
354 // ============================================================================= |
371 // ============================================================================= |
375 // ============================================================================= |
372 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * |
376 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * |
373 // ============================================================================= |
377 // ============================================================================= |
374 void ForgeWindow::slot_paste () { |
378 void ForgeWindow::slot_paste () { |
375 for (LDObject* obj : g_Clipboard) |
379 for (LDObject* obj : g_Clipboard) |
376 g_CurrentFile->addObject (obj->makeClone ()); |
380 g_CurrentFile->addObject (obj->clone ()); |
377 |
381 |
378 refresh (); |
382 refresh (); |
379 } |
383 } |
380 |
384 |
381 // ============================================================================= |
385 // ============================================================================= |