mirror of
https://github.com/leozide/leocad
synced 2025-01-29 20:34:50 +01:00
Added option to open a model from the context menu.
This commit is contained in:
parent
96e0b46931
commit
b6ef506997
5 changed files with 83 additions and 38 deletions
|
@ -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",
|
||||
|
|
|
@ -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,
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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]);
|
||||
|
@ -194,42 +210,42 @@ void lcTimelineWidget::UpdateSelection()
|
|||
blockSignals(Blocked);
|
||||
}
|
||||
|
||||
void lcTimelineWidget::InsertStep()
|
||||
{
|
||||
QTreeWidgetItem* CurrentItem = currentItem();
|
||||
|
||||
if (!CurrentItem)
|
||||
return;
|
||||
|
||||
if (CurrentItem->parent())
|
||||
CurrentItem = CurrentItem->parent();
|
||||
|
||||
int Step = indexOfTopLevelItem(CurrentItem);
|
||||
|
||||
if (Step == -1)
|
||||
return;
|
||||
|
||||
lcGetActiveModel()->InsertStep(Step + 1);
|
||||
}
|
||||
|
||||
void lcTimelineWidget::RemoveStep()
|
||||
{
|
||||
QTreeWidgetItem* CurrentItem = currentItem();
|
||||
|
||||
if (!CurrentItem)
|
||||
return;
|
||||
|
||||
if (CurrentItem->parent())
|
||||
CurrentItem = CurrentItem->parent();
|
||||
|
||||
int Step = indexOfTopLevelItem(CurrentItem);
|
||||
|
||||
if (Step == -1)
|
||||
return;
|
||||
|
||||
lcGetActiveModel()->RemoveStep(Step + 1);
|
||||
}
|
||||
|
||||
void lcTimelineWidget::InsertStep()
|
||||
{
|
||||
QTreeWidgetItem* CurrentItem = currentItem();
|
||||
|
||||
if (!CurrentItem)
|
||||
return;
|
||||
|
||||
if (CurrentItem->parent())
|
||||
CurrentItem = CurrentItem->parent();
|
||||
|
||||
int Step = indexOfTopLevelItem(CurrentItem);
|
||||
|
||||
if (Step == -1)
|
||||
return;
|
||||
|
||||
lcGetActiveModel()->InsertStep(Step + 1);
|
||||
}
|
||||
|
||||
void lcTimelineWidget::RemoveStep()
|
||||
{
|
||||
QTreeWidgetItem* CurrentItem = currentItem();
|
||||
|
||||
if (!CurrentItem)
|
||||
return;
|
||||
|
||||
if (CurrentItem->parent())
|
||||
CurrentItem = CurrentItem->parent();
|
||||
|
||||
int Step = indexOfTopLevelItem(CurrentItem);
|
||||
|
||||
if (Step == -1)
|
||||
return;
|
||||
|
||||
lcGetActiveModel()->RemoveStep(Step + 1);
|
||||
}
|
||||
|
||||
void lcTimelineWidget::ItemSelectionChanged()
|
||||
{
|
||||
lcArray<lcObject*> Selection;
|
||||
|
|
Loading…
Add table
Reference in a new issue