OfficeAssistant_Win10/OfficeAssistant_msvc/MyButton.h

75 lines
1.9 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"
#include "buttonstruct.h"
class MyButton: public QPushButton{
Q_OBJECT
signals:
void clicked1(QString orig_name,QString op, QString func, QString url, QString path, QString initial_position);
public:
MyButton(ButtonStruct &buttonStruct,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:
QColor text_color;
QColor text_cover_color;
QString background_color;
QList<MyButton *> *buttons;
QImage *logo;
QImage *logo_cover;
QVBoxLayout *layout;
QString text;
QString orig_name;
QString url;
QString op;
QString path;
QString initial_position;
QString func;
int width2;
int height2;
int logicalwidth;
int logicalheight;
bool checked=false;
};
#endif //OFFICEASSISTANT_MYBUTTON_H