1/*
2 * kPPP: A pppd front end for the KDE project
3 *
4 * $Id$
5 * Copyright (C) 1997 Bernd Wuebben
6 * wuebben@math.cornel.edu
7 *
8 * This program is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU Library General Public
10 * License as published by the Free Software Foundation; either
11 * version 2 of the License, or (at your option) any later version.
12 *
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 * Library General Public License for more details.
17 *
18 * You should have received a copy of the GNU Library General Public
19 * License along with this program; if not, write to the Free
20 * Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
21 */
22
23#include "debug.h"
24#include "main.h"
25#include "pppdata.h"
26#include <klocale.h>
27
28#include <assert.h>
29//Added by qt3to4:
30#include <QHideEvent>
31#include <QLabel>
32#include <QFrame>
33#include <QResizeEvent>
34
35extern KPPPWidget *p_kppp;
36
37myMultiEdit::myMultiEdit(QWidget *parent, const char *name)
38 : Q3MultiLineEdit(parent, name)
39{
40 setReadOnly(true);
41}
42
43void myMultiEdit::newLine() {
44 Q3MultiLineEdit::newLine();
45}
46
47
48DebugWidget::DebugWidget(QWidget *parent)
49 : QDialog(parent)
50{
51 setModal( false );
52 setWindowTitle(i18n("Login Script Debug Window"));
53
54 text_window = new myMultiEdit(this,"debugwindow");
55 text_window->setGeometry(2,5,400, 300);
56 // text_window->setReadOnly(FALSE);
57
58 statuslabel = new QLabel(QString(), this );
59 statuslabel->setObjectName("statuslabel");
60
61 statuslabel->setFrameStyle( QFrame::Panel | QFrame::Sunken );
62 statuslabel->setAlignment( Qt::AlignLeft|Qt::AlignVCenter );
63 statuslabel->setGeometry(2, 307, 400, 20);
64 //statusPageLabel->setFont( KGlobalSettings::generalFont() );
65
66 dismiss = new QPushButton(this);
67 dismiss->setGeometry(330,340,70,30);
68 dismiss->setText(i18n("&Close"));
69 dismiss->setFocus();
70 connect(dismiss, SIGNAL(clicked()), SLOT(hide()));
71
72
73 /* fline = new QFrame(this,"line");
74 fline->setFrameStyle(QFrame::HLine |QFrame::Sunken);
75 fline->setGeometry(2,332,398,5);*/
76 adjustSize();
77 setMinimumSize(width(),height());
78
79}
80
81void DebugWidget::hideEvent(QHideEvent *)
82{
83 assert(p_kppp);
84 //This causes a crash when launching kppp -c <connection name> BKO176028
85 //p_kppp->con->debug->setChecked(false);
86}
87
88void DebugWidget::clear() {
89 text_window->clear();
90}
91
92
93void DebugWidget::addChar(unsigned char c) {
94 QString stuff;
95
96 if(c == '\r' || c == '\n') {
97 if(c == '\n')
98 text_window->newLine();
99 } else
100 text_window->insert(QString(c));
101}
102
103
104void DebugWidget::statusLabel(const QString &s) {
105 statuslabel->setText(s);
106}
107
108
109/*
110void DebugWidget::keyPressEvent(QKeyEvent *k) {
111}
112
113*/
114void DebugWidget::resizeEvent(QResizeEvent *e){
115 int w = width() ;
116 int h = height();
117 e = e;
118
119 text_window->setGeometry(2,5,w - 2 ,h - 63);
120 statuslabel->setGeometry(2, h - 56 , w -2 , 20);
121 dismiss->setGeometry(w - 72 , h - 32, 70, 30);
122 // fline->setGeometry(2,h -70 ,w - 4,5);
123}
124
125
126void DebugWidget::enter() {
127 text_window->append("\r\n");
128}
129
130
131void DebugWidget::toggleVisibility() {
132 if(isVisible())
133 hide();
134 else
135 show();
136
137 bool showlog = isVisible();
138 gpppdata.set_show_log_window(showlog);
139}
140
141
142#include "debug.moc"
143
144