]> git.lyx.org Git - lyx.git/blob - src/frontends/qt4/GuiAbout.cpp
Fix the tab ordering of GuiDocument components.
[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 <QtCore>
27 #include <QtGui>
28
29 using namespace lyx::support;
30 using lyx::support::package;
31 using lyx::support::makeDisplayPath;
32
33
34 namespace lyx {
35 namespace frontend {
36
37
38 static QDate release_date()
39 {
40         return QDate::fromString(QString(lyx_release_date), Qt::ISODate);
41 }
42
43
44 static QString credits()
45 {
46         QString res;
47         QFile file(toqstr(package().system_support().absFileName()) + "/CREDITS");
48         QTextStream out(&res);
49
50         if (file.isReadable()) {
51                 out << qt_("ERROR: LyX wasn't able to read 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.");
54         } else {
55                 file.open(QIODevice::ReadOnly);
56                 QTextStream ts(&file);
57                 ts.setCodec("UTF-8");
58                 QString line;
59                 do {
60                         line = ts.readLine();
61                         if (line.startsWith("@b"))
62                                 out << "<b>" << line.mid(2) << "</b>";
63                         else if (line.startsWith("@i")) {
64                                 if (line.startsWith("@iE-mail")) {
65                                         // unmask email
66                                         line.replace(QString(" () "), QString("@"));
67                                         line.replace(QString(" ! "), QString("."));
68                                 }
69                                 out << "<i>" << line.mid(2) << "</i>";
70                         } else
71                                 out << line;
72                         out << "<br>";
73                 } while (!line.isNull());
74         }
75         out.flush();
76         return res;
77 }
78
79
80 static QString copyright()
81 {
82         QString release_year = release_date().toString("yyyy");
83         docstring copy_message =
84                 bformat(_("LyX is Copyright (C) 1995 by Matthias Ettrich,\n1995--%1$s LyX Team"),
85                         qstring_to_ucs4(release_year));
86         return toqstr(copy_message);
87 }
88
89
90 static QString license()
91 {
92         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.");
93 }
94
95
96 static QString disclaimer()
97 {
98         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.");
99 }
100
101
102 static QString version()
103 {
104         QString loc_release_date;
105         QDate date = release_date();
106         if (date.isValid()) {
107                 QLocale loc;
108                 loc_release_date = loc.toString(date, QLocale::LongFormat);
109         } else {
110                 if (QString(lyx_release_date) == "not released yet")
111                         loc_release_date = qt_("not released yet");
112                 else
113                         loc_release_date = toqstr(lyx_release_date);
114         }
115         docstring version_date =
116                 bformat(_("LyX Version %1$s\n(%2$s)"),
117                         from_ascii(lyx_version),
118                         qstring_to_ucs4(loc_release_date))+"\n\n";
119         QString res;
120         QTextStream out(&res);
121         out << toqstr(version_date);
122         out << qt_("Library directory: ");
123         out << toqstr(makeDisplayPath(package().system_support().absFileName()));
124         out << "\n";
125         out << qt_("User directory: ");
126         out << toqstr(makeDisplayPath(package().user_support().absFileName()));
127 #ifdef DEVEL_VERSION
128         out << "\n";
129         out << "Qt Version (run-time): " << toqstr(qVersion()) << "\n";
130         out << "Qt Version (compile-time): " << QT_VERSION_STR << "\n";
131 #endif
132         return res;
133 }
134
135
136 struct GuiAbout::Private
137 {
138         Ui::AboutUi ui;
139 };
140
141
142 GuiAbout::GuiAbout(GuiView & lv)
143         : DialogView(lv, "aboutlyx", qt_("About LyX")),
144         d(new GuiAbout::Private)
145 {
146         d->ui.setupUi(this);
147
148         d->ui.copyrightTB->setPlainText(copyright());
149         d->ui.copyrightTB->append(QString());
150         d->ui.copyrightTB->append(license());
151         d->ui.copyrightTB->append(QString());
152         d->ui.copyrightTB->append(disclaimer());
153
154         d->ui.versionLA->setText(version());
155         d->ui.creditsTB->setHtml(credits());
156 }
157
158
159 void GuiAbout::on_closePB_clicked()
160 {
161         close();
162 }
163
164
165 Dialog * createGuiAbout(GuiView & lv) { return new GuiAbout(lv); }
166
167
168 } // namespace frontend
169 } // namespace lyx
170
171 #include "moc_GuiAbout.cpp"