From 895f51b6a4ce39173b66d0da4d6520b9bdf7210d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lukas=20Br=C3=BCbach?= Date: Wed, 11 Jun 2025 23:52:10 +0200 Subject: [PATCH] Address comments. --- .../ui/picture_loader/picture_loader.cpp | 2 +- ...e_loader_request_status_display_widget.cpp | 34 +++++++++---------- ...ure_loader_request_status_display_widget.h | 11 +++--- .../picture_loader_status_bar.cpp | 3 ++ 4 files changed, 25 insertions(+), 25 deletions(-) diff --git a/cockatrice/src/client/ui/picture_loader/picture_loader.cpp b/cockatrice/src/client/ui/picture_loader/picture_loader.cpp index 1d6681b63..f0a0113fe 100644 --- a/cockatrice/src/client/ui/picture_loader/picture_loader.cpp +++ b/cockatrice/src/client/ui/picture_loader/picture_loader.cpp @@ -14,9 +14,9 @@ #include #include #include +#include #include #include -#include #include // never cache more than 300 cards at once for a single deck diff --git a/cockatrice/src/client/ui/picture_loader/picture_loader_request_status_display_widget.cpp b/cockatrice/src/client/ui/picture_loader/picture_loader_request_status_display_widget.cpp index a77eac2f4..3647eb71e 100644 --- a/cockatrice/src/client/ui/picture_loader/picture_loader_request_status_display_widget.cpp +++ b/cockatrice/src/client/ui/picture_loader/picture_loader_request_status_display_widget.cpp @@ -7,24 +7,24 @@ PictureLoaderRequestStatusDisplayWidget::PictureLoaderRequestStatusDisplayWidget { layout = new QHBoxLayout(this); - name = new QLabel(this); - name->setText(worker->cardToDownload.getCard()->getName()); - setShortname = new QLabel(this); - setShortname->setText(worker->cardToDownload.getSetName()); - providerId = new QLabel(this); - providerId->setText(worker->cardToDownload.getCard()->getProperty("uuid")); - startTime = new QLabel(this); - startTime->setText(QDateTime::currentDateTime().toString()); - elapsedTime = new QLabel(this); - elapsedTime->setText("0"); - finished = new QLabel(this); - finished->setText("False"); - url = new QLabel(this); - url->setText(_url.toString()); + if (worker->cardToDownload.getCard()) { + name = new QLabel(this); + name->setText(worker->cardToDownload.getCard()->getName()); + setShortname = new QLabel(this); + setShortname->setText(worker->cardToDownload.getSetName()); + providerId = new QLabel(this); + providerId->setText(worker->cardToDownload.getCard()->getProperty("uuid")); + + layout->addWidget(name); + layout->addWidget(setShortname); + layout->addWidget(providerId); + } + + startTime = new QLabel(QDateTime::currentDateTime().toString(), this); + elapsedTime = new QLabel("0", this); + finished = new QLabel("False", this); + url = new QLabel(_url.toString(), this); - layout->addWidget(name); - layout->addWidget(setShortname); - layout->addWidget(providerId); layout->addWidget(startTime); layout->addWidget(elapsedTime); layout->addWidget(finished); diff --git a/cockatrice/src/client/ui/picture_loader/picture_loader_request_status_display_widget.h b/cockatrice/src/client/ui/picture_loader/picture_loader_request_status_display_widget.h index 20c77ee56..e78ea05ad 100644 --- a/cockatrice/src/client/ui/picture_loader/picture_loader_request_status_display_widget.h +++ b/cockatrice/src/client/ui/picture_loader/picture_loader_request_status_display_widget.h @@ -1,15 +1,11 @@ #ifndef PICTURE_LOADER_REQUEST_STATUS_DISPLAY_WIDGET_H #define PICTURE_LOADER_REQUEST_STATUS_DISPLAY_WIDGET_H -#include "../../../../../../../../../../mnt/games-hdd/coding/CLionProjects/Cockatrice/cockatrice/src/client/ui/picture_loader/picture_loader_worker_work.h" +#include "picture_loader_worker_work.h" #include #include #include -struct PictureLoaderRequestStatus -{ -}; - class PictureLoaderRequestStatusDisplayWidget : public QWidget { Q_OBJECT @@ -37,11 +33,12 @@ public: int queryElapsedSeconds() { if (!finished) { + int elapsedTime = QDateTime::fromString(startTime->text()).secsTo(QDateTime::currentDateTime()); elapsedTime->setText( - QString::number(QDateTime::fromString(startTime->text()).secsTo(QDateTime::currentDateTime()))); + QString::number(elapsedTime)); update(); repaint(); - return QDateTime::fromString(startTime->text()).secsTo(QDateTime::currentDateTime()); + return elapsedTime; } return elapsedTime->text().toInt(); } diff --git a/cockatrice/src/client/ui/picture_loader/picture_loader_status_bar.cpp b/cockatrice/src/client/ui/picture_loader/picture_loader_status_bar.cpp index 7cd214e93..d206315ca 100644 --- a/cockatrice/src/client/ui/picture_loader/picture_loader_status_bar.cpp +++ b/cockatrice/src/client/ui/picture_loader/picture_loader_status_bar.cpp @@ -23,6 +23,9 @@ PictureLoaderStatusBar::PictureLoaderStatusBar(QWidget *parent) : QWidget(parent void PictureLoaderStatusBar::cleanOldEntries() { + if (!loadLog || !loadLog->popup) { + return; + } for (PictureLoaderRequestStatusDisplayWidget *statusDisplayWidget : loadLog->popup->findChildren()) { statusDisplayWidget->queryElapsedSeconds();