[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-devel
Subject:    kppp miniterm patch & questions
From:       Juerg Marti <tschortsch () gmx ! ch>
Date:       2001-07-29 10:55:15
[Download RAW message or body]

Hi

The layout managment of kppp's miniterm is broken. I replaced the setGeomtry 
stuff in miniterm.cpp with a QVBoxLayout and the QMenuBar with a KMenuBar. 
The patch for this is attached.

But I have still some questions:
1) There is a problem with the dialogs in the helpmenu of miniterm. When I 
open one of them (i.e. Help->About KPPP) I'm not able to close it. Maybe this 
is because MiniTerm is a modal Dialog. Any ideas?

2) I don't understand why a QLabel is used for the statusbar.

3) Why is there a second QLabel statusbar2, which is never used? 

4) I think It's strange to put a MenuBar, a ToolBar and a StatusBar in a 
Dialog. Maybe MiniTerm should inherit KMainWindow and not QDialog or we 
should remove the StatusBar and the MenuBar.

5) Is it really necessary to delete toolbar and statusbar in the destructor? 
They are children of MiniTerm, so they should be deleted by qt.


Juerg

["miniterm.patch" (text/x-diff)]

? miniterm.patch
Index: miniterm.cpp
===================================================================
RCS file: /home/kde/kdenetwork/kppp/miniterm.cpp,v
retrieving revision 1.34
diff -u -3 -p -u -r1.34 miniterm.cpp
--- miniterm.cpp	2000/09/15 19:56:10	1.34
+++ miniterm.cpp	2001/07/29 10:08:19
@@ -2,8 +2,8 @@
  *            kPPP: A front end for pppd for the KDE project
  *
  * $Id: miniterm.cpp,v 1.34 2000/09/15 19:56:10 faure Exp $
- * 
- * Copyright (C) 1997 Bernd Johannes Wuebben 
+ *
+ * Copyright (C) 1997 Bernd Johannes Wuebben
  *                    wuebben@math.cornell.edu
  *
  *
@@ -38,64 +38,61 @@
 #include <kglobal.h>
 #include <kpopupmenu.h>
 
-#define T_WIDTH 550
-#define T_HEIGHT 400
-
 extern PPPData gpppdata;
 
 MiniTerm::MiniTerm(QWidget *parent, const char *name)
-  : QDialog(parent, name, TRUE)
+  : QDialog(parent, name,true)
 {
   setCaption(i18n("Kppp Mini-Terminal"));
   KWin::setIcons(winId(), kapp->icon(), kapp->miniIcon());
 
-  m_file = new QPopupMenu;
+  m_file = new QPopupMenu(this);
   m_file->insertItem( i18n("&Close"),this, SLOT(cancelbutton()) );
-  m_options = new QPopupMenu;
+  m_options = new QPopupMenu(this);
   m_options->insertItem(i18n("&Reset Modem"),this,SLOT(resetModem()));
-  m_help = 
-    new KHelpMenu(this, 
+  m_help =
+    new KHelpMenu(this,
 		      i18n("MiniTerm - A terminal emulation for KPPP\n\n"
 			   "(c) 1997 Bernd Johannes Wuebben <wuebben@kde.org>\n"
 			   "(c) 1998 Harri Porten <porten@kde.org>\n"
-			   "(c) 1998 Mario Weilguni <mweilguni@kde.org>\n\n" 
+			   "(c) 1998 Mario Weilguni <mweilguni@kde.org>\n\n"
 			   "This program is published under the GNU GPL\n"
 			   "(GNU General Public License)"
 			   ));
-  
-  menubar = new QMenuBar( this );
+
+  menubar = new KMenuBar( this );
   menubar->insertItem( i18n("&File"), m_file );
   menubar->insertItem( i18n("&Modem"), m_options );
   menubar->insertItem( i18n("&Help"), m_help->menu());
-  
+
   statusbar = new QLabel(this);
   statusbar->setFrameStyle(QFrame::Panel | QFrame::Sunken);
 
-  statusbar2 = new QLabel(this);
-  statusbar2->setFrameStyle(QFrame::Panel | QFrame::Sunken);
+  //statusbar2 = new QLabel(this);
+  //statusbar2->setFrameStyle(QFrame::Panel | QFrame::Sunken);
 
   terminal = new MyTerm(this,"term");
 
   setupToolbar();
 
-  statusbar->setGeometry(0, T_HEIGHT - 20, T_WIDTH - 70, 20);
-  statusbar2->setGeometry(T_WIDTH - 70, T_HEIGHT - 20, 70, 20);
+  QVBoxLayout *layout=new QVBoxLayout(this);
+  layout->addWidget(menubar);
+  layout->addWidget(toolbar);
+  layout->addWidget(terminal);
+  layout->addWidget(statusbar);
 
-  menubar->setGeometry(0,0,T_WIDTH,30);
-
-  terminal->setGeometry(0, menubar->height() + toolbar->height() , 
-   T_WIDTH,  T_HEIGHT - menubar->height() - toolbar->height() - statusbar->height());
- 
   inittimer = new QTimer(this);
   connect(inittimer,SIGNAL(timeout()),this,SLOT(init()));
   inittimer->start(500);
-}  
+
+  resize(550,400);
+}
 
 
 MiniTerm::~MiniTerm() {
   delete toolbar;
   delete statusbar;
-  delete statusbar2;
+  //delete statusbar2;
 }
 
 
@@ -125,17 +122,6 @@ void MiniTerm::setupToolbar() {
 }
 
 
-void MiniTerm::resizeEvent(QResizeEvent*) {
-  menubar->setGeometry(0,0,width(),30);
-  toolbar->setGeometry(0,menubar->height(),width(),toolbar->height());
-  terminal->setGeometry(0, menubar->height() + toolbar->height() , 
-			width(),  height() - menubar->height() 
-			- toolbar->height() - statusbar->height());
-  statusbar->setGeometry(0, height() - 20, width() - 70, 20);
-  statusbar2->setGeometry(width() - 70, height() - 20, 70, 20);
-}
-
-
 void MiniTerm::init() {
   inittimer->stop();
   statusbar->setText(i18n("Initializing Modem"));
@@ -163,10 +149,10 @@ void MiniTerm::init() {
     }
     Modem::modem->writeLine(gpppdata.modemInitStr().local8Bit());
     usleep(gpppdata.modemInitDelay() * 10000);
-      
+
       statusbar->setText(i18n("Modem Ready"));
       terminal->setFocus();
-      
+
       kapp->processEvents();
       kapp->processEvents();
 
@@ -174,11 +160,11 @@ void MiniTerm::init() {
       return;
     }
   }
-  
-  // opentty() or hangup() failed 
+
+  // opentty() or hangup() failed
   statusbar->setText(Modem::modem->modemMessage());
   Modem::modem->unlockdevice();
-}                  
+}
 
 
 void MiniTerm::readChar(unsigned char c) {
@@ -202,7 +188,7 @@ void MiniTerm::readChar(unsigned char c)
 }
 
 
-void MiniTerm::cancelbutton() {  
+void MiniTerm::cancelbutton() {
   Modem::modem->stop();
 
   statusbar->setText(i18n("Hanging up ..."));
@@ -244,7 +230,7 @@ void MiniTerm::help() {
 MyTerm::MyTerm(QWidget *parent, const char* name)
   : QMultiLineEdit(parent, name)
 {
-   this->setFont(QFont("courier",12,QFont::Normal));  
+   this->setFont(QFont("courier",12,QFont::Normal));
 }
 
 void MyTerm::keyPressEvent(QKeyEvent *k) {
@@ -259,12 +245,12 @@ void MyTerm::keyPressEvent(QKeyEvent *k)
 }
 
 
-void MyTerm::insertChar(unsigned char c) {  
+void MyTerm::insertChar(unsigned char c) {
   QMultiLineEdit::insert(QChar(c));
 }
 
 
-void MyTerm::newLine() {  
+void MyTerm::newLine() {
   QMultiLineEdit::newLine();
 }
 
@@ -282,7 +268,7 @@ void MyTerm::backspace() {
 void MyTerm::myreturn() {
   int column;
   int line;
-  
+
   getCursorPosition(&line,&column);
   for (int i = 0; i < column;i++)
     QMultiLineEdit::cursorLeft();
Index: miniterm.h
===================================================================
RCS file: /home/kde/kdenetwork/kppp/miniterm.h,v
retrieving revision 1.12
diff -u -3 -p -u -r1.12 miniterm.h
--- miniterm.h	2001/03/08 16:03:00	1.12
+++ miniterm.h	2001/07/29 10:08:19
@@ -3,8 +3,8 @@
  *            kPPP: A front end for pppd for the KDE project
  *
  * $Id: miniterm.h,v 1.12 2001/03/08 16:03:00 mueller Exp $
- * 
- * Copyright (C) 1997 Bernd Johannes Wuebben 
+ *
+ * Copyright (C) 1997 Bernd Johannes Wuebben
  * wuebben@math.cornell.edu
  *
  *
@@ -28,21 +28,21 @@
 #ifndef _MINITERM_H_
 #define _MINITERM_H_
 
-#include <qpixmap.h>
-#include <qmenubar.h> 
-#include <qpopupmenu.h> 
 #include <qdialog.h>
+#include <qpixmap.h>
+#include <qlayout.h>
+#include <qpopupmenu.h>
 #include <qlabel.h>
 #include <qevent.h>
 #include <qtimer.h>
 #include <qframe.h>
-#include <qmultilineedit.h> 
-#include <qtooltip.h> 
+#include <qmultilineedit.h>
+#include <qtooltip.h>
 
 #include <ktoolbar.h>
+#include <kmenubar.h>
 class KHelpMenu;
 
-
 class MyTerm : public QMultiLineEdit {
   Q_OBJECT
 public:
@@ -66,7 +66,6 @@ public:
   ~MiniTerm();
 
   void closeEvent( QCloseEvent *e );
-  void resizeEvent(QResizeEvent *e);
 
 public slots:
   void cancelbutton();
@@ -89,7 +88,7 @@ protected:
   QPopupMenu  * m_options;
   KHelpMenu  * m_help;
   QLabel      * statusbar;
-  QLabel      * statusbar2;
+  //QLabel      * statusbar2;
   QPushButton *pb1;
   QPushButton *pb2;
   QPushButton *pb3;

>> Visit http://master.kde.org/mailman/listinfo/kde-devel#unsub to unsubscribe <<


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic