void TrackView::editBiasValue(float amount) { SyncDocument *doc = getDocument(); if (0 == getTrackCount()) { QApplication::beep(); return; } QRect selection = getSelection(); doc->beginMacro("bias"); for (int track = selection.left(); track <= selection.right(); ++track) { Q_ASSERT(track < getTrackCount()); SyncTrack *t = getTrack(track); for (int row = selection.top(); row <= selection.bottom(); ++row) { if (t->isKeyFrame(row)) { SyncTrack::TrackKey k = t->getKeyFrame(row); // copy old key k.value += amount; // modify value // add sub-command doc->setKeyFrame(t, k); } } } doc->endMacro(); dirtyCurrentValue(); }
void TrackView::editEnterValue() { SyncDocument *doc = getDocument(); if (!lineEdit->isVisible()) return; if (lineEdit->text().length() > 0 && editTrack < getTrackCount()) { SyncTrack *t = getTrack(editTrack); SyncTrack::TrackKey newKey; newKey.type = SyncTrack::TrackKey::STEP; newKey.row = editRow; if (t->isKeyFrame(editRow)) newKey = t->getKeyFrame(editRow); // copy old key QString text = lineEdit->text(); text.remove(lineEdit->validator()->locale().groupSeparator()); // workaround QTBUG-40456 newKey.value = lineEdit->validator()->locale().toFloat(text); // modify value doc->setKeyFrame(t, newKey); dirtyCurrentValue(); } else QApplication::beep(); lineEdit->hide(); setFocus(); }