]> git.sesse.net Git - vlc/commitdiff
Warnings/Errors dialog
authorClément Stenac <zorglub@videolan.org>
Thu, 31 Aug 2006 22:10:11 +0000 (22:10 +0000)
committerClément Stenac <zorglub@videolan.org>
Thu, 31 Aug 2006 22:10:11 +0000 (22:10 +0000)
modules/gui/qt4/Modules.am
modules/gui/qt4/dialogs/errors.cpp [new file with mode: 0644]
modules/gui/qt4/dialogs/errors.hpp [new file with mode: 0644]
modules/gui/qt4/dialogs/interaction.cpp
modules/gui/qt4/dialogs_provider.cpp

index bebc177ff36964b1862b6fe45795f2e40651be42..4132304a89afbbd94bebaed12b935148582b5753 100644 (file)
@@ -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 \
diff --git a/modules/gui/qt4/dialogs/errors.cpp b/modules/gui/qt4/dialogs/errors.cpp
new file mode 100644 (file)
index 0000000..67bcf76
--- /dev/null
@@ -0,0 +1,97 @@
+/*****************************************************************************
+ * 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 );
+    }
+}
diff --git a/modules/gui/qt4/dialogs/errors.hpp b/modules/gui/qt4/dialogs/errors.hpp
new file mode 100644 (file)
index 0000000..6229140
--- /dev/null
@@ -0,0 +1,60 @@
+/*****************************************************************************
+ * 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
index a419affd30c1f1599d3a73a8bf0823f73fe6a748..db257d7f62e53aebf79185a85d7db95d9c8aee39 100644 (file)
@@ -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,
index 9b0d7c458dadd3114edf4a648b15a1a185c32a26..247049f78c9bfce40f56bf5a23fd593544acd59b 100644 (file)
@@ -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);