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

List:       kde-devel
Subject:    KControl layout fixed -- please check!
From:       Matthias Hoelzer <hoelzer () physik ! uni-wuerzburg ! de>
Date:       1998-12-23 10:10:10
[Download RAW message or body]

Hi,

I have attached a patch that fixed most of the layout problems in
kcontrol reported here on the list lately, as well as one problem known
for quite some time:

- floating or mac like menubars work now 
- kcontrol resizes if swallowed modules are too large
- better resizing if the slider is moved

Because of the freeze, I will only commit it if someone has checked it
before, so please apply the patch and tell me if it is OK.

Another paint: someone asked why I did not use the picture from
kdehelp's intro screen. The reason: it does not adhere to the standard
palette. Feel free to put a better picture into kcontrol, but it should
not use more than the 40 standard colours.


Bye,
Matthias.


=======================================================================
Matthias H"olzer-Kl"upfel             | 
Universit"at W"urzburg                | hoelzer@physik.uni-wuerzburg.de
KDE-Projekt (http://www.kde.org)      |                 hoelzer@kde.org
\-------------------------------------^-------------------------------/

["kcontrol.patch" (TEXT/PLAIN)]

Index: configlist.cpp
===================================================================
RCS file: /home/kde/kdebase/kcontrol/kcontrol/configlist.cpp,v
retrieving revision 1.10
diff -u -r1.10 configlist.cpp
--- configlist.cpp	1998/12/16 00:18:22	1.10
+++ configlist.cpp	1998/12/23 10:00:31
@@ -234,7 +234,16 @@
 	if (visibleWidget && visibleWidget != swallowWidget) 
 	  visibleWidget->hide();
 
-	swallowWidget->resize(swallowParent->width(), swallowParent->height());
+        // let the toplevel widget resize if necessary
+        connect(this, SIGNAL(ensureSize(int,int)), 
+          qApp->mainWidget(), SLOT(ensureSize(int,int)));
+        emit ensureSize(swallowWidget->getOrigSize().width(),
+          swallowWidget->getOrigSize().height());
+        disconnect(this, SIGNAL(ensureSize(int,int)), 
+          qApp->mainWidget(), SLOT(ensureSize(int,int)));
+
+        swallowWidget->resize(swallowParent->width(), swallowParent->height());
+
 	swallowWidget->raise();
 	swallowWidget->show();
 
@@ -284,8 +293,14 @@
       swallowWidget->swallowWindow(w);
       swallowWidget->setFocus(); //workaround (ettrich)
 
+      // let the toplevel widget resize if necessary
+      connect(this, SIGNAL(ensureSize(int,int)), 
+        qApp->mainWidget(), SLOT(ensureSize(int,int)));
+      emit ensureSize(swallowWidget->width(), swallowWidget->height());
+      disconnect(this, SIGNAL(ensureSize(int,int)), 
+        qApp->mainWidget(), SLOT(ensureSize(int,int)));
+     
       swallowWidget->resize(swallowParent->size());
-
       // disconnect from KWM events
       disconnect(kapp, SIGNAL(windowAdd(Window)), this, SLOT(addWindow(Window)));
     }
Index: configlist.h
===================================================================
RCS file: /home/kde/kdebase/kcontrol/kcontrol/configlist.h,v
retrieving revision 1.1.1.1
diff -u -r1.1.1.1 configlist.h
--- configlist.h	1997/12/20 08:34:40	1.1.1.1
+++ configlist.h	1998/12/23 10:00:31
@@ -94,7 +94,11 @@
   void processExit(KProcess *proc);
 
   void addWindow(Window w);
- 
+
+signals:
+
+  void ensureSize(int w, int h);
+   
 };
 
 
Index: kswallow.cpp
===================================================================
RCS file: /home/kde/kdebase/kcontrol/kcontrol/kswallow.cpp,v
retrieving revision 1.3
diff -u -r1.3 kswallow.cpp
--- kswallow.cpp	1998/05/24 12:14:41	1.3
+++ kswallow.cpp	1998/12/23 10:00:31
@@ -32,7 +32,7 @@
 {
   window = 0;
   setFocusPolicy(StrongFocus);
-  resize(480,480);
+  setMinimumSize(480,480);
 }
 
 
@@ -65,7 +65,22 @@
 
   XReparentWindow(qt_xdisplay(), w, winId(), 0, 0);
   XMapRaised(qt_xdisplay(), w);
