#include "minibutton.h" #include #include "config.h" #include "globalvariables.h" MiniButton::MiniButton(QString orig_name, QString op, QWidget* parent) { this->orig_name = orig_name; this->op = op; connect(this, &MiniButton::click, this, &MiniButton::onclick2); } MiniButton::MiniButton(ButtonStruct button_struct, QWidget *parent) : QPushButton(parent) { ui.setupUi(this); connect(this, &MiniButton::click, this, &MiniButton::onclick1); this->button_struct = button_struct; } MiniButton::~MiniButton() {} void MiniButton::paintEvent(QPaintEvent* event) { QPushButton::paintEvent(event); setContentsMargins(0, 0, 0, 0); QRect rect(0, 0, this->width(), this->height()); QPainter painter(this); q_color.setNamedColor(background_color); painter.fillRect(rect, q_color); int text_x = (width() - TEXT_SIZE * text().length() * scale * 3) / 2; int text_y = (height()- TEXT_SIZE * scale * 3)/2; QFont ft; ft.setPixelSize(TEXT_SIZE); QRectF text_rect(text_x, text_y, TEXT_SIZE * text().length() * scale * 3, TEXT_SIZE * scale * 3); painter.setPen(text_color); painter.drawText(text_rect, Qt::AlignCenter, text()); } void MiniButton::onclick1() { emit click1(button_struct.op, button_struct.func, button_struct.path, button_struct.url); } void MiniButton::onclick2() { emit click2(this->orig_name,this->op); }