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

@@ -5,12 +5,10 @@
#include <QDateTime>
#include <QDebug>
#include <QTimer>
ElaLCDNumber::ElaLCDNumber(QWidget* parent)
: QLCDNumber(parent), d_ptr(new ElaLCDNumberPrivate)
{
ElaLCDNumber::ElaLCDNumber(QWidget *parent) : QLCDNumber(parent), d_ptr(new ElaLCDNumberPrivate) {
Q_D(ElaLCDNumber);
d->q_ptr = this;
d->_pIsUseAutoClock = false;
d->q_ptr = this;
d->_pIsUseAutoClock = false;
d->_pAutoClockFormat = "yyyy-MM-dd hh:mm:ss";
setDigitCount(d->_pAutoClockFormat.length());
setSegmentStyle(QLCDNumber::Flat);
@@ -19,83 +17,65 @@ ElaLCDNumber::ElaLCDNumber(QWidget* parent)
d->_lcdNumberStyle = new ElaLCDNumberStyle();
setStyle(d->_lcdNumberStyle);
d->_clockTimer = new QTimer(this);
connect(d->_clockTimer, &QTimer::timeout, this, [=]() {
display(QDateTime::currentDateTime().toString(d->_pAutoClockFormat));
});
connect(d->_clockTimer, &QTimer::timeout, this, [=]() { display(QDateTime::currentDateTime().toString(d->_pAutoClockFormat)); });
d->onThemeModeChanged(eTheme->getThemeMode());
connect(eTheme, &ElaTheme::themeModeChanged, d, &ElaLCDNumberPrivate::onThemeModeChanged);
}
ElaLCDNumber::ElaLCDNumber(uint numDigits, QWidget* parent)
: ElaLCDNumber(parent)
{
setDigitCount(numDigits);
}
ElaLCDNumber::ElaLCDNumber(uint numDigits, QWidget *parent) : ElaLCDNumber(parent) { setDigitCount(numDigits); }
ElaLCDNumber::~ElaLCDNumber()
{
ElaLCDNumber::~ElaLCDNumber() {
Q_D(ElaLCDNumber);
delete d->_lcdNumberStyle;
}
void ElaLCDNumber::setIsUseAutoClock(bool isUseAutoClock)
{
void ElaLCDNumber::setIsUseAutoClock(bool isUseAutoClock) {
Q_D(ElaLCDNumber);
d->_pIsUseAutoClock = isUseAutoClock;
if (d->_pIsUseAutoClock)
{
if (d->_pIsUseAutoClock) {
setDigitCount(d->_pAutoClockFormat.length());
display(QDateTime::currentDateTime().toString(d->_pAutoClockFormat));
d->_clockTimer->start(200);
}
else
{
} else {
d->_clockTimer->stop();
display("");
}
Q_EMIT pIsUseAutoClockChanged();
}
bool ElaLCDNumber::getIsUseAutoClock() const
{
bool ElaLCDNumber::getIsUseAutoClock() const {
Q_D(const ElaLCDNumber);
return d->_pIsUseAutoClock;
}
void ElaLCDNumber::setAutoClockFormat(QString autoClockFormat)
{
void ElaLCDNumber::setAutoClockFormat(QString autoClockFormat) {
Q_D(ElaLCDNumber);
d->_pAutoClockFormat = autoClockFormat;
setDigitCount(d->_pAutoClockFormat.length());
Q_EMIT pAutoClockFormatChanged();
}
QString ElaLCDNumber::getAutoClockFormat() const
{
QString ElaLCDNumber::getAutoClockFormat() const {
Q_D(const ElaLCDNumber);
return d->_pAutoClockFormat;
}
void ElaLCDNumber::setIsTransparent(bool isTransparent)
{
void ElaLCDNumber::setIsTransparent(bool isTransparent) {
Q_D(ElaLCDNumber);
d->_lcdNumberStyle->setIsTransparent(isTransparent);
update();
Q_EMIT pIsTransparentChanged();
}
bool ElaLCDNumber::getIsTransparent() const
{
bool ElaLCDNumber::getIsTransparent() const {
Q_D(const ElaLCDNumber);
return d->_lcdNumberStyle->getIsTransparent();
}
void ElaLCDNumber::paintEvent(QPaintEvent* event)
{
void ElaLCDNumber::paintEvent(QPaintEvent *event) {
Q_D(ElaLCDNumber);
if (palette().color(QPalette::WindowText) != ElaThemeColor(d->_themeMode, BasicText))
{
if (palette().color(QPalette::WindowText) != ElaThemeColor(d->_themeMode, BasicText)) {
d->onThemeModeChanged(d->_themeMode);
}
QLCDNumber::paintEvent(event);