KXmlGui

kshortcutwidget.h
1 /*
2  This file is part of the KDE libraries
3  SPDX-FileCopyrightText: 2007 Andreas Hartmetz <[email protected]>
4 
5  SPDX-License-Identifier: LGPL-2.0-or-later
6 */
7 #ifndef KSHORTCUTWIDGET_H
8 #define KSHORTCUTWIDGET_H
9 
10 #include <kxmlgui_export.h>
11 
12 #include <QKeySequence>
13 #include <QList>
14 #include <QWidget>
15 #include <memory>
16 
17 class KActionCollection;
18 class KShortcutWidgetPrivate;
19 
20 /**
21  * @class KShortcutWidget kshortcutwidget.h KShortcutWidget
22  *
23  * \image html kshortcutwidget.png "KShortcutWidget"
24  */
25 class KXMLGUI_EXPORT KShortcutWidget : public QWidget
26 {
27  Q_OBJECT
28  Q_PROPERTY(bool modifierlessAllowed READ isModifierlessAllowed WRITE setModifierlessAllowed)
29 public:
30  KShortcutWidget(QWidget *parent = nullptr);
31  ~KShortcutWidget();
32 
33  void setModifierlessAllowed(bool allow);
34  bool isModifierlessAllowed();
35 
36  void setClearButtonsShown(bool show);
37 
38  QList<QKeySequence> shortcut() const;
39 
40  /**
41  * Set a list of action collections to check against for conflictuous shortcut.
42  *
43  * If there is a conflictuous shortcut with a QAction, and that his shortcut can be configured
44  * (KActionCollection::isShortcutConfigurable() returns true) the user will be prompted for eventually steal
45  * the shortcut from this action
46  *
47  * Global shortcuts are automatically checked for conflicts
48  *
49  * Don't forget to call applyStealShortcut to actually steal the shortcut.
50  *
51  * @since 4.1
52  */
53  void setCheckActionCollections(const QList<KActionCollection *> &actionCollections);
54 
55 #if KXMLGUI_ENABLE_DEPRECATED_SINCE(4, 1)
56  /**
57  * @deprecated since 4.1
58  * Use setCheckActionCollections so that KShortcutWidget knows
59  * in which action collection to call the writeSettings method after stealing
60  * a shortcut from an action.
61  */
62  KXMLGUI_DEPRECATED_VERSION(4, 1, "Use KShortcutWidget::setCheckActionCollections(const QList<KActionCollection *> &)")
63  void setCheckActionList(const QList<QAction *> &checkList);
64 #endif
65 
66 Q_SIGNALS:
67  void shortcutChanged(const QList<QKeySequence> &cut);
68 
69 public Q_SLOTS:
70  void setShortcut(const QList<QKeySequence> &cut);
71  void clearShortcut();
72 
73  /**
74  * Actually remove the shortcut that the user wanted to steal, from the
75  * action that was using it.
76  *
77  * To be called before you apply your changes.
78  * No shortcuts are stolen until this function is called.
79  */
80  void applyStealShortcut();
81 
82 private:
83  friend class KShortcutWidgetPrivate;
84  std::unique_ptr<KShortcutWidgetPrivate> const d;
85 };
86 
87 #endif // KSHORTCUTWIDGET_H
A container for a set of QAction objects.
Q_PROPERTY(...)
This file is part of the KDE documentation.
Documentation copyright © 1996-2021 The KDE developers.
Generated on Thu May 13 2021 22:50:34 by doxygen 1.8.11 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.