2006-03-05 17:24:44 +00:00
/**
2007-08-31 05:53:55 +00:00
* \ file GuiAbout . cpp
2006-03-05 17:24:44 +00:00
* 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>
2007-08-31 05:53:55 +00:00
# include "GuiAbout.h"
2007-09-05 22:54:47 +00:00
2010-01-23 20:29:00 +00:00
# include "ui_AboutUi.h"
2006-03-05 17:24:44 +00:00
# include "qt_helpers.h"
2007-09-05 22:54:47 +00:00
# include "version.h"
2006-03-05 17:24:44 +00:00
2007-09-05 22:54:47 +00:00
# include "support/filetools.h"
2009-01-15 13:31:05 +00:00
# include "support/gettext.h"
# include "support/lstrings.h"
2007-09-05 22:54:47 +00:00
# include "support/Package.h"
2006-03-05 17:24:44 +00:00
2009-01-15 13:31:05 +00:00
# include <QDate>
2013-05-15 05:47:02 +00:00
# include <QFile>
2013-05-12 10:27:16 +00:00
# include <QTextStream>
2006-03-05 17:24:44 +00:00
2009-01-15 13:31:05 +00:00
using namespace lyx : : support ;
2007-09-05 22:54:47 +00:00
using lyx : : support : : package ;
using lyx : : support : : makeDisplayPath ;
2006-03-05 17:24:44 +00:00
2007-09-05 20:33:29 +00:00
2006-03-05 17:24:44 +00:00
namespace lyx {
namespace frontend {
2009-01-15 13:31:05 +00:00
static QDate release_date ( )
{
return QDate : : fromString ( QString ( lyx_release_date ) , Qt : : ISODate ) ;
}
2007-09-05 22:54:47 +00:00
static QString credits ( )
2006-03-05 17:24:44 +00:00
{
2007-09-05 22:54:47 +00:00
QString res ;
2010-04-21 01:19:09 +00:00
QFile file ( toqstr ( package ( ) . system_support ( ) . absFileName ( ) ) + " /CREDITS " ) ;
2007-09-05 22:54:47 +00:00
QTextStream out ( & res ) ;
if ( file . isReadable ( ) ) {
2008-02-05 12:43:19 +00:00
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. " ) ;
2007-09-05 22:54:47 +00:00
} else {
file . open ( QIODevice : : ReadOnly ) ;
QTextStream ts ( & file ) ;
2008-07-07 23:41:19 +00:00
ts . setCodec ( " UTF-8 " ) ;
2007-09-05 22:54:47 +00:00
QString line ;
do {
line = ts . readLine ( ) ;
if ( line . startsWith ( " @b " ) )
out < < " <b> " < < line . mid ( 2 ) < < " </b> " ;
2009-11-10 14:45:21 +00:00
else if ( line . startsWith ( " @i " ) ) {
if ( line . startsWith ( " @iE-mail " ) ) {
// unmask email
line . replace ( QString ( " () " ) , QString ( " @ " ) ) ;
line . replace ( QString ( " ! " ) , QString ( " . " ) ) ;
}
2007-09-05 22:54:47 +00:00
out < < " <i> " < < line . mid ( 2 ) < < " </i> " ;
2009-11-10 14:45:21 +00:00
} else
2007-09-05 22:54:47 +00:00
out < < line ;
out < < " <br> " ;
} while ( ! line . isNull ( ) ) ;
}
out . flush ( ) ;
return res ;
}
2006-03-05 17:24:44 +00:00
2007-09-05 22:54:47 +00:00
static QString copyright ( )
{
2009-01-15 13:31:05 +00:00
QString release_year = release_date ( ) . toString ( " yyyy " ) ;
docstring copy_message =
bformat ( _ ( " LyX is Copyright (C) 1995 by Matthias Ettrich, \n 1995--%1$s LyX Team " ) ,
qstring_to_ucs4 ( release_year ) ) ;
return toqstr ( copy_message ) ;
2007-09-05 22:54:47 +00:00
}
2007-09-05 20:33:29 +00:00
2006-03-05 17:24:44 +00:00
2007-09-05 22:54:47 +00:00
static QString license ( )
{
2008-02-05 12:43:19 +00:00
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. " ) ;
2007-09-05 22:54:47 +00:00
}
2006-03-05 17:24:44 +00:00
2007-09-05 22:54:47 +00:00
static QString disclaimer ( )
{
2008-02-05 12:43:19 +00:00
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. \n See the GNU General Public License for more details. \n You 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. " ) ;
2007-09-05 22:54:47 +00:00
}
2006-03-05 17:24:44 +00:00
2007-09-05 22:54:47 +00:00
static QString version ( )
{
2009-03-18 23:17:33 +00:00
QString loc_release_date ;
QDate date = release_date ( ) ;
if ( date . isValid ( ) ) {
QLocale loc ;
loc_release_date = loc . toString ( date , QLocale : : LongFormat ) ;
} else {
2009-02-16 10:06:24 +00:00
if ( QString ( lyx_release_date ) = = " not released yet " )
2009-01-15 13:56:40 +00:00
loc_release_date = qt_ ( " not released yet " ) ;
else
loc_release_date = toqstr ( lyx_release_date ) ;
}
2009-01-15 13:31:05 +00:00
docstring version_date =
2009-01-17 13:30:41 +00:00
bformat ( _ ( " LyX Version %1$s \n (%2$s) " ) ,
2009-01-15 13:31:05 +00:00
from_ascii ( lyx_version ) ,
2009-01-17 13:30:41 +00:00
qstring_to_ucs4 ( loc_release_date ) ) + " \n \n " ;
2007-09-05 22:54:47 +00:00
QString res ;
QTextStream out ( & res ) ;
2009-01-15 13:31:05 +00:00
out < < toqstr ( version_date ) ;
2008-02-05 12:43:19 +00:00
out < < qt_ ( " Library directory: " ) ;
2010-04-21 01:19:09 +00:00
out < < toqstr ( makeDisplayPath ( package ( ) . system_support ( ) . absFileName ( ) ) ) ;
2007-09-05 22:54:47 +00:00
out < < " \n " ;
2008-02-05 12:43:19 +00:00
out < < qt_ ( " User directory: " ) ;
2010-04-21 01:19:09 +00:00
out < < toqstr ( makeDisplayPath ( package ( ) . user_support ( ) . absFileName ( ) ) ) ;
2010-03-11 18:31:01 +00:00
# ifdef DEVEL_VERSION
out < < " \n " ;
2013-05-13 10:45:59 +00:00
out < < toqstr ( bformat ( _ ( " Qt Version (run-time): %1$s " ) , from_ascii ( qVersion ( ) ) ) ) < < " \n " ;
out < < toqstr ( bformat ( _ ( " Qt Version (compile-time): %1$s " ) , from_ascii ( QT_VERSION_STR ) ) ) < < " \n " ;
2010-03-11 18:31:01 +00:00
# endif
2007-09-05 22:54:47 +00:00
return res ;
}
2006-03-05 17:24:44 +00:00
2012-10-07 15:27:07 +00:00
static QString buildinfo ( )
{
QString res ;
QTextStream out ( & res ) ;
out < < " LyX " < < lyx_version
< < " ( " < < lyx_release_date < < " ) " < < endl ;
2013-05-13 10:47:22 +00:00
out < < toqstr ( bformat ( _ ( " Built on %1$s[[date]], %2$s[[time]] " ) ,
2013-05-13 10:45:59 +00:00
from_ascii ( __DATE__ ) , from_ascii ( __TIME__ ) ) ) < < endl ;
2012-10-07 15:27:07 +00:00
out < < lyx_version_info < < endl ;
return res ;
}
2006-03-05 17:24:44 +00:00
2010-01-23 20:29:00 +00:00
struct GuiAbout : : Private
{
Ui : : AboutUi ui ;
} ;
2007-11-23 09:44:02 +00:00
GuiAbout : : GuiAbout ( GuiView & lv )
2010-01-23 20:29:00 +00:00
: DialogView ( lv , " aboutlyx " , qt_ ( " About LyX " ) ) ,
d ( new GuiAbout : : Private )
2007-09-05 22:54:47 +00:00
{
2010-01-23 20:29:00 +00:00
d - > ui . setupUi ( this ) ;
2006-03-05 17:24:44 +00:00
2010-01-23 20:29:00 +00:00
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 ( ) ) ;
d - > ui . versionLA - > setText ( version ( ) ) ;
2012-10-07 15:27:07 +00:00
d - > ui . buildinfoTB - > setText ( buildinfo ( ) ) ;
2010-01-23 20:29:00 +00:00
d - > ui . creditsTB - > setHtml ( credits ( ) ) ;
}
2007-09-05 20:33:29 +00:00
2010-01-23 20:29:00 +00:00
void GuiAbout : : on_closePB_clicked ( )
{
close ( ) ;
2006-03-05 17:24:44 +00:00
}
2007-10-06 09:55:21 +00:00
2007-11-23 09:44:02 +00:00
Dialog * createGuiAbout ( GuiView & lv ) { return new GuiAbout ( lv ) ; }
2007-10-06 09:55:21 +00:00
2006-03-05 17:24:44 +00:00
} // namespace frontend
} // namespace lyx
2007-04-24 11:32:09 +00:00
2008-11-14 14:28:50 +00:00
# include "moc_GuiAbout.cpp"