• Skip to content
  • Skip to link menu
KDE 4.3 API Reference
  • KDE API Reference
  • kdelibs
  • Sitemap
  • Contact Us
 

KDEUI

KKeySequenceWidget Class Reference

A widget to input a QKeySequence. More...

#include <kkeysequencewidget.h>

Inheritance diagram for KKeySequenceWidget:
QWidget

List of all members.

Public Types

enum  Validation { Validate = 0, NoValidate = 1 }

Public Slots

void applyStealShortcut ()
void captureKeySequence ()
void clearKeySequence ()
void setKeySequence (const QKeySequence &seq, Validation val=NoValidate)

Signals

void keySequenceChanged (const QKeySequence &seq)
void stealShortcut (const QKeySequence &seq, KAction *action)

Public Member Functions

bool isKeySequenceAvailable (const QKeySequence &seq) const
QKeySequence keySequence () const
 KKeySequenceWidget (QWidget *parent=0)
void setCheckActionCollections (const QList< KActionCollection * > &actionCollections)
KDE_DEPRECATED void setCheckActionList (const QList< QAction * > &checkList)
void setComponentName (const QString &componentName)
virtual ~KKeySequenceWidget ()

Properties

ShortcutTypes checkForConflictsAgainst
bool multiKeyShortcutsAllowed

Configuration

Configuration options for the widget.



enum  ShortcutType { None = 0x00, LocalShortcuts = 0x01, StandardShortcuts = 0x02, GlobalShortcuts = 0x03 }
ShortcutTypes checkForConflictsAgainst () const
bool isModifierlessAllowed ()
bool multiKeyShortcutsAllowed () const
void setCheckForConflictsAgainst (ShortcutTypes types)
void setClearButtonShown (bool show)
void setModifierlessAllowed (bool allow)
void setMultiKeyShortcutsAllowed (bool)

Detailed Description

A widget to input a QKeySequence.

This widget lets the user choose a QKeySequence, which is usually used as a shortcut key. The recording is initiated by calling captureKeySequence() or the user clicking into the widget.

The widgets provides support for conflict handling. See setCheckForConflictsAgainst() for more information.

Author:
Mark Donohoe <donohoe@kde.org>

For internal use only.

Definition at line 49 of file kkeysequencewidget.h.


Member Enumeration Documentation

enum KKeySequenceWidget::ShortcutType
Enumerator:
None 

No checking for conflicts.

LocalShortcuts 

Check with local shortcuts.

See also:
setCheckActionCollections()
StandardShortcuts 

Check against standard shortcuts.

See also:
KStandardShortcut
GlobalShortcuts 

Check against global shortcuts.

See also:
KGlobalAccel

Definition at line 91 of file kkeysequencewidget.h.

enum KKeySequenceWidget::Validation

An enum about validation when setting a key sequence.

See also:
setKeySequence()
Enumerator:
Validate 

Validate key sequence.

NoValidate 

Use key sequence without validation.

Definition at line 67 of file kkeysequencewidget.h.


Constructor & Destructor Documentation

KKeySequenceWidget::KKeySequenceWidget ( QWidget *  parent = 0  )  [explicit]

Constructor.

Definition at line 277 of file kkeysequencewidget.cpp.

KKeySequenceWidget::~KKeySequenceWidget (  )  [virtual]

Destructs the widget.

Definition at line 312 of file kkeysequencewidget.cpp.


Member Function Documentation

void KKeySequenceWidget::applyStealShortcut (  )  [slot]

Actually remove the shortcut that the user wanted to steal, from the action that was using it.

This only applies to actions provided to us by setCheckActionCollections() and setCheckActionList().

Global and Standard Shortcuts have to be stolen immediately when the user gives his consent (technical reasons). That means those changes will be active even if you never call applyStealShortcut().

To be called before you apply your changes. No local shortcuts are stolen until this function is called.

Definition at line 419 of file kkeysequencewidget.cpp.

void KKeySequenceWidget::captureKeySequence (  )  [slot]

Capture a shortcut from the keyboard.

This call will only return once a key sequence has been captured or input was aborted. If a key sequence was input, keySequenceChanged() will be emitted.

See also:
setModifierlessAllowed()

Definition at line 385 of file kkeysequencewidget.cpp.

ShortcutTypes KKeySequenceWidget::checkForConflictsAgainst (  )  const

The shortcut types we check for conflicts.

See also:
setCheckForConflictsAgainst()
Since:
4.2
void KKeySequenceWidget::clearKeySequence (  )  [slot]

Clear the key sequence.

Definition at line 413 of file kkeysequencewidget.cpp.

bool KKeySequenceWidget::isKeySequenceAvailable ( const QKeySequence &  seq  )  const

Checks whether the key sequence seq is available to grab.

The sequence is checked under the same rules as if it has been typed by the user. This method is useful if you get key sequences from another input source and want to check if it is save to set them.

Since:
4.2

Definition at line 352 of file kkeysequencewidget.cpp.

bool KKeySequenceWidget::isModifierlessAllowed (  ) 
See also:
setModifierlessAllowed()

Definition at line 362 of file kkeysequencewidget.cpp.

QKeySequence KKeySequenceWidget::keySequence (  )  const

Return the currently selected key sequence.

Definition at line 391 of file kkeysequencewidget.cpp.

void KKeySequenceWidget::keySequenceChanged ( const QKeySequence &  seq  )  [signal]

This signal is emitted when the current key sequence has changed, be it by user input or programmatically.

bool KKeySequenceWidget::multiKeyShortcutsAllowed (  )  const
void KKeySequenceWidget::setCheckActionCollections ( const QList< KActionCollection * > &  actionCollections  ) 

