|
Krita Source Code Documentation
|
#include <kxmlguiclient.h>
Inheritance diagram for KisKXMLGUIClient:Classes | |
| struct | StateChange |
Public Types | |
| enum | ReverseStateChange { StateNoReverse , StateReverse } |
Public Member Functions | |
| QAction * | action (const char *name) const |
| virtual QAction * | action (const QDomElement &element) const |
| virtual KisKActionCollection * | actionCollection () const |
| void | addStateActionDisabled (const QString &state, const QString &action) |
| void | addStateActionEnabled (const QString &state, const QString &action) |
| void | beginXMLPlug (QWidget *) |
| QList< KisKXMLGUIClient * > | childClients () |
| KisKXMLGUIBuilder * | clientBuilder () const |
| virtual QString | componentName () const |
| virtual QDomDocument | domDocument () const |
| void | endXMLPlug () |
| KisKXMLGUIFactory * | factory () const |
| StateChange | getActionsToChangeForState (const QString &state) |
| void | insertChildClient (KisKXMLGUIClient *child) |
| KisKXMLGUIClient () | |
| KisKXMLGUIClient (KisKXMLGUIClient *parent) | |
| virtual QString | localXMLFile () const |
| KisKXMLGUIClient * | parentClient () const |
| void | plugActionList (const QString &name, const QList< QAction * > &actionList) |
| void | prepareXMLUnplug (QWidget *) |
| void | reloadXML () |
| void | removeChildClient (KisKXMLGUIClient *child) |
| void | replaceXMLFile (const QString &xmlfile, const QString &localxmlfile, bool merge=false) |
| void | setClientBuilder (KisKXMLGUIBuilder *builder) |
| void | setFactory (KisKXMLGUIFactory *factory) |
| void | setXMLGUIBuildDocument (const QDomDocument &doc) |
| void | unplugActionList (const QString &name) |
| virtual QString | xmlFile () const |
| QDomDocument | xmlguiBuildDocument () const |
| virtual | ~KisKXMLGUIClient () |
Static Public Member Functions | |
| static QString | findMostRecentXMLFile (const QStringList &files, QString &doc) |
Protected Member Functions | |
| void | loadStandardsXmlFile () |
| virtual void | setComponentName (const QString &componentName, const QString &componentDisplayName) |
| void | setDOMDocument (const QDomDocument &document, bool merge=false) |
| void | setLocalXMLFile (const QString &file) |
| void | setXML (const QString &document, bool merge=false) |
| void | setXMLFile (const QString &file, bool merge=false, bool setXMLDoc=true) |
| virtual void | stateChanged (const QString &newstate, ReverseStateChange reverse=StateNoReverse) |
| virtual void | virtual_hook (int id, void *data) |
Static Protected Member Functions | |
| static QString | standardsXmlFileLocation () |
Private Attributes | |
| KisKXMLGUIClientPrivate *const | d |
Friends | |
| class | KDEPrivate::KisKEditToolBarWidget |
A KisKXMLGUIClient can be used with KisKXMLGUIFactory to create a GUI from actions and an XML document, and can be dynamically merged with other KisKXMLGUIClients.
Definition at line 36 of file kxmlguiclient.h.
| KisKXMLGUIClient::KisKXMLGUIClient | ( | ) |
Constructs a KisKXMLGUIClient which can be used with a KisKXMLGUIFactory to create a GUI from actions and an XML document, and which can be dynamically merged with other KisKXMLGUIClients.
Definition at line 76 of file kxmlguiclient.cpp.
|
explicit |
Constructs a KisKXMLGUIClient which can be used with a KisKXMLGUIFactory to create a GUI from actions and an XML document, and which can be dynamically merged with other KisKXMLGUIClients.
This constructor takes an additional parent argument, which makes the client a child client of the parent.
Child clients are automatically added to the GUI if the parent is added.
Definition at line 81 of file kxmlguiclient.cpp.
|
virtual |
Destructs the KisKXMLGUIClient.
If the client was in a factory, the factory is NOT informed about the client being removed. This is a feature, it makes window destruction fast (the xmlgui is not updated for every client being deleted), but if you want to simply remove one client and to keep using the window, make sure to call factory->removeClient(client) before deleting the client.
Definition at line 87 of file kxmlguiclient.cpp.
References d, KisKXMLGUIClientPrivate::m_actionCollection, KisKXMLGUIClientPrivate::m_children, KisKXMLGUIClientPrivate::m_factory, KisKXMLGUIClientPrivate::m_parent, and removeChildClient().
| QAction * KisKXMLGUIClient::action | ( | const char * | name | ) | const |
Retrieves an action of the client by name. If not found, it looks in its child clients. This method is provided for convenience, as it uses actionCollection() to get the action object.
Definition at line 110 of file kxmlguiclient.cpp.
References KisKActionCollection::action(), actionCollection(), d, and KisKXMLGUIClientPrivate::m_children.
|
virtual |
Retrieves an action for a given QDomElement. The default implementation uses the "name" attribute to query the action object via the other action() method.
Definition at line 133 of file kxmlguiclient.cpp.
References KisKActionCollection::action(), and actionCollection().
|
virtual |
Retrieves the entire action collection for the GUI client.
Reimplemented in KDEPrivate::KisKEditToolBarWidget.
Definition at line 124 of file kxmlguiclient.cpp.
References d, and KisKXMLGUIClientPrivate::m_actionCollection.
| void KisKXMLGUIClient::addStateActionDisabled | ( | const QString & | state, |
| const QString & | action ) |
Definition at line 732 of file kxmlguiclient.cpp.
References action(), KisKXMLGUIClient::StateChange::actionsToDisable, d, getActionsToChangeForState(), and KisKXMLGUIClientPrivate::m_actionsStateMap.
| void KisKXMLGUIClient::addStateActionEnabled | ( | const QString & | state, |
| const QString & | action ) |
Definition at line 721 of file kxmlguiclient.cpp.
References action(), KisKXMLGUIClient::StateChange::actionsToEnable, d, getActionsToChangeForState(), and KisKXMLGUIClientPrivate::m_actionsStateMap.
| void KisKXMLGUIClient::beginXMLPlug | ( | QWidget * | w | ) |
Definition at line 779 of file kxmlguiclient.cpp.
References actionCollection(), KisKActionCollection::addAssociatedWidget(), beginXMLPlug(), d, and KisKXMLGUIClientPrivate::m_children.
| QList< KisKXMLGUIClient * > KisKXMLGUIClient::childClients | ( | ) |
Retrieves a list of all child clients.
Definition at line 681 of file kxmlguiclient.cpp.
References d, and KisKXMLGUIClientPrivate::m_children.
| KisKXMLGUIBuilder * KisKXMLGUIClient::clientBuilder | ( | ) | const |
Retrieves the client's GUI builder or 0 if no client specific builder has been assigned via setClientBuilder()
Definition at line 691 of file kxmlguiclient.cpp.
References d, and KisKXMLGUIClientPrivate::m_builder.
|
virtual |
Definition at line 138 of file kxmlguiclient.cpp.
References d, and KisKXMLGUIClientPrivate::m_componentName.
|
virtual |
Definition at line 143 of file kxmlguiclient.cpp.
References d, and KisKXMLGUIClientPrivate::m_doc.
| void KisKXMLGUIClient::endXMLPlug | ( | ) |
Definition at line 787 of file kxmlguiclient.cpp.
| KisKXMLGUIFactory * KisKXMLGUIClient::factory | ( | ) | const |
Retrieves a pointer to the KisKXMLGUIFactory this client is associated with (will return 0 if the client's GUI has not been built by a KisKXMLGUIFactory.
Definition at line 647 of file kxmlguiclient.cpp.
References d, and KisKXMLGUIClientPrivate::m_factory.
|
static |
Definition at line 714 of file kxmlguiclient.cpp.
References KXmlGuiVersionHandler::finalDocument(), and KXmlGuiVersionHandler::finalFile().
| KisKXMLGUIClient::StateChange KisKXMLGUIClient::getActionsToChangeForState | ( | const QString & | state | ) |
Definition at line 743 of file kxmlguiclient.cpp.
References d, and KisKXMLGUIClientPrivate::m_actionsStateMap.
| void KisKXMLGUIClient::insertChildClient | ( | KisKXMLGUIClient * | child | ) |
Use this method to make a client a child client of another client. Usually you don't need to call this method, as it is called automatically when using the second constructor, which takes a parent argument.
Definition at line 657 of file kxmlguiclient.cpp.
References d, KisKXMLGUIClientPrivate::m_children, KisKXMLGUIClientPrivate::m_parent, and removeChildClient().
|
protected |
Load the ui_standards.xmlgui file. Usually followed by setXMLFile(xmlFile, true), for merging.
Definition at line 203 of file kxmlguiclient.cpp.
References KisKXMLGUIFactory::readConfigFile(), setXML(), and standardsXmlFileLocation().
|
virtual |
Definition at line 153 of file kxmlguiclient.cpp.
References componentName(), d, KisKXMLGUIClientPrivate::m_localXMLFile, and KisKXMLGUIClientPrivate::m_xmlFile.
| KisKXMLGUIClient * KisKXMLGUIClient::parentClient | ( | ) | const |
KisKXMLGUIClients can form a simple child/parent object tree. This method returns a pointer to the parent client or 0 if it has no parent client assigned.
Definition at line 652 of file kxmlguiclient.cpp.
References d, and KisKXMLGUIClientPrivate::m_parent.
| void KisKXMLGUIClient::plugActionList | ( | const QString & | name, |
| const QList< QAction * > & | actionList ) |
ActionLists are a way for XMLGUI to support dynamic lists of actions. E.g. if you are writing a file manager, and there is a menu file whose contents depend on the mimetype of the file that is selected, then you can achieve this using ActionLists. It works as follows: In your xxxui.xmlgui file ( the one that you set in setXMLFile() / pass to setupGUI() ), you put a tag <ActionList name="xxx">.
Example:
This tag will get expanded to a list of actions. In the example above ( a file manager with a dynamic file menu ), you would call
every time a file is selected, unselected or ...
Definition at line 696 of file kxmlguiclient.cpp.
References d, and KisKXMLGUIClientPrivate::m_factory.
| void KisKXMLGUIClient::prepareXMLUnplug | ( | QWidget * | w | ) |
Definition at line 791 of file kxmlguiclient.cpp.
References actionCollection(), d, KisKXMLGUIClientPrivate::m_children, prepareXMLUnplug(), and KisKActionCollection::removeAssociatedWidget().
| void KisKXMLGUIClient::reloadXML | ( | ) |
Forces this client to re-read its XML resource file. This is intended to be used when you know that the resource file has changed and you will soon be rebuilding the GUI. This will only have an effect if the client is then removed and re-added to the factory.
This method is only for child clients, do not call it for a mainwindow! For a mainwindow, use loadStandardsXmlFile + setXmlFile(xmlFile()) instead.
Definition at line 171 of file kxmlguiclient.cpp.
References setXMLFile(), and xmlFile().
| void KisKXMLGUIClient::removeChildClient | ( | KisKXMLGUIClient * | child | ) |
Removes the given child from the client's children list.
Definition at line 666 of file kxmlguiclient.cpp.
References d, KisKXMLGUIClientPrivate::m_children, and KisKXMLGUIClientPrivate::m_parent.
| void KisKXMLGUIClient::replaceXMLFile | ( | const QString & | xmlfile, |
| const QString & | localxmlfile, | ||
| bool | merge = false ) |
Sets a new xmlFile() and localXMLFile(). The purpose of this public method is to allow non-inherited objects to replace the ui definition of an embedded client with a customized version. It corresponds to the usual calls to setXMLFile() and setLocalXMLFile().
| xmlfile | The xml file to use. Contrary to setXMLFile(), this must be an absolute file path. |
| localxmlfile | The local xml file to set. This should be the full path to a writeable file, usually using QStandardPaths::writableLocation. You can set this to QString(), but no user changes to shortcuts / toolbars will be possible in this case. |
| merge | Whether to merge with the global document |
Definition at line 273 of file kxmlguiclient.cpp.
References setLocalXMLFile(), and setXMLFile().
| void KisKXMLGUIClient::setClientBuilder | ( | KisKXMLGUIBuilder * | builder | ) |
A client can have an own KisKXMLGUIBuilder. Use this method to assign your builder instance to the client (so that the KisKXMLGUIFactory can use it when building the client's GUI)
Client specific guibuilders are useful if you want to create custom container widgets for your GUI.
Definition at line 686 of file kxmlguiclient.cpp.
References d, and KisKXMLGUIClientPrivate::m_builder.
|
protectedvirtual |
Sets the component name for this part.
Call this first in the inherited class constructor. (At least before setXMLFile().)
| componentName | the name of the directory where the XMLGUI files will be found |
| componentDisplayName | a user-visible name (e.g. for the toolbar editor) |
Definition at line 182 of file kxmlguiclient.cpp.
References actionCollection(), componentName(), d, KisKXMLGUIClientPrivate::m_builder, KisKXMLGUIClientPrivate::m_componentName, KisKXMLGUIBuilder::setBuilderClient(), KisKActionCollection::setComponentDisplayName(), and KisKActionCollection::setComponentName().
|
protected |
Sets the Document for the part, describing the layout of the GUI.
Call this in the Part-inherited class constructor if you don't call setXMLFile or setXML.
WARNING: using this method is not recommended. Many code paths lead to reloading from the XML file on disk. And editing toolbars requires that the result is written to disk anyway, and loaded from there the next time.
For application-specific changes to a client's XML, it is a better idea to save the modified dom document to an app/default-client.xml and define a local-xml-file to something specific like app/local-client.xml, using replaceXMLFile. See kdepimlibs/kontactinterface/plugin.cpp for an example.
Definition at line 335 of file kxmlguiclient.cpp.
References actionCollection(), d, KisKXMLGUIClientPrivate::m_doc, KisKXMLGUIClientPrivate::mergeXML(), and setXMLGUIBuildDocument().
| void KisKXMLGUIClient::setFactory | ( | KisKXMLGUIFactory * | factory | ) |
This method is called by the KisKXMLGUIFactory as soon as the client is added to the KisKXMLGUIFactory's GUI.
Definition at line 642 of file kxmlguiclient.cpp.
References d, factory(), and KisKXMLGUIClientPrivate::m_factory.
|
protected |
Set the full path to the "local" xml file, the one used for saving toolbar and shortcut changes. You normally don't need to call this, if you pass a simple filename to setXMLFile.
Definition at line 268 of file kxmlguiclient.cpp.
References d, and KisKXMLGUIClientPrivate::m_localXMLFile.
|
protected |
Sets the XML for the part.
Call this in the Part-inherited class constructor if you don't call setXMLFile().
Definition at line 313 of file kxmlguiclient.cpp.
References d, KisKXMLGUIClientPrivate::m_textTagNames, propagateTranslationDomain(), and setDOMDocument().
|
protected |
Sets the name of the rc file containing the XML for the part.
Call this in the inherited class constructor, for parts and plugins. NOTE: for mainwindows, don't call this, pass the name of the xml file to KXmlGuiWindow::setupGUI() or KXmlGuiWindow::createGUI().
| file | Either an absolute path for the file, or simply the filename. See below for details. If you pass an absolute path here, make sure to also call setLocalXMLFile, otherwise toolbar editing won't work. |
| merge | Whether to merge with the global document. |
| setXMLDoc | Specify whether to call setXML. Default is true. |
The preferred way to call this method is with a simple filename for the file argument.
Since KF 5.1, the file will then be assumed to be installed in DATADIR/kxmlgui5/, under a directory named after the component name. You should use ${KisKXMLGUI_INSTALL_DIR}/componentname in your CMakeLists.txt file, to install the .xmlgui file(s).
Since KF 5.4, the file will then be assumed to be installed in a Qt resource in :/kxmlgui5/, under a directory named after the component name.
Compatibility notes: Fallback lookups exist to older locations: DATADIR/componentname/file and DATADIR/file. The latter was there so that setXMLFile("componentname/filename") worked (but this was undocumented). Do not do this anymore after porting to KisKXMLGUI_INSTALL_DIR, use setComponentName("componentname") and setXMLFile("filename").
Definition at line 208 of file kxmlguiclient.cpp.
References componentName(), d, findMostRecentXMLFile(), KisKXMLGUIClientPrivate::m_localXMLFile, KisKXMLGUIClientPrivate::m_xmlFile, and setXML().
| void KisKXMLGUIClient::setXMLGUIBuildDocument | ( | const QDomDocument & | doc | ) |
Definition at line 632 of file kxmlguiclient.cpp.
References d, and KisKXMLGUIClientPrivate::m_buildDocument.
|
staticprotected |
Return the full path to the ui_standards.xmlgui, might return a resource path.
Definition at line 192 of file kxmlguiclient.cpp.
|
protectedvirtual |
Actions can collectively be assigned a "State". To accomplish this the respective actions are tagged as <enable> or <disable> in a <State> </State> group of the XMLfile. During program execution the programmer can call stateChanged() to set actions to a defined state.
| newstate | Name of a State in the XMLfile. |
| reverse | If the flag reverse is set to StateReverse, the State is reversed. (actions to be enabled will be disabled and action to be disabled will be enabled) Default is reverse=false. |
Definition at line 748 of file kxmlguiclient.cpp.
References action(), KisKActionCollection::action(), actionCollection(), KisKXMLGUIClient::StateChange::actionsToDisable, KisKXMLGUIClient::StateChange::actionsToEnable, getActionsToChangeForState(), and StateNoReverse.
| void KisKXMLGUIClient::unplugActionList | ( | const QString & | name | ) |
Unplugs the action list name from the XMLGUI. Calling this removes the specified action list, i.e. this is the complement to plugActionList(). See plugActionList() for a more detailed example.
Definition at line 705 of file kxmlguiclient.cpp.
References d, and KisKXMLGUIClientPrivate::m_factory.
Definition at line 799 of file kxmlguiclient.cpp.
|
virtual |
This will return the name of the XML file as set by setXMLFile(). If setXML() is used directly, then this will return 0.
The filename that this returns is obvious for components as each component has exactly one XML file. In non-components, however, there are usually two: the global file and the local file. This function doesn't really care about that, though. It will always return the last XML file set. This, in almost all cases, will be the local XML file.
Definition at line 148 of file kxmlguiclient.cpp.
References d, and KisKXMLGUIClientPrivate::m_xmlFile.
| QDomDocument KisKXMLGUIClient::xmlguiBuildDocument | ( | ) | const |
Definition at line 637 of file kxmlguiclient.cpp.
References d, and KisKXMLGUIClientPrivate::m_buildDocument.
|
friend |
Definition at line 38 of file kxmlguiclient.h.
|
private |
Definition at line 395 of file kxmlguiclient.h.