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 784 of file kedittoolbar.cpp.

786 : QWidget(parent),
787 d(new KisKEditToolBarWidgetPrivate(this, componentName(), collection))
788{
789 d->setupLayout();
790}
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 792 of file kedittoolbar.cpp.

793 : QWidget(parent),
795{
796 d->setupLayout();
797}
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 799 of file kedittoolbar.cpp.

800{
801 delete d;
802}

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 1293 of file kedittoolbar.cpp.

1294{
1295 return d->m_collection;
1296}

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 804 of file kedittoolbar.cpp.

805{
806 d->initOldStyle(file, global, defaultToolBar);
807}
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 809 of file kedittoolbar.cpp.

810{
811 d->initFromFactory(factory, defaultToolBar);
812}
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 946 of file kedittoolbar.cpp.

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

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