1 /*****************************************************************************
3 ****************************************************************************
4 * Copyright ( C ) 2006 the VideoLAN team
7 * Authors: Clément Stenac <zorglub@videolan.org>
8 * Jean-Baptiste Kempf <jb@videolan.org>
10 * This program is free software; you can redistribute it and/or modify
11 * it under the terms of the GNU General Public License as published by
12 * the Free Software Foundation; either version 2 of the License, or
13 * ( at your option ) any later version.
15 * This program is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU General Public License for more details.
20 * You should have received a copy of the GNU General Public License
21 * along with this program; if not, write to the Free Software
22 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
23 *****************************************************************************/
28 #include "dialogs/errors.hpp"
30 #include <QTextCursor>
33 #include <QGridLayout>
34 #include <QDialogButtonBox>
35 #include <QPushButton>
37 ErrorsDialog::ErrorsDialog( intf_thread_t *_p_intf )
38 : QVLCDialog( (QWidget*)_p_intf->p_sys->p_mi, _p_intf )
40 setWindowTitle( qtr( "Errors" ) );
41 setWindowRole( "vlc-errors" );
44 QGridLayout *layout = new QGridLayout( this );
46 QDialogButtonBox *buttonBox = new QDialogButtonBox;
47 QPushButton *closeButton = new QPushButton( qtr( "&Close" ) );
48 QPushButton *clearButton = new QPushButton( qtr( "&Clear" ) );
49 buttonBox->addButton( closeButton, QDialogButtonBox::AcceptRole );
50 buttonBox->addButton( clearButton, QDialogButtonBox::ActionRole );
52 messages = new QTextEdit();
53 messages->setReadOnly( true );
54 messages->setHorizontalScrollBarPolicy( Qt::ScrollBarAlwaysOff );
55 stopShowing = new QCheckBox( qtr( "Hide future errors" ) );
57 layout->addWidget( messages, 0, 0, 1, 3 );
58 layout->addWidget( stopShowing, 1, 0 );
59 layout->addItem( new QSpacerItem( 200, 20, QSizePolicy::Expanding ), 2,0 );
60 layout->addWidget( buttonBox, 2, 2 );
62 CONNECT( buttonBox, accepted(), this, close() );
63 BUTTONACT( clearButton, clear() );
64 BUTTONACT( stopShowing, dontShow() );
67 void ErrorsDialog::addError( const QString& title, const QString& text )
69 add( true, title, text );
72 /*void ErrorsDialog::addWarning( QString title, QString text )
74 add( false, title, text );
77 void ErrorsDialog::add( bool error, const QString& title, const QString& text )
79 if( stopShowing->isChecked() ) return;
80 messages->textCursor().movePosition( QTextCursor::End );
81 messages->setTextColor( error ? "red" : "yellow" );
82 messages->insertPlainText( title + QString( ":\n" ) );
83 messages->setTextColor( "black" );
84 messages->insertPlainText( text + QString( "\n" ) );
85 messages->ensureCursorVisible();
89 void ErrorsDialog::close()
94 void ErrorsDialog::clear()
99 void ErrorsDialog::dontShow()
101 if( stopShowing->isChecked() )
103 config_PutInt( p_intf, "qt-show-errors", 0 );