- added an action for opening the subfiles pointed to by selected references as editable documents

Mon, 02 Jun 2014 14:34:23 +0300

author
Santeri Piippo <crimsondusk64@gmail.com>
date
Mon, 02 Jun 2014 14:34:23 +0300
changeset 788
c9d1dad83ad0
parent 787
67cc5b47bbff
child 789
4b7306f52bb5

- added an action for opening the subfiles pointed to by selected references as editable documents

changelog.txt file | annotate | diff | comparison | revisions
src/actions.cc file | annotate | diff | comparison | revisions
src/ldDocument.cc file | annotate | diff | comparison | revisions
src/mainWindow.cc file | annotate | diff | comparison | revisions
src/mainWindow.h file | annotate | diff | comparison | revisions
ui/ldforge.ui file | annotate | diff | comparison | revisions
--- a/changelog.txt	Mon Jun 02 13:35:41 2014 +0300
+++ b/changelog.txt	Mon Jun 02 14:34:23 2014 +0300
@@ -35,6 +35,7 @@
 +	- Selecting an invertnext'd object now also selects the invertnext.
 +	- Made the coordinate rounding precision configurable.
 +	- Inverting a subfile now detects whether the subfile is flat and flips it if it is instead of naively invertnexting everything.
++	- Added an action for opening the subfiles pointed to by selected references as editable documents.
 
 -	- The camera is now changed to the top one if switching to draw mode while using the free camera instead of disabling the draw mode.
 -	- The color selector now uses the color's edge color for the borders instead of black.
--- a/src/actions.cc	Mon Jun 02 13:35:41 2014 +0300
+++ b/src/actions.cc	Mon Jun 02 14:34:23 2014 +0300
@@ -895,4 +895,17 @@
 
 	updateActions();
 	R()->refresh();
-}
\ No newline at end of file
+}
+
+DEFINE_ACTION (OpenSubfiles, 0)
+{
+	for (LDObjectPtr obj : selection())
+	{
+		LDSubfilePtr ref = obj.dynamicCast<LDSubfile>();
+
+		if (ref == null || not ref->fileInfo()->isImplicit())
+			continue;
+
+		ref->fileInfo()->setImplicit (false);
+	}
+}
--- a/src/ldDocument.cc	Mon Jun 02 13:35:41 2014 +0300
+++ b/src/ldDocument.cc	Mon Jun 02 14:34:23 2014 +0300
@@ -168,7 +168,15 @@
 		m_isImplicit = a;
 
 		if (a == false)
+		{
 			g_explicitDocuments << self().toStrongRef();
+			print ("Opened %1", name());
+
+			// Implicit files are not compiled by the GL renderer. Now that this
+			// part is no longer implicit, it needs to be compiled.
+			if (g_win != null)
+				g_win->R()->compiler()->compileDocument (self());
+		}
 		else
 		{
 			g_explicitDocuments.removeOne (self().toStrongRef());
--- a/src/mainWindow.cc	Mon Jun 02 13:35:41 2014 +0300
+++ b/src/mainWindow.cc	Mon Jun 02 14:34:23 2014 +0300
@@ -622,6 +622,17 @@
 	const bool single = (selection().size() == 1);
 	LDObjectPtr singleObj = single ? selection().first() : LDObjectPtr();
 
+	bool hasSubfiles = false;
+
+	for (LDObjectPtr obj : selection())
+	{
+		if (obj->type() == OBJ_Subfile)
+		{
+			hasSubfiles = true;
+			break;
+		}
+	}
+
 	QMenu* contextMenu = new QMenu;
 
 	if (single && singleObj->type() != OBJ_Empty)
@@ -643,6 +654,14 @@
 	contextMenu->addAction (ui->actionBorders);
 	contextMenu->addAction (ui->actionSetOverlay);
 	contextMenu->addAction (ui->actionClearOverlay);
+
+	if (hasSubfiles)
+	{
+		contextMenu->addSeparator();
+		contextMenu->addAction (ui->actionOpenSubfiles);
+	}
+
+	contextMenu->addSeparator();
 	contextMenu->addAction (ui->actionModeSelect);
 	contextMenu->addAction (ui->actionModeDraw);
 	contextMenu->addAction (ui->actionModeCircle);
--- a/src/mainWindow.h	Mon Jun 02 13:35:41 2014 +0300
+++ b/src/mainWindow.h	Mon Jun 02 14:34:23 2014 +0300
@@ -286,6 +286,7 @@
 		void slot_actionSubfileSelection();
 		void slot_actionDrawAngles();
 		void slot_actionRandomColors();
+		void slot_actionOpenSubfiles();
 
 	protected:
 		void closeEvent (QCloseEvent* ev);
--- a/ui/ldforge.ui	Mon Jun 02 13:35:41 2014 +0300
+++ b/ui/ldforge.ui	Mon Jun 02 14:34:23 2014 +0300
@@ -60,7 +60,7 @@
      <x>0</x>
      <y>0</y>
      <width>1010</width>
-     <height>27</height>
+     <height>24</height>
     </rect>
    </property>
    <widget class="QMenu" name="menuFile">
@@ -177,6 +177,7 @@
     <addaction name="actionReplaceCoords"/>
     <addaction name="actionFlip"/>
     <addaction name="actionDemote"/>
+    <addaction name="actionOpenSubfiles"/>
     <addaction name="separator"/>
     <addaction name="actionVisibilityHide"/>
     <addaction name="actionVisibilityToggle"/>
@@ -1364,6 +1365,14 @@
     <string>Random colors</string>
    </property>
   </action>
+  <action name="actionOpenSubfiles">
+   <property name="text">
+    <string>Open Subfiles</string>
+   </property>
+   <property name="toolTip">
+    <string>Opens the documents used by the selected subparts for editing.</string>
+   </property>
+  </action>
  </widget>
  <resources>
   <include location="../ldforge.qrc"/>

mercurial