]> git.lyx.org Git - features.git/commitdiff
Add "Open Containing Directory" button to the log dialog (#9211, #9834)
authorGuillaume Munch <gm@lyx.org>
Mon, 2 Nov 2015 18:19:40 +0000 (18:19 +0000)
committerGuillaume Munch <gm@lyx.org>
Tue, 3 Nov 2015 03:54:52 +0000 (03:54 +0000)
It takes the place of the "Copy to Clipboard" button which was redundant.

src/frontends/qt4/GuiLog.cpp
src/frontends/qt4/GuiLog.h
src/frontends/qt4/ui/LogUi.ui

index 14e7aaf73a035fd7b95fd33eb4eb8a1a76d15059..427e98961a142ac4de1f7b51addfe677ac8cdc44 100644 (file)
 #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 =
index 2a9ebb6e7a44d5233b2da13c9bd643bc1f7aa5d9..8159836c39685a4da3bfcbac799fece68865cb63 100644 (file)
@@ -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);
 
index ddf6ebcd39a863e11aed8cab31f81af249f64ba6..f2497fedc8f4b4cdd7ce339d69e2e9adb6c0b801 100644 (file)
@@ -1,3 +1,4 @@
+<?xml version="1.0" encoding="UTF-8"?>
 <ui version="4.0" >
  <class>LogUi</class>
  <widget class="QDialog" name="LogUi" >
     </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 Containing Directory</string>
      </property>
     </widget>
    </item>