mirror of
https://github.com/Cockatrice/Cockatrice.git
synced 2026-07-08 17:13:57 -07:00
Same treatment for printing selector.
Took 42 minutes
This commit is contained in:
parent
d5d57ec469
commit
e6d3d98feb
6 changed files with 90 additions and 2 deletions
|
|
@ -203,6 +203,7 @@ set(cockatrice_SOURCES
|
|||
src/interface/widgets/printing_selector/printing_selector.cpp
|
||||
src/interface/widgets/printing_selector/printing_selector_card_display_widget.cpp
|
||||
src/interface/widgets/printing_selector/printing_selector_card_overlay_widget.cpp
|
||||
src/interface/widgets/printing_selector/printing_selector_placeholder_widget.cpp
|
||||
src/interface/widgets/printing_selector/printing_selector_card_search_widget.cpp
|
||||
src/interface/widgets/printing_selector/printing_selector_card_selection_widget.cpp
|
||||
src/interface/widgets/printing_selector/printing_selector_card_sorting_widget.cpp
|
||||
|
|
|
|||
|
|
@ -61,6 +61,7 @@
|
|||
|
||||
<file>resources/backgrounds/home.png</file>
|
||||
<file>resources/backgrounds/card_triplet.svg</file>
|
||||
<file>resources/backgrounds/placeholder_printing_selector.svg</file>
|
||||
|
||||
<file>resources/config/general.svg</file>
|
||||
<file>resources/config/appearance.svg</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);
|
||||
}
|
||||
}
|
||||
|
|
@ -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;
|
||||
|
|
|
|||
|
|
@ -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"));
|
||||
}
|
||||
|
|
@ -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
|
||||
Loading…
Add table
Add a link
Reference in a new issue