Le 28/10/2015 16:39, Ilan a écrit :
Thanks David and Stephan.

My problem is that I'm working on a multi-file project so under the tmp
directory there are several directories and the location of the Latex file
depends on the file I compiled (and of course the tmp directory has a different
name each time under windows).

What I used to do until few months ago is opening the Latex log, and there I
saw the full path to the compiled file, so I could copy it to a Latex editor.
After some updates to Lyx & Latex, I see in the log only the file name without
the path.

I can (and this is what I do) to find the current tmp directory and then
searching for all the Latex files to find the right one by its name.
I hoped there is an option to return to the previous state of easily finding
the directory with a click.



(from <http://www.lyx.org/trac/ticket/9834>)


Dear List,

(continuing on lyx-devel)


Here's a proof-of-concept patch to add an “Open directory…” button to the log dialog. I did it very quickly which is why I only call it “proof-of-concept”. If we want to commit this then at least somebody with better QtDesigner skills should add the button to the interface in a more proper way.

I, too, used to spend too much time finding the proper lyxtmpdir (for various reasons ranging from debugging the latex output using divide-and-conquer when LyX's debugging facility was unsufficient, to debugging instant preview). And I think it's not too bad to expose the LyX internals in this way.

What do you think?


Guillaume
>From 7f97044ddbe67ccd83c6460878045aabf134c443 Mon Sep 17 00:00:00 2001
From: Guillaume Munch <g...@lyx.org>
Date: Mon, 2 Nov 2015 18:19:40 +0000
Subject: [PATCH] Add "Open directory..." button to the log dialog.

Proof of concept.
---
 src/frontends/qt4/GuiLog.cpp  |  17 +++++
 src/frontends/qt4/GuiLog.h    |   2 +
 src/frontends/qt4/ui/LogUi.ui | 150 ++++++++++++++++++++++--------------------
 3 files changed, 98 insertions(+), 71 deletions(-)

diff --git a/src/frontends/qt4/GuiLog.cpp b/src/frontends/qt4/GuiLog.cpp
index 14e7aaf..1db6f99 100644
--- a/src/frontends/qt4/GuiLog.cpp
+++ b/src/frontends/qt4/GuiLog.cpp
@@ -24,8 +24,10 @@
 #include "support/FileName.h"
 #include "support/gettext.h"
 
+#include <QDesktopServices>
 #include <QTextBrowser>
 #include <QSyntaxHighlighter>
+#include <QUrl>
 #include <QClipboard>
 
 #include <fstream>
@@ -189,6 +191,21 @@ void GuiLog::on_nextWarningPB_clicked()
 }
 
 
+void GuiLog::on_openDirPB_clicked()
+{
+	support::FileName dir = logfile_.onlyPath();
+	QUrl qdir(toqstr(from_utf8("file://" + dir.absFileName())),
+			  QUrl::StrictMode);
+	if (dir.exists()) {
+		// Give hints in case of bugs
+		if (!qdir.isValid())
+			LYXERR0("QUrl is invalid!");
+		if (!QDesktopServices::openUrl(qdir))
+			LYXERR0("Unable to open QUrl although dir exists.");
+	}
+}
+
+
 void GuiLog::goTo(QRegExp const & exp) const
 {
 	QTextCursor const newc =
diff --git a/src/frontends/qt4/GuiLog.h b/src/frontends/qt4/GuiLog.h
index 2a9ebb6..8159836 100644
--- a/src/frontends/qt4/GuiLog.h
+++ b/src/frontends/qt4/GuiLog.h
@@ -41,6 +41,8 @@ private Q_SLOTS:
 	void on_nextErrorPB_clicked();
 	/// jump to next warning
 	void on_nextWarningPB_clicked();
+	/// open containing directory
+	void on_openDirPB_clicked();
 	/// Log type changed
 	void typeChanged(int);
 
diff --git a/src/frontends/qt4/ui/LogUi.ui b/src/frontends/qt4/ui/LogUi.ui
index ddf6ebc..6a4f49b 100644
--- a/src/frontends/qt4/ui/LogUi.ui
+++ b/src/frontends/qt4/ui/LogUi.ui
@@ -1,60 +1,68 @@
-<ui version="4.0" >
+<?xml version="1.0" encoding="UTF-8"?>
+<ui version="4.0">
  <class>LogUi</class>
- <widget class="QDialog" name="LogUi" >
-  <property name="geometry" >
+ <widget class="QDialog" name="LogUi">
+  <property name="geometry">
    <rect>
     <x>0</x>
     <y>0</y>
-    <width>421</width>
+    <width>454</width>
     <height>474</height>
    </rect>
   </property>
-  <property name="windowTitle" >
+  <property name="windowTitle">
    <string/>
   </property>
-  <property name="sizeGripEnabled" >
+  <property name="sizeGripEnabled">
    <bool>true</bool>
   </property>
-  <layout class="QGridLayout" >
-   <property name="margin" >
+  <layout class="QGridLayout">
+   <property name="margin">
     <number>9</number>
    </property>
-   <property name="spacing" >
+   <property name="spacing">
     <number>6</number>
    </property>
-   <item row="3" column="0" >
-    <widget class="QLabel" name="findLA" >
-     <property name="text" >
+   <item row="4" column="0" colspan="2">
+    <widget class="QPushButton" name="copyPB">
+     <property name="text">
+      <string>Copy to Clip&amp;board</string>
+     </property>
+    </widget>
+   </item>
+   <item row="3" column="0">
+    <widget class="QLabel" name="findLA">
+     <property name="text">
       <string>&amp;Find:</string>
      </property>
-     <property name="buddy" >
+     <property name="buddy">
       <cstring>findLE</cstring>
      </property>
     </widget>
    </item>
-   <item row="3" column="1" colspan="5" >
-    <widget class="QLineEdit" name="findLE" >
-     <property name="toolTip" >
+   <item row="3" column="1" colspan="5">
+    <widget class="QLineEdit" name="findLE">
+     <property name="toolTip">
       <string>Hit Enter to search, or click Go!</string>
      </property>
     </widget>
    </item>
-   <item row="0" column="0" >
-    <widget class="QLabel" name="logTypeLA" >
-     <property name="text" >
+   <item row="0" column="0">
+    <widget class="QLabel" name="logTypeLA">
+     <property name="text">
       <string>Log &amp;Type:</string>
      </property>
-     <property name="buddy" >
+     <property name="buddy">
       <cstring>logTypeCO</cstring>
      </property>
     </widget>
    </item>
-   <item row="0" column="4" colspan="3" >
+   <item row="0" column="4" colspan="3">
     <spacer>
-     <property name="orientation" >
+     <property name="orientation">
       <enum>Qt::Horizontal</enum>
      </property>
-     <property name="sizeHint" >
+     <property name="sizeHint" stdset="0">
       <size>
        <width>161</width>
        <height>20</height>
@@ -62,41 +70,41 @@
      </property>
     </spacer>
    </item>
-   <item row="0" column="1" colspan="3" >
-    <widget class="QComboBox" name="logTypeCO" />
+   <item row="0" column="1" colspan="3">
+    <widget class="QComboBox" name="logTypeCO"/>
    </item>
-   <item row="1" column="0" colspan="7" >
-    <widget class="QTextBrowser" name="logTB" />
+   <item row="1" column="0" colspan="7">
+    <widget class="QTextBrowser" name="logTB"/>
    </item>
-   <item row="4" column="4" colspan="2" >
-    <widget class="QPushButton" name="updatePB" >
-     <property name="toolTip" >
+   <item row="4" column="4" colspan="2">
+    <widget class="QPushButton" name="updatePB">
+     <property name="toolTip">
       <string>Update the display</string>
      </property>
-     <property name="text" >
+     <property name="text">
       <string>&amp;Update</string>
      </property>
-     <property name="default" >
+     <property name="default">
       <bool>true</bool>
      </property>
     </widget>
    </item>
-   <item row="4" column="6" >
-    <widget class="QPushButton" name="closePB" >
-     <property name="text" >
+   <item row="4" column="6">
+    <widget class="QPushButton" name="closePB">
+     <property name="text">
       <string>&amp;Close</string>
      </property>
     </widget>
    </item>
-   <item row="4" column="2" colspan="2" >
+   <item row="4" column="2" colspan="2">
     <spacer>
-     <property name="orientation" >
+     <property name="orientation">
       <enum>Qt::Horizontal</enum>
      </property>
-     <property name="sizeType" >
+     <property name="sizeType">
       <enum>QSizePolicy::Expanding</enum>
      </property>
-     <property name="sizeHint" >
+     <property name="sizeHint" stdset="0">
       <size>
        <width>111</width>
        <height>26</height>
@@ -104,53 +112,53 @@
      </property>
     </spacer>
    </item>
-   <item row="4" column="0" colspan="2" >
-    <widget class="QPushButton" name="copyPB" >
-     <property name="text" >
-      <string>Copy to Clip&amp;board</string>
-     </property>
-    </widget>
-   </item>
-   <item row="2" column="0" colspan="3" >
-    <spacer>
-     <property name="orientation" >
-      <enum>Qt::Horizontal</enum>
-     </property>
-     <property name="sizeHint" >
-      <size>
-       <width>201</width>
-       <height>20</height>
-      </size>
-     </property>
-    </spacer>
-   </item>
-   <item row="3" column="6" >
-    <widget class="QPushButton" name="findPB" >
-     <property name="text" >
+   <item row="3" column="6">
+    <widget class="QPushButton" name="findPB">
+     <property name="text">
       <string>&amp;Go!</string>
      </property>
     </widget>
    </item>
-   <item row="2" column="5" colspan="2" >
-    <widget class="QPushButton" name="nextWarningPB" >
-     <property name="toolTip" >
+   <item row="2" column="5" colspan="2">
+    <widget class="QPushButton" name="nextWarningPB">
+     <property name="toolTip">
       <string>Jump to the next warning message.</string>
      </property>
-     <property name="text" >
+     <property name="text">
       <string>Next &amp;Warning</string>
      </property>
     </widget>
    </item>
-   <item row="2" column="3" colspan="2" >
-    <widget class="QPushButton" name="nextErrorPB" >
-     <property name="toolTip" >
+   <item row="2" column="3" colspan="2">
+    <widget class="QPushButton" name="nextErrorPB">
+     <property name="toolTip">
       <string>Jump to the next error message.</string>
      </property>
-     <property name="text" >
+     <property name="text">
       <string>Next &amp;Error</string>
      </property>
     </widget>
    </item>
+   <item row="2" column="2">
+    <spacer>
+     <property name="orientation">
+      <enum>Qt::Horizontal</enum>
+     </property>
+     <property name="sizeHint" stdset="0">
+      <size>
+       <width>201</width>
+       <height>20</height>
+      </size>
+     </property>
+    </spacer>
+   </item>
+   <item row="2" column="0" colspan="2">
+    <widget class="QPushButton" name="openDirPB">
+     <property name="text">
+      <string>&amp;Open directory...</string>
+     </property>
+    </widget>
+   </item>
   </layout>
  </widget>
  <tabstops>
@@ -160,7 +168,7 @@
   <tabstop>closePB</tabstop>
  </tabstops>
  <includes>
-  <include location="local" >qt_i18n.h</include>
+  <include location="local">qt_i18n.h</include>
  </includes>
  <resources/>
  <connections/>
-- 
2.1.4

Reply via email to