Krita Source Code Documentation
Loading...
Searching...
No Matches
KXmlGuiWindow Class Reference

KDE top level main window with predefined action layout More...

#include <kxmlguiwindow.h>

+ Inheritance diagram for KXmlGuiWindow:

Public Types

enum  StandardWindowOption {
  ToolBar = 1 , Keys = 2 , StatusBar = 4 , Save = 8 ,
  Create = 16 , Default = ToolBar | Keys | StatusBar | Save | Create
}
 
- Public Types inherited from KisKXMLGUIClient
enum  ReverseStateChange { StateNoReverse , StateReverse }
 

Public Slots

virtual void configureToolbars ()
 
virtual void slotStateChanged (const QString &newstate)
 
void slotStateChanged (const QString &newstate, bool reverse)
 
- Public Slots inherited from KisKMainWindow
void appHelpActivated (void)
 
void setSettingsDirty ()
 

Public Member Functions

void applyMainWindowSettings (const KConfigGroup &config) override
 
void createGUI (const QString &xmlfile=QString())
 
void createStandardStatusBarAction ()
 
void finalizeGUI (bool force)
 
void finalizeGUI (KisKXMLGUIClient *client) override
 
virtual KisKXMLGUIFactoryguiFactory ()
 
bool isHelpMenuEnabled () const
 
bool isStandardToolBarMenuEnabled () const
 
 KXmlGuiWindow (QWidget *parent=0, Qt::WindowFlags f=Qt::WindowFlags())
 
void setHelpMenuEnabled (bool showHelpMenu=true)
 
void setStandardToolBarMenuEnabled (bool enable)
 
void setupGUI (const QSize &defaultSize, StandardWindowOptions options=Default, const QString &xmlfile=QString())
 
void setupGUI (StandardWindowOptions options=Default, const QString &xmlfile=QString())
 
void setupToolbarMenuActions ()
 
QAction * toolBarMenuAction ()
 
 ~KXmlGuiWindow () override
 Destructor.
 
- Public Member Functions inherited from KisKMainWindow
KConfigGroup autoSaveConfigGroup () const
 
QString autoSaveGroup () const
 
bool autoSaveSettings () const
 
QString dbusName () const
 
bool hasMenuBar ()
 
 KisKMainWindow (QWidget *parent=0, Qt::WindowFlags f=Qt::WindowFlags())
 
void resetAutoSaveSettings ()
 
bool restore (int number, bool show=true)
 
void saveMainWindowSettings (KConfigGroup &config)
 
void setAutoSaveSettings (const KConfigGroup &group, bool saveWindowSize=true)
 
void setAutoSaveSettings (const QString &groupName=QLatin1String("MainWindow"), bool saveWindowSize=true)
 
KisToolBartoolBar (const QString &name=QString())
 
QList< KisToolBar * > toolBars () const
 
 ~KisKMainWindow () override
 Destructor.
 
- Public Member Functions inherited from KisKXMLGUIBuilder
KisKXMLGUIClientbuilderClient () const
 
virtual QStringList containerTags () const
 
virtual QWidget * createContainer (QWidget *parent, int index, const QDomElement &element, QAction *&containerAction)
 
virtual QAction * createCustomElement (QWidget *parent, int index, const QDomElement &element)
 
virtual QStringList customTags () const
 
 KisKXMLGUIBuilder (QWidget *widget)
 
virtual void removeContainer (QWidget *container, QWidget *parent, QDomElement &element, QAction *containerAction)
 
virtual void removeCustomElement (QWidget *parent, QAction *action)
 
void setBuilderClient (KisKXMLGUIClient *client)
 
QWidget * widget ()
 
virtual ~KisKXMLGUIBuilder ()
 
- Public Member Functions inherited from KisKXMLGUIClient
QAction * action (const char *name) const
 
virtual QAction * action (const QDomElement &element) const
 
virtual KisKActionCollectionactionCollection () 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 ()
 

Protected Slots

virtual void saveNewToolbarConfig ()
 
