mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-11-26 11:16:55 +00:00
Fix bug #10346.
Allow to open user and library directories from About LyX.
This commit is contained in:
parent
13b928d534
commit
01b2893f8b
@ -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,33 +245,12 @@ 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";
|
||||
return res;
|
||||
}
|
||||
|
||||
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;
|
||||
out << toqstr(bformat(_("Qt Version (compile-time): %1$s"), from_ascii(QT_VERSION_STR)));
|
||||
return res;
|
||||
}
|
||||
|
||||
@ -252,6 +260,24 @@ struct GuiAbout::Private
|
||||
Ui::AboutUi ui;
|
||||
};
|
||||
|
||||
void GuiAbout::on_showDirLibraryPB_clicked()
|
||||
{
|
||||
showDirectory(package().system_support());
|
||||
}
|
||||
|
||||
|
||||
void GuiAbout::on_showDirUserPB_clicked()
|
||||
{
|
||||
showDirectory(package().user_support());
|
||||
}
|
||||
|
||||
|
||||
void GuiAbout::on_versionCopyPB_clicked()
|
||||
{
|
||||
QClipboard *clipboard = QGuiApplication::clipboard();
|
||||
clipboard->setText(version());
|
||||
}
|
||||
|
||||
|
||||
GuiAbout::GuiAbout(GuiView & lv)
|
||||
: DialogView(lv, "aboutlyx", qt_("About LyX")),
|
||||
@ -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);
|
||||
|
@ -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
|
||||
|
@ -25,10 +25,8 @@
|
||||
#include "support/gettext.h"
|
||||
#include "support/lstrings.h"
|
||||
|
||||
#include <QDesktopServices>
|
||||
#include <QTextBrowser>
|
||||
#include <QSyntaxHighlighter>
|
||||
#include <QUrl>
|
||||
#include <QClipboard>
|
||||
|
||||
#include <fstream>
|
||||
@ -192,17 +190,7 @@ 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());
|
||||
}
|
||||
|
||||
|
||||
|
@ -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 *)
|
||||
|
@ -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
|
||||
|
||||
|
@ -7,7 +7,7 @@
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>424</width>
|
||||
<height>258</height>
|
||||
<height>370</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
@ -46,39 +46,140 @@
|
||||
<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><html><head/><body><p>LyX version info goes here.</p><p>Qt version (run-time) goes here.</p><p>Qt version (compile-time) goes here.</p></body></html></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>
|
||||
</widget>
|
||||
<widget class="QWidget" name="creditstab">
|
||||
@ -161,6 +262,21 @@
|
||||
<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>
|
||||
@ -185,6 +301,13 @@
|
||||
<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">
|
||||
|
Loading…
Reference in New Issue
Block a user