Set a list of action collections to check against for conflictuous shortcut.

See also:
setCheckForConflictsAgainst()

If a KAction with a conflicting shortcut is found inside this list and its shortcut can be configured (KAction::isShortcutConfigurable() returns true) the user will be prompted whether to steal the shortcut from this action.

Since:
4.1

Definition at line 379 of file kkeysequencewidget.cpp.

void KKeySequenceWidget::setCheckActionList ( const QList< QAction * > &  checkList  ) 
Deprecated:
since 4.1 use setCheckActionCollections so that KKeySequenceWidget knows in which action collection to call the writeSettings method after stealing a shortcut from an action.

Definition at line 373 of file kkeysequencewidget.cpp.

void KKeySequenceWidget::setCheckForConflictsAgainst ( ShortcutTypes  types  ) 

Configure if the widget should check for conflicts with existing shortcuts.

When capturing a key sequence for local shortcuts you should check against GlobalShortcuts and your other local shortcuts. This is the default.

You have to provide the local actions to check against with setCheckActionCollections().

When capturing a key sequence for a global shortcut you should check against StandardShortcuts, GlobalShortcuts and your local shortcuts.

There are two ways to react to a user agreeing to steal a shortcut:

1. Listen to the stealShortcut() signal and steal the shortcuts manually. It's your responsibility to save that change later when you think it is appropriate.

2. Call applyStealShortcut and KKeySequenceWidget will steal the shortcut. This will save the actionCollections the shortcut is part of so make sure it doesn't inadvertly save some unwanted changes too. Read its documentation for some limitation when handling global shortcuts.

If you want to do the conflict checking yourself here are some code snippets for global ...

 QStringList conflicting = KGlobalAccel::findActionNameSystemwide(keySequence);
 if (!conflicting.isEmpty()) {
     // Inform and ask the user about the conflict and reassigning
     // the keys sequence
     if (!KGlobalAccel::promptStealShortcutSystemwide(q, conflicting, keySequence)) {
         return true;
     }
     KGlobalAccel::stealShortcutSystemwide(keySequence);
 }

... and standard shortcuts

 KStandardShortcut::StandardShortcut ssc = KStandardShortcut::find(keySequence);
 if (ssc != KStandardShortcut::AccelNone) {
     // We have a conflict
 }
Since:
4.2

Definition at line 341 of file kkeysequencewidget.cpp.

void KKeySequenceWidget::setClearButtonShown ( bool  show  ) 

Set whether a small button to set an empty key sequence should be displayed next to the main input widget.

The default is to show the clear button.

Definition at line 368 of file kkeysequencewidget.cpp.

void KKeySequenceWidget::setComponentName ( const QString &  componentName  ) 

If the component using this widget supports shortcuts contexts, it has to set its component name so we can check conflicts correctly.

Definition at line 324 of file kkeysequencewidget.cpp.

void KKeySequenceWidget::setKeySequence ( const QKeySequence &  seq,
Validation  val = NoValidate 
) [slot]

Set the key sequence.

If val == Validate, and the call is actually changing the key sequence, conflictuous shortcut will be checked.

Definition at line 398 of file kkeysequencewidget.cpp.

void KKeySequenceWidget::setModifierlessAllowed ( bool  allow  ) 

This only applies to user input, not to setShortcut().

Set whether to accept "plain" keys without modifiers (like Ctrl, Alt, Meta). Plain keys by our definition include letter and symbol keys and text editing keys (Return, Space, Tab, Backspace, Delete). "Special" keys like F1, Cursor keys, Insert, PageDown will always work.

Definition at line 346 of file kkeysequencewidget.cpp.

void KKeySequenceWidget::setMultiKeyShortcutsAllowed ( bool  allowed  ) 

Allow multikey shortcuts?

Definition at line 335 of file kkeysequencewidget.cpp.

void KKeySequenceWidget::stealShortcut ( const QKeySequence &  seq,
KAction *  action 
) [signal]

This signal is emitted after the user agreed to steal a shortcut from an action.

This is only done for local shortcuts. So you can be sure action is one of the actions you provided with setCheckActionList() or setCheckActionCollections().

If you listen to that signal and don't call applyStealShortcut() you are supposed to steal the shortcut and save this change.


Property Documentation

KKeySequenceWidget::ShortcutTypes KKeySequenceWidget::checkForConflictsAgainst [read, write]

Definition at line 61 of file kkeysequencewidget.h.

bool KKeySequenceWidget::multiKeyShortcutsAllowed [read, write]

Definition at line 56 of file kkeysequencewidget.h.


The documentation for this class was generated from the following files:
  • kkeysequencewidget.h
  • kkeysequencewidget.cpp

KDEUI

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

kdelibs

Skip menu "kdelibs"
  • DNSSD
  • Interfaces
  •   KHexEdit
  •   KMediaPlayer
  •   KSpeech
  •   KTextEditor
  • Kate
  • kconf_update
  • KDE3Support
  •   KUnitTest
  • KDECore
  • KDED
  • KDEsu
  • KDEUI
  • KDocTools
  • KFile
  • KHTML
  • KImgIO
  • KInit
  • kio
  • KIOSlave
  • KJS
  •   KJS-API
  •   WTF
  • kjsembed
  • KNewStuff
  • KParts
  • KPty
  • Kross
  • KUtils
  • Nepomuk
  • Plasma
  • Solid
  • Sonnet
  • ThreadWeaver
Generated for kdelibs by doxygen 1.6.1
This website is maintained by Adriaan de Groot and Allen Winter.
KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal