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>
28 #include <QTextBrowser>
30 using lyx::support::prefixIs;
34 using std::istringstream;
35 using std::ostringstream;
41 typedef QController<ControlAboutlyx, QView<QAboutDialog> > base_class;
43 QAbout::QAbout(Dialog & parent)
44 : base_class(parent, _("About LyX"))
49 void QAbout::build_dialog()
51 dialog_.reset(new QAboutDialog);
52 connect(dialog_.get()->closePB, SIGNAL(clicked()),
53 this, SLOT(slotClose()));
55 dialog_->copyrightTB->setPlainText(toqstr(controller().getCopyright()));
56 dialog_->copyrightTB->append("\n");
57 dialog_->copyrightTB->append(toqstr(controller().getLicense()));
58 dialog_->copyrightTB->append("\n");
59 dialog_->copyrightTB->append(toqstr(controller().getDisclaimer()));
61 dialog_->versionLA->setText(toqstr(controller().getVersion()));
63 // The code below should depend on a autoconf test. (Lgb)
65 // There are a lot of buggy stringstream implementations..., but the
66 // code below will work on all of them (I hope). The drawback with
67 // this solutions os the extra copying. (Lgb)
70 controller().getCredits(in);
72 istringstream ss(in.str());
77 while (getline(ss, s)) {
78 if (prefixIs(s, "@b"))
79 out << "<b>" << s.substr(2) << "</b>";
80 else if (prefixIs(s, "@i"))
81 out << "<i>" << s.substr(2) << "</i>";
87 // Good stringstream implementations can handle this. It avoids
88 // some copying, and should thus be faster and use less memory. (Lgb)
89 // I'll make this the default for a short while to see if anyone
92 controller().getCredits(in);
97 while (getline(in, s)) {
98 if (prefixIs(s, "@b"))
99 out << "<b>" << s.substr(2) << "</b>";
100 else if (prefixIs(s, "@i"))
101 out << "<i>" << s.substr(2) << "</i>";
108 // Try and grab the latin1 codec
109 QTextCodec * const codec =
110 QTextCodec::codecForName("ISO8859-1");
112 lyxerr << "Unable to find ISO8859-1 codec" << std::endl;
114 QString const qtext = codec ?
115 codec->toUnicode(out.str().c_str()) :
117 dialog_->creditsTB->setPlainText(qtext);
119 // try to resize to a good size
120 dialog_->copyrightTB->hide();
121 dialog_->setMinimumSize(dialog_->copyrightTB->sizeHint());
122 dialog_->copyrightTB->show();
123 dialog_->setMinimumSize(dialog_->sizeHint());
125 // Manage the cancel/close button
126 bcview().setCancel(dialog_->closePB);
130 } // namespace frontend