3 * This file is part of LyX, the document processor.
4 * Licence details can be found in the file COPYING.
6 * \author Kalle Dalheimer
8 * Full author contact details are available in file CREDITS.
15 #include "GuiApplication.h"
17 #include "ui_AboutUi.h"
19 #include "qt_helpers.h"
22 #include "support/filetools.h"
23 #include "support/gettext.h"
24 #include "support/lstrings.h"
25 #include "support/Package.h"
29 #include <QTextStream>
31 using namespace lyx::support;
32 using lyx::support::package;
33 using lyx::support::makeDisplayPath;
40 static QDate release_date()
42 return QDate::fromString(QString(lyx_release_date), Qt::ISODate);
46 static QString credits()
49 QFile file(toqstr(package().system_support().absFileName()) + "/CREDITS");
50 QTextStream out(&res);
53 out << qt_("ERROR: LyX wasn't able to find the CREDITS file\n");
54 out << qt_("Please install correctly to estimate the great\n");
55 out << qt_("amount of work other people have done for the LyX project.");
57 file.open(QIODevice::ReadOnly);
58 if (!file.isReadable()) {
59 out << qt_("ERROR: LyX wasn't able to read the CREDITS file\n");
60 out << qt_("Please install correctly to estimate the great\n");
61 out << qt_("amount of work other people have done for the LyX project.");
63 QTextStream ts(&file);
68 if (line.startsWith("@b"))
69 out << "<b>" << line.mid(2) << "</b>";
70 else if (line.startsWith("@i")) {
71 if (line.startsWith("@iE-mail")) {
73 line.replace(QString(" () "), QString("@"));
74 line.replace(QString(" ! "), QString("."));
76 out << "<i>" << line.mid(2) << "</i>";
80 } while (!line.isNull());
88 static QString release_notes()
91 QFile file(toqstr(package().system_support().absFileName()) + "/RELEASE-NOTES");
92 QTextStream out(&res);
95 out << qt_("ERROR: LyX wasn't able to find the RELEASE-NOTES file\n");
96 out << qt_("Please install correctly to see what has changed\n");
97 out << qt_("for this version of LyX.");
99 file.open(QIODevice::ReadOnly);
100 if (!file.isReadable()) {
101 out << qt_("ERROR: LyX wasn't able to read the RELEASE-NOTES file\n");
102 out << qt_("Please install correctly to see what has changed\n");
103 out << qt_("for this version of LyX.");
105 QTextStream ts(&file);
106 ts.setCodec("UTF-8");
108 bool incomment = false;
111 // a simple markdown parser
112 line = ts.readLine();
116 // parse (:comments:)
117 if (line.startsWith("(:")) {
118 if (!line.endsWith(":)"))
121 } if (line.endsWith(":)") && incomment) {
127 // detect links to the tracker
128 line.replace(QRegExp("(bug )(\\#)(\\d+)*"),
129 "<a href=\"http://www.lyx.org/trac/ticket/\\3\">\\1\\3</a>");
132 if (line.startsWith("!!!")) {
138 out << "<h4>" << line.mid(3) << "</h4>";
140 else if (line.startsWith("!!")) {
146 out << "<h3>" << line.mid(2) << "</h3>";
147 } else if (line.startsWith("!")) {
153 out << "<h2>" << line.mid(1) << "</h2>";
155 } else if (line.startsWith("* ")) {
161 out << "<li>" << line.mid(2);
162 } else if (inlist && line.startsWith(" ")) {
173 } while (!line.isNull());
181 static QString copyright()
183 QString release_year = release_date().toString("yyyy");
184 docstring copy_message =
185 bformat(_("LyX is Copyright (C) 1995 by Matthias Ettrich,\n1995--%1$s LyX Team"),
186 qstring_to_ucs4(release_year));
187 return toqstr(copy_message);
191 static QString license()
193 return qt_("This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.");
197 static QString disclaimer()
199 return qt_("LyX is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.\nSee the GNU General Public License for more details.\nYou should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.");
203 static QString version()
205 QString loc_release_date;
206 QDate date = release_date();
207 if (date.isValid()) {
209 loc_release_date = loc.toString(date, QLocale::LongFormat);
211 if (QString(lyx_release_date) == "not released yet")
212 loc_release_date = qt_("not released yet");
214 loc_release_date = toqstr(lyx_release_date);
216 docstring version_date =
217 bformat(_("LyX Version %1$s\n(%2$s)"),
218 from_ascii(lyx_version),
219 qstring_to_ucs4(loc_release_date))+"\n";
220 if (std::string(lyx_git_commit_hash) != "none")
221 version_date += _("Built from git commit hash ")
222 + from_utf8(lyx_git_commit_hash).substr(0,8);
223 version_date += "\n";
226 QTextStream out(&res);
227 out << toqstr(version_date);
228 out << qt_("Library directory: ");
229 out << toqstr(makeDisplayPath(package().system_support().absFileName()));
231 out << qt_("User directory: ");
232 out << toqstr(makeDisplayPath(package().user_support().absFileName()));
234 out << toqstr(bformat(_("Qt Version (run-time): %1$s on platform %2$s"), from_ascii(qVersion()), qstring_to_ucs4(guiApp->platformName()))) << "\n";
235 out << toqstr(bformat(_("Qt Version (compile-time): %1$s"), from_ascii(QT_VERSION_STR))) << "\n";
239 static QString buildinfo()
242 QTextStream out(&res);
248 #if (QT_VERSION >= QT_VERSION_CHECK(5, 15, 0))
253 if (std::string(lyx_git_commit_hash) != "none")
254 out << qt_(" Git commit hash ")
255 << QString(lyx_git_commit_hash).left(8)
256 #if (QT_VERSION >= QT_VERSION_CHECK(5, 15, 0))
262 out << lyx_version_info
263 #if (QT_VERSION >= QT_VERSION_CHECK(5, 15, 0))
272 struct GuiAbout::Private
278 GuiAbout::GuiAbout(GuiView & lv)
279 : DialogView(lv, "aboutlyx", qt_("About LyX")),
280 d(new GuiAbout::Private)
284 d->ui.copyrightTB->setPlainText(copyright());
285 d->ui.copyrightTB->append(QString());
286 d->ui.copyrightTB->append(license());
287 d->ui.copyrightTB->append(QString());
288 d->ui.copyrightTB->append(disclaimer());
290 d->ui.versionLA->setText(version());
291 d->ui.buildinfoTB->setText(buildinfo());
292 d->ui.releasenotesTB->setHtml(release_notes());
293 d->ui.releasenotesTB->setOpenExternalLinks(true);
294 d->ui.creditsTB->setHtml(credits());
296 d->ui.tab->setUsesScrollButtons(false);
300 void GuiAbout::on_closePB_clicked()
306 Dialog * createGuiAbout(GuiView & lv) { return new GuiAbout(lv); }
309 } // namespace frontend
312 #include "moc_GuiAbout.cpp"