change: change code style to Linux style except indent.
This commit is contained in:
@@ -29,161 +29,175 @@
|
||||
#include "widget/collapsebutton/collapsebutton.h"
|
||||
#include "widget/menu/menu.h"
|
||||
|
||||
namespace olive {
|
||||
|
||||
NodeParamViewConnectedLabel::NodeParamViewConnectedLabel(const NodeInput &input, QWidget *parent) :
|
||||
QWidget(parent),
|
||||
input_(input),
|
||||
connected_node_(nullptr),
|
||||
viewer_(nullptr)
|
||||
namespace olive
|
||||
{
|
||||
QVBoxLayout *layout = new QVBoxLayout(this);
|
||||
layout->setContentsMargins(0, 0, 0, 0);
|
||||
|
||||
QSizePolicy p = sizePolicy();
|
||||
p.setHorizontalStretch(1);
|
||||
p.setHorizontalPolicy(QSizePolicy::Expanding);
|
||||
setSizePolicy(p);
|
||||
NodeParamViewConnectedLabel::NodeParamViewConnectedLabel(const NodeInput &input,
|
||||
QWidget *parent)
|
||||
: QWidget(parent)
|
||||
, input_(input)
|
||||
, connected_node_(nullptr)
|
||||
, viewer_(nullptr)
|
||||
{
|
||||
QVBoxLayout *layout = new QVBoxLayout(this);
|
||||
layout->setContentsMargins(0, 0, 0, 0);
|
||||
|
||||
// Set up label area
|
||||
QHBoxLayout *label_layout = new QHBoxLayout();
|
||||
label_layout->setSpacing(QtUtils::QFontMetricsWidth(fontMetrics(), QStringLiteral(" ")));
|
||||
label_layout->setContentsMargins(0, 0, 0, 0);
|
||||
layout->addLayout(label_layout);
|
||||
QSizePolicy p = sizePolicy();
|
||||
p.setHorizontalStretch(1);
|
||||
p.setHorizontalPolicy(QSizePolicy::Expanding);
|
||||
setSizePolicy(p);
|
||||
|
||||
CollapseButton *collapse_btn = new CollapseButton(this);
|
||||
collapse_btn->setChecked(false);
|
||||
label_layout->addWidget(collapse_btn);
|
||||
// Set up label area
|
||||
QHBoxLayout *label_layout = new QHBoxLayout();
|
||||
label_layout->setSpacing(
|
||||
QtUtils::QFontMetricsWidth(fontMetrics(), QStringLiteral(" ")));
|
||||
label_layout->setContentsMargins(0, 0, 0, 0);
|
||||
layout->addLayout(label_layout);
|
||||
|
||||
label_layout->addWidget(new QLabel(tr("Connected to"), this));
|
||||
CollapseButton *collapse_btn = new CollapseButton(this);
|
||||
collapse_btn->setChecked(false);
|
||||
label_layout->addWidget(collapse_btn);
|
||||
|
||||
connected_to_lbl_ = new ClickableLabel(this);
|
||||
connected_to_lbl_->setCursor(Qt::PointingHandCursor);
|
||||
connected_to_lbl_->setContextMenuPolicy(Qt::CustomContextMenu);
|
||||
connect(connected_to_lbl_, &ClickableLabel::MouseClicked, this, &NodeParamViewConnectedLabel::ConnectionClicked);
|
||||
connect(connected_to_lbl_, &ClickableLabel::customContextMenuRequested, this, &NodeParamViewConnectedLabel::ShowLabelContextMenu);
|
||||
label_layout->addWidget(connected_to_lbl_);
|
||||
label_layout->addWidget(new QLabel(tr("Connected to"), this));
|
||||
|
||||
label_layout->addStretch();
|
||||
connected_to_lbl_ = new ClickableLabel(this);
|
||||
connected_to_lbl_->setCursor(Qt::PointingHandCursor);
|
||||
connected_to_lbl_->setContextMenuPolicy(Qt::CustomContextMenu);
|
||||
connect(connected_to_lbl_, &ClickableLabel::MouseClicked, this,
|
||||
&NodeParamViewConnectedLabel::ConnectionClicked);
|
||||
connect(connected_to_lbl_, &ClickableLabel::customContextMenuRequested,
|
||||
this, &NodeParamViewConnectedLabel::ShowLabelContextMenu);
|
||||
label_layout->addWidget(connected_to_lbl_);
|
||||
|
||||
// Set up "link" font
|
||||
QFont link_font = connected_to_lbl_->font();
|
||||
link_font.setUnderline(true);
|
||||
connected_to_lbl_->setForegroundRole(QPalette::Link);
|
||||
connected_to_lbl_->setFont(link_font);
|
||||
label_layout->addStretch();
|
||||
|
||||
if (input_.IsConnected()) {
|
||||
InputConnected(input_.GetConnectedOutput(), input_);
|
||||
} else {
|
||||
InputDisconnected(nullptr, input_);
|
||||
}
|
||||
// Set up "link" font
|
||||
QFont link_font = connected_to_lbl_->font();
|
||||
link_font.setUnderline(true);
|
||||
connected_to_lbl_->setForegroundRole(QPalette::Link);
|
||||
connected_to_lbl_->setFont(link_font);
|
||||
|
||||
connect(input_.node(), &Node::InputConnected, this, &NodeParamViewConnectedLabel::InputConnected);
|
||||
connect(input_.node(), &Node::InputDisconnected, this, &NodeParamViewConnectedLabel::InputDisconnected);
|
||||
if (input_.IsConnected()) {
|
||||
InputConnected(input_.GetConnectedOutput(), input_);
|
||||
} else {
|
||||
InputDisconnected(nullptr, input_);
|
||||
}
|
||||
|
||||
// Creating the tree is expensive, hold off until the user specifically requests it
|
||||
value_tree_ = nullptr;
|
||||
connect(collapse_btn, &CollapseButton::toggled, this, &NodeParamViewConnectedLabel::SetValueTreeVisible);
|
||||
connect(input_.node(), &Node::InputConnected, this,
|
||||
&NodeParamViewConnectedLabel::InputConnected);
|
||||
connect(input_.node(), &Node::InputDisconnected, this,
|
||||
&NodeParamViewConnectedLabel::InputDisconnected);
|
||||
|
||||
// Creating the tree is expensive, hold off until the user specifically requests it
|
||||
value_tree_ = nullptr;
|
||||
connect(collapse_btn, &CollapseButton::toggled, this,
|
||||
&NodeParamViewConnectedLabel::SetValueTreeVisible);
|
||||
}
|
||||
|
||||
void NodeParamViewConnectedLabel::SetViewerNode(ViewerOutput *viewer)
|
||||
{
|
||||
if (viewer_) {
|
||||
disconnect(viewer_, &ViewerOutput::PlayheadChanged, this, &NodeParamViewConnectedLabel::UpdateValueTree);
|
||||
}
|
||||
if (viewer_) {
|
||||
disconnect(viewer_, &ViewerOutput::PlayheadChanged, this,
|
||||
&NodeParamViewConnectedLabel::UpdateValueTree);
|
||||
}
|
||||
|
||||
viewer_ = viewer;
|
||||
viewer_ = viewer;
|
||||
|
||||
if (viewer_) {
|
||||
connect(viewer_, &ViewerOutput::PlayheadChanged, this, &NodeParamViewConnectedLabel::UpdateValueTree);
|
||||
UpdateValueTree();
|
||||
}
|
||||
if (viewer_) {
|
||||
connect(viewer_, &ViewerOutput::PlayheadChanged, this,
|
||||
&NodeParamViewConnectedLabel::UpdateValueTree);
|
||||
UpdateValueTree();
|
||||
}
|
||||
}
|
||||
|
||||
void NodeParamViewConnectedLabel::CreateTree()
|
||||
{
|
||||
// Set up table area
|
||||
value_tree_ = new NodeValueTree(this);
|
||||
layout()->addWidget(value_tree_);
|
||||
// Set up table area
|
||||
value_tree_ = new NodeValueTree(this);
|
||||
layout()->addWidget(value_tree_);
|
||||
}
|
||||
|
||||
void NodeParamViewConnectedLabel::InputConnected(Node *output, const NodeInput& input)
|
||||
void NodeParamViewConnectedLabel::InputConnected(Node *output,
|
||||
const NodeInput &input)
|
||||
{
|
||||
if (input_ != input) {
|
||||
return;
|
||||
}
|
||||
if (input_ != input) {
|
||||
return;
|
||||
}
|
||||
|
||||
connected_node_ = output;
|
||||
connected_node_ = output;
|
||||
|
||||
UpdateLabel();
|
||||
UpdateLabel();
|
||||
}
|
||||
|
||||
void NodeParamViewConnectedLabel::InputDisconnected(Node *output, const NodeInput &input)
|
||||
void NodeParamViewConnectedLabel::InputDisconnected(Node *output,
|
||||
const NodeInput &input)
|
||||
{
|
||||
if (input_ != input) {
|
||||
return;
|
||||
}
|
||||
if (input_ != input) {
|
||||
return;
|
||||
}
|
||||
|
||||
Q_UNUSED(output)
|
||||
Q_UNUSED(output)
|
||||
|
||||
connected_node_ = nullptr;
|
||||
connected_node_ = nullptr;
|
||||
|
||||
UpdateLabel();
|
||||
UpdateLabel();
|
||||
}
|
||||
|
||||
void NodeParamViewConnectedLabel::ShowLabelContextMenu()
|
||||
{
|
||||
Menu m(this);
|
||||
Menu m(this);
|
||||
|
||||
QAction* disconnect_action = m.addAction(tr("Disconnect"));
|
||||
connect(disconnect_action, &QAction::triggered, this, [this](){
|
||||
Core::instance()->undo_stack()->push(new NodeEdgeRemoveCommand(connected_node_, input_), Node::GetDisconnectCommandString(connected_node_, input_));
|
||||
});
|
||||
QAction *disconnect_action = m.addAction(tr("Disconnect"));
|
||||
connect(disconnect_action, &QAction::triggered, this, [this]() {
|
||||
Core::instance()->undo_stack()->push(
|
||||
new NodeEdgeRemoveCommand(connected_node_, input_),
|
||||
Node::GetDisconnectCommandString(connected_node_, input_));
|
||||
});
|
||||
|
||||
m.exec(QCursor::pos());
|
||||
m.exec(QCursor::pos());
|
||||
}
|
||||
|
||||
void NodeParamViewConnectedLabel::ConnectionClicked()
|
||||
{
|
||||
if (connected_node_) {
|
||||
emit RequestSelectNode(connected_node_);
|
||||
}
|
||||
if (connected_node_) {
|
||||
emit RequestSelectNode(connected_node_);
|
||||
}
|
||||
}
|
||||
|
||||
void NodeParamViewConnectedLabel::UpdateLabel()
|
||||
{
|
||||
QString s;
|
||||
QString s;
|
||||
|
||||
if (connected_node_) {
|
||||
s = connected_node_->Name();
|
||||
} else {
|
||||
s = tr("Nothing");
|
||||
}
|
||||
if (connected_node_) {
|
||||
s = connected_node_->Name();
|
||||
} else {
|
||||
s = tr("Nothing");
|
||||
}
|
||||
|
||||
connected_to_lbl_->setText(s);
|
||||
connected_to_lbl_->setText(s);
|
||||
}
|
||||
|
||||
void NodeParamViewConnectedLabel::UpdateValueTree()
|
||||
{
|
||||
if (value_tree_ && viewer_ && value_tree_->isVisible()) {
|
||||
value_tree_->SetNode(input_, viewer_->GetPlayhead());
|
||||
}
|
||||
if (value_tree_ && viewer_ && value_tree_->isVisible()) {
|
||||
value_tree_->SetNode(input_, viewer_->GetPlayhead());
|
||||
}
|
||||
}
|
||||
|
||||
void NodeParamViewConnectedLabel::SetValueTreeVisible(bool e)
|
||||
{
|
||||
if (value_tree_) {
|
||||
value_tree_->setVisible(e);
|
||||
}
|
||||
if (value_tree_) {
|
||||
value_tree_->setVisible(e);
|
||||
}
|
||||
|
||||
if (e) {
|
||||
if (!value_tree_) {
|
||||
CreateTree();
|
||||
value_tree_->setVisible(true);
|
||||
}
|
||||
if (e) {
|
||||
if (!value_tree_) {
|
||||
CreateTree();
|
||||
value_tree_->setVisible(true);
|
||||
}
|
||||
|
||||
UpdateValueTree();
|
||||
}
|
||||
UpdateValueTree();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user