From 68482935f5aa8c40573d9062a20a41315357a764 Mon Sep 17 00:00:00 2001 From: RickyRister Date: Sat, 8 Feb 2025 21:40:30 -0800 Subject: [PATCH] get icon to work --- .../widgets/general/display/banner_widget.cpp | 20 +++++++++++++++++-- .../widgets/general/display/banner_widget.h | 3 ++- 2 files changed, 20 insertions(+), 3 deletions(-) diff --git a/cockatrice/src/client/ui/widgets/general/display/banner_widget.cpp b/cockatrice/src/client/ui/widgets/general/display/banner_widget.cpp index 64a64ba7c..68367ef18 100644 --- a/cockatrice/src/client/ui/widgets/general/display/banner_widget.cpp +++ b/cockatrice/src/client/ui/widgets/general/display/banner_widget.cpp @@ -1,5 +1,7 @@ #include "banner_widget.h" +#include "../../../../../client/ui/pixel_map_generator.h" + #include #include #include @@ -8,14 +10,20 @@ BannerWidget::BannerWidget(QWidget *parent, const QString &text, Qt::Orientation orientation, int transparency) : QWidget(parent), gradientOrientation(orientation), transparency(qBound(0, transparency, 100)) { + auto layout = new QHBoxLayout(this); + + iconLabel = new QLabel(this); + iconLabel->setAlignment(Qt::AlignLeft | Qt::AlignVCenter); + setExpandIconState(true); + // Create the banner label and set properties bannerLabel = new QLabel(text, this); bannerLabel->setAlignment(Qt::AlignCenter); bannerLabel->setStyleSheet("font-size: 24px; font-weight: bold; color: white;"); - // Layout to center the banner label - layout = new QVBoxLayout(this); + layout->addWidget(iconLabel); layout->addWidget(bannerLabel); + layout->addWidget(new QLabel(this)); // add dummy label to force text label to be centered setLayout(layout); // Set minimum height for the widget @@ -40,9 +48,17 @@ void BannerWidget::toggleBuddyVisibility() const { if (buddy) { buddy->setVisible(!buddy->isVisible()); + setExpandIconState(buddy->isVisible()); + } else { + setExpandIconState(false); } } +void BannerWidget::setExpandIconState(bool expanded) const +{ + iconLabel->setPixmap(ExpandIconPixmapGenerator::generatePixmap(24, expanded)); +} + void BannerWidget::paintEvent(QPaintEvent *event) { Q_UNUSED(event); diff --git a/cockatrice/src/client/ui/widgets/general/display/banner_widget.h b/cockatrice/src/client/ui/widgets/general/display/banner_widget.h index 545cb5ed6..39e5b0202 100644 --- a/cockatrice/src/client/ui/widgets/general/display/banner_widget.h +++ b/cockatrice/src/client/ui/widgets/general/display/banner_widget.h @@ -33,7 +33,7 @@ protected: void paintEvent(QPaintEvent *event) override; private: - QVBoxLayout *layout; + QLabel *iconLabel; QLabel *bannerLabel; Qt::Orientation gradientOrientation; int transparency; // Transparency percentage for the gradient @@ -43,6 +43,7 @@ signals: void buddyVisibilityChanged(); private slots: void toggleBuddyVisibility() const; + void setExpandIconState(bool expanded) const; }; #endif // BANNER_WIDGET_H