mirror of
https://github.com/leozide/leocad.git
synced 2026-09-11 09:04:06 +00:00
Add option to open submodels from the parts picker. Fixes #1031.
This commit is contained in:
@@ -60,6 +60,8 @@ std::optional<PieceInfo*> lcShowPartSelectionPopup(PieceInfo* InitialPart, const
|
||||
lcPartSelectionPopup* Popup = new lcPartSelectionPopup(InitialPart, Menu.get());
|
||||
lcPartSelectionWidget* PartSelectionWidget = Popup->GetPartSelectionWidget();
|
||||
|
||||
PartSelectionWidget->SetIsPopup(true);
|
||||
|
||||
if (CustomParts.empty())
|
||||
{
|
||||
PartSelectionWidget->SetCategory(lcPartCategoryType::AllParts, 0);
|
||||
|
||||
@@ -561,7 +561,7 @@ void lcPartSelectionListView::DoubleClicked(const QModelIndex& Index)
|
||||
|
||||
void lcPartSelectionListView::CustomContextMenuRequested(QPoint Pos)
|
||||
{
|
||||
if (!mPartSelectionWidget)
|
||||
if (!mPartSelectionWidget || mPartSelectionWidget->GetIsPopup())
|
||||
return;
|
||||
|
||||
QMenu* Menu = new QMenu(this);
|
||||
@@ -587,6 +587,12 @@ void lcPartSelectionListView::CustomContextMenuRequested(QPoint Pos)
|
||||
QAction* RemoveAction = Menu->addAction(tr("Remove from Palette"), mPartSelectionWidget, &lcPartSelectionWidget::RemoveFromPalette);
|
||||
RemoveAction->setEnabled(mCategoryType == lcPartCategoryType::Palette);
|
||||
|
||||
if (mContextInfo && mContextInfo->IsModel())
|
||||
{
|
||||
Menu->addSeparator();
|
||||
Menu->addAction(tr("Open Submodel"), mPartSelectionWidget, &lcPartSelectionWidget::OpenSubmodel);
|
||||
}
|
||||
|
||||
Menu->exec(viewport()->mapToGlobal(Pos));
|
||||
delete Menu;
|
||||
}
|
||||
@@ -1150,7 +1156,7 @@ void lcPartSelectionWidget::OptionsMenuAboutToShow()
|
||||
QMenu* Menu = (QMenu*)sender();
|
||||
Menu->clear();
|
||||
|
||||
Menu->addAction(tr("Edit Palettes..."), this, &lcPartSelectionWidget::EditPartPalettes);
|
||||
Menu->addAction(tr("Edit Palettes..."), this, &lcPartSelectionWidget::EditPartPalettes)->setEnabled(!mIsPopup);
|
||||
|
||||
Menu->addSeparator();
|
||||
|
||||
@@ -1378,6 +1384,18 @@ void lcPartSelectionWidget::RemoveFromPalette()
|
||||
}
|
||||
}
|
||||
|
||||
void lcPartSelectionWidget::OpenSubmodel()
|
||||
{
|
||||
PieceInfo* Info = mPartsWidget->GetContextInfo();
|
||||
|
||||
if (!Info || !Info->IsModel())
|
||||
return;
|
||||
|
||||
lcModel* Model = Info->GetModel();
|
||||
|
||||
lcGetActiveProject()->SetActiveModel(Model, true);
|
||||
}
|
||||
|
||||
void lcPartSelectionWidget::UpdateInUseCategory()
|
||||
{
|
||||
mPartsWidget->UpdateInUseCategory();
|
||||
|
||||
@@ -278,6 +278,16 @@ public:
|
||||
void SetCategory(lcPartCategoryType Type, int Index);
|
||||
void SetCustomParts(const std::vector<std::pair<PieceInfo*, std::string>>& Parts, int ColorIndex);
|
||||
|
||||
bool GetIsPopup() const
|
||||
{
|
||||
return mIsPopup;
|
||||
}
|
||||
|
||||
void SetIsPopup(bool IsPopup)
|
||||
{
|
||||
mIsPopup = IsPopup;
|
||||
}
|
||||
|
||||
int GetColorIndex() const
|
||||
{
|
||||
return mPartsWidget->GetListModel()->GetColorIndex();
|
||||
@@ -316,6 +326,7 @@ signals:
|
||||
public slots:
|
||||
void AddToPalette();
|
||||
void RemoveFromPalette();
|
||||
void OpenSubmodel();
|
||||
void DockLocationChanged(Qt::DockWidgetArea Area);
|
||||
|
||||
protected slots:
|
||||
@@ -347,4 +358,5 @@ protected:
|
||||
QSplitter* mSplitter = nullptr;
|
||||
QTreeWidgetItem* mAllPartsCategoryItem = nullptr;
|
||||
std::vector<lcPartPalette> mPartPalettes;
|
||||
bool mIsPopup = false;
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user