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

List:       kde-core-devel
Subject:    Re: KToolbar Confusion
From:       Simon St James <kdedevel () etotheipiplusone ! com>
Date:       2009-05-14 18:39:39
Message-ID: 200905141939.40428.kdedevel () etotheipiplusone ! com
[Download RAW message or body]

Hi all,

Follow up from http://lists.kde.org/?l=kde-core-devel&m=123325087220541&w=2; 
working towards a fix for:

http://bugs.kde.org/show_bug.cgi?id=168480 and 
https://bugs.kde.org/show_bug.cgi?id=169067

Not much feedback on the original post (but thanks to dfaure for explaining 
that some of my assumptions were wrong :)), so I figured I'd try to work out 
the requirements myself, write a patch implementing them, and let people pick 
it apart in order to tease out the full spec ;) The attached does just that: 
it "works", but I'm sure there's lots and lots of incorrect assumptions 
there - I have no objection to throwing it all out and starting from scratch 
once I have a spec.  It could probably be made a simpler if we assume that 
e.g. loadState and saveState are only called at specific, predictable times, 
but they are public API and I can't bring myself to do this ;)

Note that global changes to toolbutton style are not yet automatically 
responded to by apps: this will require extra changes to the Style KCM to 
make it actually write the changes to the kdeglobals file(!)  Doing 
this "manually" and firing the relevant signal makes the apps update their 
toolbutton style settings, if appropriate, correctly though. Icon size should 
Just Work.  I'll fix the KCM Style once I've gotten the KToolbar stuff 
hammered into shape.  There's a small System Settings patch which may or may 
not be required in order to detect changes to the global default icon size - 
again, something I'll sort out later :)

My assumptions - please review and correct :)

1) An icon size/ toolbutton style is the Default (capital "D"!) if it has not 
been specified explicitly in the apprc nor via an API call to 
QToolbar::setIconSize/setToolButtonStyle nor via the user choosing an 
explicit size in the toolbar context menu.  An icon size/ toolbutton style 
can be reverted to Default by choosing "Default" from the toolbar context 
menu.  In particular: Just because e.g. the current size of the icon is 22 
and the global default size for icons is also 22, it does not follow that the 
icon size is the Default - it may have been manually set to 22 by the user!

2) The "Text Position" (toolbutton style) context menu should really have 
a "Default" option to match that of the "Icon Size" context menu.

3) The Default for the icon size/ toolbutton style can be a) hard-coded; b) 
loaded from relevant group(s) in the kdeglobals file; or c) specified in the 
xmlgui appnameui.rc.  This list is given in order of precedence: kdeglobals 
overrides the hard-coded defaults and xmlgui overrides this.

4) If the icon size/ tool button style is Default, it should track the actual 
defaults as they change: In particular, if the defaults originate in 
kdeglobals, then they should track changes made to the kdeglobals default 
values via System Settings kcm's.

5) The default value for the icon size/ toolbutton style can be specified via 
xmlgui using the "iconSize" and "iconText" attributes.  Thus, if e.g. 
iconSize=xx is specified for a toolbar in the appnameui.rc, then as a 
consequence of the precedence described in 3), the icon size for this toolbar 
will *not* track the kdeglobals default icon size.  This does not affect the 
non-Default status of icon size/ toolbutton style i.e. if the icon size was 
Default prior to a call to loadState(...) and loadState(...) found 
iconSize="32" in appnameui.rc, then the default icon size is set to 32, and 
the actual icon size is still Default - it does not count as explicitly 
setting the icon size to 32.

6) If the icon size/ toolbutton style is the Default, it should *not* be saved 
in the appnamerc - otherwise it should.

7) If the icon size/ toolbutton style is the Default, it should *not* be saved 
in a call to saveState - otherwise it should.  I guess if they have 
non-Default values they should be saved as "iconSize" and "iconText", but the 
only related thing that is actually currently saved is "toolButtonStyle"(?).

8) If the value of the default icon size/ toolbutton style did not originate 
in xmlgui, then it should not be saved in saveState - otherwise it should.  
I.e. - if the appnameui.rc did not provide a "iconSize" attribute for this 
toolbar, then "iconSizeDefault" should not be saved in saveState - this 
avoids the case where a future call to loadState retrieves iconSizeDefault 
(which may have originated from kdeglobals), identifies this as coming from 
xmlgui (overriding kdeglobals, as per 3)) and thus prevents a Default icon 
size from tracking the changes to the default icon size in kdeglobals when it 
really should.

9) If an icon size/ toolbutton has been manually set via an API call to 
QToolbar::setIconSize/setToolButtonStyle or via the user choosing an explicit 
size in the toolbar context menu, then re-loading from a config group via 
applySettings(...) will not override these manually set icon size/ toolbutton 
unless "force" is true - this is  debatable and I would appreciate input on 
it :) It makes some sense to me as if the user specifies explicit values at 
runtime, these should not be overridden i.e. manual changes should have 
highest "precedence".  This is still a TODO.

Many thanks for any advice; I'd really like to get this nailed before 4.3, but 
can't without the help of people "in the know" :/

Best Wishes,
Simon

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

Index: ../../../src/kdebase/runtime/kcontrol/icons/icons.cpp
===================================================================
--- ../../../src/kdebase/runtime/kcontrol/icons/icons.cpp	(revision 966674)
+++ ../../../src/kdebase/runtime/kcontrol/icons/icons.cpp	(working copy)
@@ -381,6 +381,7 @@
 	if (mbChanged[i])
 	{
 	    KGlobalSettings::self()->emitChange(KGlobalSettings::IconChanged, i);
+            KGlobalSettings::self()->emitChange(KGlobalSettings::ToolbarStyleChanged);
 	    mbChanged[i] = false;
 	}
     }

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

Index: ../../../src/kdelibs/kdeui/widgets/ktoolbar.h
===================================================================
--- ../../../src/kdelibs/kdeui/widgets/ktoolbar.h	(revision 966673)
+++ ../../../src/kdelibs/kdeui/widgets/ktoolbar.h	(working copy)
@@ -213,15 +213,18 @@
     Q_PRIVATE_SLOT( d, void slotContextAboutToShow() )
     Q_PRIVATE_SLOT( d, void slotContextAboutToHide() )
     Q_PRIVATE_SLOT( d, void slotContextLeft() )
-    Q_PRIVATE_SLOT( d, void slotContextRight() )
+    Q_PRIVATE_SLOT( d, void slotContextRight() )    
     Q_PRIVATE_SLOT( d, void slotContextTop() )
     Q_PRIVATE_SLOT( d, void slotContextBottom() )
+    Q_PRIVATE_SLOT( d, void slotContextStyleDefault() )
     Q_PRIVATE_SLOT( d, void slotContextIcons() )
     Q_PRIVATE_SLOT( d, void slotContextText() )
     Q_PRIVATE_SLOT( d, void slotContextTextRight() )
     Q_PRIVATE_SLOT( d, void slotContextTextUnder() )
     Q_PRIVATE_SLOT( d, void slotContextIconSize() )
     Q_PRIVATE_SLOT( d, void slotLockToolBars( bool ) )
+    Q_PRIVATE_SLOT( d, void slotIconSizeChanged ( const QSize & ) )
+    Q_PRIVATE_SLOT( d, void slotToolButtonStyleChanged ( Qt::ToolButtonStyle ) )
 };
 
 #endif
Index: ../../../src/kdelibs/kdeui/widgets/ktoolbar.cpp
===================================================================
--- ../../../src/kdelibs/kdeui/widgets/ktoolbar.cpp	(revision 966673)
+++ ../../../src/kdelibs/kdeui/widgets/ktoolbar.cpp	(working copy)
@@ -56,6 +56,17 @@
 
 #include <kconfiggroup.h>
 
+typedef enum { 
+        // Either not been set by any of XmlGui, apprc, etc, or the "Default"
+        // item has been chosen from the context menu.
+        Default, 
+        GlobalRc, 
+        XmlGui, 
+        AppRc, 
+        // Set via context menu to an explicit size or via QToolbar::setIconSize/  
+        // setToolButtonStyle.
+        Manual } SettingSource;
+
 class KToolBar::Private
 {
   public:
@@ -68,7 +79,12 @@
         xmlguiClient(0),
         contextLockAction(0),
         IconSizeDefault(22),
+        iconSizeDefaultSource(Default),
+        iconSizeSource(Default),
         ToolButtonStyleDefault(Qt::ToolButtonTextBesideIcon),
+        toolButtonStyleDefaultSource(Default),
+        toolButtonStyleSource(Default),
+        ignoreSettingsChanges(false),
         HiddenDefault(false),
         NewLineDefault(false),
         PositionDefault("Top"),
@@ -90,22 +106,34 @@
             ToolButtonStyleDefault = Qt::ToolButtonTextUnderIcon;
         }
         **/
+        updateDefaultsFromGlobal();
+        // Listen out for external, Manual changes to the toolbar's icon size/ \
style. +        connect(q, SIGNAL(iconSizeChanged (const QSize &)), q, \
SLOT(slotIconSizeChanged (const QSize &))); +        connect(q, \
SIGNAL(toolButtonStyleChanged (Qt::ToolButtonStyle)), q, \
SLOT(slotToolButtonStyleChanged (Qt::ToolButtonStyle))); +        // Get notified of \
changes to the global toolbar icon size/ style. +        \
connect(KGlobalSettings::self(), SIGNAL(iconChanged(int)), q, \
SLOT(slotAppearanceChanged())); +        connect(KGlobalSettings::self(), \
SIGNAL(toolbarAppearanceChanged(int)), q, SLOT(slotAppearanceChanged()));     }
 
     void slotReadConfig();
     void slotAppearanceChanged();
     void slotContextAboutToShow();
     void slotContextAboutToHide();
+    // Orientation menu.
     void slotContextLeft();
     void slotContextRight();
     void slotContextTop();
     void slotContextBottom();
+    // Text Position (toolbar style)
+    void slotContextStyleDefault();
     void slotContextIcons();
     void slotContextText();
     void slotContextTextRight();
     void slotContextTextUnder();
     void slotContextIconSize();
     void slotLockToolBars(bool lock);
+    void slotIconSizeChanged ( const QSize & );
+    void slotToolButtonStyleChanged ( Qt::ToolButtonStyle );
 
     void init(bool readConfig = true, bool honorStyle = false);
     void getAttributes(QString &position, Qt::ToolButtonStyle &toolButtonStyle, int \
&index) const; @@ -119,6 +147,10 @@
     static QString toolButtonStyleToString(Qt::ToolButtonStyle);
     static Qt::ToolBarArea positionFromString(const QString& position);
 
+    // Refreshes the values of IconSizeDefault and ToolButtonStyleDefault from
+    // the global config, and ensure that icon size/ style are updated to match
+    // them, if appropriate.
+    void updateDefaultsFromGlobal();
 
     KToolBar *q;
     bool honorStyle : 1;
@@ -140,6 +172,7 @@
     QAction* contextLeft;
     QAction* contextRight;
     QAction* contextBottom;
+    QAction* contextStyleDefault;
     QAction* contextIcons;
     QAction* contextTextRight;
     QAction* contextText;
@@ -154,6 +187,25 @@
     bool NewLineDefault : 1;
     QString PositionDefault;
 
+    // Where did the current toolbar icon size and style come from?          
+    SettingSource iconSizeSource;
+    SettingSource toolButtonStyleSource;    
+    // Where did the current IconSizeDefault and ToolButtonStyleDefault come from?
+    SettingSource iconSizeDefaultSource;
+    SettingSource toolButtonStyleDefaultSource;
+    bool ignoreSettingsChanges;
+
+    // The icon size/ style and the defaults should always be set via these methods!
+    // If source has at least the priority of the current iconSizeSource,
+    // Sets the icon size to size, and makes note of the new source.
+    // TODO - I don't fully respect this at the moment - I'll need to add a \
"override" flag +    // as we occasionally want to override the priority.
+    void setIconSize(const QSize& size, SettingSource source); // TODO - this should \
take an int, not a QSize - silly me! +    // As with setIconSize, but for the toolbar \
style. +    void setToolButtonStyle(Qt::ToolButtonStyle style, SettingSource source);
+    void setIconSizeDefault(const QSize& size, SettingSource source); // TODO - this \
should take an int, not a QSize - silly me! +    void \
setToolButtonStyleDefault(Qt::ToolButtonStyle style, SettingSource source); +
     QList<QAction*> actionsBeingDragged;
     QAction* dropIndicatorAction;
 
@@ -253,6 +305,7 @@
     contextMode = new KMenu(i18n("Text Position"), context);
     context->addMenu(contextMode);
 
+    contextStyleDefault = contextMode->addAction(i18n("Default"), q, \
                SLOT(slotContextStyleDefault()));
     contextIcons = contextMode->addAction(i18n("Icons Only"), q, \
SLOT(slotContextIcons()));  contextIcons->setChecked(true);
     contextText = contextMode->addAction(i18n("Text Only"), q, \
SLOT(slotContextText())); @@ -268,7 +321,7 @@
     contextSize = new KMenu(i18n("Icon Size"), context);
     context->addMenu(contextSize);
 
-    contextIconSizes.insert(contextSize->addAction(i18nc("@item:inmenu Icon size", \
"Default"), q, SLOT(slotContextIconSize())), IconSizeDefault); +    \
contextIconSizes.insert(contextSize->addAction(i18nc("@item:inmenu Icon size", \
"Default"), q, SLOT(slotContextIconSize())), -1 /* -1 represents the default */);  
     // Query the current theme for available sizes
     KIconTheme *theme = KIconLoader::global()->theme();
@@ -435,6 +488,75 @@
     return newposition;
 }
 
+void KToolBar::Private::updateDefaultsFromGlobal()
+{
+    setIconSizeDefault(QSize(q->iconSizeDefault(), q->iconSizeDefault()), GlobalRc);
+    setToolButtonStyleDefault(q->toolButtonStyleSetting(), GlobalRc);
+    // Track the new defaults?
+    if (iconSizeSource == Default) {
+        setIconSize(QSize(IconSizeDefault,IconSizeDefault), Default);
+    }
+    if (toolButtonStyleSource == Default) {        
+        setToolButtonStyle(ToolButtonStyleDefault, Default);
+    }
+}
+
+void KToolBar::Private::setIconSize(const QSize& size, SettingSource source)
+{
+    if (source < iconSizeSource) {
+        // The current source overrides source - ignore.
+        return;
+    }
+    
+    // slotIconSizeChanged will assume a Manual source: prevent this.
+    ignoreSettingsChanges = true;
+
+    if (q->iconSize().width() != size.width()) {
+        q->setIconSize(size);
+    }
+    iconSizeSource = source;
+
+    ignoreSettingsChanges = false;
+}
+
+void KToolBar::Private::setToolButtonStyle(Qt::ToolButtonStyle style, SettingSource \
source) +{    
+    if (source < toolButtonStyleSource) {
+        // The current source overrides source - ignore.
+        return;
+    }
+     // slotToolButtonStyleChanged will assume a Manual source: prevent this.
+    ignoreSettingsChanges = true;
+
+    if (q->toolButtonStyle() != style) {
+        q->setToolButtonStyle(style);
+    }
+    toolButtonStyleSource = source;
+
+    ignoreSettingsChanges = false;
+}
+
+void KToolBar::Private::setIconSizeDefault(const QSize& size, SettingSource source)
+{
+    if (source < iconSizeDefaultSource) {
+        // The current source overrides source - ignore.
+        return;
+    }
+    IconSizeDefault = size.width();
+    iconSizeDefaultSource = source; 
+}
+void KToolBar::Private::setToolButtonStyleDefault(Qt::ToolButtonStyle style, \
SettingSource source) +{
+    if (source < toolButtonStyleDefaultSource) {
+        // The current source overrides source - ignore.
+        return;
+    }
+    ToolButtonStyleDefault = style;
+    toolButtonStyleDefaultSource = source;
+}
+
+
+
 void KToolBar::Private::slotReadConfig()
 {
   /**
@@ -448,14 +570,19 @@
 
 void KToolBar::Private::slotAppearanceChanged()
 {
+  updateDefaultsFromGlobal();
+  // TODO - dfaure - KMainWindow::setSettingsDirty(...) here ... ? It was done \
originally, +  // but I don't know if it is necessary.
+#if 0    
   // Read appearance settings from global file.
-  KConfigGroup cg(KGlobal::config(), QString());
+  KConfigGroup cg(KGlobal::config(), QString()); 
   q->applyAppearanceSettings(cg , true /* lose local settings */);
 
   // And remember to save the new look later
   KMainWindow *kmw = qobject_cast<KMainWindow *>(q->mainWindow());
   if (kmw)
     kmw->setSettingsDirty();
+#endif  
 }
 
 void KToolBar::Private::slotContextAboutToShow()
@@ -491,6 +618,7 @@
   KEditToolBar::setGlobalDefaultToolBar(q->QObject::objectName().toLatin1().constData());
  
   // Check the actions that should be checked
+  // TODO - case where toolButtonStyleSource == Default (should check newly-added \
"Default" option).  switch (q->toolButtonStyle()) {
     case Qt::ToolButtonIconOnly:
     default:
@@ -510,7 +638,8 @@
   QMapIterator< QAction*, int > it = contextIconSizes;
   while (it.hasNext()) {
     it.next();
-    if (it.value() == q->iconSize().width()) {
+    if ((iconSizeSource == Default && it.value() == -1) ||
+        (iconSizeSource != Default && it.value() == q->iconSize().width())) {
       it.key()->setChecked(true);
       break;
     }
@@ -580,6 +709,12 @@
   q->setToolButtonStyle(Qt::ToolButtonIconOnly);
 }
 
+void KToolBar::Private::slotContextStyleDefault()
+{
+    toolButtonStyleSource = Default;
+    updateDefaultsFromGlobal();
+}
+
 void KToolBar::Private::slotContextText()
 {
   q->setToolButtonStyle(Qt::ToolButtonTextOnly);
@@ -599,7 +734,15 @@
 {
   QAction* action = qobject_cast<QAction*>(q->sender());
   if (action && contextIconSizes.contains(action)) {
-    q->setIconDimensions(contextIconSizes.value(action));
+        int size = contextIconSizes.value(action);
+    if (size == -1) {
+        // Set to Default.
+        iconSizeSource = Default;
+        updateDefaultsFromGlobal();
+    }
+    else {
+        setIconSize(QSize(contextIconSizes.value(action),contextIconSizes.value(action)), \
Manual); +    }
   }
 }
 
@@ -608,8 +751,23 @@
   q->setToolBarsLocked(lock);
 }
 
+void KToolBar::Private::slotIconSizeChanged ( const QSize & size)        
+{
+    if (ignoreSettingsChanges)
+        return;
+    // Presumably the icon size was changed via QToolbar::setIconSize()
+    // which is a manual change.
+    iconSizeSource = Manual;
+}
+void KToolBar::Private::slotToolButtonStyleChanged ( Qt::ToolButtonStyle style )
+{
+    if (ignoreSettingsChanges)
+        return;
+    // Presumably the icon size was changed via QToolbar::setToolButtonStyle()
+    // which is a manual change.
+    toolButtonStyleSource = Manual;
+}
 
-
 KToolBar::KToolBar(QWidget *parent, bool honorStyle, bool readConfig)
   : QToolBar(parent),
     d(new Private(this))
@@ -667,13 +825,13 @@
     cg.revertToDefault("Position");
   else
     cg.writeEntry("Position", position);
-
-  if (d->honorStyle && ToolButtonStyle == d->ToolButtonStyleDefault && \
!cg.hasDefault("ToolButtonStyle")) +  
+  if (d->honorStyle && d->toolButtonStyleSource == Default && \
!cg.hasDefault("ToolButtonStyle"))  cg.revertToDefault("ToolButtonStyle");
   else
     cg.writeEntry("ToolButtonStyle", d->toolButtonStyleToString(ToolButtonStyle));
 
-  if (!cg.hasDefault("IconSize") && iconSize().width() == iconSizeDefault())
+  if (!cg.hasDefault("IconSize") && d->iconSizeSource == Default)
     cg.revertToDefault("IconSize");
   else
     cg.writeEntry("IconSize", iconSize().width());
@@ -733,7 +891,6 @@
 Qt::ToolButtonStyle KToolBar::toolButtonStyleSetting()
 {
   KConfigGroup saver(KGlobal::config(), "Toolbar style");
-
   return KToolBar::Private::toolButtonStyleFromString(saver.readEntry("ToolButtonStyle", \
"TextUnderIcon"));  }
 
@@ -790,7 +947,7 @@
       deleted and recreated meanwhile. So we store the app-default settings
       into the XML.
    */
-  bool loadingAppDefaults = true;
+  bool loadingAppDefaults = true;  
   if (element.hasAttribute("newlineDefault")) {
     // this isn't the first time, so the defaults have been saved into the \
(in-memory) XML  loadingAppDefaults = false;
@@ -804,27 +961,51 @@
   {
     QString attrIconText = element.attribute("iconText").toLower().toLatin1();
     if (!attrIconText.isEmpty()) {
+      if (loadingAppDefaults) {
+          // The app's xmlgui file contained an explicit "iconText" - this now \
becomes +          // the default.
+          d->setToolButtonStyleDefault(d->toolButtonStyleFromString(attrIconText), \
XmlGui); +          d->setToolButtonStyle(d->ToolButtonStyleDefault, Default);
+      }
+      else {
+          // An explicit iconText was saved by setState - this only occurs if the
+          // iconText was set manually.  Respect this.  
+          // TODO - after further checking, saveState(...) does not save "iconText" \
- should it? +          d->setToolButtonStyle(d->ToolButtonStyleDefault, Manual);
+      }
       setToolButtonStyle(d->toolButtonStyleFromString(attrIconText));
     } else {
       if (d->honorStyle)
-        setToolButtonStyle(toolButtonStyleSetting());
+        d->setToolButtonStyle(toolButtonStyleSetting(), Default);
       else
-        setToolButtonStyle(d->ToolButtonStyleDefault);
+        d->setToolButtonStyle(d->ToolButtonStyleDefault, Default);
     }
   }
 
-  QString attrIconSize = element.attribute("iconSize").toLower().trimmed();
   int iconSize = d->IconSizeDefault;
-
+  d->setIconSize(QSize(iconSize, iconSize), Default);
   {
+    QString attrIconSize = element.attribute("iconSize").toLower().trimmed();
     bool ok;
     int newIconSize = attrIconSize.toInt(&ok);
     if (ok)
+    {
       iconSize = newIconSize;
+      if (loadingAppDefaults) {
+          // The app's xmlgui file contained an explicit "iconSize" - this now \
becomes +          // the default.
+          d->setIconSizeDefault(QSize(iconSize,iconSize), XmlGui);
+          d->setIconSize(QSize(iconSize, iconSize), Default);
+      }
+      else {
+          // An explicit iconSize was saved by setState - this only occurs if the
+          // iconSize was set manually.  Respect this.
+          // TODO - after further checking, saveState(...) does not save "iconSize" \
- should it? +          d->setIconSize(QSize(iconSize, iconSize), Manual);
+      }
+    }
   }
 
-  setIconDimensions(iconSize);
-
   int index = -1; // append by default. This is very important, otherwise
 
   // with all 0 indexes, we keep reversing the toolbars.
@@ -867,11 +1048,11 @@
     show();
 
   if (loadingAppDefaults) {
-    d->getAttributes(d->PositionDefault, d->ToolButtonStyleDefault, index);
-
+    // "iconSize" and "iconText" defaults are set earlier. TODO - sigh, actually, \
they're probably not- m'aidez! +    Qt::ToolButtonStyle dummy;
+    d->getAttributes(d->PositionDefault, dummy, index);
     d->NewLineDefault = newLine;
     d->HiddenDefault = hidden;
-    d->IconSizeDefault = iconSize;
   }
 }
 
@@ -887,7 +1068,11 @@
 
   current.setAttribute("noMerge", "1");
   current.setAttribute("position", position);
+  // TODO - why is iconSize not saved? And why is "toolButtonStyle" saved but \
"iconText" +  // loaded in loadState?
+  if (d->toolButtonStyleSource != Default) {
   current.setAttribute("toolButtonStyle", \
d->toolButtonStyleToString(ToolButtonStyle)); +  }
   current.setAttribute("index", index);
   // FIXME KAction port
   //current.setAttribute("newline", newLine());
@@ -898,10 +1083,14 @@
   // TODO if this method is used by more than KXMLGUIBuilder, e.g. to save XML \
settings to *disk*,  // then the stuff below shouldn't always be done.
   current.setAttribute("newlineDefault", d->NewLineDefault);
-  current.setAttribute("hiddenDefault", d->HiddenDefault ? "true" : "false");
-  current.setAttribute("iconSizeDefault", d->IconSizeDefault);
+  current.setAttribute("hiddenDefault", d->HiddenDefault ? "true" : "false");  
   current.setAttribute("positionDefault", d->PositionDefault);
-  current.setAttribute("toolButtonStyleDefault", \
d->toolButtonStyleToString(d->ToolButtonStyleDefault)); +  if \
(d->iconSizeDefaultSource == XmlGui) { +      current.setAttribute("iconSizeDefault", \
d->IconSizeDefault);  +  }
+  if (d->toolButtonStyleDefaultSource == XmlGui) {
+    current.setAttribute("toolButtonStyleDefault", \
d->toolButtonStyleToString(d->ToolButtonStyleDefault)); +  }
 }
 
 void KToolBar::applySettings(const KConfigGroup &cg, bool force)
@@ -955,6 +1144,35 @@
 {
   Q_ASSERT(! cg.name().isEmpty());
 
+  d->updateDefaultsFromGlobal();
+
+  // We assume that the config group is the apprc.  We check the hasKey(...) \
explicitly +  // before loading as we don't want the merged-in global defaults!
+  // TODO - if KToolbar::applySettings(... force = true), override ... ?
+  if (cg.hasKey("IconSize")) {
+      d->setIconSize(QSize(cg.readEntry("IconSize", d->IconSizeDefault), \
cg.readEntry("IconSize", d->IconSizeDefault)), AppRc); +  }
+  if (cg.hasKey("ToolButtonStyle")) {
+      d->setToolButtonStyle(d->toolButtonStyleFromString(cg.readEntry("ToolButtonStyle",
 +                            \
d->toolButtonStyleToString(d->ToolButtonStyleDefault))), AppRc); +  }  
+  return;
+#if 0 // TODO - delete this completely if this approach is approved.
+  if (!cg.exists())
+  {
+  kDebug() << "KConfigGroup does not exist";
+}
+                      else
+              {
+                      kDebug() << "name: " << cg.name() << " keys:" << cg.keyList() \
<< " hasKey(IconSize): " << cg.hasKey("IconSize") << " hasKey(ToolButtonStyle): " << \
cg.hasKey("ToolButtonStyle"); +}
+  
+  QString defaultIconSize = "Default";
+                                    kDebug() << "IconSize: " << \
cg.readEntry("IconSize", defaultIconSize); +
+                                    QString defaultToolButtonStyle = "Default";
+                                    kDebug() << "IconSize: " << \
cg.readEntry("ToolButtonStyle", defaultToolButtonStyle ); +
   // If we have application-specific settings in the XML file,
   // and nothing in the application's config file, then
   // we don't apply the global defaults, the XML ones are preferred
@@ -1018,6 +1236,7 @@
   // ...and check if the icon size has changed
   if (iconSize != KToolBar::iconSize().width() && applyIconSize)
     setIconDimensions(iconSize);
+#endif
 }
 
 KMainWindow * KToolBar::mainWindow() const



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

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