Move shortcut creation code to its own helper file

This commit is contained in:
Rasmus Karlsson
2018-01-06 20:24:04 +01:00
parent e5b8e33eb3
commit 8aa459d826
3 changed files with 29 additions and 21 deletions
+18
View File
@@ -0,0 +1,18 @@
#pragma once
#include <QShortcut>
#include <QWidget>
namespace chatterino {
namespace widgets {
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);
}
} // namespace widgets
} // namespace chatterino