• 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::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::actionHovered
void actionHovered(QAction *action)
Indicates that action was hovered.
KActionCollection::actionHighlighted
QT_MOC_COMPAT void actionHighlighted(QAction *action)
Indicates that action was highlighted (hovered over).
KActionCollection::removed
QT_MOC_COMPAT void removed(QAction *action)
Indicates that action was removed from this action collection.
KActionCollection::inserted
void inserted(QAction *action)
Indicates that action was inserted into this action collection.
KActionCollection::actionTriggered
void actionTriggered(QAction *action)
Indicates that action was triggered.
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::StandardAction
StandardAction
The standard menubar and toolbar actions.
Definition: kstandardaction.h:125
This file is part of the KDE documentation.
Documentation copyright © 1996-2023 The KDE developers.
Generated on Mon Feb 20 2023 00:00:00 by doxygen 1.9.6 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
  • Modules
  • 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