X-Git-Url: https://git.lyx.org/gitweb/?a=blobdiff_plain;f=src%2Ffrontends%2Fqt4%2FGuiAbout.cpp;h=dfe6d5c27e1659d295e448cd81fbbdd80b382a7b;hb=425d092204118ea6c24c28e85fdf03fcf2bb51a4;hp=0ed3de0a9684b543f7722d601e6c1539d262315f;hpb=a1cec91afaca91968b46e695533c10ad2a3f73d3;p=lyx.git diff --git a/src/frontends/qt4/GuiAbout.cpp b/src/frontends/qt4/GuiAbout.cpp index 0ed3de0a96..dfe6d5c27e 100644 --- a/src/frontends/qt4/GuiAbout.cpp +++ b/src/frontends/qt4/GuiAbout.cpp @@ -11,114 +11,156 @@ #include #include "GuiAbout.h" -#include "Qt2BC.h" -#include "qt_helpers.h" - -#include "controllers/ButtonController.h" -#include "controllers/ControlAboutlyx.h" -#include "support/lstrings.h" +#include "ui_AboutUi.h" -#include +#include "qt_helpers.h" +#include "version.h" -#include -#include -#include -#include +#include "support/filetools.h" +#include "support/gettext.h" +#include "support/lstrings.h" +#include "support/Package.h" -using lyx::support::prefixIs; +#include +#include +#include -using std::getline; +using namespace lyx::support; +using lyx::support::package; +using lyx::support::makeDisplayPath; -using std::istringstream; -using std::ostringstream; -using std::string; namespace lyx { namespace frontend { -typedef QController > AboutBase; - -GuiAbout::GuiAbout(Dialog & parent) - : AboutBase(parent, _("About LyX")) +static QDate release_date() { + return QDate::fromString(QString(lyx_release_date), Qt::ISODate); } -void GuiAbout::build_dialog() +static QString credits() { - dialog_.reset(new GuiAboutDialog); - connect(dialog_.get()->closePB, SIGNAL(clicked()), - this, SLOT(slotClose())); + 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); + ts.setCodec("UTF-8"); + QString line; + do { + line = ts.readLine(); + if (line.startsWith("@b")) + out << "" << line.mid(2) << ""; + else if (line.startsWith("@i")) { + if (line.startsWith("@iE-mail")) { + // unmask email + line.replace(QString(" () "), QString("@")); + line.replace(QString(" ! "), QString(".")); + } + out << "" << line.mid(2) << ""; + } else + out << line; + out << "
"; + } while (!line.isNull()); + } + out.flush(); + return res; +} - 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())); +static QString copyright() +{ + QString release_year = release_date().toString("yyyy"); + docstring copy_message = + bformat(_("LyX is Copyright (C) 1995 by Matthias Ettrich,\n1995--%1$s LyX Team"), + qstring_to_ucs4(release_year)); + return toqstr(copy_message); +} - // 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); +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."); +} - istringstream ss(in.str()); - string s; - ostringstream out; +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."); +} - while (getline(ss, s)) { - if (prefixIs(s, "@b")) - out << "" << s.substr(2) << ""; - else if (prefixIs(s, "@i")) - out << "" << s.substr(2) << ""; - else - out << s; - out << "
"; - } -#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 << "" << s.substr(2) << ""; - else if (prefixIs(s, "@i")) - out << "" << s.substr(2) << ""; + +static QString version() +{ + QString loc_release_date; + QDate date = release_date(); + if (date.isValid()) { + QLocale loc; + loc_release_date = loc.toString(date, QLocale::LongFormat); + } else { + if (QString(lyx_release_date) == "not released yet") + loc_release_date = qt_("not released yet"); else - out << s; - out << "
"; + loc_release_date = toqstr(lyx_release_date); } -#endif + docstring version_date = + bformat(_("LyX Version %1$s\n(%2$s)"), + from_ascii(lyx_version), + qstring_to_ucs4(loc_release_date))+"\n\n"; + QString res; + QTextStream out(&res); + out << toqstr(version_date); + 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())); +struct GuiAbout::Private +{ + Ui::AboutUi ui; +}; + + +GuiAbout::GuiAbout(GuiView & lv) + : DialogView(lv, "aboutlyx", qt_("About LyX")), + d(new GuiAbout::Private) +{ + d->ui.setupUi(this); - // try to resize to a good size - dialog_->copyrightTB->hide(); - dialog_->setMinimumSize(dialog_->copyrightTB->sizeHint()); - dialog_->copyrightTB->show(); - dialog_->setMinimumSize(dialog_->sizeHint()); + d->ui.copyrightTB->setPlainText(copyright()); + d->ui.copyrightTB->append(QString()); + d->ui.copyrightTB->append(license()); + d->ui.copyrightTB->append(QString()); + d->ui.copyrightTB->append(disclaimer()); - // Manage the cancel/close button - bcview().setCancel(dialog_->closePB); - bc().refresh(); + d->ui.versionLA->setText(version()); + d->ui.creditsTB->setHtml(credits()); } + +void GuiAbout::on_closePB_clicked() +{ + close(); +} + + +Dialog * createGuiAbout(GuiView & lv) { return new GuiAbout(lv); } + + } // namespace frontend } // namespace lyx -#include "GuiAbout_moc.cpp" +#include "moc_GuiAbout.cpp"