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