lyx_mirror/src/frontends/qt4/GuiAbout.cpp
André Pönitz c9ea6e6eef the fun begins....
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@20077 a592a061-630c-0410-9148-cb99ea01b6c8
2007-09-05 20:33:29 +00:00

128 lines
2.8 KiB
C++

/**
* \file GuiAbout.cpp
* This file is part of LyX, the document processor.
* Licence details can be found in the file COPYING.
*
* \author Kalle Dalheimer
*
* Full author contact details are available in file CREDITS.
*/
#include <config.h>
#include "GuiAbout.h"
#include "qt_helpers.h"
#include "gettext.h"
#include "support/lstrings.h"
#include <sstream>
#include <QLabel>
#include <QPushButton>
#include <QTextCodec>
#include <QTextBrowser>
using lyx::support::prefixIs;
using std::getline;
using std::istringstream;
using std::ostringstream;
using std::string;
namespace lyx {
namespace frontend {
GuiAboutDialog::GuiAboutDialog(LyXView & lv)
: GuiDialog(lv, "aboutlyx")
{
setupUi(this);
setViewTitle(_("About LyX"));
setController(new ControlAboutlyx(*this));
connect(closePB, SIGNAL(clicked()), this, SLOT(reject()));
connect(closePB, SIGNAL(clicked()),
this, SLOT(slotClose()));
copyrightTB->setPlainText(toqstr(controller().getCopyright()));
copyrightTB->append("");
copyrightTB->append(toqstr(controller().getLicense()));
copyrightTB->append("");
copyrightTB->append(toqstr(controller().getDisclaimer()));
versionLA->setText(toqstr(controller().getVersion()));
// The code below should depend on a autoconf test. (Lgb)
#if 1
// There are a lot of buggy stringstream implementations..., but the
// code below will work on all of them (I hope). The drawback with
// this solutions os the extra copying. (Lgb)
ostringstream in;
controller().getCredits(in);
istringstream ss(in.str());
string s;
ostringstream out;
while (getline(ss, s)) {
if (prefixIs(s, "@b"))
out << "<b>" << s.substr(2) << "</b>";
else if (prefixIs(s, "@i"))
out << "<i>" << s.substr(2) << "</i>";
else
out << s;
out << "<br>";
}
#else
// Good stringstream implementations can handle this. It avoids
// some copying, and should thus be faster and use less memory. (Lgb)
// I'll make this the default for a short while to see if anyone
// see the error...
stringstream in;
controller().getCredits(in);
in.seekg(0);
string s;
ostringstream out;
while (getline(in, s)) {
if (prefixIs(s, "@b"))
out << "<b>" << s.substr(2) << "</b>";
else if (prefixIs(s, "@i"))
out << "<i>" << s.substr(2) << "</i>";
else
out << s;
out << "<br>";
}
#endif
creditsTB->setHtml(toqstr(out.str()));
// try to resize to a good size
copyrightTB->hide();
setMinimumSize(copyrightTB->sizeHint());
copyrightTB->show();
setMinimumSize(sizeHint());
// Manage the cancel/close button
bc().setPolicy(ButtonPolicy::OkCancelPolicy);
bc().setCancel(closePB);
bc().refresh();
}
ControlAboutlyx & GuiAboutDialog::controller() const
{
return static_cast<ControlAboutlyx &>(Dialog::controller());
}
} // namespace frontend
} // namespace lyx
#include "GuiAbout_moc.cpp"