On Monday 05 Dec 2005 18:59, David Faure wrote:
> On Monday 05 December 2005 19:38, David Jarvie wrote:
> > On Monday 05 Dec 2005 12:21, David Faure wrote:
> > > On Monday 05 December 2005 14:55, Benjamin Meyer wrote:
> > > > On Sunday 04 December 2005 8:36 pm, David Jarvie wrote:
> > > > > On Sunday 04 Dec 2005 21:01, David Faure wrote:
> > > > > > On Sunday 04 December 2005 19:03, David Jarvie wrote:
> > > > > > > In my application, there is a "Hide Toolbar" menu option, which
> > > > > > > appears due to the StandardToolBarMenuHandler entry in its
> > > > > > > ui.rc file. Using the menu option successfully toggles the
> > > > > > > toolbar on and off, but the setting doesn't get carried over
> > > > > > > after quitting and restarting the application. Similarly, if I
> > > > > > > change the text position setting via the toolbar context menu,
> > > > > > > the new position is lost the next time I run the application.
> > > > > > >
> > > > > > > Is there standard code to save and restore these settings?
> > > > > >
> > > > > > Call KMainWindow::setAutoSaveSettings() once in your constructor,
> > > > > > and it will do it all for you (saving and restoring)
> > > > >
> > > > > I already had that, but it didn't save the toolbar hide state or
> > > > > text position.
> > > >
> > > > Use KMainWindow's setupGUI() and it will save it.
> > >
> > > Funny... all setupGUI does is to call setAutoSaveSettings, so if it
> > > didn't work for him, why should setupGUI work?
> > >
> > > I wonder why setAutoSaveSettings didn't work though. Ah, probably due
> > > to the missing save/apply calls in the kedittoolbar-related code, cf
> > > the kedittoolbar documentation.

> >
> > Are you referring to the calls which were previously missing in the
> > KAlarm code, or to the kedittoolbar stuff in kdelibs? If the former, I
> > put them in and tested them - they didn't fix it - before posting my
> > question on the list.

>
> I mean that when using the auto-save-settings feature of kmainwindow,
> one should use this kind of code for editing toolbars:
>
> * void MyClass::slotConfigureToolbars()
> * {
> * saveMainWindowSettings( KGlobal::config(), "MainWindow" );
> * KEditToolbar dlg(actionCollection());
> *
> connect(&dlg,SIGNAL(newToolbarConfig()),this,SLOT(slotNewTo olbarConfig()));
> * dlg.exec();
> * }
> *
> * void MyClass::slotNewToolbarConfig() // This is called when OK, Apply or
> Defaults is clicked * {
> * ...if you use any action list, use plugActionList on each here...
> * createGUI();
> * applyMainWindowSettings( KGlobal::config(), "MainWindow" );
> * }
>
> Note the saveMainWindowSettings / applyMainWindowSettings calls.


These calls were originally missing from my code. I then added them in, but
although they did improve things when the Edit Toolbar dialog was used, they
didn't save the hide or text position settings.

--
David Jarvie.
KAlarm author and maintainer.
http://www.astrojar.org.uk/linux/kalarm.html

>> Visit http://mail.kde.org/mailman/listinfo/kde-devel#unsub to unsubscribe <<