KEditToolBar Class

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

Header: #include <KEditToolBar>
CMake: find_package(KF6 REQUIRED COMPONENTS XmlGui)
target_link_libraries(mytarget PRIVATE KF6::XmlGui)
Inherits: QDialog

Public Functions

KEditToolBar(KActionCollection *collection, QWidget *parent = nullptr)
KEditToolBar(KXMLGUIFactory *factory, QWidget *parent = nullptr)
virtual ~KEditToolBar() override
void setDefaultToolBar(const QString &toolBarName)
void setResourceFile(const QString &file, bool global = true)

Signals

Static Public Members

(since 6.0) void setGlobalDefaultToolBar(const QString &toolBarName)

Detailed Description

This dialog 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.

Typically you do not need to use it directly as KXmlGuiWindow::setupGUI takes care of it.

If you use KXMLGUIClient::plugActionList() you need to overload KXmlGuiWindow::saveNewToolbarConfig() to plug actions again:

void MyClass::saveNewToolbarConfig()
{
    KXmlGuiWindow::saveNewToolbarConfig();
    plugActionList( "list1", list1Actions );
    plugActionList( "list2", list2Actions );
}

When created, KEditToolBar takes a KXMLGUIFactory object, and uses it to find all of the action collections and XML files (there is one of each for the mainwindow, but there could be more, when adding other XMLGUI clients like KParts or plugins). The editor aims to be semi-intelligent about where it assigns any modifications. In other words, it will not write out part specific changes to your application's main XML file.

KXmlGuiWindow and KParts::MainWindow take care of creating KEditToolBar correctly and connecting to its newToolBarConfig slot, but if you really really want to do it yourself, see the KXmlGuiWindow::configureToolbars() and KXmlGuiWindow::saveNewToolbarConfig() code.

"KEditToolBar (example: usage in KWrite)"

Member Function Documentation

[explicit] KEditToolBar::KEditToolBar(KActionCollection *collection, QWidget *parent = nullptr)

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).

collection The collection of actions to work on.

parent The parent of the dialog.

[explicit] KEditToolBar::KEditToolBar(KXMLGUIFactory *factory, QWidget *parent = nullptr)

Main constructor.

The main parameter, factory, is a pointer 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.

Use this like so:

KEditToolBar edit(factory());
if (edit.exec())
// ...

factory Your application's factory object.

parent The usual parent for the dialog.

[override virtual noexcept] KEditToolBar::~KEditToolBar()

Destructor.

[signal] void KEditToolBar::newToolBarConfig()

Emitted when 'Apply' or 'Ok' is clicked or toolbars were reset.

Connect to it to plug action lists and to call applyMainWindowSettings (see sample code in the documentation for this class).

void KEditToolBar::setDefaultToolBar(const QString &toolBarName)

Sets toolBarName as the 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 setGlobalDefaultToolBar.

[static, since 6.0] void KEditToolBar::setGlobalDefaultToolBar(const QString &toolBarName)

Sets toolBarName as the default toolbar which will be auto-selected for all KEditToolBar instances.

Can be overridden on a per-dialog basis by calling setDefaultToolBar( const QString& ) on the dialog.

This function was introduced in 6.0.

void KEditToolBar::setResourceFile(const QString &file, bool global = true)

Sets a new resource file and whether the global resource file should be used.

The name (absolute or relative) of your application's UI resource file is assumed to be share/apps/appname/appnameui.rc, but it can be overridden by calling this method.

The global parameter controls 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).

file The application's local resource file.

global If true, then the global resource file will also be parsed.