Skip to content

Commit

Permalink
Set focus on the part filter when showing the parts toolbar.
Browse files Browse the repository at this point in the history
  • Loading branch information
leozide committed Oct 26, 2024
1 parent 11e9958 commit bf3f1d5
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 2 deletions.
7 changes: 6 additions & 1 deletion common/lc_mainwindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down Expand Up @@ -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:
Expand Down
2 changes: 1 addition & 1 deletion common/lc_partselectionwidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
6 changes: 6 additions & 0 deletions common/lc_partselectionwidget.h
Original file line number Diff line number Diff line change
Expand Up @@ -239,6 +239,12 @@ class lcPartSelectionWidget : public QWidget
return mPartsWidget->GetCurrentPart();
}

void FocusPartFilterWidget() const
{
mFilterWidget->setFocus();
mFilterWidget->selectAll();
}

signals:
void PartPicked(PieceInfo* Info);
void CurrentPartChanged(PieceInfo* Info);
Expand Down
2 changes: 2 additions & 0 deletions qt/lc_qutils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -196,6 +196,8 @@ void lcPieceIdPickerPopup::showEvent(QShowEvent* ShowEvent)

mPartSelectionWidget->SetOrientation(Qt::Horizontal);
mPartSelectionWidget->SetCurrentPart(mInitialPart);

mPartSelectionWidget->FocusPartFilterWidget();
}

void lcPieceIdPickerPopup::Accept()
Expand Down

0 comments on commit bf3f1d5

Please sign in to comment.