src/actions.cpp

changeset 954
7feaa1a3c438
parent 953
8349552ee5e9
child 956
2af18ba2665f
equal deleted inserted replaced
953:8349552ee5e9 954:7feaa1a3c438
36 #include "radioGroup.h" 36 #include "radioGroup.h"
37 #include "colors.h" 37 #include "colors.h"
38 #include "glCompiler.h" 38 #include "glCompiler.h"
39 #include "ui_newpart.h" 39 #include "ui_newpart.h"
40 #include "dialogs/ldrawpathdialog.h" 40 #include "dialogs/ldrawpathdialog.h"
41 #include "dialogs/newpartdialog.h"
41 #include "editmodes/abstractEditMode.h" 42 #include "editmodes/abstractEditMode.h"
42 43
43 EXTERN_CFGENTRY (Bool, DrawWireframe) 44 EXTERN_CFGENTRY (Bool, DrawWireframe)
44 EXTERN_CFGENTRY (Bool, BFCRedGreenView) 45 EXTERN_CFGENTRY (Bool, BFCRedGreenView)
45 EXTERN_CFGENTRY (String, DefaultName)
46 EXTERN_CFGENTRY (String, DefaultUser)
47 EXTERN_CFGENTRY (Bool, UseCALicense)
48 EXTERN_CFGENTRY (Bool, DrawAngles) 46 EXTERN_CFGENTRY (Bool, DrawAngles)
49 EXTERN_CFGENTRY (Bool, RandomColors) 47 EXTERN_CFGENTRY (Bool, RandomColors)
50 EXTERN_CFGENTRY (Bool, DrawSurfaces) 48 EXTERN_CFGENTRY (Bool, DrawSurfaces)
51 EXTERN_CFGENTRY (Bool, DrawEdgeLines) 49 EXTERN_CFGENTRY (Bool, DrawEdgeLines)
52 EXTERN_CFGENTRY (Bool, DrawConditionalLines) 50 EXTERN_CFGENTRY (Bool, DrawConditionalLines)
53 EXTERN_CFGENTRY (Bool, DrawAxes) 51 EXTERN_CFGENTRY (Bool, DrawAxes)
54 EXTERN_CFGENTRY (String, LDrawPath) 52 EXTERN_CFGENTRY (String, LDrawPath)
53 EXTERN_CFGENTRY (String, DefaultName)
54 EXTERN_CFGENTRY (String, DefaultUser)
55 EXTERN_CFGENTRY (Bool, UseCALicense)
55 56
56 // ============================================================================= 57 // =============================================================================
57 // 58 //
58 void MainWindow::slot_actionNew() 59 void MainWindow::slot_actionNew()
59 { 60 {
60 QDialog* dlg = new QDialog (g_win); 61 NewPartDialog* dlg = new NewPartDialog (this);
61 Ui::NewPartUI ui; 62
62 ui.setupUi (dlg); 63 if (dlg->exec() == QDialog::Accepted)
63 64 {
64 QString authortext = cfg::DefaultName; 65 newFile();
65 66 dlg->fillHeader (CurrentDocument());
66 if (not cfg::DefaultUser.isEmpty()) 67 doFullRefresh();
67 authortext.append (format (" [%1]", cfg::DefaultUser)); 68 }
68 69 }
69 ui.le_author->setText (authortext); 70
70 ui.caLicense->setChecked (cfg::UseCALicense); 71 // =============================================================================
71 72 //
72 if (dlg->exec() == QDialog::Rejected) 73 void MainWindow::slot_actionNewFile()
73 return; 74 {
74
75 newFile(); 75 newFile();
76
77 BFCStatement const bfctype = ui.rb_bfc_ccw->isChecked() ? BFCStatement::CertifyCCW
78 : ui.rb_bfc_cw->isChecked() ? BFCStatement::CertifyCW
79 : BFCStatement::NoCertify;
80 QString const license = ui.caLicense->isChecked() ? CALicenseText : "";
81
82 LDObjectList objs;
83 objs << LDSpawn<LDComment> (ui.le_title->text());
84 objs << LDSpawn<LDComment> ("Name: <untitled>.dat");
85 objs << LDSpawn<LDComment> (format ("Author: %1", ui.le_author->text()));
86 objs << LDSpawn<LDComment> (format ("!LDRAW_ORG Unofficial_Part"));
87
88 if (not license.isEmpty())
89 objs << LDSpawn<LDComment> (license);
90
91 objs << LDSpawn<LDEmpty>();
92 objs << LDSpawn<LDBFC> (bfctype);
93 objs << LDSpawn<LDEmpty>();
94 CurrentDocument()->addObjects (objs);
95 doFullRefresh();
96 }
97
98 // =============================================================================
99 //
100 void MainWindow::slot_actionNewFile()
101 {
102 newFile();
103 } 76 }
104 77
105 // ============================================================================= 78 // =============================================================================
106 // 79 //
107 void MainWindow::slot_actionOpen() 80 void MainWindow::slot_actionOpen()
108 { 81 {
109 QString name = QFileDialog::getOpenFileName (g_win, "Open File", "", "LDraw files (*.dat *.ldr)"); 82 QString name = QFileDialog::getOpenFileName (this, "Open File", "", "LDraw files (*.dat *.ldr)");
110 83
111 if (name.isEmpty()) 84 if (name.isEmpty())
112 return; 85 return;
113 86
114 OpenMainModel (name); 87 OpenMainModel (name);
238 void MainWindow::slot_actionEdit() 211 void MainWindow::slot_actionEdit()
239 { 212 {
240 if (Selection().size() != 1) 213 if (Selection().size() != 1)
241 return; 214 return;
242 215
243 LDObject* obj = Selection() [0]; 216 LDObject* obj = Selection().first();
244 AddObjectDialog::staticDialog (obj->type(), obj); 217 AddObjectDialog::staticDialog (obj->type(), obj);
245 } 218 }
246 219
247 // ============================================================================= 220 // =============================================================================
248 // 221 //
259 232
260 // ============================================================================= 233 // =============================================================================
261 // 234 //
262 void MainWindow::slot_actionAboutQt() 235 void MainWindow::slot_actionAboutQt()
263 { 236 {
264 QMessageBox::aboutQt (g_win); 237 QMessageBox::aboutQt (this);
265 } 238 }
266 239
267 // ============================================================================= 240 // =============================================================================
268 // 241 //
269 void MainWindow::slot_actionSelectAll() 242 void MainWindow::slot_actionSelectAll()
476 449
477 if (root.right (4) == ".dat") 450 if (root.right (4) == ".dat")
478 root.chop (4); 451 root.chop (4);
479 452
480 QString defaultname = (root.length() > 0) ? format ("%1.png", root) : ""; 453 QString defaultname = (root.length() > 0) ? format ("%1.png", root) : "";
481 QString fname = QFileDialog::getSaveFileName (g_win, "Save Screencap", defaultname, 454 QString fname = QFileDialog::getSaveFileName (this, "Save Screencap", defaultname,
482 "PNG images (*.png);;JPG images (*.jpg);;BMP images (*.bmp);;All Files (*.*)"); 455 "PNG images (*.png);;JPG images (*.jpg);;BMP images (*.bmp);;All Files (*.*)");
483 456
484 if (not fname.isEmpty() and not img.save (fname)) 457 if (not fname.isEmpty() and not img.save (fname))
485 Critical (format ("Couldn't open %1 for writing to save screencap: %2", fname, strerror (errno))); 458 Critical (format ("Couldn't open %1 for writing to save screencap: %2", fname, strerror (errno)));
486 459
607 { 580 {
608 if (R()->camera() == EFreeCamera) 581 if (R()->camera() == EFreeCamera)
609 return; 582 return;
610 583
611 bool ok; 584 bool ok;
612 double depth = QInputDialog::getDouble (g_win, "Set Draw Depth", 585 double depth = QInputDialog::getDouble (this, "Set Draw Depth",
613 format ("Depth value for %1 Camera:", R()->getCameraName()), 586 format ("Depth value for %1 Camera:", R()->getCameraName()),
614 R()->getDepthValue(), -10000.0f, 10000.0f, 3, &ok); 587 R()->getDepthValue(), -10000.0f, 10000.0f, 3, &ok);
615 588
616 if (ok) 589 if (ok)
617 R()->setDepthValue (depth); 590 R()->setDepthValue (depth);

mercurial