]> git.sesse.net Git - vlc/blob - modules/gui/kde/messages.cpp
38894efd245dd95796fabefcb901e175c94b28d6
[vlc] / modules / gui / kde / messages.cpp
1 /*****************************************************************************
2  * messages.cpp: the KMessagesWindow class
3  *****************************************************************************
4  * Copyright (C) 2001-2003 VideoLAN
5  * $Id: messages.cpp,v 1.5 2003/12/22 14:23:14 sam Exp $
6  *
7  * Author: Sigmund Augdal <sigmunau@idi.ntnu.no>
8  *
9  * This program is free software; you can redistribute it and/or modify
10  * it under the terms of the GNU General Public License as published by
11  * the Free Software Foundation; either version 2 of the License, or
12  * (at your option) any later version.
13  *
14  * This program is distributed in the hope that it will be useful,
15  * but WITHOUT ANY WARRANTY; without even the implied warranty of
16  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
17  * GNU General Public License for more details.
18  *
19  * You should have received a copy of the GNU General Public License
20  * along with this program; if not, write to the Free Software
21  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111, USA.
22  *****************************************************************************/
23
24 #include "messages.h"
25 #include <qtextview.h>
26 #include <qlayout.h>
27 #include <qlabel.h>
28 #include <qvbox.h>
29
30 KMessagesWindow::KMessagesWindow( intf_thread_t * p_intf,  msg_subscription_t *p_msg ) :
31     KDialogBase( Plain, _( "Messages" ), Ok, Ok, 0, 0, false)
32 {
33 //    clearWFlags(~0);
34 //    setWFlags(WType_TopLevel);
35     setSizeGripEnabled(true);
36     this->p_intf = p_intf;
37     this->p_msg = p_msg;
38     QFrame *page = plainPage();
39     QVBoxLayout *toplayout = new QVBoxLayout( page);
40 //    QScrollView *sv = new QScrollView(page);
41 //    sv->setResizePolicy(QScrollView::AutoOneFit);
42 //    sv->setFrameStyle(QScrollView::NoFrame);
43 //    toplayout->addWidget(sv);
44 //    QVBox *category_table = new QVBox(sv->viewport());
45 //    sv->addChild(category_table);
46 //    toplayout->addStretch(10);
47     QVBox *category_table = new QVBox(page);
48     toplayout->addWidget(category_table);
49     toplayout->setResizeMode(QLayout::FreeResize);
50     category_table->setSpacing(spacingHint());
51     resize(300,400);
52     new QLabel( _("Messages:"), category_table );
53     text = new QTextView( category_table );
54     text->setPaper( QBrush( black ) );
55 //    clearWFlags(WStyle_DialogBorder|WStyle_NoBorder);
56 //    setWFlags(WStyle_NormalBorder|WStyle_Customize);
57 //    connect(this, SIGNAL(okClicked()), this, SLOT(accept()));
58 }
59
60 KMessagesWindow::~KMessagesWindow()
61 {
62     ;
63 }
64
65 void KMessagesWindow::update()
66 {
67     int i_stop, i_start;
68     /* Update the log window */
69     vlc_mutex_lock( p_msg->p_lock );
70     i_stop = *p_msg->pi_stop;
71     vlc_mutex_unlock( p_msg->p_lock );
72
73     if( p_msg->i_start != i_stop )
74     {
75         static const char * ppsz_type[4] = { ": ", " error: ", " warning: ",
76                                              " debug: " };
77         static const char * ppsz_color[4] = {
78             "<font color=white>",
79             "<font color=red>",
80             "<font color=yellow>",
81             "<font color=gray>"
82         };
83         for( i_start = p_msg->i_start;
84              i_start != i_stop;
85              i_start = (i_start+1) % VLC_MSG_QSIZE )
86         {
87             text->append( QString("<font color=white>") +
88                           p_msg->p_msg[i_start].psz_module +
89                           ppsz_type[p_msg->p_msg[i_start].i_type] +
90                           "</font>" +
91                           ppsz_color[p_msg->p_msg[i_start].i_type] +
92                           p_msg->p_msg[i_start].psz_msg + "</font>" );
93         }
94
95         vlc_mutex_lock( p_msg->p_lock );
96         p_msg->i_start = i_start;
97         vlc_mutex_unlock( p_msg->p_lock );
98
99     }
100 }