]> git.lyx.org Git - lyx.git/blob - src/frontends/qt4/GuiAbout.cpp
* GuiAbout.cpp:
[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 "qt_helpers.h"
16 #include "version.h"
17
18 #include "support/filetools.h"
19 #include "support/gettext.h"
20 #include "support/lstrings.h"
21 #include "support/Package.h"
22
23 #include <QDate>
24 #include <QtCore>
25 #include <QtGui>
26
27 using namespace lyx::support;
28 using lyx::support::package;
29 using lyx::support::makeDisplayPath;
30
31
32 namespace lyx {
33 namespace frontend {
34
35
36 static QDate release_date()
37 {
38         return QDate::fromString(QString(lyx_release_date), Qt::ISODate);
39 }
40
41
42 static QString credits()
43 {
44         QString res;
45         QFile file(toqstr(package().system_support().absFilename()) + "/CREDITS");
46         QTextStream out(&res);
47
48         if (file.isReadable()) {
49                 out << qt_("ERROR: LyX wasn't able to read CREDITS file\n");
50                 out << qt_("Please install correctly to estimate the great\n");
51                 out << qt_("amount of work other people have done for the LyX project.");
52         } else {
53                 file.open(QIODevice::ReadOnly);
54                 QTextStream ts(&file);
55                 ts.setCodec("UTF-8");
56                 QString line;
57                 do {
58                         line = ts.readLine();
59                         if (line.startsWith("@b"))
60                                 out << "<b>" << line.mid(2) << "</b>";
61                         else if (line.startsWith("@i")) {
62                                 if (line.startsWith("@iE-mail")) {
63                                         // unmask email
64                                         line.replace(QString(" () "), QString("@"));
65                                         line.replace(QString(" ! "), QString("."));
66                                 }
67                                 out << "<i>" << line.mid(2) << "</i>";
68                         } else
69                                 out << line;
70                         out << "<br>";
71                 } while (!line.isNull());
72         }
73         out.flush();
74         return res;
75 }
76
77
78 static QString copyright()
79 {
80         QString release_year = release_date().toString("yyyy");
81         docstring copy_message =
82                 bformat(_("LyX is Copyright (C) 1995 by Matthias Ettrich,\n1995--%1$s LyX Team"),
83                         qstring_to_ucs4(release_year));
84         return toqstr(copy_message);
85 }
86
87
88 static QString license()
89 {
90         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.");
91 }
92
93
94 static QString disclaimer()
95 {
96         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.");
97 }
98
99
100 static QString version()
101 {
102         QString loc_release_date;
103         QDate date = release_date();
104         if (date.isValid()) {
105                 QLocale loc;
106                 loc_release_date = loc.toString(date, QLocale::LongFormat);
107         } else {
108                 if (QString(lyx_release_date) == "not released yet")
109                         loc_release_date = qt_("not released yet");
110                 else
111                         loc_release_date = toqstr(lyx_release_date);
112         }
113         docstring version_date =
114                 bformat(_("LyX Version %1$s\n(%2$s)"),
115                         from_ascii(lyx_version),
116                         qstring_to_ucs4(loc_release_date))+"\n\n";
117         QString res;
118         QTextStream out(&res);
119         out << toqstr(version_date);
120         out << qt_("Library directory: ");
121         out << toqstr(makeDisplayPath(package().system_support().absFilename()));
122         out << "\n";
123         out << qt_("User directory: ");
124         out << toqstr(makeDisplayPath(package().user_support().absFilename()));
125         return res;
126 }
127
128
129 GuiAbout::GuiAbout(GuiView & lv)
130         : GuiDialog(lv, "aboutlyx", qt_("About LyX"))
131 {
132         setupUi(this);
133
134         connect(closePB, SIGNAL(clicked()), this, SLOT(reject()));
135
136         copyrightTB->setPlainText(copyright());
137         copyrightTB->append(QString());
138         copyrightTB->append(license());
139         copyrightTB->append(QString());
140         copyrightTB->append(disclaimer());
141
142         versionLA->setText(version());
143         creditsTB->setHtml(credits());
144 }
145
146
147 Dialog * createGuiAbout(GuiView & lv) { return new GuiAbout(lv); }
148
149
150 } // namespace frontend
151 } // namespace lyx
152
153 #include "moc_GuiAbout.cpp"