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