62 |
62 |
63 const str license = |
63 const str license = |
64 ui.rb_license_ca->isChecked() ? CALicense : |
64 ui.rb_license_ca->isChecked() ? CALicense : |
65 ui.rb_license_nonca->isChecked() ? NonCALicense : ""; |
65 ui.rb_license_nonca->isChecked() ? NonCALicense : ""; |
66 |
66 |
67 LDOpenFile* f = LDOpenFile::current(); |
67 LDFile* f = LDFile::current(); |
68 *f << new LDCommentObject (ui.le_title->text()); |
68 *f << new LDCommentObject (ui.le_title->text()); |
69 *f << new LDCommentObject ("Name: <untitled>.dat" ); |
69 *f << new LDCommentObject ("Name: <untitled>.dat" ); |
70 *f << new LDCommentObject (fmt ("Author: %1", ui.le_author->text())); |
70 *f << new LDCommentObject (fmt ("Author: %1", ui.le_author->text())); |
71 *f << new LDCommentObject (fmt ("!LDRAW_ORG Unofficial_Part")); |
71 *f << new LDCommentObject (fmt ("!LDRAW_ORG Unofficial_Part")); |
72 |
72 |
94 |
94 |
95 // ============================================================================= |
95 // ============================================================================= |
96 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * |
96 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * |
97 // ============================================================================= |
97 // ============================================================================= |
98 DEFINE_ACTION (Save, CTRL (S)) { |
98 DEFINE_ACTION (Save, CTRL (S)) { |
99 g_win->save (LDOpenFile::current(), false); |
99 g_win->save (LDFile::current(), false); |
100 } |
100 } |
101 |
101 |
102 // ============================================================================= |
102 // ============================================================================= |
103 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * |
103 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * |
104 // ============================================================================= |
104 // ============================================================================= |
105 DEFINE_ACTION (SaveAs, CTRL_SHIFT (S)) { |
105 DEFINE_ACTION (SaveAs, CTRL_SHIFT (S)) { |
106 g_win->save (LDOpenFile::current(), true); |
106 g_win->save (LDFile::current(), true); |
107 } |
107 } |
108 |
108 |
109 // ============================================================================= |
109 // ============================================================================= |
110 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * |
110 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * |
111 // ============================================================================= |
111 // ============================================================================= |
112 DEFINE_ACTION (SaveAll, CTRL (L)) { |
112 DEFINE_ACTION (SaveAll, CTRL (L)) { |
113 for (LDOpenFile* file : g_loadedFiles) { |
113 for (LDFile* file : g_loadedFiles) { |
114 if (file->implicit()) |
114 if (file->implicit()) |
115 continue; |
115 continue; |
116 |
116 |
117 g_win->save (file, false); |
117 g_win->save (file, false); |
118 } |
118 } |
120 |
120 |
121 // ============================================================================= |
121 // ============================================================================= |
122 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * |
122 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * |
123 // ============================================================================= |
123 // ============================================================================= |
124 DEFINE_ACTION (Close, CTRL (W)) { |
124 DEFINE_ACTION (Close, CTRL (W)) { |
125 if (!LDOpenFile::current()->safeToClose()) |
125 if (!LDFile::current()->safeToClose()) |
126 return; |
126 return; |
127 |
127 |
128 delete LDOpenFile::current(); |
128 delete LDFile::current(); |
129 } |
129 } |
130 |
130 |
131 // ============================================================================= |
131 // ============================================================================= |
132 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * |
132 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * |
133 // ============================================================================= |
133 // ============================================================================= |
223 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * |
223 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * |
224 // ============================================================================= |
224 // ============================================================================= |
225 DEFINE_ACTION (SelectAll, CTRL (A)) { |
225 DEFINE_ACTION (SelectAll, CTRL (A)) { |
226 g_win->sel().clear(); |
226 g_win->sel().clear(); |
227 |
227 |
228 for (LDObject* obj : LDOpenFile::current()->objs()) |
228 for (LDObject* obj : LDFile::current()->objs()) |
229 g_win->sel() << obj; |
229 g_win->sel() << obj; |
230 |
230 |
231 g_win->updateSelection(); |
231 g_win->updateSelection(); |
232 } |
232 } |
233 |
233 |
237 |
237 |
238 if (colnum == -1) |
238 if (colnum == -1) |
239 return; // no consensus on color |
239 return; // no consensus on color |
240 |
240 |
241 g_win->sel().clear(); |
241 g_win->sel().clear(); |
242 for (LDObject* obj : LDOpenFile::current()->objs()) |
242 for (LDObject* obj : LDFile::current()->objs()) |
243 if (obj->color() == colnum) |
243 if (obj->color() == colnum) |
244 g_win->sel() << obj; |
244 g_win->sel() << obj; |
245 |
245 |
246 g_win->updateSelection(); |
246 g_win->updateSelection(); |
247 } |
247 } |
267 if (static_cast<LDSubfileObject*> (obj)->fileInfo()->name() != refName) |
267 if (static_cast<LDSubfileObject*> (obj)->fileInfo()->name() != refName) |
268 return; |
268 return; |
269 } |
269 } |
270 |
270 |
271 g_win->sel().clear(); |
271 g_win->sel().clear(); |
272 for (LDObject* obj : LDOpenFile::current()->objs()) { |
272 for (LDObject* obj : LDFile::current()->objs()) { |
273 if (obj->getType() != type) |
273 if (obj->getType() != type) |
274 continue; |
274 continue; |
275 |
275 |
276 if (type == LDObject::Subfile && static_cast<LDSubfileObject*> (obj)->fileInfo()->name() != refName) |
276 if (type == LDObject::Subfile && static_cast<LDSubfileObject*> (obj)->fileInfo()->name() != refName) |
277 continue; |
277 continue; |
388 g_win->sel().clear(); |
388 g_win->sel().clear(); |
389 |
389 |
390 for (str line : str (te_edit->toPlainText()).split ("\n")) { |
390 for (str line : str (te_edit->toPlainText()).split ("\n")) { |
391 LDObject* obj = parseLine (line); |
391 LDObject* obj = parseLine (line); |
392 |
392 |
393 LDOpenFile::current()->insertObj (idx, obj); |
393 LDFile::current()->insertObj (idx, obj); |
394 g_win->sel() << obj; |
394 g_win->sel() << obj; |
395 idx++; |
395 idx++; |
396 } |
396 } |
397 |
397 |
398 g_win->fullRefresh(); |
398 g_win->fullRefresh(); |
404 |
404 |
405 ushort w, h; |
405 ushort w, h; |
406 uchar* imgdata = g_win->R()->screencap (w, h); |
406 uchar* imgdata = g_win->R()->screencap (w, h); |
407 QImage img = imageFromScreencap (imgdata, w, h); |
407 QImage img = imageFromScreencap (imgdata, w, h); |
408 |
408 |
409 str root = basename (LDOpenFile::current()->name()); |
409 str root = basename (LDFile::current()->name()); |
410 if (root.right (4) == ".dat") |
410 if (root.right (4) == ".dat") |
411 root.chop (4); |
411 root.chop (4); |
412 |
412 |
413 str defaultname = (root.length() > 0) ? fmt ("%1.png", root) : ""; |
413 str defaultname = (root.length() > 0) ? fmt ("%1.png", root) : ""; |
414 str fname = QFileDialog::getSaveFileName (g_win, "Save Screencap", defaultname, |
414 str fname = QFileDialog::getSaveFileName (g_win, "Save Screencap", defaultname, |
480 #if 0 |
480 #if 0 |
481 // This is a test to draw a dummy axle. Meant to be used as a primitive gallery, |
481 // This is a test to draw a dummy axle. Meant to be used as a primitive gallery, |
482 // but I can't figure how to generate these pictures properly. Multi-threading |
482 // but I can't figure how to generate these pictures properly. Multi-threading |
483 // these is an immense pain. |
483 // these is an immense pain. |
484 DEFINE_ACTION (testpic, "Test picture", "", "", (0)) { |
484 DEFINE_ACTION (testpic, "Test picture", "", "", (0)) { |
485 LDOpenFile* file = getFile ("axle.dat"); |
485 LDFile* file = getFile ("axle.dat"); |
486 setlocale (LC_ALL, "C"); |
486 setlocale (LC_ALL, "C"); |
487 |
487 |
488 if (!file) { |
488 if (!file) { |
489 critical ("couldn't load axle.dat"); |
489 critical ("couldn't load axle.dat"); |
490 return; |
490 return; |