- Protected Slots inherited from KisKMainWindow
void saveAutoSaveSettings ()
 

Protected Member Functions

bool event (QEvent *event) override
 
- Protected Member Functions inherited from KisKMainWindow
void closeEvent (QCloseEvent *) override
 
bool event (QEvent *event) override
 
 KisKMainWindow (KisKMainWindowPrivate &dd, QWidget *parent, Qt::WindowFlags f)
 
virtual bool queryClose ()
 
virtual void readGlobalProperties (KConfig *sessionConfig)
 
virtual void readProperties (const KConfigGroup &)
 
bool readPropertiesInternal (KConfig *, int)
 
virtual void saveGlobalProperties (KConfig *sessionConfig)
 
virtual void saveProperties (KConfigGroup &)
 
void savePropertiesInternal (KConfig *, int)
 
bool settingsDirty () const
 
virtual bool windowsLayoutSavingAllowed () const
 
- Protected Member Functions inherited from KisKXMLGUIBuilder
virtual void virtual_hook (int id, void *data)
 
- 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)
 

Properties

QString autoSaveGroup
 
bool autoSaveSettings
 
bool hasMenuBar
 
bool standardToolBarMenuEnabled
 
- Properties inherited from KisKMainWindow
QString autoSaveGroup
 
bool autoSaveSettings
 
bool hasMenuBar
 

Additional Inherited Members

- Static Public Member Functions inherited from KisKMainWindow
static bool canBeRestored (int number)
 
static const QString classNameOfToplevel (int number)
 
static QList< KisKMainWindow * > memberList ()
 
- Static Public Member Functions inherited from KisKXMLGUIClient
static QString findMostRecentXMLFile (const QStringList &files, QString &doc)
 
- Static Protected Member Functions inherited from KisKXMLGUIClient
static QString standardsXmlFileLocation ()
 
- Protected Attributes inherited from KisKMainWindow
KisKMainWindowPrivate *const k_ptr
 

Detailed Description

KDE top level main window with predefined action layout

Instead of creating a KisKMainWindow manually and assigning menus, menu entries, toolbar buttons and actions to it by hand, this class can be used to load an rc file to manage the main window's actions.

See http://techbase.kde.org/Development/Tutorials/Using_KActions#XMLGUI for essential information on the XML file format and usage of this class.

See also
KisKMainWindow
Author
Reginald Stadlbauer (reggi.nosp@m.e@kd.nosp@m.e.org) Stephan Kulow (coolo.nosp@m.@kde.nosp@m..org), Matthias Ettrich (ettri.nosp@m.ch@k.nosp@m.de.or.nosp@m.g), Chris Schlaeger (cs@kd.nosp@m.e.or.nosp@m.g), Sven Radej (radej.nosp@m.@kde.nosp@m..org). Maintained by Sven Radej (radej.nosp@m.@kde.nosp@m..org)

Definition at line 46 of file kxmlguiwindow.h.

Member Enumeration Documentation

◆ StandardWindowOption

See also
setupGUI()
Enumerator
ToolBar 

adds action to show/hide the toolbar(s) and adds action to configure the toolbar(s).

See also
setStandardToolBarMenuEnabled
Keys 

adds action to show the key configure action.

StatusBar 

adds action to show/hide the statusbar if the statusbar exists.

See also
createStandardStatusBarAction
Save 

auto-saves (and loads) the toolbar/menubar/statusbar settings and window size using the default name.

See also
setAutoSaveSettings

Typically you want to let the default window size be determined by the widgets size hints. Make sure that setupGUI() is called after all the widgets are created ( including setCentralWidget ) so the default size's will be correct.

See also
setAutoSaveSettings for more information on this topic.
Create 

calls createGUI() once ToolBar, Keys and Statusbar have been taken care of.

See also
createGUI

NOTE: when using KParts::MainWindow, remove this flag from the setupGUI call, since you'll be using createGUI(part) instead.

void setupGUI(StandardWindowOptions options=Default, const QString &xmlfile=QString())
Default 

All the above option (this is the default)

Definition at line 174 of file kxmlguiwindow.h.

174 {
180 ToolBar = 1,
181
185 Keys = 2,
186
191 StatusBar = 4,
192
203 Save = 8,
204
215 Create = 16,
216
222 };

Constructor & Destructor Documentation

◆ KXmlGuiWindow()

KXmlGuiWindow::KXmlGuiWindow ( QWidget * parent = 0,
Qt::WindowFlags f = Qt::WindowFlags() )
explicit

Construct a main window.

Parameters
parentThe widget parent. This is usually 0 but it may also be the window group leader. In that case, the KisKMainWindow becomes sort of a secondary window.
fSpecify the widget flags. The default is Qt::Window and Qt::WA_DeleteOnClose. Qt::Window indicates that a main window is a toplevel window, regardless of whether it has a parent or not. Qt::WA_DeleteOnClose indicates that a main window is automatically destroyed when its window is closed. Pass 0 if you do not want this behavior.
See also
http://doc.trolltech.com/qt.html#WindowType-enum

KisKMainWindows must be created on the heap with 'new', like:

kmw->setObjectName(...);
KDE top level main window
Definition kmainwindow.h:89
KisKMainWindow(QWidget *parent=0, Qt::WindowFlags f=Qt::WindowFlags())

IMPORTANT: For session management and window management to work properly, all main windows in the application should have a different name. If you don't do it, KisKMainWindow will create a unique name, but it's recommended to explicitly pass a window name that will also describe the type of the window. If there can be several windows of the same type, append '#' (hash) to the name, and KisKMainWindow will replace it with numbers to make the names unique. For example, for a mail client which has one main window showing the mails and folders, and which can also have one or more windows for composing mails, the name for the folders window should be e.g. "mainwindow" and for the composer windows "composer#".

Definition at line 73 of file kxmlguiwindow.cpp.

75{
77 d->showHelpMenu = true;
78 d->toolBarHandler = 0;
79 d->showStatusBarAction = 0;
80 d->factory = 0;
81#ifdef HAVE_DBUS
83#endif
84}
KDE top level main window with predefined action layout
D-Bus interface to KisKMainWindow.
KisKXMLGUIBuilder(QWidget *widget)
KisKXMLGUIBuilderPrivate *const d
#define K_D(Class)

References KisKXMLGUIBuilder::d, and K_D.

◆ ~KXmlGuiWindow()

KXmlGuiWindow::~KXmlGuiWindow ( )
override

Destructor.

Will also destroy the toolbars, and menubar if needed.

Definition at line 104 of file kxmlguiwindow.cpp.

105{
107 delete d->factory;
108}

References KisKXMLGUIBuilder::d, and K_D.

Member Function Documentation

◆ applyMainWindowSettings()

void KXmlGuiWindow::applyMainWindowSettings ( const KConfigGroup & config)
overridevirtual

Read settings for statusbar, menubar and toolbar from their respective groups in the config file and apply them.

Parameters
configConfig group to read the settings from. KF5 porting note: the unused bool argument was removed, make sure to remove it from your reimplementations too! And add a override for good measure.

Reimplemented from KisKMainWindow.

Definition at line 365 of file kxmlguiwindow.cpp.

366{
369 QStatusBar *sb = findChild<QStatusBar *>();
370 if (sb && d->showStatusBarAction) {
371 d->showStatusBarAction->setChecked(!sb->isHidden());
372 }
373}
virtual void applyMainWindowSettings(const KConfigGroup &config)

References KisKMainWindow::applyMainWindowSettings(), KisKXMLGUIBuilder::d, and K_D.

◆ configureToolbars

void KXmlGuiWindow::configureToolbars ( )
virtualslot

Show a standard configure toolbar dialog.

This slot can be connected directly to the action to configure toolbar. This is very simple to do that by adding a single line

virtual void configureToolbars()
virtual KisKActionCollection * actionCollection() const
QAction * configureToolbars(const QObject *recvr, const char *slot, QObject *parent)

