Fixed enter key not working on the part picker.

This commit is contained in:
Leonardo Zide
2025-01-20 16:42:08 -08:00
parent f2a2e446bb
commit 79dbf992bf
7 changed files with 139 additions and 30 deletions
+26 -5
View File
@@ -547,11 +547,34 @@ lcPartSelectionListView::lcPartSelectionListView(QWidget* Parent, lcPartSelectio
lcPartSelectionItemDelegate* ItemDelegate = new lcPartSelectionItemDelegate(this, mListModel);
setItemDelegate(ItemDelegate);
connect(this, SIGNAL(customContextMenuRequested(QPoint)), SLOT(CustomContextMenuRequested(QPoint)));
connect(this, &QListView::doubleClicked, this, &lcPartSelectionListView::DoubleClicked);
connect(this, &QListView::customContextMenuRequested, this, &lcPartSelectionListView::CustomContextMenuRequested);
SetIconSize(lcGetProfileInt(LC_PROFILE_PARTS_LIST_ICONS));
}
void lcPartSelectionListView::keyPressEvent(QKeyEvent* KeyEvent)
{
if (KeyEvent->key() == Qt::Key_Enter)
{
PieceInfo* Info = GetCurrentPart();
emit PartPicked(Info);
return;
}
return QListView::keyPressEvent(KeyEvent);
}
void lcPartSelectionListView::DoubleClicked(const QModelIndex& Index)
{
PieceInfo* Info = GetListModel()->GetPieceInfo(Index.row());
if (Info)
emit PartPicked(Info);
}
void lcPartSelectionListView::CustomContextMenuRequested(QPoint Pos)
{
if (!mPartSelectionWidget)
@@ -878,7 +901,7 @@ lcPartSelectionWidget::lcPartSelectionWidget(QWidget* Parent)
Layout->addWidget(mSplitter);
setLayout(Layout);
connect(mPartsWidget, &QListView::doubleClicked, this, &lcPartSelectionWidget::PartViewDoubleClicked);
connect(mPartsWidget, &lcPartSelectionListView::PartPicked, this, &lcPartSelectionWidget::PartViewPartPicked);
connect(mPartsWidget->selectionModel(), &QItemSelectionModel::currentChanged, this, &lcPartSelectionWidget::PartViewSelectionChanged);
connect(mFilterWidget, &QLineEdit::textChanged, this, &lcPartSelectionWidget::FilterChanged);
connect(mCategoriesWidget, &QTreeWidget::currentItemChanged, this, &lcPartSelectionWidget::CategoryChanged);
@@ -1079,10 +1102,8 @@ void lcPartSelectionWidget::PartViewSelectionChanged(const QModelIndex& Current,
emit CurrentPartChanged(mPartsWidget->GetCurrentPart());
}
void lcPartSelectionWidget::PartViewDoubleClicked(const QModelIndex& Index)
void lcPartSelectionWidget::PartViewPartPicked(PieceInfo* Info)
{
PieceInfo* Info = mPartsWidget->GetListModel()->GetPieceInfo(Index.row());
if (Info)
emit PartPicked(Info);
}