[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 15:00:52
[Download RAW message or body]
Attached is the new diff which has the new function that is used to create the
Action.
-Benjamin Meyer
On Thursday 13 March 2003 9:11 am, Benjamin Meyer wrote:
> > > > Also KToggleToolBarAction is marked as "@obsolete. toolbar actions
> > > > are created automatically now in the Settings menu. Don't use this
> > > > anymore"
>
> We should probably add setStandardToolBarMenuEnabled( ) to the doc so
> developers will know what to use.
>
> > > I knew I wasn't up-to-date about this. Can anyone tell us how that
> > > works now?
> >
> > look for instance into the kate code
> >
> > setStandardToolBarMenuEnabled( true );
>
> How nice. I was looking at the problem from the statusbar and hadn't even
> looked to see if someone had already made an automated ToolBar function. I
> will rework my patch to behave similarly.
>
> -Ben
["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 14:59:01 -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,21 @@ bool KMainWindow::isStandardToolBarMenuE
return ( d->toolBarHandler != 0 );
}
+void KMainWindow::setStandardStatusBarMenuEnabled(){
+ 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::isStandardStatusBarMenuEnabled() const
+{
+ return (d->showStatusBarAction != 0);
+}
+
bool KMainWindow::readPropertiesInternal( KConfig *config, int number )
{
if ( number == 1 )
@@ -728,12 +745,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 14:59:02 -0000
@@ -449,6 +449,31 @@ 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 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.1
+ */
+ void setStandardStatusBarMenuEnabled();
+ /// @since 3.1
+ bool isStandardStatusBarMenuEnabled() const;
+
+
/**
* 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