tracks: use node label instead of separate name string

This commit is contained in:
itsmattkc
2020-10-10 20:17:25 +11:00
parent 0cafbb2594
commit 0d102defab
5 changed files with 31 additions and 34 deletions
-14
View File
@@ -96,15 +96,6 @@ QString TrackOutput::Description() const
"a Sequence.");
}
QString TrackOutput::GetTrackName()
{
if (track_name_.isEmpty()) {
return GetDefaultTrackName(track_type_, index_);
}
return track_name_;
}
const double &TrackOutput::GetTrackHeight() const
{
return track_height_;
@@ -438,11 +429,6 @@ void TrackOutput::Hash(QCryptographicHash &hash, const rational &time) const
}
}
void TrackOutput::SetTrackName(const QString &name)
{
track_name_ = name;
}
void TrackOutput::SetMuted(bool e)
{
muted_input_->set_standard_value(e);
-6
View File
@@ -48,8 +48,6 @@ public:
virtual QList<CategoryID> Category() const override;
virtual QString Description() const override;
QString GetTrackName();
const double& GetTrackHeight() const;
void SetTrackHeight(const double& height);
@@ -229,8 +227,6 @@ public:
static const double kTrackHeightInterval;
public slots:
void SetTrackName(const QString& name);
void SetMuted(bool e);
void SetLocked(bool e);
@@ -296,8 +292,6 @@ private:
double track_height_;
QString track_name_;
int index_;
bool locked_;
+10 -3
View File
@@ -287,10 +287,17 @@ void NodeViewItem::paint(QPainter *painter, const QStyleOptionGraphicsItem *opti
QString node_label;
if (node_->GetLabel().isEmpty()) {
node_label = node_->ShortName();
} else {
if (!node_->GetLabel().isEmpty()) {
// Use label directly if node has one
node_label = node_->GetLabel();
} else if (node_->IsTrack()) {
// If node is a track, use a special track name to help users identify better
// Exception for tracks
TrackOutput* track = static_cast<TrackOutput*>(node_);
node_label = TrackOutput::GetDefaultTrackName(track->track_type(), track->Index());
} else {
// Otherwise, just use the node's short name
node_label = node_->ShortName();
}
QFont f;
@@ -39,24 +39,26 @@ TrackViewItem::TrackViewItem(TrackOutput* track, QWidget *parent) :
stack_ = new QStackedWidget();
layout->addWidget(stack_);
label_ = new ClickableLabel(track_->GetTrackName());
connect(label_, SIGNAL(MouseDoubleClicked()), this, SLOT(LabelClicked()));
label_ = new ClickableLabel();
connect(label_, &ClickableLabel::MouseDoubleClicked, this, &TrackViewItem::LabelClicked);
connect(track_, &TrackOutput::LabelChanged, this, &TrackViewItem::UpdateLabel);
UpdateLabel();
stack_->addWidget(label_);
line_edit_ = new FocusableLineEdit();
connect(line_edit_, SIGNAL(Confirmed()), this, SLOT(LineEditConfirmed()));
connect(line_edit_, SIGNAL(Cancelled()), this, SLOT(LineEditCancelled()));
connect(line_edit_, &FocusableLineEdit::Confirmed, this, &TrackViewItem::LineEditConfirmed);
connect(line_edit_, &FocusableLineEdit::Cancelled, this, &TrackViewItem::LineEditCancelled);
stack_->addWidget(line_edit_);
mute_button_ = CreateMSLButton(tr("M"), Qt::red);
connect(mute_button_, SIGNAL(toggled(bool)), track_, SLOT(SetMuted(bool)));
connect(mute_button_, &QPushButton::toggled, track_, &TrackOutput::SetMuted);
layout->addWidget(mute_button_);
/*solo_button_ = CreateMSLButton(tr("S"), Qt::yellow);
layout->addWidget(solo_button_);*/
lock_button_ = CreateMSLButton(tr("L"), Qt::gray);
connect(lock_button_, SIGNAL(toggled(bool)), track_, SLOT(SetLocked(bool)));
connect(lock_button_, &QPushButton::toggled, track_, &TrackOutput::SetLocked);
layout->addWidget(lock_button_);
setMinimumHeight(mute_button_->height());
@@ -89,11 +91,8 @@ void TrackViewItem::LineEditConfirmed()
{
line_edit_->blockSignals(true);
QString line_edit_str = line_edit_->text();
if (!line_edit_str.isEmpty()) {
label_->setText(line_edit_str);
track_->SetTrackName(line_edit_str);
}
track_->SetLabel(line_edit_->text());
UpdateLabel();
stack_->setCurrentWidget(label_);
@@ -109,4 +108,13 @@ void TrackViewItem::LineEditCancelled()
line_edit_->blockSignals(false);
}
void TrackViewItem::UpdateLabel()
{
if (track_->GetLabel().isEmpty()) {
label_->setText(track_->GetDefaultTrackName(track_->track_type(), track_->Index()));
} else {
label_->setText(track_->GetLabel());
}
}
OLIVE_NAMESPACE_EXIT
@@ -59,6 +59,8 @@ private slots:
void LineEditCancelled();
void UpdateLabel();
};
OLIVE_NAMESPACE_EXIT