mirror of
https://github.com/Cockatrice/Cockatrice.git
synced 2026-04-27 07:48:01 -07:00
[DeckEditor] Deck List History Manager. (#6340)
* [DeckEditor] Deck List History Manager. Took 23 minutes Took 17 minutes * Add icons. Took 2 minutes Took 3 seconds * Small fixes. Took 12 minutes * Style lint. Took 48 seconds * tr() things. Took 5 minutes * Add tooltips for buttons. Took 3 minutes * Add explanation label to history. Took 3 minutes * Refactor to .cpp, delegate undo/redo to manager, don't return memento Took 8 minutes * Clear history when setting deck. Took 6 minutes * Move to value based stacks. Took 52 seconds * Default constructor. Took 31 seconds Took 3 minutes Took 4 minutes Took 2 minutes * Have it listen to deck editor additions. Took 18 minutes * Don't connect buttons *and* actions. Took 2 minutes --------- Co-authored-by: Lukas Brübach <Bruebach.Lukas@bdosecurity.de>
This commit is contained in:
parent
c46f6d1178
commit
846f16ddaa
21 changed files with 612 additions and 41 deletions
|
|
@ -14,8 +14,8 @@
|
|||
#include <QLabel>
|
||||
#include <QMessageBox>
|
||||
|
||||
DeckPreviewDeckTagsDisplayWidget::DeckPreviewDeckTagsDisplayWidget(QWidget *_parent, DeckLoader *_deckLoader)
|
||||
: QWidget(_parent), deckLoader(_deckLoader)
|
||||
DeckPreviewDeckTagsDisplayWidget::DeckPreviewDeckTagsDisplayWidget(QWidget *_parent, DeckList *_deckList)
|
||||
: QWidget(_parent), deckList(nullptr)
|
||||
{
|
||||
|
||||
setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Minimum);
|
||||
|
|
@ -28,20 +28,21 @@ DeckPreviewDeckTagsDisplayWidget::DeckPreviewDeckTagsDisplayWidget(QWidget *_par
|
|||
|
||||
flowWidget = new FlowWidget(this, Qt::Horizontal, Qt::ScrollBarAlwaysOff, Qt::ScrollBarAsNeeded);
|
||||
|
||||
connectDeckList();
|
||||
if (_deckList) {
|
||||
connectDeckList(_deckList);
|
||||
}
|
||||
|
||||
layout->addWidget(flowWidget);
|
||||
}
|
||||
|
||||
void DeckPreviewDeckTagsDisplayWidget::connectDeckList()
|
||||
void DeckPreviewDeckTagsDisplayWidget::connectDeckList(DeckList *_deckList)
|
||||
{
|
||||
if (deckLoader) {
|
||||
disconnect(deckLoader->getDeckList(), &DeckList::deckTagsChanged, this,
|
||||
&DeckPreviewDeckTagsDisplayWidget::refreshTags);
|
||||
if (deckList) {
|
||||
disconnect(deckList, &DeckList::deckTagsChanged, this, &DeckPreviewDeckTagsDisplayWidget::refreshTags);
|
||||
}
|
||||
|
||||
connect(deckLoader->getDeckList(), &DeckList::deckTagsChanged, this,
|
||||
&DeckPreviewDeckTagsDisplayWidget::refreshTags);
|
||||
deckList = _deckList;
|
||||
connect(deckList, &DeckList::deckTagsChanged, this, &DeckPreviewDeckTagsDisplayWidget::refreshTags);
|
||||
|
||||
refreshTags();
|
||||
}
|
||||
|
|
@ -50,7 +51,7 @@ void DeckPreviewDeckTagsDisplayWidget::refreshTags()
|
|||
{
|
||||
flowWidget->clearLayout();
|
||||
|
||||
for (const QString &tag : deckLoader->getDeckList()->getTags()) {
|
||||
for (const QString &tag : deckList->getTags()) {
|
||||
flowWidget->addWidget(new DeckPreviewTagDisplayWidget(this, tag));
|
||||
}
|
||||
|
||||
|
|
@ -97,7 +98,7 @@ void DeckPreviewDeckTagsDisplayWidget::openTagEditDlg()
|
|||
if (qobject_cast<DeckPreviewWidget *>(parentWidget())) {
|
||||
auto *deckPreviewWidget = qobject_cast<DeckPreviewWidget *>(parentWidget());
|
||||
QStringList knownTags = deckPreviewWidget->visualDeckStorageWidget->tagFilterWidget->getAllKnownTags();
|
||||
QStringList activeTags = deckLoader->getDeckList()->getTags();
|
||||
QStringList activeTags = deckList->getTags();
|
||||
|
||||
bool canAddTags = true;
|
||||
|
||||
|
|
@ -148,7 +149,7 @@ void DeckPreviewDeckTagsDisplayWidget::openTagEditDlg()
|
|||
DeckPreviewTagDialog dialog(knownTags, activeTags);
|
||||
if (dialog.exec() == QDialog::Accepted) {
|
||||
QStringList updatedTags = dialog.getActiveTags();
|
||||
deckLoader->getDeckList()->setTags(updatedTags);
|
||||
deckList->setTags(updatedTags);
|
||||
deckPreviewWidget->deckLoader->saveToFile(deckPreviewWidget->filePath, DeckLoader::CockatriceFormat);
|
||||
}
|
||||
}
|
||||
|
|
@ -174,12 +175,12 @@ void DeckPreviewDeckTagsDisplayWidget::openTagEditDlg()
|
|||
knownTags.removeDuplicates();
|
||||
}
|
||||
|
||||
QStringList activeTags = deckLoader->getDeckList()->getTags();
|
||||
QStringList activeTags = deckList->getTags();
|
||||
|
||||
DeckPreviewTagDialog dialog(knownTags, activeTags);
|
||||
if (dialog.exec() == QDialog::Accepted) {
|
||||
QStringList updatedTags = dialog.getActiveTags();
|
||||
deckLoader->getDeckList()->setTags(updatedTags);
|
||||
deckList->setTags(updatedTags);
|
||||
deckEditor->setModified(true);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -20,10 +20,10 @@ class DeckPreviewDeckTagsDisplayWidget : public QWidget
|
|||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit DeckPreviewDeckTagsDisplayWidget(QWidget *_parent, DeckLoader *_deckLoader);
|
||||
void connectDeckList();
|
||||
explicit DeckPreviewDeckTagsDisplayWidget(QWidget *_parent, DeckList *_deckList);
|
||||
void connectDeckList(DeckList *_deckList);
|
||||
void refreshTags();
|
||||
DeckLoader *deckLoader;
|
||||
DeckList *deckList;
|
||||
FlowWidget *flowWidget;
|
||||
|
||||
public slots:
|
||||
|
|
|
|||
|
|
@ -82,7 +82,7 @@ void DeckPreviewWidget::initializeUi(const bool deckLoadSuccess)
|
|||
setFilePath(deckLoader->getLastFileName());
|
||||
|
||||
colorIdentityWidget = new ColorIdentityWidget(this, getColorIdentity());
|
||||
deckTagsDisplayWidget = new DeckPreviewDeckTagsDisplayWidget(this, deckLoader);
|
||||
deckTagsDisplayWidget = new DeckPreviewDeckTagsDisplayWidget(this, deckLoader->getDeckList());
|
||||
|
||||
bannerCardLabel = new QLabel(this);
|
||||
bannerCardLabel->setObjectName("bannerCardLabel");
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue