Krita Source Code Documentation
Loading...
Searching...
No Matches
KDEPrivate::KisKEditToolBarWidget Class Reference

A widget used to customize or configure toolbars. More...

#include <kedittoolbar_p.h>

+ Inheritance diagram for KDEPrivate::KisKEditToolBarWidget:

Signals

void enableOk (bool)
 

Public Member Functions

KisKActionCollectionactionCollection () const override
 
 KisKEditToolBarWidget (KisKActionCollection *collection, QWidget *parent=0L)
 
 KisKEditToolBarWidget (QWidget *parent=0L)
 
void load (const QString &resourceFile, bool global=true, const QString &defaultToolBar=QString())
 
void load (KisKXMLGUIFactory *factory, const QString &defaultToolBar=QString())
 
void rebuildKisKXMLGUIClients ()
 
void save ()
 
 ~KisKEditToolBarWidget () override
 
- Public Member Functions inherited from KisKXMLGUIClient
QAction * action (const char *name) const
 
virtual QAction * action (const QDomElement &element) const
 
void addStateActionDisabled (const QString &state, const QString &action)
 
void addStateActionEnabled (const QString &state, const QString &action)
 
void beginXMLPlug (QWidget *)
 
QList< KisKXMLGUIClient * > childClients ()
 
KisKXMLGUIBuilderclientBuilder () const
 
virtual QString componentName () const
 
virtual QDomDocument domDocument () const
 
void endXMLPlug ()
 
KisKXMLGUIFactoryfactory () const
 
StateChange getActionsToChangeForState (const QString &state)
 
void insertChildClient (KisKXMLGUIClient *child)
 
 KisKXMLGUIClient ()
 
 KisKXMLGUIClient (KisKXMLGUIClient *parent)
 
virtual QString localXMLFile () const
 
KisKXMLGUIClientparentClient () 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 ()
 

Private Attributes

KisKEditToolBarWidgetPrivate *const d
 

Friends

class KisKEditToolBarWidgetPrivate
 

Additional Inherited Members

- Public Types inherited from KisKXMLGUIClient
enum  ReverseStateChange { StateNoReverse , StateReverse }
 
- Static Public Member Functions inherited from KisKXMLGUIClient
static QString findMostRecentXMLFile (const QStringList &files, QString &doc)
 
- Protected Member Functions inherited from KisKXMLGUIClient
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 inherited from KisKXMLGUIClient
static QString standardsXmlFileLocation ()
 

Detailed Description

A widget used to customize or configure toolbars.

This is the widget that does all of the work for the KisKEditToolBar dialog. In most cases, you will want to use the dialog instead of this widget directly.

Typically, you would use this widget only if you wanted to embed the toolbar editing directly into your existing configure or preferences dialog.

This widget only works if your application uses the XML UI framework for creating menus and toolbars. It depends on the XML files to describe the toolbar layouts and it requires the actions to determine which buttons are active.

Author
Kurt Granroth granr.nosp@m.oth@.nosp@m.kde.o.nosp@m.rg

Definition at line 114 of file kedittoolbar_p.h.

Constructor & Destructor Documentation

◆ KisKEditToolBarWidget() [1/2]

KisKEditToolBarWidget::KisKEditToolBarWidget ( KisKActionCollection * collection,
QWidget * parent = 0L )
explicit

Old constructor for apps that do not use components. This constructor is somewhat deprecated, since it doesn't work with any KXMLGuiClient being added to the mainwindow. You really want to use the other constructor.

You must pass along your collection of actions (some of which appear in your toolbars). Then call old-style load.

Parameters
collectionThe collection of actions to work on
parentThis widget's parent

Definition at line 782 of file kedittoolbar.cpp.

784 : QWidget(parent),
785 d(new KisKEditToolBarWidgetPrivate(this, componentName(), collection))
786{
787 d->setupLayout();
788}
KisKEditToolBarWidgetPrivate *const d
virtual QString componentName() const

References d, and KDEPrivate::KisKEditToolBarWidgetPrivate::setupLayout().

◆ KisKEditToolBarWidget() [2/2]

KisKEditToolBarWidget::KisKEditToolBarWidget ( QWidget * parent = 0L)
explicit

Main constructor.

Use this like so:

KisKEditToolBarWidget widget(this);
widget.load(factory());
...
A widget used to customize or configure toolbars.
KisKXMLGUIFactory * factory() const
Parameters
parentThis widget's parent

