src/actions/MainActions.cc

changeset 644
93dcd1a0e4bd
parent 642
751a8df42842
child 697
2766f7b037ad
equal deleted inserted replaced
643:a79277000830 644:93dcd1a0e4bd
53 ui.setupUi (dlg); 53 ui.setupUi (dlg);
54 54
55 QString authortext = ld_defaultname; 55 QString authortext = ld_defaultname;
56 56
57 if (!ld_defaultuser.isEmpty()) 57 if (!ld_defaultuser.isEmpty())
58 authortext.append (fmt (" [%1]", ld_defaultuser)); 58 authortext.append (format (" [%1]", ld_defaultuser));
59 59
60 ui.le_author->setText (authortext); 60 ui.le_author->setText (authortext);
61 61
62 switch (ld_defaultlicense) 62 switch (ld_defaultlicense)
63 { 63 {
73 ui.rb_license_none->setChecked (true); 73 ui.rb_license_none->setChecked (true);
74 break; 74 break;
75 75
76 default: 76 default:
77 QMessageBox::warning (null, "Warning", 77 QMessageBox::warning (null, "Warning",
78 fmt ("Unknown ld_defaultlicense value %1!", ld_defaultlicense)); 78 format ("Unknown ld_defaultlicense value %1!", ld_defaultlicense));
79 break; 79 break;
80 } 80 }
81 81
82 if (dlg->exec() == false) 82 if (dlg->exec() == false)
83 return; 83 return;
94 94
95 getCurrentDocument()->addObjects ( 95 getCurrentDocument()->addObjects (
96 { 96 {
97 new LDComment (ui.le_title->text()), 97 new LDComment (ui.le_title->text()),
98 new LDComment ("Name: <untitled>.dat"), 98 new LDComment ("Name: <untitled>.dat"),
99 new LDComment (fmt ("Author: %1", ui.le_author->text())), 99 new LDComment (format ("Author: %1", ui.le_author->text())),
100 new LDComment (fmt ("!LDRAW_ORG Unofficial_Part")), 100 new LDComment (format ("!LDRAW_ORG Unofficial_Part")),
101 (license != "" ? new LDComment (license) : null), 101 (license != "" ? new LDComment (license) : null),
102 new LDEmpty, 102 new LDEmpty,
103 new LDBFC (BFCType), 103 new LDBFC (BFCType),
104 new LDEmpty, 104 new LDEmpty,
105 }); 105 });
390 390
391 QFile f (fname); 391 QFile f (fname);
392 392
393 if (!f.open (QIODevice::ReadOnly)) 393 if (!f.open (QIODevice::ReadOnly))
394 { 394 {
395 critical (fmt ("Couldn't open %1 (%2)", fname, f.errorString())); 395 critical (format ("Couldn't open %1 (%2)", fname, f.errorString()));
396 return; 396 return;
397 } 397 }
398 398
399 LDObjectList objs = loadFileContents (&f, null); 399 LDObjectList objs = loadFileContents (&f, null);
400 400
427 427
428 QFile file (fname); 428 QFile file (fname);
429 429
430 if (!file.open (QIODevice::WriteOnly | QIODevice::Text)) 430 if (!file.open (QIODevice::WriteOnly | QIODevice::Text))
431 { 431 {
432 critical (fmt ("Unable to open %1 for writing (%2)", fname, file.errorString())); 432 critical (format ("Unable to open %1 for writing (%2)", fname, file.errorString()));
433 return; 433 return;
434 } 434 }
435 435
436 for (LDObject* obj : selection()) 436 for (LDObject* obj : selection())
437 { 437 {
492 QString root = basename (getCurrentDocument()->name()); 492 QString root = basename (getCurrentDocument()->name());
493 493
494 if (root.right (4) == ".dat") 494 if (root.right (4) == ".dat")
495 root.chop (4); 495 root.chop (4);
496 496
497 QString defaultname = (root.length() > 0) ? fmt ("%1.png", root) : ""; 497 QString defaultname = (root.length() > 0) ? format ("%1.png", root) : "";
498 QString fname = QFileDialog::getSaveFileName (g_win, "Save Screencap", defaultname, 498 QString fname = QFileDialog::getSaveFileName (g_win, "Save Screencap", defaultname,
499 "PNG images (*.png);;JPG images (*.jpg);;BMP images (*.bmp);;All Files (*.*)"); 499 "PNG images (*.png);;JPG images (*.jpg);;BMP images (*.bmp);;All Files (*.*)");
500 500
501 if (fname.length() > 0 && !img.save (fname)) 501 if (fname.length() > 0 && !img.save (fname))
502 critical (fmt ("Couldn't open %1 for writing to save screencap: %2", fname, strerror (errno))); 502 critical (format ("Couldn't open %1 for writing to save screencap: %2", fname, strerror (errno)));
503 503
504 delete[] imgdata; 504 delete[] imgdata;
505 } 505 }
506 506
507 // ============================================================================= 507 // =============================================================================
607 if (R()->camera() == GL::EFreeCamera) 607 if (R()->camera() == GL::EFreeCamera)
608 return; 608 return;
609 609
610 bool ok; 610 bool ok;
611 double depth = QInputDialog::getDouble (g_win, "Set Draw Depth", 611 double depth = QInputDialog::getDouble (g_win, "Set Draw Depth",
612 fmt ("Depth value for %1 Camera:", R()->getCameraName()), 612 format ("Depth value for %1 Camera:", R()->getCameraName()),
613 R()->getDepthValue(), -10000.0f, 10000.0f, 3, &ok); 613 R()->getDepthValue(), -10000.0f, 10000.0f, 3, &ok);
614 614
615 if (ok) 615 if (ok)
616 R()->setDepthValue (depth); 616 R()->setDepthValue (depth);
617 } 617 }
752 752
753 if (topdirname != "s") 753 if (topdirname != "s")
754 { 754 {
755 QString desiredPath = subdirname + "/s"; 755 QString desiredPath = subdirname + "/s";
756 QString title = tr ("Create subfile directory?"); 756 QString title = tr ("Create subfile directory?");
757 QString text = fmt (tr ("The directory <b>%1</b> is suggested for " 757 QString text = format (tr ("The directory <b>%1</b> is suggested for "
758 "subfiles. This directory does not exist, create it?"), desiredPath); 758 "subfiles. This directory does not exist, create it?"), desiredPath);
759 759
760 if (QDir (desiredPath).exists() || confirm (title, text)) 760 if (QDir (desiredPath).exists() || confirm (title, text))
761 { 761 {
762 subdirname = desiredPath; 762 subdirname = desiredPath;
822 doc->setName (LDDocument::shortenName (fullsubname)); 822 doc->setName (LDDocument::shortenName (fullsubname));
823 doc->addObjects ( 823 doc->addObjects (
824 { 824 {
825 new LDComment (subtitle), 825 new LDComment (subtitle),
826 new LDComment ("Name: "), 826 new LDComment ("Name: "),
827 new LDComment (fmt ("Author: %1 [%2]", ld_defaultname, ld_defaultuser)), 827 new LDComment (format ("Author: %1 [%2]", ld_defaultname, ld_defaultuser)),
828 new LDComment (fmt ("!LDRAW_ORG Unofficial_Subpart")), 828 new LDComment (format ("!LDRAW_ORG Unofficial_Subpart")),
829 (license != "" ? new LDComment (license) : null), 829 (license != "" ? new LDComment (license) : null),
830 new LDEmpty, 830 new LDEmpty,
831 new LDBFC (bfctype), 831 new LDBFC (bfctype),
832 new LDEmpty, 832 new LDEmpty,
833 }); 833 });

mercurial