mirror of
https://github.com/Cockatrice/Cockatrice.git
synced 2026-07-19 08:52:15 -07:00
Remove close button (for now) and change "Add tags ..." to "Edit tags ..."
This commit is contained in:
parent
3976ab8d5d
commit
856cfb7d87
3 changed files with 17 additions and 17 deletions
|
|
@ -26,6 +26,6 @@ DeckPreviewDeckTagsDisplayWidget::DeckPreviewDeckTagsDisplayWidget(DeckPreviewWi
|
|||
for (const QString &tag : this->deckLoader->getTags()) {
|
||||
flowWidget->addWidget(new DeckPreviewTagDisplayWidget(this, tag));
|
||||
}
|
||||
flowWidget->addWidget(new DeckPreviewTagAdditionWidget(this, tr("Add tags ...")));
|
||||
flowWidget->addWidget(new DeckPreviewTagAdditionWidget(this, tr("Edit tags ...")));
|
||||
layout->addWidget(flowWidget);
|
||||
}
|
||||
|
|
@ -19,15 +19,15 @@ DeckPreviewTagAdditionWidget::DeckPreviewTagAdditionWidget(DeckPreviewDeckTagsDi
|
|||
layout->addWidget(tagLabel_);
|
||||
|
||||
// Create close button
|
||||
closeButton_ = new QPushButton("x", this);
|
||||
closeButton_->setFixedSize(16, 16); // Small square button
|
||||
layout->addWidget(closeButton_);
|
||||
// closeButton_ = new QPushButton("x", this);
|
||||
// closeButton_->setFixedSize(16, 16); // Small square button
|
||||
// layout->addWidget(closeButton_);
|
||||
|
||||
// Adjust widget size
|
||||
setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Fixed);
|
||||
|
||||
// Connect close button to the remove signal
|
||||
connect(closeButton_, &QPushButton::clicked, this, &DeckPreviewTagAdditionWidget::tagClosed);
|
||||
// connect(closeButton_, &QPushButton::clicked, this, &DeckPreviewTagAdditionWidget::tagClosed);
|
||||
}
|
||||
|
||||
void DeckPreviewTagAdditionWidget::mousePressEvent(QMouseEvent *event)
|
||||
|
|
|
|||
|
|
@ -14,25 +14,25 @@ DeckPreviewTagDisplayWidget::DeckPreviewTagDisplayWidget(QWidget *parent, const
|
|||
layout->setSpacing(5);
|
||||
|
||||
// Add a stretch spacer for text and close button separation
|
||||
layout->addStretch(); // Ensures the close button stays at the far-right side
|
||||
// layout->addStretch(); // Ensures the close button stays at the far-right side
|
||||
|
||||
// Create close button
|
||||
closeButton = new QPushButton("x", this);
|
||||
closeButton->setFixedSize(16, 16); // Small square button
|
||||
closeButton->setFocusPolicy(Qt::NoFocus);
|
||||
// closeButton = new QPushButton("x", this);
|
||||
// closeButton->setFixedSize(16, 16); // Small square button
|
||||
// closeButton->setFocusPolicy(Qt::NoFocus);
|
||||
|
||||
// Set font for close button to ensure the "x" appears correctly
|
||||
QFont closeButtonFont = closeButton->font();
|
||||
closeButtonFont.setPointSize(10); // Adjust the size to make the "x" clear
|
||||
closeButton->setFont(closeButtonFont);
|
||||
// QFont closeButtonFont = closeButton->font();
|
||||
// closeButtonFont.setPointSize(10); // Adjust the size to make the "x" clear
|
||||
// closeButton->setFont(closeButtonFont);
|
||||
|
||||
layout->addWidget(closeButton);
|
||||
// layout->addWidget(closeButton);
|
||||
|
||||
// Adjust widget size
|
||||
setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Fixed);
|
||||
|
||||
// Connect close button to the remove signal
|
||||
connect(closeButton, &QPushButton::clicked, this, &DeckPreviewTagDisplayWidget::tagClosed);
|
||||
// connect(closeButton, &QPushButton::clicked, this, &DeckPreviewTagDisplayWidget::tagClosed);
|
||||
}
|
||||
|
||||
QSize DeckPreviewTagDisplayWidget::sizeHint() const
|
||||
|
|
@ -40,7 +40,7 @@ QSize DeckPreviewTagDisplayWidget::sizeHint() const
|
|||
// Calculate the size based on the tag name and close button
|
||||
QFontMetrics fm(font());
|
||||
int textWidth = fm.horizontalAdvance(tagName);
|
||||
int width = textWidth + closeButton->width() + 50; // Add extra padding
|
||||
int width = textWidth + 50; // Add extra padding
|
||||
int height = fm.height() + 10; // Height based on font size + padding
|
||||
|
||||
return QSize(width, height);
|
||||
|
|
@ -86,9 +86,9 @@ void DeckPreviewTagDisplayWidget::paintEvent(QPaintEvent *event)
|
|||
painter.setFont(font);
|
||||
|
||||
// Calculate text rect to avoid overlap with the close button
|
||||
int closeButtonWidth = closeButton->width();
|
||||
// int closeButtonWidth = closeButton->width();
|
||||
int margin = 10; // Left and right margins
|
||||
QRect textRect(margin, 0, width() - closeButtonWidth - margin * 2, height());
|
||||
QRect textRect(margin, 0, width() - margin * 2, height());
|
||||
|
||||
// Draw the text with a black border for better legibility
|
||||
painter.setPen(Qt::black);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue