class KPanelExtension

# class KPanelExtension | KDE Panel Extension class. More...
Definition | `#include <kpanelextension.h>`
Inherits | QFrame (qt) [public ]
List of all Methods
Annotated List
Files
Globals
Hierarchy
Index

#### Public Types

- enum Type { Normal = 0, Stretch }
- enum Action { About = 1, Help = 2, Preferences = 4, ReportBug = 8 }
- enum Position { Left = 0, Right, Top, Bottom }
- enum Alignment { LeftTop = 0, Center, RightBottom }
- enum Size { SizeTiny = 0, SizeSmall, SizeNormal, SizeLarge, SizeCustom }

#### Public Methods

- KPanelExtension (const QString& configFile, Type t = Normal, int actions = 0, QWidget *parent = 0, const char *name = 0)
- ~KPanelExtension ()
- virtual QSize sizeHint (Position , QSize maxsize) const
- KConfig* config () const
- Type type () const
- int actions () const
- virtual void action ( Action a )
- virtual Position preferedPosition () const
- void setPosition ( Position p )
- void setAlignment ( Alignment a )
- void setSize ( Size size, int customSize )
- Size sizeSetting () const
- int customSize () const

#### Signals

- void updateLayout ()

#### Protected Methods

- virtual void about ()
- virtual void help ()
- virtual void preferences ()
- virtual void reportBug ()
- Position position () const
- Alignment alignment () const
- Orientation orientation ()
- int sizeInPixels () const
- virtual void positionChange ( Position )
- virtual void alignmentChange ( Alignment )
- virtual void virtual_hook ( int id, void* data )

## Detailed Description

Implements a panel extension.

Panel extensions

- Are small applications living in the Window Manager dock managed by the panel.
- Are implemented as DSOs (Dynamic Shared Objects).

Note: For security and stability reasons the panel won't load untrusted third party extensions directly into its namespace but via an external wrapper process.

The panel locates available extensions by searching for extension desktop files in (ALL_KDEDIRS)/share/apps/kicker/extensions. Every panel extension should install a desktop file there to be recognised by the panel.

Besides standard keys like "Name", "Comment" and "Icon" there are two panel extension specific keys:

### X-KDE-Library

Used by the panel to locate the extension DSO (Dynamic Shared Object) Example: X-KDE-Library=libexampleextension

### X-KDE-UniqueExtension

Similar to KApplication and KUniqueApplication there are two types of panel extensions. Use unique extensions when it makes no sence to run more than one instance of an extension in the panel. A good example for unique extensions is the taskbar extension. Use normal extensions when you need instance specific configuration. An example is a subpanel extension where you might want to run more than one instances. X-KDE-UniqueExtension is a boolean key which defaults to "false". Example: X-KDE-UniqueExtension=true

Back to panel extension DSOs, the following conventions are used for KDE: Name: libextension.la LDFLAGS: -module -no-undefined

To implement a panel extension it is not enough to write a class inheriting from KPanelExtension but you also have to provide a factory function in your DSO. A sample factory function could look like this:

     extern "C"
     {
         KPanelExtension* init(QWidget *parent, const QString& configFile)
         {
             KGlobal::locale()->insertCatalogue("exampleextension");
             return new ExampleExtension(configFile, KPanelExtension::Normal,
                           KPanelExtension::About | KPanelExtension::Help | KPanelExtension::Preferences,
                           parent, "exampleextension");
         }
     }

Note: Don't change the factory function signature or the panel will fail to load your extension.

enum Type { Normal = 0, Stretch } | ### Type

enum Action { About = 1, Help = 2, Preferences = 4, ReportBug = 8 } | ### Action

enum Position { Left = 0, Right, Top, Bottom } | ### Position

enum Alignment { LeftTop = 0, Center, RightBottom } | ### Alignment

enum Size { SizeTiny = 0, SizeSmall, SizeNormal, SizeLarge, SizeCustom } | ### Size

KPanelExtension (const QString& configFile, Type t = Normal, int actions = 0, QWidget *parent = 0, const char *name = 0) | ### KPanelExtension

