footagecombobox: fixed bug where footagecombobox would display null on first showing

This commit is contained in:
itsmattkc
2020-04-15 03:59:46 +10:00
parent cc421d4108
commit 2610d58ae3
3 changed files with 28 additions and 18 deletions
+20 -14
View File
@@ -1,4 +1,4 @@
/***
/***
Olive - Non-Linear Video Editor
Copyright (C) 2019 Olive Team
@@ -51,12 +51,7 @@ void FootageComboBox::showPopup()
QAction* selected = menu.exec(parentWidget()->mapToGlobal(pos()));
if (selected != nullptr) {
// Use combobox functions to show the footage name
clear();
addItem(selected->text());
footage_ = selected->data().value<StreamPtr>();
SetFootage(selected->data().value<StreamPtr>());
emit FootageChanged(footage_);
}
@@ -82,14 +77,9 @@ StreamPtr FootageComboBox::SelectedFootage()
void FootageComboBox::SetFootage(StreamPtr f)
{
// Remove existing single item used to show the footage name
clear();
footage_ = f;
if (footage_ != nullptr) {
// Use combobox functions to show the footage name
addItem(footage_->footage()->name());
}
UpdateText();
}
void FootageComboBox::TraverseFolder(const Folder *f, QMenu *m)
@@ -112,7 +102,7 @@ void FootageComboBox::TraverseFolder(const Folder *f, QMenu *m)
m->addMenu(stream_menu);
foreach (StreamPtr stream, footage->streams()) {
QAction* stream_action = stream_menu->addAction(stream->description());
QAction* stream_action = stream_menu->addAction(FootageToString(stream.get()));
stream_action->setData(QVariant::fromValue(stream));
stream_action->setIcon(Stream::IconFromType(stream->type()));
}
@@ -121,4 +111,20 @@ void FootageComboBox::TraverseFolder(const Folder *f, QMenu *m)
}
}
void FootageComboBox::UpdateText()
{
// Use combobox functions to show the footage name
clear();
if (footage_) {
// Use combobox functions to show the footage name
addItem(FootageToString(footage_.get()));
}
}
QString FootageComboBox::FootageToString(Stream *f)
{
return f->description();
}
OLIVE_NAMESPACE_EXIT
@@ -52,6 +52,10 @@ signals:
private:
void TraverseFolder(const Folder *f, QMenu* m);
void UpdateText();
static QString FootageToString(Stream* f);
const Folder* root_;
StreamPtr footage_;
@@ -55,11 +55,9 @@ void NodeParamViewWidgetBridge::SetTime(const rational &time)
{
time_ = time;
if (!input_) {
return;
if (input_) {
UpdateWidgetValues();
}
UpdateWidgetValues();
}
const QList<QWidget *> &NodeParamViewWidgetBridge::widgets() const
@@ -174,6 +172,8 @@ void NodeParamViewWidgetBridge::CreateWidgets()
for (iterator=input_->properties().begin();iterator!=input_->properties().end();iterator++) {
PropertyChanged(iterator.key(), iterator.value());
}
UpdateWidgetValues();
}
void NodeParamViewWidgetBridge::SetInputValue(const QVariant &value, int track)