diff options
Diffstat (limited to 'muse2/awl/sigedit.cpp')
-rw-r--r-- | muse2/awl/sigedit.cpp | 46 |
1 files changed, 34 insertions, 12 deletions
diff --git a/muse2/awl/sigedit.cpp b/muse2/awl/sigedit.cpp index 74e4b060..d3685a53 100644 --- a/muse2/awl/sigedit.cpp +++ b/muse2/awl/sigedit.cpp @@ -43,20 +43,26 @@ SigEdit::SigEdit(QWidget* parent) { initialized = false; slash = new QLabel("/",this); - zSpin = new QSpinBox(this); - nSpin = new QSpinBox(this); + zSpin = new SigSpinBox(this); + nSpin = new SigSpinBox(this); zSpin->setRange(1,100); - nSpin->setRange(1,100); + nSpin->setDenominator(); + nSpin->setRange(1,128); layout = new QHBoxLayout(this); layout->setContentsMargins(0,0,0,0); layout->setSpacing(1); layout->addWidget(zSpin); layout->addWidget(slash); layout->addWidget(nSpin); - layout->addSpacing(40); + layout->addSpacing(30); connect(zSpin, SIGNAL(valueChanged(int)), SLOT(setZ(int))); connect(nSpin, SIGNAL(valueChanged(int)), SLOT(setN(int))); + connect(nSpin, SIGNAL(returnPressed()), SIGNAL(returnPressed())); + connect(zSpin, SIGNAL(returnPressed()), SIGNAL(returnPressed())); + connect(zSpin, SIGNAL(moveFocus()), SLOT(moveFocus())); + connect(nSpin, SIGNAL(moveFocus()), SLOT(moveFocus())); + zSpin->selectAll(); } SigEdit::~SigEdit() @@ -68,18 +74,29 @@ SigEdit::~SigEdit() //--------------------------------------------------------- +// moveFocus +//--------------------------------------------------------- + +void SigEdit::moveFocus() +{ + if (zSpin->hasFocus()) { + nSpin->setFocus(); + nSpin->selectAll(); + } + else { + zSpin->setFocus(); + zSpin->selectAll(); + } +} + +//--------------------------------------------------------- // setZ //--------------------------------------------------------- void SigEdit::setZ(const int z) { _sig.z=z; - if (_sig.isValid()) { - zSpin->setStyleSheet(""); - emit valueChanged(_sig); - } - else - zSpin->setStyleSheet("QSpinBox { background-color: red; }"); + emit valueChanged(_sig); } //--------------------------------------------------------- // setN @@ -118,13 +135,18 @@ void SigEdit::updateValue() nSpin->setValue(_sig.n); } - void SigEdit::paintEvent(QPaintEvent* event) { +void SigEdit::paintEvent(QPaintEvent* event) { if (!initialized) updateValue(); initialized = true; QPainter p(this); - p.fillRect(event->rect(), Qt::white); + p.fillRect(event->rect(), p.background()); QWidget::paintEvent(event); } +void SigEdit::setFocus() +{ + zSpin->setFocus(); +} + } |