Phosphor
Qt6 / Wayland library suite for window-management tools
 
Loading...
Searching...
No Matches
IBackend.h
Go to the documentation of this file.
1// SPDX-FileCopyrightText: 2026 fuddlesworth
2// SPDX-License-Identifier: LGPL-2.1-or-later
3
4#pragma once
5
6#include <QKeySequence>
7#include <QObject>
8#include <QString>
9#include <QStringList>
10
11#include <optional>
12
13#include "phosphorshortcuts_export.h"
14
15namespace PhosphorShortcuts {
16
31class PHOSPHORSHORTCUTS_EXPORT IBackend : public QObject
32{
33 Q_OBJECT
34public:
35 explicit IBackend(QObject* parent = nullptr)
36 : QObject(parent)
37 {
38 }
39 ~IBackend() override = default;
40
76 virtual void registerShortcut(const QString& id, const QKeySequence& defaultSeq, const QKeySequence& currentSeq,
77 const QString& description, bool persistent = true) = 0;
78
95 virtual void updateShortcut(const QString& id, const QKeySequence& defaultSeq, const QKeySequence& newTrigger) = 0;
96
109 virtual void unregisterShortcut(const QString& id) = 0;
110
117 virtual void flush() = 0;
118
151 virtual std::optional<QStringList> currentTriggers(const QString& id) const
152 {
153 Q_UNUSED(id);
154 return std::nullopt;
155 }
156
157Q_SIGNALS:
162 void activated(QString id);
163
169 void ready();
170
179 void triggersChanged(QString id);
180};
181
182} // namespace PhosphorShortcuts
Pluggable global shortcut backend.
Definition IBackend.h:32
virtual std::optional< QStringList > currentTriggers(const QString &id) const
The key sequence(s) the backend believes are EFFECTIVELY bound for an id right now — i....
Definition IBackend.h:151
void ready()
Emitted after flush() completes.
void activated(QString id)
Emitted when the backend observes the user triggering a registered shortcut.
IBackend(QObject *parent=nullptr)
Definition IBackend.h:35
virtual void registerShortcut(const QString &id, const QKeySequence &defaultSeq, const QKeySequence &currentSeq, const QString &description, bool persistent=true)=0
Register a new shortcut id.
virtual void updateShortcut(const QString &id, const QKeySequence &defaultSeq, const QKeySequence &newTrigger)=0
Change the active binding for an already-registered id.
virtual void unregisterShortcut(const QString &id)=0
Release the key grab for an id.
virtual void flush()=0
Commit any queued register/update ops.
void triggersChanged(QString id)
Emitted when the effective binding for an id changes outside the register/update flow — e....
~IBackend() override=default
Definition Factory.h:12