zz_setContentsDialog.cpp

changeset 135
c243df39913e
parent 125
7ee7aa5e28be
child 158
499286fcbf37
equal deleted inserted replaced
134:7fd0784471df 135:c243df39913e
27 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * 27 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
28 // ============================================================================= 28 // =============================================================================
29 SetContentsDialog::SetContentsDialog (LDObject* obj, QWidget* parent) : QDialog(parent) { 29 SetContentsDialog::SetContentsDialog (LDObject* obj, QWidget* parent) : QDialog(parent) {
30 setWindowTitle (APPNAME_DISPLAY ": Set Contents"); 30 setWindowTitle (APPNAME_DISPLAY ": Set Contents");
31 31
32 qContentsLabel = new QLabel ("Set contents:", parent); 32 lb_contents = new QLabel ("Set contents:", parent);
33 33
34 qContents = new QLineEdit (parent); 34 le_contents = new QLineEdit (parent);
35 qContents->setText (obj->getContents ().chars()); 35 le_contents->setText (obj->getContents ().chars());
36 qContents->setWhatsThis ("The LDraw code of this object. The code written " 36 le_contents->setWhatsThis ("The LDraw code of this object. The code written "
37 "here is expected to be valid LDraw code, invalid code here results " 37 "here is expected to be valid LDraw code, invalid code here results "
38 "the object being turned into an error object. Please do refer to the " 38 "the object being turned into an error object. Please do refer to the "
39 "<a href=\"http://www.ldraw.org/article/218.html\">official file format " 39 "<a href=\"http://www.ldraw.org/article/218.html\">official file format "
40 "standard</a> for further information."); 40 "standard</a> for further information.");
41 qContents->setMinimumWidth (384); 41 le_contents->setMinimumWidth (384);
42 42
43 if (obj->getType() == OBJ_Gibberish) { 43 if (obj->getType() == OBJ_Gibberish) {
44 qErrorLabel = new QLabel; 44 lb_error = new QLabel;
45 qErrorLabel->setText (format ("<span style=\"color: #900\">%s</span>", 45 lb_error->setText (format ("<span style=\"color: #900\">%s</span>",
46 static_cast<LDGibberish*> (obj)->zReason.chars())); 46 static_cast<LDGibberish*> (obj)->zReason.chars()));
47 47
48 QPixmap qErrorPixmap = QPixmap ("icons/error.png").scaledToHeight (16); 48 QPixmap qErrorPixmap = QPixmap ("icons/error.png").scaledToHeight (16);
49 49
50 qErrorIcon = new QLabel; 50 lb_errorIcon = new QLabel;
51 qErrorIcon->setPixmap (qErrorPixmap); 51 lb_errorIcon->setPixmap (qErrorPixmap);
52 } 52 }
53 53
54 IMPLEMENT_DIALOG_BUTTONS 54 IMPLEMENT_DIALOG_BUTTONS
55 55
56 QVBoxLayout* layout = new QVBoxLayout; 56 QVBoxLayout* layout = new QVBoxLayout;
57 layout->addWidget (qContentsLabel); 57 layout->addWidget (lb_contents);
58 layout->addWidget (qContents); 58 layout->addWidget (le_contents);
59 59
60 QHBoxLayout* layout2 = new QHBoxLayout; 60 QHBoxLayout* layout2 = new QHBoxLayout;
61 61
62 if (obj->getType() == OBJ_Gibberish) { 62 if (obj->getType() == OBJ_Gibberish) {
63 layout2->addWidget (qErrorIcon); 63 layout2->addWidget (lb_errorIcon);
64 layout2->addWidget (qErrorLabel); 64 layout2->addWidget (lb_error);
65 } 65 }
66 66
67 layout2->addWidget (qButtons); 67 layout2->addWidget (bbx_buttons);
68 layout->addLayout (layout2); 68 layout->addLayout (layout2);
69 setLayout (layout); 69 setLayout (layout);
70 70
71 setWindowTitle (APPNAME_DISPLAY " - setting contents"); 71 setWindowTitle (APPNAME_DISPLAY " - setting contents");
72 setWindowIcon (QIcon ("icons/set-contents.png")); 72 setWindowIcon (QIcon ("icons/set-contents.png"));
91 return; 91 return;
92 92
93 LDObject* oldobj = obj; 93 LDObject* oldobj = obj;
94 94
95 // Reinterpret it from the text of the input field 95 // Reinterpret it from the text of the input field
96 obj = parseLine (dlg.qContents->text ().toStdString ().c_str ()); 96 obj = parseLine (dlg.le_contents->text ().toStdString ().c_str ());
97 97
98 // Mark down the history now before we perform the replacement (which 98 // Mark down the history now before we perform the replacement (which
99 // destroys the old object) 99 // destroys the old object)
100 History::addEntry (new EditHistory ({(ulong) oldobj->getIndex (g_CurrentFile)}, 100 History::addEntry (new EditHistory ({(ulong) oldobj->getIndex (g_CurrentFile)},
101 {oldobj->clone ()}, {obj->clone ()})); 101 {oldobj->clone ()}, {obj->clone ()}));

mercurial