Commit 1d8c0c10 authored by Emmet O'Neill's avatar Emmet O'Neill Committed by Dmitry Kazakov

Bug fix: Ctrl-activated color picker no longer glitches out when double clicking with a mouse.

Summary:
Currently a glitch exists where double clicking with a mouse while using the ctrl key-activated color picker causes the `KisAbstractInputAction::eventPos` and ``KisAbstractInputAction::eventPosF` functions to return an incorrect value, which then causes the ctrl-picker to return an undefined and unwanted color (usually black or white).

This patch fixes this bug by simply adding the `QEvent::MouseButtonDblClick` case to both switch statements, returning the correct position info for the abstract input events.

I believe this should close https://bugs.kde.org/show_bug.cgi?id=394396 . Although the user reported a crash associated with this bug, I was unable to reproduce any.

I also threw in some tiny formatting/style changes while I was in those files.

Test Plan:
Using a mouse, select the Brush Tool, hold the Ctrl Key to pop up a color picker, and double click.

Without this patch applied the picked color will often incorrectly be pure black or pure white, which seems to change depending on the zoom level.

After this patch, double clicking should not create any unwanted or unpredictable behavior from the ctrl-picker.

BUG:394396
Reviewers: #krita, rempt, dkazakov
Reviewed By: #krita, dkazakov
Subscribers: #krita
Tags: #krita
Differential Revision: https://phabricator.kde.org/D12953
parent c215d014
......@@ -33,12 +33,12 @@ public:
QPointF lastCursorPosition;
static KisInputManager* inputManager;
static KisInputManager *inputManager;
};
KisInputManager *KisAbstractInputAction::Private::inputManager = 0;
KisAbstractInputAction::KisAbstractInputAction(const QString & id)
KisAbstractInputAction::KisAbstractInputAction(const QString &id)
: d(new Private)
{
d->id = id;
......@@ -69,7 +69,7 @@ void KisAbstractInputAction::begin(int shortcut, QEvent *event)
}
}
void KisAbstractInputAction::inputEvent(QEvent* event)
void KisAbstractInputAction::inputEvent(QEvent *event)
{
if (event) {
QPointF newPosition = eventPosF(event);
......@@ -135,17 +135,17 @@ QString KisAbstractInputAction::id() const
return d->id;
}
void KisAbstractInputAction::setName(const QString& name)
void KisAbstractInputAction::setName(const QString &name)
{
d->name = name;
}
void KisAbstractInputAction::setDescription(const QString& description)
void KisAbstractInputAction::setDescription(const QString &description)
{
d->description = description;
}
void KisAbstractInputAction::setShortcutIndexes(const QHash< QString, int >& indexes)
void KisAbstractInputAction::setShortcutIndexes(const QHash< QString, int > &indexes)
{
d->indexes = indexes;
}
......@@ -161,9 +161,8 @@ bool KisAbstractInputAction::isShortcutRequired(int shortcut) const
return false;
}
QPoint KisAbstractInputAction::eventPos(const QEvent *event) {
QPoint KisAbstractInputAction::eventPos(const QEvent *event)
{
if(!event) {
return QPoint();
}
......@@ -171,6 +170,7 @@ QPoint KisAbstractInputAction::eventPos(const QEvent *event) {
switch (event->type()) {
case QEvent::MouseMove:
case QEvent::MouseButtonPress:
case QEvent::MouseButtonDblClick:
case QEvent::MouseButtonRelease:
return static_cast<const QMouseEvent*>(event)->pos();
......@@ -191,12 +191,12 @@ QPoint KisAbstractInputAction::eventPos(const QEvent *event) {
}
}
QPointF KisAbstractInputAction::eventPosF(const QEvent *event) {
switch (event->type()) {
case QEvent::MouseMove:
case QEvent::MouseButtonPress:
case QEvent::MouseButtonDblClick:
case QEvent::MouseButtonRelease:
return static_cast<const QMouseEvent*>(event)->localPos();
......
......@@ -159,5 +159,4 @@ void KisAlternateInvocationAction::inputEvent(QEvent* event)
QMouseEvent targetEvent(QEvent::MouseMove, eventPosF(event), Qt::LeftButton, Qt::LeftButton, modifiers);
inputManager()->toolProxy()->forwardEvent(KisToolProxy::CONTINUE, m_d->savedAction, &targetEvent, event);
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment