Home
Phabricator
Search
Log In
Paste
P74
Masterwork From Distant Lands
Active
Public
Actions
Authored by
dkazakov
on Apr 8 2017, 9:50 AM.
Edit Paste
Archive Paste
View Raw File
Subscribe
Mute Notifications
Award Token
Flag For Later
Tags
None
Subscribers
None
diff --git a/libs/ui/input/KisQtWidgetsTweaker.cpp b/libs/ui/input/KisQtWidgetsTweaker.cpp
index a21b3a3..8c25cca 100644
--- a/libs/ui/input/KisQtWidgetsTweaker.cpp
+++ b/libs/ui/input/KisQtWidgetsTweaker.cpp
@@ -56,6 +56,48 @@ KisQtWidgetsTweaker::~KisQtWidgetsTweaker()
}
+QKeySequence toKeySequence(const QKeyEvent& event)
+{
+ return QKeySequence(event.key() | event.modifiers());
+}
+
+struct StandardSequence
+{
+ QVector<QLatin1String> widgetTypes;
+ QVector<QKeySequence::StandardKey> sequences;
+
+ bool matches(QKeyEvent *event, QKeySequence::StandardKey key) {
+ return event->matches(key);
+ }
+};
+
+struct CustomSequence
+{
+ QVector<QLatin1String> widgetTypes;
+ QVector<QKeySequence> sequences;
+
+ bool matches(QKeyEvent *event, QKeySequence key) {
+ return key.matches(toKeySequence(*event)) == QKeySequence::ExactMatch;
+ }
+};
+
+template <class SequenceMap>
+bool tryAcceptSequence(QObject *receiver, QEvent *event, const SequenceMap &sequenceMap)
+{
+ Q_FOREACH (const QLatin1String &type, sequenceMap.widgetTypes) {
+ if (receiver->inherits(type.data())) {
+ QKeyEvent* key = static_cast<QKeyEvent*>(event);
+ Q_FOREACH (QKeySequence seq, sequenceMap.sequences) {
+ if (sequenceMap.matches(key, seq)) {
+ event->accept();
+ return true;
+ }
+ }
+ }
+ }
+ return false;
+}
+
bool KisQtWidgetsTweaker::eventFilter(QObject *receiver, QEvent *event)
{
dkazakov
edited the content of this paste.
(Show Details)
Apr 8 2017, 9:50 AM
dkazakov
changed the title of this paste from untitled to
Masterwork From Distant Lands
.
dkazakov
updated the paste's language from
autodetect
to
autodetect
.
dkazakov
mentioned this in
D5265: Fix for qLineEdits everywhere
.
Apr 8 2017, 10:01 AM
Log In to Comment