more changes. Spawn the config prompt on first start, on the profile tab. gl_colorbfc and gl_blackedges now default to false.

Wed, 21 Aug 2013 10:54:33 +0300

author
Santeri Piippo <crimsondusk64@gmail.com>
date
Wed, 21 Aug 2013 10:54:33 +0300
changeset 469
f2faed654633
parent 468
7b3159f1a9e2
child 470
e41b6e1e3299

more changes. Spawn the config prompt on first start, on the profile tab. gl_colorbfc and gl_blackedges now default to false.

changelog.txt file | annotate | diff | comparison | revisions
src/config.cpp file | annotate | diff | comparison | revisions
src/configDialog.cpp file | annotate | diff | comparison | revisions
src/configDialog.h file | annotate | diff | comparison | revisions
src/gldraw.cpp file | annotate | diff | comparison | revisions
src/gui_actions.cpp file | annotate | diff | comparison | revisions
src/main.cpp file | annotate | diff | comparison | revisions
src/ui/config.ui file | annotate | diff | comparison | revisions
--- a/changelog.txt	Wed Aug 21 01:30:38 2013 +0300
+++ b/changelog.txt	Wed Aug 21 10:54:33 2013 +0300
@@ -6,26 +6,33 @@
 		- Added close, close all and save all actions.
 - Added ability to download parts from the Parts Tracker or from a custom-specified URL. If the resulting
 	file contains references to unknown files, LDForge attempts to recursively download all of them.
-- Color icon border now reflects the color's edge color.
-- Changing to draw mode while in free camera now causes the camera to be changed to top.
+- Converted the configuration code to use QSettings, in practice this means the configuration file moved to
+	the registry under Windows and into ~/.config/LDForge under Linux. Unfortunately this means settings get
+	lost during transition from version 0.2 and 0.3.
 - Corrections to the primitive generator:
 	- Fixed: "Hi-Res" was not prepended to the names of 48/ primitives.
 	- Fixed: Checking the Hi-Res option would not allow segment values over 16.
 	- Added support for multiple spaces before the ring number.
+- Changing to draw mode while in free camera now causes the camera to be changed to top.
+- Added config fields for default name/username/license. This data will be automatically filled
+	into forms that require such information.
+- Upon first start the configuration prompt pops up on its own, defaulting on the profile tab. This
+	way the user can fill in the profile data on the first start and get that out of the way (and
+	gives the opportunity to see the other config fields)
 - Added new action "Add History Line" for quickly inserting 0 !HISTORY lines to headers
 - Added new action "Go to line", default shortcut Ctrl-G. It should be obvious what it does.
 - Added support for logoed studs, this should satisfy Steffen. :p
 - Added support for '0 BFC CLIP' and '0 BFC NOCLIP' and added auto-correction from errorneous MLCAD
 	syntax ('0 BFC CERTIFY CLIP').
-- Added config fields for default name/username/license. This data will be automatically filled
-	into forms that require such information.
 - When an external program is attempted to be used without a binary path defined, one will be asked
 	with an input dialog instead of being told to go to configuration to set the path.
 - When adding edges with Intersector (which is done with Isecalc), the user is prompted for Isecalc's
 	path now as well if necessary instead of just ignoring it and not adding the edgelines.
+- BFC red/green view and black edges no longer default to true.
 - If the vertex snapper finds a vertex closer than 4 pixels, it likely is the vertex being looked for
 	and the algorithm can terminate early, hopefully this will save a few cycles on large parts.
 - The camera icons now draw real tooltips instead of emulated ones.
+- Color icon border now reflects the color's edge color.
 - Fixed: The message log was still written with black text with dark backgrounds.
 
 =================================================
--- a/src/config.cpp	Wed Aug 21 01:30:38 2013 +0300
+++ b/src/config.cpp	Wed Aug 21 10:54:33 2013 +0300
@@ -77,6 +77,9 @@
 		if (!cfg)
 			break;
 		
+		if (cfg->isDefault())
+			continue;
+		
 		settings->setValue (cfg->name, cfg->toVariant());
 	}
 	
--- a/src/configDialog.cpp	Wed Aug 21 01:30:38 2013 +0300
+++ b/src/configDialog.cpp	Wed Aug 21 10:54:33 2013 +0300
@@ -82,14 +82,48 @@
 ConfigDialog::ConfigDialog (ConfigDialog::Tab deftab, QWidget* parent, Qt::WindowFlags f) :
 	QDialog (parent, f)
 {
+	assert (g_win);
 	ui = new Ui_ConfigUI;
 	ui->setupUi (this);
 	
-	initMainTab();
-	initShortcutsTab();
-	initQuickColorTab();
-	initGridTab();
-	initExtProgTab();
+	// Interface tab:
+	setButtonBackground (ui->backgroundColorButton, gl_bgcolor);
+	connect (ui->backgroundColorButton, SIGNAL (clicked()),
+		this, SLOT (slot_setGLBackground()));
+	
+	setButtonBackground (ui->mainColorButton, gl_maincolor.value);
+	connect (ui->mainColorButton, SIGNAL (clicked()),
+		this, SLOT (slot_setGLForeground()));
+	
+	ui->mainColorAlpha->setValue (gl_maincolor_alpha * 10.0f);
+	ui->lineThickness->setValue (gl_linethickness);
+	ui->colorizeObjects->setChecked (lv_colorize);
+	ui->colorBFC->setChecked (gl_colorbfc);
+	ui->blackEdges->setChecked (gl_blackedges);
+	ui->implicitFiles->setChecked (gui_implicitfiles);
+	ui->m_logostuds->setChecked (gl_logostuds);
+	
+	ulong i = 0;
+#define act(N) addShortcut (key_##N, ACTION(N), i);
+#include "actions.h"
+	
+	ui->shortcutsList->setSortingEnabled (true);
+	ui->shortcutsList->sortItems();
+	
+	connect (ui->shortcut_set, SIGNAL (clicked()), this, SLOT (slot_setShortcut()));
+	connect (ui->shortcut_reset, SIGNAL (clicked()), this, SLOT (slot_resetShortcut()));
+	connect (ui->shortcut_clear, SIGNAL (clicked()), this, SLOT (slot_clearShortcut()));
+	
+	quickColors = quickColorsFromConfig();
+	updateQuickColorList();
+	
+	connect (ui->quickColor_add, SIGNAL (clicked()), this, SLOT (slot_setColor()));
+	connect (ui->quickColor_remove, SIGNAL (clicked()), this, SLOT (slot_delColor()));
+	connect (ui->quickColor_edit, SIGNAL (clicked()), this, SLOT (slot_setColor()));
+	connect (ui->quickColor_addSep, SIGNAL (clicked()), this, SLOT (slot_addColorSeparator()));
+	connect (ui->quickColor_moveUp, SIGNAL (clicked()), this, SLOT (slot_moveColor()));
+	connect (ui->quickColor_moveDown, SIGNAL (clicked()), this, SLOT (slot_moveColor()));
+	connect (ui->quickColor_clear, SIGNAL (clicked()), this, SLOT (slot_clearColors()));
 	
 	ui->downloadPath->setText (net_downloadpath);
 	ui->guessNetPaths->setChecked (net_guesspaths);
@@ -99,8 +133,13 @@
 	ui->m_profileName->setText (ld_defaultname);
 	ui->m_profileUsername->setText (ld_defaultuser);
 	ui->m_profileLicense->setCurrentIndex (ld_defaultlicense);
+	ui->tabs->setCurrentIndex (deftab);
 	
-	ui->tabs->setCurrentIndex (deftab);
+	initGrids();
+	initExtProgs();
+	
+	connect (ui->buttonBox, SIGNAL (clicked (QAbstractButton*)),
+		this, SLOT (buttonClicked(QAbstractButton*)));
 }
 
 // =============================================================================
@@ -111,45 +150,6 @@
 
 // =============================================================================
 // -----------------------------------------------------------------------------
-void ConfigDialog::initMainTab() {
-	// Init color stuff
-	setButtonBackground (ui->backgroundColorButton, gl_bgcolor);
-	connect (ui->backgroundColorButton, SIGNAL (clicked()),
-		this, SLOT (slot_setGLBackground()));
-	
-	setButtonBackground (ui->mainColorButton, gl_maincolor.value);
-	connect (ui->mainColorButton, SIGNAL (clicked()),
-		this, SLOT (slot_setGLForeground()));
-	
-	// Sliders
-	ui->mainColorAlpha->setValue (gl_maincolor_alpha * 10.0f);
-	ui->lineThickness->setValue (gl_linethickness);
-	
-	// Checkboxes
-	ui->colorizeObjects->setChecked (lv_colorize);
-	ui->colorBFC->setChecked (gl_colorbfc);
-	ui->blackEdges->setChecked (gl_blackedges);
-	// ui->scemanticInlining->setChecked (edit_schemanticinline);
-	ui->implicitFiles->setChecked (gui_implicitfiles);
-	ui->m_logostuds->setChecked (gl_logostuds);
-}
-
-// =============================================================================
-// -----------------------------------------------------------------------------
-void ConfigDialog::initShortcutsTab() {
-	ulong i = 0;
-	
-#define act(N) addShortcut (key_##N, ACTION(N), i);
-#include "actions.h"
-	
-	ui->shortcutsList->setSortingEnabled (true);
-	ui->shortcutsList->sortItems();
-	
-	connect (ui->shortcut_set, SIGNAL (clicked()), this, SLOT (slot_setShortcut()));
-	connect (ui->shortcut_reset, SIGNAL (clicked()), this, SLOT (slot_resetShortcut()));
-	connect (ui->shortcut_clear, SIGNAL (clicked()), this, SLOT (slot_clearShortcut()));
-}
-
 void ConfigDialog::addShortcut (KeySequenceConfig& cfg, QAction* act, ulong& i) {
 	ShortcutListItem* item = new ShortcutListItem;
 	item->setIcon (act->icon());
@@ -167,22 +167,7 @@
 
 // =============================================================================
 // -----------------------------------------------------------------------------
-void ConfigDialog::initQuickColorTab() {
-	quickColors = quickColorsFromConfig();
-	updateQuickColorList();
-	
-	connect (ui->quickColor_add, SIGNAL (clicked()), this, SLOT (slot_setColor()));
-	connect (ui->quickColor_remove, SIGNAL (clicked()), this, SLOT (slot_delColor()));
-	connect (ui->quickColor_edit, SIGNAL (clicked()), this, SLOT (slot_setColor()));
-	connect (ui->quickColor_addSep, SIGNAL (clicked()), this, SLOT (slot_addColorSeparator()));
-	connect (ui->quickColor_moveUp, SIGNAL (clicked()), this, SLOT (slot_moveColor()));
-	connect (ui->quickColor_moveDown, SIGNAL (clicked()), this, SLOT (slot_moveColor()));
-	connect (ui->quickColor_clear, SIGNAL (clicked()), this, SLOT (slot_clearColors()));
-}
-
-// =============================================================================
-// -----------------------------------------------------------------------------
-void ConfigDialog::initGridTab() {
+void ConfigDialog::initGrids() {
 	QGridLayout* gridlayout = new QGridLayout;
 	QLabel* xlabel = new QLabel ("X"),
 		*ylabel = new QLabel ("Y"),
@@ -215,7 +200,7 @@
 			gridlayout->addWidget (dsb_gridData[i][j], i + 1, j + 1);
 		}
 	}
-
+	
 	ui->grids->setLayout (gridlayout);
 }
 
@@ -247,7 +232,7 @@
 
 // =============================================================================
 // -----------------------------------------------------------------------------
-void ConfigDialog::initExtProgTab() {
+void ConfigDialog::initExtProgs() {
 	QGridLayout* pathsLayout = new QGridLayout;
 	ulong row = 0;
 	
@@ -279,8 +264,77 @@
 		
 		++row;
 	}
+	
+	ui->extProgs->setLayout (pathsLayout);
+}
 
-	ui->extProgs->setLayout (pathsLayout);
+// =============================================================================
+// -----------------------------------------------------------------------------
+void ConfigDialog::applySettings() {
+	// Apply configuration
+	lv_colorize = ui->colorizeObjects->isChecked();
+	gl_colorbfc = ui->colorBFC->isChecked();
+	// edit_schemanticinline = ui->scemanticInlining->isChecked();
+	gl_blackedges = ui->blackEdges->isChecked();
+	gl_maincolor_alpha = ((double) ui->mainColorAlpha->value()) / 10.0f;
+	gl_linethickness = ui->lineThickness->value();
+	gui_implicitfiles = ui->implicitFiles->isChecked();
+	net_downloadpath = ui->downloadPath->text();
+	net_guesspaths = ui->guessNetPaths->isChecked();
+	net_autoclose = ui->autoCloseNetPrompt->isChecked();
+	gl_logostuds = ui->m_logostuds->isChecked();
+	ld_defaultuser = ui->m_profileUsername->text();
+	ld_defaultname = ui->m_profileName->text();
+	ld_defaultlicense = ui->m_profileLicense->currentIndex();
+	
+	if (net_downloadpath.value.right (1) != DIRSLASH)
+		net_downloadpath += DIRSLASH;
+	
+	// Rebuild the quick color toolbar
+	g_win->setQuickColors (quickColors);
+	gui_colortoolbar = quickColorString();
+	
+	// Set the grid settings
+	for (int i = 0; i < g_NumGrids; ++i)
+		for (int j = 0; j < 4; ++j)
+			g_GridInfo[i].confs[j]->value = dsb_gridData[i][j]->value();
+	
+	// Apply key shortcuts
+#define act(N) ACTION(N)->setShortcut (key_##N);
+#include "actions.h"
+	
+	// Ext program settings
+	for (const extProgInfo & info : g_extProgInfo) {
+		*info.path = info.input->text();
+		
+#ifndef _WIN32
+		*info.wine = info.wineBox->isChecked();
+#endif // _WIN32
+	}
+	
+	Config::save();
+	reloadAllSubfiles();
+	loadLogoedStuds();
+	g_win->R()->setBackground();
+	g_win->fullRefresh();
+	g_win->updateToolBars();
+	g_win->updateFileList();
+}
+
+// =============================================================================
+// -----------------------------------------------------------------------------
+void ConfigDialog::buttonClicked (QAbstractButton* button) {
+	typedef QDialogButtonBox QDDB;
+	QDialogButtonBox* dbb = ui->buttonBox;
+	
+	if (button == dbb->button (QDDB::Ok)) {
+		applySettings();
+		accept();
+	} elif (button == dbb->button (QDDB::Apply)) {
+		applySettings();
+	} elif (button == dbb->button (QDDB::Cancel)) {
+		reject();
+	}
 }
 
 // =============================================================================
@@ -572,77 +626,6 @@
 	return val;
 }
 
