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;
39 typedef QController<ControlAboutlyx, QView<QAboutDialog> > base_class;
41 QAbout::QAbout(Dialog & parent)
42 : base_class(parent, _("About LyX"))
47 void QAbout::build_dialog()
49 dialog_.reset(new QAboutDialog);
50 connect(dialog_.get()->closePB, SIGNAL(clicked()),
51 this, SLOT(slotClose()));
53 dialog_->copyright->setText(toqstr(controller().getCopyright()));
54 dialog_->copyright->append("\n");
55 dialog_->copyright->append(toqstr(controller().getLicense()));
56 dialog_->copyright->append("\n");
57 dialog_->copyright->append(toqstr(controller().getDisclaimer()));
59 dialog_->versionLA->setText(toqstr(controller().getVersion()));
61 // The code below should depend on a autoconf test. (Lgb)
63 // There are a lot of buggy stringstream implementations..., but the
64 // code below will work on all of them (I hope). The drawback with
65 // this solutions os the extra copying. (Lgb)
68 controller().getCredits(in);
70 istringstream ss(in.str());
75 while (getline(ss, s)) {
76 if (prefixIs(s, "@b"))
77 out << "<b>" << s.substr(2) << "</b>";
78 else if (prefixIs(s, "@i"))
79 out << "<i>" << s.substr(2) << "</i>";
85 // Good stringstream implementations can handle this. It avoids
86 // some copying, and should thus be faster and use less memory. (Lgb)
87 // I'll make this the default for a short while to see if anyone
90 controller().getCredits(in);
95 while (getline(in, s)) {
96 if (prefixIs(s, "@b"))
97 out << "<b>" << s.substr(2) << "</b>";
98 else if (prefixIs(s, "@i"))
99 out << "<i>" << s.substr(2) << "</i>";
106 dialog_->creditsTV->setText(toqstr(out.str()));
108 // try to resize to a good size
109 dialog_->copyright->hide();
110 dialog_->setMinimumSize(dialog_->copyright->sizeHint());
111 dialog_->copyright->show();
112 dialog_->setMinimumSize(dialog_->sizeHint());
114 // Manage the cancel/close button
115 bcview().setCancel(dialog_->closePB);
119 } // namespace frontend