Definition at line 790 of file kedittoolbar.cpp.

791 : QWidget(parent),
793{
794 d->setupLayout();
795}
virtual KisKActionCollection * actionCollection() const

References d, and KDEPrivate::KisKEditToolBarWidgetPrivate::setupLayout().

◆ ~KisKEditToolBarWidget()

KisKEditToolBarWidget::~KisKEditToolBarWidget ( )
override

Destructor. Note that any changes done in this widget will NOT be saved in the destructor. You must call save() to do that.

Definition at line 797 of file kedittoolbar.cpp.

798{
799 delete d;
800}

References d.

Member Function Documentation

◆ actionCollection()

KisKActionCollection * KisKEditToolBarWidget::actionCollection ( ) const
overridevirtual

Retrieves the entire action collection for the GUI client.

Reimplemented from KisKXMLGUIClient.

Definition at line 1291 of file kedittoolbar.cpp.

1292{
1293 return d->m_collection;
1294}

References d, and KDEPrivate::KisKEditToolBarWidgetPrivate::m_collection.

◆ enableOk

void KDEPrivate::KisKEditToolBarWidget::enableOk ( bool )
signal

Emitted whenever any modifications are made by the user.

◆ load() [1/2]

void KisKEditToolBarWidget::load ( const QString & resourceFile,
bool global = true,
const QString & defaultToolBar = QString() )

Old-style load.

Loads the toolbar configuration into the widget. Should be called before being shown.

Parameters
resourceFilethe name (absolute or relative) of your application's UI resource file. If it is left blank, then the resource file: share/apps/appname/appnameui.xmlgui is used. This is the same resource file that is used by the default createGUI function in KisKMainWindow so you're usually pretty safe in leaving it blank.
globalcontrols whether or not the global resource file is used. If this is true, then you may edit all of the actions in your toolbars – global ones and local one. If it is false, then you may edit only your application's entries. The only time you should set this to false is if your application does not use the global resource file at all (very rare)
defaultToolBarthe default toolbar that will be selected when the dialog is shown. If not set, or QString() is passed in, the global default tool bar name will be used.
See also
KisKEditToolBar

Definition at line 802 of file kedittoolbar.cpp.

803{
804 d->initOldStyle(file, global, defaultToolBar);
805}
void initOldStyle(const QString &file, bool global, const QString &defaultToolbar)

References d, and KDEPrivate::KisKEditToolBarWidgetPrivate::initOldStyle().

◆ load() [2/2]

void KisKEditToolBarWidget::load ( KisKXMLGUIFactory * factory,
const QString & defaultToolBar = QString() )

Loads the toolbar configuration into the widget. Should be called before being shown.

Parameters
factorypointer to the XML GUI factory object for your application. It contains a list of all of the GUI clients (along with the action collections and xml files) and the toolbar editor uses that.
defaultToolBarthe default toolbar that will be selected when the dialog is shown. If not set, or QString() is passed in, the global default tool bar name will be used.
See also
KisKEditToolBar

Definition at line 807 of file kedittoolbar.cpp.

808{
809 d->initFromFactory(factory, defaultToolBar);
810}
void initFromFactory(KisKXMLGUIFactory *factory, const QString &defaultToolbar)

References d, KisKXMLGUIClient::factory(), and KDEPrivate::KisKEditToolBarWidgetPrivate::initFromFactory().

◆ rebuildKisKXMLGUIClients()

void KisKEditToolBarWidget::rebuildKisKXMLGUIClients ( )

Remove and readd all KMXLGUIClients to update the GUI

Definition at line 944 of file kedittoolbar.cpp.

945{
946 if (!d->m_factory) {
947 return;
948 }
949
950 const QList<KisKXMLGUIClient *> clients = d->m_factory->clients();
951 //qDebug(240) << "factory: " << clients.count() << " clients";
952
953 // remove the elements starting from the last going to the first
954 if (!clients.count()) {
955 return;
956 }
957
958 QListIterator<KisKXMLGUIClient *> clientIterator = clients;
959 clientIterator.toBack();
960 while (clientIterator.hasPrevious()) {
961 KisKXMLGUIClient *client = clientIterator.previous();
962 //qDebug(240) << "factory->removeClient " << client;
963 d->m_factory->removeClient(client);
964 }
965
966 KisKXMLGUIClient *firstClient = clients.first();
967
968 // now, rebuild the gui from the first to the last
969 //qDebug(240) << "rebuilding the gui";
970 foreach (KisKXMLGUIClient *client, clients) {
971 //qDebug(240) << "updating client " << client << " " << client->componentName() << " xmlFile=" << client->xmlFile();
972 QString file(client->xmlFile()); // before setting ui_standards!
973 if (!file.isEmpty()) {
974 // passing an empty stream forces the clients to reread the XML
975 client->setXMLGUIBuildDocument(QDomDocument());
976
977 // for the shell, merge in ui_standards.xmlgui
978 if (client == firstClient) { // same assumption as in the ctor: first==shell
979 client->loadStandardsXmlFile();
980 }
981
982 // and this forces it to use the *new* XML file
983 client->setXMLFile(file, client == firstClient /* merge if shell */);
984
985 // [we can't use reloadXML, it doesn't load ui_standards.xmlgui]
986 }
987 }
988
989 // Now we can add the clients to the factory
990 // We don't do it in the loop above because adding a part automatically
991 // adds its plugins, so we must make sure the plugins were updated first.
992 foreach (KisKXMLGUIClient *client, clients) {
993 d->m_factory->addClient(client);
994 }
995}
void setXMLGUIBuildDocument(const QDomDocument &doc)
virtual QString xmlFile() const
void setXMLFile(const QString &file, bool merge=false, bool setXMLDoc=true)
void removeClient(KisKXMLGUIClient *client)
void addClient(KisKXMLGUIClient *client)
QList< KisKXMLGUIClient * > clients() const

References KisKXMLGUIFactory::addClient(), KisKXMLGUIFactory::clients(), d, KisKXMLGUIClient::loadStandardsXmlFile(), KDEPrivate::KisKEditToolBarWidgetPrivate::m_factory, KisKXMLGUIFactory::removeClient(), KisKXMLGUIClient::setXMLFile(), KisKXMLGUIClient::setXMLGUIBuildDocument(), and KisKXMLGUIClient::xmlFile().

◆ save()

void KisKEditToolBarWidget::save ( )

Save any changes the user made. The file will be in the user's local directory (usually $HOME/.kde/share/apps/<appname>). The filename will be the one specified in the constructor.. or the made up one if the filename was NULL.

Definition at line 904 of file kedittoolbar.cpp.

905{
906 //qDebug(240) << "KisKEditToolBarWidget::save";
908 for (; it != d->m_xmlFiles.end(); ++it) {
909 // let's not save non-modified files
910 if (!((*it).m_isModified)) {
911 continue;
912 }
913
914 // let's also skip (nonexistent) merged files
915 if ((*it).type() == XmlData::Merged) {
916 continue;
917 }
918
919 // Add noMerge="1" to all the menus since we are saving the merged data
920 QDomNodeList menuNodes = (*it).domDocument().elementsByTagName(QStringLiteral("Menu"));
921 for (int i = 0; i < menuNodes.length(); ++i) {
922 QDomNode menuNode = menuNodes.item(i);
923 QDomElement menuElement = menuNode.toElement();
924 if (menuElement.isNull()) {
925 continue;
926 }
927 menuElement.setAttribute(QStringLiteral("noMerge"), QLatin1String("1"));
928 }
929
930 //qDebug() << (*it).domDocument().toString();
931
932 //qDebug(240) << "Saving " << (*it).xmlFile();
933 // if we got this far, we might as well just save it
934 KisKXMLGUIFactory::saveConfigFile((*it).domDocument(), (*it).xmlFile());
935 }
936
937 if (!d->m_factory) {
938 return;
939 }
940
942}
static bool saveConfigFile(const QDomDocument &doc, const QString &filename, const QString &componentName=QString())

References d, KDEPrivate::KisKEditToolBarWidgetPrivate::m_factory, KDEPrivate::KisKEditToolBarWidgetPrivate::m_xmlFiles, KDEPrivate::XmlData::Merged, rebuildKisKXMLGUIClients(), and KisKXMLGUIFactory::saveConfigFile().

Friends And Related Symbol Documentation

◆ KisKEditToolBarWidgetPrivate

friend class KisKEditToolBarWidgetPrivate
friend

Definition at line 240 of file kedittoolbar_p.h.

Member Data Documentation

◆ d

KisKEditToolBarWidgetPrivate* const KDEPrivate::KisKEditToolBarWidget::d
private

Definition at line 241 of file kedittoolbar_p.h.


The documentation for this class was generated from the following files: