UI-ified the new part prompt

Tue, 02 Jul 2013 01:42:43 +0300

author
Santeri Piippo <crimsondusk64@gmail.com>
date
Tue, 02 Jul 2013 01:42:43 +0300
changeset 315
cb0c23f35e2b
parent 314
fd3711a5457a
child 316
b4fefda58f43

UI-ified the new part prompt

changelog.txt file | annotate | diff | comparison | revisions
src/dialogs.cpp file | annotate | diff | comparison | revisions
src/dialogs.h file | annotate | diff | comparison | revisions
src/gui_actions.cpp file | annotate | diff | comparison | revisions
src/ui/makeprim.ui file | annotate | diff | comparison | revisions
src/ui/newpart.ui file | annotate | diff | comparison | revisions
--- a/changelog.txt	Tue Jul 02 00:31:40 2013 +0300
+++ b/changelog.txt	Tue Jul 02 01:42:43 2013 +0300
@@ -5,7 +5,6 @@
 - Completely rewrote history (undo/redo) code, making it a LOT stabler in the process.
 - Added ability to snap to pre-existing vertices while drawing.
 - Replaced the radial type with a single action to generate primitives.
-- When drawing, drawn vertices now display coordinate labels.
 - Replaced parts list in subfile item list with a primitive listing. Listing is generated either if
 	it's not cached (prims.cfg in configuration directory) or on user demand. Primitives can be categorised
 	with the use of a regex-based configuration file, with a valid default which should cater to most users.
@@ -13,6 +12,7 @@
 - Parts are now zoomed to fit properly, making the initial view of the part clearer.
 - Replace coords: allow replacing all coords regardless of original value, plus relative moving (offset)
 - Objects can now be edited by double-clicking on them.
+- When drawing, drawn vertices now display coordinate labels.
 - Changed default keys for Y-axis moving from PgUp/PgDown to Home and End ala MLCAD.
 - [Linux] External programs can now be launched with Wine.
 - Improved external program fault handling: don't try to replace/append the output in case of failure, catch non-zero exit codes.
--- a/src/dialogs.cpp	Tue Jul 02 00:31:40 2013 +0300
+++ b/src/dialogs.cpp	Tue Jul 02 01:42:43 2013 +0300
@@ -351,89 +351,6 @@
 // =============================================================================
 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
 // =============================================================================
-NewPartDialog::NewPartDialog (QWidget* parent, Qt::WindowFlags f) : QDialog (parent, f) {
-	lb_brickIcon = new QLabel;
-	lb_brickIcon->setPixmap (getIcon ("brick"));
-	
-	lb_name = new QLabel ("Title:");
-	le_name = new QLineEdit;
-	le_name->setMinimumWidth (384);
-	
-	lb_author = new QLabel ("Author:");
-	le_author = new QLineEdit;
-	
-	rb_license = new RadioBox ("License", {
-		"CCAL Redistributable",
-		"Non-redistributable",
-		"None",
-	}, CCAL);
-	
-	rb_BFC = new RadioBox ("BFC Winding", {
-		"CCW",
-		"CW",
-		"None"
-	}, CCW);
-	
-	QHBoxLayout* boxes = new QHBoxLayout;
-	boxes->addWidget (rb_license);
-	boxes->addWidget (rb_BFC);
-	
-	QGridLayout* layout = new QGridLayout;
-	layout->addWidget (lb_brickIcon, 0, 0);
-	layout->addWidget (lb_name, 0, 1);
-	layout->addWidget (le_name, 0, 2);
-	layout->addWidget (lb_author, 1, 1);
-	layout->addWidget (le_author, 1, 2);
-	layout->addLayout (boxes, 2, 1, 1, 2);
-	layout->addWidget (makeButtonBox (*this), 3, 2);
-	
-	setLayout (layout);
-	setWindowTitle ("New Part");
-}
-
-// =============================================================================
-// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
-// =============================================================================
-void NewPartDialog::StaticDialog () {
-	NewPartDialog dlg (g_win);
-	if (dlg.exec () == false)
-		return;
-	
-	newFile ();
-	
-	short idx;
-	str author = dlg.le_author->text ();
-	
-	idx = dlg.rb_BFC->value ();
-	const LDBFC::Type BFCType =
-		(idx == CCW) ? LDBFC::CertifyCCW :
-		(idx == CW) ? LDBFC::CertifyCW :
-		LDBFC::NoCertify;
-	
-	idx = dlg.rb_license->value ();
-	const str license =
-		(idx == CCAL) ? CALicense :
-		(idx == NonCA) ? NonCALicense :
-		"";
-	
-	*g_curfile << new LDComment (dlg.le_name->text ());
-	*g_curfile << new LDComment ("Name: <untitled>.dat");
-	*g_curfile << new LDComment (fmt ("Author: %1", author));
-	*g_curfile << new LDComment (fmt ("!LDRAW_ORG Unofficial_Part"));
-	
-	if( license != "" )
-		*g_curfile << new LDComment ( license );
-	
-	*g_curfile << new LDEmpty;
-	*g_curfile << new LDBFC (BFCType);
-	*g_curfile << new LDEmpty;
-	
-	g_win->fullRefresh ();
-}
-
-// =============================================================================
-// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
-// =============================================================================
 RotationPointDialog::RotationPointDialog (QWidget* parent, Qt::WindowFlags f) : QDialog (parent, f) {
 	rb_rotpoint = new RadioBox ("Rotation Point", { "Object center", "Custom" }, 0, Qt::Vertical, this);
 	connect (rb_rotpoint, SIGNAL (valueChanged (int)), this, SLOT (radioBoxChanged ()));
--- a/src/dialogs.h	Tue Jul 02 00:31:40 2013 +0300
+++ b/src/dialogs.h	Tue Jul 02 01:42:43 2013 +0300
@@ -131,20 +131,6 @@
 };
 
 // =============================================================================
