• Skip to content
  • Skip to link menu
KDE API Reference
  • KDE API Reference
  • kdelibs API Reference
  • KDE Home
  • Contact Us
 

KDEUI

Public Slots | Signals | Public Member Functions | Static Public Member Functions | List of all members
KXMLGUIFactory Class Reference

#include <kxmlguifactory.h>

Inheritance diagram for KXMLGUIFactory:
Inheritance graph
[legend]

Public Slots

void changeShortcutScheme (const QString &scheme)
 
int configureShortcuts (bool bAllowLetterShortcuts=true, bool bSaveSettings=true)
 

Signals

void clientAdded (KXMLGUIClient *client)
 
void clientRemoved (KXMLGUIClient *client)
 
void makingChanges (bool)
 

Public Member Functions

 KXMLGUIFactory (KXMLGUIBuilder *builder, QObject *parent=0)
 
 ~KXMLGUIFactory ()
 
void addClient (KXMLGUIClient *client)
 
QList< KXMLGUIClient * > clients () const
 
QWidget * container (const QString &containerName, KXMLGUIClient *client, bool useTagName=false)
 
QList< QWidget * > containers (const QString &tagName)
 
void plugActionList (KXMLGUIClient *client, const QString &name, const QList< QAction * > &actionList)
 
void refreshActionProperties ()
 
void removeClient (KXMLGUIClient *client)
 
void reset ()
 
void resetContainer (const QString &containerName, bool useTagName=false)
 
void unplugActionList (KXMLGUIClient *client, const QString &name)
 

Static Public Member Functions

static QDomElement actionPropertiesElement (QDomDocument &doc)
 
static QDomElement findActionByName (QDomElement &elem, const QString &sName, bool create)
 
static QString readConfigFile (const QString &filename, const KComponentData &componentData=KComponentData())
 
static bool saveConfigFile (const QDomDocument &doc, const QString &filename, const KComponentData &componentData=KComponentData())
 

Detailed Description

KXMLGUIFactory, together with KXMLGUIClient objects, can be used to create a GUI of container widgets (like menus, toolbars, etc.) and container items (menu items, toolbar buttons, etc.) from an XML document and action objects.

Each KXMLGUIClient represents a part of the GUI, composed from containers and actions. KXMLGUIFactory takes care of building (with the help of a KXMLGUIBuilder) and merging the GUI from an unlimited number of clients.

Each client provides XML through a QDomDocument and actions through a KActionCollection . The XML document contains the rules for how to merge the GUI.

KXMLGUIFactory processes the DOM tree provided by a client and plugs in the client's actions, according to the XML and the merging rules of previously inserted clients. Container widgets are built via a KXMLGUIBuilder , which has to be provided with the KXMLGUIFactory constructor.

Definition at line 65 of file kxmlguifactory.h.

Constructor & Destructor Documentation

KXMLGUIFactory::KXMLGUIFactory ( KXMLGUIBuilder *  builder,
QObject *  parent = 0 
)
explicit

Constructs a KXMLGUIFactory.

The provided builder KXMLGUIBuilder will be called for creating and removing container widgets, when clients are added/removed from the GUI.

Note that the ownership of the given KXMLGUIBuilder object won't be transferred to this KXMLGUIFactory, so you have to take care of deleting it properly.

Definition at line 190 of file kxmlguifactory.cpp.

KXMLGUIFactory::~KXMLGUIFactory ( )

Destructor.

Definition at line 202 of file kxmlguifactory.cpp.

Member Function Documentation

QDomElement KXMLGUIFactory::actionPropertiesElement ( QDomDocument &  doc)
static

Find or create the ActionProperties element, used when saving custom action properties

Definition at line 769 of file kxmlguifactory.cpp.

void KXMLGUIFactory::addClient ( KXMLGUIClient *  client)

Creates the GUI described by the QDomDocument of the client, using the client's actions, and merges it with the previously created GUI.

This also means that the order in which clients are added to the factory is relevant; assuming that your application supports plugins, you should first add your application to the factory and then the plugin, so that the plugin's UI is merged into the UI of your application, and not the other way round.

Definition at line 210 of file kxmlguifactory.cpp.

void KXMLGUIFactory::changeShortcutScheme ( const QString &  scheme)
slot

Definition at line 397 of file kxmlguifactory.cpp.

void KXMLGUIFactory::clientAdded ( KXMLGUIClient *  client)
signal
void KXMLGUIFactory::clientRemoved ( KXMLGUIClient *  client)
signal
QList< KXMLGUIClient * > KXMLGUIFactory::clients ( ) const

Returns a list of all clients currently added to this factory.

Definition at line 469 of file kxmlguifactory.cpp.

int KXMLGUIFactory::configureShortcuts ( bool  bAllowLetterShortcuts = true,
bool  bSaveSettings = true 
)
slot

Show a standard configure shortcut for every action in this factory.

This slot can be connected directly to the action to configure shortcuts. This is very simple to do that by adding a single line

KStandardAction::keyBindings( guiFactory(), SLOT( configureShortcuts() ), actionCollection() );
Parameters
bAllowLetterShortcutsSet to false if unmodified alphanumeric keys ('A', '1', etc.) are not permissible shortcuts.
bSaveSettingsif true, the settings will also be saved back to the *uirc file which they were intially read from.

Definition at line 755 of file kxmlguifactory.cpp.

QWidget * KXMLGUIFactory::container ( const QString &  containerName,
KXMLGUIClient *  client,
bool  useTagName = false 
)

