blob: 2b3f6627020a464f43c81cc02ab543ec23e2e20a (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
|
/*********
*
* In the name of the Father, and of the Son, and of the Holy Spirit.
*
* This file is part of BibleTime's source code, http://www.bibletime.info/.
*
* Copyright 1999-2014 by the BibleTime developers.
* The BibleTime source code is licensed under the GNU General Public License version 2.0.
*
**********/
#ifndef CSCROLLBUTTON_H
#define CSCROLLBUTTON_H
#include <QToolButton>
class QMouseEvent;
class QWheelEvent;
class QWidget;
/**
* This Class implements the direct chooser button used in the KeyChooser Widget.
* \author The BibleTime team.
*/
class CScrollButton: public QToolButton {
Q_OBJECT
public:
CScrollButton(QWidget *parent = 0);
signals:
/**
* \brief The lock() signal is emitted when the button grabs the mouse
* and enters the locked state.
*/
void lock();
/**
* \brief The unlock() signal is emitted when the button releases the
* leaves the locked state.
*/
void unlock();
/**
* \brief Indicates a change the user made by moving the mouse.
*
* \param count the number of items to be changed in the KeyChooser
* ComboBox.
*/
void change_requested(int count);
protected:
/**
* \brief Grabs the mouse on left button click and emits lock().
*/
virtual void mousePressEvent(QMouseEvent *e);
/**
* \brief If the mouse is grabbed and we release the left mouse button,
* releases the mouse and emits unlock().
*/
virtual void mouseReleaseEvent(QMouseEvent *e);
/**
* \brief Reimplementation of QWidget::mouseMoveEvent() to process mouse
move events.
*/
virtual void mouseMoveEvent(QMouseEvent *e);
protected:
/**
* \brief Indicates whether the button is in locked state or not.
*
* If the button is in the locked state, this means the mouse is grabbed
* and any mouse move events invoke calculation about whether to emit the
* change_requested() signal.
*/
bool m_isLocked;
/**
* \brief The amount the mouse moved.
*
* This is saved so slow movements of mice can still be tracked and yet not
* emitting a change for every smallest movement of the mouse.
*/
float m_movement;
};
#endif
|