-class NewPartDialog : public QDialog {
-public:
-	enum { CCAL, NonCA, NoLicense };
-	enum { CCW, CW, NoWinding };
-	
-	explicit NewPartDialog (QWidget* parent = null, Qt::WindowFlags f = 0);
-	static void StaticDialog ();
-	
-	QLabel* lb_brickIcon, *lb_name, *lb_author, *lb_license, *lb_BFC;
-	QLineEdit* le_name, *le_author;
-	RadioBox* rb_license, *rb_BFC;
-};
-
-// =============================================================================
 class RotationPointDialog : public QDialog {
 	Q_OBJECT
 	
--- a/src/gui_actions.cpp	Tue Jul 02 00:31:40 2013 +0300
+++ b/src/gui_actions.cpp	Tue Jul 02 01:42:43 2013 +0300
@@ -34,6 +34,7 @@
 #include "gldraw.h"
 #include "dialogs.h"
 #include "primitives.h"
+#include "ui_newpart.h"
 
 extern_cfg (bool, gl_wireframe);
 
@@ -44,7 +45,38 @@
 	if (safeToCloseAll () == false)
 		return;
 	
-	NewPartDialog::StaticDialog ();
+	QDialog* dlg = new QDialog( g_win );
+	Ui::NewPartUI ui;
+	ui.setupUi( dlg );
+	
+	if (dlg->exec () == false)
+		return;
+	
+	newFile ();
+	
+	const LDBFC::Type BFCType =
+		ui.rb_bfc_ccw->isChecked() ? LDBFC::CertifyCCW :
+		ui.rb_bfc_cw->isChecked()  ? LDBFC::CertifyCW :
+		                             LDBFC::NoCertify;
+	
+	const str license =
+		ui.rb_license_ca->isChecked()    ? CALicense :
+		ui.rb_license_nonca->isChecked() ? NonCALicense :
+		                                   "";
+	
+	*g_curfile << new LDComment( ui.le_title->text() );
+	*g_curfile << new LDComment( "Name: <untitled>.dat" );
+	*g_curfile << new LDComment( fmt( "Author: %1", ui.le_author->text() ));
+	*g_curfile << new LDComment( fmt( "!LDRAW_ORG Unofficial_Part" ));
+	
+	if( license != "" )
+		*g_curfile << new LDComment( license );
+	
+	*g_curfile << new LDEmpty;
+	*g_curfile << new LDBFC( BFCType );
+	*g_curfile << new LDEmpty;
+	
+	g_win->fullRefresh();
 }
 
 // =============================================================================
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/ui/makeprim.ui	Tue Jul 02 01:42:43 2013 +0300
@@ -0,0 +1,309 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<ui version="4.0">
+ <class>MakePrimUI</class>
+ <widget class="QDialog" name="MakePrimUI">
+  <property name="geometry">
+   <rect>
+    <x>0</x>
+    <y>0</y>
+    <width>336</width>
+    <height>147</height>
+   </rect>
+  </property>
+  <property name="windowTitle">
+   <string>Generate a Primitive</string>
+  </property>
+  <layout class="QVBoxLayout" name="verticalLayout">
+   <item>
+    <layout class="QHBoxLayout" name="horizontalLayout" stretch="0,0">
+     <item>
+      <layout class="QVBoxLayout" name="verticalLayout_6">
+       <item>
+        <widget class="QGroupBox" name="gb_type">
+         <property name="sizePolicy">
+          <sizepolicy hsizetype="Preferred" vsizetype="Preferred">
+           <horstretch>0</horstretch>
+           <verstretch>0</verstretch>
+          </sizepolicy>
+         </property>
+         <property name="title">
+          <string>Type</string>
+         </property>
+         <layout class="QGridLayout" name="gridLayout_3">
+          <item row="1" column="0">
+           <widget class="QRadioButton" name="rb_circle">
+            <property name="text">
+             <string>Circle</string>
+            </property>
+            <property name="checked">
+             <bool>true</bool>
+            </property>
+            <property name="autoRepeat">
+             <bool>false</bool>
+            </property>
+           </widget>
+          </item>
+          <item row="1" column="1">
+           <widget class="QRadioButton" name="rb_cylinder">
+            <property name="text">
+             <string>Cylinder</string>
+            </property>
+           </widget>
+          </item>
+          <item row="2" column="0">
+           <widget class="QRadioButton" name="rb_disc">
+            <property name="text">
+             <string>Disc</string>
+            </property>
+           </widget>
+          </item>
+          <item row="2" column="1">
+           <widget class="QRadioButton" name="rb_ndisc">
+            <property name="text">
+             <string>Disc Negative</string>
+            </property>
+           </widget>
+          </item>
+          <item row="3" column="0">
+           <widget class="QRadioButton" name="rb_ring">
+            <property name="text">
+             <string>Ring</string>
+            </property>
+           </widget>
+          </item>
+          <item row="3" column="1">
+           <widget class="QRadioButton" name="rb_cone">
+            <property name="text">
+             <string>Cone</string>
+            </property>
+           </widget>
+          </item>
+         </layout>
+        </widget>
+       </item>
+      </layout>
+     </item>
+     <item>
+      <layout class="QVBoxLayout" name="verticalLayout_2">
+       <item>
+        <spacer name="verticalSpacer_2">
+         <property name="orientation">
+          <enum>Qt::Vertical</enum>
+         </property>
+         <property name="sizeHint" stdset="0">
+          <size>
+           <width>20</width>
+           <height>40</height>
+          </size>
+         </property>
+        </spacer>
+       </item>
+       <item>
+        <widget class="QCheckBox" name="cb_hires">
+         <property name="text">
+          <string>Hi-res</string>
+         </property>
+        </widget>
+       </item>
+       <item>
+        <layout class="QGridLayout" name="gridLayout_2">
+         <item row="0" column="0">
+          <widget class="QLabel" name="label">
+           <property name="text">
+            <string>Segments:</string>
+           </property>
+          </widget>
+         </item>
+         <item row="1" column="0">
+          <widget class="QLabel" name="label_2">
+           <property name="text">
+            <string>Ring number:</string>
+           </property>
+          </widget>
+         </item>
+         <item row="0" column="1">
+          <widget class="QSpinBox" name="sb_segs">
+           <property name="minimum">
+            <number>1</number>
+           </property>
+           <property name="maximum">
+            <number>16</number>
+           </property>
+           <property name="value">
+            <number>16</number>
+           </property>
+          </widget>
+         </item>
+         <item row="1" column="1">
+          <widget class="QSpinBox" name="sb_ringnum">
+           <property name="enabled">
+            <bool>false</bool>
+           </property>
+          </widget>
+         </item>
+        </layout>
+       </item>
+       <item>
+        <spacer name="verticalSpacer">
+         <property name="orientation">
+          <enum>Qt::Vertical</enum>
+         </property>
+         <property name="sizeHint" stdset="0">
+          <size>
+           <width>20</width>
+           <height>40</height>
+          </size>
+         </property>
+        </spacer>
+       </item>
+      </layout>
+     </item>
+    </layout>
+   </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>
+ </widget>
+ <resources/>
+ <connections>
+  <connection>
+   <sender>buttonBox</sender>
+   <signal>accepted()</signal>
+   <receiver>MakePrimUI</receiver>
+   <slot>accept()</slot>
+   <hints>
+    <hint type="sourcelabel">
+     <x>254</x>
+     <y>140</y>
+    </hint>
+    <hint type="destinationlabel">
+     <x>157</x>
+     <y>146</y>
+    </hint>
+   </hints>
+  </connection>
+  <connection>
+   <sender>buttonBox</sender>
+   <signal>rejected()</signal>
+   <receiver>MakePrimUI</receiver>
+   <slot>reject()</slot>
+   <hints>
+    <hint type="sourcelabel">
+     <x>322</x>
+     <y>140</y>
+    </hint>
+    <hint type="destinationlabel">
+     <x>286</x>
+     <y>146</y>
+    </hint>
+   </hints>
+  </connection>
+  <connection>
+   <sender>rb_circle</sender>
+   <signal>clicked(bool)</signal>
+   <receiver>sb_ringnum</receiver>
+   <slot>setDisabled(bool)</slot>
+   <hints>
+    <hint type="sourcelabel">
+     <x>45</x>
+     <y>41</y>
+    </hint>
+    <hint type="destinationlabel">
+     <x>305</x>
+     <y>86</y>
+    </hint>
+   </hints>
+  </connection>
+  <connection>
+   <sender>rb_cylinder</sender>
+   <signal>clicked(bool)</signal>
+   <receiver>sb_ringnum</receiver>
+   <slot>setDisabled(bool)</slot>
+   <hints>
+    <hint type="sourcelabel">
+     <x>109</x>
+     <y>42</y>
+    </hint>
+    <hint type="destinationlabel">
+     <x>287</x>
+     <y>86</y>
+    </hint>
+   </hints>
+  </connection>
+  <connection>
+   <sender>rb_disc</sender>
+   <signal>clicked(bool)</signal>
+   <receiver>sb_ringnum</receiver>
+   <slot>setDisabled(bool)</slot>
+   <hints>
+    <hint type="sourcelabel">
+     <x>49</x>
+     <y>66</y>
+    </hint>
+    <hint type="destinationlabel">
+     <x>287</x>
+     <y>87</y>
+    </hint>
+   </hints>
+  </connection>
+  <connection>
+   <sender>rb_ndisc</sender>
+   <signal>clicked(bool)</signal>
+   <receiver>sb_ringnum</receiver>
+   <slot>setDisabled(bool)</slot>
+   <hints>
+    <hint type="sourcelabel">
+     <x>121</x>
+     <y>58</y>
+    </hint>
+    <hint type="destinationlabel">
+     <x>288</x>
+     <y>83</y>
+    </hint>
+   </hints>
+  </connection>
+  <connection>
+   <sender>rb_ring</sender>
+   <signal>clicked(bool)</signal>
+   <receiver>sb_ringnum</receiver>
+   <slot>setEnabled(bool)</slot>
+   <hints>
+    <hint type="sourcelabel">
+     <x>45</x>
+     <y>90</y>
+    </hint>
+    <hint type="destinationlabel">
+     <x>301</x>
+     <y>86</y>
+    </hint>
+   </hints>
+  </connection>
+  <connection>
+   <sender>rb_cone</sender>
+   <signal>clicked(bool)</signal>
+   <receiver>sb_ringnum</receiver>
+   <slot>setEnabled(bool)</slot>
+   <hints>
+    <hint type="sourcelabel">
+     <x>111</x>
+     <y>89</y>
+    </hint>
+    <hint type="destinationlabel">
+     <x>302</x>
+     <y>85</y>
+    </hint>
+   </hints>
+  </connection>
+ </connections>
+ <slots>
+  <slot>enableRingNumber()</slot>
+ </slots>
+</ui>
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/ui/newpart.ui	Tue Jul 02 01:42:43 2013 +0300
@@ -0,0 +1,191 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<ui version="4.0">
+ <class>NewPartUI</class>
+ <widget class="QDialog" name="NewPartUI">
+  <property name="geometry">
+   <rect>
+    <x>0</x>
+    <y>0</y>
+    <width>491</width>
+    <height>203</height>
+   </rect>
+  </property>
+  <property name="windowTitle">
+   <string>New Part</string>
+  </property>
+  <layout class="QVBoxLayout" name="verticalLayout" stretch="0,1,0">
+   <item>
+    <layout class="QHBoxLayout" name="horizontalLayout_2">
+     <item>
+      <layout class="QVBoxLayout" name="verticalLayout_2">
+       <item>
+        <widget class="QLabel" name="label_3">
+         <property name="text">
+          <string/>
+         </property>
+         <property name="pixmap">
+          <pixmap resource="../../ldforge.qrc">:/icons/brick.png</pixmap>
+         </property>
+        </widget>
+       </item>
+       <item>
+        <spacer name="verticalSpacer">
+         <property name="orientation">
+          <enum>Qt::Vertical</enum>
+         </property>
+         <property name="sizeHint" stdset="0">
+          <size>
+           <width>20</width>
+           <height>40</height>
+          </size>
+         </property>
+        </spacer>
+       </item>
+      </layout>
+     </item>
+     <item>
+      <layout class="QGridLayout" name="gridLayout">
+       <item row="0" column="0">
+        <widget class="QLabel" name="label">
+         <property name="text">
+          <string>Title:</string>
+         </property>
+        </widget>
+       </item>
+       <item row="1" column="0">
+        <widget class="QLabel" name="label_2">
+         <property name="text">
+          <string>Author:</string>
+         </property>
+        </widget>
+       </item>
+       <item row="0" column="1">
+        <widget class="QLineEdit" name="le_title"/>
+       </item>
+       <item row="1" column="1">
+        <widget class="QLineEdit" name="le_author"/>
+       </item>
+      </layout>
+     </item>
+    </layout>
+   </item>
+   <item>
+    <layout class="QHBoxLayout" name="horizontalLayout">
+     <item>
+      <widget class="QGroupBox" name="groupBox_2">
+       <property name="title">
+        <string>License</string>
+       </property>
+       <layout class="QVBoxLayout" name="verticalLayout_3">
+        <item>
+         <widget class="QRadioButton" name="rb_license_ca">
+          <property name="text">
+           <string>CCAL Redistributable</string>
+          </property>
+          <property name="checked">
+           <bool>true</bool>
+          </property>
+         </widget>
+        </item>
+        <item>
+         <widget class="QRadioButton" name="rb_license_nonca">
+          <property name="text">
+           <string>Non-redistributable</string>
+          </property>
+         </widget>
+        </item>
+        <item>
+         <widget class="QRadioButton" name="rb_license_none">
+          <property name="text">
+           <string>None</string>
+          </property>
+         </widget>
+        </item>
+       </layout>
+      </widget>
+     </item>
+     <item>
+      <widget class="QGroupBox" name="groupBox">
+       <property name="title">
+        <string>BFC winding</string>
+       </property>
+       <layout class="QVBoxLayout" name="verticalLayout_4">
+        <item>
+         <widget class="QRadioButton" name="rb_bfc_ccw">
+          <property name="text">
+           <string>CCW</string>
+          </property>
+          <property name="checked">
+           <bool>true</bool>
+          </property>
+         </widget>
+        </item>
+        <item>
+         <widget class="QRadioButton" name="rb_bfc_cw">
+          <property name="text">
+           <string>CW</string>
+          </property>
+         </widget>
+        </item>
+        <item>
+         <widget class="QRadioButton" name="rb_bfc_none">
+          <property name="text">
+           <string>None</string>
+          </property>
+         </widget>
+        </item>
+       </layout>
+      </widget>
+     </item>
+    </layout>
+   </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>
+ </widget>
+ <resources>
+  <include location="../../ldforge.qrc"/>
+ </resources>
+ <connections>
+  <connection>
+   <sender>buttonBox</sender>
+   <signal>accepted()</signal>
+   <receiver>NewPartUI</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>NewPartUI</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