Use this method to get access to a container widget with the name specified with containerName and which is owned by the client.

The container name is specified with a "name" attribute in the XML document.

This function is particularly useful for getting hold of a popupmenu defined in an XMLUI file. For instance:

QMenu *popup = static_cast<QMenu*>(guiFactory()->container("my_popup",this));

where "my_popup" is the name of the menu in the XMLUI file, and "this" is XMLGUIClient which owns the popupmenu (e.g. the mainwindow, or the part, or the plugin...)

Parameters
containerNameName of the container widget
clientOwner of the container widget
useTagNameSpecifies whether to compare the specified name with the name attribute or the tag name.

This method may return 0 if no container with the given name exists or is not owned by the client.

Definition at line 474 of file kxmlguifactory.cpp.

QList< QWidget * > KXMLGUIFactory::containers ( const QString &  tagName)

Definition at line 491 of file kxmlguifactory.cpp.

QDomElement KXMLGUIFactory::findActionByName ( QDomElement &  elem,
const QString &  sName,
bool  create 
)
static

Find or create the element for a given action, by name. Used when saving custom action properties

Definition at line 783 of file kxmlguifactory.cpp.

void KXMLGUIFactory::makingChanges ( bool  )
signal

Emitted when the factory is currently making changes to the GUI, i.e.

adding or removing clients. makingChanges(true) is emitted before any change happens, and makingChanges(false) is emitted after the change is done. This allows e.g. KMainWindow to know that the GUI is being changed programmatically and not by the user (so there is no reason to save toolbar settings afterwards).

Since
4.1.3
void KXMLGUIFactory::plugActionList ( KXMLGUIClient *  client,
const QString &  name,
const QList< QAction * > &  actionList 
)

Definition at line 564 of file kxmlguifactory.cpp.

QString KXMLGUIFactory::readConfigFile ( const QString &  filename,
const KComponentData &  componentData = KComponentData() 
)
static

Definition at line 117 of file kxmlguifactory.cpp.

void KXMLGUIFactory::refreshActionProperties ( )

Use this method to reset and reread action properties (shortcuts, etc.) for all actions.

This is needed, for example, when you change shortcuts scheme at runtime.

Definition at line 311 of file kxmlguifactory.cpp.

void KXMLGUIFactory::removeClient ( KXMLGUIClient *  client)

Removes the GUI described by the client, by unplugging all provided actions and removing all owned containers (and storing container state information in the given client)

Definition at line 411 of file kxmlguifactory.cpp.

void KXMLGUIFactory::reset ( )

Use this method to free all memory allocated by the KXMLGUIFactory.

This deletes the internal node tree and therefore resets the internal state of the class. Please note that the actual GUI is NOT touched at all, meaning no containers are deleted nor any actions unplugged. That is something you have to do on your own. So use this method only if you know what you are doing :-)

(also note that this will call KXMLGUIClient::setFactory( 0 ) for all inserted clients)

Definition at line 496 of file kxmlguifactory.cpp.

void KXMLGUIFactory::resetContainer ( const QString &  containerName,
bool  useTagName = false 
)

Use this method to free all memory allocated by the KXMLGUIFactory for a specific container, including all child containers and actions.

This deletes the internal node subtree for the specified container. The actual GUI is not touched, no containers are deleted or any actions unplugged. Use this method only if you know what you are doing :-)

(also note that this will call KXMLGUIClient::setFactory( 0 ) for all clients of the container)

Definition at line 503 of file kxmlguifactory.cpp.

bool KXMLGUIFactory::saveConfigFile ( const QDomDocument &  doc,
const QString &  filename,
const KComponentData &  componentData = KComponentData() 
)
static

Definition at line 142 of file kxmlguifactory.cpp.

void KXMLGUIFactory::unplugActionList ( KXMLGUIClient *  client,
const QString &  name 
)

Definition at line 583 of file kxmlguifactory.cpp.


The documentation for this class was generated from the following files:
  • kxmlguifactory.h
  • kxmlguifactory.cpp
This file is part of the KDE documentation.
Documentation copyright © 1996-2014 The KDE developers.
Generated on Tue Oct 14 2014 22:49:18 by doxygen 1.8.7 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.

KDEUI

Skip menu "KDEUI"
  • Main Page
  • Namespace List
  • Namespace Members
  • Alphabetical List
  • Class List
  • Class Hierarchy
  • Class Members
  • File List
  • File Members
  • Modules
  • Related Pages

kdelibs API Reference

Skip menu "kdelibs API Reference"
  • DNSSD
  • Interfaces
  •   KHexEdit
  •   KMediaPlayer
  •   KSpeech
  •   KTextEditor
  • kconf_update
  • KDE3Support
  •   KUnitTest
  • KDECore
  • KDED
  • KDEsu
  • KDEUI
  • KDEWebKit
  • KDocTools
  • KFile
  • KHTML
  • KImgIO
  • KInit
  • kio
  • KIOSlave
  • KJS
  •   KJS-API
  • kjsembed
  •   WTF
  • KNewStuff
  • KParts
  • KPty
  • Kross
  • KUnitConversion
  • KUtils
  • Nepomuk
  • Nepomuk-Core
  • Nepomuk
  • Plasma
  • Solid
  • Sonnet
  • ThreadWeaver

Search



Report problems with this website to our bug tracking system.
Contact the specific authors with questions and comments about the page contents.

KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal