From kde-core-devel Sat Jan 03 13:58:02 2009 From: "Friedrich W. H. Kossebau" Date: Sat, 03 Jan 2009 13:58:02 +0000 To: kde-core-devel Subject: Re: [PATCH] KAcceleratorManager is broken wrt QDockWidget Message-Id: <200901031458.03383.kossebau () kde ! org> X-MARC-Message: https://marc.info/?l=kde-core-devel&m=123099108014556 MIME-Version: 1 Content-Type: multipart/mixed; boundary="--Boundary-00=_r72XJO9y3dI6vTY" --Boundary-00=_r72XJO9y3dI6vTY Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit Content-Disposition: inline Hi, noone feels to act on this, many still on holiday? Lucky them :) BTW, this effects almost all applications using multiple QDockWidgets, e.g. Dolphin, Lokalize, Parley, and Okteta. When QDockWidgets get tabbed by the user. Just try yourself, stack one QDockWidgets onto the other and see the cpu usage rising high as long as they are staying stacked (given that AutoCheckAccelerators=true, as default, see below). KOffice programs are save, because their docked tools use their own QDockWidget titel, which is not handled by KAcceleratorManager. Patch discussed below \/ Am Mittwoch, 31. Dezember 2008, um 02:32 Uhr, schrieb Friedrich W. H. Kossebau: > Hi, > > who is experienced with KAcceleratorManager & friends? I think I have found > a problem with regard to QDockWidgets: > > The title of a QDockWidget appears in up to three places: > 1) title bar > 2) tab bar title > 3) toggle action menu entry > > A) endless loop due to automatically reset texts > Currently KAcceleratorManager gives all three different accelerators - but > as on a title change the QDockWidget updates it's toggle action and also > the tab title, this leads to an endless loop, if AutoCheckAccelerators=true > (see below). > Can be even seen by executing "QT_FLUSH_PAINT=1 okteta" and stacking two or > more tool views onto each other: the QDockWidget tabbar will now flash all > the time. Does not block the program, but steals cpu time also without > QT_FLUSH_PAINT set, up to 50 % if tools are visible. > > B) Tab vs titlebar > If a tabbed QDockWidget is visible, both it's title bar and the tab are > shown, including their shortcut. > Should it be the same? Should it be different? > Should one shortcut be omitted? Which one? > How to have consistency with untabbed QDockWidget, which always show their > title bar including the focus shortcut? > > C) Accelerator also with title of floating widgets > The title bar also receives a accelerator if a the dock widget is undocked, > i.e. floating. I do not think this is expected. > > How to solve all of this? I have no real idea (at least at 2.30 in the > night), so no patch. > > But at least I learned about Dr. Klash: > Edit your kdeglobals (`kde-config --localprefix`share/config/kdeglobals) > and check your own program with adding a section > [Development] > CheckAccelerators=F12 > # default true > AutoCheckAccelerators=false > #default false > AlwaysShowCheckAccelerators=false > See > http://techbase.kde.org/Development/Tools#Internationalization_.28i18n.29_T >ools The attached patch tries to solve the problem by dropping those QTabBars from accelerator setting which stack the QDockWidgets. Not perfect, but works better than before, i.e. no endless loop for accelerator setting. The tab texts get the accelerators from the QDockWidgets title, also the hidden ones. Problem is: How to precisely detect if the QTabBar is the one handling the QDockWidgets? The test, as done in the patch, for the parent being of QMainWindow type might perhaps effect other QTabBars as well? What chance is there to meet such examples in real life? Your comments, please. I will commit sunday evening, otherwise :) Cheers Friedrich -- Okteta - KDE 4 Hex Editor - http://utils.kde.org/projects/okteta --Boundary-00=_r72XJO9y3dI6vTY Content-Type: text/x-diff; charset="iso 8859-15"; name="improveAcceleratorSettingForQDockWidget.patch" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename="improveAcceleratorSettingForQDockWidget.patch" Index: kdelibs/kdeui/shortcuts/kacceleratormanager.cpp =================================================================== --- kdelibs/kdeui/shortcuts/kacceleratormanager.cpp (Revision 903572) +++ kdelibs/kdeui/shortcuts/kacceleratormanager.cpp (Arbeitskopie) @@ -20,6 +20,7 @@ #include "kacceleratormanager.h" #include +#include #include #include #include @@ -393,6 +394,17 @@ void KAcceleratorManagerPrivate::manageTabBar(QTabBar *bar, Item *item) { + // ignore QTabBar for QDockWidgets, because QDockWidget on its title change + // also updates its tabbar entry, so on the next run of KCheckAccelerators + // this looks like a conflict and triggers a new reset of the shortcuts -> endless loop + QWidget* parentWidget = bar->parentWidget(); + if( parentWidget ) + { + QMainWindow* mainWindow = qobject_cast(parentWidget); + if( mainWindow ) // && (mainWindow->layout()->indexOf(bar) != -1)) QMainWindowLayout lacks proper support + return; + } + for (int i=0; icount(); i++) { QString content = bar->tabText(i); @@ -416,7 +428,7 @@ Item *it = new Item; item->addChild(it); it->m_widget = dock; - it->m_content = KAccelString(content); + it->m_content = KAccelString(content, KAccelManagerAlgorithm::STANDARD_ACCEL); } --Boundary-00=_r72XJO9y3dI6vTY--