-// =============================================================================
-// -----------------------------------------------------------------------------
-const Ui_ConfigUI* ConfigDialog::getUI() const {
-	return ui;
-}
-
-// =============================================================================
-// -----------------------------------------------------------------------------
-float ConfigDialog::getGridValue (int i, int j) const {
-	return dsb_gridData[i][j]->value();
-}
-
-// =============================================================================
-// -----------------------------------------------------------------------------
-void ConfigDialog::staticDialog() {
-	ConfigDialog dlg (InterfaceTab, g_win);
-	
-	if (dlg.exec()) {
-		const alias ui = *dlg.getUI();
-		
-		// Apply configuration
-		lv_colorize = ui.colorizeObjects->isChecked();
-		gl_colorbfc = ui.colorBFC->isChecked();
-		// edit_schemanticinline = ui.scemanticInlining->isChecked();
-		gl_blackedges = ui.blackEdges->isChecked();
-		gl_maincolor_alpha = ((double) ui.mainColorAlpha->value()) / 10.0f;
-		gl_linethickness = ui.lineThickness->value();
-		gui_implicitfiles = ui.implicitFiles->isChecked();
-		net_downloadpath = ui.downloadPath->text();
-		net_guesspaths = ui.guessNetPaths->isChecked();
-		net_autoclose = ui.autoCloseNetPrompt->isChecked();
-		gl_logostuds = ui.m_logostuds->isChecked();
-		ld_defaultuser = ui.m_profileUsername->text();
-		ld_defaultname = ui.m_profileName->text();
-		ld_defaultlicense = ui.m_profileLicense->currentIndex();
-		
-		if (net_downloadpath.value.right (1) != DIRSLASH)
-			net_downloadpath += DIRSLASH;
-		
-		// Rebuild the quick color toolbar
-		g_win->setQuickColors (dlg.quickColors);
-		gui_colortoolbar = dlg.quickColorString();
-		
-		// Set the grid settings
-		for (int i = 0; i < g_NumGrids; ++i)
-			for (int j = 0; j < 4; ++j)
-				g_GridInfo[i].confs[j]->value = dlg.getGridValue (i, j);
-		
-		// Apply key shortcuts
-#define act(N) ACTION(N)->setShortcut (key_##N);
-#include "actions.h"
-		
-		// Ext program settings
-		for (const extProgInfo & info : g_extProgInfo) {
-			*info.path = info.input->text();
-			
-#ifndef _WIN32
-			*info.wine = info.wineBox->isChecked();
-#endif // _WIN32
-		}
-		
-		Config::save();
-		reloadAllSubfiles();
-		loadLogoedStuds();
-		g_win->R()->setBackground();
-		g_win->fullRefresh();
-		g_win->updateToolBars();
-		g_win->updateFileList();
-	}
-}
-
 // =========================================================================================================================
 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
 // =========================================================================================================================
--- a/src/configDialog.h	Wed Aug 21 01:30:38 2013 +0300
+++ b/src/configDialog.h	Wed Aug 21 10:54:33 2013 +0300
@@ -53,8 +53,6 @@
 	
 	explicit ConfigDialog (Tab deftab = InterfaceTab, QWidget* parent = null, Qt::WindowFlags f = 0);
 	virtual ~ConfigDialog();
-	static void staticDialog();
-	const Ui_ConfigUI* getUI() const;
 	float getGridValue (int i, int j) const;
 	
 	List<LDQuickColor> quickColors;
@@ -66,11 +64,7 @@
 	QLabel* lb_gridIcons[3];
 	List<QListWidgetItem*> quickColorItems;
 	
-	void initMainTab();
-	void initShortcutsTab();
-	void initQuickColorTab();
-	void initGridTab();
-	void initExtProgTab();
+	void applySettings();
 	void addShortcut (KeySequenceConfig& cfg, QAction* act, ulong& i);
 	void setButtonBackground (QPushButton* button, str value);
 	void pickColor (StringConfig& cfg, QPushButton* button);
@@ -80,6 +74,8 @@
 	str quickColorString();
 	QListWidgetItem* getSelectedQuickColor();
 	QList<ShortcutListItem*> getShortcutSelection();
+	void initGrids();
+	void initExtProgs();
 	
 private slots:
 	void slot_setGLBackground();
@@ -94,6 +90,7 @@
 	void slot_clearColors();
 	void slot_setExtProgPath();
 	void slot_findDownloadFolder();
+	void buttonClicked (QAbstractButton* button);
 };
 
 // =============================================================================
--- a/src/gldraw.cpp	Wed Aug 21 01:30:38 2013 +0300
+++ b/src/gldraw.cpp	Wed Aug 21 10:54:33 2013 +0300
@@ -55,9 +55,9 @@
 cfg (String, gl_maincolor, "#707078");
 cfg (Float, gl_maincolor_alpha, 1.0);
 cfg (Int, gl_linethickness, 2);
-cfg (Bool, gl_colorbfc, true);
+cfg (Bool, gl_colorbfc, false);
 cfg (Int, gl_camera, GLRenderer::Free);
-cfg (Bool, gl_blackedges, true);
+cfg (Bool, gl_blackedges, false);
 cfg (Bool, gl_axes, false);
 cfg (Bool, gl_wireframe, false);
 cfg (Bool, gl_logostuds, false);
--- a/src/gui_actions.cpp	Wed Aug 21 01:30:38 2013 +0300
+++ b/src/gui_actions.cpp	Wed Aug 21 10:54:33 2013 +0300
@@ -166,14 +166,13 @@
 // =============================================================================
 // -----------------------------------------------------------------------------
 DEFINE_ACTION (Settings, 0) {
-	ConfigDialog::staticDialog();
+	(new ConfigDialog)->exec();
 }
 
 // =============================================================================
 // -----------------------------------------------------------------------------
 DEFINE_ACTION (SetLDrawPath, 0) {
-	LDrawPathDialog dlg (true);
-	dlg.exec();
+	(new LDrawPathDialog (true))->exec();
 }
 
 // =============================================================================
--- a/src/main.cpp	Wed Aug 21 01:30:38 2013 +0300
+++ b/src/main.cpp	Wed Aug 21 10:54:33 2013 +0300
@@ -29,6 +29,7 @@
 #include "types.h"
 #include "primitives.h"
 #include "gldraw.h"
+#include "configDialog.h"
 
 List<LDFile*> g_loadedFiles;
 ForgeWindow* g_win = null; 
@@ -40,6 +41,8 @@
 const vertex g_origin (0.0f, 0.0f, 0.0f);
 const matrix g_identity ({1.0f, 0.0f, 0.0f, 0.0f, 1.0f, 0.0f, 0.0f, 0.0f, 1.0f});
 
+cfg (Bool, firststart, true);
+
 // =============================================================================
 // -----------------------------------------------------------------------------
 int main (int argc, char* argv[]) {
@@ -64,11 +67,18 @@
 	loadLogoedStuds();
 	
 	ForgeWindow* win = new ForgeWindow;
+	newFile();
+	win->show();
 	
-	newFile();
+	// If this is the first start, get the user to configuration. Especially point
+	// them to the profile tab, it's the most important form to fill in.
+	if (firststart) {
+		(new ConfigDialog (ConfigDialog::ProfileTab))->exec();
+		firststart = false;
+		Config::save();
+	}
+	
 	loadPrimitives();
-	
-	win->show();
 	return app.exec();
 }
 
--- a/src/ui/config.ui	Wed Aug 21 01:30:38 2013 +0300
+++ b/src/ui/config.ui	Wed Aug 21 10:54:33 2013 +0300
@@ -691,7 +691,7 @@
       <enum>Qt::Horizontal</enum>
      </property>
      <property name="standardButtons">
-      <set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set>
+      <set>QDialogButtonBox::Apply|QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set>
      </property>
     </widget>
    </item>
@@ -700,38 +700,5 @@
  <resources>
   <include location="../../ldforge.qrc"/>
  </resources>
- <connections>
-  <connection>
-   <sender>buttonBox</sender>
-   <signal>accepted()</signal>
-   <receiver>ConfigUI</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>ConfigUI</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>
+ <connections/>
 </ui>

mercurial