• Skip to content
  • Skip to link menu
  • KDE API Reference
  • kdelibs-4.14.38 API Reference
  • KDE Home
  • Contact Us
 

KDEUI

  • kdeui
  • actions
kactioncollection.h
Go to the documentation of this file.
1/* This file is part of the KDE libraries
2 Copyright (C) 1999 Reginald Stadlbauer <reggie@kde.org>
3 (C) 1999 Simon Hausmann <hausmann@kde.org>
4 (C) 2000 Nicolas Hadacek <haadcek@kde.org>
5 (C) 2000 Kurt Granroth <granroth@kde.org>
6 (C) 2000 Michael Koch <koch@kde.org>
7 (C) 2001 Holger Freyther <freyther@kde.org>
8 (C) 2002 Ellis Whitehead <ellis@kde.org>
9 (C) 2005-2006 Hamish Rodda <rodda@kde.org>
10
11 This library is free software; you can redistribute it and/or
12 modify it under the terms of the GNU Library General Public
13 License version 2 as published by the Free Software Foundation.
14
15 This library is distributed in the hope that it will be useful,
16 but WITHOUT ANY WARRANTY; without even the implied warranty of
17 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
18 Library General Public License for more details.
19
20 You should have received a copy of the GNU Library General Public License
21 along with this library; see the file COPYING.LIB. If not, write to
22 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
23 Boston, MA 02110-1301, USA.
24*/
25
26#ifndef KACTIONCOLLECTION_H
27#define KACTIONCOLLECTION_H
28
29#include <kdeui_export.h>
30#include <kstandardaction.h>
31#include <kcomponentdata.h>
32
33#include <QtCore/QObject>
34
35class QAction;
36class KXMLGUIClient;
37
38class QActionGroup;
39class QString;
40
56class KDEUI_EXPORT KActionCollection : public QObject
57{
58 friend class KXMLGUIClient;
59
60 Q_OBJECT
61
62 Q_PROPERTY( QString configGroup READ configGroup WRITE setConfigGroup )
63 Q_PROPERTY( bool configIsGlobal READ configIsGlobal WRITE setConfigGlobal )
64
65public:
70 explicit KActionCollection(QObject *parent, const KComponentData &cData = KComponentData());
71
75 virtual ~KActionCollection();
76
80 static const QList<KActionCollection*>& allCollections();
81
85 void clear();
86
94 void associateWidget(QWidget* widget) const;
95
104 void addAssociatedWidget(QWidget* widget);
105
110 void removeAssociatedWidget(QWidget* widget);
111
115 QList<QWidget*> associatedWidgets() const;
116
120 void clearAssociatedWidgets();
121
125 QString configGroup() const;
126
131 bool configIsGlobal() const;
132
136 void setConfigGroup( const QString& group );
137
142 void setConfigGlobal( bool global );
143
151 void readSettings( KConfigGroup* config = 0 );
152
160 void importGlobalShortcuts( KConfigGroup* config );
161
170 void exportGlobalShortcuts( KConfigGroup* config, bool writeDefaults = false ) const;
171
187 void writeSettings( KConfigGroup* config = 0, bool writeDefaults = false, QAction* oneAction = 0 ) const;
188
194 int count() const;
195
199 bool isEmpty() const;
200
206 QAction *action(int index) const;
207
215 QAction* action( const QString& name ) const;
216
223 QList<QAction*> actions() const;
224
228 const QList<QAction*> actionsWithoutGroup() const;
229
233 const QList<QActionGroup*> actionGroups() const;
234
244 void setComponentData(const KComponentData &componentData);
245
247 KComponentData componentData() const;
248
252 const KXMLGUIClient *parentGUIClient() const;
253
254Q_SIGNALS:
258 void inserted( QAction* action );
259
264 QT_MOC_COMPAT void removed( QAction* action );
265
270 QT_MOC_COMPAT void actionHighlighted(QAction* action);
271
275 void actionHovered(QAction* action);
276
280 void actionTriggered(QAction* action);
281
282protected Q_SLOTS:
284 virtual void connectNotify ( const char * signal );
285
286 virtual void slotActionTriggered();
287
292 QT_MOC_COMPAT virtual void slotActionHighlighted();
293
294private Q_SLOTS:
295 void slotActionHovered();
296
297
298public:
315 QAction *addAction(const QString &name, QAction *action);
316 KAction *addAction(const QString &name, KAction *action);
317
322 void removeAction(QAction *action);
323
328 QAction* takeAction(QAction *action);
329
348 KAction *addAction(KStandardAction::StandardAction actionType, const QObject *receiver = 0, const char *member = 0);
349
368 KAction *addAction(KStandardAction::StandardAction actionType, const QString &name,
369 const QObject *receiver = 0, const char *member = 0);
370
393 KAction *addAction(const QString &name, const QObject *receiver = 0, const char *member = 0);
394
411 template<class ActionType>
412 ActionType *add(const QString &name, const QObject *receiver = 0, const char *member = 0)
413 {
414 ActionType *a = new ActionType(this);
415 if (receiver && member)
416 connect(a, SIGNAL(triggered(bool)), receiver, member);
417 addAction(name, a);
418 return a;
419 }
420
421private:
422 Q_PRIVATE_SLOT(d, void _k_actionDestroyed(QObject *))
423 Q_PRIVATE_SLOT(d, void _k_associatedWidgetDestroyed(QObject*))
424
425 KActionCollection( const KXMLGUIClient* parent ); // used by KXMLGUIClient
426
427 friend class KActionCollectionPrivate;
428 class KActionCollectionPrivate* const d;
429};
430
431#endif
KActionCollection
A container for a set of QAction objects.
Definition kactioncollection.h:57
KActionCollection::addAction
QAction * addAction(const QString &name, QAction *action)
Add an action under the given name to the collection.
Definition kactioncollection.cpp:217
KActionCollection::slotActionHighlighted
virtual QT_MOC_COMPAT void slotActionHighlighted()
Definition kactioncollection.cpp:643
KActionCollection::configGroup
QString configGroup
Definition kactioncollection.h:62
KActionCollection::configIsGlobal
bool configIsGlobal
Definition kactioncollection.h:63
KActionCollection::addAssociatedWidget
void addAssociatedWidget(QWidget *widget)
Associate all actions in this collection to the given widget, including any actions added after this ...
Definition kactioncollection.cpp:708
KActionCollection::count
int count() const
Returns the number of actions in the collection.
Definition kactioncollection.cpp:147
KActionCollection::add
ActionType * add(const QString &name, const QObject *receiver=0, const char *member=0)
Creates a new action under the given name, adds it to the collection and connects the action's trigge...
Definition kactioncollection.h:412
KActionCollection::associatedWidgets
QList< QWidget * > associatedWidgets() const
Return a list of all associated widgets.
Definition kactioncollection.cpp:761
KActionCollection::actionHovered
void actionHovered(QAction *action)
Indicates that action was hovered.
KActionCollection::readSettings
void readSettings(KConfigGroup *config=0)
Read all key associations from config.
Definition kactioncollection.cpp:413
KActionCollection::connectNotify
virtual void connectNotify(const char *signal)
Overridden to perform connections when someone wants to know whether an action was highlighted or tri...
Definition kactioncollection.cpp:671
KActionCollection::writeSettings
void writeSettings(KConfigGroup *config=0, bool writeDefaults=false, QAction *oneAction=0) const
Write the current configurable key associations to config.
Definition kactioncollection.cpp:563
KActionCollection::clear
void clear()
Clears the entire action collection, deleting all actions.
Definition kactioncollection.cpp:124
KActionCollection::importGlobalShortcuts
void importGlobalShortcuts(KConfigGroup *config)
Import from config all configurable global key associations.
Definition kactioncollection.cpp:386
KActionCollection::actionHighlighted
QT_MOC_COMPAT void actionHighlighted(QAction *action)
Indicates that action was highlighted (hovered over).
KActionCollection::exportGlobalShortcuts
void exportGlobalShortcuts(KConfigGroup *config, bool writeDefaults=false) const
Export the current configurable global key associations to config.
Definition kactioncollection.cpp:444
KActionCollection::setConfigGroup
void setConfigGroup(const QString &group)
Sets group as the KConfig group with which settings will be loaded and saved.
Definition kactioncollection.cpp:371
KActionCollection::clearAssociatedWidgets
void clearAssociatedWidgets()
Clear all associated widgets and remove the actions from those widgets.
Definition kactioncollection.cpp:766
KActionCollection::componentData
KComponentData componentData() const
The KComponentData with which this class is associated.
Definition kactioncollection.cpp:176
KActionCollection::associateWidget
void associateWidget(QWidget *widget) const
Associate all actions in this collection to the given widget.
Definition kactioncollection.cpp:700
KActionCollection::parentGUIClient
const KXMLGUIClient * parentGUIClient() const
The parent KXMLGUIClient, or null if not available.
Definition kactioncollection.cpp:181
KActionCollection::actionsWithoutGroup
const QList< QAction * > actionsWithoutGroup() const
Returns the list of KActions without an QAction::actionGroup() which belong to this action collection...
Definition kactioncollection.cpp:191
KActionCollection::takeAction
QAction * takeAction(QAction *action)
Removes an action from the collection.
Definition kactioncollection.cpp:321
KActionCollection::isEmpty
bool isEmpty() const
Returns whether the action collection is empty or not.
Definition kactioncollection.cpp:152
KActionCollection::slotActionTriggered
virtual void slotActionTriggered()
Definition kactioncollection.cpp:636
KActionCollection::actionGroups
const QList< QActionGroup * > actionGroups() const
Returns the list of all QActionGroups associated with actions in this action collection.
Definition kactioncollection.cpp:200
KActionCollection::removed
QT_MOC_COMPAT void removed(QAction *action)
Indicates that action was removed from this action collection.
KActionCollection::removeAction
void removeAction(QAction *action)
Removes an action from the collection and deletes it.
Definition kactioncollection.cpp:316
KActionCollection::inserted
void inserted(QAction *action)
Indicates that action was inserted into this action collection.
KActionCollection::KActionCollection
KActionCollection(QObject *parent, const KComponentData &cData=KComponentData())
Constructor.
Definition kactioncollection.cpp:96
KActionCollection::allCollections
static const QList< KActionCollection * > & allCollections()
Access the list of all action collections in existence for this app.
Definition kactioncollection.cpp:695
KActionCollection::setComponentData
void setComponentData(const KComponentData &componentData)
Set the componentData associated with this action collection.
Definition kactioncollection.cpp:157
KActionCollection::removeAssociatedWidget
void removeAssociatedWidget(QWidget *widget)
Remove an association between all actions in this collection and the given widget,...
Definition kactioncollection.cpp:718
KActionCollection::actions
QList< QAction * > actions() const
Returns the list of KActions which belong to this action collection.
Definition kactioncollection.cpp:186
KActionCollection::KActionCollectionPrivate
friend class KActionCollectionPrivate
Definition kactioncollection.h:427
KActionCollection::setConfigGlobal
void setConfigGlobal(bool global)
Set whether this action collection's configuration should be global to KDE ( true ),...
Definition kactioncollection.cpp:381
KActionCollection::action
QAction * action(int index) const
Return the QAction* at position "index" in the action collection.
Definition kactioncollection.cpp:141
KActionCollection::actionTriggered
void actionTriggered(QAction *action)
Indicates that action was triggered.
KActionCollection::KXMLGUIClient
friend class KXMLGUIClient
Definition kactioncollection.h:58
KAction
Class to encapsulate user-driven action or event.
Definition kaction.h:217
KComponentData
KConfigGroup
KXMLGUIClient
A KXMLGUIClient can be used with KXMLGUIFactory to create a GUI from actions and an XML document,...
Definition kxmlguiclient.h:47
QAction
QList
QObject
QWidget
kcomponentdata.h
kdeui_export.h
kstandardaction.h
KStandardAction
Convenience methods to access all standard KDE actions.
Definition kstandardaction.cpp:47
This file is part of the KDE documentation.
Documentation copyright © 1996-2025 The KDE developers.
Generated on Fri Jan 17 2025 00:00:00 by doxygen 1.13.2 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.

KDEUI

Skip menu "KDEUI"
  • Main Page
  • Namespace List
  • Namespace Members
  • Alphabetical List
  • Class List
  • Class Hierarchy
  • Class Members
  • File List
  • File Members
  • Related Pages

kdelibs-4.14.38 API Reference

Skip menu "kdelibs-4.14.38 API Reference"
  • DNSSD
  • Interfaces
  •   KHexEdit
  •   KMediaPlayer
  •   KSpeech
  •   KTextEditor
  • kconf_update
  • KDE3Support
  •   KUnitTest
  • KDECore
  • KDED
  • KDEsu
  • KDEUI
  • KDEWebKit
  • KDocTools
  • KFile
  • KHTML
  • KImgIO
  • KInit
  • kio
  • KIOSlave
  • KJS
  •   KJS-API
  •   WTF
  • kjsembed
  • KNewStuff
  • KParts
  • KPty
  • Kross
  • KUnitConversion
  • KUtils
  • Nepomuk
  • Plasma
  • Solid
  • Sonnet
  • ThreadWeaver
Report problems with this website to our bug tracking system.
Contact the specific authors with questions and comments about the page contents.

KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal