Files
handleaiuinew/HanddleAI/HandleAiUi-new/uiModule/components/fancyButton.h
T
2024-05-18 23:53:26 +08:00

132 lines
3.9 KiB
C++

#include <QApplication>
#include <QPushButton>
#include <QPropertyAnimation>
#include <QMouseEvent>
#include <globalStruct.h>
#include <qpainter.h>
class fancyButton : public QPushButton {
public:
QIcon defaultIcon;
fancyButton(int Width, int Height, QIcon defaultIn,QString tips="")
{
defaultIcon = defaultIn;
this->setToolTip(tips);
this->setIcon(defaultIcon); // ÉèÖÃͼ±ê
this->setFixedHeight(Height);
this->setFixedWidth(Width);
toDefault();
}
void toDefault()
{
this->setStyleSheet(QString("QPushButton { background-color: transparent;"
"border: 0px solid red;"
"border-radius: 0px;"
"}"
"QPushButton:focus {"
" outline: none;"
"}"
"QPushButton:hover { background-color: rgb(%1); }").arg(sColor_GoldWithBlack));
}
};
class fancyButtonText : public QPushButton {
public:
QString text;
fancyButtonText(int Width, int Height, QString textIn, QString tips = "")
{
QPalette palette;
palette.setColor(QPalette::WindowText, Qt::white);
QFont font("΢ÈíÑźÚ", 14, QFont::Bold);
text = textIn;
this->setToolTip(tips);
this->setText(text);
this->setFixedHeight(Height);
this->setFixedWidth(Width);
this->setPalette(palette);
this->setFont(font);
toDefault();
}
void toDefault()
{
this->setStyleSheet(QString("QPushButton { background-color: transparent;"
"color: white;"
"border: 0px solid red;"
"border-radius: 0px;"
"}"
"QPushButton:focus {"
" outline: none;"
"}"
"QPushButton:hover { background-color: rgb(%1); }").arg(sColor_GoldWithBlack));
}
};
class gradientButton : public QPushButton {
public:
QString text;
gradientButton(int Width, int Height, QString textIn, QString tips = "")
{
QPalette palette;
palette.setColor(QPalette::WindowText, Qt::white);
QFont font("΢ÈíÑźÚ", 14, QFont::Bold);
text = textIn;
this->setToolTip(tips);
this->setText(text);
this->setFixedHeight(Height);
this->setFixedWidth(Width);
this->setPalette(palette);
this->setFont(font);
toDefault();
}
void toDefault()
{
this->setStyleSheet(
QString("QPushButton {"
" color: white;"
" background: qlineargradient(spread:pad, x1:0, y1:0, x2:0, y2:1, "
" stop:1 rgba(%1, 255), "
" stop:0.9 rgba(%1, 255),"
" stop:0.9 rgba(255, 255, 255, 0)"
" ); "
" border: none;"
" padding: 10px;"
"}"
"QPushButton:hover {"
" color: white;"
" background: qlineargradient(spread:pad, x1:0, y1:0, x2:0, y2:1, "
" stop:1 rgba(%1, 255), "
" stop:0.9 rgba(%1, 255),"
" stop:0.9 rgba(255, 255, 255, 0.2),"
" stop:0.5 rgba(255, 255, 255, 0) "
" ); "
" border: none;"
" padding: 10px;"
"}"
"QPushButton:focus {"
" outline: none;"
"}"
).arg(sColor_Gold));
}
void pressed()
{
this->setStyleSheet(
QString("QPushButton {"
" color: white;"
" background: qlineargradient(spread:pad, x1:0, y1:0, x2:0, y2:1, "
" stop:1 rgba(%1, 255), "
" stop:0.9 rgba(%1, 255),"
" stop:0.9 rgba(255, 255, 255, 0.3),"
" stop:0.3 rgba(255, 255, 255, 0) "
" ); "
" border: none;"
" padding: 10px;"
"}"
"QPushButton:focus {"
" outline: none;"
"}"
).arg(sColor_Gold));
}
};
#pragma once