Commit f70a9052 authored by Rémi Denis-Courmont's avatar Rémi Denis-Courmont

Qt4: restore message dialog

(bug at exit due to more generic problems with #2226 and #2227)
parent 42b58e87
...@@ -39,9 +39,16 @@ ...@@ -39,9 +39,16 @@
#include <QTreeWidget> #include <QTreeWidget>
#include <QTreeWidgetItem> #include <QTreeWidgetItem>
#include <QHeaderView> #include <QHeaderView>
#include <QMutex>
MessagesDialog *MessagesDialog::instance = NULL; MessagesDialog *MessagesDialog::instance = NULL;
struct msg_cb_data_t
{
MessagesDialog *self;
QMutex lock; /**< protects MessagesDialog::messages */
};
MessagesDialog::MessagesDialog( intf_thread_t *_p_intf) MessagesDialog::MessagesDialog( intf_thread_t *_p_intf)
: QVLCFrame( _p_intf ) : QVLCFrame( _p_intf )
{ {
...@@ -64,7 +71,6 @@ MessagesDialog::MessagesDialog( intf_thread_t *_p_intf) ...@@ -64,7 +71,6 @@ MessagesDialog::MessagesDialog( intf_thread_t *_p_intf)
msgLayout->addWidget( messages, 0, 0, 1, 0 ); msgLayout->addWidget( messages, 0, 0, 1, 0 );
mainTab->addTab( msgWidget, qtr( "Messages" ) ); mainTab->addTab( msgWidget, qtr( "Messages" ) );
// ON_TIMEOUT( updateLog() );
/* Modules tree */ /* Modules tree */
...@@ -109,8 +115,21 @@ MessagesDialog::MessagesDialog( intf_thread_t *_p_intf) ...@@ -109,8 +115,21 @@ MessagesDialog::MessagesDialog( intf_thread_t *_p_intf)
/* General action */ /* General action */
readSettings( "Messages", QSize( 600, 450 ) ); readSettings( "Messages", QSize( 600, 450 ) );
/* Hook up to LibVLC messaging */
cb_data = new msg_cb_data_t;
cb_data->self = this;
sub = msg_Subscribe (_p_intf->p_libvlc, sinkMessage, cb_data);
} }
MessagesDialog::~MessagesDialog ()
{
writeSettings( "messages" );
msg_Unsubscribe (sub);
delete cb_data;
};
void MessagesDialog::updateTab( int index ) void MessagesDialog::updateTab( int index )
{ {
/* Second tab : modules tree */ /* Second tab : modules tree */
...@@ -132,72 +151,53 @@ void MessagesDialog::updateTab( int index ) ...@@ -132,72 +151,53 @@ void MessagesDialog::updateTab( int index )
} }
} }
void MessagesDialog::updateLog() void MessagesDialog::sinkMessage (msg_cb_data_t *data, msg_item_t *item,
unsigned overruns)
{
MessagesDialog *self = data->self;
QMutexLocker locker (&data->lock);
self->sinkMessage (item, overruns);
}
void MessagesDialog::sinkMessage (msg_item_t *item, unsigned)
{ {
#if 0 if ((item->i_type == VLC_MSG_WARN && verbosityBox->value() < 1)
msg_subscription_t *p_sub = p_intf->p_sys->p_sub; || (item->i_type == VLC_MSG_DBG && verbosityBox->value() < 2 ))
int i_start; return;
vlc_mutex_lock( p_sub->p_lock ); messages->textCursor().movePosition( QTextCursor::End );
int i_stop = *p_sub->pi_stop; messages->setFontItalic( true );
vlc_mutex_unlock( p_sub->p_lock ); messages->setTextColor( "darkBlue" );
messages->insertPlainText( qfu( item->psz_module ) );
if( p_sub->i_start != i_stop ) switch (item->i_type)
{ {
messages->textCursor().movePosition( QTextCursor::End ); case VLC_MSG_INFO:
messages->setTextColor( "blue" );
for( i_start = p_sub->i_start; messages->insertPlainText( " info: " );
i_start != i_stop; break;
i_start = (i_start+1) % VLC_MSG_QSIZE ) case VLC_MSG_ERR:
{ messages->setTextColor( "red" );
if( p_sub->p_msg[i_start].i_type == VLC_MSG_INFO || messages->insertPlainText( " error: " );
p_sub->p_msg[i_start].i_type == VLC_MSG_ERR || break;
p_sub->p_msg[i_start].i_type == VLC_MSG_WARN && case VLC_MSG_WARN:
verbosityBox->value() >= 1 || messages->setTextColor( "green" );
p_sub->p_msg[i_start].i_type == VLC_MSG_DBG && messages->insertPlainText( " warning: " );
verbosityBox->value() >= 2 ) break;
{ case VLC_MSG_DBG:
messages->setFontItalic( true ); default:
messages->setTextColor( "darkBlue" ); messages->setTextColor( "grey" );
messages->insertPlainText( qfu( p_sub->p_msg[i_start].psz_module ) ); messages->insertPlainText( " debug: " );
} break;
else
continue;
switch( p_sub->p_msg[i_start].i_type )
{
case VLC_MSG_INFO:
messages->setTextColor( "blue" );
messages->insertPlainText( " info: " );
break;
case VLC_MSG_ERR:
messages->setTextColor( "red" );
messages->insertPlainText( " error: " );
break;
case VLC_MSG_WARN:
messages->setTextColor( "green" );
messages->insertPlainText( " warning: " );
break;
case VLC_MSG_DBG:
default:
messages->setTextColor( "grey" );
messages->insertPlainText( " debug: " );
break;
}
/* Add message Regular black Font */
messages->setFontItalic( false );
messages->setTextColor( "black" );
messages->insertPlainText( qfu(p_sub->p_msg[i_start].psz_msg) );
messages->insertPlainText( "\n" );
}
messages->ensureCursorVisible();
vlc_mutex_lock( p_sub->p_lock );
p_sub->i_start = i_start;
vlc_mutex_unlock( p_sub->p_lock );
} }
#endif
/* Add message Regular black Font */
messages->setFontItalic( false );
messages->setTextColor( "black" );
messages->insertPlainText( qfu(item->psz_msg) );
messages->insertPlainText( "\n" );
messages->ensureCursorVisible();
} }
void MessagesDialog::buildTree( QTreeWidgetItem *parentItem, void MessagesDialog::buildTree( QTreeWidgetItem *parentItem,
...@@ -242,6 +242,7 @@ void MessagesDialog::updateTree() ...@@ -242,6 +242,7 @@ void MessagesDialog::updateTree()
void MessagesDialog::clear() void MessagesDialog::clear()
{ {
QMutexLocker locker (&cb_data->lock);
messages->clear(); messages->clear();
} }
...@@ -264,6 +265,7 @@ bool MessagesDialog::save() ...@@ -264,6 +265,7 @@ bool MessagesDialog::save()
} }
QTextStream out( &file ); QTextStream out( &file );
QMutexLocker locker (&cb_data->lock);
out << messages->toPlainText() << "\n"; out << messages->toPlainText() << "\n";
return true; return true;
......
...@@ -51,7 +51,7 @@ public: ...@@ -51,7 +51,7 @@ public:
instance = NULL; instance = NULL;
} }
virtual ~MessagesDialog(){ writeSettings( "messages" ); }; virtual ~MessagesDialog();
private: private:
MessagesDialog( intf_thread_t * ); MessagesDialog( intf_thread_t * );
...@@ -63,10 +63,13 @@ private: ...@@ -63,10 +63,13 @@ private:
QTreeWidget *modulesTree; QTreeWidget *modulesTree;
QPushButton *clearUpdateButton; QPushButton *clearUpdateButton;
QPushButton *saveLogButton; QPushButton *saveLogButton;
msg_subscription_t *sub;
msg_cb_data_t *cb_data;
static void sinkMessage (msg_cb_data_t *, msg_item_t *, unsigned);
void sinkMessage (msg_item_t *item, unsigned);
private slots: private slots:
void updateTab( int ); void updateTab( int );
void updateLog();
void clearOrUpdate(); void clearOrUpdate();
bool save(); bool save();
private: private:
......
...@@ -263,8 +263,6 @@ static int Open( vlc_object_t *p_this ) ...@@ -263,8 +263,6 @@ static int Open( vlc_object_t *p_this )
/* Access to the playlist */ /* Access to the playlist */
p_intf->p_sys->p_playlist = pl_Hold( p_intf ); p_intf->p_sys->p_playlist = pl_Hold( p_intf );
/* Listen to the messages */
//p_intf->p_sys->p_sub = msg_Subscribe( p_intf->p_libvlc, NULL, NULL );
/* one settings to rule them all */ /* one settings to rule them all */
var_Create( p_this, "window_widget", VLC_VAR_ADDRESS ); var_Create( p_this, "window_widget", VLC_VAR_ADDRESS );
...@@ -298,7 +296,6 @@ static void Close( vlc_object_t *p_this ) ...@@ -298,7 +296,6 @@ static void Close( vlc_object_t *p_this )
} }
vlc_object_release( p_intf->p_sys->p_playlist ); vlc_object_release( p_intf->p_sys->p_playlist );
//msg_Unsubscribe( p_intf->p_sys->p_sub );
free( p_intf->p_sys ); free( p_intf->p_sys );
} }
......
...@@ -72,7 +72,6 @@ struct intf_sys_t ...@@ -72,7 +72,6 @@ struct intf_sys_t
bool b_isDialogProvider; bool b_isDialogProvider;
playlist_t *p_playlist; playlist_t *p_playlist;
msg_subscription_t *p_sub; ///< Subscription to the message bank
VideoWidget *p_video; VideoWidget *p_video;
......
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