Definition at line 149 of file kxmlguiwindow.cpp.

150{
152 KConfigGroup cg(KSharedConfig::openConfig(), "");
154 if (!d->toolBarEditor) {
155 d->toolBarEditor = new KisKEditToolBar(guiFactory(), this);
156 d->toolBarEditor->setAttribute(Qt::WA_DeleteOnClose);
157 connect(d->toolBarEditor, SIGNAL(newToolBarConfig()), SLOT(saveNewToolbarConfig()));
158 }
159 d->toolBarEditor->show();
160}
connect(this, SIGNAL(optionsChanged()), this, SLOT(saveOptions()))
virtual void saveNewToolbarConfig()
virtual KisKXMLGUIFactory * guiFactory()
A dialog used to customize or configure toolbars.
void saveMainWindowSettings(KConfigGroup &config)

References connect(), KisKXMLGUIBuilder::d, guiFactory(), K_D, KisKMainWindow::saveMainWindowSettings(), and saveNewToolbarConfig().

◆ createGUI()

void KXmlGuiWindow::createGUI ( const QString & xmlfile = QString())

Create a GUI given a local XML file. In a regular app you usually want to use setupGUI() instead of this one since it does more things for free like setting up the toolbar/shortcut edit actions, etc.

If xmlfile is 0, then it will try to construct a local XML filename like appnameui.xmlgui where 'appname' is your app's name. If that file does not exist, then the XML UI code will only use the global (standard) XML file for the layout purposes.

Parameters
xmlfileThe local xmlfile (relative or absolute)

Definition at line 216 of file kxmlguiwindow.cpp.

217{
219 // disabling the updates prevents unnecessary redraws
220 //setUpdatesEnabled( false );
221
222 // just in case we are rebuilding, let's remove our old client
223 guiFactory()->removeClient(this);
224
225 // make sure to have an empty GUI
226 QMenuBar *mb = menuBar();
227 if (mb) {
228 mb->clear();
229 }
230
231 qDeleteAll(toolBars()); // delete all toolbars
232
233 // don't build a help menu unless the user ask for it
234 if (d->showHelpMenu) {
235 delete d->helpMenu;
236 // we always want a help menu
237 d->helpMenu = new KisKHelpMenu(this, KAboutData::applicationData(), true);
238
240 QAction *helpContentsAction = d->helpMenu->action(KisKHelpMenu::menuHelpContents);
241 QAction *whatsThisAction = d->helpMenu->action(KisKHelpMenu::menuWhatsThis);
242 QAction *reportBugAction = d->helpMenu->action(KisKHelpMenu::menuReportBug);
243 QAction *switchLanguageAction = d->helpMenu->action(KisKHelpMenu::menuSwitchLanguage);
244 QAction *aboutAppAction = d->helpMenu->action(KisKHelpMenu::menuAboutApp);
245 QAction *aboutKdeAction = d->helpMenu->action(KisKHelpMenu::menuAboutKDE);
246
247 if (helpContentsAction) {
248 actions->addAction(helpContentsAction->objectName(), helpContentsAction);
249 }
250 if (whatsThisAction) {
251 actions->addAction(whatsThisAction->objectName(), whatsThisAction);
252 }
253 if (reportBugAction) {
254 actions->addAction(reportBugAction->objectName(), reportBugAction);
255 }
256 if (switchLanguageAction) {
257 actions->addAction(switchLanguageAction->objectName(), switchLanguageAction);
258 }
259 if (aboutAppAction) {
260 actions->addAction(aboutAppAction->objectName(), aboutAppAction);
261 }
262 if (aboutKdeAction) {
263 actions->addAction(aboutKdeAction->objectName(), aboutKdeAction);
264 }
265 }
266
267 const QString windowXmlFile = xmlfile.isNull() ? componentName() + QStringLiteral("ui.xmlgui") : xmlfile;
268
269 // Help beginners who call setXMLFile and then setupGUI...
270 if (!xmlFile().isEmpty() && xmlFile() != windowXmlFile) {
271 qWarning() << "You called setXMLFile(" << xmlFile() << ") and then createGUI or setupGUI,"
272 << "which also calls setXMLFile and will overwrite the file you have previously set.\n"
273 << "You should call createGUI(" << xmlFile() << ") or setupGUI(<options>," << xmlFile() << ") instead.";
274 }
275
276 // we always want to load in our global standards file
278
279 // now, merge in our local xml file.
280 setXMLFile(windowXmlFile, true);
281
282 // make sure we don't have any state saved already
283 setXMLGUIBuildDocument(QDomDocument());
284
285 // do the actual GUI building
286 guiFactory()->reset();
287 guiFactory()->addClient(this);
288
289 // setUpdatesEnabled( true );
290}
A container for a set of QAction objects.
Q_INVOKABLE QAction * addAction(const QString &name, QAction *action)
Standard KDE help menu with dialog boxes.
Definition khelpmenu.h:106
QList< KisToolBar * > toolBars() const
void setXMLGUIBuildDocument(const QDomDocument &doc)
virtual QString xmlFile() const
void setXMLFile(const QString &file, bool merge=false, bool setXMLDoc=true)
virtual QString componentName() const
void removeClient(KisKXMLGUIClient *client)
void addClient(KisKXMLGUIClient *client)

References KisKXMLGUIClient::actionCollection(), KisKActionCollection::addAction(), KisKXMLGUIFactory::addClient(), KisKXMLGUIClient::componentName(), KisKXMLGUIBuilder::d, guiFactory(), K_D, KisKXMLGUIClient::loadStandardsXmlFile(), KisKHelpMenu::menuAboutApp, KisKHelpMenu::menuAboutKDE, KisKHelpMenu::menuHelpContents, KisKHelpMenu::menuReportBug, KisKHelpMenu::menuSwitchLanguage, KisKHelpMenu::menuWhatsThis, KisKXMLGUIFactory::removeClient(), KisKXMLGUIFactory::reset(), KisKXMLGUIClient::setXMLFile(), KisKXMLGUIClient::setXMLGUIBuildDocument(), KisKMainWindow::toolBars(), and KisKXMLGUIClient::xmlFile().

◆ createStandardStatusBarAction()

void KXmlGuiWindow::createStandardStatusBarAction ( )

Sets whether KisKMainWindow should provide a menu that allows showing/hiding of the statusbar ( using KToggleStatusBarAction ).

The menu / menu item is implemented using xmlgui. It will be inserted in your menu structure in the 'Settings' menu.

Note that you should enable this feature before calling createGUI() ( or similar ).

If an application maintains the action on its own (i.e. never calls this function) a connection needs to be made to let KisKMainWindow know when that status (hidden/shown) of the statusbar has changed. For example: connect(action, SIGNAL(activated()), kmainwindow, SLOT(setSettingsDirty())); Otherwise the status (hidden/show) of the statusbar might not be saved by KisKMainWindow.

Definition at line 337 of file kxmlguiwindow.cpp.

338{
340 if (!d->showStatusBarAction) {
341 d->showStatusBarAction = KStandardAction::showStatusbar(this, SLOT(setSettingsDirty()), actionCollection());
342 QStatusBar *sb = statusBar(); // Creates statusbar if it doesn't exist already.
343 connect(d->showStatusBarAction, SIGNAL(toggled(bool)), sb, SLOT(setVisible(bool)));
344 d->showStatusBarAction->setChecked(sb->isHidden());
345 } else {
346 // If the language has changed, we'll need to grab the new text and whatsThis
347 QAction *tmpStatusBar = KStandardAction::showStatusbar(0, 0, 0);
348 d->showStatusBarAction->setText(tmpStatusBar->text());
349 d->showStatusBarAction->setWhatsThis(tmpStatusBar->whatsThis());
350 delete tmpStatusBar;
351 }
352}
void setSettingsDirty()
KToggleAction * showStatusbar(const QObject *recvr, const char *slot, QObject *parent)

References KisKXMLGUIClient::actionCollection(), connect(), KisKXMLGUIBuilder::d, K_D, KisKMainWindow::setSettingsDirty(), and KStandardAction::showStatusbar().

◆ event()

bool KXmlGuiWindow::event ( QEvent * event)
overrideprotected

Reimplemented to catch QEvent::Polish in order to adjust the object name if needed, once all constructor code for the main window has run. Also reimplemented to catch when a QDockWidget is added or removed.

Definition at line 110 of file kxmlguiwindow.cpp.

111{
112 bool ret = KisKMainWindow::event(ev);
113#ifdef HAVE_DBUS
114 if (ev->type() == QEvent::Polish) {
115 QDBusConnection::sessionBus().registerObject(dbusName() + QStringLiteral("/actions"), actionCollection(),
116 QDBusConnection::ExportScriptableSlots |
117 QDBusConnection::ExportScriptableProperties |
118 QDBusConnection::ExportNonScriptableSlots |
119 QDBusConnection::ExportNonScriptableProperties |
120 QDBusConnection::ExportChildObjects);
121 }
122#endif
123 return ret;
124}
QString dbusName() const
bool event(QEvent *event) override

References KisKXMLGUIClient::actionCollection(), KisKMainWindow::dbusName(), and KisKMainWindow::event().

◆ finalizeGUI() [1/2]

void KXmlGuiWindow::finalizeGUI ( bool force)

Definition at line 354 of file kxmlguiwindow.cpp.

355{
356 // FIXME: this really needs to be removed with a code more like the one we had on KDE3.
357 // what we need to do here is to position correctly toolbars so they don't overlap.
358 // Also, take in count plugins could provide their own toolbars and those also need to
359 // be restored.
360 if (autoSaveSettings() && autoSaveConfigGroup().isValid()) {
362 }
363}
void applyMainWindowSettings(const KConfigGroup &config) override
KConfigGroup autoSaveConfigGroup() const

References applyMainWindowSettings(), KisKMainWindow::autoSaveConfigGroup(), and autoSaveSettings.

◆ finalizeGUI() [2/2]

void KXmlGuiWindow::finalizeGUI ( KisKXMLGUIClient * client)
overridevirtual

Reimplemented from KisKXMLGUIBuilder.

Definition at line 377 of file kxmlguiwindow.cpp.

378{
380}
virtual void finalizeGUI(KisKXMLGUIClient *client)

References KisKXMLGUIBuilder::finalizeGUI().

◆ guiFactory()

KisKXMLGUIFactory * KXmlGuiWindow::guiFactory ( )
virtual

Definition at line 138 of file kxmlguiwindow.cpp.

139{
141 if (!d->factory) {
142 d->factory = new KisKXMLGUIFactory(this, this);
143 connect(d->factory, SIGNAL(makingChanges(bool)),
144 this, SLOT(_k_slotFactoryMakingChanges(bool)));
145 }
146 return d->factory;
147}

References connect(), KisKXMLGUIBuilder::d, and K_D.

◆ isHelpMenuEnabled()

bool KXmlGuiWindow::isHelpMenuEnabled ( ) const

Return true when the help menu is enabled

Definition at line 132 of file kxmlguiwindow.cpp.

133{
134 K_D(const KXmlGuiWindow);
135 return d->showHelpMenu;
136}

References KisKXMLGUIBuilder::d, and K_D.

◆ isStandardToolBarMenuEnabled()

bool KXmlGuiWindow::isStandardToolBarMenuEnabled ( ) const

Definition at line 331 of file kxmlguiwindow.cpp.

332{
333 K_D(const KXmlGuiWindow);
334 return (d->toolBarHandler);
335}

References KisKXMLGUIBuilder::d, and K_D.

◆ saveNewToolbarConfig

void KXmlGuiWindow::saveNewToolbarConfig ( )
protectedvirtualslot

Rebuilds the GUI after KisKEditToolbar changed the toolbar layout.

See also
configureToolbars()

Definition at line 162 of file kxmlguiwindow.cpp.

