Lomiri
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

◆ addShortcut()

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 }

◆ hasShortcut()

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 }

◆ setupFilterOnWindow()

void GlobalShortcutRegistry::setupFilterOnWindow ( QWindow *  window)

Sets up key events filtering on window window

Definition at line 123 of file globalshortcutregistry.cpp.

124 {
125  if (m_filteredWindow) {
126  m_filteredWindow->removeEventFilter(this);
127  m_filteredWindow.clear();
128  }
129 
130  if (window) {
131  m_filteredWindow = window;
132  window->installEventFilter(this);
133  }
134 }

◆ shortcuts()

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:
GlobalShortcutRegistry::shortcuts
GlobalShortcutList shortcuts() const
Definition: globalshortcutregistry.cpp:45