mirror of
https://github.com/Cockatrice/Cockatrice.git
synced 2026-07-08 17:13:57 -07:00
[VDE] Use placeholder image for deck view if deck is empty.
Took 15 minutes Took 9 seconds Took 5 seconds
This commit is contained in:
parent
38e73486c1
commit
09ae89d283
4 changed files with 85 additions and 8 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);
|
&VisualDeckEditorWidget::onSelectionChanged);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
updatePlaceholderVisibility();
|
||||||
retranslateUi();
|
retranslateUi();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -181,15 +182,13 @@ void VisualDeckEditorWidget::initializeScrollAreaAndZoneContainer()
|
||||||
zoneContainer = new QWidget(scrollArea);
|
zoneContainer = new QWidget(scrollArea);
|
||||||
zoneContainer->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
|
zoneContainer->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
|
||||||
zoneContainer->setObjectName("zoneContainer");
|
zoneContainer->setObjectName("zoneContainer");
|
||||||
zoneContainer->setStyleSheet(R"(
|
|
||||||
QWidget#zoneContainer {
|
|
||||||
background-image: url(theme:backgrounds/card_triplet.svg);
|
|
||||||
background-repeat: no-repeat;
|
|
||||||
background-position: center;
|
|
||||||
}
|
|
||||||
)");
|
|
||||||
zoneContainerLayout = new QVBoxLayout(zoneContainer);
|
zoneContainerLayout = new QVBoxLayout(zoneContainer);
|
||||||
zoneContainer->setLayout(zoneContainerLayout);
|
zoneContainer->setLayout(zoneContainerLayout);
|
||||||
|
|
||||||
|
// Create placeholder widget
|
||||||
|
placeholderWidget = new VisualDeckEditorPlaceholderWidget(zoneContainer);
|
||||||
|
zoneContainerLayout->addWidget(placeholderWidget);
|
||||||
|
|
||||||
scrollArea->addScrollBarWidget(zoneContainer, Qt::AlignHCenter);
|
scrollArea->addScrollBarWidget(zoneContainer, Qt::AlignHCenter);
|
||||||
scrollArea->setWidget(zoneContainer);
|
scrollArea->setWidget(zoneContainer);
|
||||||
}
|
}
|
||||||
|
|
@ -208,6 +207,17 @@ void VisualDeckEditorWidget::retranslateUi()
|
||||||
searchPushButton->setText(tr("Quick search and add card"));
|
searchPushButton->setText(tr("Quick search and add card"));
|
||||||
searchPushButton->setToolTip(tr("Search for closest match in the database (with auto-suggestions) and add "
|
searchPushButton->setToolTip(tr("Search for closest match in the database (with auto-suggestions) and add "
|
||||||
"preferred printing to the deck on pressing enter"));
|
"preferred printing to the deck on pressing enter"));
|
||||||
|
|
||||||
|
if (placeholderWidget) {
|
||||||
|
placeholderWidget->retranslateUi();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void VisualDeckEditorWidget::updatePlaceholderVisibility()
|
||||||
|
{
|
||||||
|
if (placeholderWidget) {
|
||||||
|
placeholderWidget->setVisible(indexToWidgetMap.isEmpty());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// =====================================================================================================================
|
// =====================================================================================================================
|
||||||
|
|
@ -258,6 +268,7 @@ void VisualDeckEditorWidget::constructZoneWidgetsFromDeckListModel()
|
||||||
|
|
||||||
constructZoneWidgetForIndex(persistent);
|
constructZoneWidgetForIndex(persistent);
|
||||||
}
|
}
|
||||||
|
updatePlaceholderVisibility();
|
||||||
}
|
}
|
||||||
|
|
||||||
void VisualDeckEditorWidget::updateZoneWidgets()
|
void VisualDeckEditorWidget::updateZoneWidgets()
|
||||||
|
|
@ -398,4 +409,4 @@ void VisualDeckEditorWidget::onSelectionChanged(const QItemSelection &selected,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -11,6 +11,7 @@
|
||||||
#include "../cards/card_size_widget.h"
|
#include "../cards/card_size_widget.h"
|
||||||
#include "../general/layout_containers/overlap_control_widget.h"
|
#include "../general/layout_containers/overlap_control_widget.h"
|
||||||
#include "../quick_settings/settings_button_widget.h"
|
#include "../quick_settings/settings_button_widget.h"
|
||||||
|
#include "visual_deck_editor_placeholder_widget.h"
|
||||||
|
|
||||||
#include <QCheckBox>
|
#include <QCheckBox>
|
||||||
#include <QListWidget>
|
#include <QListWidget>
|
||||||
|
|
@ -44,6 +45,7 @@ public:
|
||||||
|
|
||||||
void setSelectionModel(QItemSelectionModel *model);
|
void setSelectionModel(QItemSelectionModel *model);
|
||||||
void onSelectionChanged(const QItemSelection &selected, const QItemSelection &deselected);
|
void onSelectionChanged(const QItemSelection &selected, const QItemSelection &deselected);
|
||||||
|
void updatePlaceholderVisibility();
|
||||||
QItemSelectionModel *getSelectionModel() const
|
QItemSelectionModel *getSelectionModel() const
|
||||||
{
|
{
|
||||||
return selectionModel;
|
return selectionModel;
|
||||||
|
|
@ -96,6 +98,7 @@ private:
|
||||||
QScrollArea *scrollArea;
|
QScrollArea *scrollArea;
|
||||||
QWidget *zoneContainer;
|
QWidget *zoneContainer;
|
||||||
QVBoxLayout *zoneContainerLayout;
|
QVBoxLayout *zoneContainerLayout;
|
||||||
|
VisualDeckEditorPlaceholderWidget *placeholderWidget;
|
||||||
// OverlapControlWidget *overlapControlWidget;
|
// OverlapControlWidget *overlapControlWidget;
|
||||||
QHash<QPersistentModelIndex, QWidget *> indexToWidgetMap;
|
QHash<QPersistentModelIndex, QWidget *> indexToWidgetMap;
|
||||||
};
|
};
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue