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 "support/lstrings.h"
15 #include "support/std_sstream.h"
16 #include "qt_helpers.h"
17 #include "ButtonController.h"
18 #include "ControlAboutlyx.h"
21 #include <qpushbutton.h>
22 #include <qtextview.h>
24 #include "QAboutDialog.h"
28 using lyx::support::prefixIs;
32 using std::istringstream;
33 using std::ostringstream;
37 typedef QController<ControlAboutlyx, QView<QAboutDialog> > base_class;
39 QAbout::QAbout(Dialog & parent)
40 : base_class(parent, _("About LyX"))
45 void QAbout::build_dialog()
47 dialog_.reset(new QAboutDialog);
48 connect(dialog_.get()->closePB, SIGNAL(clicked()),
49 this, SLOT(slotClose()));
51 dialog_->copyright->setText(toqstr(controller().getCopyright()));
52 dialog_->copyright->append("\n");
53 dialog_->copyright->append(toqstr(controller().getLicense()));
54 dialog_->copyright->append("\n");
55 dialog_->copyright->append(toqstr(controller().getDisclaimer()));
57 dialog_->versionLA->setText(toqstr(controller().getVersion()));
59 // The code below should depend on a autoconf test. (Lgb)
61 // There are a lot of buggy stringstream implementations..., but the
62 // code below will work on all of them (I hope). The drawback with
63 // this solutions os the extra copying. (Lgb)
66 controller().getCredits(in);
68 istringstream ss(in.str());
73 while (getline(ss, s)) {
74 if (prefixIs(s, "@b"))
75 out << "<b>" << s.substr(2) << "</b>";
76 else if (prefixIs(s, "@i"))
77 out << "<i>" << s.substr(2) << "</i>";
83 // Good stringstream implementations can handle this. It avoids
84 // some copying, and should thus be faster and use less memory. (Lgb)
85 // I'll make this the default for a short while to see if anyone
88 controller().getCredits(in);
93 while (getline(in, s)) {
94 if (prefixIs(s, "@b"))
95 out << "<b>" << s.substr(2) << "</b>";
96 else if (prefixIs(s, "@i"))
97 out << "<i>" << s.substr(2) << "</i>";
104 dialog_->creditsTV->setText(toqstr(out.str()));
106 // try to resize to a good size
107 dialog_->copyright->hide();
108 dialog_->setMinimumSize(dialog_->copyright->sizeHint());
109 dialog_->copyright->show();
110 dialog_->setMinimumSize(dialog_->sizeHint());
112 // Manage the cancel/close button
113 bcview().setCancel(dialog_->closePB);