]> git.lyx.org Git - lyx.git/blob - src/frontends/qt4/GuiAbout.cpp
renaming of some methods that hurt the eyes + removal of:
[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 #include "qt_helpers.h"
15 #include "gettext.h"
16
17 #include "support/lstrings.h"
18
19 #include <sstream>
20
21 #include <QLabel>
22 #include <QPushButton>
23 #include <QTextCodec>
24 #include <QTextBrowser>
25
26 using lyx::support::prefixIs;
27
28 using std::getline;
29
30 using std::istringstream;
31 using std::ostringstream;
32 using std::string;
33
34 namespace lyx {
35 namespace frontend {
36
37
38 GuiAbout::GuiAbout(GuiDialog & parent)
39         : GuiView<GuiAboutDialog>(parent, _("About LyX"))
40 {
41 }
42
43
44 void GuiAbout::build_dialog()
45 {
46         dialog_.reset(new GuiAboutDialog);
47         connect(dialog_.get()->closePB, SIGNAL(clicked()),
48                 this, SLOT(slotClose()));
49
50         dialog_->copyrightTB->setPlainText(toqstr(controller().getCopyright()));
51         dialog_->copyrightTB->append("");
52         dialog_->copyrightTB->append(toqstr(controller().getLicense()));
53         dialog_->copyrightTB->append("");
54         dialog_->copyrightTB->append(toqstr(controller().getDisclaimer()));
55
56         dialog_->versionLA->setText(toqstr(controller().getVersion()));
57
58         // The code below should depend on a autoconf test. (Lgb)
59 #if 1
60         // There are a lot of buggy stringstream implementations..., but the
61         // code below will work on all of them (I hope). The drawback with
62         // this solutions os the extra copying. (Lgb)
63
64         ostringstream in;
65         controller().getCredits(in);
66
67         istringstream ss(in.str());
68
69         string s;
70         ostringstream out;
71
72         while (getline(ss, s)) {
73                 if (prefixIs(s, "@b"))
74                         out << "<b>" << s.substr(2) << "</b>";
75                 else if (prefixIs(s, "@i"))
76                         out << "<i>" << s.substr(2) << "</i>";
77                 else
78                         out << s;
79                 out << "<br>";
80         }
81 #else
82         // Good stringstream implementations can handle this. It avoids
83         // some copying, and should thus be faster and use less memory. (Lgb)
84         // I'll make this the default for a short while to see if anyone
85         // see the error...
86         stringstream in;
87         controller().getCredits(in);
88         in.seekg(0);
89         string s;
90         ostringstream out;
91
92         while (getline(in, s)) {
93                 if (prefixIs(s, "@b"))
94                         out << "<b>" << s.substr(2) << "</b>";
95                 else if (prefixIs(s, "@i"))
96                         out << "<i>" << s.substr(2) << "</i>";
97                 else
98                         out << s;
99                 out << "<br>";
100         }
101 #endif
102
103         dialog_->creditsTB->setHtml(toqstr(out.str()));
104
105         // try to resize to a good size
106         dialog_->copyrightTB->hide();
107         dialog_->setMinimumSize(dialog_->copyrightTB->sizeHint());
108         dialog_->copyrightTB->show();
109         dialog_->setMinimumSize(dialog_->sizeHint());
110
111         // Manage the cancel/close button
112         bc().setCancel(dialog_->closePB);
113         //FIXME bc().refresh();
114 }
115
116 } // namespace frontend
117 } // namespace lyx
118
119 #include "GuiAbout_moc.cpp"