InputDialogValidatable.h 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  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. #pragma once
  9. #if !defined(Q_MOC_RUN)
  10. #include <Editor/LineEditValidatable.h>
  11. #include <QDialog>
  12. #endif
  13. QT_FORWARD_DECLARE_CLASS(QDialogButtonBox)
  14. namespace EMStudio
  15. {
  16. class InputDialogValidatable
  17. : public QDialog
  18. {
  19. Q_OBJECT //AUTOMOC
  20. public:
  21. AZ_CLASS_ALLOCATOR_DECL
  22. InputDialogValidatable(QWidget* parent, const QString& labelText, const QRegExp regExp = LineEditValidatable::s_defaultRegExp);
  23. // When destructing clear the Validator which sets the LineEdit Validator to stop lambda validates being called
  24. ~InputDialogValidatable() { SetValidatorFunc(nullptr); }
  25. void SetText(const QString& text);
  26. QString GetText() const;
  27. void SetValidatorFunc(const AZStd::function<bool()>& func);
  28. private slots:
  29. void OnAccepted();
  30. private:
  31. LineEditValidatable* m_lineEdit = nullptr;
  32. QDialogButtonBox* m_buttonBox = nullptr;
  33. };
  34. } // namespace EMStudio