Skip to content

Commit

Permalink
MythGesture: Add a LongClick type
Browse files Browse the repository at this point in the history
- currently unused
  • Loading branch information
mark-kendall committed Sep 23, 2020
1 parent af7a9da commit 8d0aa1a
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 6 deletions.
9 changes: 6 additions & 3 deletions mythtv/libs/libmythui/mythgesture.cpp
Expand Up @@ -57,6 +57,7 @@ MythGestureEvent::MythGestureEvent(Gesture gesture, Button button)

const std::map<QString, MythGestureEvent::Gesture>MythGesture::kSequences =
{
{ "1", MythGestureEvent::LongClick },
{ "5", MythGestureEvent::Click },
{ "456", MythGestureEvent::Right },
{ "654", MythGestureEvent::Left },
Expand Down Expand Up @@ -159,7 +160,7 @@ void MythGesture::Start(void)
*
* This method stores the gesture, as it is, and resets all information.
*/
void MythGesture::Stop(void)
void MythGesture::Stop(bool Timeout)
{
m_lock.lock();

Expand All @@ -168,7 +169,7 @@ void MythGesture::Stop(void)
m_recording = false;

// translate before resetting maximums
const QString gesture = Translate();
const QString gesture = Translate(Timeout);
auto found = kSequences.find(gesture);
if (found != kSequences.cend())
m_lastGesture = found->second;
Expand Down Expand Up @@ -213,7 +214,7 @@ static int determineBin (const QPoint & p, int x1, int x2, int y1, int y2)
*
* \note The points will be removed during this method.
*/
QString MythGesture::Translate(void)
QString MythGesture::Translate(bool Timeout)
{
size_t total_points = static_cast<size_t>(m_points.count());

Expand All @@ -228,6 +229,8 @@ QString MythGesture::Translate(void)
if (total_points < m_minPoints)
{
m_points.clear();
if (Timeout)
return "1";
return "5";
}

Expand Down
6 changes: 4 additions & 2 deletions mythtv/libs/libmythui/mythgesture.h
Expand Up @@ -72,6 +72,8 @@ class MUI_PUBLIC MythGestureEvent : public QEvent
DownThenUp,

/* A click */
// NB LongClick before Click as MythMainWindow filters out otherwise
LongClick,
Click
};
Q_ENUM(Gesture)
Expand Down Expand Up @@ -114,7 +116,7 @@ class MythGesture
float BinPercent = 0.07F);

void Start();
void Stop();
void Stop(bool Timeout = false);
bool Recording();
MythGestureEvent* GetGesture() const;
bool Record(const QPoint& Point);
Expand All @@ -123,7 +125,7 @@ class MythGesture
Q_DISABLE_COPY(MythGesture)

bool HasMinimumPoints() const;
QString Translate();
QString Translate(bool Timeout);
void AdjustExtremes(int X, int Y);

bool m_recording { false };
Expand Down
2 changes: 1 addition & 1 deletion mythtv/libs/libmythui/mythmainwindow.cpp
Expand Up @@ -1525,7 +1525,7 @@ void MythMainWindow::mouseTimeout(void)
{
/* complete the stroke if its our first timeout */
if (d->m_gesture.Recording())
d->m_gesture.Stop();
d->m_gesture.Stop(true);

/* get the last gesture */
MythGestureEvent *e = d->m_gesture.GetGesture();
Expand Down

0 comments on commit 8d0aa1a

Please sign in to comment.