]> git.sesse.net Git - vlc/blob - modules/gui/kde/messages.cpp
messages.cpp: use append(...) and not setText( text() + ...), seems to
[vlc] / 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 GdkColor white  = { 0, 0xffff, 0xffff, 0xffff };
52 //         static GdkColor gray   = { 0, 0xaaaa, 0xaaaa, 0xaaaa };
53 //         static GdkColor yellow = { 0, 0xffff, 0xffff, 0x6666 };
54 //         static GdkColor red    = { 0, 0xffff, 0x6666, 0x6666 };
55         
56         static const char * ppsz_type[4] = { ": ", " error: ", " warning: ",
57                                              " debug: " };
58 //        static GdkColor *   pp_color[4] = { &white, &red, &yellow, &gray };
59
60         for( i_start = p_msg->i_start;
61              i_start != i_stop;
62              i_start = (i_start+1) % VLC_MSG_QSIZE )
63         {
64             text->append( QString(p_msg->p_msg[i_start].psz_module) +
65                           ppsz_type[p_msg->p_msg[i_start].i_type] +
66                           p_msg->p_msg[i_start].psz_msg + "<br>");
67             
68 //             /* Append all messages to log window */
69 //             gtk_text_insert( p_intf->p_sys->p_messages_text, NULL, &gray,
70 //              NULL, p_msg->p_msg[i_start].psz_module, -1 );
71
72 //             gtk_text_insert( p_intf->p_sys->p_messages_text, NULL, &gray,
73 //                 NULL, ppsz_type[p_msg->p_msg[i_start].i_type],
74 //                 -1 );
75
76 //             gtk_text_insert( p_intf->p_sys->p_messages_text, NULL,
77 //                 pp_color[p_msg->p_msg[i_start].i_type], NULL,
78 //                 p_msg->p_msg[i_start].psz_msg, -1 );
79
80 //             gtk_text_insert( p_intf->p_sys->p_messages_text, NULL, &gray,
81 //                 NULL, "\n", -1 );
82         }
83
84         vlc_mutex_lock( p_msg->p_lock );
85         p_msg->i_start = i_start;
86         vlc_mutex_unlock( p_msg->p_lock );
87 //        gtk_text_set_point( p_intf->p_sys->p_messages_text,
88 //                    gtk_text_get_length( p_intf->p_sys->p_messages_text ) );
89
90     }
91 }