mirror of
https://github.com/Cockatrice/Cockatrice.git
synced 2026-07-18 16:32:16 -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;
|
||||
}
|
||||
|
||||
DeckPreviewColorIdentityWidget::DeckPreviewColorIdentityWidget(const QString &colorIdentity, QWidget *parent)
|
||||
DeckPreviewColorIdentityWidget::DeckPreviewColorIdentityWidget(QWidget *parent, const QString &colorIdentity)
|
||||
: QWidget(parent)
|
||||
{
|
||||
QHBoxLayout *layout = new QHBoxLayout(this);
|
||||
|
|
|
|||
|
|
@ -11,7 +11,7 @@ class DeckPreviewColorCircleWidget : public QWidget
|
|||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit DeckPreviewColorCircleWidget(QChar color, QWidget *parent = nullptr);
|
||||
explicit DeckPreviewColorCircleWidget(QChar color, QWidget *parent);
|
||||
|
||||
void setColorActive(bool active);
|
||||
QChar getColorChar() const;
|
||||
|
|
@ -33,7 +33,7 @@ class DeckPreviewColorIdentityWidget : public QWidget
|
|||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit DeckPreviewColorIdentityWidget(const QString &colorIdentity, QWidget *parent = nullptr);
|
||||
explicit DeckPreviewColorIdentityWidget(QWidget *parent, const QString &colorIdentity);
|
||||
|
||||
protected:
|
||||
void resizeEvent(QResizeEvent *event) override;
|
||||
|
|
|
|||
|
|
@ -31,25 +31,25 @@ DeckPreviewWidget::DeckPreviewWidget(VisualDeckStorageWidget *_parent, const QSt
|
|||
|
||||
void DeckPreviewWidget::initializeUi(const bool deckLoadSuccess)
|
||||
{
|
||||
if (deckLoadSuccess) {
|
||||
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(getColorIdentity());
|
||||
deckTagsDisplayWidget = new DeckPreviewDeckTagsDisplayWidget(this, deckLoader);
|
||||
|
||||
layout->addWidget(colorIdentityWidget);
|
||||
layout->addWidget(deckTagsDisplayWidget);
|
||||
if (!deckLoadSuccess) {
|
||||
return;
|
||||
}
|
||||
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()
|
||||
|
|
|
|||
|
|
@ -11,10 +11,8 @@
|
|||
#include <QFutureWatcher>
|
||||
#include <QRegularExpression>
|
||||
#include <QStringList>
|
||||
#include <qloggingcategory.h>
|
||||
#include <qtconcurrentrun.h>
|
||||
#include <QtConcurrentRun>
|
||||
|
||||
Q_LOGGING_CATEGORY(DeckLoaderLog, "deck_loader")
|
||||
|
||||
const QStringList DeckLoader::fileNameFilters = QStringList()
|
||||
<< 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)
|
||||
{
|
||||
QFutureWatcher<bool> *watcher = new QFutureWatcher<bool>(this);
|
||||
auto *watcher = new QFutureWatcher<bool>(this);
|
||||
|
||||
connect(watcher, &QFutureWatcher<bool>::finished, this, [this, watcher, fileName, fmt, userRequest]() {
|
||||
const bool result = watcher->result();
|
||||
|
|
@ -108,23 +106,23 @@ bool DeckLoader::loadFromFileAsync(const QString &fileName, FileFormat fmt, bool
|
|||
return false;
|
||||
}
|
||||
|
||||
bool result = false;
|
||||
|
||||
switch (fmt) {
|
||||
case PlainTextFormat:
|
||||
result = loadFromFile_Plain(&file);
|
||||
break;
|
||||
return loadFromFile_Plain(&file);
|
||||
case CockatriceFormat: {
|
||||
bool result = false;
|
||||
result = loadFromFile_Native(&file);
|
||||
if (!result) {
|
||||
file.seek(0);
|
||||
result = loadFromFile_Plain(&file);
|
||||
return loadFromFile_Plain(&file);
|
||||
}
|
||||
break;
|
||||
return result;
|
||||
}
|
||||
default:
|
||||
return false;
|
||||
break;
|
||||
}
|
||||
return result;
|
||||
});
|
||||
|
||||
watcher->setFuture(future);
|
||||
|
|
|
|||
|
|
@ -3,6 +3,10 @@
|
|||
|
||||
#include "decklist.h"
|
||||
|
||||
#include <QLoggingCategory>
|
||||
|
||||
inline Q_LOGGING_CATEGORY(DeckLoaderLog, "deck_loader")
|
||||
|
||||
class DeckLoader : public DeckList
|
||||
{
|
||||
Q_OBJECT
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue