blob: 5ee98bc99562e47f9ea41cc90b739cb3501ca6d2 (
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
|
#include "sigspinbox.h"
#include "al/sig.h"
#include <QKeyEvent>
#include <stdio.h>
SigSpinBox::SigSpinBox(QWidget *parent) :
QSpinBox(parent)
{
_denominator=false;
}
void SigSpinBox::keyPressEvent(QKeyEvent*ev)
{
switch (ev->key()) {
case Qt::Key_Return:
emit returnPressed();
break;
case Qt::Key_Left:
case Qt::Key_Right:
case Qt::Key_Slash:
emit moveFocus();
break;
case Qt::Key_Up:
if (_denominator) {
// make sure that sig is valid then increase
AL::TimeSignature sig(4,value());
if (sig.isValid())
setValue(value()*2);
return;
}
break;
case Qt::Key_Down:
if (_denominator) {
// make sure that sig is valid then increase
AL::TimeSignature sig(4,value());
if (sig.isValid()) {
int v = value()/2;
if (v<2)
v=2;
setValue(v);
return;
}
return;
}
break;
default:
break;
}
QSpinBox::keyPressEvent(ev);
}
void SigSpinBox::setDenominator()
{
_denominator=true;
}
|