+++ /dev/null
-/**
- * \file ControlAboutlyx.cpp
- * This file is part of LyX, the document processor.
- * Licence details can be found in the file COPYING.
- *
- * \author Edwin Leuven
- * \author Angus Leeming
- *
- * Full author contact details are available in file CREDITS.
- */
-
-#include <config.h>
-
-#include "ControlAboutlyx.h"
-#include "gettext.h"
-#include "version.h"
-
-#include "support/filetools.h" // FileSearch
-#include "support/Package.h"
-
-#include <fstream>
-#include <sstream>
-
-using std::ostream;
-using std::ostringstream;
-using std::string;
-
-
-namespace lyx {
-
-using support::FileName;
-using support::fileSearch;
-using support::makeDisplayPath;
-using support::package;
-
-namespace frontend {
-
-
-ControlAboutlyx::ControlAboutlyx(Dialog & parent)
- : Dialog::Controller(parent)
-{}
-
-
-void ControlAboutlyx::getCredits(ostream & ss) const
-{
- FileName const name = fileSearch(package().system_support().absFilename(), "CREDITS");
-
- bool found(!name.empty());
-
- if (found) {
- std::ifstream in(name.toFilesystemEncoding().c_str());
-
- ss << in.rdbuf();
- found = ss.good();
- }
-
- if (!found) {
- ss << to_utf8(_("ERROR: LyX wasn't able to read CREDITS file\n"))
- << to_utf8(_("Please install correctly to estimate the great\n"))
- << to_utf8(_("amount of work other people have done for the LyX project."));
- }
-}
-
-
-string const ControlAboutlyx::getCopyright() const
-{
- return to_utf8(_("LyX is Copyright (C) 1995 by Matthias Ettrich,\n1995-2006 LyX Team"));
-}
-
-
-string const ControlAboutlyx::getLicense() const
-{
- return to_utf8(_("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."));
-}
-
-
-string const ControlAboutlyx::getDisclaimer() const
-{
- return to_utf8(_("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."));
-}
-
-
-string const ControlAboutlyx::getVersion() const
-{
- ostringstream ss;
-
- ss << to_utf8(_("LyX Version "))
- << lyx_version
- << " ("
- << lyx_release_date
- << ")\n"
- << to_utf8(_("Library directory: "))
- << to_utf8(makeDisplayPath(package().system_support().absFilename()))
- << "\n"
- << to_utf8(_("User directory: "))
- << to_utf8(makeDisplayPath(package().user_support().absFilename()));
-
- return ss.str();
-}
-
-} // namespace frontend
-} // namespace lyx
+++ /dev/null
-// -*- C++ -*-
-/**
- * \file ControlAboutlyx.h
- * This file is part of LyX, the document processor.
- * Licence details can be found in the file COPYING.
- *
- * \author Edwin Leuven
- * \author Angus Leeming
- *
- * Full author contact details are available in file CREDITS.
- */
-
-#ifndef CONTROLABOUTLYX_H
-#define CONTROLABOUTLYX_H
-
-#include "Dialog.h"
-#include <iosfwd>
-
-namespace lyx {
-namespace frontend {
-
-/** \c ControlAboutlyx is a controller for the "About LyX" dialogs.
- */
-class ControlAboutlyx : public Dialog::Controller {
-public:
- ControlAboutlyx(Dialog & parent);
-
- //@{
- /// Instantiate Dialog::Controller methods.
- virtual bool initialiseParams(std::string const &) { return true; }
- virtual void clearParams() {}
- virtual void dispatchParams() {}
- virtual bool isBufferDependent() const { return false; }
- //@}
-
- //@{
- /// Provide the View with specific pieces of information.
- void getCredits(std::ostream &) const;
- std::string const getCopyright() const;
- std::string const getLicense() const;
- std::string const getDisclaimer() const;
- std::string const getVersion() const;
- //@}
-};
-
-} // namespace frontend
-} // namespace lyx
-
-#endif // CONTROLABOUTLYX_H
#include <config.h>
#include "GuiAbout.h"
+
#include "qt_helpers.h"
#include "gettext.h"
+#include "version.h"
-#include "support/lstrings.h"
-
-#include <sstream>
-
-#include <QLabel>
-#include <QPushButton>
-#include <QTextCodec>
-#include <QTextBrowser>
-
-using lyx::support::prefixIs;
+#include "support/filetools.h"
+#include "support/Package.h"
-using std::getline;
+#include <QtCore>
+#include <QtGui>
-using std::istringstream;
-using std::ostringstream;
-using std::string;
+using lyx::support::package;
+using lyx::support::makeDisplayPath;
namespace lyx {
namespace frontend {
-GuiAboutDialog::GuiAboutDialog(LyXView & lv)
- : GuiDialog(lv, "aboutlyx")
+static QString credits()
{
- setupUi(this);
- setViewTitle(_("About LyX"));
+ QString res;
+ QFile file(toqstr(package().system_support().absFilename()) + "CREDITS");
+ QTextStream out(&res);
+
+ if (file.isReadable()) {
+ out << toqstr(_("ERROR: LyX wasn't able to read CREDITS file\n"));
+ out << toqstr(_("Please install correctly to estimate the great\n"));
+ out << toqstr(_("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;
+}
- setController(new ControlAboutlyx(*this));
- connect(closePB, SIGNAL(clicked()), this, SLOT(reject()));
+static QString copyright()
+{
+ return toqstr(_("LyX is Copyright (C) 1995 by Matthias Ettrich,\n1995-2006 LyX Team"));
+}
- 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()));
+static QString license()
+{
+ return toqstr(_("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."));
+}
- 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)
+static QString disclaimer()
+{
+ return toqstr(_("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."));
+}
- ostringstream in;
- controller().getCredits(in);
- istringstream ss(in.str());
+static QString version()
+{
+ QString res;
+ QTextStream out(&res);
+ out << toqstr(_("LyX Version "));
+ out << lyx_version;
+ out << " (";
+ out << lyx_release_date;
+ out << ")\n";
+ out << toqstr(_("Library directory: "));
+ out << toqstr(makeDisplayPath(package().system_support().absFilename()));
+ out << "\n";
+ out << toqstr(_("User directory: "));
+ out << toqstr(makeDisplayPath(package().user_support().absFilename()));
+ return res;
+}
- 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
+class ControlAbout : public Dialog::Controller
+{
+public:
+ ControlAbout(Dialog & parent) : Dialog::Controller(parent) {}
+ bool initialiseParams(std::string const &) { return true; }
+ void clearParams() {}
+ void dispatchParams() {}
+ bool isBufferDependent() const { return false; }
+};
- creditsTB->setHtml(toqstr(out.str()));
- // try to resize to a good size
- copyrightTB->hide();
- setMinimumSize(copyrightTB->sizeHint());
- copyrightTB->show();
- setMinimumSize(sizeHint());
+GuiAboutDialog::GuiAboutDialog(LyXView & lv)
+ : GuiDialog(lv, "aboutlyx")
+{
+ setupUi(this);
+ setViewTitle(_("About LyX"));
+ setController(new ControlAbout(*this));
- // Manage the cancel/close button
- bc().setPolicy(ButtonPolicy::OkCancelPolicy);
- bc().setCancel(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());
-ControlAboutlyx & GuiAboutDialog::controller() const
-{
- return static_cast<ControlAboutlyx &>(Dialog::controller());
+ versionLA->setText(version());
+ creditsTB->setHtml(credits());
}
} // namespace frontend