--- /dev/null
+/*****************************************************************************
+ * errors.cpp : Errors
+ ****************************************************************************
+ * Copyright (C) 2006 the VideoLAN team
+ * $Id: Errors.cpp 16024 2006-07-13 13:51:05Z xtophe $
+ *
+ * Authors: Clément Stenac <zorglub@videolan.org>
+ *
+ * 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.
+ *****************************************************************************/
+
+#include "dialogs/errors.hpp"
+#include "qt4.hpp"
+
+#include <QTextCursor>
+#include <QTextEdit>
+#include <QCheckBox>
+#include <QGridLayout>
+#include <QPushButton>
+
+ErrorsDialog *ErrorsDialog::instance = NULL;
+
+ErrorsDialog::ErrorsDialog( intf_thread_t *_p_intf ) : QVLCFrame( _p_intf )
+{
+ setWindowTitle( _("Errors" ) );
+ resize( 500 , 200 );
+
+ QGridLayout *layout = new QGridLayout( this );
+ QPushButton *closeButton = new QPushButton(qtr("&Close"));
+ QPushButton *clearButton = new QPushButton(qtr("&Clear"));
+ messages = new QTextEdit();
+ messages->setReadOnly( true );
+ messages->setHorizontalScrollBarPolicy( Qt::ScrollBarAlwaysOff );
+ stopShowing = new QCheckBox( qtr( "Don't show further errors") );
+
+ layout->addWidget( messages, 0, 0, 1, 3 );
+ layout->addWidget( stopShowing, 1, 0 );
+ layout->addItem( new QSpacerItem( 200, 20, QSizePolicy::Expanding ), 2,0 );
+ layout->addWidget( clearButton, 2, 1 );
+ layout->addWidget( closeButton, 2, 2 );
+
+ connect( closeButton, SIGNAL( clicked() ), this, SLOT( onClose() ));
+ connect( clearButton, SIGNAL( clicked() ), this, SLOT( onClear() ));
+ connect( stopShowing, SIGNAL( clicked() ), this, SLOT( dontShow() ) );
+}
+
+void ErrorsDialog::addError( QString title, QString text )
+{
+ add( true, title, text );
+}
+
+void ErrorsDialog::addWarning( QString title, QString text )
+{
+ add( false, title, text );
+}
+
+void ErrorsDialog::add( bool error, QString title, QString text )
+{
+ if( stopShowing->isChecked() ) return;
+ messages->textCursor().movePosition( QTextCursor::End );
+ messages->setTextColor( error ? "red" : "yellow" );
+ messages->insertPlainText( title + QString( ":\n" ));
+ messages->setTextColor( "black" );
+ messages->insertPlainText( text + QString( "\n" ) );
+ messages->ensureCursorVisible();
+ show();
+}
+
+void ErrorsDialog::onClose()
+{
+ hide();
+}
+
+void ErrorsDialog::onClear()
+{
+ messages->clear();
+}
+
+void ErrorsDialog::dontShow()
+{
+ if( stopShowing->isChecked() )
+ {
+ config_PutInt( p_intf, "qt-show-errors", 0 );
+ }
+}
--- /dev/null
+/*****************************************************************************
+ * errors.hpp : Errors
+ ****************************************************************************
+ * Copyright (C) 2006 the VideoLAN team
+ * $Id: Errors.hpp 16024 2006-07-13 13:51:05Z xtophe $
+ *
+ * Authors: Jean-Baptiste Kempf <jb (at) videolan.org>
+ *
+ * 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. *****************************************************************************/
+
+#ifndef _ERRORS_DIALOG_H_
+#define _ERRORS_DIALOG_H_
+
+#include "util/qvlcframe.hpp"
+
+class QPushButton;
+class QCheckBox;
+class QGridLayout;
+class QTextEdit;
+
+class ErrorsDialog : public QVLCFrame
+{
+ Q_OBJECT;
+public:
+ static ErrorsDialog * getInstance( intf_thread_t *p_intf )
+ {
+ if( !instance)
+ instance = new ErrorsDialog( p_intf );
+ return instance;
+ }
+ virtual ~ErrorsDialog() {};
+
+ void addError( QString, QString );
+ void addWarning( QString, QString );
+private:
+ ErrorsDialog( intf_thread_t * );
+ static ErrorsDialog *instance;
+ void add( bool, QString, QString );
+
+ QCheckBox *stopShowing;
+ QTextEdit *messages;
+public slots:
+ void onClose();
+ void onClear();
+ void dontShow();
+};
+
+#endif
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA. *****************************************************************************/
#include <QMessageBox>
+#include "dialogs/errors.hpp"
#include "dialogs/interaction.hpp"
#include "util/qvlcframe.hpp"
#include <vlc/intf.h>
}
else if( p_dialog->i_flags & DIALOG_NONBLOCKING_ERROR )
{
- // Create instance of the errors dialog
+ if( config_GetInt( p_intf, "qt-show-errors" ) != 0 )
+ ErrorsDialog::getInstance( p_intf )->addError(
+ qfu( p_dialog->psz_title ), qfu( p_dialog->psz_description ) );
+ i_ret = 0;
// QApplication::style()->standardPixmap(QStyle::SP_MessageBoxCritical)
}
+ else if( p_dialog->i_flags & DIALOG_WARNING )
+ {
+ if( config_GetInt( p_intf, "qt-show-errors" ) != 0 )
+ ErrorsDialog::getInstance( p_intf )->addWarning(
+ qfu( p_dialog->psz_title ),qfu( p_dialog->psz_description ) );
+ i_ret = 0;
+ }
else if( p_dialog->i_flags & DIALOG_YES_NO_CANCEL )
{
i_ret = QMessageBox::question( this,