2019-07-23 22:18:36 +02:00
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include <QShortcut>
|
|
|
|
#include <QWidget>
|
|
|
|
|
2019-10-07 15:46:08 +02:00
|
|
|
namespace chatterino {
|
2019-07-23 22:18:36 +02:00
|
|
|
|
|
|
|
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);
|
|
|
|
}
|
|
|
|
|
2019-10-07 15:46:08 +02:00
|
|
|
} // namespace chatterino
|