diff --git a/app/node/audio/pan/pan.cpp b/app/node/audio/pan/pan.cpp index 9b0b688f7..71ae6ea6f 100644 --- a/app/node/audio/pan/pan.cpp +++ b/app/node/audio/pan/pan.cpp @@ -28,9 +28,9 @@ PanNode::PanNode() AddInput(samples_input_); panning_input_ = new NodeInput("panning_in", NodeParam::kFloat, 0.0); - panning_input_->set_property("min", -1.0); - panning_input_->set_property("max", 1.0); - panning_input_->set_property("view", "percent"); + panning_input_->setProperty("min", -1.0); + panning_input_->setProperty("max", 1.0); + panning_input_->setProperty("view", QStringLiteral("percent")); AddInput(panning_input_); } diff --git a/app/node/audio/volume/volume.cpp b/app/node/audio/volume/volume.cpp index 5f6d829c2..20c94b342 100644 --- a/app/node/audio/volume/volume.cpp +++ b/app/node/audio/volume/volume.cpp @@ -24,13 +24,13 @@ namespace olive { VolumeNode::VolumeNode() { - samples_input_ = new NodeInput("samples_in", NodeParam::kSamples); + samples_input_ = new NodeInput(QStringLiteral("samples_in"), NodeParam::kSamples); samples_input_->set_is_keyframable(false); AddInput(samples_input_); - volume_input_ = new NodeInput("volume_in", NodeParam::kFloat, 1.0); - volume_input_->set_property("min", 0.0); - volume_input_->set_property("view", "db"); + volume_input_ = new NodeInput(QStringLiteral("volume_in"), NodeParam::kFloat, 1.0); + volume_input_->setProperty("min", 0.0); + volume_input_->setProperty("view", QStringLiteral("db")); AddInput(volume_input_); } diff --git a/app/node/block/block.cpp b/app/node/block/block.cpp index 6cdc8535e..29857d25f 100644 --- a/app/node/block/block.cpp +++ b/app/node/block/block.cpp @@ -51,7 +51,7 @@ Block::Block() : speed_input_ = new NodeInput("speed_in", NodeParam::kFloat); speed_input_->set_standard_value(1.0); - speed_input_->set_property(QStringLiteral("view"), QStringLiteral("percent")); + speed_input_->setProperty("view", QStringLiteral("percent")); AddInput(speed_input_); // A block's length must be greater than 0 diff --git a/app/node/distort/crop/cropdistortnode.cpp b/app/node/distort/crop/cropdistortnode.cpp index b3b706f0a..4c7c8b446 100644 --- a/app/node/distort/crop/cropdistortnode.cpp +++ b/app/node/distort/crop/cropdistortnode.cpp @@ -30,31 +30,31 @@ CropDistortNode::CropDistortNode() AddInput(texture_input_); left_input_ = new NodeInput(QStringLiteral("left_in"), NodeParam::kFloat, 0.0); - left_input_->set_property(QStringLiteral("min"), 0.0); - left_input_->set_property(QStringLiteral("max"), 1.0); - left_input_->set_property(QStringLiteral("view"), QStringLiteral("percent")); + left_input_->setProperty("min", 0.0); + left_input_->setProperty("max", 1.0); + left_input_->setProperty("view", QStringLiteral("percent")); AddInput(left_input_); top_input_ = new NodeInput(QStringLiteral("top_in"), NodeParam::kFloat, 0.0); - top_input_->set_property(QStringLiteral("min"), 0.0); - top_input_->set_property(QStringLiteral("max"), 1.0); - top_input_->set_property(QStringLiteral("view"), QStringLiteral("percent")); + top_input_->setProperty("min", 0.0); + top_input_->setProperty("max", 1.0); + top_input_->setProperty("view", QStringLiteral("percent")); AddInput(top_input_); right_input_ = new NodeInput(QStringLiteral("right_in"), NodeParam::kFloat, 0.0); - right_input_->set_property(QStringLiteral("min"), 0.0); - right_input_->set_property(QStringLiteral("max"), 1.0); - right_input_->set_property(QStringLiteral("view"), QStringLiteral("percent")); + right_input_->setProperty("min", 0.0); + right_input_->setProperty("max", 1.0); + right_input_->setProperty("view", QStringLiteral("percent")); AddInput(right_input_); bottom_input_ = new NodeInput(QStringLiteral("bottom_in"), NodeParam::kFloat, 0.0); - bottom_input_->set_property(QStringLiteral("min"), 0.0); - bottom_input_->set_property(QStringLiteral("max"), 1.0); - bottom_input_->set_property(QStringLiteral("view"), QStringLiteral("percent")); + bottom_input_->setProperty("min", 0.0); + bottom_input_->setProperty("max", 1.0); + bottom_input_->setProperty("view", QStringLiteral("percent")); AddInput(bottom_input_); feather_input_ = new NodeInput(QStringLiteral("feather_in"), NodeParam::kFloat, 0.0); - feather_input_->set_property(QStringLiteral("min"), 0.0); + feather_input_->setProperty("min", 0.0); AddInput(feather_input_); } diff --git a/app/node/distort/transform/transformdistortnode.cpp b/app/node/distort/transform/transformdistortnode.cpp index 9235ac603..46abe9cf4 100644 --- a/app/node/distort/transform/transformdistortnode.cpp +++ b/app/node/distort/transform/transformdistortnode.cpp @@ -437,8 +437,8 @@ void TransformDistortNode::DrawGizmos(NodeValueDatabase &db, QPainter *p) // Use offsets to make the appearance of values that start in the top left, even though we // really anchor around the center - position_input()->set_property(QStringLiteral("offset"), sequence_res * 0.5); - anchor_input()->set_property(QStringLiteral("offset"), tex_sz * 0.5); + position_input()->setProperty("offset", sequence_res * 0.5); + anchor_input()->setProperty("offset", tex_sz * 0.5); } } diff --git a/app/node/filter/blur/blur.cpp b/app/node/filter/blur/blur.cpp index fbc42efda..70e07d79f 100644 --- a/app/node/filter/blur/blur.cpp +++ b/app/node/filter/blur/blur.cpp @@ -31,7 +31,7 @@ BlurFilterNode::BlurFilterNode() AddInput(method_input_); radius_input_ = new NodeInput("radius_in", NodeParam::kFloat, 10.0f); - radius_input_->set_property(QStringLiteral("min"), 0.0f); + radius_input_->setProperty("min", 0.0f); AddInput(radius_input_); horiz_input_ = new NodeInput("horiz_in", NodeParam::kBoolean, true); diff --git a/app/node/filter/mosaic/mosaicfilternode.cpp b/app/node/filter/mosaic/mosaicfilternode.cpp index 001c12be5..b1e633b63 100644 --- a/app/node/filter/mosaic/mosaicfilternode.cpp +++ b/app/node/filter/mosaic/mosaicfilternode.cpp @@ -27,12 +27,12 @@ MosaicFilterNode::MosaicFilterNode() tex_input_ = new NodeInput(QStringLiteral("tex_in"), NodeParam::kTexture); AddInput(tex_input_); - horiz_input_ = new NodeInput(QStringLiteral("horiz_in"), NodeParam::kFloat); - horiz_input_->set_property(QStringLiteral("min"), 1.0); + horiz_input_ = new NodeInput(QStringLiteral("horiz_in"), NodeParam::kFloat, 32.0); + horiz_input_->setProperty("min", 1.0); AddInput(horiz_input_); - vert_input_ = new NodeInput(QStringLiteral("vert_in"), NodeParam::kFloat); - vert_input_->set_property(QStringLiteral("min"), 1.0); + vert_input_ = new NodeInput(QStringLiteral("vert_in"), NodeParam::kFloat, 18.0); + vert_input_->setProperty("min", 1.0); AddInput(vert_input_); } diff --git a/app/node/filter/stroke/stroke.cpp b/app/node/filter/stroke/stroke.cpp index c2aca5c3d..edc74b4c5 100644 --- a/app/node/filter/stroke/stroke.cpp +++ b/app/node/filter/stroke/stroke.cpp @@ -35,13 +35,13 @@ StrokeFilterNode::StrokeFilterNode() AddInput(color_input_); radius_input_ = new NodeInput("radius_in", NodeParam::kFloat, 10.0f); - radius_input_->set_property("min", 0.0f); + radius_input_->setProperty("min", 0.0f); AddInput(radius_input_); opacity_input_ = new NodeInput("opacity_in", NodeParam::kFloat, 1.0f); - opacity_input_->set_property("view", "percent"); - opacity_input_->set_property("min", 0.0f); - opacity_input_->set_property("max", 1.0f); + opacity_input_->setProperty("view", QStringLiteral("percent")); + opacity_input_->setProperty("min", 0.0f); + opacity_input_->setProperty("max", 1.0f); AddInput(opacity_input_); inner_input_ = new NodeInput("inner_in", NodeParam::kBoolean, false); diff --git a/app/node/generator/matrix/matrix.cpp b/app/node/generator/matrix/matrix.cpp index 6f57a0bde..52cecfad2 100644 --- a/app/node/generator/matrix/matrix.cpp +++ b/app/node/generator/matrix/matrix.cpp @@ -34,9 +34,9 @@ MatrixGenerator::MatrixGenerator() AddInput(rotation_input_); scale_input_ = new NodeInput("scale_in", NodeParam::kVec2, QVector2D(1.0f, 1.0f)); - scale_input_->set_property("min", QVector2D(0, 0)); - scale_input_->set_property("view", "percent"); - scale_input_->set_property("disabley", true); + scale_input_->setProperty("min", QVector2D(0, 0)); + scale_input_->setProperty("view", QStringLiteral("percent")); + scale_input_->setProperty("disabley", true); AddInput(scale_input_); uniform_scale_input_ = new NodeInput("uniform_scale_in", NodeParam::kBoolean, true); @@ -183,7 +183,7 @@ QMatrix4x4 MatrixGenerator::GenerateMatrix(const QVector2D& pos, void MatrixGenerator::UniformScaleChanged() { - scale_input_->set_property("disabley", uniform_scale_input_->get_standard_value().toBool()); + scale_input_->setProperty("disabley", uniform_scale_input_->get_standard_value().toBool()); } } diff --git a/app/node/input.cpp b/app/node/input.cpp index c8d07f65b..b1ac562b8 100644 --- a/app/node/input.cpp +++ b/app/node/input.cpp @@ -192,13 +192,13 @@ void NodeInput::Load(QXmlStreamReader *reader, XMLNodeData &xml_node_data, const } } } else if (reader->name() == QStringLiteral("csinput")) { - set_property(QStringLiteral("col_input"), reader->readElementText()); + setProperty("col_input", reader->readElementText()); } else if (reader->name() == QStringLiteral("csdisplay")) { - set_property(QStringLiteral("col_display"), reader->readElementText()); + setProperty("col_display", reader->readElementText()); } else if (reader->name() == QStringLiteral("csview")) { - set_property(QStringLiteral("col_view"), reader->readElementText()); + setProperty("col_view", reader->readElementText()); } else if (reader->name() == QStringLiteral("cslook")) { - set_property(QStringLiteral("col_look"), reader->readElementText()); + setProperty("col_look", reader->readElementText()); } else if (reader->name() == QStringLiteral("custom")) { LoadInternal(reader, xml_node_data, cancelled); } else { @@ -250,10 +250,10 @@ void NodeInput::Save(QXmlStreamWriter *writer) const if (data_type_ == NodeParam::kColor) { // Save color management information - writer->writeTextElement(QStringLiteral("csinput"), get_property(QStringLiteral("col_input")).toString()); - writer->writeTextElement(QStringLiteral("csdisplay"), get_property(QStringLiteral("col_display")).toString()); - writer->writeTextElement(QStringLiteral("csview"), get_property(QStringLiteral("col_view")).toString()); - writer->writeTextElement(QStringLiteral("cslook"), get_property(QStringLiteral("col_look")).toString()); + writer->writeTextElement(QStringLiteral("csinput"), property("col_input").toString()); + writer->writeTextElement(QStringLiteral("csdisplay"), property("col_display").toString()); + writer->writeTextElement(QStringLiteral("csview"), property("col_view").toString()); + writer->writeTextElement(QStringLiteral("cslook"), property("col_look").toString()); } SaveConnections(writer); @@ -289,6 +289,17 @@ void NodeInput::SaveInternal(QXmlStreamWriter*) const { } +bool NodeInput::event(QEvent *e) +{ + if (e->type() == QEvent::DynamicPropertyChange) { + QByteArray key = static_cast(e)->propertyName(); + emit PropertyChanged(key, property(key)); + return true; + } + + return QObject::event(e); +} + void NodeInput::Init(DataType type) { keyframable_ = true; @@ -1106,27 +1117,6 @@ void NodeInput::CopyValues(NodeInput *source, NodeInput *dest, bool include_conn emit dest->ValueChanged(TimeRange(RATIONAL_MIN, RATIONAL_MAX)); } -void NodeInput::set_property(const QString &key, const QVariant &value) -{ - properties_.insert(key, value); - emit PropertyChanged(key, value); -} - -QVariant NodeInput::get_property(const QString &key) const -{ - return properties_.value(key); -} - -bool NodeInput::has_property(const QString &key) const -{ - return properties_.contains(key); -} - -const QHash &NodeInput::properties() const -{ - return properties_; -} - QVector NodeInput::split_normal_value_into_track_values(const QVariant &value) const { QVector vals(get_number_of_keyframe_tracks()); @@ -1207,12 +1197,12 @@ QVariant NodeInput::combine_track_values_into_normal_value(const QVector& properties() const; - QVector split_normal_value_into_track_values(const QVariant &value) const; QVariant combine_track_values_into_normal_value(const QVector& split) const; @@ -310,6 +277,8 @@ protected: virtual void SaveInternal(QXmlStreamWriter* writer) const; + virtual bool event(QEvent* e) override; + private: void Init(NodeParam::DataType type); @@ -398,11 +367,6 @@ private: */ bool keyframing_; - /** - * @brief Internal properties variable - */ - QHash properties_; - private slots: /** * @brief Slot when a keyframe's time changes to keep the keyframes correctly sorted by time diff --git a/app/node/inputdragger.cpp b/app/node/inputdragger.cpp index c0067c4fb..265994c46 100644 --- a/app/node/inputdragger.cpp +++ b/app/node/inputdragger.cpp @@ -74,17 +74,17 @@ void NodeInputDragger::Drag(QVariant value) { Q_ASSERT(input_); - if (!input_->get_property(QStringLiteral("min")).isNull()) { + if (input_->property("min").isValid()) { // Assumes the value is a double of some kind - double min = input_->get_property(QStringLiteral("min")).toDouble(); + double min = input_->property("min").toDouble(); double v = value.toDouble(); if (v < min) { value = min; } } - if (!input_->get_property(QStringLiteral("max")).isNull()) { - double max = input_->get_property(QStringLiteral("max")).toDouble(); + if (input_->property("max").isValid()) { + double max = input_->property("max").toDouble(); double v = value.toDouble(); if (v > max) { value = max; diff --git a/app/node/math/math/math.cpp b/app/node/math/math/math.cpp index caa4d8f42..41d30bbf8 100644 --- a/app/node/math/math/math.cpp +++ b/app/node/math/math/math.cpp @@ -30,13 +30,13 @@ MathNode::MathNode() AddInput(method_in_); param_a_in_ = new NodeInput(QStringLiteral("param_a_in"), NodeParam::kFloat, 0.0); - param_a_in_->set_property(QStringLiteral("decimalplaces"), 8); - param_a_in_->set_property(QStringLiteral("autotrim"), true); + param_a_in_->setProperty("decimalplaces", 8); + param_a_in_->setProperty("autotrim", true); AddInput(param_a_in_); param_b_in_ = new NodeInput(QStringLiteral("param_b_in"), NodeParam::kFloat, 0.0); - param_b_in_->set_property(QStringLiteral("decimalplaces"), 8); - param_b_in_->set_property(QStringLiteral("autotrim"), true); + param_b_in_->setProperty("decimalplaces", 8); + param_b_in_->setProperty("autotrim", true); AddInput(param_b_in_); } diff --git a/app/widget/nodeparamview/nodeparamviewwidgetbridge.cpp b/app/widget/nodeparamview/nodeparamviewwidgetbridge.cpp index c0fd282a4..59559d5c4 100644 --- a/app/widget/nodeparamview/nodeparamviewwidgetbridge.cpp +++ b/app/widget/nodeparamview/nodeparamviewwidgetbridge.cpp @@ -180,10 +180,8 @@ void NodeParamViewWidgetBridge::CreateWidgets() } // Check all properties - QHash::const_iterator iterator; - - for (iterator=input_->properties().begin();iterator!=input_->properties().end();iterator++) { - PropertyChanged(iterator.key(), iterator.value()); + foreach (const QByteArray& key, input_->dynamicPropertyNames()) { + PropertyChanged(key, input_->property(key)); } UpdateWidgetValues(); @@ -281,7 +279,7 @@ void NodeParamViewWidgetBridge::WidgetCallback() // Widget is a IntegerSlider IntegerSlider* slider = static_cast(sender()); - int64_t offset = input_->get_property(QStringLiteral("offset")).toLongLong(); + int64_t offset = input_->property("offset").toLongLong(); ProcessSlider(slider, QVariant::fromValue(slider->GetValue() - offset)); break; @@ -291,7 +289,7 @@ void NodeParamViewWidgetBridge::WidgetCallback() // Widget is a FloatSlider FloatSlider* slider = static_cast(sender()); - double offset = input_->get_property(QStringLiteral("offset")).toDouble(); + double offset = input_->property("offset").toDouble(); ProcessSlider(slider, slider->GetValue() - offset); break; @@ -301,7 +299,7 @@ void NodeParamViewWidgetBridge::WidgetCallback() // Widget is a FloatSlider FloatSlider* slider = static_cast(sender()); - QVector2D offset = input_->get_property(QStringLiteral("offset")).value(); + QVector2D offset = input_->property("offset").value(); ProcessSlider(slider, slider->GetValue() - offset[widgets_.indexOf(slider)]); break; @@ -311,7 +309,7 @@ void NodeParamViewWidgetBridge::WidgetCallback() // Widget is a FloatSlider FloatSlider* slider = static_cast(sender()); - QVector3D offset = input_->get_property(QStringLiteral("offset")).value(); + QVector3D offset = input_->property("offset").value(); ProcessSlider(slider, slider->GetValue() - offset[widgets_.indexOf(slider)]); break; @@ -321,7 +319,7 @@ void NodeParamViewWidgetBridge::WidgetCallback() // Widget is a FloatSlider FloatSlider* slider = static_cast(sender()); - QVector4D offset = input_->get_property(QStringLiteral("offset")).value(); + QVector4D offset = input_->property("offset").value(); ProcessSlider(slider, slider->GetValue() - offset[widgets_.indexOf(slider)]); break; @@ -342,10 +340,10 @@ void NodeParamViewWidgetBridge::WidgetCallback() SetInputValueInternal(c.alpha(), 3, command); input_->blockSignals(true); - input_->set_property(QStringLiteral("col_input"), c.color_input()); - input_->set_property(QStringLiteral("col_display"), c.color_output().display()); - input_->set_property(QStringLiteral("col_view"), c.color_output().view()); - input_->set_property(QStringLiteral("col_look"), c.color_output().look()); + input_->setProperty("col_input", c.color_input()); + input_->setProperty("col_display", c.color_output().display()); + input_->setProperty("col_view", c.color_output().view()); + input_->setProperty("col_look", c.color_output().look()); input_->blockSignals(false); Core::instance()->undo_stack()->pushIfHasChildren(command); @@ -433,14 +431,14 @@ void NodeParamViewWidgetBridge::UpdateWidgetValues() break; case NodeParam::kInt: { - int64_t offset = input_->get_property(QStringLiteral("offset")).toLongLong(); + int64_t offset = input_->property("offset").toLongLong(); static_cast(widgets_.first())->SetValue(input_->get_value_at_time(node_time).toLongLong() + offset); break; } case NodeParam::kFloat: { - double offset = input_->get_property(QStringLiteral("offset")).toDouble(); + double offset = input_->property("offset").toDouble(); static_cast(widgets_.first())->SetValue(input_->get_value_at_time(node_time).toDouble() + offset); break; @@ -448,7 +446,7 @@ void NodeParamViewWidgetBridge::UpdateWidgetValues() case NodeParam::kVec2: { QVector2D vec2 = input_->get_value_at_time(node_time).value(); - QVector2D offset = input_->get_property(QStringLiteral("offset")).value(); + QVector2D offset = input_->property("offset").value(); static_cast(widgets_.at(0))->SetValue(static_cast(vec2.x() + offset.x())); static_cast(widgets_.at(1))->SetValue(static_cast(vec2.y() + offset.y())); @@ -457,7 +455,7 @@ void NodeParamViewWidgetBridge::UpdateWidgetValues() case NodeParam::kVec3: { QVector3D vec3 = input_->get_value_at_time(node_time).value(); - QVector3D offset = input_->get_property(QStringLiteral("offset")).value(); + QVector3D offset = input_->property("offset").value(); static_cast(widgets_.at(0))->SetValue(static_cast(vec3.x() + offset.x())); static_cast(widgets_.at(1))->SetValue(static_cast(vec3.y() + offset.y())); @@ -467,7 +465,7 @@ void NodeParamViewWidgetBridge::UpdateWidgetValues() case NodeParam::kVec4: { QVector4D vec4 = input_->get_value_at_time(node_time).value(); - QVector4D offset = input_->get_property(QStringLiteral("offset")).value(); + QVector4D offset = input_->property("offset").value(); static_cast(widgets_.at(0))->SetValue(static_cast(vec4.x() + offset.x())); static_cast(widgets_.at(1))->SetValue(static_cast(vec4.y() + offset.y())); @@ -482,11 +480,11 @@ void NodeParamViewWidgetBridge::UpdateWidgetValues() { ManagedColor mc = input_->get_value_at_time(node_time).value(); - mc.set_color_input(input_->get_property(QStringLiteral("col_input")).toString()); + mc.set_color_input(input_->property("col_input").toString()); - QString d = input_->get_property(QStringLiteral("col_display")).toString(); - QString v = input_->get_property(QStringLiteral("col_view")).toString(); - QString l = input_->get_property(QStringLiteral("col_look")).toString(); + QString d = input_->property("col_display").toString(); + QString v = input_->property("col_view").toString(); + QString l = input_->property("col_look").toString(); mc.set_color_output(ColorTransform(d, v, l));