KXMLGUIFactory

Search for usage in LXR

#include <KXMLGUIFactory>

Inheritance diagram for KXMLGUIFactory:

Signals

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

Public Slots

void changeShortcutScheme (const QString &scheme)
 
void showConfigureShortcutsDialog ()
 

Public Member Functions

 KXMLGUIFactory (KXMLGUIBuilder *builder, QObject *parent=nullptr)
 
 ~KXMLGUIFactory () override
 
void addClient (KXMLGUIClient *client)
 
QList< KXMLGUIClient * > clients () const
 
QWidgetcontainer (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)
 
- Public Member Functions inherited from QObject
 QObject (QObject *parent)
 
QBindable< QStringbindableObjectName ()
 
bool blockSignals (bool block)
 
const QObjectListchildren () const const
 
QMetaObject::Connection connect (const QObject *sender, const char *signal, const char *method, Qt::ConnectionType type) const const
 
void deleteLater ()
 
void destroyed (QObject *obj)
 
bool disconnect (const char *signal, const QObject *receiver, const char *method) const const
 
bool disconnect (const QObject *receiver, const char *method) const const
 
void dumpObjectInfo () const const
 
void dumpObjectTree () const const
 
QList< QByteArraydynamicPropertyNames () const const
 
virtual bool event (QEvent *e)
 
virtual bool eventFilter (QObject *watched, QEvent *event)
 
findChild (const QString &name, Qt::FindChildOptions options) const const
 
QList< T > findChildren (const QRegularExpression &re, Qt::FindChildOptions options) const const
 
QList< T > findChildren (const QString &name, Qt::FindChildOptions options) const const
 
QList< T > findChildren (Qt::FindChildOptions options) const const
 
bool inherits (const char *className) const const
 
void installEventFilter (QObject *filterObj)
 
bool isQuickItemType () const const
 
bool isWidgetType () const const
 
bool isWindowType () const const
 
void killTimer (int id)
 
virtual const QMetaObjectmetaObject () const const
 
void moveToThread (QThread *targetThread)
 
QString objectName () const const
 
void objectNameChanged (const QString &objectName)
 
QObjectparent () const const
 
QVariant property (const char *name) const const
 
 Q_CLASSINFO (Name, Value)
 
 Q_EMIT Q_EMIT
 
 Q_ENUM (...)
 
 Q_ENUM_NS (...)
 
 Q_ENUMS (...)
 
 Q_FLAG (...)
 
 Q_FLAG_NS (...)
 
 Q_FLAGS (...)
 
 Q_GADGET Q_GADGET
 
 Q_GADGET_EXPORT (EXPORT_MACRO)
 
 Q_INTERFACES (...)
 
 Q_INVOKABLE Q_INVOKABLE
 
 Q_MOC_INCLUDE Q_MOC_INCLUDE
 
 Q_NAMESPACE Q_NAMESPACE
 
 Q_NAMESPACE_EXPORT (EXPORT_MACRO)
 
 Q_OBJECT Q_OBJECT
 
 Q_PROPERTY (...)
 
 Q_REVISION Q_REVISION
 
 Q_SET_OBJECT_NAME (Object)
 
 Q_SIGNAL Q_SIGNAL
 
 Q_SIGNALS Q_SIGNALS
 
 Q_SLOT Q_SLOT
 
 Q_SLOTS Q_SLOTS
 
qobject_cast (const QObject *object)
 
qobject_cast (QObject *object)
 
 QT_NO_NARROWING_CONVERSIONS_IN_CONNECT QT_NO_NARROWING_CONVERSIONS_IN_CONNECT
 
void removeEventFilter (QObject *obj)
 
void setObjectName (const QString &name)
 
void setObjectName (QAnyStringView name)
 
void setParent (QObject *parent)
 
bool setProperty (const char *name, const QVariant &value)
 
bool setProperty (const char *name, QVariant &&value)
 
bool signalsBlocked () const const
 
int startTimer (int interval, Qt::TimerType timerType)
 
int startTimer (std::chrono::milliseconds interval, Qt::TimerType timerType)
 
QThreadthread () const const
 

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 QString &componentName=QString())
 
static bool saveConfigFile (const QDomDocument &doc, const QString &filename, const QString &componentName=QString())
 
- Static Public Member Functions inherited from QObject
QMetaObject::Connection connect (const QObject *sender, const char *signal, const QObject *receiver, const char *method, Qt::ConnectionType type)
 
QMetaObject::Connection connect (const QObject *sender, const QMetaMethod &signal, const QObject *receiver, const QMetaMethod &method, Qt::ConnectionType type)
 
QMetaObject::Connection connect (const QObject *sender, PointerToMemberFunction signal, const QObject *context, Functor functor, Qt::ConnectionType type)
 
QMetaObject::Connection connect (const QObject *sender, PointerToMemberFunction signal, const QObject *receiver, PointerToMemberFunction method, Qt::ConnectionType type)
 
QMetaObject::Connection connect (const QObject *sender, PointerToMemberFunction signal, Functor functor)
 
bool disconnect (const QMetaObject::Connection &connection)
 
