Added option to open a model from the context menu.

This commit is contained in:
leo 2015-03-17 04:18:28 +00:00
parent 96e0b46931
commit b6ef506997
5 changed files with 83 additions and 38 deletions

View file

@ -1124,6 +1124,13 @@ lcCommand gCommands[LC_NUM_COMMANDS] =
QT_TRANSLATE_NOOP("Status", "Display the properties of the current model"),
QT_TRANSLATE_NOOP("Shortcut", "")
},
// LC_MODEL_EDIT_FOCUS
{
"Model.SwitchToFocus",
QT_TRANSLATE_NOOP("Menu", "Switch to Model"),
QT_TRANSLATE_NOOP("Status", "Switch to the model corresponding to the piece with focus"),
QT_TRANSLATE_NOOP("Shortcut", "")
},
// LC_MODEL_LIST
{
"Model.List",

View file

@ -171,6 +171,7 @@ enum lcCommandId
LC_PIECE_SHOW_LATER,
LC_MODEL_NEW,
LC_MODEL_PROPERTIES,
LC_MODEL_EDIT_FOCUS,
LC_MODEL_LIST,
LC_MODEL_FIRST,
LC_MODEL_01 = LC_MODEL_FIRST,

View file

@ -1777,6 +1777,22 @@ bool lcMainWindow::SaveProjectIfModified()
return true;
}
void lcMainWindow::SetModelFromFocus()
{
lcObject* FocusObject = lcGetActiveModel()->GetFocusObject();
if (!FocusObject || !FocusObject->IsPiece())
return;
lcModel* Model = ((lcPiece*)FocusObject)->mPieceInfo->GetModel();
if (Model)
{
Project* Project = lcGetActiveProject();
Project->SetActiveModel(Project->GetModels().FindIndex(Model));
}
}
void lcMainWindow::HandleCommand(lcCommandId CommandId)
{
switch (CommandId)
@ -2145,6 +2161,10 @@ void lcMainWindow::HandleCommand(lcCommandId CommandId)
lcGetActiveModel()->ShowPropertiesDialog();
break;
case LC_MODEL_EDIT_FOCUS:
SetModelFromFocus();
break;
case LC_MODEL_LIST:
lcGetActiveProject()->ShowModelListDialog();
break;

View file

@ -150,6 +150,7 @@ public:
void MergeProject();
bool SaveProject(const QString& FileName);
bool SaveProjectIfModified();
void SetModelFromFocus();
void HandleCommand(lcCommandId CommandId);
void AddRecentFile(const QString& FileName);

View file

@ -32,9 +32,25 @@ void lcTimelineWidget::CustomMenuRequested(QPoint Pos)
{
QMenu* Menu = new QMenu(this);
Menu->addAction(tr("Insert Step"), this, SLOT(InsertStep()));
Menu->addAction(tr("Remove Step"), this, SLOT(RemoveStep()));
lcObject* FocusObject = lcGetActiveModel()->GetFocusObject();
if (FocusObject && FocusObject->IsPiece())
{
lcPiece* Piece = (lcPiece*)FocusObject;
if (Piece->mPieceInfo->IsModel())
{
Menu->addAction(gMainWindow->mActions[LC_MODEL_EDIT_FOCUS]);
Menu->addSeparator();
}
}
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->addSeparator();
Menu->addAction(gMainWindow->mActions[LC_PIECE_HIDE_SELECTED]);
Menu->addAction(gMainWindow->mActions[LC_PIECE_HIDE_UNSELECTED]);
Menu->addAction(gMainWindow->mActions[LC_PIECE_UNHIDE_SELECTED]);