[prev in list] [next in list] [prev in thread] [next in thread]
List: kde-kimageshop
Subject: [calligra/krita-testing-kazakov] krita/ui/input: Fix hiding the brush outline when the cursor is out
From: Dmitry Kazakov <dimula73 () gmail ! com>
Date: 2014-06-06 8:17:08
Message-ID: E1WspKm-00066S-18 () scm ! kde ! org
[Download RAW message or body]
Git commit 6eedc10af62fb369ddaee6c893e8fbfb8a15e6a5 by Dmitry Kazakov.
Committed on 06/06/2014 at 08:13.
Pushed by dkazakov into branch 'krita-testing-kazakov'.
Fix hiding the brush outline when the cursor is outside the canvas
Please check this patch on Gnome and Windows!
BUG:335649
CCMAIL:kimageshop@kde.org
M +4 -0 krita/ui/input/kis_input_manager.cpp
M +29 -3 krita/ui/input/kis_shortcut_matcher.cpp
M +12 -0 krita/ui/input/kis_shortcut_matcher.h
http://commits.kde.org/calligra/6eedc10af62fb369ddaee6c893e8fbfb8a15e6a5
diff --git a/krita/ui/input/kis_input_manager.cpp \
b/krita/ui/input/kis_input_manager.cpp index 94611be..34581f8 100644
--- a/krita/ui/input/kis_input_manager.cpp
+++ b/krita/ui/input/kis_input_manager.cpp
@@ -598,6 +598,8 @@ bool KisInputManager::eventFilter(QObject* object, QEvent* event)
//Ensure we have focus so we get key events.
d->canvas->canvasWidget()->setFocus();
stop_ignore_cursor_events();
+
+ d->matcher.enterEvent();
break;
case QEvent::Leave:
d->debugEvent<QEvent, false>(event);
@@ -607,6 +609,8 @@ bool KisInputManager::eventFilter(QObject* object, QEvent* event)
* events processing right now.
*/
stop_ignore_cursor_events();
+
+ d->matcher.leaveEvent();
break;
case QEvent::FocusIn:
d->debugEvent<QEvent, false>(event);
diff --git a/krita/ui/input/kis_shortcut_matcher.cpp \
b/krita/ui/input/kis_shortcut_matcher.cpp index e4796ac..178a903 100644
--- a/krita/ui/input/kis_shortcut_matcher.cpp
+++ b/krita/ui/input/kis_shortcut_matcher.cpp
@@ -43,6 +43,7 @@ public:
, readyShortcut(0)
, touchShortcut(0)
, suppressAllActions(false)
+ , cursorEntered(false)
, usingTouch(false)
{}
@@ -60,7 +61,12 @@ public:
KisTouchShortcut *touchShortcut;
bool suppressAllActions;
+ bool cursorEntered;
bool usingTouch;
+
+ inline bool actionsSuppressed() const {
+ return suppressAllActions || !cursorEntered;
+ }
};
KisShortcutMatcher::KisShortcutMatcher()
@@ -216,6 +222,26 @@ bool KisShortcutMatcher::mouseMoved(QMouseEvent *event)
return true;
}
+void KisShortcutMatcher::enterEvent()
+{
+ m_d->cursorEntered = true;
+
+ if (!m_d->runningShortcut) {
+ prepareReadyShortcuts();
+ tryActivateReadyShortcut();
+ }
+}
+
+void KisShortcutMatcher::leaveEvent()
+{
+ m_d->cursorEntered = false;
+
+ if (!m_d->runningShortcut) {
+ prepareReadyShortcuts();
+ tryActivateReadyShortcut();
+ }
+}
+
bool KisShortcutMatcher::touchBeginEvent( QTouchEvent* event )
{
Q_UNUSED(event)
@@ -313,7 +339,7 @@ bool KisShortcutMatcher::tryRunKeyShortcut(Qt::Key key, QKeyEvent \
*event) template<typename T, typename U>
bool KisShortcutMatcher::tryRunSingleActionShortcutImpl(T param, U *event, const \
QList<Qt::Key> &keysState) {
- if (m_d->suppressAllActions) return false;
+ if (m_d->actionsSuppressed()) return false;
KisSingleActionShortcut *goodCandidate = 0;
@@ -336,7 +362,7 @@ bool KisShortcutMatcher::tryRunSingleActionShortcutImpl(T param, \
U *event, const void KisShortcutMatcher::prepareReadyShortcuts()
{
m_d->readyShortcuts.clear();
- if (m_d->suppressAllActions) return;
+ if (m_d->actionsSuppressed()) return;
foreach(KisStrokeShortcut *s, m_d->strokeShortcuts) {
if (s->matchReady(m_d->keys, m_d->buttons)) {
@@ -424,7 +450,7 @@ bool KisShortcutMatcher::tryRunTouchShortcut( QTouchEvent* event \
) {
KisTouchShortcut *goodCandidate = 0;
- if (m_d->suppressAllActions)
+ if (m_d->actionsSuppressed())
return false;
foreach(KisTouchShortcut* shortcut, m_d->touchShortcuts) {
diff --git a/krita/ui/input/kis_shortcut_matcher.h \
b/krita/ui/input/kis_shortcut_matcher.h index 5cc54e3..b3cd01d 100644
--- a/krita/ui/input/kis_shortcut_matcher.h
+++ b/krita/ui/input/kis_shortcut_matcher.h
@@ -166,6 +166,18 @@ public:
*/
bool mouseMoved(QMouseEvent *event);
+ /**
+ * Handle cursor's Enter event.
+ * We never eat it because it might be used by someone else
+ */
+ void enterEvent();
+
+ /**
+ * Handle cursor's Leave event.
+ * We never eat it because it might be used by someone else
+ */
+ void leaveEvent();
+
bool touchBeginEvent(QTouchEvent *event);
bool touchUpdateEvent(QTouchEvent *event);
bool touchEndEvent(QTouchEvent *event);
_______________________________________________
Krita mailing list
kimageshop@kde.org
https://mail.kde.org/mailman/listinfo/kimageshop
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic