OfficeAssistant_Win10/OfficeAssistant_msvc/MyButton.h

69 lines
1.7 KiB
C
Raw Normal View History

2023-07-26 19:48:14 +08:00
//
// 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>
2023-07-27 13:44:54 +08:00
#include "globalvariables.h"
2023-07-30 01:06:42 +08:00
#include "buttonstruct.h"
2023-07-26 19:48:14 +08:00
class MyButton: public QPushButton{
2023-07-30 10:26:41 +08:00
Q_OBJECT
signals:
void clicked1(QString text, QString url);
2023-07-26 19:48:14 +08:00
public:
2023-07-30 01:06:42 +08:00
MyButton(ButtonStruct &buttonStruct,int width,int height,QList<MyButton *> *buttons,QWidget *parent=nullptr);
2023-07-26 19:48:14 +08:00
~MyButton() override;
QString getText(){
return text;
}
2023-07-27 13:44:54 +08:00
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);
};
}
2023-07-29 07:20:49 +08:00
void setSize(int width,int height,int logicalwidth,int logicalheight){
2023-07-27 13:44:54 +08:00
this->width2=width;
this->height2=height;
this->logicalwidth=logicalwidth;
this->logicalheight=logicalheight;
}
2023-07-26 19:48:14 +08:00
protected:
void paintEvent(QPaintEvent *e) override;
2023-07-27 13:44:54 +08:00
void enterEvent(QEvent *event) override;
void leaveEvent(QEvent *event) override;
void mousePressEvent(QMouseEvent *event) override;
void mouseReleaseEvent(QMouseEvent *event) override;
2023-07-26 19:48:14 +08:00
private:
2023-08-01 09:04:53 +08:00
QColor text_color;
QColor text_cover_color;
2023-07-27 13:44:54 +08:00
QList<MyButton *> *buttons;
2023-07-26 19:48:14 +08:00
QImage *logo;
2023-07-30 01:06:42 +08:00
QImage *logo_cover;
2023-07-26 19:48:14 +08:00
QVBoxLayout *layout;
QString text;
2023-07-30 10:26:41 +08:00
QString url;
2023-07-26 19:48:14 +08:00
int width2;
int height2;
2023-07-27 13:44:54 +08:00
int logicalwidth;
int logicalheight;
bool checked=false;
2023-07-26 19:48:14 +08:00
};
#endif //OFFICEASSISTANT_MYBUTTON_H