Refactor MainWindow's API

Sun, 06 Sep 2015 01:52:23 +0300

author
Teemu Piippo <crimsondusk64@gmail.com>
date
Sun, 06 Sep 2015 01:52:23 +0300
changeset 981
5d5d84ab2c48
parent 980
4a95c6b06ebe
child 982
a3a2e62a581b

Refactor MainWindow's API

src/addObjectDialog.cpp file | annotate | diff | comparison | revisions
src/dialogs.cpp file | annotate | diff | comparison | revisions
src/dialogs/configdialog.cpp file | annotate | diff | comparison | revisions
src/editHistory.cpp file | annotate | diff | comparison | revisions
src/editmodes/abstractEditMode.cpp file | annotate | diff | comparison | revisions
src/editmodes/magicWandMode.cpp file | annotate | diff | comparison | revisions
src/glRenderer.cpp file | annotate | diff | comparison | revisions
src/ldDocument.cpp file | annotate | diff | comparison | revisions
src/ldObject.cpp file | annotate | diff | comparison | revisions
src/mainwindow.cpp file | annotate | diff | comparison | revisions
src/mainwindow.h file | annotate | diff | comparison | revisions
src/partDownloader.cpp file | annotate | diff | comparison | revisions
src/toolsets/algorithmtoolset.cpp file | annotate | diff | comparison | revisions
src/toolsets/basictoolset.cpp file | annotate | diff | comparison | revisions
src/toolsets/filetoolset.cpp file | annotate | diff | comparison | revisions
src/toolsets/movetoolset.cpp file | annotate | diff | comparison | revisions
src/toolsets/viewtoolset.cpp file | annotate | diff | comparison | revisions
--- a/src/addObjectDialog.cpp	Sun Sep 06 01:22:25 2015 +0300
+++ b/src/addObjectDialog.cpp	Sun Sep 06 01:52:23 2015 +0300
@@ -389,7 +389,7 @@
 
 	if (newObject)
 	{
-		int idx = g_win->getInsertionPoint();
+		int idx = g_win->suggestInsertPoint();
 		g_win->currentDocument()->insertObj (idx, obj);
 	}
 
--- a/src/dialogs.cpp	Sun Sep 06 01:22:25 2015 +0300
+++ b/src/dialogs.cpp	Sun Sep 06 01:52:23 2015 +0300
@@ -60,7 +60,7 @@
 		{ ui->right,  ERightCamera }
 	};
 
-	ECamera cam = g_win->R()->camera();
+	ECamera cam = g_win->renderer()->camera();
 
 	if (cam == EFreeCamera)
 		cam = ETopCamera;
@@ -85,7 +85,7 @@
 // =============================================================================
 void OverlayDialog::fillDefaults (int newcam)
 {
-	LDGLOverlay& info = g_win->R()->getOverlay (newcam);
+	LDGLOverlay& info = g_win->renderer()->getOverlay (newcam);
 	RadioDefault<int> (newcam, m_cameraArgs);
 
 	if (info.img != null)
--- a/src/dialogs/configdialog.cpp	Sun Sep 06 01:22:25 2015 +0300
+++ b/src/dialogs/configdialog.cpp	Sun Sep 06 01:52:23 2015 +0300
@@ -277,7 +277,7 @@
 	m_window->syncSettings();
 	currentDocument()->reloadAllSubfiles();
 	LoadLogoStuds();
-	m_window->R()->setBackground();
+	m_window->renderer()->setBackground();
 	m_window->doFullRefresh();
 	m_window->updateDocumentList();
 }
--- a/src/editHistory.cpp	Sun Sep 06 01:22:25 2015 +0300
+++ b/src/editHistory.cpp	Sun Sep 06 01:52:23 2015 +0300
@@ -141,7 +141,7 @@
 {
 	LDObject* obj = ParseLine (code());
 	parent()->document()->insertObj (index(), obj);
-	g_win->R()->compileObject (obj);
+	g_win->renderer()->compileObject (obj);
 }
 
 // =============================================================================
@@ -157,7 +157,7 @@
 {
 	LDObject* obj = ParseLine (code());
 	parent()->document()->insertObj (index(), obj);
-	g_win->R()->compileObject (obj);
+	g_win->renderer()->compileObject (obj);
 }
 
 // =============================================================================
@@ -175,7 +175,7 @@
 	LDObject* obj = g_win->currentDocument()->getObject (index());
 	LDObject* newobj = ParseLine (oldCode());
 	obj->replace (newobj);
-	g_win->R()->compileObject (newobj);
+	g_win->renderer()->compileObject (newobj);
 }
 
 // =============================================================================
@@ -185,7 +185,7 @@
 	LDObject* obj = g_win->currentDocument()->getObject (index());
 	LDObject* newobj = ParseLine (newCode());
 	obj->replace (newobj);
-	g_win->R()->compileObject (newobj);
+	g_win->renderer()->compileObject (newobj);
 }
 
 // =============================================================================
