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 "ui_AboutUi.h"
17 #include "qt_helpers.h"
20 #include "support/filetools.h"
21 #include "support/gettext.h"
22 #include "support/lstrings.h"
23 #include "support/Package.h"
27 #include <QTextStream>
29 using namespace lyx::support;
30 using lyx::support::package;
31 using lyx::support::makeDisplayPath;
38 static QDate release_date()
40 return QDate::fromString(QString(lyx_release_date), Qt::ISODate);
44 static QString credits()
47 QFile file(toqstr(package().system_support().absFileName()) + "/CREDITS");
48 QTextStream out(&res);
51 out << qt_("ERROR: LyX wasn't able to find the CREDITS file\n");
52 out << qt_("Please install correctly to estimate the great\n");
53 out << qt_("amount of work other people have done for the LyX project.");
55 file.open(QIODevice::ReadOnly);
56 if (!file.isReadable()) {
57 out << qt_("ERROR: LyX wasn't able to read the CREDITS file\n");
58 out << qt_("Please install correctly to estimate the great\n");
59 out << qt_("amount of work other people have done for the LyX project.");
61 QTextStream ts(&file);
66 if (line.startsWith("@b"))
67 out << "<b>" << line.mid(2) << "</b>";
68 else if (line.startsWith("@i")) {
69 if (line.startsWith("@iE-mail")) {
71 line.replace(QString(" () "), QString("@"));
72 line.replace(QString(" ! "), QString("."));
74 out << "<i>" << line.mid(2) << "</i>";
78 } while (!line.isNull());
86 static QString release_notes()
89 QFile file(toqstr(package().system_support().absFileName()) + "/RELEASE-NOTES");
90 QTextStream out(&res);
93 out << qt_("ERROR: LyX wasn't able to find the RELEASE-NOTES file\n");
94 out << qt_("Please install correctly to see what has changed\n");
95 out << qt_("for this version of LyX.");
97 file.open(QIODevice::ReadOnly);
98 if (!file.isReadable()) {
99 out << qt_("ERROR: LyX wasn't able to read the RELEASE-NOTES file\n");
100 out << qt_("Please install correctly to see what has changed\n");
101 out << qt_("for this version of LyX.");
103 QTextStream ts(&file);
104 ts.setCodec("UTF-8");
106 bool incomment = false;
109 // a simple markdown parser
110 line = ts.readLine();
114 // parse (:comments:)
115 if (line.startsWith("(:")) {
116 if (!line.endsWith(":)"))
119 } if (line.endsWith(":)") && incomment) {
125 // detect links to the tracker
126 line.replace(QRegExp("(bug )(\\#)(\\d+)*"),
127 "<a href=\"http://www.lyx.org/trac/ticket/\\3\">\\1\\3</a>");
130 if (line.startsWith("!!!")) {
136 out << "<h4>" << line.mid(3) << "</h4>";
138 else if (line.startsWith("!!")) {
144 out << "<h3>" << line.mid(2) << "</h3>";
145 } else if (line.startsWith("!")) {
151 out << "<h2>" << line.mid(1) << "</h2>";
153 } else if (line.startsWith("* ")) {
159 out << "<li>" << line.mid(2);
160 } else if (inlist && line.startsWith(" ")) {
171 } while (!line.isNull());
179 static QString copyright()
181 QString release_year = release_date().toString("yyyy");
182 docstring copy_message =
183 bformat(_("LyX is Copyright (C) 1995 by Matthias Ettrich,\n1995--%1$s LyX Team"),
184 qstring_to_ucs4(release_year));
185 return toqstr(copy_message);
189 static QString license()
191 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.");
195 static QString disclaimer()
197 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.");
201 static QString version()
203 QString loc_release_date;
204 QDate date = release_date();
205 if (date.isValid()) {
207 loc_release_date = loc.toString(date, QLocale::LongFormat);
209 if (QString(lyx_release_date) == "not released yet")
210 loc_release_date = qt_("not released yet");
212 loc_release_date = toqstr(lyx_release_date);
214 docstring version_date =
215 bformat(_("LyX Version %1$s\n(%2$s)"),
216 from_ascii(lyx_version),
217 qstring_to_ucs4(loc_release_date))+"\n";
218 if (std::string(lyx_git_commit_hash) != "none")
219 version_date += _("Built from git commit hash ")
220 + from_utf8(lyx_git_commit_hash).substr(0,8);
221 version_date += "\n";
224 QTextStream out(&res);
225 out << toqstr(version_date);
226 out << qt_("Library directory: ");
227 out << toqstr(makeDisplayPath(package().system_support().absFileName()));
229 out << qt_("User directory: ");
230 out << toqstr(makeDisplayPath(package().user_support().absFileName()));
232 out << toqstr(bformat(_("Qt Version (run-time): %1$s"), from_ascii(qVersion()))) << "\n";
233 out << toqstr(bformat(_("Qt Version (compile-time): %1$s"), from_ascii(QT_VERSION_STR))) << "\n";
237 static QString buildinfo()
240 QTextStream out(&res);
241 out << "LyX " << lyx_version
242 << " (" << lyx_release_date << ")" << endl;
243 if (std::string(lyx_git_commit_hash) != "none")
244 out << qt_(" Git commit hash ")
245 << QString(lyx_git_commit_hash).left(8) << endl;
247 out << lyx_version_info << endl;
252 struct GuiAbout::Private
258 GuiAbout::GuiAbout(GuiView & lv)
259 : DialogView(lv, "aboutlyx", qt_("About LyX")),
260 d(new GuiAbout::Private)
264 d->ui.copyrightTB->setPlainText(copyright());
265 d->ui.copyrightTB->append(QString());
266 d->ui.copyrightTB->append(license());
267 d->ui.copyrightTB->append(QString());
268 d->ui.copyrightTB->append(disclaimer());
270 d->ui.versionLA->setText(version());
271 d->ui.buildinfoTB->setText(buildinfo());
272 d->ui.releasenotesTB->setHtml(release_notes());
273 d->ui.releasenotesTB->setOpenExternalLinks(true);
274 d->ui.creditsTB->setHtml(credits());
276 d->ui.tab->setUsesScrollButtons(false);
280 void GuiAbout::on_closePB_clicked()
286 Dialog * createGuiAbout(GuiView & lv) { return new GuiAbout(lv); }
289 } // namespace frontend
292 #include "moc_GuiAbout.cpp"