diff --git a/app/core.cpp b/app/core.cpp index d6a339eaf..70fb71f6c 100644 --- a/app/core.cpp +++ b/app/core.cpp @@ -27,6 +27,7 @@ #include #include #include +#include #include #include @@ -970,6 +971,38 @@ void Core::SetPreferenceForRenderMode(RenderMode::Mode mode, const QString &pref Config::Current()[GetRenderModePreferencePrefix(mode, preference)] = value; } +void Core::LabelNodes(const QList &nodes) const +{ + if (nodes.isEmpty()) { + return; + } + + bool ok; + + QString start_label = nodes.first()->GetLabel(); + + for (int i=1; iGetLabel() != start_label) { + // Not all the nodes share the same name, so we'll start with a blank one + start_label.clear(); + break; + } + } + + QString s = QInputDialog::getText(main_window_, + tr("Label Node"), + tr("Set node label"), + QLineEdit::Normal, + start_label, + &ok); + + if (ok) { + foreach (Node* n, nodes) { + n->SetLabel(s); + } + } +} + SequencePtr Core::CreateNewSequenceForProject(Project* project) const { SequencePtr new_sequence = std::make_shared(); diff --git a/app/core.h b/app/core.h index 958fdf28c..07aeccb08 100644 --- a/app/core.h +++ b/app/core.h @@ -206,6 +206,11 @@ public: static QVariant GetPreferenceForRenderMode(RenderMode::Mode mode, const QString& preference); static void SetPreferenceForRenderMode(RenderMode::Mode mode, const QString& preference, const QVariant& value); + /** + * @brief Show a dialog to the user to rename a set of nodes + */ + void LabelNodes(const QList& nodes) const; + /** * @brief Create a new sequence named appropriately for the active project */ diff --git a/app/node/block/block.cpp b/app/node/block/block.cpp index 4bc07aba4..f46179786 100644 --- a/app/node/block/block.cpp +++ b/app/node/block/block.cpp @@ -31,11 +31,6 @@ Block::Block() : previous_(nullptr), next_(nullptr) { - name_input_ = new NodeInput("name_in", NodeParam::kString); - name_input_->set_connectable(false); - name_input_->set_is_keyframable(false); - AddInput(name_input_); - length_input_ = new NodeInput("length_in", NodeParam::kRational); length_input_->set_connectable(false); length_input_->set_is_keyframable(false); @@ -195,18 +190,6 @@ void Block::set_enabled(bool e) emit EnabledChanged(); } -QString Block::block_name() const -{ - return name_input_->get_standard_value().toString(); -} - -void Block::set_block_name(const QString &name) -{ - name_input_->set_standard_value(name); - - emit NameChanged(); -} - rational Block::SequenceToMediaTime(const rational &sequence_time) const { // These constants are not considered "values" per se, so we don't modify them @@ -351,7 +334,6 @@ void Block::Retranslate() { Node::Retranslate(); - name_input_->set_name(tr("Name")); length_input_->set_name(tr("Length")); media_in_input_->set_name(tr("Media In")); enabled_input_->set_name(tr("Enabled")); diff --git a/app/node/block/block.h b/app/node/block/block.h index 6568ca543..5694d4391 100644 --- a/app/node/block/block.h +++ b/app/node/block/block.h @@ -72,9 +72,6 @@ public: bool is_enabled() const; void set_enabled(bool e); - QString block_name() const; - void set_block_name(const QString& name); - static bool Link(Block* a, Block* b); static void Link(const QList& blocks); static bool Unlink(Block* a, Block* b); @@ -109,8 +106,6 @@ signals: void LinksChanged(); - void NameChanged(); - void EnabledChanged(); protected: @@ -134,7 +129,6 @@ protected: private: void set_length_internal(const rational &length); - NodeInput* name_input_; NodeInput* length_input_; NodeInput* media_in_input_; NodeInput* speed_input_; diff --git a/app/widget/nodeview/nodeview.cpp b/app/widget/nodeview/nodeview.cpp index 087b8abae..24af22840 100644 --- a/app/widget/nodeview/nodeview.cpp +++ b/app/widget/nodeview/nodeview.cpp @@ -490,15 +490,13 @@ void NodeView::ShowContextMenu(const QPoint &pos) if (itemAt(pos) && !selected.isEmpty()) { - if (selected.size() == 1) { + // Label node action + QAction* label_action = m.addAction(tr("Label")); + connect(label_action, &QAction::triggered, this, [this](){ + Core::instance()->LabelNodes(scene_.GetSelectedNodes()); + }); - // Label node action - QAction* label_action = m.addAction(tr("Label")); - connect(label_action, &QAction::triggered, this, &NodeView::ContextMenuLabelNode); - - m.addSeparator(); - - } + m.addSeparator(); // Auto-position action QAction* autopos = m.addAction(tr("Auto-Position")); @@ -591,30 +589,6 @@ void NodeView::AutoPositionDescendents() } } -void NodeView::ContextMenuLabelNode() -{ - QList nodes = scene_.GetSelectedNodes(); - - if (nodes.isEmpty()) { - return; - } - - Node* n = nodes.first(); - - bool ok; - - QString s = QInputDialog::getText(this, - tr("Label Node"), - tr("Set node label"), - QLineEdit::Normal, - n->GetLabel(), - &ok); - - if (ok) { - n->SetLabel(s); - } -} - void NodeView::ContextMenuFilterChanged(QAction *action) { FilterMode filter = static_cast(action->data().toInt()); diff --git a/app/widget/nodeview/nodeview.h b/app/widget/nodeview/nodeview.h index 4c5d6c614..bca1d669a 100644 --- a/app/widget/nodeview/nodeview.h +++ b/app/widget/nodeview/nodeview.h @@ -175,11 +175,6 @@ private slots: */ void AutoPositionDescendents(); - /** - * @brief Receiver for labelling a node from the context menu - */ - void ContextMenuLabelNode(); - /** * @brief Receiver for the user changing the filter */ diff --git a/app/widget/nodeview/nodeviewscene.cpp b/app/widget/nodeview/nodeviewscene.cpp index 070bff7c1..a36657b7c 100644 --- a/app/widget/nodeview/nodeviewscene.cpp +++ b/app/widget/nodeview/nodeviewscene.cpp @@ -291,10 +291,12 @@ bool NodeViewScene::GetEdgesAreCurved() const void NodeViewScene::SetEdgesAreCurved(bool curved) { - curved_edges_ = curved; + if (curved_edges_ != curved) { + curved_edges_ = curved; - foreach (NodeViewEdge* e, edge_map_) { - e->SetCurved(curved_edges_); + foreach (NodeViewEdge* e, edge_map_) { + e->SetCurved(curved_edges_); + } } } diff --git a/app/widget/timelinewidget/timelinewidget.cpp b/app/widget/timelinewidget/timelinewidget.cpp index 677c31360..880ac9870 100644 --- a/app/widget/timelinewidget/timelinewidget.cpp +++ b/app/widget/timelinewidget/timelinewidget.cpp @@ -965,7 +965,7 @@ void TimelineWidget::AddBlock(Block *block, TrackReference track) connect(block, &Block::Refreshed, this, &TimelineWidget::BlockRefreshed); connect(block, &Block::LinksChanged, this, &TimelineWidget::BlockUpdated); - connect(block, &Block::NameChanged, this, &TimelineWidget::BlockUpdated); + connect(block, &Block::LabelChanged, this, &TimelineWidget::BlockUpdated); connect(block, &Block::EnabledChanged, this, &TimelineWidget::BlockUpdated); } @@ -973,7 +973,7 @@ void TimelineWidget::RemoveBlock(Block *block) { disconnect(block, &Block::Refreshed, this, &TimelineWidget::BlockRefreshed); disconnect(block, &Block::LinksChanged, this, &TimelineWidget::BlockUpdated); - disconnect(block, &Block::NameChanged, this, &TimelineWidget::BlockUpdated); + disconnect(block, &Block::LabelChanged, this, &TimelineWidget::BlockUpdated); disconnect(block, &Block::EnabledChanged, this, &TimelineWidget::BlockUpdated); delete block_items_.take(block); diff --git a/app/widget/timelinewidget/tool/add.cpp b/app/widget/timelinewidget/tool/add.cpp index 06393bcf8..8f1ae9c74 100644 --- a/app/widget/timelinewidget/tool/add.cpp +++ b/app/widget/timelinewidget/tool/add.cpp @@ -105,7 +105,7 @@ void TimelineWidget::AddTool::MouseRelease(TimelineViewMouseEvent *event) ClipBlock* clip = new ClipBlock(); clip->set_length_and_media_out(ghost_->AdjustedLength()); - clip->set_block_name(OLIVE_NAMESPACE::Tool::GetAddableObjectName(Core::instance()->selected_addable_object())); + clip->SetLabel(OLIVE_NAMESPACE::Tool::GetAddableObjectName(Core::instance()->selected_addable_object())); NodeGraph* graph = static_cast(parent()->GetConnectedNode()->parent()); diff --git a/app/widget/timelinewidget/tool/import.cpp b/app/widget/timelinewidget/tool/import.cpp index ca0bf95b7..148129721 100644 --- a/app/widget/timelinewidget/tool/import.cpp +++ b/app/widget/timelinewidget/tool/import.cpp @@ -396,7 +396,7 @@ void TimelineWidget::ImportTool::DropGhosts(bool insert) ClipBlock* clip = new ClipBlock(); clip->set_media_in(ghost->MediaIn()); clip->set_length_and_media_out(ghost->Length()); - clip->set_block_name(footage_stream->footage()->name()); + clip->SetLabel(footage_stream->footage()->name()); new NodeAddCommand(dst_graph, clip, command); switch (footage_stream->type()) { diff --git a/app/widget/timelinewidget/view/timelineviewblockitem.cpp b/app/widget/timelinewidget/view/timelineviewblockitem.cpp index 74bbc66bf..733b9c88c 100644 --- a/app/widget/timelinewidget/view/timelineviewblockitem.cpp +++ b/app/widget/timelinewidget/view/timelineviewblockitem.cpp @@ -122,12 +122,12 @@ void TimelineViewBlockItem::paint(QPainter *painter, const QStyleOptionGraphicsI int text_top = TrackOutput::GetTrackHeightMinimum() / 2 - painter->fontMetrics().height() / 2; QRectF text_rect = rect(); text_rect.adjust(0, text_top, 0, 0); - painter->drawText(text_rect, Qt::AlignLeft | Qt::AlignTop, block_->block_name()); + painter->drawText(text_rect, Qt::AlignLeft | Qt::AlignTop, block_->GetLabel()); // Linked clips are underlined if (block_->HasLinks()) { QFontMetrics fm = painter->fontMetrics(); - int text_width = qMin(qRound(rect().width()), QFontMetricsWidth(fm, block_->block_name())); + int text_width = qMin(qRound(rect().width()), QFontMetricsWidth(fm, block_->GetLabel())); QPointF underline_start = rect().topLeft() + QPointF(0, text_top + fm.height()); QPointF underline_end = underline_start + QPointF(text_width, 0);