diff options
author | Florian Jung <flo@windfisch.org> | 2011-10-08 13:47:24 +0000 |
---|---|---|
committer | Florian Jung <flo@windfisch.org> | 2011-10-08 13:47:24 +0000 |
commit | a347445db32f51562aee5c6a786c312d1f612d2f (patch) | |
tree | ba3dc9a6e03eec2edf2c213b7f4d7e5e49903edc /muse2/awl/sigspinbox.cpp | |
parent | 375d6a53630f364c6560eb40255a8cc4c0496b8c (diff) | |
parent | 5367067f7a36dce8a362dcc000d41ac581bffdfe (diff) |
merged namespace changes. HOPEFULLY the last one.
Diffstat (limited to 'muse2/awl/sigspinbox.cpp')
-rw-r--r-- | muse2/awl/sigspinbox.cpp | 57 |
1 files changed, 57 insertions, 0 deletions
diff --git a/muse2/awl/sigspinbox.cpp b/muse2/awl/sigspinbox.cpp new file mode 100644 index 00000000..6e38b164 --- /dev/null +++ b/muse2/awl/sigspinbox.cpp @@ -0,0 +1,57 @@ +#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(); + return; + break; + case Qt::Key_Left: + case Qt::Key_Right: + case Qt::Key_Slash: + emit moveFocus(); + return; + break; + default: + break; + } + QSpinBox::keyPressEvent(ev); +} + +void SigSpinBox::setDenominator() +{ + _denominator=true; +} + +void SigSpinBox::stepBy(int step) +{ + if (!_denominator) { + setValue(value() + step); + return; + } + + AL::TimeSignature sig(4, value()); + if (step == 1) { + // make sure that sig is valid then increase + if (sig.isValid()) + setValue(value() * 2); + } + else if (step == -1) { + // make sure that sig is valid then increase + if (sig.isValid()) { + int v = value() / 2; + if (v < 2) + v = 2; + setValue(v); + } + } +} |