From bf3f1d5db8ae0eecf194ac5178a5a12db5d3808b Mon Sep 17 00:00:00 2001 From: Leonardo Zide Date: Sat, 26 Oct 2024 12:31:22 -0700 Subject: [PATCH] Set focus on the part filter when showing the parts toolbar. --- common/lc_mainwindow.cpp | 7 ++++++- common/lc_partselectionwidget.cpp | 2 +- common/lc_partselectionwidget.h | 6 ++++++ qt/lc_qutils.cpp | 2 ++ 4 files changed, 15 insertions(+), 2 deletions(-) diff --git a/common/lc_mainwindow.cpp b/common/lc_mainwindow.cpp index aecd719e..fc06d669 100644 --- a/common/lc_mainwindow.cpp +++ b/common/lc_mainwindow.cpp @@ -1906,9 +1906,12 @@ void lcMainWindow::ResetViews() void lcMainWindow::ToggleDockWidget(QWidget* DockWidget) { if (DockWidget->isHidden()) + { DockWidget->show(); + DockWidget->raise(); + } else - DockWidget->hide(); + DockWidget->close(); } void lcMainWindow::TogglePrintPreview() @@ -2812,6 +2815,8 @@ void lcMainWindow::HandleCommand(lcCommandId CommandId) case LC_VIEW_TOOLBAR_PARTS: ToggleDockWidget(mPartsToolBar); + if (mPartsToolBar->isVisible()) + mPartSelectionWidget->FocusPartFilterWidget(); break; case LC_VIEW_TOOLBAR_COLORS: diff --git a/common/lc_partselectionwidget.cpp b/common/lc_partselectionwidget.cpp index ae8599c4..06dc333f 100644 --- a/common/lc_partselectionwidget.cpp +++ b/common/lc_partselectionwidget.cpp @@ -676,7 +676,7 @@ lcPartSelectionWidget::lcPartSelectionWidget(QWidget* Parent) PartsLayout->addLayout(SearchLayout); mFilterWidget = new QLineEdit(PartsGroupWidget); - mFilterWidget->setPlaceholderText(tr("Search Parts")); + mFilterWidget->setPlaceholderText(tr("Filter Parts")); SearchLayout->addWidget(mFilterWidget); QToolButton* OptionsButton = new QToolButton(); diff --git a/common/lc_partselectionwidget.h b/common/lc_partselectionwidget.h index d66945fc..c5e901bc 100644 --- a/common/lc_partselectionwidget.h +++ b/common/lc_partselectionwidget.h @@ -239,6 +239,12 @@ public: return mPartsWidget->GetCurrentPart(); } + void FocusPartFilterWidget() const + { + mFilterWidget->setFocus(); + mFilterWidget->selectAll(); + } + signals: void PartPicked(PieceInfo* Info); void CurrentPartChanged(PieceInfo* Info); diff --git a/qt/lc_qutils.cpp b/qt/lc_qutils.cpp index d315fa76..faf25154 100644 --- a/qt/lc_qutils.cpp +++ b/qt/lc_qutils.cpp @@ -196,6 +196,8 @@ void lcPieceIdPickerPopup::showEvent(QShowEvent* ShowEvent) mPartSelectionWidget->SetOrientation(Qt::Horizontal); mPartSelectionWidget->SetCurrentPart(mInitialPart); + + mPartSelectionWidget->FocusPartFilterWidget(); } void lcPieceIdPickerPopup::Accept()