kdeui Library API Documentation

KEditToolbar Class Reference

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

#include <kedittoolbar.h>

Inheritance diagram for KEditToolbar:

Inheritance graph
[legend]
Collaboration diagram for KEditToolbar:

Collaboration graph
[legend]
List of all members.

Signals

void newToolbarConfig ()

Public Member Functions

 KEditToolbar (KActionCollection *collection, const QString &xmlfile=QString::null, bool global=true, QWidget *parent=0, const char *name=0)
 KEditToolbar (const QString &defaultToolbar, KActionCollection *collection, const QString &xmlfile=QString::null, bool global=true, QWidget *parent=0, const char *name=0)
 KEditToolbar (KXMLGUIFactory *factory, QWidget *parent=0, const char *name=0)
 KEditToolbar (const QString &defaultToolbar, KXMLGUIFactory *factory, QWidget *parent=0, const char *name=0)
 ~KEditToolbar ()

Static Public Member Functions

void setDefaultToolbar (const char *toolbarName)

Protected Slots

virtual void slotOk ()
virtual void slotApply ()
void acceptOK (bool b)

Protected Member Functions

virtual void virtual_hook (int id, void *data)

Detailed Description

A dialog used to customize or configure toolbars.

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 would include the KStdAction::configureToolbars() standard action in your application. In your slot to this action, you would have something like so:

KEditToolbar dlg(actionCollection()); if (dlg.exec()) { createGUI(); }

That code snippet also takes care of redrawing the menu and toolbars if you have made any changes.

If you are using KMainWindow's settings methods (either save/apply manually or autoSaveSettings), you should write something like:

void MyClass::slotConfigureToolbars() { saveMainWindowSettings( KGlobal::config(), "MainWindow" ); KEditToolbar dlg(actionCollection()); connect(&dlg,SIGNAL(newToolbarConfig()),this,SLOT(slotNewToolbarConfig())); dlg.exec(); } void MyClass::slotNewToolbarConfig() // This is called when OK or Apply is clicked { ...if you use any action list, use plugActionList on each here... createGUI(); applyMainWindowSettings( KGlobal::config(), "MainWindow" ); }

Note that the procedure is a bit different for KParts applications. In this case, you need only pass along a pointer to your application's KXMLGUIFactory object. The editor will take care of finding all of the action collections and XML files. 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 shell's XML file.

An example would be:

saveMainWindowSettings( KGlobal::config(), "MainWindow" ); KEditToolbar dlg(factory()); connect(&dlg,SIGNAL(newToolbarConfig()),this,SLOT(slotNewToolbarConfig())); dlg.exec(); void MyClass::slotNewToolbarConfig() // This is called when OK or Apply is clicked { ...if you use any action list, use plugActionList on each here... // Do NOT call createGUI()! applyMainWindowSettings( KGlobal::config(), "MainWindow" ); }

Author:
Kurt Granroth <granroth@kde.org>
Version:
Id
kedittoolbar.h,v 1.42 2004/10/10 08:07:34 bhards Exp

Definition at line 110 of file kedittoolbar.h.


Constructor & Destructor Documentation

KEditToolbar::KEditToolbar KActionCollection collection,
const QString xmlfile = QString::null,
bool  global = true,
QWidget parent = 0,
const char *  name = 0
 

Constructor for apps that do not use components.

This is the only entry point to this class. You must pass along your collection of actions (some of which appear in your toolbars). The other two parameters are optional.

The second parameter, xmlfile(), is the name (absolute or relative) of your application's UI resource file. If it is left blank, then the resource file: share/apps/appname/appnameui.rc is used. This is the same resource file that is used by the default createGUI() function in KMainWindow so you're usually pretty safe in leaving it blank.

The third parameter, global(), 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).

Parameters:
collection The collection of actions to work on.
xmlfile The application's local resource file.
global If true, then the global resource file will also be parsed.
parent The parent of the dialog.
name An internal name.

Definition at line 371 of file kedittoolbar.cpp.

References KEditToolbar().

Referenced by KEditToolbar().

KEditToolbar::KEditToolbar KXMLGUIFactory factory,
QWidget parent = 0,
const char *  name = 0
 

Constructor for KParts based apps.

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

Parameters:
factory Your application's factory object
parent The usual parent for the dialog.
name An internal name.
Some people seem tempted to use this also in non-KParts apps, using KMainWindow::guiFactory(). This works, but only _if_ setting conserveMemory to false when calling KMainWindow::createGUI()! If not, use the other KEditToolbar constructor.

Definition at line 388 of file kedittoolbar.cpp.

References KEditToolbar().

KEditToolbar::KEditToolbar const QString defaultToolbar,
KXMLGUIFactory factory,
QWidget parent = 0,
const char *  name = 0
 

Constructor for KParts based apps, which has an extra argument specifying the toolbar to be shown.

Parameters:
defaultToolbar The toolbar with this name will appear for editing.
factory Your application's factory object
parent The usual parent for the dialog.
name An internal name.
Since:
3.2

Definition at line 395 of file kedittoolbar.cpp.

References KEditToolbar().

KEditToolbar::~KEditToolbar  ) 
 

destructor

Definition at line 418 of file kedittoolbar.cpp.


Member Function Documentation

void KEditToolbar::setDefaultToolbar const char *  toolbarName  )  [static]
 

Sets the default toolbar, which will be auto-selected when the constructor without the defaultToolbar argument is used.

Parameters:
toolbarName the name of the toolbar
Since:
3.3

Definition at line 454 of file kedittoolbar.cpp.

References setDefaultToolbar().

Referenced by setDefaultToolbar().

void KEditToolbar::slotOk  )  [protected, virtual, slot]
 

Overridden in order to save any changes made to the toolbars.

Reimplemented from KDialogBase.

Definition at line 429 of file kedittoolbar.cpp.

References QDialog::accept(), newToolbarConfig(), QDialog::reject(), and KEditToolbarWidget::save().

void KEditToolbar::slotApply  )  [protected, virtual, slot]
 

idem

Reimplemented from KDialogBase.

Definition at line 447 of file kedittoolbar.cpp.

References newToolbarConfig(), and KEditToolbarWidget::save().

void KEditToolbar::acceptOK bool  b  )  [protected, slot]
 

should OK really save?

Definition at line 423 of file kedittoolbar.cpp.

References acceptOK().

Referenced by acceptOK().

void KEditToolbar::newToolbarConfig  )  [signal]
 

Signal emitted when 'apply' or 'ok' is clicked.

Connect to it, to plug action lists and to call applyMainWindowSettings (see sample code in this class's documentation)

Referenced by slotApply(), and slotOk().


The documentation for this class was generated from the following files:
KDE Logo
This file is part of the documentation for kdeui Library Version 3.4.0.
Documentation copyright © 1996-2004 the KDE developers.
Generated on Tue Apr 12 23:00:13 2005 by doxygen 1.3.7 written by Dimitri van Heesch, © 1997-2003