[VDE] Placeholder image for deck view if deck is empty (#6516)

* [VDE] A stab at things

Took 14 minutes

Took 10 minutes

Took 5 minutes

Took 4 minutes


Took 41 seconds

Took 10 minutes

Took 3 minutes

* [VDE] Use placeholder image for deck view if deck is empty.

Took 15 minutes

Took 9 seconds

Took 5 seconds

* Sort CMakeList correctly.

Took 35 seconds

Took 23 seconds

* Visibility updates got lost in the rebase.

Took 7 minutes

* Same treatment for printing selector.

Took 42 minutes

* Actually add file.

Took 4 minutes

---------

Co-authored-by: Lukas Brübach <Bruebach.Lukas@bdosecurity.de>
This commit is contained in:
BruebachL 2026-01-14 14:41:54 +01:00 committed by GitHub
parent c553e15036
commit 29f60c4a67
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
12 changed files with 242 additions and 5 deletions

View file

@ -8,6 +8,7 @@
#include "printing_selector_card_search_widget.h"
#include "printing_selector_card_selection_widget.h"
#include "printing_selector_card_sorting_widget.h"
#include "printing_selector_placeholder_widget.h"
#include <QBoxLayout>
#include <QScrollBar>
@ -34,6 +35,8 @@ PrintingSelector::PrintingSelector(QWidget *parent, AbstractTabDeckEditor *_deck
flowWidget = new FlowWidget(this, Qt::Horizontal, Qt::ScrollBarAlwaysOff, Qt::ScrollBarAsNeeded);
placeholderWidget = new PrintingSelectorPlaceholderWidget(this);
sortToolBar = new PrintingSelectorCardSortingWidget(this);
sortToolBar->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Preferred);
@ -70,8 +73,13 @@ PrintingSelector::PrintingSelector(QWidget *parent, AbstractTabDeckEditor *_deck
layout->addWidget(sortAndOptionsContainer);
layout->addWidget(placeholderWidget);
layout->addWidget(flowWidget);
// Initially show placeholder, hide flowWidget
placeholderWidget->setVisible(true);
flowWidget->setVisible(false);
cardSelectionBar = new PrintingSelectorCardSelectionWidget(this, deckStateManager);
cardSelectionBar->setVisible(SettingsCache::instance().getPrintingSelectorNavigationButtonsVisible());
layout->addWidget(cardSelectionBar);
@ -139,7 +147,16 @@ void PrintingSelector::updateDisplay()
widgetLoadingBufferTimer->deleteLater();
widgetLoadingBufferTimer = new QTimer(this);
flowWidget->clearLayout();
if (selectedCard != nullptr) {
if (selectedCard.isNull()) {
// Show placeholder, hide flowWidget
placeholderWidget->setVisible(true);
flowWidget->setVisible(false);
setWindowTitle(tr("Printing Selector"));
} else {
// Hide placeholder, show flowWidget
placeholderWidget->setVisible(false);
flowWidget->setVisible(true);
setWindowTitle(selectedCard->getName());
}
getAllSetsForCurrentCard();
@ -153,6 +170,8 @@ void PrintingSelector::updateDisplay()
void PrintingSelector::setCard(const CardInfoPtr &newCard)
{
if (newCard.isNull()) {
selectedCard = newCard;
updateDisplay();
return;
}
@ -229,4 +248,4 @@ void PrintingSelector::getAllSetsForCurrentCard()
void PrintingSelector::toggleVisibilityNavigationButtons(bool _state)
{
cardSelectionBar->setVisible(_state);
}
}

View file

@ -10,6 +10,7 @@
#include "../cards/card_size_widget.h"
#include "../general/layout_containers/flow_widget.h"
#include "../quick_settings/settings_button_widget.h"
#include "printing_selector_placeholder_widget.h"
#include <QCheckBox>
#include <QLabel>
@ -70,6 +71,7 @@ private:
QCheckBox *navigationCheckBox;
PrintingSelectorCardSortingWidget *sortToolBar;
PrintingSelectorCardSearchWidget *searchBar;
PrintingSelectorPlaceholderWidget *placeholderWidget;
FlowWidget *flowWidget;
CardSizeWidget *cardSizeWidget;
PrintingSelectorCardSelectionWidget *cardSelectionBar;

View file

@ -0,0 +1,42 @@
#include "printing_selector_placeholder_widget.h"
PrintingSelectorPlaceholderWidget::PrintingSelectorPlaceholderWidget(QWidget *parent) : QWidget(parent)
{
setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
mainLayout = new QVBoxLayout(this);
mainLayout->setAlignment(Qt::AlignCenter);
setLayout(mainLayout);
// Image label with the background image
imageLabel = new QLabel(this);
imageLabel->setAlignment(Qt::AlignCenter);
imageLabel->setStyleSheet(R"(
QLabel {
background-image: url(theme:backgrounds/placeholder_printing_selector.svg);
background-repeat: no-repeat;
background-position: center;
}
)");
imageLabel->setFixedSize(300, 300);
textLabel = new QLabel(this);
textLabel->setAlignment(Qt::AlignCenter);
textLabel->setWordWrap(true);
textLabel->setStyleSheet(R"(
QLabel {
color: palette(mid);
font-size: 14px;
padding: 10px;
}
)");
mainLayout->addWidget(imageLabel);
mainLayout->addWidget(textLabel);
retranslateUi();
}
void PrintingSelectorPlaceholderWidget::retranslateUi()
{
textLabel->setText(tr("Select a card to view its available printings"));
}

View file

@ -0,0 +1,23 @@
#ifndef COCKATRICE_PRINTING_SELECTOR_PLACEHOLDER_WIDGET_H
#define COCKATRICE_PRINTING_SELECTOR_PLACEHOLDER_WIDGET_H
#include <QLabel>
#include <QVBoxLayout>
#include <QWidget>
class PrintingSelectorPlaceholderWidget : public QWidget
{
Q_OBJECT
public:
explicit PrintingSelectorPlaceholderWidget(QWidget *parent = nullptr);
private:
QVBoxLayout *mainLayout;
QLabel *imageLabel;
QLabel *textLabel;
void retranslateUi();
};
#endif // COCKATRICE_PRINTING_SELECTOR_PLACEHOLDER_WIDGET_H