removed Order, resolved a crash on several files being uploaded simultaniuosly

This commit is contained in:
Blue 2023-11-09 19:36:30 -03:00
parent 0a530bfa93
commit be466fbad1
Signed by untrusted user: blue
GPG key ID: 9B203B252A63EE38
12 changed files with 122 additions and 304 deletions

View file

@ -18,6 +18,8 @@
#include "badge.h"
#include "shared/utils.h"
Badge::Badge(const QString& p_id, const QString& p_text, const QIcon& icon, QWidget* parent):
QFrame(parent),
id(p_id),
@ -48,8 +50,7 @@ Badge::Badge(QWidget* parent):
layout->addWidget(closeButton);
}
void Badge::setIcon(const QIcon& icon)
{
void Badge::setIcon(const QIcon& icon) {
if (image == nullptr) {
image = new QLabel();
image->setPixmap(icon.pixmap(25, 25));
@ -59,8 +60,7 @@ void Badge::setIcon(const QIcon& icon)
}
}
void Badge::setText(const QString& p_text)
{
void Badge::setText(const QString& p_text) {
if (text == nullptr) {
text = new QLabel(p_text);
int index = 0;
@ -73,42 +73,30 @@ void Badge::setText(const QString& p_text)
}
}
Badge::~Badge()
{
if (image != nullptr) {
Badge::~Badge() {
if (image != nullptr)
delete image;
}
if (text != nullptr) {
if (text != nullptr)
delete text;
}
delete closeButton;
}
bool Badge::Comparator::operator()(const Badge* a, const Badge* b) const
{
return a->id < b->id;
}
bool Badge::Comparator::operator()(const Badge& a, const Badge& b) const
{
return a.id < b.id;
}
void Badge::createMandatoryComponents()
{
void Badge::createMandatoryComponents() {
setBackgroundRole(QPalette::Base);
//setAutoFillBackground(true);
setFrameStyle(QFrame::StyledPanel);
setFrameShadow(QFrame::Raised);
QIcon tabCloseIcon = QIcon::fromTheme("tab-close");
if (tabCloseIcon.isNull()) {
if (tabCloseIcon.isNull())
tabCloseIcon.addFile(QString::fromUtf8(":/images/fallback/dark/big/edit-none.svg"), QSize(), QIcon::Normal, QIcon::Off);
}
closeButton->setIcon(tabCloseIcon);
closeButton->setMaximumHeight(25);
closeButton->setMaximumWidth(25);
layout->setContentsMargins(2, 2, 2, 2);
connect(closeButton, &QPushButton::clicked, this, &Badge::close);
connect(closeButton, &QPushButton::clicked, this, &Badge::closeClicked);
}