Unity 8
GlobalShortcutRegistry Class Reference

The GlobalShortcutRegistry class. More...

#include <plugins/GlobalShortcut/globalshortcutregistry.h>

Inherits QObject.

Public Member Functions

 GlobalShortcutRegistry (QObject *parent=nullptr)
 
GlobalShortcutList shortcuts () const
 
bool hasShortcut (const QVariant &seq) const
 
void addShortcut (const QVariant &seq, GlobalShortcut *sc)
 
void setupFilterOnWindow (QWindow *window)
 

Protected Member Functions

bool eventFilter (QObject *obj, QEvent *event) override
 

Detailed Description

The GlobalShortcutRegistry class.

Serves as a central point for shortcut registration.

Definition at line 34 of file globalshortcutregistry.h.

Member Function Documentation

void GlobalShortcutRegistry::addShortcut ( const QVariant &  seq,
GlobalShortcut sc 
)

Adds a shortcut seq to the registry

Definition at line 55 of file globalshortcutregistry.cpp.

56 {
57  if (sc) {
58  if (!m_shortcuts.contains(seq)) { // create a new entry
59  m_shortcuts.insert(seq, {sc});
60  } else { // append to an existing one
61  auto shortcuts = m_shortcuts[seq];
62  shortcuts.append(sc);
63  m_shortcuts.insert(seq, shortcuts);
64  }
65 
66  connect(sc, &GlobalShortcut::destroyed, this, &GlobalShortcutRegistry::removeShortcut);
67  }
68 }
GlobalShortcutList shortcuts() const
bool GlobalShortcutRegistry::hasShortcut ( const QVariant &  seq) const
Returns
whether shortcut seq is currently registered

Definition at line 50 of file globalshortcutregistry.cpp.

51 {
52  return m_shortcuts.contains(seq);
53 }
void GlobalShortcutRegistry::setupFilterOnWindow ( QWindow *  window)

Sets up key events filtering on window window

Definition at line 122 of file globalshortcutregistry.cpp.

123 {
124  if (m_filteredWindow) {
125  m_filteredWindow->removeEventFilter(this);
126  m_filteredWindow.clear();
127  }
128 
129  if (window) {
130  m_filteredWindow = window;
131  window->installEventFilter(this);
132  }
133 }
GlobalShortcutList GlobalShortcutRegistry::shortcuts ( ) const
Returns
the list of shortcuts currently registered

Definition at line 45 of file globalshortcutregistry.cpp.

46 {
47  return m_shortcuts;
48 }

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