-  XResizeWindow(qt_xdisplay(), window, parentWidget()->width(), parentWidget()->height());
+ 
+  // let the swallowd window set the size
+  int x, y;
+  unsigned int width, height, dummy;
+  Window root;
+
+  XGetGeometry(qt_xdisplay(), window, &root, &x, &y, &width, &height, &dummy, &dummy);
+  if (width < parentWidget()->width())
+    width = parentWidget()->width();
+  if (height < parentWidget()->height())
+    height = parentWidget()->height();
+  parentWidget()->resize(width,height);
+  resize(width,height);
+  XResizeWindow(qt_xdisplay(), window, width, height);
 
+  orig = QSize(width,height);
+ 
   show();
 }
Index: kswallow.h
===================================================================
RCS file: /home/kde/kdebase/kcontrol/kcontrol/kswallow.h,v
retrieving revision 1.2
diff -u -r1.2 kswallow.h
--- kswallow.h	1998/05/24 12:14:42	1.2
+++ kswallow.h	1998/12/23 10:00:31
@@ -39,14 +39,18 @@
 
   void swallowWindow(Window w);
 
+  QSize getOrigSize() { return orig; };
+  
 protected: 
+
   void focusInEvent( QFocusEvent * );
   void resizeEvent(QResizeEvent *);
 
 private:
 
   Window  window;
-
+  QSize orig;
+  
 };
 
 #endif
Index: mainwidget.cpp
===================================================================
RCS file: /home/kde/kdebase/kcontrol/kcontrol/mainwidget.cpp,v
retrieving revision 1.6
diff -u -r1.6 mainwidget.cpp
--- mainwidget.cpp	1998/12/16 03:44:20	1.6
+++ mainwidget.cpp	1998/12/23 10:00:31
@@ -91,3 +91,11 @@
   p.end();
 
 }
+
+
+void mainWidget::resizeEvent(QResizeEvent *event)
+{
+  QWidget::resizeEvent(event);
+
+  emit resized();
+}
Index: mainwidget.h
===================================================================
RCS file: /home/kde/kdebase/kcontrol/kcontrol/mainwidget.h,v
retrieving revision 1.1.1.1
diff -u -r1.1.1.1 mainwidget.h
--- mainwidget.h	1997/12/20 08:34:41	1.1.1.1
+++ mainwidget.h	1998/12/23 10:00:31
@@ -31,9 +31,15 @@
   QPixmap pmap;  
   struct utsname info;  
   
-  protected:   
+protected:   
+
   virtual void paintEvent(QPaintEvent *);	  
-  
+  virtual void resizeEvent(QResizeEvent *);
+    
+signals:
+    
+  void resized();
+    
 };
 
 
Index: toplevel.cpp
===================================================================
RCS file: /home/kde/kdebase/kcontrol/kcontrol/toplevel.cpp,v
retrieving revision 1.9
diff -u -r1.9 toplevel.cpp
--- toplevel.cpp	1998/12/16 03:43:35	1.9
+++ toplevel.cpp	1998/12/23 10:00:31
@@ -29,6 +29,14 @@
 #include "toplevel.moc"
 
 
+void MySplitter::resizeEvent(QResizeEvent *event)
+{
+  QSplitter::resizeEvent(event);
+
+  emit resized();
+}
+
+
 TopLevel::TopLevel (ConfigList *cl)
   : KTopLevelWidget(), ID_GENERAL(1)
 {
@@ -38,24 +46,25 @@
   setupMenuBar();
   setupStatusBar();
 
-  panner = new KPanner(this, "panner", KPanner::U_ABSOLUTE | KPanner::O_VERTICAL, 200);
-  panner->resize(400,100);
-  panner->setAbsSeparator(200);
+  splitter = new MySplitter(this);
+  connect(splitter, SIGNAL(resized()), this, SLOT(doResize()));
 
-  treelist = new KTreeList(panner->child0());
+  treelist = new KTreeList(splitter);
   configList->fillTreeList(treelist);
+  treelist->setMinimumWidth(200);
+  splitter->setResizeMode(treelist,QSplitter::KeepSize);
 
-  mwidget = new mainWidget(panner->child1());
+  mwidget = new mainWidget(splitter);
+  connect(mwidget, SIGNAL(resized()), this, SLOT(doResize()));
 
   connect(treelist, SIGNAL(selected(int)), this, SLOT(item_selected(int)));
   connect(treelist, SIGNAL(singleSelected(int)), this, SLOT(item_singleSelected(int)));
-  connect(panner, SIGNAL(positionChanged()), this, SLOT(pannerChanged()));
-
-  setView(panner);
 
+  setView(splitter);
   setMinimumSize(450,200);
 
   resize(700,600);
+
   show();
   resizeEvent(NULL);
 
@@ -104,29 +113,18 @@
 }
 
 
-void TopLevel::pannerChanged()
-{
-  treelist->resize(panner->child0()->width(), panner->child0()->height());
-
-  if (mwidget)
-    mwidget->resize(width()-panner->getAbsSeparator(), height());
-
-  if (KModuleListEntry::visibleWidget)
-    KModuleListEntry::visibleWidget->resize(panner->child1()->width(), panner->child1()->height());
-}
-
-
 void TopLevel::resizeEvent(QResizeEvent *)
 {
   updateRects();
 
-  treelist->resize(panner->child0()->width(), panner->child0()->height());
+  doResize();
+}
 
-  if (mwidget)
-    mwidget->resize(width()-panner->getAbsSeparator(), height());
 
+void TopLevel::doResize()
+{
   if (KModuleListEntry::visibleWidget)
-    KModuleListEntry::visibleWidget->resize(panner->child1()->width(), panner->child1()->height());
+    KModuleListEntry::visibleWidget->resize(mwidget->width(), mwidget->height());
 }
 
 
@@ -138,7 +136,7 @@
     if (listEntry->isDirectory())
       treelist->expandOrCollapseItem(item);
     else
-      listEntry->execute(panner->child1());
+      listEntry->execute(mwidget);
 }
 
 
@@ -153,7 +151,7 @@
   statusbar->changeItem(hint.data(), ID_GENERAL);
 
   if (listEntry && !listEntry->isDirectory())
-    listEntry->execute(panner->child1());
+    listEntry->execute(mwidget);
 }
 
 
@@ -183,3 +181,23 @@
   config->sync();
 }
 
+
+void TopLevel::ensureSize(int w, int h)
+{
+  int width=w, height=h;
+
+  if (w < mwidget->width())
+    width = mwidget->width();
+  if (h < mwidget->height())
+    height = mwidget->height();
+
+  width += treelist->width() + 6; // 6 ~= width of QSplitter slider
+  height += menubar->height()+statusbar->height();
+
+  if (width < this->width())
+    width = this->width();
+  if (height < this->height())
+    height = this->height();
+
+  resize(width, height);
+}
Index: toplevel.h
===================================================================
RCS file: /home/kde/kdebase/kcontrol/kcontrol/toplevel.h,v
retrieving revision 1.3
diff -u -r1.3 toplevel.h
--- toplevel.h	1998/05/24 12:14:44	1.3
+++ toplevel.h	1998/12/23 10:00:32
@@ -30,12 +30,31 @@
 #include <ktoolbar.h>
 #include <ktreelist.h>
 #include <kstatusbar.h>
-#include <kpanner.h>
+#include <qsplitter.h>
 
 #include "mainwidget.h"
 #include "configlist.h"
 
 
+class MySplitter : public QSplitter
+{
+  Q_OBJECT
+  
+public:
+
+  MySplitter(QWidget *parent) : QSplitter(parent) {};
+  
+protected:
+
+  void resizeEvent(QResizeEvent *event);
+  
+signals:
+
+  void resized();
+  
+};
+
+
 class TopLevel : public KTopLevelWidget
 {
   Q_OBJECT
@@ -44,6 +63,9 @@
 
   TopLevel(ConfigList *cl);
 
+  
+private:
+
   QPopupMenu *file, *helpMenu, *options;
   int        helpModuleID, helpID, swallowID;
 
@@ -60,7 +82,7 @@
   KToolBar   *toolbar;
   KTreeList  *treelist;
   KStatusBar *statusbar;
-  KPanner    *panner;
+  MySplitter *splitter;
   ConfigList *configList;
   mainWidget *mwidget;
 
@@ -72,13 +94,19 @@
 
   void updateMenu();
 
+private slots:
+
+  void doResize();
+  
 public slots:
 
-  void pannerChanged();
   void swallowChanged();
     
   void item_selected(int item);
   void item_singleSelected(int item);
+  
+  void ensureSize(int w, int h);
+  
 };
 
 #endif


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

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