1 /*****************************************************************************
2 * messages.cpp: the KMessagesWindow class
3 *****************************************************************************
4 * Copyright (C) 2001-2003 VideoLAN (Centrale Réseaux) and its contributors
7 * Author: Sigmund Augdal <sigmunau@idi.ntnu.no>
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.
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.
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 *****************************************************************************/
25 #include <qtextview.h>
30 KMessagesWindow::KMessagesWindow( intf_thread_t * p_intf, msg_subscription_t *p_msg ) :
31 KDialogBase( Plain, _( "Messages" ), Ok, Ok, 0, 0, false)
34 // setWFlags(WType_TopLevel);
35 setSizeGripEnabled(true);
36 this->p_intf = p_intf;
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());
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()));
60 KMessagesWindow::~KMessagesWindow()
65 void KMessagesWindow::update()
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 );
73 if( p_msg->i_start != i_stop )
75 static const char * ppsz_type[4] = { ": ", " error: ", " warning: ",
77 static const char * ppsz_color[4] = {
80 "<font color=yellow>",
83 for( i_start = p_msg->i_start;
85 i_start = (i_start+1) % VLC_MSG_QSIZE )
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] +
91 ppsz_color[p_msg->p_msg[i_start].i_type] +
92 p_msg->p_msg[i_start].psz_msg + "</font>" );
95 vlc_mutex_lock( p_msg->p_lock );
96 p_msg->i_start = i_start;
97 vlc_mutex_unlock( p_msg->p_lock );