12class ChangeParameterValueCommand :
public QUndoCommand
18 QObject::tr (
"Change '%1' value to %2").arg (param.label ()).arg (value)),
19 param_ (param), value_after_ (value)
23 int id ()
const override {
return 89453187; }
24 bool mergeWith (
const QUndoCommand * other)
override
26 if (other->id () != id ())
31 const auto * other_cmd =
32 dynamic_cast<const ChangeParameterValueCommand *
> (other);
33 const auto cur_time = std::chrono::steady_clock::now ();
34 const auto duration = cur_time - last_redo_timestamp_;
36 std::chrono::duration_cast<std::chrono::milliseconds> (duration).count ()
42 last_redo_timestamp_ = cur_time;
43 value_after_ = other_cmd->value_after_;
47 void undo ()
override { param_.setBaseValue (value_before_); }
50 value_before_ = param_.baseValue ();
51 param_.setBaseValue (value_after_);
52 last_redo_timestamp_ = std::chrono::steady_clock::now ();
57 float value_before_{};
59 std::chrono::time_point<std::chrono::steady_clock> last_redo_timestamp_;