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