mirror of
https://github.com/Cockatrice/Cockatrice.git
synced 2026-07-19 08:52:15 -07:00
Address comments.
This commit is contained in:
parent
438df92ab5
commit
6a3dc43c8e
8 changed files with 64 additions and 36 deletions
|
|
@ -87,9 +87,9 @@ void FlowWidget::addWidget(QWidget *widget_to_add) const
|
|||
flowLayout->addWidget(widget_to_add);
|
||||
}
|
||||
|
||||
void FlowWidget::removeWidget(QWidget *widget_to_remove) const
|
||||
void FlowWidget::removeWidget(QWidget *widgetToRemove) const
|
||||
{
|
||||
flowLayout->removeWidget(widget_to_remove);
|
||||
flowLayout->removeWidget(widgetToRemove);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -13,7 +13,7 @@ class FlowWidget final : public QWidget
|
|||
public:
|
||||
FlowWidget(QWidget *parent, Qt::ScrollBarPolicy horizontalPolicy, Qt::ScrollBarPolicy verticalPolicy);
|
||||
void addWidget(QWidget *widget_to_add) const;
|
||||
void removeWidget(QWidget *widget_to_remove) const;
|
||||
void removeWidget(QWidget *widgetToRemove) const;
|
||||
void clearLayout();
|
||||
[[nodiscard]] int count() const;
|
||||
[[nodiscard]] QLayoutItem *itemAt(int index) const;
|
||||
|
|
|
|||
|
|
@ -26,6 +26,6 @@ DeckPreviewDeckTagsDisplayWidget::DeckPreviewDeckTagsDisplayWidget(DeckPreviewWi
|
|||
for (const QString &tag : this->deckLoader->getTags()) {
|
||||
flowWidget->addWidget(new DeckPreviewTagDisplayWidget(this, tag));
|
||||
}
|
||||
flowWidget->addWidget(new DeckPreviewTagAdditionWidget(this, "Add tags ..."));
|
||||
flowWidget->addWidget(new DeckPreviewTagAdditionWidget(this, tr("Add tags ...")));
|
||||
layout->addWidget(flowWidget);
|
||||
}
|
||||
|
|
@ -61,24 +61,39 @@ DeckPreviewTagDialog::DeckPreviewTagDialog(const QStringList &knownTags, const Q
|
|||
"🌏 Land",
|
||||
"🪄 Aura",
|
||||
|
||||
// Tribal Types
|
||||
"🐉 Tribal",
|
||||
"🐠 Merfolk",
|
||||
"🐺 Werewolves",
|
||||
"🦴 Skeletons",
|
||||
"🦅 Flying",
|
||||
"👾 Eldrazi",
|
||||
"🧛 Vampires",
|
||||
"🦇 Bats",
|
||||
"🐺 Wolves",
|
||||
"🐉 Dragons",
|
||||
"🍄 Fungus",
|
||||
"🦗 Insects",
|
||||
"🦅 Birds",
|
||||
"🐚 Sea Creatures",
|
||||
"🎩 Wizards",
|
||||
"🎻 Bards",
|
||||
|
||||
// Kindred Types
|
||||
"🐉 Kindred", // Kindred
|
||||
"🐠 Merfolk", // Merfolk
|
||||
"🐺 Werewolves", // Werewolves
|
||||
"🦴 Skeletons", // Skeletons
|
||||
"🦅 Birds", // Birds
|
||||
"👾 Eldrazi", // Eldrazi
|
||||
"🐉 Dragons", // Dragons
|
||||
"🧛 Vampires", // Vampires
|
||||
"🦇 Bats", // Bats
|
||||
"🐺 Wolves", // Wolves
|
||||
"🍄 Fungus", // Fungus
|
||||
"🦗 Insects", // Insects
|
||||
"🐚 Sea Creatures", // Octopus, Leviathan, etc.
|
||||
"🎩 Wizards", // Wizards
|
||||
"🎻 Bards", // Bards
|
||||
"😇 Angels", // Angels
|
||||
"⚔️ Soldiers", // Soldiers
|
||||
"🛡️ Knights", // Knights
|
||||
"🧙 Humans", // Humans
|
||||
"🧝 Elves", // Elves
|
||||
"💀 Zombies", // Zombies
|
||||
"👹 Demons", // Demons
|
||||
"🌲 Dryads", // Dryads
|
||||
"🐗 Boars", // Boars
|
||||
"🦁 Cats", // Cats
|
||||
"🦊 Foxes", // Foxes
|
||||
"🐀 Rats", // Rats
|
||||
"🦄 Unicorns", // Unicorns
|
||||
"🐘 Elephants", // Elephants
|
||||
"🐻 Bears", // Bears
|
||||
"🦏 Rhinos", // Rhinos
|
||||
"🦂 Scorpions", // Scorpions
|
||||
};
|
||||
|
||||
// Merge knownTags with defaultTags, ensuring no duplicates
|
||||
|
|
@ -89,8 +104,7 @@ DeckPreviewTagDialog::DeckPreviewTagDialog(const QStringList &knownTags, const Q
|
|||
auto *mainLayout = new QVBoxLayout(this);
|
||||
|
||||
// Instruction label
|
||||
auto *instructionLabel =
|
||||
new QLabel("Manage your deck tags. Check or uncheck tags as needed, or add new ones:", this);
|
||||
instructionLabel = new QLabel(this);
|
||||
instructionLabel->setWordWrap(true);
|
||||
mainLayout->addWidget(instructionLabel);
|
||||
|
||||
|
|
@ -111,8 +125,7 @@ DeckPreviewTagDialog::DeckPreviewTagDialog(const QStringList &knownTags, const Q
|
|||
// Add tag input layout
|
||||
auto *addTagLayout = new QHBoxLayout();
|
||||
newTagInput_ = new QLineEdit(this);
|
||||
newTagInput_->setPlaceholderText("Add a new tag (e.g., Aggro️)");
|
||||
addTagButton_ = new QPushButton("Add Tag", this);
|
||||
addTagButton_ = new QPushButton(this);
|
||||
addTagLayout->addWidget(newTagInput_);
|
||||
addTagLayout->addWidget(addTagButton_);
|
||||
mainLayout->addLayout(addTagLayout);
|
||||
|
|
@ -121,8 +134,8 @@ DeckPreviewTagDialog::DeckPreviewTagDialog(const QStringList &knownTags, const Q
|
|||
|
||||
// OK and Cancel buttons
|
||||
auto *buttonLayout = new QHBoxLayout();
|
||||
auto *okButton = new QPushButton("OK", this);
|
||||
auto *cancelButton = new QPushButton("Cancel", this);
|
||||
okButton = new QPushButton(this);
|
||||
cancelButton = new QPushButton(this);
|
||||
buttonLayout->addStretch();
|
||||
buttonLayout->addWidget(okButton);
|
||||
buttonLayout->addWidget(cancelButton);
|
||||
|
|
@ -130,6 +143,16 @@ DeckPreviewTagDialog::DeckPreviewTagDialog(const QStringList &knownTags, const Q
|
|||
|
||||
connect(okButton, &QPushButton::clicked, this, &DeckPreviewTagDialog::accept);
|
||||
connect(cancelButton, &QPushButton::clicked, this, &DeckPreviewTagDialog::reject);
|
||||
retranslateUi();
|
||||
}
|
||||
|
||||
void DeckPreviewTagDialog::retranslateUi()
|
||||
{
|
||||
instructionLabel->setText(tr("Manage your deck tags. Check or uncheck tags as needed, or add new ones:"));
|
||||
newTagInput_->setPlaceholderText(tr("Add a new tag (e.g., Aggro️)"));
|
||||
addTagButton_->setText(tr("Add Tag"));
|
||||
okButton->setText(tr("OK"));
|
||||
cancelButton->setText(tr("Cancel"));
|
||||
}
|
||||
|
||||
QStringList DeckPreviewTagDialog::getActiveTags() const
|
||||
|
|
@ -141,7 +164,7 @@ void DeckPreviewTagDialog::addTag()
|
|||
{
|
||||
QString newTag = newTagInput_->text().trimmed();
|
||||
if (newTag.isEmpty()) {
|
||||
QMessageBox::warning(this, "Invalid Input", "Tag name cannot be empty!");
|
||||
QMessageBox::warning(this, tr("Invalid Input"), tr("Tag name cannot be empty!"));
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
@ -150,7 +173,7 @@ void DeckPreviewTagDialog::addTag()
|
|||
auto *item = tagListView_->item(i);
|
||||
auto *tagWidget = qobject_cast<DeckPreviewTagItemWidget *>(tagListView_->itemWidget(item));
|
||||
if (tagWidget && tagWidget->checkBox()->text() == newTag) {
|
||||
QMessageBox::warning(this, "Duplicate Tag", "This tag already exists.");
|
||||
QMessageBox::warning(this, tr("Duplicate Tag"), tr("This tag already exists."));
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -3,6 +3,7 @@
|
|||
|
||||
#include <QCheckBox>
|
||||
#include <QDialog>
|
||||
#include <QLabel>
|
||||
#include <QLineEdit>
|
||||
#include <QListWidget>
|
||||
#include <QPushButton>
|
||||
|
|
@ -21,11 +22,15 @@ public:
|
|||
private slots:
|
||||
void addTag();
|
||||
void onCheckboxStateChanged();
|
||||
void retranslateUi();
|
||||
|
||||
private:
|
||||
QLabel *instructionLabel;
|
||||
QListWidget *tagListView_;
|
||||
QLineEdit *newTagInput_;
|
||||
QPushButton *addTagButton_;
|
||||
QPushButton *okButton;
|
||||
QPushButton *cancelButton;
|
||||
QStringList activeTags_;
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -48,7 +48,7 @@ QString DeckPreviewWidget::getColorIdentity()
|
|||
{
|
||||
QStringList cardList = deckLoader->getCardList();
|
||||
if (cardList.isEmpty()) {
|
||||
return "";
|
||||
return {};
|
||||
}
|
||||
|
||||
QSet<QChar> colorSet; // A set to collect unique color symbols (e.g., W, U, B, R, G)
|
||||
|
|
|
|||
|
|
@ -121,7 +121,7 @@ bool DeckLoader::updateLastLoadedTimestamp(const QString &fileName, FileFormat f
|
|||
{
|
||||
QFileInfo fileInfo(fileName);
|
||||
if (!fileInfo.exists()) {
|
||||
qWarning() << "File does not exist:" << fileName;
|
||||
qCWarning(DeckLoaderLog) << "File does not exist:" << fileName;
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
@ -130,7 +130,7 @@ bool DeckLoader::updateLastLoadedTimestamp(const QString &fileName, FileFormat f
|
|||
// Open the file for writing
|
||||
QFile file(fileName);
|
||||
if (!file.open(QIODevice::WriteOnly | QIODevice::Text)) {
|
||||
qWarning() << "Failed to open file for writing:" << fileName;
|
||||
qCWarning(DeckLoaderLog) << "Failed to open file for writing:" << fileName;
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
@ -154,12 +154,12 @@ bool DeckLoader::updateLastLoadedTimestamp(const QString &fileName, FileFormat f
|
|||
|
||||
// Re-open the file and set the original timestamp
|
||||
if (!file.open(QIODevice::ReadWrite)) {
|
||||
qWarning() << "Failed to re-open file to set timestamp:" << fileName;
|
||||
qCWarning(DeckLoaderLog) << "Failed to re-open file to set timestamp:" << fileName;
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!file.setFileTime(originalTimestamp, QFileDevice::FileModificationTime)) {
|
||||
qWarning() << "Failed to set modification time for file:" << fileName;
|
||||
qCWarning(DeckLoaderLog) << "Failed to set modification time for file:" << fileName;
|
||||
file.close();
|
||||
return false;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -265,7 +265,7 @@ SettingsCache::SettingsCache()
|
|||
visualDeckStorageDrawUnusedColorIdentities =
|
||||
settings->value("interface/visualdeckstoragedrawunusedcoloridentities", true).toBool();
|
||||
visualDeckStorageUnusedColorIdentitiesOpacity =
|
||||
settings->value("interface/visualdeckstorageunusedcoloridentitiesopacity", 30).toInt();
|
||||
settings->value("interface/visualdeckstorageunusedcoloridentitiesopacity", 15).toInt();
|
||||
horizontalHand = settings->value("hand/horizontal", true).toBool();
|
||||
invertVerticalCoordinate = settings->value("table/invert_vertical", false).toBool();
|
||||
minPlayersForMultiColumnLayout = settings->value("interface/min_players_multicolumn", 4).toInt();
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue