2 * kPPP: A pppd Front End for the KDE project
6 * Copyright (C) 1997-98 Bernd Johannes Wuebben
7 * wuebben@math.cornell.edu
9 * This file was contributed by Harri Porten <porten@tu-harburg.de>
12 * This program is free software; you can redistribute it and/or
13 * modify it under the terms of the GNU Library General Public
14 * License as published by the Free Software Foundation; either
15 * version 2 of the License, or (at your option) any later version.
17 * This program is distributed in the hope that it will be useful,
18 * but WITHOUT ANY WARRANTY; without even the implied warranty of
19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
20 * Library General Public License for more details.
22 * You should have received a copy of the GNU Library General Public
23 * License along with this program; if not, write to the Free
24 * Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
27 #include <KStandardGuiItem>
30 #include "loginterm.h"
37 #include <QVBoxLayout>
38 #include <QGridLayout>
40 #include <QTextCursor>
41 extern KPPPWidget
*p_kppp
;
43 LoginMultiLineEdit::LoginMultiLineEdit(QWidget
*parent
)
49 LoginMultiLineEdit::~LoginMultiLineEdit() {
54 void LoginMultiLineEdit::insertChar(unsigned char c
) {
55 insertPlainText(QString(c
));
56 p_kppp
->debugwindow
->addChar(c
);
60 void LoginMultiLineEdit::myreturn() {
61 textCursor().movePosition( QTextCursor::Start
);
65 void LoginMultiLineEdit::mynewline() {
66 textCursor().movePosition( QTextCursor::End
);
67 insertPlainText(QString("\n"));
70 Q3MultiLineEdit::end(false);
71 Q3MultiLineEdit::newLine();
73 p_kppp
->debugwindow
->addChar('\n');
77 void LoginMultiLineEdit::keyPressEvent(QKeyEvent
*k
) {
78 if (k
->key() == 0 || k
->key() == Qt::Key_unknown
) return;
80 if(k
->key() == Qt::Key_Enter
|| k
->key() == Qt::Key_Return
)
81 Modem::modem
->writeLine("");
83 QByteArray ascii
= k
->text().toAscii();
85 Modem::modem
->writeChar(ascii
[0]);
90 void LoginMultiLineEdit::readChar(unsigned char c
) {
92 if(((int)c
!= 13) && ((int)c
!= 10) && ((int)c
!= 8))
95 if((int)c
== 8 || ( int )c
== 127)
96 textCursor().deleteChar ();
104 LoginTerm::LoginTerm (QWidget
*parent
, const char *name
)
109 setWindowTitle(i18n("Login Terminal Window"));
110 setMinimumSize(300, 200);
111 setMaximumSize(600, 400);
114 QVBoxLayout
*tl
= new QVBoxLayout(this);
116 QGridLayout
*vgr
= new QGridLayout();
117 QGridLayout
*hgr
= new QGridLayout();
118 hgr
->setMargin( 30 );
121 vgr
->addLayout(hgr
, 1, 0);
122 vgr
->setRowStretch(0, 1);
123 vgr
->addItem(new QSpacerItem(0, 40), 1, 0);
125 text_window
= new LoginMultiLineEdit(this);
126 text_window
->setObjectName("term");
127 text_window
->setFocus();
128 vgr
->addWidget(text_window
, 0, 0);
130 cancel_b
= new KPushButton(KStandardGuiItem::cancel(), this);
131 cancel_b
->setFixedHeight(25);
132 connect(cancel_b
, SIGNAL(clicked()), SLOT(cancelbutton()));
134 continue_b
= new KPushButton(KStandardGuiItem::cont(), this);
135 continue_b
->setFixedHeight(25);
136 connect(continue_b
, SIGNAL(clicked()), SLOT(continuebutton()));
139 if (cancel_b
->sizeHint().width() > continue_b
->sizeHint().width())
140 mwidth
= cancel_b
->sizeHint().width();
142 mwidth
= continue_b
->sizeHint().width();
144 cancel_b
->setFixedWidth(mwidth
+ 20);
145 continue_b
->setFixedWidth(mwidth
+ 20);
147 hgr
->addWidget(cancel_b
, 0, 0, Qt::AlignCenter
);
148 hgr
->addWidget(continue_b
, 0, 1, Qt::AlignCenter
);
152 Modem::modem
->notify(text_window
, SLOT(readChar(unsigned char)));
156 void LoginTerm::cancelbutton () {
161 void LoginTerm::continuebutton() {
167 bool LoginTerm::pressedContinue() {
172 #include "loginterm.moc"