]> git.lyx.org Git - lyx.git/blob - src/frontends/qt4/GuiAbout.cpp
qt5: Only include a single header to fix compilation
[lyx.git] / src / frontends / qt4 / GuiAbout.cpp
1 /**
2  * \file GuiAbout.cpp
3  * This file is part of LyX, the document processor.
4  * Licence details can be found in the file COPYING.
5  *
6  * \author Kalle Dalheimer
7  *
8  * Full author contact details are available in file CREDITS.
9  */
10
11 #include <config.h>
12
13 #include "GuiAbout.h"
14
15 #include "ui_AboutUi.h"
16
17 #include "qt_helpers.h"
18 #include "version.h"
19
20 #include "support/filetools.h"
21 #include "support/gettext.h"
22 #include "support/lstrings.h"
23 #include "support/Package.h"
24
25 #include <QDate>
26 #include <QTextStream>
27
28 using namespace lyx::support;
29 using lyx::support::package;
30 using lyx::support::makeDisplayPath;
31
32
33 namespace lyx {
34 namespace frontend {
35
36
37 static QDate release_date()
38 {
39         return QDate::fromString(QString(lyx_release_date), Qt::ISODate);
40 }
41
42
43 static QString credits()
44 {
45         QString res;
46         QFile file(toqstr(package().system_support().absFileName()) + "/CREDITS");
47         QTextStream out(&res);
48
49         if (file.isReadable()) {
50                 out << qt_("ERROR: LyX wasn't able to read CREDITS file\n");
51                 out << qt_("Please install correctly to estimate the great\n");
52                 out << qt_("amount of work other people have done for the LyX project.");
53         } else {
54                 file.open(QIODevice::ReadOnly);
55                 QTextStream ts(&file);
56                 ts.setCodec("UTF-8");
57                 QString line;
58                 do {
59                         line = ts.readLine();
60                         if (line.startsWith("@b"))
61                                 out << "<b>" << line.mid(2) << "</b>";
62                         else if (line.startsWith("@i")) {
63                                 if (line.startsWith("@iE-mail")) {
64                                         // unmask email
65                                         line.replace(QString(" () "), QString("@"));
66                                         line.replace(QString(" ! "), QString("."));
67                                 }
68                                 out << "<i>" << line.mid(2) << "</i>";
69                         } else
70                                 out << line;
71                         out << "<br>";
72                 } while (!line.isNull());
73         }
74         out.flush();
75         return res;
76 }
77
78
79 static QString copyright()
80 {
81         QString release_year = release_date().toString("yyyy");
82         docstring copy_message =
83                 bformat(_("LyX is Copyright (C) 1995 by Matthias Ettrich,\n1995--%1$s LyX Team"),
84                         qstring_to_ucs4(release_year));
85         return toqstr(copy_message);
86 }
87
88
89 static QString license()
90 {
91         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.");
92 }
93
94
95 static QString disclaimer()
96 {
97         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.");
98 }
99
100
101 static QString version()
102 {
103         QString loc_release_date;
104         QDate date = release_date();
105         if (date.isValid()) {
106                 QLocale loc;
107                 loc_release_date = loc.toString(date, QLocale::LongFormat);
108         } else {
109                 if (QString(lyx_release_date) == "not released yet")
110                         loc_release_date = qt_("not released yet");
111                 else
112                         loc_release_date = toqstr(lyx_release_date);
113         }
114         docstring version_date =
115                 bformat(_("LyX Version %1$s\n(%2$s)"),
116                         from_ascii(lyx_version),
117                         qstring_to_ucs4(loc_release_date))+"\n\n";
118         QString res;
119         QTextStream out(&res);
120         out << toqstr(version_date);
121         out << qt_("Library directory: ");
122         out << toqstr(makeDisplayPath(package().system_support().absFileName()));
123         out << "\n";
124         out << qt_("User directory: ");
125         out << toqstr(makeDisplayPath(package().user_support().absFileName()));
126 #ifdef DEVEL_VERSION
127         out << "\n";
128         out << toqstr(bformat(_("Qt Version (run-time): %1$s"), from_ascii(qVersion()))) << "\n";
129         out << toqstr(bformat(_("Qt Version (compile-time): %1$s"), from_ascii(QT_VERSION_STR))) << "\n";
130 #endif
131         return res;
132 }
133
134 static QString buildinfo()
135 {
136         QString res;
137         QTextStream out(&res);
138         out << "LyX " << lyx_version
139                 << " (" << lyx_release_date << ")" << endl;
140         out << toqstr(bformat(_("Built on %1$s[[date]], %2$s[[time]]"),
141                 from_ascii(__DATE__), from_ascii(__TIME__))) << endl;
142
143         out << lyx_version_info << endl;
144         return res;
145 }
146
147
148 struct GuiAbout::Private
149 {
150         Ui::AboutUi ui;
151 };
152
153
154 GuiAbout::GuiAbout(GuiView & lv)
155         : DialogView(lv, "aboutlyx", qt_("About LyX")),
156         d(new GuiAbout::Private)
157 {
158         d->ui.setupUi(this);
159
160         d->ui.copyrightTB->setPlainText(copyright());
161         d->ui.copyrightTB->append(QString());
162         d->ui.copyrightTB->append(license());
163         d->ui.copyrightTB->append(QString());
164         d->ui.copyrightTB->append(disclaimer());
165
166         d->ui.versionLA->setText(version());
167         d->ui.buildinfoTB->setText(buildinfo());
168         d->ui.creditsTB->setHtml(credits());
169 }
170
171
172 void GuiAbout::on_closePB_clicked()
173 {
174         close();
175 }
176
177
178 Dialog * createGuiAbout(GuiView & lv) { return new GuiAbout(lv); }
179
180
181 } // namespace frontend
182 } // namespace lyx
183
184 #include "moc_GuiAbout.cpp"