#include <config.h>
#include "GuiAbout.h"
-#include "Qt2BC.h"
+
#include "qt_helpers.h"
+#include "version.h"
-#include "controllers/ButtonController.h"
-#include "controllers/ControlAboutlyx.h"
+#include "support/filetools.h"
+#include "support/Package.h"
-#include "support/lstrings.h"
+#include <QtCore>
+#include <QtGui>
-#include <sstream>
+using lyx::support::package;
+using lyx::support::makeDisplayPath;
-#include <QLabel>
-#include <QPushButton>
-#include <QTextCodec>
-#include <QTextBrowser>
-using lyx::support::prefixIs;
+namespace lyx {
+namespace frontend {
-using std::getline;
+static QString credits()
+{
+ QString res;
+ QFile file(toqstr(package().system_support().absFilename()) + "CREDITS");
+ QTextStream out(&res);
+
+ if (file.isReadable()) {
+ out << qt_("ERROR: LyX wasn't able to read CREDITS file\n");
+ out << qt_("Please install correctly to estimate the great\n");
+ out << qt_("amount of work other people have done for the LyX project.");
+ } else {
+ file.open(QIODevice::ReadOnly);
+ QTextStream ts(&file);
+ QString line;
+ do {
+ line = ts.readLine();
+ if (line.startsWith("@b"))
+ out << "<b>" << line.mid(2) << "</b>";
+ else if (line.startsWith("@i"))
+ out << "<i>" << line.mid(2) << "</i>";
+ else
+ out << line;
+ out << "<br>";
+ } while (!line.isNull());
+ }
+ out.flush();
+ return res;
+}
-using std::istringstream;
-using std::ostringstream;
-using std::string;
-namespace lyx {
-namespace frontend {
+static QString copyright()
+{
+ return qt_("LyX is Copyright (C) 1995 by Matthias Ettrich,\n1995-2006 LyX Team");
+}
+
+static QString license()
+{
+ return qt_("This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.");
+}
-typedef QController<ControlAboutlyx, GuiView<GuiAboutDialog> > AboutBase;
-GuiAbout::GuiAbout(Dialog & parent)
- : AboutBase(parent, _("About LyX"))
+static QString disclaimer()
{
+ return qt_("LyX is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.\nSee the GNU General Public License for more details.\nYou should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.");
}
-void GuiAbout::build_dialog()
+static QString version()
{
- dialog_.reset(new GuiAboutDialog);
- connect(dialog_.get()->closePB, SIGNAL(clicked()),
- this, SLOT(slotClose()));
-
- dialog_->copyrightTB->setPlainText(toqstr(controller().getCopyright()));
- dialog_->copyrightTB->append("");
- dialog_->copyrightTB->append(toqstr(controller().getLicense()));
- dialog_->copyrightTB->append("");
- dialog_->copyrightTB->append(toqstr(controller().getDisclaimer()));
-
- dialog_->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
+ QString res;
+ QTextStream out(&res);
+ out << qt_("LyX Version ");
+ out << lyx_version;
+ out << " (";
+ out << lyx_release_date;
+ out << ")\n";
+ out << qt_("Library directory: ");
+ out << toqstr(makeDisplayPath(package().system_support().absFilename()));
+ out << "\n";
+ out << qt_("User directory: ");
+ out << toqstr(makeDisplayPath(package().user_support().absFilename()));
+ return res;
+}
- dialog_->creditsTB->setHtml(toqstr(out.str()));
- // try to resize to a good size
- dialog_->copyrightTB->hide();
- dialog_->setMinimumSize(dialog_->copyrightTB->sizeHint());
- dialog_->copyrightTB->show();
- dialog_->setMinimumSize(dialog_->sizeHint());
+GuiAbout::GuiAbout(GuiView & lv)
+ : GuiDialog(lv, "aboutlyx", qt_("About LyX"))
+{
+ setupUi(this);
- // Manage the cancel/close button
- bcview().setCancel(dialog_->closePB);
- bc().refresh();
+ connect(closePB, SIGNAL(clicked()), this, SLOT(reject()));
+
+ copyrightTB->setPlainText(copyright());
+ copyrightTB->append(QString());
+ copyrightTB->append(license());
+ copyrightTB->append(QString());
+ copyrightTB->append(disclaimer());
+
+ versionLA->setText(version());
+ creditsTB->setHtml(credits());
}
+
+Dialog * createGuiAbout(GuiView & lv) { return new GuiAbout(lv); }
+
+
} // namespace frontend
} // namespace lyx