]> git.lyx.org Git - features.git/commitdiff
Fix bug #10346.
authorDaniel Ramoeller <d.lyx@web.de>
Wed, 12 Aug 2020 18:24:40 +0000 (14:24 -0400)
committerRichard Kimberly Heck <rikiheck@lyx.org>
Wed, 12 Aug 2020 18:25:36 +0000 (14:25 -0400)
Allow to open user and library directories from About LyX.

src/frontends/qt/GuiAbout.cpp
src/frontends/qt/GuiAbout.h
src/frontends/qt/GuiLog.cpp
src/frontends/qt/qt_helpers.cpp
src/frontends/qt/qt_helpers.h
src/frontends/qt/ui/AboutUi.ui

index a641e9ad8713eaf5d7edd9b53482d22901efc9a0..25c3a689ddf121e87320bb632a28189b5ef937b2 100644 (file)
@@ -11,6 +11,7 @@
 #include <config.h>
 
 #include "GuiAbout.h"
+#include "GuiApplication.h"
 
 #include "ui_AboutUi.h"
 
@@ -22,6 +23,7 @@
 #include "support/lstrings.h"
 #include "support/Package.h"
 
+#include <QClipboard>
 #include <QDate>
 #include <QFile>
 #include <QTextStream>
@@ -196,6 +198,33 @@ static QString disclaimer()
 }
 
 
+static QString buildinfo()
+{
+       QString res;
+       QTextStream out(&res);
+       out << "LyX " << lyx_version
+               << " (" << lyx_release_date << ")" << endl;
+       if (std::string(lyx_git_commit_hash) != "none")
+               out << qt_("  Git commit hash ")
+                   << QString(lyx_git_commit_hash).left(8) << endl;
+
+       out << lyx_version_info << endl;
+       return res;
+}
+
+
+static QString dirLibrary()
+{
+       return toqstr(makeDisplayPath(package().system_support().absFileName()));
+}
+
+
+static QString dirUser()
+{
+       return toqstr(makeDisplayPath(package().user_support().absFileName()));
+}
+
+
 static QString version()
 {
        QString loc_release_date;
@@ -216,41 +245,38 @@ static QString version()
        if (std::string(lyx_git_commit_hash) != "none")
                version_date += _("Built from git commit hash ")
                        + from_utf8(lyx_git_commit_hash).substr(0,8);
-       version_date += "\n";
 
        QString res;
        QTextStream out(&res);
-       out << toqstr(version_date);
-       out << qt_("Library directory: ");
-       out << toqstr(makeDisplayPath(package().system_support().absFileName()));
-       out << "\n";
-       out << qt_("User directory: ");
-       out << toqstr(makeDisplayPath(package().user_support().absFileName()));
-       out << "\n";
+       out << toqstr(version_date) << "\n";
        out << toqstr(bformat(_("Qt Version (run-time): %1$s"), from_ascii(qVersion()))) << "\n";
-       out << toqstr(bformat(_("Qt Version (compile-time): %1$s"), from_ascii(QT_VERSION_STR))) << "\n";
+       out << toqstr(bformat(_("Qt Version (compile-time): %1$s"), from_ascii(QT_VERSION_STR)));
        return res;
 }
 
-static QString buildinfo()
+
+struct GuiAbout::Private
 {
-       QString res;
-       QTextStream out(&res);
-       out << "LyX " << lyx_version
-               << " (" << lyx_release_date << ")" << endl;
-       if (std::string(lyx_git_commit_hash) != "none")
-               out << qt_("  Git commit hash ")
-                   << QString(lyx_git_commit_hash).left(8) << endl;
+       Ui::AboutUi ui;
+};
 
-       out << lyx_version_info << endl;
-       return res;
+void GuiAbout::on_showDirLibraryPB_clicked()
+{
+       showDirectory(package().system_support());
 }
 
 
-struct GuiAbout::Private
+void GuiAbout::on_showDirUserPB_clicked()
 {
-       Ui::AboutUi ui;
-};
+       showDirectory(package().user_support());
+}
+
+
+void GuiAbout::on_versionCopyPB_clicked()
+{
+       QClipboard *clipboard = QGuiApplication::clipboard();
+       clipboard->setText(version());
+}
 
 
 GuiAbout::GuiAbout(GuiView & lv)