--- a/src/editmodes/abstractEditMode.cpp	Sun Sep 06 01:22:25 2015 +0300
+++ b/src/editmodes/abstractEditMode.cpp	Sun Sep 06 01:52:23 2015 +0300
@@ -156,7 +156,7 @@
 
 void AbstractDrawMode::finishDraw (LDObjectList const& objs)
 {
-	int pos = m_window->getInsertionPoint();
+	int pos = m_window->suggestInsertPoint();
 
 	if (objs.size() > 0)
 	{
--- a/src/editmodes/magicWandMode.cpp	Sun Sep 06 01:22:25 2015 +0300
+++ b/src/editmodes/magicWandMode.cpp	Sun Sep 06 01:52:23 2015 +0300
@@ -78,7 +78,7 @@
 		if (type == Set)
 		{
 			currentDocument()->clearSelection();
-			m_window->buildObjList();
+			m_window->buildObjectList();
 		}
 
 		return;
@@ -195,7 +195,7 @@
 	}
 
 	if (type != InternalRecursion)
-		m_window->buildObjList();
+		m_window->buildObjectList();
 }
 
 bool MagicWandMode::mouseReleased (MouseEventData const& data)
--- a/src/glRenderer.cpp	Sun Sep 06 01:22:25 2015 +0300
+++ b/src/glRenderer.cpp	Sun Sep 06 01:52:23 2015 +0300
@@ -1523,7 +1523,7 @@
 		}
 	}
 
-	if (m_window->R() == this)
+	if (m_window->renderer() == this)
 		m_window->refresh();
 }
 
@@ -1586,10 +1586,10 @@
 		ref->setFileInfo (GetDocument (primName));
 		ref->setPosition (Origin);
 		ref->setTransform (IdentityMatrix);
-		currentDocument()->insertObj (m_window->getInsertionPoint(), ref);
+		currentDocument()->insertObj (m_window->suggestInsertPoint(), ref);
 		ref->select();
-		m_window->buildObjList();
-		m_window->R()->refresh();
+		m_window->buildObjectList();
+		m_window->renderer()->refresh();
 		ev->acceptProposedAction();
 	}
 }
--- a/src/ldDocument.cpp	Sun Sep 06 01:22:25 2015 +0300
+++ b/src/ldDocument.cpp	Sun Sep 06 01:52:23 2015 +0300
@@ -140,7 +140,7 @@
 
 		// Cache files are not compiled by the GL renderer. Now that this file is open for editing, it needs to be
 		// compiled.
-		m_window->R()->compiler()->compileDocument (this);
+		m_window->renderer()->compiler()->compileDocument (this);
 		m_window->updateDocumentList();
 	}
 }
@@ -412,7 +412,7 @@
 	if (g_loadingMainFile)
 	{
 		g_win->changeDocument (load);
-		g_win->R()->setDocument (load);
+		g_win->renderer()->setDocument (load);
 		print (QObject::tr ("File %1 parsed successfully (%2 errors)."), path, numWarnings);
 	}
 
@@ -622,7 +622,7 @@
 		{
 			QString newname = shortenName (path);
 			nameComment->setText (format ("Name: %1", newname));
-			m_window->buildObjList();
+			m_window->buildObjectList();
 		}
 	}
 
@@ -954,7 +954,7 @@
 	m_needsReCache = true;
 
 	if (this == m_window->currentDocument())
-		m_window->buildObjList();
+		m_window->buildObjectList();
 }
 
 // =============================================================================
@@ -965,7 +965,7 @@
 	m_objects << obj;
 	addKnownVertices (obj);
 	obj->setDocument (this);
-	m_window->R()->compileObject (obj);
+	m_window->renderer()->compileObject (obj);
 	return getObjectCount() - 1;
 }
 
@@ -987,7 +987,7 @@
 	history()->add (new AddHistory (pos, obj));
 	m_objects.insert (pos, obj);
 	obj->setDocument (this);
-	m_window->R()->compileObject (obj);
+	m_window->renderer()->compileObject (obj);
 	
 
 #ifdef DEBUG
@@ -1065,7 +1065,7 @@
 	m_objects[idx]->setDocument (nullptr);
 	obj->setDocument (this);
 	addKnownVertices (obj);
-	m_window->R()->compileObject (obj);
+	m_window->renderer()->compileObject (obj);
 	m_objects[idx] = obj;
 	needVertexMerge();
 }
@@ -1234,7 +1234,7 @@
 	if (not obj->isSelected() and obj->document() == this)
 	{
 		m_sel << obj;
-		m_window->R()->compileObject (obj);
+		m_window->renderer()->compileObject (obj);
 		obj->setSelected (true);
 	}
 }
@@ -1246,7 +1246,7 @@
 	if (obj->isSelected() and obj->document() == this)
 	{
 		m_sel.removeOne (obj);
-		m_window->R()->compileObject (obj);
+		m_window->renderer()->compileObject (obj);
 		obj->setSelected (false);
 	}
 }
