Added SetCurrentStep and MoveSelection to Timeline context menu.

This commit is contained in:
Leonardo Zide 2017-02-04 18:40:46 -08:00
parent e3bb498741
commit 0dabe0d435
6 changed files with 135 additions and 8 deletions

View file

@ -868,15 +868,15 @@ lcCommand gCommands[LC_NUM_COMMANDS] =
// LC_VIEW_TIME_INSERT
{
QT_TRANSLATE_NOOP("Action", "View.Time.Insert"),
QT_TRANSLATE_NOOP("Menu", "Insert"),
QT_TRANSLATE_NOOP("Menu", "Insert Step"),
QT_TRANSLATE_NOOP("Status", "Insert new step"),
QT_TRANSLATE_NOOP("Shortcut", "")
},
// LC_VIEW_TIME_DELETE
{
QT_TRANSLATE_NOOP("Action", "View.Time.Delete"),
QT_TRANSLATE_NOOP("Menu", "Delete"),
QT_TRANSLATE_NOOP("Status", "Delete current step"),
QT_TRANSLATE_NOOP("Menu", "Remove Step"),
QT_TRANSLATE_NOOP("Status", "Remove current step"),
QT_TRANSLATE_NOOP("Shortcut", "")
},
// LC_VIEW_TIME_ADD_KEYS
@ -1389,6 +1389,34 @@ lcCommand gCommands[LC_NUM_COMMANDS] =
QT_TRANSLATE_NOOP("Menu", "&About..."),
QT_TRANSLATE_NOOP("Status", "Display program version number and system information"),
QT_TRANSLATE_NOOP("Shortcut", "")
},
// LC_TIMELINE_INSERT
{
"",
QT_TRANSLATE_NOOP("Menu", "Insert Step"),
QT_TRANSLATE_NOOP("Status", "Insert new step"),
""
},
// LC_TIMELINE_DELETE
{
"",
QT_TRANSLATE_NOOP("Menu", "Remove Step"),
QT_TRANSLATE_NOOP("Status", "Remove current step"),
""
},
// LC_TIMELINE_MOVE_SELECTION
{
"",
QT_TRANSLATE_NOOP("Menu", "Move Selection Here"),
QT_TRANSLATE_NOOP("Status", "Move the selected parts into this step"),
""
},
// LC_TIMELINE_SET_CURRENT
{
"",
QT_TRANSLATE_NOOP("Menu", "Set Current Step"),
QT_TRANSLATE_NOOP("Status", "View the model at this point in the timeline"),
""
}
};

View file

@ -211,6 +211,10 @@ enum lcCommandId
LC_HELP_EMAIL,
LC_HELP_UPDATES,
LC_HELP_ABOUT,
LC_TIMELINE_INSERT,
LC_TIMELINE_DELETE,
LC_TIMELINE_MOVE_SELECTION,
LC_TIMELINE_SET_CURRENT,
LC_NUM_COMMANDS
};

View file

@ -1489,6 +1489,7 @@ void lcMainWindow::UpdateSelectedObjects(bool SelectionChanged)
mActions[LC_PIECE_GROUP_EDIT]->setEnabled((Flags & LC_SEL_NO_PIECES) == 0);
mActions[LC_PIECE_SHOW_EARLIER]->setEnabled(Flags & LC_SEL_PIECE); // FIXME: disable if current step is 1
mActions[LC_PIECE_SHOW_LATER]->setEnabled(Flags & LC_SEL_PIECE);
mActions[LC_TIMELINE_MOVE_SELECTION]->setEnabled(Flags & LC_SEL_PIECE);
}
mPropertiesWidget->Update(Selection, Focus);
@ -2543,6 +2544,22 @@ void lcMainWindow::HandleCommand(lcCommandId CommandId)
ActiveView->CancelTrackingOrClearSelection();
break;
case LC_TIMELINE_INSERT:
mTimelineWidget->InsertStep();
break;
case LC_TIMELINE_DELETE:
mTimelineWidget->RemoveStep();
break;
case LC_TIMELINE_MOVE_SELECTION:
mTimelineWidget->MoveSelection();
break;
case LC_TIMELINE_SET_CURRENT:
mTimelineWidget->SetCurrentStep();
break;
case LC_NUM_COMMANDS:
break;
}

View file

@ -45,10 +45,11 @@ void lcTimelineWidget::CustomMenuRequested(QPoint Pos)
}
}
QAction* InsertStepAction = Menu->addAction(gMainWindow->mActions[LC_VIEW_TIME_INSERT]->text(), this, SLOT(InsertStep()));
InsertStepAction->setStatusTip(gMainWindow->mActions[LC_VIEW_TIME_INSERT]->statusTip());
QAction* RemoveStepAction = Menu->addAction(gMainWindow->mActions[LC_VIEW_TIME_DELETE]->text(), this, SLOT(RemoveStep()));
RemoveStepAction->setStatusTip(gMainWindow->mActions[LC_VIEW_TIME_DELETE]->statusTip());
Menu->addAction(gMainWindow->mActions[LC_TIMELINE_SET_CURRENT]);
Menu->addAction(gMainWindow->mActions[LC_TIMELINE_INSERT]);
Menu->addAction(gMainWindow->mActions[LC_TIMELINE_DELETE]);
Menu->addAction(gMainWindow->mActions[LC_TIMELINE_MOVE_SELECTION]);
Menu->addSeparator();
Menu->addAction(gMainWindow->mActions[LC_PIECE_HIDE_SELECTED]);
@ -292,6 +293,55 @@ void lcTimelineWidget::RemoveStep()
lcGetActiveModel()->RemoveStep(Step + 1);
}
void lcTimelineWidget::MoveSelection()
{
QTreeWidgetItem* CurrentItem = currentItem();
if (!CurrentItem)
return;
if (CurrentItem->parent())
CurrentItem = CurrentItem->parent();
int Step = indexOfTopLevelItem(CurrentItem);
if (Step == -1)
return;
QList<QTreeWidgetItem*> SelectedItems = selectedItems();
foreach(QTreeWidgetItem* PieceItem, SelectedItems)
{
QTreeWidgetItem* Parent = PieceItem->parent();
if (!Parent)
continue;
int ChildIndex = Parent->indexOfChild(PieceItem);
CurrentItem->addChild(Parent->takeChild(ChildIndex));
}
UpdateModel();
}
void lcTimelineWidget::SetCurrentStep()
{
QTreeWidgetItem* CurrentItem = currentItem();
if (!CurrentItem)
return;
if (CurrentItem->parent())
CurrentItem = CurrentItem->parent();
int Step = indexOfTopLevelItem(CurrentItem);
if (Step == -1)
return;
lcGetActiveModel()->SetCurrentStep(Step + 1);
}
void lcTimelineWidget::ItemSelectionChanged()
{
lcArray<lcObject*> Selection;
@ -322,7 +372,27 @@ void lcTimelineWidget::ItemSelectionChanged()
void lcTimelineWidget::dropEvent(QDropEvent* Event)
{
QTreeWidget::dropEvent(Event);
UpdateModel();
}
void lcTimelineWidget::mousePressEvent(QMouseEvent* Event)
{
if (Event->button() == Qt::RightButton)
{
QItemSelection Selection = selectionModel()->selection();
bool Blocked = blockSignals(true);
QTreeWidget::mousePressEvent(Event);
blockSignals(Blocked);
selectionModel()->select(Selection, QItemSelectionModel::ClearAndSelect);
}
else
QTreeWidget::mousePressEvent(Event);
}
void lcTimelineWidget::UpdateModel()
{
QList<QPair<lcPiece*, lcStep>> PieceSteps;
for (int TopLevelItemIdx = 0; TopLevelItemIdx < topLevelItemCount(); TopLevelItemIdx++)

View file

@ -12,14 +12,19 @@ public:
void Update(bool Clear, bool UpdateItems);
void UpdateSelection();
public slots:
void InsertStep();
void RemoveStep();
void MoveSelection();
void SetCurrentStep();
public slots:
void ItemSelectionChanged();
void CustomMenuRequested(QPoint Pos);
protected:
virtual void dropEvent(QDropEvent* Event);
virtual void mousePressEvent(QMouseEvent* Event);
void UpdateModel();
QMap<int, QIcon> mIcons;
QMap<lcPiece*, QTreeWidgetItem*> mItems;

View file

@ -431,6 +431,9 @@ void lcQPreferencesDialog::updateCommandList()
for (int actionIdx = 0; actionIdx < LC_NUM_COMMANDS; actionIdx++)
{
if (!gCommands[actionIdx].ID[0])
continue;
const QString identifier = tr(gCommands[actionIdx].ID);
int pos = identifier.indexOf(QLatin1Char('.'));