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