mirror of
https://github.com/Chatterino/chatterino2.git
synced 2024-11-13 19:49:51 +01:00
25 lines
662 B
C++
25 lines
662 B
C++
|
#pragma once
|
||
|
|
||
|
#include <QShortcut>
|
||
|
#include <QWidget>
|
||
|
|
||
|
namespace AB_NAMESPACE {
|
||
|
|
||
|
template <typename WidgetType, typename Func>
|
||
|
inline void createShortcut(WidgetType *w, const char *key, Func func)
|
||
|
{
|
||
|
auto s = new QShortcut(QKeySequence(key), w);
|
||
|
s->setContext(Qt::WidgetWithChildrenShortcut);
|
||
|
QObject::connect(s, &QShortcut::activated, w, func);
|
||
|
}
|
||
|
|
||
|
template <typename WidgetType, typename Func>
|
||
|
inline void createWindowShortcut(WidgetType *w, const char *key, Func func)
|
||
|
{
|
||
|
auto s = new QShortcut(QKeySequence(key), w);
|
||
|
s->setContext(Qt::WindowShortcut);
|
||
|
QObject::connect(s, &QShortcut::activated, w, func);
|
||
|
}
|
||
|
|
||
|
} // namespace AB_NAMESPACE
|