163{
164 // createGUI(xmlFile()); // this loses any plugged-in guiclients, so we use remove+add instead.
165
166 guiFactory()->removeClient(this);
167 guiFactory()->addClient(this);
168
169 KConfigGroup cg(KSharedConfig::openConfig(), "");
171}

References KisKXMLGUIFactory::addClient(), applyMainWindowSettings(), guiFactory(), and KisKXMLGUIFactory::removeClient().

◆ setHelpMenuEnabled()

void KXmlGuiWindow::setHelpMenuEnabled ( bool showHelpMenu = true)

Enables the build of a standard help menu when calling createGUI/setupGUI().

The default behavior is to build one, you must call this function to disable it

Definition at line 126 of file kxmlguiwindow.cpp.

127{
129 d->showHelpMenu = showHelpMenu;
130}

References KisKXMLGUIBuilder::d, and K_D.

◆ setStandardToolBarMenuEnabled()

void KXmlGuiWindow::setStandardToolBarMenuEnabled ( bool enable)

Sets whether KisKMainWindow should provide a menu that allows showing/hiding the available toolbars ( using KToggleToolBarAction ) . In case there is only one toolbar configured a simple 'Show <toolbar name here>' menu item is shown.

The menu / menu item is implemented using xmlgui. It will be inserted in your menu structure in the 'Settings' menu.

If your application uses a non-standard xmlgui resource file then you can specify the exact position of the menu / menu item by adding a <Merge name="StandardToolBarMenuHandler" /> line to the settings menu section of your resource file ( usually appname.xmlgui ).

Note that you should enable this feature before calling createGUI() ( or similar ) .

Definition at line 304 of file kxmlguiwindow.cpp.

305{
307 if (enable) {
308 if (d->toolBarHandler) {
309 return;
310 }
311
312 d->toolBarHandler = new KDEPrivate::ToolBarHandler(this);
313
314 if (factory()) {
315 factory()->addClient(d->toolBarHandler);
316 }
317 } else {
318 if (!d->toolBarHandler) {
319 return;
320 }
321
322 if (factory()) {
323 factory()->removeClient(d->toolBarHandler);
324 }
325
326 delete d->toolBarHandler;
327 d->toolBarHandler = 0;
328 }
329}
KisKXMLGUIFactory * factory() const

References KisKXMLGUIFactory::addClient(), KisKXMLGUIBuilder::d, KisKXMLGUIClient::factory(), K_D, and KisKXMLGUIFactory::removeClient().

◆ setupGUI() [1/2]

void KXmlGuiWindow::setupGUI ( const QSize & defaultSize,
StandardWindowOptions options = Default,
const QString & xmlfile = QString() )

Configures the current windows and its actions in the typical KDE fashion. The options are all enabled by default but can be turned off if desired through the params or if the prereqs don't exists.

defaultSize The default size of the window

Typically this function replaces createGUI().

See also
StandardWindowOptions
Note
Since this method will restore the state of the application (toolbar, dockwindows positions...), you need to have added all your actions to your toolbars etc before calling to this method. (This note is only applicable if you are using the Default or Save flag).
Warning
If you are calling createGUI yourself, remember to remove the Create flag from the options parameter. Also, call setupGUI always after you call createGUI.

Definition at line 178 of file kxmlguiwindow.cpp.

179{
181 if (options & Keys) {
183 SLOT(configureShortcuts()), actionCollection());
184 }
185 if ((options & StatusBar) && statusBar()) {
187 }
188
189 if (options & ToolBar) {
193 }
194
195 d->defaultSize = defaultSize;
196
197 if (options & Create) {
198 createGUI(xmlfile);
199 }
200
201 if (d->defaultSize.isValid()) {
202 resize(d->defaultSize);
203 } else if (isHidden()) {
204 adjustSize();
205 }
206
207 if (options & Save) {
208 const KConfigGroup cg(autoSaveConfigGroup());
209 if (cg.isValid()) {
211 } else {
213 }
214 }
215}
void createGUI(const QString &xmlfile=QString())
void createStandardStatusBarAction()
void setStandardToolBarMenuEnabled(bool enable)
void setAutoSaveSettings(const QString &groupName=QLatin1String("MainWindow"), bool saveWindowSize=true)
QAction * keyBindings(const QObject *recvr, const char *slot, QObject *parent)

