removed unused old message line files, first thoughts on message edition

This commit is contained in:
Blue 2022-02-20 22:10:09 +03:00
parent 73b1b58a96
commit 0823b35148
Signed by untrusted user: blue
GPG key ID: 9B203B252A63EE38
11 changed files with 121 additions and 1083 deletions

View file

@ -26,32 +26,62 @@ Badge::Badge(const QString& p_id, const QString& p_text, const QIcon& icon, QWid
closeButton(new QPushButton()),
layout(new QHBoxLayout(this))
{
setBackgroundRole(QPalette::Base);
//setAutoFillBackground(true);
setFrameStyle(QFrame::StyledPanel);
setFrameShadow(QFrame::Raised);
createMandatoryComponents();
image->setPixmap(icon.pixmap(25, 25));
QIcon tabCloseIcon = QIcon::fromTheme("tab-close");
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->addWidget(image);
layout->addWidget(text);
layout->addWidget(closeButton);
layout->setContentsMargins(2, 2, 2, 2);
connect(closeButton, &QPushButton::clicked, this, &Badge::close);
}
Badge::Badge(QWidget* parent):
QFrame(parent),
id(Shared::generateUUID()),
image(nullptr),
text(nullptr),
closeButton(new QPushButton()),
layout(new QHBoxLayout(this))
{
createMandatoryComponents();
layout->addWidget(closeButton);
}
void Badge::setIcon(const QIcon& icon)
{
if (image == nullptr) {
image = new QLabel();
image->setPixmap(icon.pixmap(25, 25));
layout->insertWidget(0, image);
} else {
image->setPixmap(icon.pixmap(25, 25));
}
}
void Badge::setText(const QString& p_text)
{
if (text == nullptr) {
text = new QLabel(p_text);
int index = 0;
if (image != nullptr) {
index = 1;
}
layout->insertWidget(index, text);
} else {
text->setText(p_text);
}
}
Badge::~Badge()
{
if (image != nullptr) {
delete image;
}
if (text != nullptr) {
delete text;
}
delete closeButton;
}
bool Badge::Comparator::operator()(const Badge* a, const Badge* b) const
@ -63,3 +93,22 @@ bool Badge::Comparator::operator()(const Badge& a, const Badge& b) const
{
return a.id < b.id;
}
void Badge::createMandatoryComponents()
{
setBackgroundRole(QPalette::Base);
//setAutoFillBackground(true);
setFrameStyle(QFrame::StyledPanel);
setFrameShadow(QFrame::Raised);
QIcon tabCloseIcon = QIcon::fromTheme("tab-close");
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);
}

View file

@ -25,6 +25,8 @@
#include <QIcon>
#include <QPushButton>
#include "shared/utils.h"
/**
* @todo write docs
*/
@ -33,9 +35,14 @@ class Badge : public QFrame
Q_OBJECT
public:
Badge(const QString& id, const QString& text, const QIcon& icon, QWidget* parent = nullptr);
Badge(QWidget* parent = nullptr);
~Badge();
const QString id;
public:
void setText(const QString& text);
void setIcon(const QIcon& icon);
signals:
void close();
@ -45,6 +52,9 @@ private:
QLabel* text;
QPushButton* closeButton;
QHBoxLayout* layout;
private:
void createMandatoryComponents();
public:
struct Comparator {