143 |
144 |
144 void OverlayDialog::slot_dimensionsChanged () { |
145 void OverlayDialog::slot_dimensionsChanged () { |
145 bool enable = (dsb_lwidth->value () != 0) || (dsb_lheight->value () != 0); |
146 bool enable = (dsb_lwidth->value () != 0) || (dsb_lheight->value () != 0); |
146 dbb_buttons->button (QDialogButtonBox::Ok)->setEnabled (enable); |
147 dbb_buttons->button (QDialogButtonBox::Ok)->setEnabled (enable); |
147 } |
148 } |
|
149 |
|
150 ReplaceCoordsDialog::ReplaceCoordsDialog (QWidget* parent, Qt::WindowFlags f) : QDialog (parent, f) { |
|
151 cbg_axes = makeAxesBox (); |
|
152 |
|
153 lb_search = new QLabel ("Search:"); |
|
154 lb_replacement = new QLabel ("Replacement:"); |
|
155 |
|
156 dsb_search = new QDoubleSpinBox; |
|
157 dsb_search->setRange (-10000.0f, 10000.0f); |
|
158 |
|
159 dsb_replacement = new QDoubleSpinBox; |
|
160 dsb_replacement->setRange (-10000.0f, 10000.0f); |
|
161 |
|
162 QGridLayout* valueLayout = new QGridLayout; |
|
163 valueLayout->setColumnStretch (1, 1); |
|
164 valueLayout->addWidget (lb_search, 0, 0); |
|
165 valueLayout->addWidget (dsb_search, 0, 1); |
|
166 valueLayout->addWidget (lb_replacement, 1, 0); |
|
167 valueLayout->addWidget (dsb_replacement, 1, 1); |
|
168 |
|
169 QVBoxLayout* layout = new QVBoxLayout; |
|
170 layout->addWidget (cbg_axes); |
|
171 layout->addLayout (valueLayout); |
|
172 layout->addWidget (makeButtonBox (*this)); |
|
173 setLayout (layout); |
|
174 } |
|
175 |
|
176 double ReplaceCoordsDialog::searchValue() const { |
|
177 return dsb_search->value (); |
|
178 } |
|
179 |
|
180 double ReplaceCoordsDialog::replacementValue() const { |
|
181 return dsb_replacement->value (); |
|
182 } |
|
183 |
|
184 vector<Axis> ReplaceCoordsDialog::axes() const { |
|
185 return cbg_axes->checkedValues (); |
|
186 } |
|
187 |
|
188 // ============================================================================= |
|
189 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * |
|
190 // ============================================================================= |
|
191 SetContentsDialog::SetContentsDialog (QWidget* parent, Qt::WindowFlags f) : QDialog (parent, f) { |
|
192 setWindowTitle (APPNAME ": Set Contents"); |
|
193 |
|
194 lb_error = new QLabel; |
|
195 lb_errorIcon = new QLabel; |
|
196 lb_contents = new QLabel ("Set contents:", parent); |
|
197 |
|
198 le_contents = new QLineEdit (parent); |
|
199 le_contents->setWhatsThis ("The LDraw code of this object. The code written " |
|
200 "here is expected to be valid LDraw code, invalid code here results " |
|
201 "the object being turned into an error object. Please do refer to the " |
|
202 "<a href=\"http://www.ldraw.org/article/218.html\">official file format " |
|
203 "standard</a> for further information."); |
|
204 le_contents->setMinimumWidth (384); |
|
205 |
|
206 QHBoxLayout* bottomRow = new QHBoxLayout; |
|
207 bottomRow->addWidget (lb_errorIcon); |
|
208 bottomRow->addWidget (lb_error); |
|
209 bottomRow->addWidget (makeButtonBox (*this)); |
|
210 |
|
211 QVBoxLayout* layout = new QVBoxLayout (this); |
|
212 layout->addWidget (lb_contents); |
|
213 layout->addWidget (le_contents); |
|
214 layout->addLayout (bottomRow); |
|
215 |
|
216 setWindowTitle ("Set Contents"); |
|
217 setWindowIcon (getIcon ("set-contents")); |
|
218 } |
|
219 |
|
220 void SetContentsDialog::setObject (LDObject* obj) { |
|
221 le_contents->setText (obj->getContents ().chars()); |
|
222 |
|
223 if (obj->getType() == LDObject::Gibberish) { |
|
224 lb_error->setText (fmt ("<span style=\"color: #900\">%s</span>", |
|
225 static_cast<LDGibberish*> (obj)->reason.chars())); |
|
226 |
|
227 QPixmap errorPixmap = getIcon ("error").scaledToHeight (16); |
|
228 lb_errorIcon->setPixmap (errorPixmap); |
|
229 } |
|
230 } |
|
231 |
|
232 str SetContentsDialog::text () const { |
|
233 return le_contents->text (); |
|
234 } |