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

Qt4: convert VLC message stuff to QString

parent 166da1ce
...@@ -47,23 +47,32 @@ enum { ...@@ -47,23 +47,32 @@ enum {
class MsgEvent : public QEvent class MsgEvent : public QEvent
{ {
public: public:
MsgEvent( msg_item_t *msg ) MsgEvent( const msg_item_t * );
: QEvent( (QEvent::Type)MsgEvent_Type )
{ int priority;
this->msg = msg_Copy( msg ); uintptr_t object_id;
} QString object_type;
virtual ~MsgEvent( void ) QString header;
{ QString module;
msg_Free( msg ); QString text;
}
msg_item_t *msg;
}; };
MsgEvent::MsgEvent( const msg_item_t *msg )
: QEvent( (QEvent::Type)MsgEvent_Type ),
priority( msg->i_type ),
object_id( msg->i_object_id ),
object_type( qfu(msg->psz_object_type) ),
header( qfu(msg->psz_header) ),
module( qfu(msg->psz_module) ),
text( qfu(msg->psz_msg) )
{
}
struct msg_cb_data_t struct msg_cb_data_t
{ {
MessagesDialog *self; MessagesDialog *self;
}; };
static void MsgCallback( msg_cb_data_t *, msg_item_t *, unsigned ); static void MsgCallback( msg_cb_data_t *, msg_item_t *, unsigned );
MessagesDialog::MessagesDialog( intf_thread_t *_p_intf) MessagesDialog::MessagesDialog( intf_thread_t *_p_intf)
...@@ -71,7 +80,6 @@ MessagesDialog::MessagesDialog( intf_thread_t *_p_intf) ...@@ -71,7 +80,6 @@ MessagesDialog::MessagesDialog( intf_thread_t *_p_intf)
{ {
setWindowTitle( qtr( "Messages" ) ); setWindowTitle( qtr( "Messages" ) );
setWindowRole( "vlc-messages" ); setWindowRole( "vlc-messages" );
/* Build Ui */ /* Build Ui */
ui.setupUi( this ); ui.setupUi( this );
ui.bottomButtonsBox->addButton( new QPushButton( qtr("&Close"), this ), ui.bottomButtonsBox->addButton( new QPushButton( qtr("&Close"), this ),
...@@ -160,7 +168,7 @@ void MessagesDialog::updateConfig() ...@@ -160,7 +168,7 @@ void MessagesDialog::updateConfig()
} }
} }
void MessagesDialog::sinkMessage( msg_item_t *item ) void MessagesDialog::sinkMessage( MsgEvent *msg )
{ {
QTextEdit *messages = ui.messages; QTextEdit *messages = ui.messages;
/* Only scroll if the viewport is at the end. /* Only scroll if the viewport is at the end.
...@@ -180,9 +188,9 @@ void MessagesDialog::sinkMessage( msg_item_t *item ) ...@@ -180,9 +188,9 @@ void MessagesDialog::sinkMessage( msg_item_t *item )
messages->setFontItalic( true ); messages->setFontItalic( true );
messages->setTextColor( "darkBlue" ); messages->setTextColor( "darkBlue" );
messages->insertPlainText( qfu( item->psz_module ) ); messages->insertPlainText( msg->module );
switch (item->i_type) switch (msg->priority)
{ {
case VLC_MSG_INFO: case VLC_MSG_INFO:
messages->setTextColor( "blue" ); messages->setTextColor( "blue" );
...@@ -206,7 +214,7 @@ void MessagesDialog::sinkMessage( msg_item_t *item ) ...@@ -206,7 +214,7 @@ void MessagesDialog::sinkMessage( msg_item_t *item )
/* Add message Regular black Font */ /* Add message Regular black Font */
messages->setFontItalic( false ); messages->setFontItalic( false );
messages->setTextColor( "black" ); messages->setTextColor( "black" );
messages->insertPlainText( qfu(item->psz_msg) ); messages->insertPlainText( msg->text );
messages->insertPlainText( "\n" ); messages->insertPlainText( "\n" );
if ( b_autoscroll ) messages->ensureCursorVisible(); if ( b_autoscroll ) messages->ensureCursorVisible();
} }
...@@ -216,7 +224,7 @@ void MessagesDialog::customEvent( QEvent *event ) ...@@ -216,7 +224,7 @@ void MessagesDialog::customEvent( QEvent *event )
MsgEvent *msge = static_cast<MsgEvent *>(event); MsgEvent *msge = static_cast<MsgEvent *>(event);
assert( msge ); assert( msge );
sinkMessage( msge->msg ); sinkMessage( msge );
} }
void MessagesDialog::clear() void MessagesDialog::clear()
......
...@@ -37,6 +37,7 @@ class QTextEdit; ...@@ -37,6 +37,7 @@ class QTextEdit;
class QTreeWidget; class QTreeWidget;
class QTreeWidgetItem; class QTreeWidgetItem;
class QLineEdit; class QLineEdit;
class MsgEvent;
class MessagesDialog : public QVLCFrame, public Singleton<MessagesDialog> class MessagesDialog : public QVLCFrame, public Singleton<MessagesDialog>
{ {
...@@ -50,7 +51,7 @@ private: ...@@ -50,7 +51,7 @@ private:
msg_cb_data_t *cbData; msg_cb_data_t *cbData;
static void sinkMessage( msg_cb_data_t *, msg_item_t *, unsigned ); static void sinkMessage( msg_cb_data_t *, msg_item_t *, unsigned );
void customEvent( QEvent * ); void customEvent( QEvent * );
void sinkMessage( msg_item_t *item ); void sinkMessage( MsgEvent * );
private slots: private slots:
bool save(); bool save();
......
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