converted the raw edit prompt

Thu, 04 Jul 2013 18:56:34 +0300

author
Santeri Piippo <crimsondusk64@gmail.com>
date
Thu, 04 Jul 2013 18:56:34 +0300
changeset 330
76505a9c7b56
parent 329
76db02dc7f60
child 331
bf301f81a0b6

converted the raw edit prompt

src/gui_editactions.cpp file | annotate | diff | comparison | revisions
src/ui/editraw.ui file | annotate | diff | comparison | revisions
--- a/src/gui_editactions.cpp	Thu Jul 04 18:41:24 2013 +0300
+++ b/src/gui_editactions.cpp	Thu Jul 04 18:56:34 2013 +0300
@@ -32,6 +32,7 @@
 #include "dialogs.h"
 #include "colors.h"
 #include "ui_replcoords.h"
+#include "ui_editraw.h"
 
 vector<str> g_Clipboard;
 
@@ -169,27 +170,38 @@
 // =============================================================================
 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
 // =============================================================================
-MAKE_ACTION (setContents, "Edit LDraw Code", "set-contents", "Edit the LDraw code of this object.", KEY (F9)) {
-	if (g_win->sel ().size() != 1)
+MAKE_ACTION( setContents, "Edit LDraw Code", "set-contents", "Edit the LDraw code of this object.", KEY( F9 ))
+{
+	if( g_win->sel().size() != 1 )
 		return;
 	
-	LDObject* obj = g_win->sel ()[0];
+	LDObject* obj = g_win->sel()[0];
+	QDialog* dlg = new QDialog;
+	Ui::EditRawUI ui;
+	
+	ui.setupUi( dlg );
+	ui.code->setText( obj->raw() );
 	
-	SetContentsDialog dlg;
-	dlg.setObject (obj);
-	if (!dlg.exec ())
+	if( obj->getType() == LDObject::Gibberish )
+		ui.errorDescription->setText( static_cast<LDGibberish*>( obj )->reason );
+	else
+	{
+		ui.errorDescription->hide();
+		ui.errorIcon->hide();
+	}
+	
+	if( !dlg->exec() )
 		return;
 	
 	LDObject* oldobj = obj;
 	
 	// Reinterpret it from the text of the input field
-	obj = parseLine (dlg.text ());
-	
-	oldobj->replace (obj);
+	obj = parseLine( ui.code->text() );
+	oldobj->replace( obj );
 	
 	// Refresh
-	g_win->R ()->compileObject (obj);
-	g_win->refresh ();
+	g_win->R()->compileObject( obj );
+	g_win->refresh();
 }
 
 // =============================================================================
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/ui/editraw.ui	Thu Jul 04 18:56:34 2013 +0300
@@ -0,0 +1,112 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<ui version="4.0">
+ <class>EditRawUI</class>
+ <widget class="QDialog" name="EditRawUI">
+  <property name="geometry">
+   <rect>
+    <x>0</x>
+    <y>0</y>
+    <width>400</width>
+    <height>85</height>
+   </rect>
+  </property>
+  <property name="windowTitle">
+   <string>Edit LDraw Code</string>
+  </property>
+  <layout class="QVBoxLayout" name="verticalLayout">
+   <item>
+    <widget class="QLabel" name="label">
+     <property name="text">
+      <string>LDraw code:</string>
+     </property>
+    </widget>
+   </item>
+   <item>
+    <widget class="QLineEdit" name="code"/>
+   </item>
+   <item>
+    <layout class="QHBoxLayout" name="horizontalLayout">
+     <item>
+      <widget class="QLabel" name="errorIcon">
+       <property name="maximumSize">
+        <size>
+         <width>16</width>
+         <height>16</height>
+        </size>
+       </property>
+       <property name="text">
+        <string/>
+       </property>
+       <property name="pixmap">
+        <pixmap resource="../../ldforge.qrc">:/icons/error.png</pixmap>
+       </property>
+       <property name="scaledContents">
+        <bool>true</bool>
+       </property>
+      </widget>
+     </item>
+     <item>
+      <widget class="QLabel" name="errorDescription">
+       <property name="enabled">
+        <bool>true</bool>
+       </property>
+       <property name="styleSheet">
+        <string notr="true">color: #900</string>
+       </property>
+       <property name="text">
+        <string>Error description</string>
+       </property>
+      </widget>
+     </item>
+     <item>
+      <widget class="QDialogButtonBox" name="buttonBox">
+       <property name="orientation">
+        <enum>Qt::Horizontal</enum>
+       </property>
+       <property name="standardButtons">
+        <set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set>
+       </property>
+      </widget>
+     </item>
+    </layout>
+   </item>
+  </layout>
+ </widget>
+ <resources>
+  <include location="../../ldforge.qrc"/>
+ </resources>
+ <connections>
+  <connection>
+   <sender>buttonBox</sender>
+   <signal>accepted()</signal>
+   <receiver>EditRawUI</receiver>
+   <slot>accept()</slot>
+   <hints>
+    <hint type="sourcelabel">
+     <x>248</x>
+     <y>254</y>
+    </hint>
+    <hint type="destinationlabel">
+     <x>157</x>
+     <y>274</y>
+    </hint>
+   </hints>
+  </connection>
+  <connection>
+   <sender>buttonBox</sender>
+   <signal>rejected()</signal>
+   <receiver>EditRawUI</receiver>
+   <slot>reject()</slot>
+   <hints>
+    <hint type="sourcelabel">
+     <x>316</x>
+     <y>260</y>
+    </hint>
+    <hint type="destinationlabel">
+     <x>286</x>
+     <y>274</y>
+    </hint>
+   </hints>
+  </connection>
+ </connections>
+</ui>

mercurial