OfficeAssistant_Win10/MyButton.h

64 lines
1.6 KiB
C++

//
// Created by HW on 2023/07/26.
//
#ifndef OFFICEASSISTANT_MYBUTTON_H
#define OFFICEASSISTANT_MYBUTTON_H
#include <QPushButton>
#include <QPaintEvent>
#include <QtSvg/QtSvg>
#include <QtSvg/QSvgWidget>
#include <QtSvg/QSvgRenderer>
#include "globalvariables.h"
class MyButton: public QPushButton{
public:
MyButton(QString logo,QString text,int width,int height,QList<MyButton *> *buttons,QWidget *parent=nullptr);
~MyButton() override;
QString getText(){
return text;
}
QSize sizeHint() const override;
void setChecked(bool checked){
this->checked=checked;
}
QSize getLogicalSize() const {
if(scale>=1.25){
return QSize(width2,height2);
}
else{
return QSize(width2,height2);
};
}
void setSize(int width,int height,int logicalwidth,int logicalheight){
this->width2=width;
this->height2=height;
this->logicalwidth=logicalwidth;
this->logicalheight=logicalheight;
}
protected:
void paintEvent(QPaintEvent *e) override;
void enterEvent(QEvent *event) override;
void leaveEvent(QEvent *event) override;
void mousePressEvent(QMouseEvent *event) override;
void mouseReleaseEvent(QMouseEvent *event) override;
private:
QList<MyButton *> *buttons;
QImage *logo;
QLabel *logo_label;
QLabel *text_label;
QVBoxLayout *layout;
QPixmap* logo_pixmap;
QString text;
int width2;
int height2;
int logicalwidth;
int logicalheight;
bool checked=false;
};
#endif //OFFICEASSISTANT_MYBUTTON_H