更新文档

This commit is contained in:
feiyangqingyun
2023-09-08 13:52:30 +08:00
parent 9af16093a2
commit 8173abef29
39 changed files with 1556 additions and 1464 deletions

View File

@@ -144,86 +144,6 @@ void Battery::updateValue()
this->update();
}
double Battery::getMinValue() const
{
return this->minValue;
}
double Battery::getMaxValue() const
{
return this->maxValue;
}
double Battery::getValue() const
{
return this->value;
}
double Battery::getAlarmValue() const
{
return this->alarmValue;
}
bool Battery::getAnimation() const
{
return this->animation;
}
double Battery::getAnimationStep() const
{
return this->animationStep;
}
int Battery::getBorderWidth() const
{
return this->borderWidth;
}
int Battery::getBorderRadius() const
{
return this->borderRadius;
}
int Battery::getBgRadius() const
{
return this->bgRadius;
}
int Battery::getHeadRadius() const
{
return this->headRadius;
}
QColor Battery::getBorderColorStart() const
{
return this->borderColorStart;
}
QColor Battery::getBorderColorEnd() const
{
return this->borderColorEnd;
}
QColor Battery::getAlarmColorStart() const
{
return this->alarmColorStart;
}
QColor Battery::getAlarmColorEnd() const
{
return this->alarmColorEnd;
}
QColor Battery::getNormalColorStart() const
{
return this->normalColorStart;
}
QColor Battery::getNormalColorEnd() const
{
return this->normalColorEnd;
}
QSize Battery::sizeHint() const
{
return QSize(150, 80);
@@ -260,16 +180,31 @@ void Battery::setRange(int minValue, int maxValue)
setRange((double)minValue, (double)maxValue);
}
double Battery::getMinValue() const
{
return this->minValue;
}
void Battery::setMinValue(double minValue)
{
setRange(minValue, maxValue);
}
double Battery::getMaxValue() const
{
return this->maxValue;
}
void Battery::setMaxValue(double maxValue)
{
setRange(minValue, maxValue);
}
double Battery::getValue() const
{
return this->value;
}
void Battery::setValue(double value)
{
//值和当前值一致则无需处理
@@ -310,6 +245,11 @@ void Battery::setValue(int value)
setValue((double)value);
}
double Battery::getAlarmValue() const
{
return this->alarmValue;
}
void Battery::setAlarmValue(double alarmValue)
{
if (this->alarmValue != alarmValue) {
@@ -323,6 +263,12 @@ void Battery::setAlarmValue(int alarmValue)
setAlarmValue((double)alarmValue);
}
bool Battery::getAnimation() const
{
return this->animation;
}
void Battery::setAnimation(bool animation)
{
if (this->animation != animation) {
@@ -331,6 +277,11 @@ void Battery::setAnimation(bool animation)
}
}
double Battery::getAnimationStep() const
{
return this->animationStep;
}
void Battery::setAnimationStep(double animationStep)
{
if (this->animationStep != animationStep) {
@@ -339,6 +290,11 @@ void Battery::setAnimationStep(double animationStep)
}
}
int Battery::getBorderWidth() const
{
return this->borderWidth;
}
void Battery::setBorderWidth(int borderWidth)
{
if (this->borderWidth != borderWidth) {
@@ -347,6 +303,11 @@ void Battery::setBorderWidth(int borderWidth)
}
}
int Battery::getBorderRadius() const
{
return this->borderRadius;
}
void Battery::setBorderRadius(int borderRadius)
{
if (this->borderRadius != borderRadius) {
@@ -355,6 +316,11 @@ void Battery::setBorderRadius(int borderRadius)
}
}
int Battery::getBgRadius() const
{
return this->bgRadius;
}
void Battery::setBgRadius(int bgRadius)
{
if (this->bgRadius != bgRadius) {
@@ -363,6 +329,11 @@ void Battery::setBgRadius(int bgRadius)
}
}
int Battery::getHeadRadius() const
{
return this->headRadius;
}
void Battery::setHeadRadius(int headRadius)
{
if (this->headRadius != headRadius) {
@@ -371,6 +342,11 @@ void Battery::setHeadRadius(int headRadius)
}
}
QColor Battery::getBorderColorStart() const
{
return this->borderColorStart;
}
void Battery::setBorderColorStart(const QColor &borderColorStart)
{
if (this->borderColorStart != borderColorStart) {
@@ -379,6 +355,11 @@ void Battery::setBorderColorStart(const QColor &borderColorStart)
}
}
QColor Battery::getBorderColorEnd() const
{
return this->borderColorEnd;
}
void Battery::setBorderColorEnd(const QColor &borderColorEnd)
{
if (this->borderColorEnd != borderColorEnd) {
@@ -387,6 +368,11 @@ void Battery::setBorderColorEnd(const QColor &borderColorEnd)
}
}
QColor Battery::getAlarmColorStart() const
{
return this->alarmColorStart;
}
void Battery::setAlarmColorStart(const QColor &alarmColorStart)
{
if (this->alarmColorStart != alarmColorStart) {
@@ -395,6 +381,11 @@ void Battery::setAlarmColorStart(const QColor &alarmColorStart)
}
}
QColor Battery::getAlarmColorEnd() const
{
return this->alarmColorEnd;
}
void Battery::setAlarmColorEnd(const QColor &alarmColorEnd)
{
if (this->alarmColorEnd != alarmColorEnd) {
@@ -403,6 +394,11 @@ void Battery::setAlarmColorEnd(const QColor &alarmColorEnd)
}
}
QColor Battery::getNormalColorStart() const
{
return this->normalColorStart;
}
void Battery::setNormalColorStart(const QColor &normalColorStart)
{
if (this->normalColorStart != normalColorStart) {
@@ -411,6 +407,11 @@ void Battery::setNormalColorStart(const QColor &normalColorStart)
}
}
QColor Battery::getNormalColorEnd() const
{
return this->normalColorEnd;
}
void Battery::setNormalColorEnd(const QColor &normalColorEnd)
{
if (this->normalColorEnd != normalColorEnd) {
@@ -418,4 +419,3 @@ void Battery::setNormalColorEnd(const QColor &normalColorEnd)
this->update();
}
}

View File

@@ -58,102 +58,107 @@ private slots:
void updateValue();
private:
double minValue; //最小值
double maxValue; //最大值
double value; //目标电量
double alarmValue; //电池电量警戒值
double minValue; //最小值
double maxValue; //最大值
double value; //目标电量
double alarmValue; //电池电量警戒值
bool animation; //是否启用动画显示
double animationStep; //动画显示时步长
bool animation; //是否启用动画显示
double animationStep; //动画显示时步长
int borderWidth; //边框粗细
int borderRadius; //边框圆角角度
int bgRadius; //背景进度圆角角度
int headRadius; //头部圆角角度
int borderWidth; //边框粗细
int borderRadius; //边框圆角角度
int bgRadius; //背景进度圆角角度
int headRadius; //头部圆角角度
QColor borderColorStart; //边框渐变开始颜色
QColor borderColorEnd; //边框渐变结束颜色
QColor borderColorStart;//边框渐变开始颜色
QColor borderColorEnd; //边框渐变结束颜色
QColor alarmColorStart; //电池低电量时的渐变开始颜色
QColor alarmColorEnd; //电池低电量时的渐变结束颜色
QColor alarmColorStart; //电池低电量时的渐变开始颜色
QColor alarmColorEnd; //电池低电量时的渐变结束颜色
QColor normalColorStart; //电池正常电量时的渐变开始颜色
QColor normalColorEnd; //电池正常电量时的渐变结束颜色
QColor normalColorStart;//电池正常电量时的渐变开始颜色
QColor normalColorEnd; //电池正常电量时的渐变结束颜色
bool isForward; //是否往前移
double currentValue; //当前电量
QRectF batteryRect; //电池主体区域
QTimer *timer; //绘制定时器
bool isForward; //是否往前移
double currentValue; //当前电量
QRectF batteryRect; //电池主体区域
QTimer *timer; //绘制定时器
public:
double getMinValue() const;
double getMaxValue() const;
double getValue() const;
double getAlarmValue() const;
//默认尺寸和最小尺寸
QSize sizeHint() const;
QSize minimumSizeHint() const;
bool getAnimation() const;
double getAnimationStep() const;
int getBorderWidth() const;
int getBorderRadius() const;
int getBgRadius() const;
int getHeadRadius() const;
QColor getBorderColorStart() const;
QColor getBorderColorEnd() const;
QColor getAlarmColorStart() const;
QColor getAlarmColorEnd() const;
QColor getNormalColorStart() const;
QColor getNormalColorEnd() const;
QSize sizeHint() const;
QSize minimumSizeHint() const;
public Q_SLOTS:
//设置范围值
void setRange(double minValue, double maxValue);
void setRange(int minValue, int maxValue);
//设置最大最小值
//获取和设置最小值
double getMinValue() const;
void setMinValue(double minValue);
//获取和设置最大值
double getMaxValue() const;
void setMaxValue(double maxValue);
//设置电池电量值
//获取和设置电池电量值
double getValue() const;
void setValue(double value);
void setValue(int value);
//设置电池电量警戒值
//获取和设置电池电量警戒值
double getAlarmValue() const;
void setAlarmValue(double alarmValue);
void setAlarmValue(int alarmValue);
//设置是否启用动画显示
//获取和设置是否启用动画显示
bool getAnimation() const;
void setAnimation(bool animation);
//设置动画显示的步长
//获取和设置动画显示的步长
double getAnimationStep() const;
void setAnimationStep(double animationStep);
//设置边框粗细
//获取和设置边框粗细
int getBorderWidth() const;
void setBorderWidth(int borderWidth);
//设置边框圆角角度
//获取和设置边框圆角角度
int getBorderRadius() const;
void setBorderRadius(int borderRadius);
//设置背景圆角角度
//获取和设置背景圆角角度
int getBgRadius() const;
void setBgRadius(int bgRadius);
//设置头部圆角角度
//获取和设置头部圆角角度
int getHeadRadius() const;
void setHeadRadius(int headRadius);
//设置边框渐变颜色
//获取和设置边框渐变颜色
QColor getBorderColorStart() const;
void setBorderColorStart(const QColor &borderColorStart);
QColor getBorderColorEnd() const;
void setBorderColorEnd(const QColor &borderColorEnd);
//设置电池电量报警时的渐变颜色
//获取和设置电池电量报警时的渐变颜色
QColor getAlarmColorStart() const;
void setAlarmColorStart(const QColor &alarmColorStart);
QColor getAlarmColorEnd() const;
void setAlarmColorEnd(const QColor &alarmColorEnd);
//设置电池电量正常时的渐变颜色
//获取和设置电池电量正常时的渐变颜色
QColor getNormalColorStart() const;
void setNormalColorStart(const QColor &normalColorStart);
QColor getNormalColorEnd() const;
void setNormalColorEnd(const QColor &normalColorEnd);
public Q_SLOTS:
void setValue(int value);
void setAlarmValue(int alarmValue);
Q_SIGNALS:
void valueChanged(double value);
};