LunaSysMgr
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
SingleClickGesture.h
Go to the documentation of this file.
1 /* @@@LICENSE
2 *
3 * Copyright (c) 2010-2013 Hewlett-Packard Development Company, L.P.
4 *
5 * Licensed under the Apache License, Version 2.0 (the "License");
6 * you may not use this file except in compliance with the License.
7 * You may obtain a copy of the License at
8 *
9 * http://www.apache.org/licenses/LICENSE-2.0
10 *
11 * Unless required by applicable law or agreed to in writing, software
12 * distributed under the License is distributed on an "AS IS" BASIS,
13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 * See the License for the specific language governing permissions and
15 * limitations under the License.
16 *
17 * LICENSE@@@ */
18 
19 
20 
21 
22 #ifndef SINGLECLICKGESTURE_H
23 #define SINGLECLICKGESTURE_H
24 
25 #include "Common.h"
26 
27 #include <QGesture>
28 #include <QPoint>
29 #include "Settings.h"
30 #include <SysMgrDefs.h>
31 
33 {
34  Q_OBJECT
35 private:
36  int m_timerId;
37  int m_timerValue;
38  QPointF m_penDownPos;
39  bool m_mouseDown;
40  bool m_triggerSingleClickOnRelease;
41  Qt::KeyboardModifiers m_modifiers;
42  static Qt::GestureType type;
43 
44  void startSingleClickTimer() {
45  m_timerId = startTimer(Settings::LunaSettings()->tapDoubleClickDuration);
46  }
47 
48  void stopSingleClickTimer() {
49  if (m_timerId) {
50  killTimer(m_timerId);
51  m_timerId = 0;
52  }
53  }
54 
55 public:
57 #if (QT_VERSION < QT_VERSION_CHECK(5, 0, 0))
58  : QGesture(parent, (Qt::GestureType) SysMgrGestureSingleClick)
59 #else
60  : QGesture(parent)
61 #endif
62  , m_timerId(0), m_triggerSingleClickOnRelease (false), m_mouseDown (false)
63  , m_modifiers (0)
64  {
65  m_timerValue = Settings::LunaSettings()->tapDoubleClickDuration;
66  if (m_timerValue <= 0)
67  m_timerValue = 300;
68  }
69 
70  virtual ~SingleClickGesture() {
71  stopSingleClickTimer();
72  }
73 
74  Qt::KeyboardModifiers modifiers() const { return m_modifiers; }
75 
76  static Qt::GestureType gestureType() { return type;}
77  static void setGestureType (Qt::GestureType t) { type = t;}
78 
79 private:
81 
82 };
83 
84 #endif /* SINGLECLICKGESTURE_H */