src/gui_editactions.cpp

changeset 330
76505a9c7b56
parent 329
76db02dc7f60
child 344
55fcf67230fd
equal deleted inserted replaced
329:76db02dc7f60 330:76505a9c7b56
30 #include "extprogs.h" 30 #include "extprogs.h"
31 #include "gldraw.h" 31 #include "gldraw.h"
32 #include "dialogs.h" 32 #include "dialogs.h"
33 #include "colors.h" 33 #include "colors.h"
34 #include "ui_replcoords.h" 34 #include "ui_replcoords.h"
35 #include "ui_editraw.h"
35 36
36 vector<str> g_Clipboard; 37 vector<str> g_Clipboard;
37 38
38 cfg (bool, edit_schemanticinline, false); 39 cfg (bool, edit_schemanticinline, false);
39 40
167 } 168 }
168 169
169 // ============================================================================= 170 // =============================================================================
170 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * 171 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
171 // ============================================================================= 172 // =============================================================================
172 MAKE_ACTION (setContents, "Edit LDraw Code", "set-contents", "Edit the LDraw code of this object.", KEY (F9)) { 173 MAKE_ACTION( setContents, "Edit LDraw Code", "set-contents", "Edit the LDraw code of this object.", KEY( F9 ))
173 if (g_win->sel ().size() != 1) 174 {
175 if( g_win->sel().size() != 1 )
174 return; 176 return;
175 177
176 LDObject* obj = g_win->sel ()[0]; 178 LDObject* obj = g_win->sel()[0];
177 179 QDialog* dlg = new QDialog;
178 SetContentsDialog dlg; 180 Ui::EditRawUI ui;
179 dlg.setObject (obj); 181
180 if (!dlg.exec ()) 182 ui.setupUi( dlg );
183 ui.code->setText( obj->raw() );
184
185 if( obj->getType() == LDObject::Gibberish )
186 ui.errorDescription->setText( static_cast<LDGibberish*>( obj )->reason );
187 else
188 {
189 ui.errorDescription->hide();
190 ui.errorIcon->hide();
191 }
192
193 if( !dlg->exec() )
181 return; 194 return;
182 195
183 LDObject* oldobj = obj; 196 LDObject* oldobj = obj;
184 197
185 // Reinterpret it from the text of the input field 198 // Reinterpret it from the text of the input field
186 obj = parseLine (dlg.text ()); 199 obj = parseLine( ui.code->text() );
187 200 oldobj->replace( obj );
188 oldobj->replace (obj);
189 201
190 // Refresh 202 // Refresh
191 g_win->R ()->compileObject (obj); 203 g_win->R()->compileObject( obj );
192 g_win->refresh (); 204 g_win->refresh();
193 } 205 }
194 206
195 // ============================================================================= 207 // =============================================================================
196 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * 208 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
197 // ============================================================================= 209 // =============================================================================

mercurial