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
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>
2007-09-05 22:54:47 +00:00
# include <QtCore>
# include <QtGui>
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 ;
2008-06-07 12:43:44 +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> " ;
else if ( line . startsWith ( " @i " ) )
out < < " <i> " < < line . mid ( 2 ) < < " </i> " ;
else
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-01-15 13:31:05 +00:00
QLocale loc ;
QString loc_release_date =
loc . toString ( release_date ( ) , QLocale : : LongFormat ) ;
2009-01-15 13:56:40 +00:00
if ( loc_release_date . isEmpty ( ) ) {
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: " ) ;
2007-09-05 22:54:47 +00:00
out < < toqstr ( makeDisplayPath ( package ( ) . system_support ( ) . absFilename ( ) ) ) ;
out < < " \n " ;
2008-02-05 12:43:19 +00:00
out < < qt_ ( " User directory: " ) ;
2007-09-05 22:54:47 +00:00
out < < toqstr ( makeDisplayPath ( package ( ) . user_support ( ) . absFilename ( ) ) ) ;
return res ;
}
2006-03-05 17:24:44 +00:00
2007-11-23 09:44:02 +00:00
GuiAbout : : GuiAbout ( GuiView & lv )
2008-02-05 12:43:19 +00:00
: GuiDialog ( lv , " aboutlyx " , qt_ ( " About LyX " ) )
2007-09-05 22:54:47 +00:00
{
setupUi ( this ) ;
2006-03-05 17:24:44 +00:00
2007-09-05 22:54:47 +00:00
connect ( closePB , SIGNAL ( clicked ( ) ) , this , SLOT ( reject ( ) ) ) ;
2007-09-05 20:33:29 +00:00
2007-09-05 22:54:47 +00:00
copyrightTB - > setPlainText ( copyright ( ) ) ;
copyrightTB - > append ( QString ( ) ) ;
copyrightTB - > append ( license ( ) ) ;
copyrightTB - > append ( QString ( ) ) ;
copyrightTB - > append ( disclaimer ( ) ) ;
2007-09-05 20:33:29 +00:00
2007-09-05 22:54:47 +00:00
versionLA - > setText ( version ( ) ) ;
creditsTB - > setHtml ( credits ( ) ) ;
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"