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:
@@ -27,6 +27,7 @@
|
||||
#include <QFileDialog>
|
||||
#include <QFileInfo>
|
||||
#include <QHBoxLayout>
|
||||
#include <QInputDialog>
|
||||
#include <QMessageBox>
|
||||
#include <QStyleFactory>
|
||||
|
||||
@@ -970,6 +971,38 @@ void Core::SetPreferenceForRenderMode(RenderMode::Mode mode, const QString &pref
|
||||
Config::Current()[GetRenderModePreferencePrefix(mode, preference)] = value;
|
||||
}
|
||||
|
||||
void Core::LabelNodes(const QList<Node *> &nodes) const
|
||||
{
|
||||
if (nodes.isEmpty()) {
|
||||
return;
|
||||
}
|
||||
|
||||
bool ok;
|
||||
|
||||
QString start_label = nodes.first()->GetLabel();
|
||||
|
||||
for (int i=1; i<nodes.size(); i++) {
|
||||
if (nodes.at(i)->GetLabel() != 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<Sequence>();
|
||||
|
||||
@@ -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<Node*>& nodes) const;
|
||||
|
||||
/**
|
||||
* @brief Create a new sequence named appropriately for the active project
|
||||
*/
|
||||
|
||||
@@ -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"));
|
||||
|
||||
@@ -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<Block*>& 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_;
|
||||
|
||||
@@ -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());
|
||||
|
||||
@@ -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
|
||||
*/
|
||||
|
||||
@@ -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_);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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());
|
||||
|
||||
|
||||
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user