3 * This file is part of LyX, the document processor.
4 * Licence details can be found in the file COPYING.
6 * \author Kalle Dalheimer
8 * Full author contact details are available in file CREDITS.
14 #include "QAboutDialog.h"
16 #include "qt_helpers.h"
18 #include "controllers/ButtonController.h"
19 #include "controllers/ControlAboutlyx.h"
21 #include "support/lstrings.h"
26 #include <qpushbutton.h>
27 #include <qtextview.h>
29 using lyx::support::prefixIs;
33 using std::istringstream;
34 using std::ostringstream;
40 typedef QController<ControlAboutlyx, QView<QAboutDialog> > base_class;
42 QAbout::QAbout(Dialog & parent)
43 : base_class(parent, _("About LyX"))
48 void QAbout::build_dialog()
50 dialog_.reset(new QAboutDialog);
51 connect(dialog_.get()->closePB, SIGNAL(clicked()),
52 this, SLOT(slotClose()));
54 dialog_->copyright->setText(toqstr(controller().getCopyright()));
55 dialog_->copyright->append("\n");
56 dialog_->copyright->append(toqstr(controller().getLicense()));
57 dialog_->copyright->append("\n");
58 dialog_->copyright->append(toqstr(controller().getDisclaimer()));
60 dialog_->versionLA->setText(toqstr(controller().getVersion()));
62 // The code below should depend on a autoconf test. (Lgb)
64 // There are a lot of buggy stringstream implementations..., but the
65 // code below will work on all of them (I hope). The drawback with
66 // this solutions os the extra copying. (Lgb)
69 controller().getCredits(in);
71 istringstream ss(in.str());
76 while (getline(ss, s)) {
77 if (prefixIs(s, "@b"))
78 out << "<b>" << s.substr(2) << "</b>";
79 else if (prefixIs(s, "@i"))
80 out << "<i>" << s.substr(2) << "</i>";
86 // Good stringstream implementations can handle this. It avoids
87 // some copying, and should thus be faster and use less memory. (Lgb)
88 // I'll make this the default for a short while to see if anyone
91 controller().getCredits(in);
96 while (getline(in, s)) {
97 if (prefixIs(s, "@b"))
98 out << "<b>" << s.substr(2) << "</b>";
99 else if (prefixIs(s, "@i"))
100 out << "<i>" << s.substr(2) << "</i>";
107 dialog_->creditsTV->setText(toqstr(out.str()));
109 // try to resize to a good size
110 dialog_->copyright->hide();
111 dialog_->setMinimumSize(dialog_->copyright->sizeHint());
112 dialog_->copyright->show();
113 dialog_->setMinimumSize(dialog_->sizeHint());
115 // Manage the cancel/close button
116 bcview().setCancel(dialog_->closePB);
120 } // namespace frontend