mirror of
https://github.com/Cockatrice/Cockatrice.git
synced 2026-07-09 17:44:01 -07:00
We have good labels at home.
This commit is contained in:
parent
46acfca790
commit
7d7db0cbb4
8 changed files with 21 additions and 53 deletions
|
|
@ -160,7 +160,6 @@ set(cockatrice_SOURCES
|
|||
src/interface/widgets/general/display/dynamic_font_size_label.cpp
|
||||
src/interface/widgets/general/display/dynamic_font_size_push_button.cpp
|
||||
src/interface/widgets/general/display/labeled_input.cpp
|
||||
src/interface/widgets/general/display/overlay_label.cpp
|
||||
src/interface/widgets/general/display/percent_bar_widget.cpp
|
||||
src/interface/widgets/general/display/shadow_background_label.cpp
|
||||
src/interface/widgets/general/home_styled_button.cpp
|
||||
|
|
|
|||
|
|
@ -1,22 +0,0 @@
|
|||
#include "overlay_label.h"
|
||||
|
||||
#include <QPainter>
|
||||
|
||||
OverlayLabel::OverlayLabel(QWidget *parent) : QLabel(parent)
|
||||
{
|
||||
setAttribute(Qt::WA_TranslucentBackground);
|
||||
}
|
||||
|
||||
void OverlayLabel::paintEvent(QPaintEvent *event)
|
||||
{
|
||||
QPainter p(this);
|
||||
p.setRenderHint(QPainter::Antialiasing, true);
|
||||
|
||||
QRect r = rect().adjusted(0, 0, -1, -1);
|
||||
|
||||
p.setBrush(QColor(0, 0, 0, 140));
|
||||
p.setPen(Qt::NoPen);
|
||||
p.drawRoundedRect(r, 6, 6);
|
||||
|
||||
QLabel::paintEvent(event);
|
||||
}
|
||||
|
|
@ -1,16 +0,0 @@
|
|||
#ifndef COCKATRICE_OVERLAY_LABEL_H
|
||||
#define COCKATRICE_OVERLAY_LABEL_H
|
||||
|
||||
#include <QLabel>
|
||||
|
||||
class OverlayLabel : public QLabel
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit OverlayLabel(QWidget *parent = nullptr);
|
||||
|
||||
protected:
|
||||
void paintEvent(QPaintEvent *event) override;
|
||||
};
|
||||
|
||||
#endif // COCKATRICE_OVERLAY_LABEL_H
|
||||
|
|
@ -13,11 +13,17 @@
|
|||
ShadowBackgroundLabel::ShadowBackgroundLabel(QWidget *parent, const QString &text) : QLabel(parent)
|
||||
{
|
||||
setAttribute(Qt::WA_TranslucentBackground); // Allows transparency.
|
||||
setText("<font color='white'>" + text + "</font>"); ///< Ensures the text is rendered in white.
|
||||
setLabelText(text);
|
||||
setAlignment(Qt::AlignCenter); ///< Centers the text within the label.
|
||||
setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Minimum); ///< Ensures minimum size constraints.
|
||||
}
|
||||
|
||||
void ShadowBackgroundLabel::setLabelText(const QString &text)
|
||||
{
|
||||
setText("<font color='white'>" + text + "</font>"); ///< Ensures the text is rendered in white.
|
||||
update();
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Handles resizing of the label.
|
||||
*
|
||||
|
|
|
|||
|
|
@ -15,6 +15,7 @@ class ShadowBackgroundLabel : public QLabel
|
|||
|
||||
public:
|
||||
explicit ShadowBackgroundLabel(QWidget *parent, const QString &text);
|
||||
void setLabelText(const QString &text);
|
||||
|
||||
protected:
|
||||
void resizeEvent(QResizeEvent *event) override;
|
||||
|
|
|
|||
|
|
@ -60,21 +60,21 @@ ArchidektApiResponseDeckEntryDisplayWidget::ArchidektApiResponseDeckEntryDisplay
|
|||
// Set deck name (ellided)
|
||||
QFontMetrics fm(previewWidget->topLeftLabel->font());
|
||||
QString elided = fm.elidedText(response.getName(), Qt::ElideRight, 280);
|
||||
previewWidget->topLeftLabel->setText(elided);
|
||||
previewWidget->topLeftLabel->setLabelText(elided);
|
||||
previewWidget->topLeftLabel->setToolTip(response.getName());
|
||||
|
||||
// Set count
|
||||
previewWidget->topRightLabel->setText(QString::number(response.getSize()));
|
||||
previewWidget->topRightLabel->setLabelText(QString::number(response.getSize()));
|
||||
|
||||
// EDH bracket (skip if 0)
|
||||
if (response.getEDHBracket() != 0) {
|
||||
previewWidget->bottomLeftLabel->setText(QString("EDH: %1").arg(response.getEDHBracket()));
|
||||
previewWidget->bottomLeftLabel->setLabelText(QString("EDH: %1").arg(response.getEDHBracket()));
|
||||
} else {
|
||||
previewWidget->bottomLeftLabel->hide();
|
||||
}
|
||||
|
||||
// Views
|
||||
previewWidget->bottomRightLabel->setText(QString("Views: %1").arg(response.getViewCount()));
|
||||
previewWidget->bottomRightLabel->setLabelText(QString("Views: %1").arg(response.getViewCount()));
|
||||
|
||||
// Use preview->imageLabel for image loading
|
||||
picture = previewWidget->imageLabel;
|
||||
|
|
|
|||
|
|
@ -8,10 +8,10 @@ ArchidektDeckPreviewImageDisplayWidget::ArchidektDeckPreviewImageDisplayWidget(Q
|
|||
imageLabel = new QLabel(this);
|
||||
imageLabel->setAlignment(Qt::AlignCenter);
|
||||
|
||||
topLeftLabel = new OverlayLabel(this);
|
||||
topRightLabel = new OverlayLabel(this);
|
||||
bottomLeftLabel = new OverlayLabel(this);
|
||||
bottomRightLabel = new OverlayLabel(this);
|
||||
topLeftLabel = new ShadowBackgroundLabel(this, "");
|
||||
topRightLabel = new ShadowBackgroundLabel(this, "");
|
||||
bottomLeftLabel = new ShadowBackgroundLabel(this, "");
|
||||
bottomRightLabel = new ShadowBackgroundLabel(this, "");
|
||||
|
||||
QFont f;
|
||||
f.setBold(true);
|
||||
|
|
|
|||
|
|
@ -5,7 +5,7 @@
|
|||
#ifndef COCKATRICE_ARCHIDEKT_DECK_PREVIEW_IMAGE_DISPLAY_WIDGET_H
|
||||
#define COCKATRICE_ARCHIDEKT_DECK_PREVIEW_IMAGE_DISPLAY_WIDGET_H
|
||||
|
||||
#include "../../../../general/display/overlay_label.h"
|
||||
#include "../../../../general/display/shadow_background_label.h"
|
||||
|
||||
#include <QLabel>
|
||||
#include <QWidget>
|
||||
|
|
@ -20,10 +20,10 @@ public:
|
|||
void setPreviewWidth(int width);
|
||||
|
||||
QLabel *imageLabel;
|
||||
OverlayLabel *topLeftLabel;
|
||||
OverlayLabel *topRightLabel;
|
||||
OverlayLabel *bottomLeftLabel;
|
||||
OverlayLabel *bottomRightLabel;
|
||||
ShadowBackgroundLabel *topLeftLabel;
|
||||
ShadowBackgroundLabel *topRightLabel;
|
||||
ShadowBackgroundLabel *bottomLeftLabel;
|
||||
ShadowBackgroundLabel *bottomRightLabel;
|
||||
|
||||
protected:
|
||||
void resizeEvent(QResizeEvent *event) override;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue