Loading...
Searching...
No Matches
GlobalShortcut Class Reference

The GlobalShortcut class. More...

`#include <plugins/GlobalShortcut/globalshortcut.h>`

## Signals

void | shortcutChanged (const QVariant &shortcut)
void | triggered (const QString &shortcut)
void | released (const QString &shortcut)
void | activeChanged (bool active)

## Public Member Functions

| GlobalShortcut (QQuickItem *parent=nullptr)
QVariant | shortcut () const
void | setShortcut (const QVariant &shortcut)
bool | isActive () const
void | setActive (bool active)

## Protected Member Functions

void | keyPressEvent (QKeyEvent *event) override
void | keyReleaseEvent (QKeyEvent *event) override

## Properties

QVariant | shortcut
bool | active

## Detailed Description

The GlobalShortcut class.

QML component for registering a shortcut; the shortcut itself can be specified either as a string ("Ctrl+Alt+L") or as an enum value (Qt.ControlModifier|Qt.AltModifier|Qt.Key_L).

When the shortcut is detected, the signal triggered() gets emitted.

Definition at line 33 of file globalshortcut.h.

## Constructor & Destructor Documentation

## GlobalShortcut()

GlobalShortcut::GlobalShortcut | ( | QQuickItem * | parent = nullptr | ) |

Definition at line 25 of file globalshortcut.cpp.

: QQuickItem(parent)
{
}

## Member Function Documentation

## isActive()

bool GlobalShortcut::isActive | ( |  | ) | const

Definition at line 45 of file globalshortcut.cpp.

{
return m_active;
}

## keyPressEvent()

void GlobalShortcut::keyPressEvent | ( | QKeyEvent * | event | ) |

override protected

Definition at line 59 of file globalshortcut.cpp.

{
if (!m_active) {
event->ignore();
return;
}
event->accept();
Q_EMIT triggered(m_shortcut.toString());
}
GlobalShortcut::triggered
void triggered(const QString &shortcut)

## keyReleaseEvent()

void GlobalShortcut::keyReleaseEvent | ( | QKeyEvent * | event | ) |

override protected

Definition at line 70 of file globalshortcut.cpp.

{
if (!m_active) {
event->ignore();
return;
}
event->accept();
Q_EMIT released(m_shortcut.toString());
}
GlobalShortcut::released
void released(const QString &shortcut)

## released

void GlobalShortcut::released | ( | const QString & | shortcut | ) |

signal

Emitted when a global keypress of `shortcut` is released

## setActive()

void GlobalShortcut::setActive | ( | bool | active | ) |

Definition at line 50 of file globalshortcut.cpp.

{
if (m_active == active)
return;
m_active = active;
Q_EMIT activeChanged(active);
}
GlobalShortcut::active
bool active
Definition globalshortcut.h:43

## setShortcut()

void GlobalShortcut::setShortcut | ( | const QVariant & | shortcut | ) |

Definition at line 35 of file globalshortcut.cpp.

{
if (m_shortcut == shortcut)
return;
m_shortcut = shortcut;
registry->addShortcut(shortcut, this);
Q_EMIT shortcutChanged(shortcut);
}
GlobalShortcut::shortcut
QVariant shortcut
Definition globalshortcut.h:39

## shortcut()

QVariant GlobalShortcut::shortcut | ( |  | ) | const

Definition at line 30 of file globalshortcut.cpp.

{
return m_shortcut;
}

## triggered

void GlobalShortcut::triggered | ( | const QString & | shortcut | ) |

signal

Emitted when a global keypress of `shortcut` is detected

## Property Documentation

## active

bool GlobalShortcut::active

read write

Whether the shortcut is active (true by default)

Definition at line 43 of file globalshortcut.h.

## shortcut

QVariant GlobalShortcut::shortcut

read write

The shortcut itself

Definition at line 39 of file globalshortcut.h.

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

- plugins/GlobalShortcut/globalshortcut.h
- plugins/GlobalShortcut/globalshortcut.cpp