- changed the config dialog's grid ui from being dynamically generated into a static one in the designer interface

Tue, 29 Apr 2014 00:15:56 +0300

author
Santeri Piippo <crimsondusk64@gmail.com>
date
Tue, 29 Apr 2014 00:15:56 +0300
changeset 756
844cda8c2aaf
parent 755
d2bd4139040c
child 757
8ab9fa53142b

- changed the config dialog's grid ui from being dynamically generated into a static one in the designer interface

src/configDialog.cc file | annotate | diff | comparison | revisions
src/configDialog.h file | annotate | diff | comparison | revisions
ui/config.ui file | annotate | diff | comparison | revisions
--- a/src/configDialog.cc	Tue Apr 29 00:00:45 2014 +0300
+++ b/src/configDialog.cc	Tue Apr 29 00:15:56 2014 +0300
@@ -71,6 +71,12 @@
 extern_cfg (Bool, prog_coverer_wine);
 extern_cfg (Bool, prog_isecalc_wine);
 extern_cfg (Bool, prog_edger2_wine);
+extern_cfg (Float,	grid_coarse_snap);
+extern_cfg (Float,	grid_coarse_angle);
+extern_cfg (Float, 	grid_medium_snap);
+extern_cfg (Float,	grid_medium_angle);
+extern_cfg (Float,	grid_fine_snap);
+extern_cfg (Float,	grid_fine_angle);
 
 const char* g_extProgPathFilter =
 #ifdef _WIN32
@@ -147,8 +153,13 @@
 	ui->m_profileName->setText (ld_defaultname);
 	ui->m_profileUsername->setText (ld_defaultuser);
 	ui->m_profileLicense->setCurrentIndex (ld_defaultlicense);
+	ui->gridCoarseCoordinateSnap->setValue (grid_coarse_snap);
+	ui->gridCoarseAngleSnap->setValue (grid_coarse_angle);
+	ui->gridMediumCoordinateSnap->setValue (grid_medium_snap);
+	ui->gridMediumAngleSnap->setValue (grid_medium_angle);
+	ui->gridFineCoordinateSnap->setValue (grid_fine_snap);
+	ui->gridFineAngleSnap->setValue (grid_fine_angle);
 
-	initGrids();
 	initExtProgs();
 	selectPage (deftab);
 
@@ -197,57 +208,6 @@
 }
 
 // =============================================================================
