mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-11-10 20:04:46 +00:00
simplify About dialog
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@20088 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
parent
1c7ed8b641
commit
665119e4f6
@ -1,102 +0,0 @@
|
||||
/**
|
||||
* \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
|
@ -1,49 +0,0 @@
|
||||
// -*- 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
|
@ -11,7 +11,6 @@ SOURCEFILES = \
|
||||
Dialog.cpp \
|
||||
Kernel.cpp \
|
||||
ButtonPolicy.cpp \
|
||||
ControlAboutlyx.cpp \
|
||||
ControlBibtex.cpp \
|
||||
ControlBox.cpp \
|
||||
ControlBranch.cpp \
|
||||
@ -53,7 +52,6 @@ SOURCEFILES = \
|
||||
HEADERFILES = \
|
||||
Kernel.h \
|
||||
ButtonPolicy.h \
|
||||
ControlAboutlyx.h \
|
||||
ControlBibtex.h \
|
||||
ControlBox.h \
|
||||
ControlBranch.h \
|
||||
|
@ -11,114 +11,118 @@
|
||||
#include <config.h>
|
||||
|
||||
#include "GuiAbout.h"
|
||||
|
||||
#include "qt_helpers.h"
|
||||
#include "gettext.h"
|
||||
#include "version.h"
|
||||
|
||||
#include "support/lstrings.h"
|
||||
#include "support/filetools.h"
|
||||
#include "support/Package.h"
|
||||
|
||||
#include <sstream>
|
||||
#include <QtCore>
|
||||
#include <QtGui>
|
||||
|
||||
#include <QLabel>
|
||||
#include <QPushButton>
|
||||
#include <QTextCodec>
|
||||
#include <QTextBrowser>
|
||||
|
||||
using lyx::support::prefixIs;
|
||||
|
||||
using std::getline;
|
||||
|
||||
using std::istringstream;
|
||||
using std::ostringstream;
|
||||
using std::string;
|
||||
using lyx::support::package;
|
||||
using lyx::support::makeDisplayPath;
|
||||
|
||||
|
||||
namespace lyx {
|
||||
namespace frontend {
|
||||
|
||||
static QString credits()
|
||||
{
|
||||
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;
|
||||
}
|
||||
|
||||
|
||||
static QString copyright()
|
||||
{
|
||||
return toqstr(_("LyX is Copyright (C) 1995 by Matthias Ettrich,\n1995-2006 LyX Team"));
|
||||
}
|
||||
|
||||
|
||||
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."));
|
||||
}
|
||||
|
||||
|
||||
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."));
|
||||
}
|
||||
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
|
||||
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; }
|
||||
};
|
||||
|
||||
|
||||
GuiAboutDialog::GuiAboutDialog(LyXView & lv)
|
||||
: GuiDialog(lv, "aboutlyx")
|
||||
{
|
||||
setupUi(this);
|
||||
setViewTitle(_("About LyX"));
|
||||
|
||||
setController(new ControlAboutlyx(*this));
|
||||
setController(new ControlAbout(*this));
|
||||
|
||||
connect(closePB, SIGNAL(clicked()), this, SLOT(reject()));
|
||||
|
||||
connect(closePB, SIGNAL(clicked()),
|
||||
this, SLOT(slotClose()));
|
||||
copyrightTB->setPlainText(copyright());
|
||||
copyrightTB->append(QString());
|
||||
copyrightTB->append(license());
|
||||
copyrightTB->append(QString());
|
||||
copyrightTB->append(disclaimer());
|
||||
|
||||
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());
|
||||
versionLA->setText(version());
|
||||
creditsTB->setHtml(credits());
|
||||
}
|
||||
|
||||
} // namespace frontend
|
||||
|
@ -13,11 +13,8 @@
|
||||
#define GUIABOUT_H
|
||||
|
||||
#include "GuiDialog.h"
|
||||
#include "ControlAboutlyx.h"
|
||||
#include "ui_AboutUi.h"
|
||||
|
||||
#include <QDialog>
|
||||
|
||||
namespace lyx {
|
||||
namespace frontend {
|
||||
|
||||
@ -28,8 +25,6 @@ class GuiAboutDialog : public GuiDialog, public Ui::AboutUi
|
||||
public:
|
||||
// Constructor
|
||||
GuiAboutDialog(LyXView & lv);
|
||||
/// parent controller
|
||||
ControlAboutlyx & controller() const;
|
||||
};
|
||||
|
||||
} // namespace frontend
|
||||
|
Loading…
Reference in New Issue
Block a user