Le 02/11/2015 21:10, Andrew Parsloe a écrit :
Your proposed button would also solve #9211 "Make the lyxpreview.log
files accessible within LyX".



I agree, part of this idea comes from all the times I had to debug lyx
previews (but not only).


For the interface, I also propose to substitute the extant “Copy to
clipboard” button with this “Open directory...” button to avoid making
the interface heavier. Indeed, “Copy to clipboard” is twice redundant:
1. With “open directory” one can open the original log file in an editor.
2. One can already do Ctrl+A in the dialog, or right mouse button ▷
Select all, then copy.

Any user of the "Copy to clipboard" button would object?


I propose to commit the attached which solves the UI issues of the
previous patch.



Guillaume
>From ea6b85adc95be9625a203f35009edfe5ee0deee5 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.
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

It takes the place of the “Copy to Clipboard” button which was redundant.
---
 src/frontends/qt4/GuiLog.cpp  | 19 +++++++++++++++++++
 src/frontends/qt4/GuiLog.h    |  2 ++
 src/frontends/qt4/ui/LogUi.ui |  5 +++--
 3 files changed, 24 insertions(+), 2 deletions(-)

diff --git a/src/frontends/qt4/GuiLog.cpp b/src/frontends/qt4/GuiLog.cpp
index 14e7aaf..427e989 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,23 @@ void GuiLog::on_nextWarningPB_clicked()
 }
 
 
+void GuiLog::on_openDirPB_clicked()
+{
+	support::FileName dir = logfile_.onlyPath();
+	if (!dir.exists())
+		return;
+	QUrl qdir(toqstr(from_utf8("file://" + dir.absFileName())),
+			  QUrl::StrictMode);
+	// Give hints in case of bugs
+	if (!qdir.isValid()) {
+		LYXERR0("QUrl is invalid!");
+		return;
+	}
+	if (!QDesktopServices::openUrl(qdir))
+		LYXERR0("Unable to open QUrl even though 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..ebbc9dd 100644
--- a/src/frontends/qt4/ui/LogUi.ui
+++ b/src/frontends/qt4/ui/LogUi.ui
@@ -1,3 +1,4 @@
+<?xml version="1.0" encoding="UTF-8"?>
 <ui version="4.0" >
  <class>LogUi</class>
  <widget class="QDialog" name="LogUi" >
@@ -105,9 +106,9 @@
     </spacer>
    </item>
    <item row="4" column="0" colspan="2" >
-    <widget class="QPushButton" name="copyPB" >
+    <widget class="QPushButton" name="openDirPB" >
      <property name="text" >
-      <string>Copy to Clip&amp;board</string>
+      <string>&amp;Open directory...</string>
      </property>
     </widget>
    </item>
-- 
2.1.4

Reply via email to