nodes/clips: use node label as clip name and allow changing multiple labels at once

Merges the "clip name" and "node label" into the same entity.
This commit is contained in:
itsmattkc
2020-06-16 16:23:05 +10:00
parent cbbf1c9149
commit 41b04d976c
11 changed files with 55 additions and 70 deletions
+6 -32
View File
@@ -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<Node*> 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<FilterMode>(action->data().toInt());
-5
View File
@@ -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
*/
+5 -3
View File
@@ -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_);
}
}
}
+2 -2
View File
@@ -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);
+1 -1
View File
@@ -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<NodeGraph*>(parent()->GetConnectedNode()->parent());
+1 -1
View File
@@ -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()) {
@@ -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);