@@ -1257,7 +1257,7 @@
 {
 	for (LDObject* obj : m_sel)
 	{
-		m_window->R()->compileObject (obj);
+		m_window->renderer()->compileObject (obj);
 		obj->setSelected (false);
 	}
 
--- a/src/ldObject.cpp	Sun Sep 06 01:22:25 2015 +0300
+++ b/src/ldObject.cpp	Sun Sep 06 01:52:23 2015 +0300
@@ -304,7 +304,7 @@
 
 		// Delete the GL lists
 		if (g_win != null)
-			g_win->R()->forgetObject (this);
+			g_win->renderer()->forgetObject (this);
 
 		// Remove this object from the list of LDObjects
 		g_allObjects.erase (g_allObjects.find (id()));
@@ -475,7 +475,7 @@
 	// The objects need to be recompiled, otherwise their pick lists are left with
 	// the wrong index colors which messes up selection.
 	for (LDObject* obj : objsToCompile)
-		g_win->R()->compileObject (obj);
+		g_win->renderer()->compileObject (obj);
 }
 
 // =============================================================================
@@ -786,7 +786,7 @@
 		if (before != after)
 		{
 			obj->document()->addToHistory (new EditHistory (idx, before, after));
-			g_win->R()->compileObject (obj);
+			g_win->renderer()->compileObject (obj);
 			g_win->currentDocument()->redoVertices();
 		}
 	}
--- a/src/mainwindow.cpp	Sun Sep 06 01:22:25 2015 +0300
+++ b/src/mainwindow.cpp	Sun Sep 06 01:52:23 2015 +0300
@@ -84,10 +84,10 @@
 
 	// Stuff the renderer into its frame
 	QVBoxLayout* rendererLayout = new QVBoxLayout (ui.rendererFrame);
-	rendererLayout->addWidget (R());
+	rendererLayout->addWidget (renderer());
 
-	connect (ui.objectList, SIGNAL (itemSelectionChanged()), this, SLOT (slot_selectionChanged()));
-	connect (ui.objectList, SIGNAL (itemDoubleClicked (QListWidgetItem*)), this, SLOT (slot_editObject (QListWidgetItem*)));
+	connect (ui.objectList, SIGNAL (itemSelectionChanged()), this, SLOT (selectionChanged()));
+	connect (ui.objectList, SIGNAL (itemDoubleClicked (QListWidgetItem*)), this, SLOT (objectListDoubleClicked (QListWidgetItem*)));
 	connect (m_tabs, SIGNAL (currentChanged(int)), this, SLOT (tabSelected()));
 	connect (m_tabs, SIGNAL (tabCloseRequested (int)), this, SLOT (closeTab (int)));
 
@@ -97,7 +97,7 @@
 		updatePrimitives();
 
 	m_msglog = new MessageManager;
-	m_msglog->setRenderer (R());
+	m_msglog->setRenderer (renderer());
 	m_renderer->setMessageLog (m_msglog);
 	m_quickColors = LoadQuickColorList();
 	setStatusBar (new QStatusBar);
@@ -106,7 +106,7 @@
 	// Connect all actions and save default sequences
 	applyToActions ([&](QAction* act)
 	{
-		connect (act, SIGNAL (triggered()), this, SLOT (slot_action()));
+		connect (act, SIGNAL (triggered()), this, SLOT (actionTriggered()));
 		g_defaultShortcuts[act] = act->shortcut();
 	});
 
@@ -117,7 +117,7 @@
 	updateTitle();
 	loadShortcuts();
 	setMinimumSize (300, 200);
-	connect (qApp, SIGNAL (aboutToQuit()), this, SLOT (slot_lastSecondCleanup()));
+	connect (qApp, SIGNAL (aboutToQuit()), this, SLOT (doLastSecondCleanup()));
 	connect (ui.ringToolHiRes, SIGNAL (clicked (bool)), this, SLOT (ringToolHiResClicked (bool)));
 	connect (ui.ringToolSegments, SIGNAL (valueChanged (int)),
 		this, SLOT (circleToolSegmentsChanged()));
@@ -188,7 +188,7 @@
 
 // ---------------------------------------------------------------------------------------------------------------------
 //
-void MainWindow::slot_action()
+void MainWindow::actionTriggered()
 {
 	// Get the name of the sender object and use it to compose the slot name,
 	// then invoke this slot to call the action.
@@ -219,7 +219,7 @@
 
 // ---------------------------------------------------------------------------------------------------------------------
 //
-void MainWindow::slot_lastSecondCleanup()
+void MainWindow::doLastSecondCleanup()
 {
 	delete m_renderer;
 	delete &ui;
@@ -242,7 +242,7 @@
 		QString file = it.toString();
 		QAction* recent = new QAction (GetIcon ("open-recent"), file, this);
 
-		connect (recent, SIGNAL (triggered()), this, SLOT (slot_recentFile()));
+		connect (recent, SIGNAL (triggered()), this, SLOT (recentFileClicked()));
 		ui.menuOpenRecent->insertAction (first, recent);
 		m_recentFiles << recent;
 		first = recent;
@@ -293,7 +293,7 @@
 			colorButton->setIconSize (QSize (16, 16));
 			colorButton->setToolTip (entry.color().name());
 
-			connect (colorButton, SIGNAL (clicked()), this, SLOT (slot_quickColor()));
+			connect (colorButton, SIGNAL (clicked()), this, SLOT (quickColorClicked()));
 			ui.toolBarColors->addWidget (colorButton);
 			m_colorButtons << colorButton;
 
@@ -370,7 +370,7 @@
 
 // ---------------------------------------------------------------------------------------------------------------------
 //
-void MainWindow::buildObjList()
+void MainWindow::buildObjectList()
 {
 	if (not m_currentDocument)
 		return;
@@ -499,18 +499,20 @@
 
 // ---------------------------------------------------------------------------------------------------------------------
 //
+// Scrolls the object list so that it points to the first selected object.
+//
 void MainWindow::scrollToSelection()
 {
 	if (selectedObjects().isEmpty())
 		return;
 
-	LDObject* obj = selectedObjects().last();
+	LDObject* obj = selectedObjects().first();
 	ui.objectList->scrollToItem (obj->qObjListEntry);
 }
 
 // ---------------------------------------------------------------------------------------------------------------------
 //
-void MainWindow::slot_selectionChanged()
+void MainWindow::selectionChanged()
 {
 	if (g_isSelectionLocked == true or m_currentDocument == null)
 		return;
@@ -542,14 +544,14 @@
 	removeDuplicates (compound);
 
 	for (LDObject* obj : compound)
-		R()->compileObject (obj);
+		renderer()->compileObject (obj);
 
-	R()->update();
+	renderer()->update();
 }
 
 // ---------------------------------------------------------------------------------------------------------------------
 //
-void MainWindow::slot_recentFile()
+void MainWindow::recentFileClicked()
 {
 	QAction* qAct = static_cast<QAction*> (sender());
 	OpenMainModel (qAct->text());
@@ -557,7 +559,7 @@
 
 // ---------------------------------------------------------------------------------------------------------------------
 //
-void MainWindow::slot_quickColor()
+void MainWindow::quickColorClicked()
 {
 	QToolButton* button = static_cast<QToolButton*> (sender());
 	LDColor color = LDColor::nullColor();
@@ -580,7 +582,7 @@
 			continue; // uncolored object
 
 		obj->setColor (color);
-		R()->compileObject (obj);
+		renderer()->compileObject (obj);
 	}
 
 	endAction();
@@ -589,7 +591,9 @@
 
 // ---------------------------------------------------------------------------------------------------------------------
 //
-int MainWindow::getInsertionPoint()
+// Returns the suggested position to place a new object at.
+//
+int MainWindow::suggestInsertPoint()
 {
 	// If we have a selection, put the item after it.
 	if (not selectedObjects().isEmpty())
@@ -603,15 +607,17 @@
 //
 void MainWindow::doFullRefresh()
 {
-	buildObjList();
+	buildObjectList();
 	m_renderer->hardRefresh();
 }
 
 // ---------------------------------------------------------------------------------------------------------------------
 //
+// Builds the object list and tells the GL renderer to do a soft update.
+//
 void MainWindow::refresh()
 {
-	buildObjList();
+	buildObjectList();
 	m_renderer->update();
 }
 
@@ -660,7 +666,9 @@
 
 // ---------------------------------------------------------------------------------------------------------------------
 //
-LDColor MainWindow::getSelectedColor()
+// Returns the uniform selected color (i.e. 4 if everything selected is red), -1 if there is no such consensus.
+//
+LDColor MainWindow::getUniformSelectedColor()
 {
 	LDColor result;
 
@@ -762,7 +770,7 @@
 		contextMenu->addAction (ui.actionSubfileSelection);
 	}
 
-	if (R()->camera() != EFreeCamera)
+	if (renderer()->camera() != EFreeCamera)
 	{
 		contextMenu->addSeparator();
 		contextMenu->addAction (ui.actionSetDrawDepth);
@@ -793,7 +801,7 @@
 //
 void MainWindow::updateEditModeActions()
 {
-	const EditModeType mode = R()->currentEditModeType();
+	const EditModeType mode = renderer()->currentEditModeType();
 	ui.actionModeSelect->setChecked (mode == EditModeType::Select);
 	ui.actionModeDraw->setChecked (mode == EditModeType::Draw);
 	ui.actionModeRectangle->setChecked (mode == EditModeType::Rectangle);
@@ -804,7 +812,7 @@
 
 // ---------------------------------------------------------------------------------------------------------------------
 //
-void MainWindow::slot_editObject (QListWidgetItem* listitem)
+void MainWindow::objectListDoubleClicked (QListWidgetItem* listitem)
 {
 	for (LDObject* it : m_currentDocument->objects())
 	{
@@ -876,6 +884,7 @@
 	return false;
 }
 
+// Adds a message to the renderer's message manager.
 void MainWindow::addMessage (QString msg)
 {
 	m_msglog->addLine (msg);
@@ -942,6 +951,8 @@
 
 // ---------------------------------------------------------------------------------------------------------------------
 //
+// Update the given document's tab. If no such tab exists, the document list is rebuilt.
+//
 void MainWindow::updateDocumentListItem (LDDocument* doc)
 {
 	bool oldUpdatingTabs = m_updatingTabs;
@@ -997,6 +1008,8 @@
 
 // ---------------------------------------------------------------------------------------------------------------------
 //
+// Updates the object list. Right now this just rebuilds it.
+//
 void MainWindow::refreshObjectList()
 {
 #if 0
@@ -1008,11 +1021,14 @@
 
 #endif
 
-	buildObjList();
+	buildObjectList();
 }
 
 // ---------------------------------------------------------------------------------------------------------------------
 //
+// Updates various actions, undo/redo are set enabled/disabled where appropriate, togglable actions are updated based
+// on configuration, etc.
+//
 void MainWindow::updateActions()
 {
 	if (m_currentDocument != null and m_currentDocument->history() != null)
@@ -1035,6 +1051,21 @@
 
 // ---------------------------------------------------------------------------------------------------------------------
 //
+GLRenderer* MainWindow::renderer()
+{
+	return m_renderer;
+}
+
+// ---------------------------------------------------------------------------------------------------------------------
+//
+void MainWindow::setQuickColors (const QList<LDQuickColor>& colors)
+{
+	m_quickColors = colors;
+	updateColorToolbar();
+}
+
+// ---------------------------------------------------------------------------------------------------------------------
+//
 void MainWindow::updatePrimitives()
 {
 	PopulatePrimitives (ui.primitives);
@@ -1223,7 +1254,7 @@
 	{
 		// A ton of stuff needs to be updated
 		updateDocumentListItem (document);
-		buildObjList();
+		buildObjectList();
 		updateTitle();
 		m_renderer->setDocument (document);
 		m_renderer->compiler()->needMerge();
@@ -1276,6 +1307,16 @@
 	}
 }
 
+ExtProgramToolset* MainWindow::externalPrograms()
+{
+	return m_externalPrograms;
+}
+
+GuiUtilities* MainWindow::guiUtilities()
+{
+	return m_guiUtilities;
+}
+
 // ---------------------------------------------------------------------------------------------------------------------
 //
 QImage GetImageFromScreencap (uchar* data, int w, int h)
--- a/src/mainwindow.h	Sun Sep 06 01:22:25 2015 +0300
+++ b/src/mainwindow.h	Sun Sep 06 01:52:23 2015 +0300
@@ -50,20 +50,16 @@
 	static LDQuickColor getSeparator();
 };
 
-//
 // Object list class for MainWindow
-//
 class ObjectList : public QListWidget
 {
 	Q_OBJECT
 
-	protected:
-		void contextMenuEvent (QContextMenuEvent* ev);
+protected:
+	void contextMenuEvent (QContextMenuEvent* ev);
 };
 
-//
 // LDForge's main GUI class.
-//
 class MainWindow : public QMainWindow
 {
 	Q_OBJECT
@@ -72,127 +68,60 @@
 	explicit MainWindow (QWidget* parent = null, Qt::WindowFlags flags = 0);
 	~MainWindow();
 
-	// Rebuilds the object list.
-	void buildObjList();
-
-	// Updates the window title.
+	void addMessage (QString msg);
+	const QList<LDDocument*>& allDocuments();
+	void applyToActions (std::function<void(QAction*)> function);
+	void buildObjectList();
+	void changeDocument (LDDocument* f);
+	void closeInitialDocument();
+	ConfigurationValueBag* configBag() { return &m_configOptions; }
+	void createBlankDocument();
+	LDDocument* currentDocument();
+	void currentDocumentClosed();
+	static QKeySequence defaultShortcut (QAction* act);
+	void deleteByColor (LDColor color);
+	int deleteSelection();
+	void doFullRefresh();
+	void endAction();
+	class ExtProgramToolset* externalPrograms();
+	QVariant getConfigValue (QString name);
+	QTreeWidget* getPrimitivesTree() const;
+	class QSettings* getSettings() { return m_settings; }
+	LDColor getUniformSelectedColor();
+	class GuiUtilities* guiUtilities();
+	void loadShortcuts();
+	class QSettings* makeSettings (QObject* parent = nullptr);
+	LDDocument* newDocument (bool cache = false);
+	GLRenderer* renderer();
+	void refresh();
+	void refreshObjectList();
+	bool ringToolHiRes() const;
+	int ringToolSegments() const;
+	bool save (LDDocument* doc, bool saveAs);
+	void saveShortcuts();
+	void scrollToSelection();
+	const LDObjectList& selectedObjects();
+	void setQuickColors (const QList<LDQuickColor>& colors);
+	void spawnContextMenu (const QPoint pos);
+	int suggestInsertPoint();
+	void syncSettings();
+	void updateActions();
+	void updateColorToolbar();
+	void updateDocumentList();
+	void updateDocumentListItem (LDDocument* doc);
+	void updateEditModeActions();
+	void updateGridToolBar();
+	void updateRecentFilesMenu();
+	void updateSelection();
 	void updateTitle();
 
-	// Builds the object list and tells the GL renderer to init a full
-	// refresh.
-	void doFullRefresh();
-
-	// Builds the object list and tells the GL renderer to do a soft update.
-	void refresh();
-
-	// Returns the suggested position to place a new object at.
-	int getInsertionPoint();
-
-	// Updates the quick color toolbar
-	void updateColorToolbar();
-
-	// Rebuilds the recent files submenu
-	void updateRecentFilesMenu();
-
-	// Sets the selection based on what's selected in the object list.
-	void updateSelection();
-
-	// Updates the grids, selects the selected grid and deselects others.
-	void updateGridToolBar();
-
-	// Updates the edit modes, current one is selected and others are deselected.
-	void updateEditModeActions();
-
-	// Rebuilds the document tab list.
-	void updateDocumentList();
-
-	// Updates the document tab for \c doc. If no such tab exists, the
-	// document list is rebuilt instead.
-	void updateDocumentListItem (LDDocument* doc);
-
-	// Returns the uniform selected color (i.e. 4 if everything selected is
-	// red), -1 if there is no such consensus.
-	LDColor getSelectedColor();
-
-	// Automatically scrolls the object list so that it points to the first
-	// selected object.
-	void scrollToSelection();
-
-	// Spawns the context menu at the given position.
-	void spawnContextMenu (const QPoint pos);
-
-	// Deletes all selected objects, returns the count of deleted objects.
-	int deleteSelection();
-
-	// Deletes all objects by the given color number.
-	void deleteByColor (LDColor color);
-
-	// Tries to save the given document.
-	bool save (LDDocument* doc, bool saveAs);
-
-	// Updates various actions, undo/redo are set enabled/disabled where
-	// appropriate, togglable actions are updated based on configuration,
-	// etc.
-	void updateActions();
-
-	// Returns a pointer to the renderer
-	inline GLRenderer* R()
-	{
-		return m_renderer;
-	}
-
-	// Sets the quick color list to the given list of colors.
-	inline void setQuickColors (const QList<LDQuickColor>& colors)
-	{
-		m_quickColors = colors;
-		updateColorToolbar();
-	}
-
-	// Adds a message to the renderer's message manager.
-	void addMessage (QString msg);
-
-	// Updates the object list. Right now this just rebuilds it.
-	void refreshObjectList();
-	void endAction();
-	QTreeWidget* getPrimitivesTree() const;
-	static QKeySequence defaultShortcut (QAction* act);
-	void loadShortcuts();
-	void saveShortcuts();
-	void applyToActions (std::function<void(QAction*)> function);
-
-	bool ringToolHiRes() const;
-	int ringToolSegments() const;
-	ConfigurationValueBag* configBag() { return &m_configOptions; }
-	class QSettings* makeSettings (QObject* parent = nullptr);
-	void syncSettings();
-	QVariant getConfigValue (QString name);
-	class QSettings* getSettings() { return m_settings; }
-	void createBlankDocument();
-	LDDocument* newDocument (bool cache = false);
-	const QList<LDDocument*>& allDocuments();
-	LDDocument* currentDocument();
-	void changeDocument (LDDocument* f);
-	void closeInitialDocument();
-	const LDObjectList& selectedObjects();
-	void currentDocumentClosed();
-
-	class ExtProgramToolset* externalPrograms()
-	{
-		return m_externalPrograms;
-	}
-
-	class GuiUtilities* guiUtilities()
-	{
-		return m_guiUtilities;
-	}
-
 public slots:
-	void updatePrimitives();
-	void tabSelected();
+	void actionTriggered();
+	void circleToolSegmentsChanged();
 	void closeTab (int tabindex);
 	void ringToolHiResClicked (bool clicked);
-	void circleToolSegmentsChanged();
-	void slot_action();
+	void tabSelected();
+	void updatePrimitives();
 
 protected:
 	void closeEvent (QCloseEvent* ev);
@@ -202,16 +131,16 @@
 
 	ConfigurationValueBag m_configOptions;
 	class GuiUtilities* m_guiUtilities;
-	GLRenderer*			m_renderer;
-	LDObjectList		m_sel;
+	GLRenderer* m_renderer;
+	LDObjectList m_sel;
 	QList<LDQuickColor>	m_quickColors;
 	QList<QToolButton*>	m_colorButtons;
-	QList<QAction*>		m_recentFiles;
-	MessageManager*		m_msglog;
+	QList<QAction*> m_recentFiles;
+	MessageManager* m_msglog;
 	class Ui_MainWindow& ui;
-	QTabBar*			m_tabs;
-	bool				m_updatingTabs;
-	QVector<Toolset*>	m_toolsets;
+	QTabBar* m_tabs;
+	bool m_updatingTabs;
+	QVector<Toolset*> m_toolsets;
 	QMap<QAction*, ToolInfo> m_toolmap;
 	class ExtProgramToolset* m_externalPrograms;
 	class QSettings* m_settings;
@@ -219,44 +148,39 @@
 	LDDocument* m_currentDocument;
 
 private slots:
-	void slot_selectionChanged();
-	void slot_recentFile();
-	void slot_quickColor();
-	void slot_lastSecondCleanup();
-	void slot_editObject (QListWidgetItem* listitem);
+	void selectionChanged();
+	void recentFileClicked();
+	void quickColorClicked();
+	void doLastSecondCleanup();
+	void objectListDoubleClicked (QListWidgetItem* listitem);
 };
 
-//! Pointer to the instance of MainWindow.
+// Pointer to the instance of MainWindow.
+// TODO: it's going out, slowly but surely.
 extern MainWindow* g_win;
 
-//! Get an icon by name from the resources directory.
+// Get an icon by name from the resources directory.
 QPixmap GetIcon (QString iconName);
 
-//! \returns a list of quick colors based on the configuration entry.
+// Returns a list of quick colors based on the configuration entry.
 QList<LDQuickColor> LoadQuickColorList();
 
-//! Asks the user a yes/no question with the given \c message and the given
-//! window \c title.
-//! \returns true if the user answered yes, false if no.
+// Asks the user a yes/no question with the given message and the given window title.
+// Returns true if the user answered yes, false if no.
 bool Confirm (const QString& title, const QString& message); // Generic confirm prompt
 
-//! An overload of \c confirm(), this asks the user a yes/no question with the
-//! given \c message.
-//! \returns true if the user answered yes, false if no.
+// An overload of confirm(), this asks the user a yes/no question with the given message.
+// Returns true if the user answered yes, false if no.
 bool Confirm (const QString& message);
 
-//! Displays an error prompt with the given \c message
+// Displays an error prompt with the given message
 void Critical (const QString& message);
 
-//! \returns a QImage from the given raw GL \c data
+// Returns a QImage from the given raw GL data
 QImage GetImageFromScreencap (uchar* data, int w, int h);
 
-//!
-//! Takes in pairs of radio buttons and respective values and finds the first
-//! selected one.
-//! \returns returns the value of the first found radio button that was checked
-//! \returns by the user.
-//!
+// Takes in pairs of radio buttons and respective values and finds the first selected one.
+// Returns returns the value of the first found radio button that was checked by the user.
 template<class T>
 T RadioSwitch (const T& defval, QList<Pair<QRadioButton*, T>> haystack)
 {
@@ -269,10 +193,8 @@
 	return defval;
 }
 
-//!
-//! Takes in pairs of radio buttons and respective values and checks the first
-//! found radio button whose respsective value matches \c expr have the given value.
-//!
+// Takes in pairs of radio buttons and respective values and checks the first found radio button whose respsective value
+// matches expr have the given value.
 template<class T>
 void RadioDefault (const T& expr, QList<Pair<QRadioButton*, T>> haystack)
 {
--- a/src/partDownloader.cpp	Sun Sep 06 01:22:25 2015 +0300
+++ b/src/partDownloader.cpp	Sun Sep 06 01:52:23 2015 +0300
@@ -326,7 +326,7 @@
 	{
 		g_win->changeDocument (primaryFile());
 		g_win->doFullRefresh();
-		g_win->R()->resetAngles();
+		g_win->renderer()->resetAngles();
 	}
 
 	for (LDDocument* f : m_files)
--- a/src/toolsets/algorithmtoolset.cpp	Sun Sep 06 01:22:25 2015 +0300
+++ b/src/toolsets/algorithmtoolset.cpp	Sun Sep 06 01:52:23 2015 +0300
@@ -369,7 +369,7 @@
 	if (obj and obj->next() and obj->next()->isScemantic())
 		currentDocument()->insertObj (idx, new LDEmpty);
 
-	m_window->buildObjList();
+	m_window->buildObjectList();
 	delete ui;
 }
 
@@ -424,7 +424,7 @@
 		obj->destroy();
 	}
 
-	m_window->buildObjList();
+	m_window->buildObjectList();
 	m_window->refresh();
 }
 
--- a/src/toolsets/basictoolset.cpp	Sun Sep 06 01:22:25 2015 +0300
+++ b/src/toolsets/basictoolset.cpp	Sun Sep 06 01:52:23 2015 +0300
@@ -70,7 +70,7 @@
 void BasicToolset::paste()
 {
 	const QString clipboardText = qApp->clipboard()->text();
-	int idx = m_window->getInsertionPoint();
+	int idx = m_window->suggestInsertPoint();
 	currentDocument()->clearSelection();
 	int num = 0;
 
@@ -159,7 +159,7 @@
 
 void BasicToolset::insertRaw()
 {
-	int idx = m_window->getInsertionPoint();
+	int idx = m_window->suggestInsertPoint();
 
 	QDialog* const dlg = new QDialog;
 	QVBoxLayout* const layout = new QVBoxLayout;
@@ -201,7 +201,7 @@
 	// If all selected objects have the same color, said color is our default
 	// value to the color selection dialog.
 	LDColor color;
-	LDColor defaultcol = m_window->getSelectedColor();
+	LDColor defaultcol = m_window->getUniformSelectedColor();
 
 	// Show the dialog to the user now and ask for a color.
 	if (ColorSelector::selectColor (m_window, color, defaultcol))
@@ -266,30 +266,30 @@
 
 void BasicToolset::modeSelect()
 {
-	m_window->R()->setEditMode (EditModeType::Select);
+	m_window->renderer()->setEditMode (EditModeType::Select);
 }
 
 void BasicToolset::modeDraw()
 {
-	m_window->R()->setEditMode (EditModeType::Draw);
+	m_window->renderer()->setEditMode (EditModeType::Draw);
 }
 
 void BasicToolset::modeRectangle()
 {
-	m_window->R()->setEditMode (EditModeType::Rectangle);
+	m_window->renderer()->setEditMode (EditModeType::Rectangle);
 }
 
 void BasicToolset::modeCircle()
 {
-	m_window->R()->setEditMode (EditModeType::Circle);
+	m_window->renderer()->setEditMode (EditModeType::Circle);
 }
 
 void BasicToolset::modeMagicWand()
 {
- 	m_window->R()->setEditMode (EditModeType::MagicWand);
+ 	m_window->renderer()->setEditMode (EditModeType::MagicWand);
 }
 
 void BasicToolset::modeLinePath()
 {
-	m_window->R()->setEditMode (EditModeType::LinePath);
+	m_window->renderer()->setEditMode (EditModeType::LinePath);
 }
\ No newline at end of file
--- a/src/toolsets/filetoolset.cpp	Sun Sep 06 01:22:25 2015 +0300
+++ b/src/toolsets/filetoolset.cpp	Sun Sep 06 01:52:23 2015 +0300
@@ -113,7 +113,7 @@
 void FileToolset::insertFrom()
 {
 	QString fname = QFileDialog::getOpenFileName();
-	int idx = m_window->getInsertionPoint();
+	int idx = m_window->suggestInsertPoint();
 
 	if (not fname.length())
 		return;
@@ -134,7 +134,7 @@
 	{
 		currentDocument()->insertObj (idx, obj);
 		obj->select();
-		m_window->R()->compileObject (obj);
+		m_window->renderer()->compileObject (obj);
 
 		idx++;
 	}
--- a/src/toolsets/movetoolset.cpp	Sun Sep 06 01:22:25 2015 +0300
+++ b/src/toolsets/movetoolset.cpp	Sun Sep 06 01:52:23 2015 +0300
@@ -29,7 +29,7 @@
 {
 	LDObjectList objs = selectedObjects();
 	LDObject::moveObjects (objs, up);
-	m_window->buildObjList();
+	m_window->buildObjectList();
 }
 
 void MoveToolset::moveUp()
--- a/src/toolsets/viewtoolset.cpp	Sun Sep 06 01:22:25 2015 +0300
+++ b/src/toolsets/viewtoolset.cpp	Sun Sep 06 01:52:23 2015 +0300
@@ -97,8 +97,8 @@
 
 void ViewToolset::resetView()
 {
-	m_window->R()->resetAngles();
-	m_window->R()->update();
+	m_window->renderer()->resetAngles();
+	m_window->renderer()->update();
 }
 
 void ViewToolset::screenshot()
@@ -106,7 +106,7 @@
 	setlocale (LC_ALL, "C");
 
 	int w, h;
-	uchar* imgdata = m_window->R()->getScreencap (w, h);
+	uchar* imgdata = m_window->renderer()->getScreencap (w, h);
 	QImage img = GetImageFromScreencap (imgdata, w, h);
 
 	QString root = Basename (currentDocument()->name());
@@ -128,7 +128,7 @@
 {
 	m_config->setDrawAxes (not m_config->drawAxes());
 	m_window->updateActions();
-	m_window->R()->update();
+	m_window->renderer()->update();
 }
 
 void ViewToolset::visibilityToggle()
@@ -152,7 +152,7 @@
 void ViewToolset::wireframe()
 {
 	m_config->setDrawWireframe (not m_config->drawWireframe());
-	m_window->R()->refresh();
+	m_window->renderer()->refresh();
 }
 
 void ViewToolset::setOverlay()
@@ -162,33 +162,33 @@
 	if (not dlg.exec())
 		return;
 
-	m_window->R()->setupOverlay ((ECamera) dlg.camera(), dlg.fpath(), dlg.ofsx(),
+	m_window->renderer()->setupOverlay ((ECamera) dlg.camera(), dlg.fpath(), dlg.ofsx(),
 		dlg.ofsy(), dlg.lwidth(), dlg.lheight());
 }
 
 void ViewToolset::clearOverlay()
 {
-	m_window->R()->clearOverlay();
+	m_window->renderer()->clearOverlay();
 }
 
 void ViewToolset::drawAngles()
 {
 	m_config->setDrawAngles (not m_config->drawAngles());
-	m_window->R()->refresh();
+	m_window->renderer()->refresh();
 }
 
 void ViewToolset::setDrawDepth()
 {
-	if (m_window->R()->camera() == EFreeCamera)
+	if (m_window->renderer()->camera() == EFreeCamera)
 		return;
 
 	bool ok;
 	double depth = QInputDialog::getDouble (m_window, "Set Draw Depth",
-		format ("Depth value for %1 Camera:", m_window->R()->getCameraName()),
-		m_window->R()->getDepthValue(), -10000.0f, 10000.0f, 3, &ok);
+		format ("Depth value for %1 Camera:", m_window->renderer()->getCameraName()),
+		m_window->renderer()->getDepthValue(), -10000.0f, 10000.0f, 3, &ok);
 
 	if (ok)
-		m_window->R()->setDepthValue (depth);
+		m_window->renderer()->setDepthValue (depth);
 }
 
 #if 0
@@ -248,7 +248,7 @@
 		m_config->setRandomColors (false);
 
 	m_window->updateActions();
-	m_window->R()->refresh();
+	m_window->renderer()->refresh();
 }
 
 void ViewToolset::jumpTo()
@@ -279,7 +279,7 @@
 		m_config->setBfcRedGreenView (false);
 
 	m_window->updateActions();
-	m_window->R()->refresh();
+	m_window->renderer()->refresh();
 }
 
 void ViewToolset::drawSurfaces()

mercurial