chore: 格式化ElaWidgetTools代码

This commit is contained in:
sleepwithoutbz
2025-09-20 01:39:00 +08:00
parent d2fded145d
commit 4ab391f8a1
394 changed files with 10913 additions and 15860 deletions

View File

@@ -10,9 +10,7 @@
#include <QTimer>
#include <QVBoxLayout>
Q_TAKEOVER_NATIVEEVENT_CPP(ElaWidget, d_func()->_appBar);
ElaWidget::ElaWidget(QWidget* parent)
: QWidget{parent}, d_ptr(new ElaWidgetPrivate())
{
ElaWidget::ElaWidget(QWidget *parent) : QWidget{parent}, d_ptr(new ElaWidgetPrivate()) {
Q_D(ElaWidget);
d->q_ptr = this;
resize(500, 500); // 默认宽高
@@ -24,7 +22,8 @@ ElaWidget::ElaWidget(QWidget* parent)
// 自定义AppBar
d->_appBar = new ElaAppBar(this);
d->_appBar->setIsStayTop(true);
d->_appBar->setWindowButtonFlags(ElaAppBarType::StayTopButtonHint | ElaAppBarType::MinimizeButtonHint | ElaAppBarType::MaximizeButtonHint | ElaAppBarType::CloseButtonHint);
d->_appBar->setWindowButtonFlags(ElaAppBarType::StayTopButtonHint | ElaAppBarType::MinimizeButtonHint | ElaAppBarType::MaximizeButtonHint |
ElaAppBarType::CloseButtonHint);
connect(d->_appBar, &ElaAppBar::routeBackButtonClicked, this, &ElaWidget::routeBackButtonClicked);
connect(d->_appBar, &ElaAppBar::navigationButtonClicked, this, &ElaWidget::navigationButtonClicked);
connect(d->_appBar, &ElaAppBar::themeChangeButtonClicked, this, &ElaWidget::themeChangeButtonClicked);
@@ -45,63 +44,46 @@ ElaWidget::ElaWidget(QWidget* parent)
eApp->syncWindowDisplayMode(this);
}
ElaWidget::~ElaWidget()
{
eApp->syncWindowDisplayMode(this, false);
}
ElaWidget::~ElaWidget() { eApp->syncWindowDisplayMode(this, false); }
void ElaWidget::setIsStayTop(bool isStayTop)
{
void ElaWidget::setIsStayTop(bool isStayTop) {
Q_D(ElaWidget);
d->_appBar->setIsStayTop(isStayTop);
}
bool ElaWidget::getIsStayTop() const
{
return d_ptr->_appBar->getIsStayTop();
}
bool ElaWidget::getIsStayTop() const { return d_ptr->_appBar->getIsStayTop(); }
void ElaWidget::setIsFixedSize(bool isFixedSize)
{
void ElaWidget::setIsFixedSize(bool isFixedSize) {
Q_D(ElaWidget);
d->_appBar->setIsFixedSize(isFixedSize);
}
bool ElaWidget::getIsFixedSize() const
{
return d_ptr->_appBar->getIsFixedSize();
}
bool ElaWidget::getIsFixedSize() const { return d_ptr->_appBar->getIsFixedSize(); }
void ElaWidget::setIsDefaultClosed(bool isDefaultClosed)
{
void ElaWidget::setIsDefaultClosed(bool isDefaultClosed) {
Q_D(ElaWidget);
d->_appBar->setIsDefaultClosed(isDefaultClosed);
Q_EMIT pIsDefaultClosedChanged();
}
bool ElaWidget::getIsDefaultClosed() const
{
bool ElaWidget::getIsDefaultClosed() const {
Q_D(const ElaWidget);
return d->_appBar->getIsDefaultClosed();
}
void ElaWidget::setAppBarHeight(int appBarHeight)
{
void ElaWidget::setAppBarHeight(int appBarHeight) {
Q_D(ElaWidget);
d->_appBar->setAppBarHeight(appBarHeight);
Q_EMIT pAppBarHeightChanged();
}
int ElaWidget::getAppBarHeight() const
{
int ElaWidget::getAppBarHeight() const {
Q_D(const ElaWidget);
return d->_appBar->getAppBarHeight();
}
void ElaWidget::moveToCenter()
{
if (isMaximized() || isFullScreen())
{
void ElaWidget::moveToCenter() {
if (isMaximized() || isFullScreen()) {
return;
}
#if QT_VERSION >= QT_VERSION_CHECK(5, 14, 0)
@@ -112,25 +94,19 @@ void ElaWidget::moveToCenter()
setGeometry((geometry.left() + geometry.right() - width()) / 2, (geometry.top() + geometry.bottom() - height()) / 2, width(), height());
}
void ElaWidget::setWindowButtonFlag(ElaAppBarType::ButtonType buttonFlag, bool isEnable)
{
void ElaWidget::setWindowButtonFlag(ElaAppBarType::ButtonType buttonFlag, bool isEnable) {
Q_D(ElaWidget);
d->_appBar->setWindowButtonFlag(buttonFlag, isEnable);
}
void ElaWidget::setWindowButtonFlags(ElaAppBarType::ButtonFlags buttonFlags)
{
void ElaWidget::setWindowButtonFlags(ElaAppBarType::ButtonFlags buttonFlags) {
Q_D(ElaWidget);
d->_appBar->setWindowButtonFlags(buttonFlags);
}
ElaAppBarType::ButtonFlags ElaWidget::getWindowButtonFlags() const
{
return d_ptr->_appBar->getWindowButtonFlags();
}
ElaAppBarType::ButtonFlags ElaWidget::getWindowButtonFlags() const { return d_ptr->_appBar->getWindowButtonFlags(); }
void ElaWidget::paintEvent(QPaintEvent* event)
{
void ElaWidget::paintEvent(QPaintEvent *event) {
Q_D(ElaWidget);
#if (QT_VERSION >= QT_VERSION_CHECK(6, 5, 3) && QT_VERSION <= QT_VERSION_CHECK(6, 6, 1))
if (d->_windowDisplayMode != ElaApplicationType::WindowDisplayMode::ElaMica)