]> git.lyx.org Git - lyx.git/blob - src/frontends/qt4/GuiAbout.cpp
Transfer some more dialog related code from core to frontend:
[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 "gettext.h"
17 #include "version.h"
18
19 #include "support/filetools.h"
20 #include "support/Package.h"
21
22 #include <QtCore>
23 #include <QtGui>
24
25 using lyx::support::package;
26 using lyx::support::makeDisplayPath;
27
28
29 namespace lyx {
30 namespace frontend {
31
32 static QString credits()
33 {
34         QString res;
35         QFile file(toqstr(package().system_support().absFilename()) + "CREDITS");
36         QTextStream out(&res);
37
38         if (file.isReadable()) {
39                 out << toqstr(_("ERROR: LyX wasn't able to read CREDITS file\n"));
40                 out << toqstr(_("Please install correctly to estimate the great\n"));
41                 out << toqstr(_("amount of work other people have done for the LyX project."));
42         } else {
43                 file.open(QIODevice::ReadOnly);
44                 QTextStream ts(&file);
45                 QString line;
46                 do {
47                         line = ts.readLine();
48                         if (line.startsWith("@b"))
49                                 out << "<b>" << line.mid(2) << "</b>";
50                         else if (line.startsWith("@i"))
51                                 out << "<i>" << line.mid(2) << "</i>";
52                         else
53                                 out << line;
54                         out << "<br>";
55                 } while (!line.isNull());
56         }
57         out.flush();
58         return res;
59 }
60
61
62 static QString copyright()
63 {
64         return toqstr(_("LyX is Copyright (C) 1995 by Matthias Ettrich,\n1995-2006 LyX Team"));
65 }
66
67
68 static QString license()
69 {
70         return toqstr(_("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."));
71 }
72
73
74 static QString disclaimer()
75 {
76         return toqstr(_("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."));
77 }
78
79
80 static QString version()
81 {
82         QString res;
83         QTextStream out(&res);
84         out << toqstr(_("LyX Version "));
85         out << lyx_version;
86         out << " (";
87         out << lyx_release_date;
88         out << ")\n";
89         out << toqstr(_("Library directory: "));
90         out << toqstr(makeDisplayPath(package().system_support().absFilename()));
91         out << "\n";
92         out << toqstr(_("User directory: "));
93         out << toqstr(makeDisplayPath(package().user_support().absFilename()));
94         return res;
95 }
96
97
98 GuiAbout::GuiAbout(GuiView & lv)
99         : GuiDialog(lv, "aboutlyx")
100 {
101         setupUi(this);
102         setViewTitle(_("About LyX"));
103
104         connect(closePB, SIGNAL(clicked()), this, SLOT(reject()));
105
106         copyrightTB->setPlainText(copyright());
107         copyrightTB->append(QString());
108         copyrightTB->append(license());
109         copyrightTB->append(QString());
110         copyrightTB->append(disclaimer());
111
112         versionLA->setText(version());
113         creditsTB->setHtml(credits());
114 }
115
116
117 Dialog * createGuiAbout(GuiView & lv) { return new GuiAbout(lv); }
118
119
120 } // namespace frontend
121 } // namespace lyx
122
123 #include "GuiAbout_moc.cpp"