-// Initializes the table of grid stuff
-// =============================================================================
-void ConfigDialog::initGrids()
-{
-	QGridLayout* gridlayout = new QGridLayout;
-	QLabel* coordlabel = new QLabel ("Coordinate");
-	QLabel* anglelabel = new QLabel ("Angle");
-	int i = 1;
-
-	for (QLabel* label : QList<QLabel*> ({coordlabel, anglelabel}))
-	{
-		label->setAlignment (Qt::AlignCenter);
-		gridlayout->addWidget (label, 0, i++);
-	}
-
-	gridlayout->setColumnStretch (0, 0);
-	gridlayout->setColumnStretch (1, 1);
-	gridlayout->setColumnStretch (2, 1);
-
-	for (int i = 0; i < g_numGrids; ++i)
-	{
-		// Icon
-		lb_gridIcons[i] = new QLabel;
-		lb_gridIcons[i]->setPixmap (getIcon (format ("grid-%1", String (g_gridInfo[i].name).toLower())));
-
-		// Text label
-		lb_gridLabels[i] = new QLabel (format ("%1:", g_gridInfo[i].name));
-
-		QHBoxLayout* labellayout = new QHBoxLayout;
-		labellayout->addWidget (lb_gridIcons[i]);
-		labellayout->addWidget (lb_gridLabels[i]);
-		gridlayout->addLayout (labellayout, i + 1, 0);
-
-		// Add the widgets
-		for (int j = 0; j < 2; ++j)
-		{
-			dsb_gridData[i][j] = new QDoubleSpinBox;
-			gridlayout->addWidget (dsb_gridData[i][j], i + 1, j + 1);
-		}
-
-		// Fill in defaults and stuff
-		dsb_gridData[i][0]->setValue (*g_gridInfo[i].coordsnap);
-		dsb_gridData[i][1]->setValue (*g_gridInfo[i].anglesnap);
-		dsb_gridData[i][1]->setMaximum (360);
-		dsb_gridData[i][1]->setSuffix (utf16 (u"\u00B0")); // degree symbol
-	}
-
-	ui->grids->setLayout (gridlayout);
-}
-
-// =============================================================================
 // =============================================================================
 static struct LDExtProgInfo
 {
@@ -344,11 +304,12 @@
 	gui_colortoolbar = quickColorString();
 
 	// Set the grid settings
-	for (int i = 0; i < g_numGrids; ++i)
-	{
-		*g_gridInfo[i].coordsnap = dsb_gridData[i][0]->value();
-		*g_gridInfo[i].anglesnap = dsb_gridData[i][1]->value();
-	}
+	grid_coarse_snap = ui->gridCoarseCoordinateSnap->value();
+	grid_coarse_angle = ui->gridCoarseAngleSnap->value();
+	grid_medium_snap = ui->gridMediumCoordinateSnap->value();
+	grid_medium_angle = ui->gridMediumAngleSnap->value();
+	grid_fine_snap = ui->gridFineCoordinateSnap->value();
+	grid_fine_angle = ui->gridFineAngleSnap->value();
 
 	// Apply key shortcuts
 	g_win->updateActionShortcuts();
--- a/src/configDialog.h	Tue Apr 29 00:00:45 2014 +0300
+++ b/src/configDialog.h	Tue Apr 29 00:15:56 2014 +0300
@@ -54,15 +54,11 @@
 
 		explicit ConfigDialog (Tab deftab = InterfaceTab, QWidget* parent = null, Qt::WindowFlags f = 0);
 		virtual ~ConfigDialog();
-		float getGridValue (int i, int j) const;
 
 		QList<LDQuickColor> quickColors;
-		QDoubleSpinBox* dsb_gridData[3][2];
 
 	private:
 		Ui_ConfigUI* ui;
-		QLabel* lb_gridLabels[3];
-		QLabel* lb_gridIcons[3];
 		QList<QListWidgetItem*> quickColorItems;
 
 		void applySettings();
@@ -75,7 +71,6 @@
 		String quickColorString();
 		QListWidgetItem* getSelectedQuickColor();
 		QList<ShortcutListItem*> getShortcutSelection();
-		void initGrids();
 		void initExtProgs();
 
 	private slots:
--- a/ui/config.ui	Tue Apr 29 00:00:45 2014 +0300
+++ b/ui/config.ui	Tue Apr 29 00:15:56 2014 +0300
@@ -7,7 +7,7 @@
     <x>0</x>
     <y>0</y>
     <width>717</width>
-    <height>359</height>
+    <height>399</height>
    </rect>
   </property>
   <property name="windowTitle">
@@ -612,21 +612,170 @@
            <property name="title">
             <string>Grids</string>
            </property>
+           <layout class="QVBoxLayout" name="verticalLayout_2">
+            <item>
+             <layout class="QGridLayout" name="gridLayout" columnstretch="0,0,1,1">
+              <item row="0" column="2">
+               <widget class="QLabel" name="label_15">
+                <property name="text">
+                 <string>Coordinate snap</string>
+                </property>
+               </widget>
+              </item>
+              <item row="0" column="3">
+               <widget class="QLabel" name="label_16">
+                <property name="text">
+                 <string>Angle snap</string>
+                </property>
+               </widget>
+              </item>
+              <item row="1" column="0">
+               <widget class="QLabel" name="label_6">
+                <property name="text">
+                 <string/>
+                </property>
+                <property name="pixmap">
+                 <pixmap resource="../ldforge.qrc">:/icons/grid-coarse.png</pixmap>
+                </property>
+               </widget>
+              </item>
+              <item row="1" column="1">
+               <widget class="QLabel" name="label_12">
+                <property name="text">
+                 <string>Coarse</string>
+                </property>
+               </widget>
+              </item>
+              <item row="1" column="2">
+               <widget class="QDoubleSpinBox" name="gridCoarseCoordinateSnap">
+                <property name="suffix">
+                 <string> LDU</string>
+                </property>
+                <property name="decimals">
+                 <number>3</number>
+                </property>
+                <property name="maximum">
+                 <double>10000.000000000000000</double>
+                </property>
+               </widget>
+              </item>
+              <item row="1" column="3">
+               <widget class="QDoubleSpinBox" name="gridCoarseAngleSnap">
+                <property name="suffix">
+                 <string>°</string>
+                </property>
+                <property name="decimals">
+                 <number>3</number>
+                </property>
+                <property name="maximum">
+                 <double>360.000000000000000</double>
+                </property>
+               </widget>
+              </item>
+              <item row="2" column="0">
+               <widget class="QLabel" name="label_10">
+                <property name="text">
+                 <string/>
+                </property>
+                <property name="pixmap">
+                 <pixmap resource="../ldforge.qrc">:/icons/grid-medium.png</pixmap>
+                </property>
+               </widget>
+              </item>
+              <item row="2" column="1">
+               <widget class="QLabel" name="label_13">
+                <property name="text">
+                 <string>Medium</string>
+                </property>
+               </widget>
+              </item>
+              <item row="2" column="2">
+               <widget class="QDoubleSpinBox" name="gridMediumCoordinateSnap">
+                <property name="suffix">
+                 <string> LDU</string>
+                </property>
+                <property name="decimals">
+                 <number>3</number>
+                </property>
+                <property name="maximum">
+                 <double>10000.000000000000000</double>
+                </property>
+               </widget>
+              </item>
+              <item row="2" column="3">
+               <widget class="QDoubleSpinBox" name="gridMediumAngleSnap">
+                <property name="suffix">
+                 <string>°</string>
+                </property>
+                <property name="decimals">
+                 <number>3</number>
+                </property>
+                <property name="maximum">
+                 <double>360.000000000000000</double>
+                </property>
+               </widget>
+              </item>
+              <item row="3" column="0">
+               <widget class="QLabel" name="label_11">
+                <property name="text">
+                 <string/>
+                </property>
+                <property name="pixmap">
+                 <pixmap resource="../ldforge.qrc">:/icons/grid-fine.png</pixmap>
+                </property>
+               </widget>
+              </item>
+              <item row="3" column="1">
+               <widget class="QLabel" name="label_14">
+                <property name="text">
+                 <string>Fine</string>
+                </property>
+               </widget>
+              </item>
+              <item row="3" column="2">
+               <widget class="QDoubleSpinBox" name="gridFineCoordinateSnap">
+                <property name="suffix">
+                 <string> LDU</string>
+                </property>
+                <property name="decimals">
+                 <number>3</number>
+                </property>
+                <property name="maximum">
+                 <double>10000.000000000000000</double>
+                </property>
+               </widget>
+              </item>
+              <item row="3" column="3">
+               <widget class="QDoubleSpinBox" name="gridFineAngleSnap">
+                <property name="suffix">
+                 <string>°</string>
+                </property>
+                <property name="decimals">
+                 <number>3</number>
+                </property>
+                <property name="maximum">
+                 <double>360.000000000000000</double>
+                </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>165</height>
+               </size>
+              </property>
+             </spacer>
+            </item>
+           </layout>
           </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>
        </widget>
        <widget class="QWidget" name="page_8">

mercurial