bool disconnect (const QObject *sender, const char *signal, const QObject *receiver, const char *method)
 
bool disconnect (const QObject *sender, const QMetaMethod &signal, const QObject *receiver, const QMetaMethod &method)
 
bool disconnect (const QObject *sender, PointerToMemberFunction signal, const QObject *receiver, PointerToMemberFunction method)
 
QString tr (const char *sourceText, const char *disambiguation, int n)
 

Additional Inherited Members

- Public Types inherited from QObject
typedef  QObjectList
 
- Properties inherited from QObject
 objectName
 
- Protected Member Functions inherited from QObject
virtual void childEvent (QChildEvent *event)
 
virtual void connectNotify (const QMetaMethod &signal)
 
virtual void customEvent (QEvent *event)
 
virtual void disconnectNotify (const QMetaMethod &signal)
 
bool isSignalConnected (const QMetaMethod &signal) const const
 
int receivers (const char *signal) const const
 
QObjectsender () const const
 
int senderSignalIndex () const const
 
virtual void timerEvent (QTimerEvent *event)
 

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 55 of file kxmlguifactory.h.

Constructor & Destructor Documentation

◆ KXMLGUIFactory()

KXMLGUIFactory::KXMLGUIFactory ( KXMLGUIBuilder * builder,
QObject * parent = nullptr )
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 147 of file kxmlguifactory.cpp.

◆ ~KXMLGUIFactory()

KXMLGUIFactory::~KXMLGUIFactory ( )
override

Destructor.

Definition at line 161 of file kxmlguifactory.cpp.

Member Function Documentation

◆ actionPropertiesElement()

QDomElement KXMLGUIFactory::actionPropertiesElement ( QDomDocument & doc)
static

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

Definition at line 700 of file kxmlguifactory.cpp.

◆ addClient()

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 168 of file kxmlguifactory.cpp.

◆ changeShortcutScheme

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

Definition at line 365 of file kxmlguifactory.cpp.

◆ clients()

QList< KXMLGUIClient * > KXMLGUIFactory::clients ( ) const

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

Definition at line 440 of file kxmlguifactory.cpp.

◆ container()

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 nullptr if no container with the given name exists or is not owned by the client.

Definition at line 445 of file kxmlguifactory.cpp.

◆ containers()

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

Definition at line 461 of file kxmlguifactory.cpp.

◆ findActionByName()

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 714 of file kxmlguifactory.cpp.

◆ makingChanges

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

◆ plugActionList()

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

Definition at line 527 of file kxmlguifactory.cpp.

◆ readConfigFile()

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

Definition at line 96 of file kxmlguifactory.cpp.

◆ refreshActionProperties()

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 272 of file kxmlguifactory.cpp.

◆ removeClient()

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 379 of file kxmlguifactory.cpp.

◆ reset()

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(nullptr) for all inserted clients)

Definition at line 466 of file kxmlguifactory.cpp.

◆ resetContainer()

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(nullptr) for all clients of the container)

Definition at line 473 of file kxmlguifactory.cpp.

◆ saveConfigFile()

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

Definition at line 122 of file kxmlguifactory.cpp.

◆ shortcutsSaved

void KXMLGUIFactory::shortcutsSaved ( )
signal

Emitted when the shortcuts have been saved (i.e.

the user accepted the dialog).

If you're using multiple instances of the same KXMLGUIClient, you probably want to connect to this signal and call KXMLGUIClient::reloadXML() for each of your KXMLGUIClients, so that the other instances update their shortcuts settings.

Since
5.79

◆ showConfigureShortcutsDialog

void KXMLGUIFactory::showConfigureShortcutsDialog ( )
slot

Shows a dialog (KShortcutsDialog) that lists every action in this factory, and which can be used to change the shortcuts associated with each action.

This slot can be connected directly to the configure shortcuts action, for example:

void showConfigureShortcutsDialog()
Shows a dialog (KShortcutsDialog) that lists every action in this factory, and which can be used to c...
QAction * keyBindings(const QObject *recvr, const char *slot, QObject *parent)

This method constructs a KShortcutsDialog with the default arguments (KShortcutsEditor::AllActions and KShortcutsEditor::LetterShortcutsAllowed).

See also
KShortcutsDialog, KShortcutsEditor::ActionTypes, KShortcutsEditor::LetterShortcuts

By default the changes will be saved back to the *ui.rc file which they were initially read from.

If you need to run some extra code if the dialog is accepted and the settings are saved, you can simply connect to the KXMLGUIFactory::shortcutsSaved() signal before calling this method, for example:

connect(guiFactory(), &KXMLGUIFactory::shortcutsSaved, this, &MyClass::slotShortcutSaved);
guiFactory()->showConfigureShortcutsDialog();
void shortcutsSaved()
Emitted when the shortcuts have been saved (i.e.
QMetaObject::Connection connect(const QObject *sender, PointerToMemberFunction signal, Functor functor)
Since
5.84

Definition at line 682 of file kxmlguifactory.cpp.

◆ unplugActionList()

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

Definition at line 545 of file kxmlguifactory.cpp.


The documentation for this class was generated from the following files:
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Fri Dec 20 2024 11:54:58 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.