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

List:       koffice
Subject:    Re: Messy toolbar build-up in KOffice (With patch!)
From:       Waldo Bastian <bastian () kde ! org>
Date:       2000-05-17 20:26:30
[Download RAW message or body]

On Tue, 16 May 2000, Waldo Bastian wrote:
> 1) Maybe
>
> Well.. that might contribute to the flicker but that was not what I ment.
>
> What happens if you call toolbar->show() is that first the toolbar is shown
> and _AFTER THAT_ KTMainWindow will update the layout and move the toolbar
> to the correct position.
>
> What you would want is that just before the toolbar is shown, the layout
> gets updated so that when the toolbar actually gets shown, it is already on
> the right position. ("doing it right the first time")
>
> But this is all theory. I have no idea whether showing and then moving is
> indeed inefficient or whether Qt handles this somehow.
>
> I do have a patch which solves this problem somewhat (But I don't know yet
> whether this is a real problem)

Ok.. here is the patch. (Attempt #2)

It contains some fprintfs to show what is going on.

It does the following:
 1) It overrides KToolbar::show(). If KTMainWindow has updates disabled, it
     delayes actually showing the widget.

 2) In KTMainWindow::updateRects() it makes sure to call KToolBar::show(),
    if the toolbar was already shown, this does nothing. However, if showing
    of the toolbar was delayed by 1) it will now make sure that the toolbar
    gets shown.

If makes the following sequence more efficient:

mainwindow->setUpdatesEnabled(false);
..insert loads of toolbars here...
mainwindow->setUpdatesEnabled(true);
mainwindow->updateRects();

Can someone with toolbar experience have a look at this?

Cheers,
Waldo

? toolbar.diff
Index: ktmainwindow.cpp
===================================================================
RCS file: /home/kde/kdelibs/kdeui/ktmainwindow.cpp,v
retrieving revision 1.89
diff -u -r1.89 ktmainwindow.cpp
--- ktmainwindow.cpp	2000/05/17 07:30:09	1.89
+++ ktmainwindow.cpp	2000/05/17 19:31:32
@@ -397,6 +397,11 @@
 	layoutMgr->addStatusBar(kstatusbar);
 
     layoutMgr->activate();
+
+    /* show the toolbars */
+    for (toolbars.first(); toolbars.current(); toolbars.next())
+	if (toolbars.current()->isVisibleTo(this))
+	    toolbars.current()->show();
 }
 
 void KTMainWindow::saveGlobalProperties(KConfig*)
Index: ktoolbar.cpp
===================================================================
RCS file: /home/kde/kdelibs/kdeui/ktoolbar.cpp,v
retrieving revision 1.183
diff -u -r1.183 ktoolbar.cpp
--- ktoolbar.cpp	2000/05/16 06:55:18	1.183
+++ ktoolbar.cpp	2000/05/17 19:31:46
@@ -48,6 +48,8 @@
 #include <kanimwidget.h>
 #include <kipc.h>
 
+#include <stdio.h> // For debug only
+
 #include "ktoolbarbutton.h"
 #include "ktoolbaritem.h"
 
@@ -1245,8 +1247,10 @@
   }
 }
 
-void KToolBar::resizeEvent(QResizeEvent*)
+void KToolBar::resizeEvent(QResizeEvent*e)
 {
+  fprintf(stderr, "KToolBar: resizeEvent() this = %p  (%d,%d) -> (%d,%d)\n", 
this,
+	e->oldSize().width(), e->oldSize().height(), e->size().width(), 
e->size().height());   
   /*
    * The resize can affect the arrangement of the toolbar items so
    * we have to call updateRects(). But we need not trigger another
@@ -1382,6 +1386,7 @@
 
 void KToolBar::closeEvent (QCloseEvent *e)
 {
+  fprintf(stderr, "KToolBar: closeEvent() this = %p\n", this);   
   if (d->m_position == Floating)
    {
      setBarPos(lastPosition);
@@ -1389,6 +1394,34 @@
      return;
    }
   e->accept();
+}
+
+void KToolBar::moveEvent (QMoveEvent *e)
+{
+  fprintf(stderr, "KToolBar: moveEvent() this = %p  (%d,%d) -> (%d,%d)\n", 
this,
+	e->oldPos().x(), e->oldPos().y(), e->pos().x(), e->pos().y());   
+}
+
+void KToolBar::showEvent (QShowEvent *e)
+{
+  fprintf(stderr, "KToolBar: showEvent() this = %p\n", this);   
+}
+
+void KToolBar::hideEvent (QHideEvent *e)
+{
+  fprintf(stderr, "KToolBar: hideEvent() this = %p\n", this);   
+}
+
+void KToolBar::show()
+{
+   if (parentWidget() && !parentWidget()->isUpdatesEnabled())
+   {
+      clearWState( WState_ForceHide);
+   }
+   else
+   {
+      QWidget::show();
+   }
 }
 
 
Index: ktoolbar.h
===================================================================
RCS file: /home/kde/kdelibs/kdeui/ktoolbar.h,v
retrieving revision 1.93
diff -u -r1.93 ktoolbar.h
--- ktoolbar.h	2000/05/12 20:19:13	1.93
+++ ktoolbar.h	2000/05/17 19:31:51
@@ -880,6 +880,8 @@
    */
   void setXML(const QString& xmlfile, const QDomDocument& xml);
 
+  void show();
+
 signals:
     /**
      * Emitted when button @p id is clicked.
@@ -982,6 +984,9 @@
   void layoutVertical(int maxVerHeight);
   void layoutHorizontal(int maxHorWidth);
   void leaveEvent (QEvent *e);
+  void moveEvent (QMoveEvent *e); // Debug only
+  void showEvent (QShowEvent *e); // Debug only
+  void hideEvent (QHideEvent *e); // Debug only
 
   /**
    * This will return a pointer to the list of toolbar items

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

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