FormComboBoxWidget.h 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  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 <QWidget>
  11. #endif
  12. QT_FORWARD_DECLARE_CLASS(QLineEdit)
  13. QT_FORWARD_DECLARE_CLASS(QLabel)
  14. QT_FORWARD_DECLARE_CLASS(QFrame)
  15. QT_FORWARD_DECLARE_CLASS(QHBoxLayout)
  16. QT_FORWARD_DECLARE_CLASS(QComboBox)
  17. namespace O3DE::ProjectManager
  18. {
  19. class FormComboBoxWidget : public QWidget
  20. {
  21. Q_OBJECT
  22. public:
  23. explicit FormComboBoxWidget(const QString& labelText, const QStringList& items = {}, QWidget* parent = nullptr);
  24. ~FormComboBoxWidget() = default;
  25. //! Set the error message for to display when invalid.
  26. void setErrorLabelText(const QString& labelText);
  27. void setErrorLabelVisible(bool visible);
  28. QComboBox* comboBox() const;
  29. protected:
  30. virtual bool eventFilter(QObject* object, QEvent* event);
  31. QLabel* m_errorLabel = nullptr;
  32. QFrame* m_frame = nullptr;
  33. QHBoxLayout* m_frameLayout = nullptr;
  34. QComboBox* m_comboBox = nullptr;
  35. private slots:
  36. void onFocus();
  37. void onFocusOut();
  38. private:
  39. void mousePressEvent(QMouseEvent* event) override;
  40. void refreshStyle();
  41. };
  42. } // namespace O3DE::ProjectManager