@@ -259,6 +285,9 @@ GuiAbout::GuiAbout(GuiView & lv)
 {
        d->ui.setupUi(this);
 
+       // fix height to minimum
+       setFixedHeight(sizeHint().height());
+
        d->ui.copyrightTB->setPlainText(copyright());
        d->ui.copyrightTB->append(QString());
        d->ui.copyrightTB->append(license());
@@ -266,6 +295,8 @@ GuiAbout::GuiAbout(GuiView & lv)
        d->ui.copyrightTB->append(disclaimer());
 
        d->ui.versionLA->setText(version());
+       d->ui.dirLibraryLA->setText(dirLibrary());
+       d->ui.dirUserLA->setText(dirUser());
        d->ui.buildinfoTB->setText(buildinfo());
        d->ui.releasenotesTB->setHtml(release_notes());
        d->ui.releasenotesTB->setOpenExternalLinks(true);
index 200f0b7837db522793910c12d2255ed60924962d..acd485fe89736a821fda9bc5edc1b317473d6ab1 100644 (file)
@@ -27,6 +27,9 @@ public:
 
 private Q_SLOTS:
        void on_buttonBox_rejected();
+       void on_showDirLibraryPB_clicked();
+       void on_showDirUserPB_clicked();
+       void on_versionCopyPB_clicked();
 
 private:
        /// Controller stuff
index 341f06c8ce81085e6e0ffd9b963b002b47c2cc54..86828067d4c7d77a9262cea18b3bc70cb3ef3cfa 100644 (file)
 #include "support/gettext.h"
 #include "support/lstrings.h"
 
-#include <QDesktopServices>
 #include <QTextBrowser>
 #include <QSyntaxHighlighter>
-#include <QUrl>
 #include <QClipboard>
 
 #include <fstream>
@@ -191,18 +189,8 @@ void GuiLog::on_nextWarningPB_clicked()
 
 
 void GuiLog::on_openDirPB_clicked()
-{
-       support::FileName dir = logfile_.onlyPath();
-       if (!dir.exists())
-               return;
-       QUrl qdir(QUrl::fromLocalFile(toqstr(from_utf8(dir.absFileName()))));
-       // 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!");
+{      
+       showDirectory(logfile_.onlyPath());
 }
 
 
index d3da0ee7dea70816cc277eda00b6d019f2025c44..8225b91b47f43873ee35901bdeaa32fed061cd3a 100644 (file)
@@ -38,6 +38,8 @@
 #include <QApplication>
 #include <QCheckBox>
 #include <QComboBox>
+#include <QDesktopServices>
+#include <QDir>
 #include <QLineEdit>
 #include <QLocale>
 #include <QPalette>
@@ -275,6 +277,21 @@ void setSectionResizeMode(QHeaderView * view, QHeaderView::ResizeMode mode) {
        view->setResizeMode(mode);
 #endif
 }
+
+void showDirectory(FileName const & directory)
+{
+       if (!directory.exists())
+               return;
+       QUrl qurl(QUrl::fromLocalFile(QDir::toNativeSeparators(toqstr(directory.absFileName()))));
+       // Give hints in case of bugs
+       if (!qurl.isValid()) {
+               LYXERR0("QUrl is invalid!");
+               return;
+
+       }
+       if (!QDesktopServices::openUrl(qurl))
+               LYXERR0("Unable to open QUrl even though dir exists!");
+}
 } // namespace frontend
 
 QString const qt_(char const * str, const char *)
index 92872e08087cbda02b56f87f70a819adada52ebd..970a02707f41119eb0d7bed6c226fbe27c062fe1 100644 (file)
@@ -99,6 +99,8 @@ void setSectionResizeMode(QHeaderView * view,
     int logicalIndex, QHeaderView::ResizeMode mode);
 void setSectionResizeMode(QHeaderView * view,
        QHeaderView::ResizeMode mode);
+/// Shows a directory in OSs file browser
+void showDirectory(support::FileName const & directory);
 
 } // namespace frontend
 
index a7eecc02ec6843dc6c2c451c97068fbca4eb66c8..7f38644bb0241de4d30c40f0e2715ef75e48daf5 100644 (file)
@@ -7,7 +7,7 @@
     <x>0</x>
     <y>0</y>
     <width>424</width>
-    <height>258</height>
+    <height>370</height>
    </rect>
   </property>
   <property name="windowTitle">
         <number>6</number>
        </property>
        <property name="leftMargin">
-        <number>11</number>
+        <number>9</number>
        </property>
        <property name="topMargin">
-        <number>11</number>
+        <number>9</number>
        </property>
        <property name="rightMargin">
-        <number>11</number>
+        <number>9</number>
        </property>
        <property name="bottomMargin">
-        <number>11</number>
+        <number>9</number>
        </property>
        <item>
         <widget class="QLabel" name="versionLA">
-         <property name="frameShape">
-          <enum>QFrame::Box</enum>
-         </property>
-         <property name="frameShadow">
-          <enum>QFrame::Sunken</enum>
+         <property name="cursor">
+          <cursorShape>IBeamCursor</cursorShape>
          </property>
          <property name="text">
-          <string>Version goes here</string>
+          <string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;LyX version info goes here.&lt;/p&gt;&lt;p&gt;Qt version (run-time) goes here.&lt;/p&gt;&lt;p&gt;Qt version (compile-time) goes here.&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
          </property>
          <property name="alignment">
           <set>Qt::AlignCenter</set>
          </property>
-         <property name="margin">
-          <number>6</number>
+         <property name="wordWrap">
+          <bool>true</bool>
          </property>
          <property name="textInteractionFlags">
-          <set>Qt::TextSelectableByMouse</set>
+          <set>Qt::LinksAccessibleByMouse|Qt::TextSelectableByMouse</set>
+         </property>
+        </widget>
+       </item>
+       <item>
+        <spacer name="verticalSpacer">
+         <property name="orientation">
+          <enum>Qt::Vertical</enum>
          </property>
+         <property name="sizeHint" stdset="0">
+          <size>
+           <width>20</width>
+           <height>40</height>
+          </size>
+         </property>
+        </spacer>
+       </item>
+       <item>
+        <widget class="QGroupBox" name="gridGroupBox">
+         <property name="title">
+          <string>Library directory</string>
+         </property>
+         <layout class="QGridLayout" name="gridLayout_3">
+          <item row="0" column="1">
+           <widget class="QPushButton" name="showDirUserPB">
+            <property name="sizePolicy">
+             <sizepolicy hsizetype="Maximum" vsizetype="Fixed">
+              <horstretch>0</horstretch>
+              <verstretch>0</verstretch>
+             </sizepolicy>
+            </property>
+            <property name="text">
+             <string>Open</string>
+            </property>
+            <property name="flat">
+             <bool>false</bool>
+            </property>
+           </widget>
+          </item>
+          <item row="0" column="0">
+           <widget class="QLabel" name="dirLibraryLA">
+            <property name="sizePolicy">
+             <sizepolicy hsizetype="MinimumExpanding" vsizetype="Preferred">
+              <horstretch>0</horstretch>
+              <verstretch>0</verstretch>
+             </sizepolicy>
+            </property>
+            <property name="cursor">
+             <cursorShape>IBeamCursor</cursorShape>
+            </property>
+            <property name="text">
+             <string>Library directory goes here.</string>
+            </property>
+            <property name="textFormat">
+             <enum>Qt::PlainText</enum>
+            </property>
+            <property name="wordWrap">
+             <bool>true</bool>
+            </property>
+            <property name="textInteractionFlags">
+             <set>Qt::LinksAccessibleByMouse|Qt::TextSelectableByMouse</set>
+            </property>
+           </widget>
+          </item>
+         </layout>
+        </widget>
+       </item>
+       <item>
+        <widget class="QGroupBox" name="gridGroupBox1">
+         <property name="title">
+          <string>User directory</string>
+         </property>
+         <layout class="QGridLayout" name="gridLayout_4">
+          <item row="0" column="1">
+           <widget class="QPushButton" name="showDirLibraryPB">
+            <property name="sizePolicy">
+             <sizepolicy hsizetype="Maximum" vsizetype="Fixed">
+              <horstretch>0</horstretch>
+              <verstretch>0</verstretch>
+             </sizepolicy>
+            </property>
+            <property name="text">
+             <string>Open</string>
+            </property>
+           </widget>
+          </item>
+          <item row="0" column="0">
+           <widget class="QLabel" name="dirUserLA">
+            <property name="cursor">
+             <cursorShape>IBeamCursor</cursorShape>
+            </property>
+            <property name="text">
+             <string>User directory goes here.</string>
+            </property>
+            <property name="textFormat">
+             <enum>Qt::PlainText</enum>
+            </property>
+            <property name="wordWrap">
+             <bool>true</bool>
+            </property>
+            <property name="textInteractionFlags">
+             <set>Qt::LinksAccessibleByMouse|Qt::TextSelectableByMouse</set>
+            </property>
+           </widget>
+          </item>
+         </layout>
         </widget>
        </item>
       </layout>
        <string>Release Notes</string>
       </attribute>
       <layout class="QGridLayout">
+       <property name="leftMargin">
+        <number>9</number>
+       </property>
+       <property name="topMargin">
+        <number>9</number>
+       </property>
+       <property name="rightMargin">
+        <number>9</number>
+       </property>
+       <property name="bottomMargin">
+        <number>9</number>
+       </property>
+       <property name="spacing">
+        <number>6</number>
+       </property>
        <item row="0" column="0">
         <widget class="QTextBrowser" name="releasenotesTB"/>
        </item>
      <property name="bottomMargin">
       <number>0</number>
      </property>
+     <item>
+      <widget class="QPushButton" name="versionCopyPB">
+       <property name="text">
+        <string>Copy Version Info</string>
+       </property>
+      </widget>
+     </item>
      <item>
       <widget class="QDialogButtonBox" name="buttonBox">
        <property name="standardButtons">