]> git.lyx.org Git - lyx.git/blobdiff - src/frontends/qt4/GuiAbout.cpp
QDialogButtonBox for the remaining dialogs.
[lyx.git] / src / frontends / qt4 / GuiAbout.cpp
index 8ceed8f5e36e60ffd1dd601e4f23dd546151c44a..747723ff0680bcab06f168997b41e72358697d53 100644 (file)
@@ -23,8 +23,8 @@
 #include "support/Package.h"
 
 #include <QDate>
-#include <QtCore>
-#include <QtGui>
+#include <QFile>
+#include <QTextStream>
 
 using namespace lyx::support;
 using lyx::support::package;
@@ -47,30 +47,125 @@ static QString credits()
        QFile file(toqstr(package().system_support().absFileName()) + "/CREDITS");
        QTextStream out(&res);
 
-       if (file.isReadable()) {
-               out << qt_("ERROR: LyX wasn't able to read CREDITS file\n");
-               out << qt_("Please install correctly to estimate the great\n");
-               out << qt_("amount of work other people have done for the LyX project.");
+       if (!file.exists()) {
+               out << qt_("ERROR: LyX wasn't able to find the CREDITS file\n");
+               out << qt_("Please install correctly to estimate the great\namount of work other people have done for the LyX project.");
        } else {
                file.open(QIODevice::ReadOnly);
-               QTextStream ts(&file);
-               ts.setCodec("UTF-8");
-               QString line;
-               do {
-                       line = ts.readLine();
-                       if (line.startsWith("@b"))
-                               out << "<b>" << line.mid(2) << "</b>";
-                       else if (line.startsWith("@i")) {
-                               if (line.startsWith("@iE-mail")) {
-                                       // unmask email
-                                       line.replace(QString(" () "), QString("@"));
-                                       line.replace(QString(" ! "), QString("."));
+               if (!file.isReadable()) {
+                       out << qt_("ERROR: LyX wasn't able to read the CREDITS file\n");
+                       out << qt_("Please install correctly to estimate the great\namount of work other people have done for the LyX project.");
+               } else {
+                       QTextStream ts(&file);
+                       ts.setCodec("UTF-8");
+                       QString line;
+                       do {
+                               line = ts.readLine();
+                               if (line.startsWith("@b"))
+                                       out << "<b>" << line.mid(2) << "</b>";
+                               else if (line.startsWith("@i")) {
+                                       if (line.startsWith("@iE-mail")) {
+                                               // unmask email
+                                               line.replace(QString(" () "), QString("@"));
+                                               line.replace(QString(" ! "), QString("."));
+                                       }
+                                       out << "<i>" << line.mid(2) << "</i>";
+                               } else
+                                       out << line;
+                               out << "<br>";
+                       } while (!line.isNull());
+               }
+       }
+       out.flush();
+       return res;
+}
+
+
+static QString release_notes()
+{
+       QString res;
+       QFile file(toqstr(package().system_support().absFileName()) + "/RELEASE-NOTES");
+       QTextStream out(&res);
+
+       if (!file.exists()) {
+               out << qt_("ERROR: LyX wasn't able to find the RELEASE-NOTES file\n");
+               out << qt_("Please install correctly to see what has changed\nfor this version of LyX.");
+       } else {
+               file.open(QIODevice::ReadOnly);
+               if (!file.isReadable()) {
+                       out << qt_("ERROR: LyX wasn't able to read the RELEASE-NOTES file\n");
+                       out << qt_("Please install correctly to see what has changed\nfor this version of LyX.");
+               } else {
+                       QTextStream ts(&file);
+                       ts.setCodec("UTF-8");
+                       QString line;
+                       bool incomment = false;
+                       bool inlist = false;
+                       do {
+                               // a simple markdown parser
+                               line = ts.readLine();
+                               // skipe empty lines
+                               if (line.isEmpty())
+                                       continue;
+                               // parse (:comments:)
+                               if (line.startsWith("(:")) {
+                                       if (!line.endsWith(":)"))
+                                               incomment = true;
+                                       continue;
+                               } if (line.endsWith(":)") && incomment) {
+                                       incomment = false;
+                                       continue;
+                               } if (incomment)
+                                       continue;
+
+                               // detect links to the tracker
+                               line.replace(QRegExp("(bug )(\\#)(\\d+)*"),
+                                            "<a href=\"http://www.lyx.org/trac/ticket/\\3\">\\1\\3</a>");
+
+                               // headings
+                               if (line.startsWith("!!!")) {
+                                       if (inlist) {
+                                           out << "</li>";
+                                           out << "</ul><br>";
+                                           inlist = false;
+                                       }
+                                       out << "<h4>" << line.mid(3) << "</h4>";
                                }
-                               out << "<i>" << line.mid(2) << "</i>";
-                       } else
-                               out << line;
-                       out << "<br>";
-               } while (!line.isNull());
+                               else if (line.startsWith("!!")) {
+                                       if (inlist) {
+                                           out << "</li>";
+                                           out << "</ul><br>";
+                                           inlist = false;
+                                       }
+                                       out << "<h3>" << line.mid(2) << "</h3>";
+                               } else if (line.startsWith("!")) {
+                                       if (inlist) {
+                                           out << "</li>";
+                                           out << "</ul><br>";
+                                           inlist = false;
+                                       }
+                                       out << "<h2>" << line.mid(1) << "</h2>";
+                               // lists
+                               } else if (line.startsWith("* ")) {
+                                       if (inlist)
+                                               out << "</li>";
+                                       else
+                                               out << "<ul>";
+                                       inlist = true;
+                                       out << "<li>" << line.mid(2);
+                               } else if (inlist && line.startsWith("  ")) {
+                                       out << line.mid(2);
+                               } else if (inlist) {
+                                       inlist = false;
+                                       out << "</li>";
+                                       out << "</ul><br>";
+                                       out << line;
+                               } else
+                                       out << line;
+
+                               out << " ";
+                       } while (!line.isNull());
+               }
        }
        out.flush();
        return res;
@@ -115,7 +210,12 @@ static QString version()
        docstring version_date =
                bformat(_("LyX Version %1$s\n(%2$s)"),
                        from_ascii(lyx_version),
-                       qstring_to_ucs4(loc_release_date))+"\n\n";
+                       qstring_to_ucs4(loc_release_date))+"\n";
+       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);
@@ -124,11 +224,9 @@ static QString version()
        out << "\n";
        out << qt_("User directory: ");
        out << toqstr(makeDisplayPath(package().user_support().absFileName()));
-#ifdef DEVEL_VERSION
        out << "\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";
-#endif
        return res;
 }
 
@@ -138,8 +236,9 @@ static QString buildinfo()
        QTextStream out(&res);
        out << "LyX " << lyx_version
                << " (" << lyx_release_date << ")" << endl;
-       out << toqstr(bformat(_("Built on %1$s[[date]], %2$s[[time]]"),
-               from_ascii(__DATE__), from_ascii(__TIME__))) << 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;
@@ -166,11 +265,15 @@ GuiAbout::GuiAbout(GuiView & lv)
 
        d->ui.versionLA->setText(version());
        d->ui.buildinfoTB->setText(buildinfo());
+       d->ui.releasenotesTB->setHtml(release_notes());
+       d->ui.releasenotesTB->setOpenExternalLinks(true);
        d->ui.creditsTB->setHtml(credits());
+
+       d->ui.tab->setUsesScrollButtons(false);
 }
 
 
-void GuiAbout::on_closePB_clicked()
+void GuiAbout::on_buttonBox_rejected()
 {
        close();
 }