[prev in list] [next in list] [prev in thread] [next in thread]
List: kde-core-devel
Subject: Re: StatusBar in KMainWindow
From: Benjamin Meyer <ben () meyerhome ! net>
Date: 2003-03-13 18:36:26
[Download RAW message or body]
On Thursday 13 March 2003 1:08 pm, David Faure wrote:
> On Thursday 13 March 2003 19:01, Benjamin Meyer wrote:
> > On Thursday 13 March 2003 12:47 pm, Simon Hausmann wrote:
> > > On Thu, Mar 13, 2003 at 12:03:21PM -0500, Benjamin Meyer wrote:
> > > > On Thursday 13 March 2003 11:28 am, Simon Hausmann wrote:
> > > > > On Thu, Mar 13, 2003 at 10:00:52AM -0500, Benjamin Meyer wrote:
> > > > > > Attached is the new diff which has the new function that is used
> > > > > > to create the Action.
> > > > >
> > > > > I like that approach, for its consistency with the toolbar
> > > > > handling.
> > > > >
> > > > > Three minor things though:
> > > > >
> > > > > 1) The set method should take a bool and it should also handle the
> > > > > case where it's called with false IMHO. Hmm, not terribly easy
> > > > > though, maybe this should be done simliar to the toolbar
> > > > > handling, except for using an actionlist instead of a whole
> > > > > guiclient component.
> > > >
> > > > Can I simply call delete on the KAction? Will everything be ok?
> > >
> > > Nope, that would make the xmlgui engine end up with a dangling
> > > pointer and leave the action plugged in the GUI.
> >
> > Would also calling this be enough?
> > actionCollection()->remove(action);
>
> No, action->unplugAll(). See latest commit to kaction.h for docu ;)
>
> > The KActionCollection::remove function is not documented.
>
> You don't ever need to call it. ~KAction does it.
After talking on irc I have removed the bool again because we couldn't think
of a reason why you would ever call false, gave the functions better names,
and improved the comment a little bit to make the function a little bit more
clear. Unless anyone objects I will commit to cvs. (and once it is in then
the multi-hour fun of going through apps and letting them use it can begin!)
-Benjamin Meyer
["diff" (text/x-diff)]
? .kmainwindow.cpp.swp
? .kmainwindow.h.swp
? diff
? kmainwindow.cpp_new
? kmainwindow.h_new
Index: kmainwindow.cpp
===================================================================
RCS file: /home/kde/kdelibs/kdeui/kmainwindow.cpp,v
retrieving revision 1.98
diff -u -3 -p -r1.98 kmainwindow.cpp
--- kmainwindow.cpp 13 Mar 2003 00:53:29 -0000 1.98
+++ kmainwindow.cpp 13 Mar 2003 18:34:10 -0000
@@ -65,6 +65,7 @@ public:
KMainWindowInterface *m_interface;
KDEPrivate::ToolBarHandler *toolBarHandler;
QTimer* settingsTimer;
+ KToggleAction *showStatusBarAction;
QRect defaultWindowSize;
};
@@ -226,6 +227,7 @@ void KMainWindow::initKMainWindow(const
d->kaccel = actionCollection()->kaccel();
d->toolBarHandler = 0;
d->settingsTimer = 0;
+ d->showStatusBarAction = NULL;
if ((d->care_about_geometry = beeing_first)) {
beeing_first = false;
if ( kapp->geometryArgument().isNull() ) // if there is no geometry, it \
doesn't mater @@ -687,6 +689,15 @@ bool KMainWindow::isStandardToolBarMenuE
return ( d->toolBarHandler != 0 );
}
+void KMainWindow::createStandardStatusBarAction(){
+ if(!d->showStatusBarAction){
+ d->showStatusBarAction = KStdAction::showStatusbar(this, \
SLOT(setSettingsDirty()), actionCollection()); + connect(d->showStatusBarAction, \
SIGNAL(toggled(bool)), statusBar(), SLOT(setShown(bool))); + \
if(internalStatusBar()) + \
d->showStatusBarAction->setChecked(!internalStatusBar()->isHidden()); + }
+}
+
bool KMainWindow::readPropertiesInternal( KConfig *config, int number )
{
if ( number == 1 )
@@ -728,12 +739,12 @@ void KMainWindow::applyMainWindowSetting
entryList.clear();
i = config->readListEntry (QString::fromLatin1("StatusBar"), entryList, \
';'); entry = entryList.first();
- if (entry == QString::fromLatin1("Disabled")){
- sb->hide();
- }
- else{
- sb->show();
- }
+ if (entry == QString::fromLatin1("Disabled"))
+ sb->hide();
+ else
+ sb->show();
+ if(d->showStatusBarAction)
+ d->showStatusBarAction->setChecked(!sb->isHidden());
}
QMenuBar* mb = internalMenuBar();
Index: kmainwindow.h
===================================================================
RCS file: /home/kde/kdelibs/kdeui/kmainwindow.h,v
retrieving revision 1.71
diff -u -3 -p -r1.71 kmainwindow.h
--- kmainwindow.h 13 Mar 2003 00:53:29 -0000 1.71
+++ kmainwindow.h 13 Mar 2003 18:34:10 -0000
@@ -449,6 +449,30 @@ public:
/// @since 3.1
bool isStandardToolBarMenuEnabled() const;
+
+ /**
+ * Sets whether KMainWindow should provide a menu that allows showing/hiding
+ * of the statusbar ( using @ref KToggleStatusBarAction ).
+ *
+ * The menu / menu item is implemented using xmlgui. It will be inserted
+ * in your menu structure in the 'Settings' menu.
+ *
+ * Note that you should enable this feature before calling createGUI()
+ * ( or similar ).
+ *
+ * If an application maintians the action on its own (i.e. never calls
+ * this function) a connection needs to be made to let KMainWindow
+ * know when that status (hiden/shown) of the statusbar has changed.
+ * For example:
+ * connect(action, SIGNAL(activated()),
+ * kmainwindow, SLOT(setSettingsDirty()));
+ * Otherwise the status (hidden/show) of the statusbar might not be saved
+ * by KMainWindow.
+ * @since 3.2
+ */
+ void createStandardStatusBarAction();
+
+
/**
* Returns a pointer to the mainwindows action responsible for the toolbars menu
* @since 3.1
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic