added some coloring to the messages window in the kde interface
[vlc.git] / modules / gui / kde / messages.cpp
1 #include "messages.h"
2 #include <qtextview.h>
3 #include <qlayout.h>
4 #include <qlabel.h>
5 #include <qvbox.h>
6
7 KMessagesWindow::KMessagesWindow( intf_thread_t * p_intf,  msg_subscription_t *p_msg ) :
8     KDialogBase( Plain, _( "Messages" ), Ok, Ok, 0, 0, false)
9 {
10 //    clearWFlags(~0);
11 //    setWFlags(WType_TopLevel);
12     setSizeGripEnabled(true);
13     this->p_intf = p_intf;
14     this->p_msg = p_msg;
15     QFrame *page = plainPage();
16     QVBoxLayout *toplayout = new QVBoxLayout( page);
17 //    QScrollView *sv = new QScrollView(page);
18 //    sv->setResizePolicy(QScrollView::AutoOneFit);
19 //    sv->setFrameStyle(QScrollView::NoFrame);
20 //    toplayout->addWidget(sv);
21 //    QVBox *category_table = new QVBox(sv->viewport());
22 //    sv->addChild(category_table);
23 //    toplayout->addStretch(10);
24     QVBox *category_table = new QVBox(page);
25     toplayout->addWidget(category_table);
26     toplayout->setResizeMode(QLayout::FreeResize);
27     category_table->setSpacing(spacingHint());
28     resize(300,400);
29     new QLabel( _("Messages:"), category_table );
30     text = new QTextView( category_table );
31 //    clearWFlags(WStyle_DialogBorder|WStyle_NoBorder);
32 //    setWFlags(WStyle_NormalBorder|WStyle_Customize);
33 //    connect(this, SIGNAL(okClicked()), this, SLOT(accept()));
34 }
35
36 KMessagesWindow::~KMessagesWindow()
37 {
38     ;
39 }
40
41 void KMessagesWindow::update()
42 {
43     int i_stop, i_start;
44     /* Update the log window */
45     vlc_mutex_lock( p_msg->p_lock );
46     i_stop = *p_msg->pi_stop;
47     vlc_mutex_unlock( p_msg->p_lock );
48
49     if( p_msg->i_start != i_stop )
50     {
51         static const char * ppsz_type[4] = { ": ", " error: ", " warning: ",
52                                              " debug: " };
53         static const char * ppsz_color[4] = {
54             "<font color=#FFFFFF>",
55             "<font color=#FF0000>",
56             "<font color=#CCCC00>",
57             "<font>"
58         };
59         for( i_start = p_msg->i_start;
60              i_start != i_stop;
61              i_start = (i_start+1) % VLC_MSG_QSIZE )
62         {
63             text->append( QString(p_msg->p_msg[i_start].psz_module) +
64                           ppsz_type[p_msg->p_msg[i_start].i_type] +
65                           ppsz_color[p_msg->p_msg[i_start].i_type] +
66                           p_msg->p_msg[i_start].psz_msg + "</font>" );
67             
68         }
69
70         vlc_mutex_lock( p_msg->p_lock );
71         p_msg->i_start = i_start;
72         vlc_mutex_unlock( p_msg->p_lock );
73
74     }
75 }