References KisKXMLGUIClient::actionCollection(), KisKMainWindow::autoSaveConfigGroup(), configureToolbars(), KStandardAction::configureToolbars(), Create, createGUI(), createStandardStatusBarAction(), KisKXMLGUIBuilder::d, guiFactory(), K_D, KStandardAction::keyBindings(), Keys, Save, KisKMainWindow::setAutoSaveSettings(), setStandardToolBarMenuEnabled(), StatusBar, and ToolBar.

◆ setupGUI() [2/2]

void KXmlGuiWindow::setupGUI ( StandardWindowOptions options = Default,
const QString & xmlfile = QString() )

Configures the current windows and its actions in the typical KDE fashion. The options are all enabled by default but can be turned off if desired through the params or if the prereqs don't exists.

Typically this function replaces createGUI().

See also
StandardWindowOptions
Note
Since this method will restore the state of the application (toolbar, dockwindows positions...), you need to have added all your actions to your toolbars etc before calling to this method. (This note is only applicable if you are using the Default or Save flag).
Warning
If you are calling createGUI yourself, remember to remove the Create flag from the options parameter.

Definition at line 173 of file kxmlguiwindow.cpp.

174{
175 setupGUI(QSize(), options, xmlfile);
176}

References setupGUI().

◆ setupToolbarMenuActions()

void KXmlGuiWindow::setupToolbarMenuActions ( )

Definition at line 96 of file kxmlguiwindow.cpp.

97{
99 if (d->toolBarHandler) {
100 d->toolBarHandler->setupActions();
101 }
102}

References KisKXMLGUIBuilder::d, and K_D.

◆ slotStateChanged [1/2]

void KXmlGuiWindow::slotStateChanged ( const QString & newstate)
virtualslot

Apply a state change

Enable and disable actions as defined in the XML rc file

Definition at line 292 of file kxmlguiwindow.cpp.

293{
295}
virtual void stateChanged(const QString &newstate, ReverseStateChange reverse=StateNoReverse)

References KisKXMLGUIClient::stateChanged(), and KisKXMLGUIClient::StateNoReverse.

◆ slotStateChanged [2/2]

void KXmlGuiWindow::slotStateChanged ( const QString & newstate,
bool reverse )
slot

Apply a state change

Enable and disable actions as defined in the XML rc file, can "reverse" the state (disable the actions which should be enabled, and vice-versa) if specified.

Definition at line 297 of file kxmlguiwindow.cpp.

References KisKXMLGUIClient::stateChanged(), KisKXMLGUIClient::StateNoReverse, and KisKXMLGUIClient::StateReverse.

◆ toolBarMenuAction()

QAction * KXmlGuiWindow::toolBarMenuAction ( )

Returns a pointer to the mainwindows action responsible for the toolbars menu

Definition at line 86 of file kxmlguiwindow.cpp.

87{
89 if (!d->toolBarHandler) {
90 return 0;
91 }
92
93 return d->toolBarHandler->toolBarMenuAction();
94}

References KisKXMLGUIBuilder::d, and K_D.

Property Documentation

◆ autoSaveGroup

QString KXmlGuiWindow::autoSaveGroup
read

Definition at line 52 of file kxmlguiwindow.h.

◆ autoSaveSettings

bool KXmlGuiWindow::autoSaveSettings
read

Definition at line 51 of file kxmlguiwindow.h.

◆ hasMenuBar

bool KXmlGuiWindow::hasMenuBar
read

Definition at line 50 of file kxmlguiwindow.h.

◆ standardToolBarMenuEnabled

bool KXmlGuiWindow::standardToolBarMenuEnabled
readwrite

Definition at line 53 of file kxmlguiwindow.h.


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