1 /*****************************************************************************
3 ****************************************************************************
4 * Copyright ( C ) 2006 the VideoLAN team
7 * Authors: Clément Stenac <zorglub@videolan.org>
9 * This program is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License as published by
11 * the Free Software Foundation; either version 2 of the License, or
12 * ( at your option ) any later version.
14 * This program is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU General Public License for more details.
19 * You should have received a copy of the GNU General Public License
20 * along with this program; if not, write to the Free Software
21 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
22 *****************************************************************************/
24 #include "dialogs/errors.hpp"
26 #include <QTextCursor>
29 #include <QGridLayout>
30 #include <QPushButton>
32 ErrorsDialog *ErrorsDialog::instance = NULL;
34 ErrorsDialog::ErrorsDialog( intf_thread_t *_p_intf ) : QVLCFrame( _p_intf )
36 setWindowTitle( qtr( "Errors" ) );
39 setWindowModality( Qt::ApplicationModal );
41 QGridLayout *layout = new QGridLayout( this );
42 QPushButton *closeButton = new QPushButton( qtr( "&Close" ) );
43 QPushButton *clearButton = new QPushButton( qtr( "&Clear" ) );
44 messages = new QTextEdit();
45 messages->setReadOnly( true );
46 messages->setHorizontalScrollBarPolicy( Qt::ScrollBarAlwaysOff );
47 stopShowing = new QCheckBox( qtr( "Hide future errors" ) );
49 layout->addWidget( messages, 0, 0, 1, 3 );
50 layout->addWidget( stopShowing, 1, 0 );
51 layout->addItem( new QSpacerItem( 200, 20, QSizePolicy::Expanding ), 2,0 );
52 layout->addWidget( clearButton, 2, 1 );
53 layout->addWidget( closeButton, 2, 2 );
55 BUTTONACT( closeButton, close() );
56 BUTTONACT( clearButton, clear() );
57 BUTTONACT( stopShowing, dontShow() );
60 void ErrorsDialog::addError( QString title, QString text )
62 add( true, title, text );
65 void ErrorsDialog::addWarning( QString title, QString text )
67 add( false, title, text );
70 void ErrorsDialog::add( bool error, QString title, QString text )
72 if( stopShowing->isChecked() ) return;
73 messages->textCursor().movePosition( QTextCursor::End );
74 messages->setTextColor( error ? "red" : "yellow" );
75 messages->insertPlainText( title + QString( ":\n" ) );
76 messages->setTextColor( "black" );
77 messages->insertPlainText( text + QString( "\n" ) );
78 messages->ensureCursorVisible();
82 void ErrorsDialog::close()
87 void ErrorsDialog::clear()
92 void ErrorsDialog::dontShow()
94 if( stopShowing->isChecked() )
96 config_PutInt( p_intf, "qt-show-errors", 0 );