Commit 2731fc0e authored by Thomas Baumgart's avatar Thomas Baumgart
Browse files

Add missing release event in very specific case

The date picker object is used in other areas of KMyMoney (e.g.
transaction editor) where this problem does not show up. I analyzed it,
and the problem is, that the very first MouseReleaseButton event on the
date picker after object creation is not reaching the object under
unknown circumstances in the enter schedule dialog. This is not always,
but the scenario reported in the bug entry shows it. I have no idea
about the root cause, though.

Detecting the specific scenario and sending a mouse release button event
based on the data of the press event solves the problem. Drawback:
pressing the mouse long in that scenario now has no effect. It needs a
second press to get the number increasing while the mouse button is
pressed.

BUG: 424378

(cherry picked from commit fae59666)
parent d425feac
......@@ -59,6 +59,7 @@ const QDate INVALID_DATE = QDate(1800, 1, 1);
KMyMoney::OldDateEdit::OldDateEdit(const QDate& date, QWidget* parent)
: QDateEdit(date, parent)
, m_initialSection(QDateTimeEdit::DaySection)
, m_initStage(Created)
{
}
......@@ -97,6 +98,31 @@ bool KMyMoney::OldDateEdit::event(QEvent* e)
} else {
rc = QDateEdit::event(e);
}
switch (m_initStage) {
case Created:
if (e->type() == QEvent::FocusIn) {
m_initStage = GotFocus;
}
break;
case GotFocus:
if (e->type() == QEvent::MouseButtonPress) {
// create a phony corresponding release event
QMouseEvent* mev = static_cast<QMouseEvent*>(e);
QMouseEvent release(QEvent::MouseButtonRelease,
mev->localPos(),
mev->windowPos(),
mev->screenPos(),
mev->button(),
mev->buttons(),
mev->modifiers(),
mev->source());
QApplication::sendEvent(this, &release);
m_initStage = FirstMousePress;
}
break;
case FirstMousePress:
break;
}
return rc;
}
......
......@@ -67,6 +67,11 @@ namespace KMyMoney {
private:
QDateEdit::Section m_initialSection;
enum {
Created,
GotFocus,
FirstMousePress
} m_initStage;
};
}; // namespace
......
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