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); |
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 |