UiAnimViewNewSequenceDialog.cpp 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  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 "UiAnimViewNewSequenceDialog.h"
  9. #include "Animation/UiAnimViewSequenceManager.h"
  10. #include <Editor/Animation/ui_UiAnimViewNewSequenceDialog.h>
  11. #include <QMessageBox>
  12. #include "QtUtil.h"
  13. // UiAnimViewNewSequenceDialog dialog
  14. CUiAVNewSequenceDialog::CUiAVNewSequenceDialog(QWidget* parent)
  15. : QDialog(parent)
  16. , ui(new Ui::CUiAVNewSequenceDialog)
  17. {
  18. ui->setupUi(this);
  19. connect(ui->buttonBox, &QDialogButtonBox::accepted, this, &CUiAVNewSequenceDialog::OnOK);
  20. setWindowTitle("Add New Sequence");
  21. }
  22. CUiAVNewSequenceDialog::~CUiAVNewSequenceDialog()
  23. {
  24. }
  25. void CUiAVNewSequenceDialog::OnOK()
  26. {
  27. m_sequenceName = ui->NAME->text();
  28. if (m_sequenceName.isEmpty())
  29. {
  30. QMessageBox::warning(this, "New Sequence", "A sequence name cannot be empty!");
  31. return;
  32. }
  33. else if (m_sequenceName.contains('/'))
  34. {
  35. QMessageBox::warning(this, "New Sequence", "A sequence name cannot contain a '/' character!");
  36. return;
  37. }
  38. for (unsigned int k = 0; k < CUiAnimViewSequenceManager::GetSequenceManager()->GetCount(); ++k)
  39. {
  40. CUiAnimViewSequence* pSequence = CUiAnimViewSequenceManager::GetSequenceManager()->GetSequenceByIndex(k);
  41. QString fullname = QString::fromUtf8(pSequence->GetName().c_str());
  42. if (fullname.compare(m_sequenceName, Qt::CaseInsensitive) == 0)
  43. {
  44. QMessageBox::warning(this, "New Sequence", "Sequence with this name already exists!");
  45. return;
  46. }
  47. }
  48. accept();
  49. }
  50. #include <Animation/moc_UiAnimViewNewSequenceDialog.cpp>