Constructs a KPanelExtension just like any other widget.

Parameters:

configFile | The configFile handed over in the factory function.
Type | The extension type().
actions | Standard RMB menu actions supported by the extension (see action() ).
parent | The pointer to the parent widget handed over in the factory function.
name | A Qt object name for your extension.

~KPanelExtension () | ### ~KPanelExtension

Destructor.

QSize sizeHint (Position , QSize maxsize) | ### sizeHint

[const virtual]

Returns the prefered size for a given Position.

Every extension should reimplement this function.

Depending on the panel position the extensions can choose a prefered size for that location in the Window Manager Dock. Please note that the size can not be larger than the maxsize given by the handler.

KConfig* config () | ### config

[const]

Always use this KConfig object to save/load your extensions configuration.

For unique extensions this config object will write to a config file called rc in the users local KDE directory.

For normal extensions this config object will write to a instance specific config file called rc in the users local KDE directory.

Type type () | ### type

[const]

Returns: Type indicating the extensions type. Type

int actions () | ### actions

[const]

Returns: int indicating the supported RMB menu actions. #Action

void action ( Action a ) | ### action

[virtual]

Generic action dispatcher. Called when the user selects an item from the extensions RMB menu.

Reimplement this function to handle actions.

For About, Help, Preferences and ReportBug use the convenience handlers ref about(), help(), preferences(), reportBug()

Position preferedPosition () | ### preferedPosition

[const virtual]

Reimplement this function to set a prefered dock position for your extension. The extension manager will try to place new instances of this extension according to this setting.

Returns: Position

void setPosition ( Position p ) | ### setPosition

void setAlignment ( Alignment a ) | ### setAlignment

void setSize ( Size size, int customSize ) | ### setSize

Size sizeSetting () | ### sizeSetting

[const]

Returns: the extension's size

int customSize () | ### customSize

[const]

Returns: the custom sizel setting in pixels

void updateLayout () | ### updateLayout

[signal]

Emit this signal to make the panel relayout all extensions in the dock, when you want to change the extensions size. The panel is going to relayout all extensions based on their prefered size.

void about () | ### about

[protected virtual]

Is called when the user selects "About" from the extensions RMB menu. Reimplement this function to launch a about dialog.

Note that this is called only when your extension supports the About action. See #Action.

void help () | ### help

[protected virtual]

Is called when the user selects "Help" from the extensions RMB menu. Reimplement this function to launch a manual or help page.

Note that this is called only when your extension supports the Help action. See #Action.

void preferences () | ### preferences

[protected virtual]

Is called when the user selects "Preferences" from the extensions RMB menu. Reimplement this function to launch a preferences dialog or kcontrol module.

Note that this is called only when your extension supports the preferences action. See #Action.

void reportBug () | ### reportBug

[protected virtual]

Is called when the user selects "Report bug" from the applet's RMB menu. Reimplement this function to launch a bug reporting dialog.

Note that this is called only when your applet supports the ReportBug action. See #Action.

Position position () | ### position

[protected const]

Returns: the extension's position. (left, right, top, bottom)

Alignment alignment () | ### alignment

[protected const]

Returns: the extension's alignment. (left/top, center, or right/bottom)

Orientation orientation () | ### orientation

[protected]

Returns: the extensions orientation. (horizontal or vertical)

int sizeInPixels () | ### sizeInPixels

[protected const]

Returns: the appropriate size in pixels for the panel

void positionChange ( Position ) | ### positionChange

[protected virtual]

This extension has changed its position. Reimplement this change handler in order to adjust the look of your applet.

void alignmentChange ( Alignment ) | ### alignmentChange

[protected virtual]

This extension has changed its alignment. Reimplement this change handler in order to adjust the look of your applet.

void virtual_hook ( int id, void* data ) | ### virtual_hook

[protected virtual]

- Author: Matthias Elter
- Generated: root on macppc.ports.openbsd.org on Sat Sep 6 10:36:37 2003, using kdoc 2.0a54.