src/dialogs.cpp

changeset 199
10dd5909a50e
parent 198
f246725199dc
child 200
5583af82087e
equal deleted inserted replaced
198:f246725199dc 199:10dd5909a50e
27 #include "dialogs.h" 27 #include "dialogs.h"
28 #include "radiobox.h" 28 #include "radiobox.h"
29 #include "gui.h" 29 #include "gui.h"
30 #include "gldraw.h" 30 #include "gldraw.h"
31 #include "docs.h" 31 #include "docs.h"
32 #include "checkboxgroup.h"
32 #include "dialogs.h" 33 #include "dialogs.h"
33 34
34 // ============================================================================= 35 // =============================================================================
35 OverlayDialog::OverlayDialog (QWidget* parent, Qt::WindowFlags f) : QDialog (parent, f) { 36 OverlayDialog::OverlayDialog (QWidget* parent, Qt::WindowFlags f) : QDialog (parent, f) {
36 rb_camera = new RadioBox ("Camera", {}, 0, Qt::Horizontal, this); 37 rb_camera = new RadioBox ("Camera", {}, 0, Qt::Horizontal, this);
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 }

mercurial