]> git.lyx.org Git - lyx.git/blob - src/frontends/qt2/QAbout.C
better selection and scrolling behaviour
[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 #ifdef __GNUG__
14 #pragma implementation
15 #endif
16
17 #include "support/lstrings.h"
18 #include "Lsstream.h"
19 #include "debug.h"
20 #include "gettext.h"
21 #include "LyXView.h"
22 #include "ButtonControllerBase.h"
23 #include "ControlAboutlyx.h"
24
25 #include <qlabel.h>
26 #include <qpushbutton.h>
27 #include <qtextview.h>
28
29 #include "QAboutDialog.h"
30 #include "Qt2BC.h"
31 #include "QAbout.h"
32
33 using std::getline;
34
35 typedef Qt2CB<ControlAboutlyx, Qt2DB<QAboutDialog> > base_class;
36
37
38 QAbout::QAbout()
39         : base_class(_("About LyX"))
40 {
41 }
42
43
44 void QAbout::build_dialog()
45 {
46         dialog_.reset(new QAboutDialog);
47         connect(dialog_.get()->closePB, SIGNAL(clicked()),
48                 this, SLOT(slotClose()));
49
50         dialog_->copyright->setText(controller().getCopyright().c_str());
51         dialog_->copyright->append("\n");
52         dialog_->copyright->append(controller().getLicense().c_str());
53         dialog_->copyright->append("\n");
54         dialog_->copyright->append(controller().getDisclaimer().c_str());
55
56         dialog_->versionLA->setText(controller().getVersion().c_str());
57
58         // The code below should depend on a autoconf test. (Lgb)
59 #if 0
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_->creditsTV->setText(out.str().c_str());
104
105         // try to resize to a good size
106         dialog_->copyright->hide();
107         dialog_->setMinimumSize(dialog_->copyright->sizeHint());
108         dialog_->copyright->show();
109         dialog_->setMinimumSize(dialog_->sizeHint());
110
111         // Manage the cancel/close button
112         bc().setCancel(dialog_->closePB);
113         bc().refresh();
114 }