KToolbar Confusion

kdedevel at etotheipiplusone.com kdedevel at etotheipiplusone.com
Wed Jan 28 17:40:06 GMT 2009



Hi all,

I'd like to fix the following bugs:

http://bugs.kde.org/show_bug.cgi?id=168480 [+ and a related one that I
can't find as bko is down]

where the toolbar icon and style neither reflect the globally
configured settings on application startup, nor do they respond when
the global settings are changed while the app is running.  I'm still
not comfortable with rampaging all over kdelibs unsupervised, though,
so I was hoping someone could sanity-check my plans.  There's also a
few bits of existing code that mystify me that I hope someone can shed
some light on.

Basic plan (all in ktoolbar.cpp):

1) IconSizeDefault and ToolButtonStyleDefault will be initially set to
22 and Qt::ToolButtonTextBesideIcon (maybe add these magic values as
named constants).  They are then updated from the global config if
some explicit values are set there.  After this, for the duration of
the app, they are not updated until slotAppearanceChanged(...) is
triggered by chaning the global settings in e.g. SystemSettings.

2) Introduce hasDefaultIconSize, hasDefaultToolbarStyle booleans to
KToolBar::Private, true by default.

3) hasDefaultIconSize/ToolbarStyle is set to false if and only if:

   - During construction, an explicit icon size/ toolbar style is read
from either the xmlgui file or the local apprc;
   - At any time, the user picks one of the explicit icon sizes/
toolbar styles from the  KToolbar right-click menu.

4) hasDefaultIconSize/ToolbarStyle is restored to true if and only if

    - At any time, the user picks the "Default" icon size/ toolbar
style from the  KToolbar right-click menu.

5) If hasDefaultIconSize/ToolbarStyle then in saveSettings(...), the
IconSize/ ToolButtonStye are reverted to defaults, replacing the
(slightly broken) existing logic:

"
if (!cg.hasDefault("IconSize") && iconSize().width() == iconSizeDefault())
      cg.revertToDefault("IconSize");
    else
      cg.writeEntry("IconSize", iconSize().width());
"

6) On slotAppearanceChanged(...) I'll skip applyAppearanceSettings and
just update the icon size/ toolbar style directly if
hasDefaultIconSize/ToolbarStyle are true.

One thing that worries me though is that IconSizeDefault and
ToolButtonStyleDefault seem to be loaded from, and later restored to,
the xmlgui file via loadState(...) and restoreState(...), and I'm
rather flummoxed as to why and wondering if the approach in 1) won't
break this. I'm tempted to view this as "historic" code and ditch it,
but it might be there for a very good reason.  Grepping through
kdebase seems to show no apps using it.  What do you think I should do?

Thanks, all!
Si




More information about the kde-core-devel mailing list