forked from blue/squawk
removed Order, resolved a crash on several files being uploaded simultaniuosly
This commit is contained in:
parent
0a530bfa93
commit
be466fbad1
12 changed files with 122 additions and 304 deletions
|
@ -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);
|
||||
}
|
||||
|
|
|
@ -16,8 +16,7 @@
|
|||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#ifndef BADGE_H
|
||||
#define BADGE_H
|
||||
#pragma once
|
||||
|
||||
#include <QFrame>
|
||||
#include <QLabel>
|
||||
|
@ -25,13 +24,7 @@
|
|||
#include <QIcon>
|
||||
#include <QPushButton>
|
||||
|
||||
#include "shared/utils.h"
|
||||
|
||||
/**
|
||||
* @todo write docs
|
||||
*/
|
||||
class Badge : public QFrame
|
||||
{
|
||||
class Badge : public QFrame {
|
||||
Q_OBJECT
|
||||
public:
|
||||
Badge(const QString& id, const QString& text, const QIcon& icon, QWidget* parent = nullptr);
|
||||
|
@ -45,7 +38,7 @@ public:
|
|||
void setIcon(const QIcon& icon);
|
||||
|
||||
signals:
|
||||
void close();
|
||||
void closeClicked();
|
||||
|
||||
private:
|
||||
QLabel* image;
|
||||
|
@ -55,12 +48,5 @@ private:
|
|||
|
||||
private:
|
||||
void createMandatoryComponents();
|
||||
|
||||
public:
|
||||
struct Comparator {
|
||||
bool operator()(const Badge& a, const Badge& b) const;
|
||||
bool operator()(const Badge* a, const Badge* b) const;
|
||||
};
|
||||
};
|
||||
|
||||
#endif // BADGE_H
|
||||
};
|
||||
|
|
|
@ -16,8 +16,7 @@
|
|||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#ifndef FLOWLAYOUT_H
|
||||
#define FLOWLAYOUT_H
|
||||
#pragma once
|
||||
|
||||
#include <QLayout>
|
||||
#include <QWidget>
|
||||
|
@ -26,8 +25,7 @@
|
|||
/**
|
||||
* @todo write docs
|
||||
*/
|
||||
class FlowLayout : public QLayout
|
||||
{
|
||||
class FlowLayout : public QLayout {
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit FlowLayout(QWidget *parent, int margin = -1, int hSpacing = -1, int vSpacing = -1);
|
||||
|
@ -55,5 +53,3 @@ private:
|
|||
int m_hSpace;
|
||||
int m_vSpace;
|
||||
};
|
||||
|
||||
#endif // FLOWLAYOUT_H
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue