kdeui Library API Documentation

KPanelMenu Class Reference

Base class to build dynamically loaded menu entries for the K-menu, or the panel. Base class to build dynamically loaded menu entries for the K-menu, or the panel. More...

#include <kpanelmenu.h>

Inheritance diagram for KPanelMenu:

KPopupMenu QPopupMenu List of all members.

Public Slots

void reinitialize ()
 Reinitialize the menu: the menu is first cleared, the initial state is set to false, and finally initialize() is called.

void deinitialize ()
 Deinitialize the menu: the menu is cleared and the initialized state is set to false.


Public Member Functions

 KPanelMenu (QWidget *parent=0, const char *name=0)
 Construct a KPanelMenu object.

 KPanelMenu (const QString &startDir, QWidget *parent=0, const char *name=0)
 Constructor used internally by Kicker.

virtual ~KPanelMenu ()
 Destructor.

const QStringpath () const
 Get the directory path associated with this menu, or QString::null if there's no such associated path.

void setPath (const QString &p)
 Set a directory path to be associated with this menu.

bool initialized () const
 Tell if the menu has been initialized, that is it already contains items.

void setInitialized (bool on)
 Set the initial state.

void disableAutoClear ()
 Disable the automatic clearing of the menu.


Protected Slots

virtual void slotAboutToShow ()
 This slot is called just before the menu is shown.

virtual void slotExec (int id)=0
 This is slot is called when an item from the menu has been selected.

virtual void initialize ()=0
 This slots is called to initialize the menu.

void slotClear ()
 Clears the menu, and update the initial state accordingly.


Protected Member Functions

virtual void hideEvent (QHideEvent *ev)
 Re-implemented for internal reasons.

void init (const QString &path=QString::null)
 For internal use only.

virtual void virtual_hook (int id, void *data)

Detailed Description

Base class to build dynamically loaded menu entries for the K-menu, or the panel. Base class to build dynamically loaded menu entries for the K-menu, or the panel.

This class allows to build menu entries that will be dynamically added either to the K-menu, or to the panel as a normal button. These dynamic menus are located in shared libraries that will be loaded at runtime by Kicker (the KDE panel).

To build such a menu, you have to inherit this class and implement the pure virtual functions initialize() and slotExec(). You also have to provide a factory object in your library, see KLibFactory. This factory is only used to construct the menu object.

Finally, you also have to provide a desktop file describing your dynamic menu. The relevant entries are: Name, Comment, Icon and X-KDE-Library (which contains the library name without any extension). This desktop file has to be installed in $KDEDIR/share/apps/kicker/menuext/.

Author:
The kicker maintainer, Michael Goffioul <goffioul@imec.be>

Definition at line 54 of file kpanelmenu.h.


Constructor & Destructor Documentation

KPanelMenu::KPanelMenu QWidget parent = 0,
const char *  name = 0
 

Construct a KPanelMenu object.

This is the normal constructor to use when building extrernal menu entries.

Definition at line 49 of file kpanelmenu.cpp.

References init(), and KStdAccel::name().

KPanelMenu::KPanelMenu const QString startDir,
QWidget parent = 0,
const char *  name = 0
 

Constructor used internally by Kicker.

You don't really want to use it.

Parameters:
startDir a directory to associate with this menu
See also:
path(), setPath()

Definition at line 43 of file kpanelmenu.cpp.

References init(), and KStdAccel::name().

KPanelMenu::~KPanelMenu  )  [virtual]
 

Destructor.

Definition at line 74 of file kpanelmenu.cpp.


Member Function Documentation

const QString & KPanelMenu::path  )  const
 

Get the directory path associated with this menu, or QString::null if there's no such associated path.

Returns:
the associated directory path
See also:
setPath()

Definition at line 114 of file kpanelmenu.cpp.

void KPanelMenu::setPath const QString p  ) 
 

Set a directory path to be associated with this menu.

Parameters:
p the directory path
See also:
path()

Definition at line 119 of file kpanelmenu.cpp.

bool KPanelMenu::initialized  )  const
 

Tell if the menu has been initialized, that is it already contains items.

This is useful when you need to know if you have to clear the menu, or to fill it.

Returns:
the initial state
See also:
setInitialized(), initialize()

Definition at line 124 of file kpanelmenu.cpp.

void KPanelMenu::setInitialized bool  on  ) 
 

Set the initial state.

Set it to true when you menu is filled with the items you want.

Parameters:
on the initial state
See also:
initialized(), initialize()

Definition at line 129 of file kpanelmenu.cpp.

Referenced by init(), and slotClear().

void KPanelMenu::disableAutoClear  ) 
 

Disable the automatic clearing of the menu.

Kicker uses a cache system for its menus. After a specific configurable delay, the menu will be cleared. Use this function if you want to disable kicker's cache system, and avoid the clearing of your menu.

Definition at line 109 of file kpanelmenu.cpp.

void KPanelMenu::reinitialize  )  [slot]
 

Reinitialize the menu: the menu is first cleared, the initial state is set to false, and finally initialize() is called.

Use this if you want to refill your menu immediately.

Definition at line 134 of file kpanelmenu.cpp.

References deinitialize().

void KPanelMenu::deinitialize  )  [slot]
 

Deinitialize the menu: the menu is cleared and the initialized state is set to false.

initialize() is NOT called. It will be called before the menu is next shown, however. Use this slot if you want a delayed reinitialization.

Since:
3.1

Definition at line 143 of file kpanelmenu.cpp.

References slotClear().

Referenced by reinitialize().

void KPanelMenu::slotAboutToShow  )  [protected, virtual, slot]
 

This slot is called just before the menu is shown.

This allows your menu to update itself if needed. However you should instead re-implement initialize to provide this feature. This function is responsible for the cache system handling, so if you re-implement it, you should call the base function also. Calls initialize().

See also:
disableAutoClear()

Definition at line 79 of file kpanelmenu.cpp.

Referenced by init().

virtual void KPanelMenu::slotExec int  id  )  [protected, pure virtual, slot]
 

This is slot is called when an item from the menu has been selected.

Your applet is then supposed to perform some action. You must re-implement this function.

Parameters:
id the ID associated with the selected item

Referenced by init().

virtual void KPanelMenu::initialize  )  [protected, pure virtual, slot]
 

This slots is called to initialize the menu.

It is called automatically by slotAboutToShow(). By re-implementing this functions, you can reconstruct the menu before it is being shown. At the end of this function, you should call setInitialize() with true to tell the system that the menu is OK. You applet must re-implement this function.

See also:
slotAboutToShow(), initialized(), setInitialized()

void KPanelMenu::slotClear  )  [protected, slot]
 

Clears the menu, and update the initial state accordingly.

See also:
initialized()

Definition at line 92 of file kpanelmenu.cpp.

References QPopupMenu::clear(), and setInitialized().

Referenced by deinitialize(), and hideEvent().

void KPanelMenu::hideEvent QHideEvent ev  )  [protected, virtual]
 

Re-implemented for internal reasons.

Definition at line 98 of file kpanelmenu.cpp.

References slotClear().

void KPanelMenu::init const QString path = QString::null  )  [protected]
 

For internal use only.

Used by constructors.

Definition at line 55 of file kpanelmenu.cpp.

References QPopupMenu::aboutToShow(), QPopupMenu::activated(), KGlobal::config(), KConfigBase::readNumEntry(), KConfigBase::setGroup(), setInitialized(), KPopupMenu::setKeyboardShortcutsEnabled(), slotAboutToShow(), and slotExec().

Referenced by KPanelMenu().


The documentation for this class was generated from the following files:
KDE Logo
This file is part of the documentation for kdelibs Version 3.1.4.
Documentation copyright © 1996-2002 the KDE developers.
Generated on Sun Feb 27 22:15:10 2005 by doxygen 1.3.4 written by Dimitri van Heesch, © 1997-2001