timeline/block: reimplemented enabling/disabling blocks
This commit is contained in:
@@ -195,7 +195,7 @@ void MenuShared::DuplicateTriggered()
|
||||
|
||||
void MenuShared::EnableDisableTriggered()
|
||||
{
|
||||
qDebug() << "FIXME: Stub";
|
||||
PanelManager::instance()->CurrentlyFocused()->ToggleSelectedEnabled();
|
||||
}
|
||||
|
||||
void MenuShared::NestTriggered()
|
||||
|
||||
@@ -154,6 +154,8 @@ public:
|
||||
|
||||
virtual void RippleDeleteInToOut(){}
|
||||
|
||||
virtual void ToggleSelectedEnabled(){}
|
||||
|
||||
protected:
|
||||
/**
|
||||
* @brief paintEvent
|
||||
|
||||
@@ -730,6 +730,25 @@ void TimelineWidget::DeleteInToOut(bool ripple)
|
||||
Core::instance()->undo_stack()->push(command);
|
||||
}
|
||||
|
||||
void TimelineWidget::ToggleSelectedEnabled()
|
||||
{
|
||||
QList<TimelineViewBlockItem*> items = GetSelectedBlocks();
|
||||
|
||||
if (items.isEmpty()) {
|
||||
return;
|
||||
}
|
||||
|
||||
QUndoCommand* command = new QUndoCommand();
|
||||
|
||||
foreach (TimelineViewBlockItem* i, items) {
|
||||
new BlockEnableDisableCommand(i->block(),
|
||||
!i->block()->is_enabled(),
|
||||
command);
|
||||
}
|
||||
|
||||
Core::instance()->undo_stack()->pushIfHasChildren(command);
|
||||
}
|
||||
|
||||
QList<TimelineViewBlockItem *> TimelineWidget::GetSelectedBlocks()
|
||||
{
|
||||
QList<TimelineViewBlockItem *> list;
|
||||
@@ -988,6 +1007,8 @@ void TimelineWidget::AddBlock(Block *block, TrackReference track)
|
||||
|
||||
connect(block, &Block::Refreshed, this, &TimelineWidget::BlockChanged);
|
||||
connect(block, &Block::LinksChanged, this, &TimelineWidget::PreviewUpdated);
|
||||
connect(block, &Block::NameChanged, this, &TimelineWidget::PreviewUpdated);
|
||||
connect(block, &Block::EnabledChanged, this, &TimelineWidget::PreviewUpdated);
|
||||
|
||||
if (block->type() == Block::kClip) {
|
||||
connect(static_cast<ClipBlock*>(block), &ClipBlock::PreviewUpdated, this, &TimelineWidget::PreviewUpdated);
|
||||
|
||||
@@ -88,6 +88,8 @@ public:
|
||||
|
||||
void DeleteInToOut(bool ripple);
|
||||
|
||||
void ToggleSelectedEnabled();
|
||||
|
||||
QList<TimelineViewBlockItem*> GetSelectedBlocks();
|
||||
|
||||
signals:
|
||||
|
||||
@@ -799,4 +799,22 @@ BlockLinkManyCommand::BlockLinkManyCommand(const QList<Block *> blocks, bool lin
|
||||
}
|
||||
}
|
||||
|
||||
BlockEnableDisableCommand::BlockEnableDisableCommand(Block *block, bool enabled, QUndoCommand *parent) :
|
||||
UndoCommand(parent),
|
||||
block_(block),
|
||||
old_enabled_(block_->is_enabled()),
|
||||
new_enabled_(enabled)
|
||||
{
|
||||
}
|
||||
|
||||
void BlockEnableDisableCommand::redo_internal()
|
||||
{
|
||||
block_->set_enabled(new_enabled_);
|
||||
}
|
||||
|
||||
void BlockEnableDisableCommand::undo_internal()
|
||||
{
|
||||
block_->set_enabled(old_enabled_);
|
||||
}
|
||||
|
||||
OLIVE_NAMESPACE_EXIT
|
||||
|
||||
@@ -375,6 +375,23 @@ private:
|
||||
|
||||
};
|
||||
|
||||
class BlockEnableDisableCommand : public UndoCommand {
|
||||
public:
|
||||
BlockEnableDisableCommand(Block* block, bool enabled, QUndoCommand* parent = nullptr);
|
||||
|
||||
protected:
|
||||
virtual void redo_internal() override;
|
||||
virtual void undo_internal() override;
|
||||
|
||||
private:
|
||||
Block* block_;
|
||||
|
||||
bool old_enabled_;
|
||||
|
||||
bool new_enabled_;
|
||||
|
||||
};
|
||||
|
||||
OLIVE_NAMESPACE_EXIT
|
||||
|
||||
#endif // TIMELINEUNDOABLE_H
|
||||
|
||||
@@ -80,8 +80,15 @@ void TimelineViewBlockItem::paint(QPainter *painter, const QStyleOptionGraphicsI
|
||||
QLinearGradient grad;
|
||||
grad.setStart(0, rect().top());
|
||||
grad.setFinalStop(0, rect().bottom());
|
||||
grad.setColorAt(0.0, QColor(160, 160, 240));
|
||||
grad.setColorAt(1.0, QColor(128, 128, 192));
|
||||
|
||||
if (block_->is_enabled()) {
|
||||
grad.setColorAt(0.0, QColor(160, 160, 240));
|
||||
grad.setColorAt(1.0, QColor(128, 128, 192));
|
||||
} else {
|
||||
grad.setColorAt(0.0, QColor(160, 160, 160));
|
||||
grad.setColorAt(1.0, QColor(128, 128, 128));
|
||||
}
|
||||
|
||||
painter->fillRect(rect(), grad);
|
||||
|
||||
if (option->state & QStyle::State_Selected) {
|
||||
@@ -121,7 +128,12 @@ void TimelineViewBlockItem::paint(QPainter *painter, const QStyleOptionGraphicsI
|
||||
painter->drawLine(rect().topLeft(), QPointF(rect().right(), rect().top()));
|
||||
painter->drawLine(rect().topLeft(), QPointF(rect().left(), rect().bottom() - 1));
|
||||
|
||||
painter->setPen(Qt::white);
|
||||
// Draw text
|
||||
if (block_->is_enabled()) {
|
||||
painter->setPen(Qt::white);
|
||||
} else {
|
||||
painter->setPen(Qt::lightGray);
|
||||
}
|
||||
painter->drawText(rect(), static_cast<int>(Qt::AlignLeft | Qt::AlignTop), block_->block_name());
|
||||
|
||||
// Linked clips are underlined
|
||||
|
||||
Reference in New Issue
Block a user