zz_newPartDialog.cpp

changeset 135
c243df39913e
parent 116
4fde8fdf258a
child 136
13db97be14cb
equal deleted inserted replaced
134:7fd0784471df 135:c243df39913e
36 36
37 // ============================================================================= 37 // =============================================================================
38 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * 38 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
39 // ============================================================================= 39 // =============================================================================
40 NewPartDialog::NewPartDialog (QWidget* parent, Qt::WindowFlags f) : QDialog (parent, f) { 40 NewPartDialog::NewPartDialog (QWidget* parent, Qt::WindowFlags f) : QDialog (parent, f) {
41 qLB_Icon = new QLabel; 41 lb_brickIcon = new QLabel;
42 qLB_Icon->setPixmap (QPixmap ("icons/brick.png")); 42 lb_brickIcon->setPixmap (QPixmap ("icons/brick.png"));
43 43
44 qLB_NameLabel = new QLabel ("Name:"); 44 lb_name = new QLabel ("Name:");
45 qLE_Name = new QLineEdit; 45 le_name = new QLineEdit;
46 qLE_Name->setMinimumWidth (320); 46 le_name->setMinimumWidth (320);
47 47
48 qLB_AuthorLabel = new QLabel ("Author:"); 48 lb_author = new QLabel ("Author:");
49 qLE_Author = new QLineEdit; 49 le_author = new QLineEdit;
50 50
51 qLB_LicenseLabel = new QLabel ("License:"); 51 lb_license = new QLabel ("License:");
52 qCB_LicenseBox = new QComboBox; 52 qCB_LicenseBox = new QComboBox;
53 qCB_LicenseBox->addItems ({ 53 qCB_LicenseBox->addItems ({
54 "CCAL Redistributable", 54 "CCAL Redistributable",
55 "Non-redistributable", 55 "Non-redistributable",
56 "[none]", 56 "[none]",
57 }); 57 });
58 58
59 qLB_BFCLabel = new QLabel ("BFC:"); 59 lb_BFC = new QLabel ("BFC:");
60 qCB_BFCBox = new QComboBox; 60 qCB_BFCBox = new QComboBox;
61 qCB_BFCBox->addItems ({ 61 qCB_BFCBox->addItems ({
62 "CCW", 62 "CCW",
63 "CW", 63 "CW",
64 "No winding" 64 "No winding"
65 }); 65 });
66 66
67 IMPLEMENT_DIALOG_BUTTONS 67 IMPLEMENT_DIALOG_BUTTONS
68 68
69 QGridLayout* layout = new QGridLayout; 69 QGridLayout* layout = new QGridLayout;
70 layout->addWidget (qLB_Icon, 0, 0); 70 layout->addWidget (lb_brickIcon, 0, 0);
71 layout->addWidget (qLB_NameLabel, 0, 1); 71 layout->addWidget (lb_name, 0, 1);
72 layout->addWidget (qLE_Name, 0, 2); 72 layout->addWidget (le_name, 0, 2);
73 layout->addWidget (qLB_AuthorLabel, 1, 1); 73 layout->addWidget (lb_author, 1, 1);
74 layout->addWidget (qLE_Author, 1, 2); 74 layout->addWidget (le_author, 1, 2);
75 layout->addWidget (qLB_LicenseLabel, 2, 1); 75 layout->addWidget (lb_license, 2, 1);
76 layout->addWidget (qCB_LicenseBox, 2, 2); 76 layout->addWidget (qCB_LicenseBox, 2, 2);
77 layout->addWidget (qLB_BFCLabel, 3, 1); 77 layout->addWidget (lb_BFC, 3, 1);
78 layout->addWidget (qCB_BFCBox, 3, 2); 78 layout->addWidget (qCB_BFCBox, 3, 2);
79 layout->addWidget (qButtons, 4, 2); 79 layout->addWidget (bbx_buttons, 4, 2);
80 80
81 setLayout (layout); 81 setLayout (layout);
82 setWindowIcon (QIcon ("icons/brick.png")); 82 setWindowIcon (QIcon ("icons/brick.png"));
83 setWindowTitle (APPNAME_DISPLAY " - new part"); 83 setWindowTitle (APPNAME_DISPLAY " - new part");
84 } 84 }
90 NewPartDialog dlg (g_ForgeWindow); 90 NewPartDialog dlg (g_ForgeWindow);
91 if (dlg.exec ()) { 91 if (dlg.exec ()) {
92 newFile (); 92 newFile ();
93 93
94 short idx; 94 short idx;
95 str zAuthor = dlg.qLE_Author->text (); 95 str zAuthor = dlg.le_author->text ();
96 vector<LDObject*>& objs = g_CurrentFile->objects; 96 vector<LDObject*>& objs = g_CurrentFile->objects;
97 97
98 idx = dlg.qCB_BFCBox->currentIndex (); 98 idx = dlg.qCB_BFCBox->currentIndex ();
99 const LDBFC::Type eBFCType = 99 const LDBFC::Type eBFCType =
100 (idx == BFCBOX_CCW) ? LDBFC::CertifyCCW : 100 (idx == BFCBOX_CCW) ? LDBFC::CertifyCCW :
105 const char* sLicense = 105 const char* sLicense =
106 (idx == LICENSE_CCAL) ? "Redistributable under CCAL version 2.0 : see CAreadme.txt" : 106 (idx == LICENSE_CCAL) ? "Redistributable under CCAL version 2.0 : see CAreadme.txt" :
107 (idx == LICENSE_NonCA) ? "Not redistributable : see NonCAreadme.txt" : 107 (idx == LICENSE_NonCA) ? "Not redistributable : see NonCAreadme.txt" :
108 null; 108 null;
109 109
110 objs.push_back (new LDComment (dlg.qLE_Name->text ())); 110 objs.push_back (new LDComment (dlg.le_name->text ()));
111 objs.push_back (new LDComment ("Name: <untitled>.dat")); 111 objs.push_back (new LDComment ("Name: <untitled>.dat"));
112 objs.push_back (new LDComment (format ("Author: %s", zAuthor.chars()))); 112 objs.push_back (new LDComment (format ("Author: %s", zAuthor.chars())));
113 objs.push_back (new LDComment (format ("!LDRAW_ORG Unofficial_Part"))); 113 objs.push_back (new LDComment (format ("!LDRAW_ORG Unofficial_Part")));
114 114
115 if (sLicense != null) 115 if (sLicense != null)

mercurial