NotificationWidget.cpp 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  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/NotificationWidget.h>
  9. #include <MysticQt/Source/MysticQtManager.h>
  10. #include <QVBoxLayout>
  11. #include <QHBoxLayout>
  12. #include <QLabel>
  13. #include <QIcon>
  14. namespace EMotionFX
  15. {
  16. NotificationWidget::NotificationWidget(QWidget* parent, const QString& title)
  17. : QFrame(parent)
  18. {
  19. setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Maximum);
  20. QFrame* headerFrame = new QFrame(this);
  21. headerFrame->setObjectName("HeaderFrame");
  22. headerFrame->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Maximum);
  23. headerFrame->setFrameStyle(QFrame::StyledPanel | QFrame::Plain);
  24. headerFrame->setStyleSheet("background-color: rgb(60, 60, 60);");
  25. // Icon widget
  26. QLabel* iconLabel = new QLabel(headerFrame);
  27. iconLabel->setObjectName("Icon");
  28. QIcon icon(":/EMotionFX/Notification.svg");
  29. iconLabel->setPixmap(icon.pixmap(QSize(24, 24)));
  30. // Title widget
  31. QLabel* titleLabel = new QLabel(title, headerFrame);
  32. titleLabel->setObjectName("Title");
  33. titleLabel->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed);
  34. titleLabel->setWordWrap(true);
  35. QHBoxLayout* headerLayout = new QHBoxLayout(headerFrame);
  36. headerLayout->setSizeConstraint(QLayout::SetMinimumSize);
  37. headerLayout->setContentsMargins(QMargins(0, 0, 0, 0));
  38. headerLayout->addWidget(iconLabel);
  39. headerLayout->addWidget(titleLabel);
  40. headerFrame->setLayout(headerLayout);
  41. m_featureLayout = new QVBoxLayout(this);
  42. m_featureLayout->setSizeConstraint(QLayout::SetMinimumSize);
  43. m_featureLayout->setContentsMargins(QMargins(0, 0, 0, 0));
  44. m_featureLayout->addWidget(headerFrame);
  45. }
  46. void NotificationWidget::addFeature(QWidget* feature)
  47. {
  48. feature->setParent(this);
  49. m_featureLayout->addWidget(feature);
  50. }
  51. }