mirror of
https://github.com/Cockatrice/Cockatrice.git
synced 2026-07-19 00:42:14 -07:00
Address comments.
This commit is contained in:
parent
d53995699e
commit
65bbf9b4ab
5 changed files with 33 additions and 31 deletions
|
|
@ -116,7 +116,7 @@ QChar DeckPreviewColorCircleWidget::getColorChar() const
|
||||||
return colorChar;
|
return colorChar;
|
||||||
}
|
}
|
||||||
|
|
||||||
DeckPreviewColorIdentityWidget::DeckPreviewColorIdentityWidget(const QString &colorIdentity, QWidget *parent)
|
DeckPreviewColorIdentityWidget::DeckPreviewColorIdentityWidget(QWidget *parent, const QString &colorIdentity)
|
||||||
: QWidget(parent)
|
: QWidget(parent)
|
||||||
{
|
{
|
||||||
QHBoxLayout *layout = new QHBoxLayout(this);
|
QHBoxLayout *layout = new QHBoxLayout(this);
|
||||||
|
|
|
||||||
|
|
@ -11,7 +11,7 @@ class DeckPreviewColorCircleWidget : public QWidget
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
explicit DeckPreviewColorCircleWidget(QChar color, QWidget *parent = nullptr);
|
explicit DeckPreviewColorCircleWidget(QChar color, QWidget *parent);
|
||||||
|
|
||||||
void setColorActive(bool active);
|
void setColorActive(bool active);
|
||||||
QChar getColorChar() const;
|
QChar getColorChar() const;
|
||||||
|
|
@ -33,7 +33,7 @@ class DeckPreviewColorIdentityWidget : public QWidget
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
explicit DeckPreviewColorIdentityWidget(const QString &colorIdentity, QWidget *parent = nullptr);
|
explicit DeckPreviewColorIdentityWidget(QWidget *parent, const QString &colorIdentity);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
void resizeEvent(QResizeEvent *event) override;
|
void resizeEvent(QResizeEvent *event) override;
|
||||||
|
|
|
||||||
|
|
@ -31,25 +31,25 @@ DeckPreviewWidget::DeckPreviewWidget(VisualDeckStorageWidget *_parent, const QSt
|
||||||
|
|
||||||
void DeckPreviewWidget::initializeUi(const bool deckLoadSuccess)
|
void DeckPreviewWidget::initializeUi(const bool deckLoadSuccess)
|
||||||
{
|
{
|
||||||
if (deckLoadSuccess) {
|
if (!deckLoadSuccess) {
|
||||||
auto bannerCard = deckLoader->getBannerCard().first.isEmpty()
|
return;
|
||||||
? CardInfoPtr()
|
|
||||||
: CardDatabaseManager::getInstance()->getCardByNameAndProviderId(
|
|
||||||
deckLoader->getBannerCard().first, deckLoader->getBannerCard().second);
|
|
||||||
|
|
||||||
bannerCardDisplayWidget->setCard(bannerCard);
|
|
||||||
bannerCardDisplayWidget->setOverlayText(deckLoader->getName().isEmpty()
|
|
||||||
? QFileInfo(deckLoader->getLastFileName()).fileName()
|
|
||||||
: deckLoader->getName());
|
|
||||||
bannerCardDisplayWidget->setFontSize(24);
|
|
||||||
setFilePath(deckLoader->getLastFileName());
|
|
||||||
|
|
||||||
colorIdentityWidget = new DeckPreviewColorIdentityWidget(getColorIdentity());
|
|
||||||
deckTagsDisplayWidget = new DeckPreviewDeckTagsDisplayWidget(this, deckLoader);
|
|
||||||
|
|
||||||
layout->addWidget(colorIdentityWidget);
|
|
||||||
layout->addWidget(deckTagsDisplayWidget);
|
|
||||||
}
|
}
|
||||||
|
auto bannerCard = deckLoader->getBannerCard().first.isEmpty()
|
||||||
|
? CardInfoPtr()
|
||||||
|
: CardDatabaseManager::getInstance()->getCardByNameAndProviderId(
|
||||||
|
deckLoader->getBannerCard().first, deckLoader->getBannerCard().second);
|
||||||
|
|
||||||
|
bannerCardDisplayWidget->setCard(bannerCard);
|
||||||
|
bannerCardDisplayWidget->setOverlayText(
|
||||||
|
deckLoader->getName().isEmpty() ? QFileInfo(deckLoader->getLastFileName()).fileName() : deckLoader->getName());
|
||||||
|
bannerCardDisplayWidget->setFontSize(24);
|
||||||
|
setFilePath(deckLoader->getLastFileName());
|
||||||
|
|
||||||
|
colorIdentityWidget = new DeckPreviewColorIdentityWidget(this, getColorIdentity());
|
||||||
|
deckTagsDisplayWidget = new DeckPreviewDeckTagsDisplayWidget(this, deckLoader);
|
||||||
|
|
||||||
|
layout->addWidget(colorIdentityWidget);
|
||||||
|
layout->addWidget(deckTagsDisplayWidget);
|
||||||
}
|
}
|
||||||
|
|
||||||
QString DeckPreviewWidget::getColorIdentity()
|
QString DeckPreviewWidget::getColorIdentity()
|
||||||
|
|
|
||||||
|
|
@ -11,10 +11,8 @@
|
||||||
#include <QFutureWatcher>
|
#include <QFutureWatcher>
|
||||||
#include <QRegularExpression>
|
#include <QRegularExpression>
|
||||||
#include <QStringList>
|
#include <QStringList>
|
||||||
#include <qloggingcategory.h>
|
#include <QtConcurrentRun>
|
||||||
#include <qtconcurrentrun.h>
|
|
||||||
|
|
||||||
Q_LOGGING_CATEGORY(DeckLoaderLog, "deck_loader")
|
|
||||||
|
|
||||||
const QStringList DeckLoader::fileNameFilters = QStringList()
|
const QStringList DeckLoader::fileNameFilters = QStringList()
|
||||||
<< QObject::tr("Common deck formats (*.cod *.dec *.dek *.txt *.mwDeck)")
|
<< QObject::tr("Common deck formats (*.cod *.dec *.dek *.txt *.mwDeck)")
|
||||||
|
|
@ -84,7 +82,7 @@ bool DeckLoader::loadFromFile(const QString &fileName, FileFormat fmt, bool user
|
||||||
|
|
||||||
bool DeckLoader::loadFromFileAsync(const QString &fileName, FileFormat fmt, bool userRequest)
|
bool DeckLoader::loadFromFileAsync(const QString &fileName, FileFormat fmt, bool userRequest)
|
||||||
{
|
{
|
||||||
QFutureWatcher<bool> *watcher = new QFutureWatcher<bool>(this);
|
auto *watcher = new QFutureWatcher<bool>(this);
|
||||||
|
|
||||||
connect(watcher, &QFutureWatcher<bool>::finished, this, [this, watcher, fileName, fmt, userRequest]() {
|
connect(watcher, &QFutureWatcher<bool>::finished, this, [this, watcher, fileName, fmt, userRequest]() {
|
||||||
const bool result = watcher->result();
|
const bool result = watcher->result();
|
||||||
|
|
@ -108,23 +106,23 @@ bool DeckLoader::loadFromFileAsync(const QString &fileName, FileFormat fmt, bool
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool result = false;
|
|
||||||
switch (fmt) {
|
switch (fmt) {
|
||||||
case PlainTextFormat:
|
case PlainTextFormat:
|
||||||
result = loadFromFile_Plain(&file);
|
return loadFromFile_Plain(&file);
|
||||||
break;
|
|
||||||
case CockatriceFormat: {
|
case CockatriceFormat: {
|
||||||
|
bool result = false;
|
||||||
result = loadFromFile_Native(&file);
|
result = loadFromFile_Native(&file);
|
||||||
if (!result) {
|
if (!result) {
|
||||||
file.seek(0);
|
file.seek(0);
|
||||||
result = loadFromFile_Plain(&file);
|
return loadFromFile_Plain(&file);
|
||||||
}
|
}
|
||||||
break;
|
return result;
|
||||||
}
|
}
|
||||||
default:
|
default:
|
||||||
|
return false;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
return result;
|
|
||||||
});
|
});
|
||||||
|
|
||||||
watcher->setFuture(future);
|
watcher->setFuture(future);
|
||||||
|
|
|
||||||
|
|
@ -3,6 +3,10 @@
|
||||||
|
|
||||||
#include "decklist.h"
|
#include "decklist.h"
|
||||||
|
|
||||||
|
#include <QLoggingCategory>
|
||||||
|
|
||||||
|
inline Q_LOGGING_CATEGORY(DeckLoaderLog, "deck_loader")
|
||||||
|
|
||||||
class DeckLoader : public DeckList
|
class DeckLoader : public DeckList
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue