mirror of
https://github.com/Cockatrice/Cockatrice.git
synced 2026-04-27 07:48:01 -07:00
[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:
parent
c553e15036
commit
29f60c4a67
12 changed files with 242 additions and 5 deletions
|
|
@ -0,0 +1,41 @@
|
|||
#include "visual_deck_editor_placeholder_widget.h"
|
||||
|
||||
VisualDeckEditorPlaceholderWidget::VisualDeckEditorPlaceholderWidget(QWidget *parent) : QWidget(parent)
|
||||
{
|
||||
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/card_triplet.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 VisualDeckEditorPlaceholderWidget::retranslateUi()
|
||||
{
|
||||
textLabel->setText(tr("Add cards using the search bar or database tab to have them appear here"));
|
||||
}
|
||||
|
|
@ -0,0 +1,22 @@
|
|||
#ifndef COCKATRICE_VISUAL_DECK_EDITOR_PLACEHOLDER_WIDGET_H
|
||||
#define COCKATRICE_VISUAL_DECK_EDITOR_PLACEHOLDER_WIDGET_H
|
||||
|
||||
#include <QLabel>
|
||||
#include <QVBoxLayout>
|
||||
#include <QWidget>
|
||||
|
||||
class VisualDeckEditorPlaceholderWidget : public QWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit VisualDeckEditorPlaceholderWidget(QWidget *parent = nullptr);
|
||||
void retranslateUi();
|
||||
|
||||
private:
|
||||
QVBoxLayout *mainLayout;
|
||||
QLabel *imageLabel;
|
||||
QLabel *textLabel;
|
||||
};
|
||||
|
||||
#endif // COCKATRICE_VISUAL_DECK_EDITOR_PLACEHOLDER_WIDGET_H
|
||||
|
|
@ -59,6 +59,7 @@ VisualDeckEditorWidget::VisualDeckEditorWidget(QWidget *parent,
|
|||
&VisualDeckEditorWidget::onSelectionChanged);
|
||||
}
|
||||
|
||||
updatePlaceholderVisibility();
|
||||
retranslateUi();
|
||||
}
|
||||
|
||||
|
|
@ -180,8 +181,14 @@ void VisualDeckEditorWidget::initializeScrollAreaAndZoneContainer()
|
|||
|
||||
zoneContainer = new QWidget(scrollArea);
|
||||
zoneContainer->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
|
||||
zoneContainer->setObjectName("zoneContainer");
|
||||
zoneContainerLayout = new QVBoxLayout(zoneContainer);
|
||||
zoneContainer->setLayout(zoneContainerLayout);
|
||||
|
||||
// Create placeholder widget
|
||||
placeholderWidget = new VisualDeckEditorPlaceholderWidget(zoneContainer);
|
||||
zoneContainerLayout->addWidget(placeholderWidget);
|
||||
|
||||
scrollArea->addScrollBarWidget(zoneContainer, Qt::AlignHCenter);
|
||||
scrollArea->setWidget(zoneContainer);
|
||||
}
|
||||
|
|
@ -200,6 +207,17 @@ void VisualDeckEditorWidget::retranslateUi()
|
|||
searchPushButton->setText(tr("Quick search and add card"));
|
||||
searchPushButton->setToolTip(tr("Search for closest match in the database (with auto-suggestions) and add "
|
||||
"preferred printing to the deck on pressing enter"));
|
||||
|
||||
if (placeholderWidget) {
|
||||
placeholderWidget->retranslateUi();
|
||||
}
|
||||
}
|
||||
|
||||
void VisualDeckEditorWidget::updatePlaceholderVisibility()
|
||||
{
|
||||
if (placeholderWidget) {
|
||||
placeholderWidget->setVisible(indexToWidgetMap.isEmpty());
|
||||
}
|
||||
}
|
||||
|
||||
// =====================================================================================================================
|
||||
|
|
@ -250,6 +268,7 @@ void VisualDeckEditorWidget::constructZoneWidgetsFromDeckListModel()
|
|||
|
||||
constructZoneWidgetForIndex(persistent);
|
||||
}
|
||||
updatePlaceholderVisibility();
|
||||
}
|
||||
|
||||
void VisualDeckEditorWidget::updateZoneWidgets()
|
||||
|
|
@ -264,6 +283,7 @@ void VisualDeckEditorWidget::clearAllDisplayWidgets()
|
|||
indexToWidgetMap.remove(idx);
|
||||
delete displayWidget;
|
||||
}
|
||||
updatePlaceholderVisibility();
|
||||
}
|
||||
|
||||
void VisualDeckEditorWidget::cleanupInvalidZones(DeckCardZoneDisplayWidget *displayWidget)
|
||||
|
|
@ -275,6 +295,7 @@ void VisualDeckEditorWidget::cleanupInvalidZones(DeckCardZoneDisplayWidget *disp
|
|||
}
|
||||
}
|
||||
delete displayWidget;
|
||||
updatePlaceholderVisibility();
|
||||
}
|
||||
|
||||
// =====================================================================================================================
|
||||
|
|
@ -294,6 +315,7 @@ void VisualDeckEditorWidget::onCardAddition(const QModelIndex &parent, int first
|
|||
constructZoneWidgetForIndex(index);
|
||||
}
|
||||
}
|
||||
updatePlaceholderVisibility();
|
||||
}
|
||||
|
||||
void VisualDeckEditorWidget::onCardRemoval(const QModelIndex &parent, int first, int last)
|
||||
|
|
@ -308,6 +330,7 @@ void VisualDeckEditorWidget::onCardRemoval(const QModelIndex &parent, int first,
|
|||
indexToWidgetMap.remove(idx);
|
||||
}
|
||||
}
|
||||
updatePlaceholderVisibility();
|
||||
}
|
||||
|
||||
void VisualDeckEditorWidget::decklistModelReset()
|
||||
|
|
@ -390,4 +413,4 @@ void VisualDeckEditorWidget::onSelectionChanged(const QItemSelection &selected,
|
|||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -11,6 +11,7 @@
|
|||
#include "../cards/card_size_widget.h"
|
||||
#include "../general/layout_containers/overlap_control_widget.h"
|
||||
#include "../quick_settings/settings_button_widget.h"
|
||||
#include "visual_deck_editor_placeholder_widget.h"
|
||||
|
||||
#include <QCheckBox>
|
||||
#include <QListWidget>
|
||||
|
|
@ -44,6 +45,7 @@ public:
|
|||
|
||||
void setSelectionModel(QItemSelectionModel *model);
|
||||
void onSelectionChanged(const QItemSelection &selected, const QItemSelection &deselected);
|
||||
void updatePlaceholderVisibility();
|
||||
QItemSelectionModel *getSelectionModel() const
|
||||
{
|
||||
return selectionModel;
|
||||
|
|
@ -96,6 +98,7 @@ private:
|
|||
QScrollArea *scrollArea;
|
||||
QWidget *zoneContainer;
|
||||
QVBoxLayout *zoneContainerLayout;
|
||||
VisualDeckEditorPlaceholderWidget *placeholderWidget;
|
||||
// OverlapControlWidget *overlapControlWidget;
|
||||
QHash<QPersistentModelIndex, QWidget *> indexToWidgetMap;
|
||||
};
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue