diff --git a/common/lc_commands.cpp b/common/lc_commands.cpp index 88d4fc75..d67b0a5c 100644 --- a/common/lc_commands.cpp +++ b/common/lc_commands.cpp @@ -227,6 +227,13 @@ const lcCommand gCommands[] = QT_TRANSLATE_NOOP("Status", "Find previous piece"), "Shift+F3" }, + // LC_EDIT_FIND_ALL + { + QT_TRANSLATE_NOOP("Action", "Edit.FindAll"), + QT_TRANSLATE_NOOP("Menu", "Find All"), + QT_TRANSLATE_NOOP("Status", "Find all pieces that match the search criteria"), + "" + }, // LC_EDIT_REPLACE { QT_TRANSLATE_NOOP("Action", "Edit.Replace"), @@ -241,6 +248,13 @@ const lcCommand gCommands[] = QT_TRANSLATE_NOOP("Status", "Replace next piece"), "" }, + // LC_EDIT_REPLACE_ALL + { + QT_TRANSLATE_NOOP("Action", "Edit.ReplaceAll"), + QT_TRANSLATE_NOOP("Menu", "Replace All"), + QT_TRANSLATE_NOOP("Status", "Replace pieces that match the search criteria"), + "" + }, // LC_EDIT_SELECT_ALL { QT_TRANSLATE_NOOP("Action", "Edit.SelectAll"), diff --git a/common/lc_commands.h b/common/lc_commands.h index 3601f31c..ed08b238 100644 --- a/common/lc_commands.h +++ b/common/lc_commands.h @@ -36,8 +36,10 @@ enum lcCommandId LC_EDIT_FIND, LC_EDIT_FIND_NEXT, LC_EDIT_FIND_PREVIOUS, + LC_EDIT_FIND_ALL, LC_EDIT_REPLACE, LC_EDIT_REPLACE_NEXT, + LC_EDIT_REPLACE_ALL, LC_EDIT_SELECT_ALL, LC_EDIT_SELECT_NONE, LC_EDIT_SELECT_INVERT, diff --git a/common/lc_findreplacewidget.cpp b/common/lc_findreplacewidget.cpp index caccbc9d..cf60bc3c 100644 --- a/common/lc_findreplacewidget.cpp +++ b/common/lc_findreplacewidget.cpp @@ -11,6 +11,9 @@ lcFindReplaceWidget::lcFindReplaceWidget(QWidget* Parent, lcModel* Model, bool R : QWidget(Parent) { setAutoFillBackground(true); + QPalette Palette = palette(); + Palette.setColor(QPalette::Window, QApplication::palette().color(QPalette::Button)); + setPalette(Palette); QGridLayout* Layout = new QGridLayout(this); Layout->setContentsMargins(5, 5, 5, 5); @@ -28,9 +31,15 @@ lcFindReplaceWidget::lcFindReplaceWidget(QWidget* Parent, lcModel* Model, bool R Layout->addWidget(FindPartComboBox, 0, 4); QToolButton* FindNextButton = new QToolButton(this); + FindNextButton->setAutoRaise(true); FindNextButton->setDefaultAction(gMainWindow->mActions[LC_EDIT_FIND_NEXT]); Layout->addWidget(FindNextButton, 0, 5); + QToolButton* FindAllButton = new QToolButton(this); + FindAllButton ->setAutoRaise(true); + FindAllButton ->setDefaultAction(gMainWindow->mActions[LC_EDIT_FIND_ALL]); + Layout->addWidget(FindAllButton, 0, 6); + connect(FindColorCheckBox, &QCheckBox::toggled, [](bool Checked) { gMainWindow->mSearchOptions.MatchColor = Checked; @@ -71,9 +80,15 @@ lcFindReplaceWidget::lcFindReplaceWidget(QWidget* Parent, lcModel* Model, bool R Layout->addWidget(ReplacePartComboBox, 1, 4); QToolButton* ReplaceNextButton = new QToolButton(this); + ReplaceNextButton->setAutoRaise(true); ReplaceNextButton->setDefaultAction(gMainWindow->mActions[LC_EDIT_REPLACE_NEXT]); Layout->addWidget(ReplaceNextButton, 1, 5); + QToolButton* ReplaceAllButton = new QToolButton(this); + ReplaceAllButton->setAutoRaise(true); + ReplaceAllButton->setDefaultAction(gMainWindow->mActions[LC_EDIT_REPLACE_ALL]); + Layout->addWidget(ReplaceAllButton, 1, 6); + connect(ReplaceColorCheckBox, &QCheckBox::toggled, [](bool Checked) { gMainWindow->mSearchOptions.ReplaceColor = Checked; diff --git a/common/lc_mainwindow.cpp b/common/lc_mainwindow.cpp index 03879653..df4594da 100644 --- a/common/lc_mainwindow.cpp +++ b/common/lc_mainwindow.cpp @@ -287,6 +287,7 @@ void lcMainWindow::CreateActions() mActions[LC_EDIT_FIND]->setIcon(QIcon(":/resources/edit_find.png")); mActions[LC_EDIT_FIND_NEXT]->setIcon(QIcon(":/resources/edit_find_next.png")); mActions[LC_EDIT_FIND_PREVIOUS]->setIcon(QIcon(":/resources/edit_find_previous.png")); + mActions[LC_EDIT_FIND_ALL]->setIcon(QIcon(":/resources/edit_find_all.png")); mActions[LC_PIECE_SHOW_EARLIER]->setIcon(QIcon(":/resources/piece_show_earlier.png")); mActions[LC_PIECE_SHOW_LATER]->setIcon(QIcon(":/resources/piece_show_later.png")); mActions[LC_VIEW_SPLIT_HORIZONTAL]->setIcon(QIcon(":/resources/view_split_horizontal.png")); @@ -2723,12 +2724,17 @@ void lcMainWindow::HandleCommand(lcCommandId CommandId) case LC_EDIT_FIND_NEXT: if (ActiveModel) - ActiveModel->FindReplacePiece(true); + ActiveModel->FindReplacePiece(true, false); break; case LC_EDIT_FIND_PREVIOUS: if (ActiveModel) - ActiveModel->FindReplacePiece(false); + ActiveModel->FindReplacePiece(false, false); + break; + + case LC_EDIT_FIND_ALL: + if (ActiveModel) + ActiveModel->FindReplacePiece(true, true); break; case LC_EDIT_REPLACE: @@ -2736,9 +2742,14 @@ void lcMainWindow::HandleCommand(lcCommandId CommandId) ActiveView->ShowFindReplaceWidget(true); break; + case LC_EDIT_REPLACE_ALL: + if (ActiveModel) + ActiveModel->FindReplacePiece(true, true); + break; + case LC_EDIT_REPLACE_NEXT: if (ActiveModel) - ActiveModel->FindReplacePiece(true); + ActiveModel->FindReplacePiece(true, false); break; case LC_EDIT_SELECT_ALL: diff --git a/common/lc_model.cpp b/common/lc_model.cpp index 22ba72cc..d7fd29da 100644 --- a/common/lc_model.cpp +++ b/common/lc_model.cpp @@ -3779,7 +3779,7 @@ void lcModel::UnhideAllPieces() SaveCheckpoint(tr("Unhide")); } -void lcModel::FindReplacePiece(bool SearchForward) +void lcModel::FindReplacePiece(bool SearchForward, bool FindAll) { if (mPieces.IsEmpty()) return; @@ -3824,6 +3824,7 @@ void lcModel::FindReplacePiece(bool SearchForward) int CurrentIdx = StartIdx; lcPiece* Focus = nullptr; + lcArray Selection; for (;;) { @@ -3844,15 +3845,23 @@ void lcModel::FindReplacePiece(bool SearchForward) if (PieceMatches(Current)) { - Focus = Current; - break; + if (FindAll) + Selection.Add(Current); + else + { + Focus = Current; + break; + } } if (CurrentIdx == StartIdx) break; } - ClearSelectionAndSetFocus(Focus, LC_PIECE_SECTION_POSITION, false); + if (FindAll) + SetSelectionAndFocus(Selection, nullptr, 0, false); + else + ClearSelectionAndSetFocus(Focus, LC_PIECE_SECTION_POSITION, false); } void lcModel::UndoAction() diff --git a/common/lc_model.h b/common/lc_model.h index 416ca902..1a168357 100644 --- a/common/lc_model.h +++ b/common/lc_model.h @@ -281,7 +281,7 @@ public: void UnhideSelectedPieces(); void UnhideAllPieces(); - void FindReplacePiece(bool SearchForward); + void FindReplacePiece(bool SearchForward, bool FindAll); void UndoAction(); void RedoAction(); diff --git a/leocad.qrc b/leocad.qrc index 09b9ed25..dce0f7b0 100644 --- a/leocad.qrc +++ b/leocad.qrc @@ -65,6 +65,7 @@ resources/edit_find.png resources/edit_find_next.png resources/edit_find_previous.png + resources/edit_find_all.png resources/edit_paste.png resources/edit_redo.png resources/edit_snap_angle.png diff --git a/resources/edit_find_all.png b/resources/edit_find_all.png new file mode 100644 index 00000000..3c548279 Binary files /dev/null and b/resources/edit_find_all.png differ