Commit e03cced9 authored by Clément Stenac's avatar Clément Stenac

Warnings/Errors dialog

parent 69c492db
......@@ -25,6 +25,7 @@ TOMOC = main_interface \
dialogs/playlist \
dialogs/prefs_dialog \
dialogs/messages \
dialogs/errors \
dialogs/streaminfo \
dialogs/interaction \
components/infopanels \
......@@ -49,6 +50,7 @@ nodist_SOURCES_qt4 = \
dialogs/playlist.moc.cpp \
dialogs/streaminfo.moc.cpp \
dialogs/messages.moc.cpp \
dialogs/errors.moc.cpp \
dialogs/prefs_dialog.moc.cpp \
dialogs/interaction.moc.cpp \
components/infopanels.moc.cpp \
......@@ -94,6 +96,7 @@ SOURCES_qt4 = qt4.cpp \
dialogs/prefs_dialog.cpp \
dialogs/streaminfo.cpp \
dialogs/messages.cpp \
dialogs/errors.cpp \
dialogs/interaction.cpp \
components/infopanels.cpp \
components/preferences_widgets.cpp \
......@@ -118,6 +121,7 @@ EXTRA_DIST += \
dialogs/playlist.hpp \
dialogs/streaminfo.hpp \
dialogs/messages.hpp \
dialogs/errors.hpp \
dialogs/prefs_dialog.hpp \
dialogs/interaction.hpp \
components/infopanels.hpp \
......
/*****************************************************************************
* 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 );
}
}
/*****************************************************************************
* 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
......@@ -21,6 +21,7 @@
* 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>
......@@ -45,9 +46,19 @@ InteractionDialog::InteractionDialog( intf_thread_t *_p_intf,
}
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,
......
......@@ -120,7 +120,8 @@ void DialogsProvider::doInteraction( intf_dialog_args_t *p_arg )
case INTERACT_NEW:
qdialog = new InteractionDialog( p_intf, p_dialog );
p_dialog->p_private = (void*)qdialog;
qdialog->show();
if( !(p_dialog->i_status == ANSWERED_DIALOG) )
qdialog->show();
break;
case INTERACT_UPDATE:
qdialog = (InteractionDialog*)(p_dialog->p_private);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment