About.cpp 3.1 KB
Newer Older
Ludovic Fauvet's avatar
Ludovic Fauvet committed
1 2 3
/*****************************************************************************
 * About.cpp: About dialog
 *****************************************************************************
Ludovic Fauvet's avatar
Ludovic Fauvet committed
4
 * Copyright (C) 2008-2010 VideoLAN
Ludovic Fauvet's avatar
Ludovic Fauvet committed
5 6
 *
 * Authors: Christophe Courtaut <christophe.courtaut@gmail.com>
7
 *          Rohit Yadav <rohityadav89@gmail.com>
Ludovic Fauvet's avatar
Ludovic Fauvet committed
8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23
 *
 * 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.
 *
 * This program 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.  See the
 * GNU General Public License for more details.
 *
 * 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.
 *****************************************************************************/

24 25 26
#include "About.h"
#include "config.h"

Ludovic Fauvet's avatar
Ludovic Fauvet committed
27
#include <QApplication>
Ludovic Fauvet's avatar
Ludovic Fauvet committed
28
#include <QFile>
Ludovic Fauvet's avatar
Ludovic Fauvet committed
29
#include <QPlainTextEdit>
30
#include <QString>
31
#include <QtGlobal>
Ludovic Fauvet's avatar
Ludovic Fauvet committed
32

33
About::About( QWidget *parent ) : QDialog( parent )
Ludovic Fauvet's avatar
Ludovic Fauvet committed
34 35 36
{
    m_ui.setupUi( this );
    m_ui.tabWidget->setCurrentIndex( 0 );
37

Ludovic Fauvet's avatar
Ludovic Fauvet committed
38
    setText( ":/text/AUTHORS", m_ui.plainTextEditAuthors );
39
    setText( ":/text/THANKS", m_ui.plainTextEditThanks );
Ludovic Fauvet's avatar
Ludovic Fauvet committed
40 41
    setText( ":/text/TRANSLATORS", m_ui.plainTextEditTranslators );
    setText( ":/text/COPYING", m_ui.plainTextEditLicense );
42

43
    m_ui.labelTitle->setText(
44 45 46
        m_ui.labelTitle->text().arg( PROJECT_VERSION, CODENAME ) );

    m_ui.labelBuild->setText(
47 48
        m_ui.labelBuild->text().arg( HOSTNAME, SYSNAME,
                                     QT_VERSION_STR, qVersion() ) );
49

50 51 52
    m_ui.labelCopyright->setText(
        m_ui.labelCopyright->text().arg( PROJECT_COPYRIGHT, PROJECT_CONTACT,
                                         ORG_WEBSITE ) );
53

Ludovic Fauvet's avatar
Ludovic Fauvet committed
54 55 56
    connect( qApp, SIGNAL( aboutToQuit() ), this, SLOT( deleteLater() ) );
}

57 58
void
About::changeEvent( QEvent *e )
Ludovic Fauvet's avatar
Ludovic Fauvet committed
59 60 61 62
{
    QDialog::changeEvent( e );
    switch ( e->type() )
    {
63 64
        case QEvent::LanguageChange:
            m_ui.retranslateUi( this );
65 66 67 68 69
            m_ui.labelTitle->setText(
                m_ui.labelTitle->text().arg( PROJECT_VERSION, CODENAME ) );
            m_ui.labelBuild->setText(
                m_ui.labelBuild->text().arg( HOSTNAME, SYSNAME,
                                             QT_VERSION_STR, qVersion() ) );
70
            m_ui.labelCopyright->setText(
71 72
                m_ui.labelCopyright->text().arg( PROJECT_COPYRIGHT,
                                                 PROJECT_CONTACT, ORG_WEBSITE ) );
73 74 75
            break;
        default:
            break;
Ludovic Fauvet's avatar
Ludovic Fauvet committed
76 77 78
    }
}

79 80
void
About::setText( const QString& filename, QPlainTextEdit* widget )
Ludovic Fauvet's avatar
Ludovic Fauvet committed
81 82
{
    QFile file( filename );
83

Ludovic Fauvet's avatar
Ludovic Fauvet committed
84 85
    if ( file.open( QIODevice::ReadOnly | QIODevice::Text ) )
        widget->insertPlainText( QString::fromUtf8( file.readAll() ) );
86

Ludovic Fauvet's avatar
Ludovic Fauvet committed
87 88
    widget->moveCursor( QTextCursor::Start );
}