mirror of
https://github.com/Cockatrice/Cockatrice.git
synced 2026-07-20 01:12: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);
|
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:
|
public:
|
||||||
FlowWidget(QWidget *parent, Qt::ScrollBarPolicy horizontalPolicy, Qt::ScrollBarPolicy verticalPolicy);
|
FlowWidget(QWidget *parent, Qt::ScrollBarPolicy horizontalPolicy, Qt::ScrollBarPolicy verticalPolicy);
|
||||||
void addWidget(QWidget *widget_to_add) const;
|
void addWidget(QWidget *widget_to_add) const;
|
||||||
void removeWidget(QWidget *widget_to_remove) const;
|
void removeWidget(QWidget *widgetToRemove) const;
|
||||||
void clearLayout();
|
void clearLayout();
|
||||||
[[nodiscard]] int count() const;
|
[[nodiscard]] int count() const;
|
||||||
[[nodiscard]] QLayoutItem *itemAt(int index) const;
|
[[nodiscard]] QLayoutItem *itemAt(int index) const;
|
||||||
|
|
|
||||||
|
|
@ -26,6 +26,6 @@ DeckPreviewDeckTagsDisplayWidget::DeckPreviewDeckTagsDisplayWidget(DeckPreviewWi
|
||||||
for (const QString &tag : this->deckLoader->getTags()) {
|
for (const QString &tag : this->deckLoader->getTags()) {
|
||||||
flowWidget->addWidget(new DeckPreviewTagDisplayWidget(this, tag));
|
flowWidget->addWidget(new DeckPreviewTagDisplayWidget(this, tag));
|
||||||
}
|
}
|
||||||
flowWidget->addWidget(new DeckPreviewTagAdditionWidget(this, "Add tags ..."));
|
flowWidget->addWidget(new DeckPreviewTagAdditionWidget(this, tr("Add tags ...")));
|
||||||
layout->addWidget(flowWidget);
|
layout->addWidget(flowWidget);
|
||||||
}
|
}
|
||||||
|
|
@ -61,24 +61,39 @@ DeckPreviewTagDialog::DeckPreviewTagDialog(const QStringList &knownTags, const Q
|
||||||
"🌏 Land",
|
"🌏 Land",
|
||||||
"🪄 Aura",
|
"🪄 Aura",
|
||||||
|
|
||||||
// Tribal Types
|
// Kindred Types
|
||||||
"🐉 Tribal",
|
"🐉 Kindred", // Kindred
|
||||||
"🐠 Merfolk",
|
"🐠 Merfolk", // Merfolk
|
||||||
"🐺 Werewolves",
|
"🐺 Werewolves", // Werewolves
|
||||||
"🦴 Skeletons",
|
"🦴 Skeletons", // Skeletons
|
||||||
"🦅 Flying",
|
"🦅 Birds", // Birds
|
||||||
"👾 Eldrazi",
|
"👾 Eldrazi", // Eldrazi
|
||||||
"🧛 Vampires",
|
"🐉 Dragons", // Dragons
|
||||||
"🦇 Bats",
|
"🧛 Vampires", // Vampires
|
||||||
"🐺 Wolves",
|
"🦇 Bats", // Bats
|
||||||
"🐉 Dragons",
|
"🐺 Wolves", // Wolves
|
||||||
"🍄 Fungus",
|
"🍄 Fungus", // Fungus
|
||||||
"🦗 Insects",
|
"🦗 Insects", // Insects
|
||||||
"🦅 Birds",
|
"🐚 Sea Creatures", // Octopus, Leviathan, etc.
|
||||||
"🐚 Sea Creatures",
|
"🎩 Wizards", // Wizards
|
||||||
"🎩 Wizards",
|
"🎻 Bards", // 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
|
// Merge knownTags with defaultTags, ensuring no duplicates
|
||||||
|
|
@ -89,8 +104,7 @@ DeckPreviewTagDialog::DeckPreviewTagDialog(const QStringList &knownTags, const Q
|
||||||
auto *mainLayout = new QVBoxLayout(this);
|
auto *mainLayout = new QVBoxLayout(this);
|
||||||
|
|
||||||
// Instruction label
|
// Instruction label
|
||||||
auto *instructionLabel =
|
instructionLabel = new QLabel(this);
|
||||||
new QLabel("Manage your deck tags. Check or uncheck tags as needed, or add new ones:", this);
|
|
||||||
instructionLabel->setWordWrap(true);
|
instructionLabel->setWordWrap(true);
|
||||||
mainLayout->addWidget(instructionLabel);
|
mainLayout->addWidget(instructionLabel);
|
||||||
|
|
||||||
|
|
@ -111,8 +125,7 @@ DeckPreviewTagDialog::DeckPreviewTagDialog(const QStringList &knownTags, const Q
|
||||||
// Add tag input layout
|
// Add tag input layout
|
||||||
auto *addTagLayout = new QHBoxLayout();
|
auto *addTagLayout = new QHBoxLayout();
|
||||||
newTagInput_ = new QLineEdit(this);
|
newTagInput_ = new QLineEdit(this);
|
||||||
newTagInput_->setPlaceholderText("Add a new tag (e.g., Aggro️)");
|
addTagButton_ = new QPushButton(this);
|
||||||
addTagButton_ = new QPushButton("Add Tag", this);
|
|
||||||
addTagLayout->addWidget(newTagInput_);
|
addTagLayout->addWidget(newTagInput_);
|
||||||
addTagLayout->addWidget(addTagButton_);
|
addTagLayout->addWidget(addTagButton_);
|
||||||
mainLayout->addLayout(addTagLayout);
|
mainLayout->addLayout(addTagLayout);
|
||||||
|
|
@ -121,8 +134,8 @@ DeckPreviewTagDialog::DeckPreviewTagDialog(const QStringList &knownTags, const Q
|
||||||
|
|
||||||
// OK and Cancel buttons
|
// OK and Cancel buttons
|
||||||
auto *buttonLayout = new QHBoxLayout();
|
auto *buttonLayout = new QHBoxLayout();
|
||||||
auto *okButton = new QPushButton("OK", this);
|
okButton = new QPushButton(this);
|
||||||
auto *cancelButton = new QPushButton("Cancel", this);
|
cancelButton = new QPushButton(this);
|
||||||
buttonLayout->addStretch();
|
buttonLayout->addStretch();
|
||||||
buttonLayout->addWidget(okButton);
|
buttonLayout->addWidget(okButton);
|
||||||
buttonLayout->addWidget(cancelButton);
|
buttonLayout->addWidget(cancelButton);
|
||||||
|
|
@ -130,6 +143,16 @@ DeckPreviewTagDialog::DeckPreviewTagDialog(const QStringList &knownTags, const Q
|
||||||
|
|
||||||
connect(okButton, &QPushButton::clicked, this, &DeckPreviewTagDialog::accept);
|
connect(okButton, &QPushButton::clicked, this, &DeckPreviewTagDialog::accept);
|
||||||
connect(cancelButton, &QPushButton::clicked, this, &DeckPreviewTagDialog::reject);
|
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
|
QStringList DeckPreviewTagDialog::getActiveTags() const
|
||||||
|
|
@ -141,7 +164,7 @@ void DeckPreviewTagDialog::addTag()
|
||||||
{
|
{
|
||||||
QString newTag = newTagInput_->text().trimmed();
|
QString newTag = newTagInput_->text().trimmed();
|
||||||
if (newTag.isEmpty()) {
|
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;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -150,7 +173,7 @@ void DeckPreviewTagDialog::addTag()
|
||||||
auto *item = tagListView_->item(i);
|
auto *item = tagListView_->item(i);
|
||||||
auto *tagWidget = qobject_cast<DeckPreviewTagItemWidget *>(tagListView_->itemWidget(item));
|
auto *tagWidget = qobject_cast<DeckPreviewTagItemWidget *>(tagListView_->itemWidget(item));
|
||||||
if (tagWidget && tagWidget->checkBox()->text() == newTag) {
|
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;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -3,6 +3,7 @@
|
||||||
|
|
||||||
#include <QCheckBox>
|
#include <QCheckBox>
|
||||||
#include <QDialog>
|
#include <QDialog>
|
||||||
|
#include <QLabel>
|
||||||
#include <QLineEdit>
|
#include <QLineEdit>
|
||||||
#include <QListWidget>
|
#include <QListWidget>
|
||||||
#include <QPushButton>
|
#include <QPushButton>
|
||||||
|
|
@ -21,11 +22,15 @@ public:
|
||||||
private slots:
|
private slots:
|
||||||
void addTag();
|
void addTag();
|
||||||
void onCheckboxStateChanged();
|
void onCheckboxStateChanged();
|
||||||
|
void retranslateUi();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
QLabel *instructionLabel;
|
||||||
QListWidget *tagListView_;
|
QListWidget *tagListView_;
|
||||||
QLineEdit *newTagInput_;
|
QLineEdit *newTagInput_;
|
||||||
QPushButton *addTagButton_;
|
QPushButton *addTagButton_;
|
||||||
|
QPushButton *okButton;
|
||||||
|
QPushButton *cancelButton;
|
||||||
QStringList activeTags_;
|
QStringList activeTags_;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -48,7 +48,7 @@ QString DeckPreviewWidget::getColorIdentity()
|
||||||
{
|
{
|
||||||
QStringList cardList = deckLoader->getCardList();
|
QStringList cardList = deckLoader->getCardList();
|
||||||
if (cardList.isEmpty()) {
|
if (cardList.isEmpty()) {
|
||||||
return "";
|
return {};
|
||||||
}
|
}
|
||||||
|
|
||||||
QSet<QChar> colorSet; // A set to collect unique color symbols (e.g., W, U, B, R, G)
|
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);
|
QFileInfo fileInfo(fileName);
|
||||||
if (!fileInfo.exists()) {
|
if (!fileInfo.exists()) {
|
||||||
qWarning() << "File does not exist:" << fileName;
|
qCWarning(DeckLoaderLog) << "File does not exist:" << fileName;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -130,7 +130,7 @@ bool DeckLoader::updateLastLoadedTimestamp(const QString &fileName, FileFormat f
|
||||||
// Open the file for writing
|
// Open the file for writing
|
||||||
QFile file(fileName);
|
QFile file(fileName);
|
||||||
if (!file.open(QIODevice::WriteOnly | QIODevice::Text)) {
|
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;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -154,12 +154,12 @@ bool DeckLoader::updateLastLoadedTimestamp(const QString &fileName, FileFormat f
|
||||||
|
|
||||||
// Re-open the file and set the original timestamp
|
// Re-open the file and set the original timestamp
|
||||||
if (!file.open(QIODevice::ReadWrite)) {
|
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;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!file.setFileTime(originalTimestamp, QFileDevice::FileModificationTime)) {
|
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();
|
file.close();
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -265,7 +265,7 @@ SettingsCache::SettingsCache()
|
||||||
visualDeckStorageDrawUnusedColorIdentities =
|
visualDeckStorageDrawUnusedColorIdentities =
|
||||||
settings->value("interface/visualdeckstoragedrawunusedcoloridentities", true).toBool();
|
settings->value("interface/visualdeckstoragedrawunusedcoloridentities", true).toBool();
|
||||||
visualDeckStorageUnusedColorIdentitiesOpacity =
|
visualDeckStorageUnusedColorIdentitiesOpacity =
|
||||||
settings->value("interface/visualdeckstorageunusedcoloridentitiesopacity", 30).toInt();
|
settings->value("interface/visualdeckstorageunusedcoloridentitiesopacity", 15).toInt();
|
||||||
horizontalHand = settings->value("hand/horizontal", true).toBool();
|
horizontalHand = settings->value("hand/horizontal", true).toBool();
|
||||||
invertVerticalCoordinate = settings->value("table/invert_vertical", false).toBool();
|
invertVerticalCoordinate = settings->value("table/invert_vertical", false).toBool();
|
||||||
minPlayersForMultiColumnLayout = settings->value("interface/min_players_multicolumn", 4).toInt();
|
minPlayersForMultiColumnLayout = settings->value("interface/min_players_multicolumn", 4).toInt();
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue