JointSelectionDialog.cpp 2.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  1. /*
  2. * Copyright (c) Contributors to the Open 3D Engine Project.
  3. * For complete copyright and license terms please see the LICENSE at the root of this distribution.
  4. *
  5. * SPDX-License-Identifier: Apache-2.0 OR MIT
  6. *
  7. */
  8. #include <Editor/JointSelectionDialog.h>
  9. #include <Editor/JointSelectionWidget.h>
  10. #include <QAbstractItemView>
  11. #include <QLabel>
  12. #include <QPushButton>
  13. #include <QVBoxLayout>
  14. namespace EMotionFX
  15. {
  16. JointSelectionDialog::JointSelectionDialog(bool singleSelection, const QString& title, const QString& descriptionLabelText, QWidget* parent)
  17. : QDialog(parent)
  18. {
  19. setWindowTitle(title);
  20. QVBoxLayout* layout = new QVBoxLayout(this);
  21. setLayout(layout);
  22. QLabel* textLabel = new QLabel(descriptionLabelText, this);
  23. layout->addWidget(textLabel, 0, Qt::AlignLeft);
  24. m_jointSelectionWidget = new JointSelectionWidget(singleSelection ? QAbstractItemView::SingleSelection : QAbstractItemView::ExtendedSelection, this);
  25. layout->addWidget(m_jointSelectionWidget);
  26. QHBoxLayout* buttonLayout = new QHBoxLayout(this);
  27. layout->addLayout(buttonLayout);
  28. QPushButton* okButton = new QPushButton("OK");
  29. buttonLayout->addWidget(okButton);
  30. QPushButton* cancelButton = new QPushButton("Cancel");
  31. buttonLayout->addWidget(cancelButton);
  32. if (singleSelection)
  33. {
  34. connect(m_jointSelectionWidget, &JointSelectionWidget::ItemDoubleClicked, this, &JointSelectionDialog::OnItemDoubleClicked);
  35. }
  36. connect(okButton, &QPushButton::clicked, this, &JointSelectionDialog::accept);
  37. connect(cancelButton, &QPushButton::clicked, this, &JointSelectionDialog::reject);
  38. setMinimumSize(QSize(500, 400));
  39. resize(700, 800);
  40. }
  41. JointSelectionDialog::~JointSelectionDialog()
  42. {
  43. }
  44. void JointSelectionDialog::OnItemDoubleClicked(const QModelIndex& modelIndex)
  45. {
  46. AZ_UNUSED(modelIndex);
  47. accept();
  48. }
  49. void JointSelectionDialog::SelectByJointNames(const AZStd::vector<AZStd::string>& jointNames)
  50. {
  51. m_jointSelectionWidget->SelectByJointNames(jointNames);
  52. }
  53. AZStd::vector<AZStd::string> JointSelectionDialog::GetSelectedJointNames() const
  54. {
  55. return m_jointSelectionWidget->GetSelectedJointNames();
  56. }
  57. void JointSelectionDialog::SetFilterState(const QString& category, const QString& displayName, bool enabled)
  58. {
  59. m_jointSelectionWidget->SetFilterState(category, displayName, enabled);
  60. }
  61. void JointSelectionDialog::HideIcons()
  62. {
  63. m_jointSelectionWidget->HideIcons();
  64. }
  65. } // namespace EMotionFX