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

The GlobalShortcut class. More...

#include <plugins/GlobalShortcut/globalshortcut.h>

Inherits QQuickItem.

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.

26 : QQuickItem(parent)
27{
28}

Member Function Documentation

◆ isActive()

bool GlobalShortcut::isActive ( ) const

Definition at line 45 of file globalshortcut.cpp.

46{
47 return m_active;
48}

◆ keyPressEvent()

void GlobalShortcut::keyPressEvent ( QKeyEvent *  event)
overrideprotected

Definition at line 59 of file globalshortcut.cpp.

60{
61 if (!m_active) {
62 event->ignore();
63 return;
64 }
65
66 event->accept();
67 Q_EMIT triggered(m_shortcut.toString());
68}
void triggered(const QString &shortcut)

◆ keyReleaseEvent()

void GlobalShortcut::keyReleaseEvent ( QKeyEvent *  event)
overrideprotected

Definition at line 70 of file globalshortcut.cpp.

71{
72 if (!m_active) {
73 event->ignore();
74 return;
75 }
76
77 event->accept();
78 Q_EMIT released(m_shortcut.toString());
79}
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.

51{
52 if (m_active == active)
53 return;
54
55 m_active = active;
56 Q_EMIT activeChanged(active);
57}

◆ setShortcut()

void GlobalShortcut::setShortcut ( const QVariant &  shortcut)

Definition at line 35 of file globalshortcut.cpp.

36{
37 if (m_shortcut == shortcut)
38 return;
39
40 m_shortcut = shortcut;
41 registry->addShortcut(shortcut, this);
42 Q_EMIT shortcutChanged(shortcut);
43}

◆ shortcut()

QVariant GlobalShortcut::shortcut ( ) const

Definition at line 30 of file globalshortcut.cpp.

31{
32 return m_shortcut;
33}

◆ triggered

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

Emitted when a global keypress of shortcut is detected

Property Documentation

◆ active

bool GlobalShortcut::active
readwrite

Whether the shortcut is active (true by default)

Definition at line 43 of file globalshortcut.h.

◆ shortcut

QVariant GlobalShortcut::shortcut
readwrite

The shortcut itself

Definition at line 39 of file globalshortcut.h.


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