ckb-next
v0.2.8 at branch master
ckb-next driver for corsair devices
Main Page
Related Pages
Namespaces
Data Structures
Files
File List
Globals
All
Data Structures
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Friends
Macros
Pages
keywidget.h
Go to the documentation of this file.
1
#ifndef RGBWIDGET_H
2
#define RGBWIDGET_H
3
4
#include <QBitArray>
5
#include <QMouseEvent>
6
#include <QPaintEvent>
7
#include <QWidget>
8
#include "
keymap.h
"
9
#include "
colormap.h
"
10
11
class
KeyWidget
:
public
QWidget
12
{
13
Q_OBJECT
14
public
:
15
// New key widget. rgbMode = true to display colors, false to display key names
16
explicit
KeyWidget
(
QWidget
*parent = 0,
bool
rgbMode
=
true
);
17
inline
bool
rgbMode
() {
return
_rgbMode
; }
18
inline
void
rgbMode
(
bool
newRgbMode) {
_rgbMode
= newRgbMode; update(); }
19
// For RGB maps, monochrome = true to covert everything to grayscale
20
inline
bool
monochrome
() {
return
_monochrome
; }
21
inline
void
monochrome
(
bool
newMono) {
_monochrome
= newMono; update(); }
22
23
// Key map
24
const
KeyMap
&
map
()
const
{
return
keyMap
; }
25
void
map
(
const
KeyMap
& newMap);
26
// Key -> color map (must contain exactly the keys in the key map)
27
const
QColorMap
&
colorMap
()
const
{
return
_colorMap
; }
28
void
colorMap
(
const
QColorMap
& newColorMap);
29
// Key -> binding map
30
typedef
QHash<QString, QString>
BindMap
;
31
const
BindMap
&
bindMap
()
const
{
return
_bindMap
; }
32
void
bindMap
(
const
BindMap
& newBindMap);
33
34
// Set current selection (highlighted in blue)
35
void
setSelection
(
const
QStringList& keys);
36
void
selectAll
();
37
void
clearSelection
();
38
39
// Set animated keys (highlighted in green)
40
void
setAnimation
(
const
QStringList& keys);
41
void
setAnimationToSelection
();
42
void
clearAnimation
();
43
44
public
slots:
45
// Sets display colors. Pass an empty map to clear.
46
// These will be displayed instead of the regular color map, if supplied.
47
void
displayColorMap
(
const
ColorMap
& newDisplayMap,
const
QSet<QString>& indicators = QSet<QString>());
48
49
signals:
50
// Emitted when the selection is changed.
51
void
selectionChanged
(QStringList selected);
52
void
sidelightToggled
();
53
54
private
:
55
KeyMap
keyMap
;
56
QColorMap
_colorMap
;
57
ColorMap
_displayColorMap
;
58
BindMap
_bindMap
;
59
QSet<QString>
_indicators
;
60
61
QBitArray
selection
;
62
QBitArray
newSelection
;
63
QBitArray
animation
;
64
int
mouseDownX
,
mouseDownY
;
65
int
mouseCurrentX
,
mouseCurrentY
;
66
enum
{
67
NONE
,
68
SET
,
69
ADD
,
70
SUBTRACT
,
71
TOGGLE
,
72
}
mouseDownMode
;
73
bool
_rgbMode
,
_monochrome
;
74
75
void
paintEvent
(QPaintEvent*);
76
void
mousePressEvent
(QMouseEvent* event);
77
void
mouseMoveEvent
(QMouseEvent* event);
78
void
mouseReleaseEvent
(QMouseEvent* event);
79
80
// Get drawing scale/offset. drawX = (keymapX + offsetX) * scale
81
void
drawInfo
(
float
& scale,
float
& offsetX,
float
& offsetY,
int
ratio = 1);
82
};
83
84
#endif // RGBWIDGET_H
colormap.h
keymap.h
KeyWidget::ADD
Definition:
keywidget.h:69
KeyWidget::clearSelection
void clearSelection()
Definition:
keywidget.cpp:617
KeyWidget::selectAll
void selectAll()
Definition:
keywidget.cpp:596
KeyWidget::clearAnimation
void clearAnimation()
Definition:
keywidget.cpp:644
KeyWidget::rgbMode
bool rgbMode()
Definition:
keywidget.h:17
KeyWidget::bindMap
const BindMap & bindMap() const
Definition:
keywidget.h:31
QWidget
KeyWidget::setSelection
void setSelection(const QStringList &keys)
Definition:
keywidget.cpp:582
KeyWidget::drawInfo
void drawInfo(float &scale, float &offsetX, float &offsetY, int ratio=1)
Definition:
keywidget.cpp:43
KeyWidget::mouseDownX
int mouseDownX
Definition:
keywidget.h:64
KeyWidget::map
const KeyMap & map() const
Definition:
keywidget.h:24
KeyWidget::mouseReleaseEvent
void mouseReleaseEvent(QMouseEvent *event)
Definition:
keywidget.cpp:548
KeyWidget::BindMap
QHash< QString, QString > BindMap
Definition:
keywidget.h:30
KeyWidget::mouseCurrentY
int mouseCurrentY
Definition:
keywidget.h:65
KeyWidget::selectionChanged
void selectionChanged(QStringList selected)
Definition:
moc_keywidget.cpp:164
KeyWidget::_monochrome
bool _monochrome
Definition:
keywidget.h:73
KeyWidget::SET
Definition:
keywidget.h:68
KeyWidget::monochrome
bool monochrome()
Definition:
keywidget.h:20
KeyWidget::mouseMoveEvent
void mouseMoveEvent(QMouseEvent *event)
Definition:
keywidget.cpp:487
KeyWidget::NONE
Definition:
keywidget.h:67
KeyWidget::colorMap
const QColorMap & colorMap() const
Definition:
keywidget.h:27
ColorMap
Definition:
colormap.h:15
KeyWidget::_displayColorMap
ColorMap _displayColorMap
Definition:
keywidget.h:57
KeyWidget::sidelightToggled
void sidelightToggled()
Definition:
moc_keywidget.cpp:171
KeyWidget::mouseDownMode
enum KeyWidget::@2 mouseDownMode
KeyWidget::_rgbMode
bool _rgbMode
Definition:
keywidget.h:73
KeyWidget::mousePressEvent
void mousePressEvent(QMouseEvent *event)
Definition:
keywidget.cpp:455
KeyWidget::TOGGLE
Definition:
keywidget.h:71
KeyWidget::SUBTRACT
Definition:
keywidget.h:70
KeyWidget
Definition:
keywidget.h:11
KeyWidget::selection
QBitArray selection
Definition:
keywidget.h:61
KeyWidget::paintEvent
void paintEvent(QPaintEvent *)
Definition:
keywidget.cpp:70
KeyWidget::animation
QBitArray animation
Definition:
keywidget.h:63
KeyWidget::keyMap
KeyMap keyMap
Definition:
keywidget.h:55
KeyWidget::setAnimationToSelection
void setAnimationToSelection()
Definition:
keywidget.cpp:639
QColorMap
QHash< QString, QRgb > QColorMap
Definition:
colormap.h:9
KeyWidget::mouseDownY
int mouseDownY
Definition:
keywidget.h:64
KeyWidget::KeyWidget
KeyWidget(QWidget *parent=0, bool rgbMode=true)
Definition:
keywidget.cpp:17
KeyMap
Definition:
keymap.h:49
KeyWidget::_bindMap
BindMap _bindMap
Definition:
keywidget.h:58
KeyWidget::_indicators
QSet< QString > _indicators
Definition:
keywidget.h:59
KeyWidget::_colorMap
QColorMap _colorMap
Definition:
keywidget.h:56
KeyWidget::rgbMode
void rgbMode(bool newRgbMode)
Definition:
keywidget.h:18
KeyWidget::displayColorMap
void displayColorMap(const ColorMap &newDisplayMap, const QSet< QString > &indicators=QSet< QString >())
Definition:
keywidget.cpp:57
KeyWidget::newSelection
QBitArray newSelection
Definition:
keywidget.h:62
KeyWidget::setAnimation
void setAnimation(const QStringList &keys)
Definition:
keywidget.cpp:625
KeyWidget::monochrome
void monochrome(bool newMono)
Definition:
keywidget.h:21
KeyWidget::mouseCurrentX
int mouseCurrentX
Definition:
keywidget.h:65
src
ckb
keywidget.h
Generated on Sat Jan 20 2018 16:59:28 for ckb-next by
1.8.6