chore: 格式化ElaWidgetTools代码
This commit is contained in:
@@ -10,9 +10,7 @@
|
||||
#include "ElaIcon.h"
|
||||
#include "ElaMenu.h"
|
||||
#include "ElaToolButtonPrivate.h"
|
||||
ElaToolButton::ElaToolButton(QWidget* parent)
|
||||
: QToolButton(parent), d_ptr(new ElaToolButtonPrivate())
|
||||
{
|
||||
ElaToolButton::ElaToolButton(QWidget *parent) : QToolButton(parent), d_ptr(new ElaToolButtonPrivate()) {
|
||||
Q_D(ElaToolButton);
|
||||
d->q_ptr = this;
|
||||
setIconSize(QSize(22, 22));
|
||||
@@ -21,55 +19,46 @@ ElaToolButton::ElaToolButton(QWidget* parent)
|
||||
setStyle(d->_toolButtonStyle);
|
||||
}
|
||||
|
||||
ElaToolButton::~ElaToolButton()
|
||||
{
|
||||
ElaToolButton::~ElaToolButton() {
|
||||
Q_D(ElaToolButton);
|
||||
delete d->_toolButtonStyle;
|
||||
}
|
||||
|
||||
void ElaToolButton::setBorderRadius(int borderRadius)
|
||||
{
|
||||
void ElaToolButton::setBorderRadius(int borderRadius) {
|
||||
Q_D(ElaToolButton);
|
||||
d->_toolButtonStyle->setBorderRadius(borderRadius);
|
||||
Q_EMIT pBorderRadiusChanged();
|
||||
}
|
||||
|
||||
int ElaToolButton::getBorderRadius() const
|
||||
{
|
||||
int ElaToolButton::getBorderRadius() const {
|
||||
Q_D(const ElaToolButton);
|
||||
return d->_toolButtonStyle->getBorderRadius();
|
||||
}
|
||||
|
||||
void ElaToolButton::setIsSelected(bool isSelected)
|
||||
{
|
||||
void ElaToolButton::setIsSelected(bool isSelected) {
|
||||
Q_D(ElaToolButton);
|
||||
d->_toolButtonStyle->setIsSelected(isSelected);
|
||||
Q_EMIT pIsSelectedChanged();
|
||||
}
|
||||
|
||||
bool ElaToolButton::getIsSelected() const
|
||||
{
|
||||
bool ElaToolButton::getIsSelected() const {
|
||||
Q_D(const ElaToolButton);
|
||||
return d->_toolButtonStyle->getIsSelected();
|
||||
}
|
||||
|
||||
void ElaToolButton::setIsTransparent(bool isTransparent)
|
||||
{
|
||||
void ElaToolButton::setIsTransparent(bool isTransparent) {
|
||||
Q_D(ElaToolButton);
|
||||
d->_toolButtonStyle->setIsTransparent(isTransparent);
|
||||
update();
|
||||
}
|
||||
|
||||
bool ElaToolButton::getIsTransparent() const
|
||||
{
|
||||
bool ElaToolButton::getIsTransparent() const {
|
||||
Q_D(const ElaToolButton);
|
||||
return d->_toolButtonStyle->getIsTransparent();
|
||||
}
|
||||
|
||||
void ElaToolButton::setMenu(ElaMenu* menu)
|
||||
{
|
||||
if (!menu || menu == this->menu())
|
||||
{
|
||||
void ElaToolButton::setMenu(ElaMenu *menu) {
|
||||
if (!menu || menu == this->menu()) {
|
||||
return;
|
||||
}
|
||||
menu->setMenuItemHeight(27);
|
||||
@@ -77,26 +66,19 @@ void ElaToolButton::setMenu(ElaMenu* menu)
|
||||
menu->installEventFilter(this);
|
||||
}
|
||||
|
||||
void ElaToolButton::setElaIcon(ElaIconType::IconName icon)
|
||||
{
|
||||
void ElaToolButton::setElaIcon(ElaIconType::IconName icon) {
|
||||
setProperty("ElaIconType", QChar((unsigned short)icon));
|
||||
setIcon(ElaIcon::getInstance()->getElaIcon(ElaIconType::Broom, 1));
|
||||
}
|
||||
|
||||
bool ElaToolButton::eventFilter(QObject* watched, QEvent* event)
|
||||
{
|
||||
bool ElaToolButton::eventFilter(QObject *watched, QEvent *event) {
|
||||
Q_D(ElaToolButton);
|
||||
if (watched == menu())
|
||||
{
|
||||
switch (event->type())
|
||||
{
|
||||
case QEvent::Show:
|
||||
{
|
||||
//指示器动画
|
||||
QPropertyAnimation* rotateAnimation = new QPropertyAnimation(d->_toolButtonStyle, "pExpandIconRotate");
|
||||
connect(rotateAnimation, &QPropertyAnimation::valueChanged, this, [=](const QVariant& value) {
|
||||
update();
|
||||
});
|
||||
if (watched == menu()) {
|
||||
switch (event->type()) {
|
||||
case QEvent::Show: {
|
||||
// 指示器动画
|
||||
QPropertyAnimation *rotateAnimation = new QPropertyAnimation(d->_toolButtonStyle, "pExpandIconRotate");
|
||||
connect(rotateAnimation, &QPropertyAnimation::valueChanged, this, [=](const QVariant &value) { update(); });
|
||||
rotateAnimation->setDuration(300);
|
||||
rotateAnimation->setEasingCurve(QEasingCurve::InOutSine);
|
||||
rotateAnimation->setStartValue(d->_toolButtonStyle->getExpandIconRotate());
|
||||
@@ -104,13 +86,10 @@ bool ElaToolButton::eventFilter(QObject* watched, QEvent* event)
|
||||
rotateAnimation->start(QAbstractAnimation::DeleteWhenStopped);
|
||||
break;
|
||||
}
|
||||
case QEvent::Hide:
|
||||
{
|
||||
//指示器动画
|
||||
QPropertyAnimation* rotateAnimation = new QPropertyAnimation(d->_toolButtonStyle, "pExpandIconRotate");
|
||||
connect(rotateAnimation, &QPropertyAnimation::valueChanged, this, [=](const QVariant& value) {
|
||||
update();
|
||||
});
|
||||
case QEvent::Hide: {
|
||||
// 指示器动画
|
||||
QPropertyAnimation *rotateAnimation = new QPropertyAnimation(d->_toolButtonStyle, "pExpandIconRotate");
|
||||
connect(rotateAnimation, &QPropertyAnimation::valueChanged, this, [=](const QVariant &value) { update(); });
|
||||
rotateAnimation->setDuration(300);
|
||||
rotateAnimation->setEasingCurve(QEasingCurve::InOutSine);
|
||||
rotateAnimation->setStartValue(d->_toolButtonStyle->getExpandIconRotate());
|
||||
@@ -120,8 +99,7 @@ bool ElaToolButton::eventFilter(QObject* watched, QEvent* event)
|
||||
QApplication::sendEvent(parentWidget(), &focusEvent);
|
||||
break;
|
||||
}
|
||||
default:
|
||||
{
|
||||
default: {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user