更新文档

master
feiyangqingyun 2023-09-08 13:51:39 +08:00
parent 997f367a19
commit f9eae763ba
41 changed files with 1556 additions and 1464 deletions

View File

@ -144,86 +144,6 @@ void Battery::updateValue()
this->update(); 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 QSize Battery::sizeHint() const
{ {
return QSize(150, 80); return QSize(150, 80);
@ -260,16 +180,31 @@ void Battery::setRange(int minValue, int maxValue)
setRange((double)minValue, (double)maxValue); setRange((double)minValue, (double)maxValue);
} }
double Battery::getMinValue() const
{
return this->minValue;
}
void Battery::setMinValue(double minValue) void Battery::setMinValue(double minValue)
{ {
setRange(minValue, maxValue); setRange(minValue, maxValue);
} }
double Battery::getMaxValue() const
{
return this->maxValue;
}
void Battery::setMaxValue(double maxValue) void Battery::setMaxValue(double maxValue)
{ {
setRange(minValue, maxValue); setRange(minValue, maxValue);
} }
double Battery::getValue() const
{
return this->value;
}
void Battery::setValue(double value) void Battery::setValue(double value)
{ {
//值和当前值一致则无需处理 //值和当前值一致则无需处理
@ -310,6 +245,11 @@ void Battery::setValue(int value)
setValue((double)value); setValue((double)value);
} }
double Battery::getAlarmValue() const
{
return this->alarmValue;
}
void Battery::setAlarmValue(double alarmValue) void Battery::setAlarmValue(double alarmValue)
{ {
if (this->alarmValue != alarmValue) { if (this->alarmValue != alarmValue) {
@ -323,6 +263,12 @@ void Battery::setAlarmValue(int alarmValue)
setAlarmValue((double)alarmValue); setAlarmValue((double)alarmValue);
} }
bool Battery::getAnimation() const
{
return this->animation;
}
void Battery::setAnimation(bool animation) void Battery::setAnimation(bool animation)
{ {
if (this->animation != 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) void Battery::setAnimationStep(double animationStep)
{ {
if (this->animationStep != 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) void Battery::setBorderWidth(int borderWidth)
{ {
if (this->borderWidth != 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) void Battery::setBorderRadius(int borderRadius)
{ {
if (this->borderRadius != 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) void Battery::setBgRadius(int bgRadius)
{ {
if (this->bgRadius != 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) void Battery::setHeadRadius(int headRadius)
{ {
if (this->headRadius != 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) void Battery::setBorderColorStart(const QColor &borderColorStart)
{ {
if (this->borderColorStart != 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) void Battery::setBorderColorEnd(const QColor &borderColorEnd)
{ {
if (this->borderColorEnd != 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) void Battery::setAlarmColorStart(const QColor &alarmColorStart)
{ {
if (this->alarmColorStart != 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) void Battery::setAlarmColorEnd(const QColor &alarmColorEnd)
{ {
if (this->alarmColorEnd != 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) void Battery::setNormalColorStart(const QColor &normalColorStart)
{ {
if (this->normalColorStart != 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) void Battery::setNormalColorEnd(const QColor &normalColorEnd)
{ {
if (this->normalColorEnd != normalColorEnd) { if (this->normalColorEnd != normalColorEnd) {
@ -418,4 +419,3 @@ void Battery::setNormalColorEnd(const QColor &normalColorEnd)
this->update(); this->update();
} }
} }

View File

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

View File

@ -114,36 +114,6 @@ bool DeviceButton::eventFilter(QObject *watched, QEvent *event)
return QWidget::eventFilter(watched, event); return QWidget::eventFilter(watched, event);
} }
bool DeviceButton::getCanMove() const
{
return this->canMove;
}
QString DeviceButton::getText() const
{
return this->text;
}
QString DeviceButton::getColorNormal() const
{
return this->colorNormal;
}
QString DeviceButton::getColorAlarm() const
{
return this->colorAlarm;
}
DeviceButton::ButtonStyle DeviceButton::getButtonStyle() const
{
return this->buttonStyle;
}
DeviceButton::ButtonColor DeviceButton::getButtonColor() const
{
return this->buttonColor;
}
QSize DeviceButton::sizeHint() const QSize DeviceButton::sizeHint() const
{ {
return QSize(50, 50); return QSize(50, 50);
@ -166,11 +136,21 @@ void DeviceButton::checkAlarm()
this->update(); this->update();
} }
bool DeviceButton::getCanMove() const
{
return this->canMove;
}
void DeviceButton::setCanMove(bool canMove) void DeviceButton::setCanMove(bool canMove)
{ {
this->canMove = canMove; this->canMove = canMove;
} }
QString DeviceButton::getText() const
{
return this->text;
}
void DeviceButton::setText(const QString &text) void DeviceButton::setText(const QString &text)
{ {
if (this->text != text) { if (this->text != text) {
@ -179,6 +159,11 @@ void DeviceButton::setText(const QString &text)
} }
} }
QString DeviceButton::getColorNormal() const
{
return this->colorNormal;
}
void DeviceButton::setColorNormal(const QString &colorNormal) void DeviceButton::setColorNormal(const QString &colorNormal)
{ {
if (this->colorNormal != colorNormal) { if (this->colorNormal != colorNormal) {
@ -187,6 +172,11 @@ void DeviceButton::setColorNormal(const QString &colorNormal)
} }
} }
QString DeviceButton::getColorAlarm() const
{
return this->colorAlarm;
}
void DeviceButton::setColorAlarm(const QString &colorAlarm) void DeviceButton::setColorAlarm(const QString &colorAlarm)
{ {
if (this->colorAlarm != colorAlarm) { if (this->colorAlarm != colorAlarm) {
@ -195,6 +185,11 @@ void DeviceButton::setColorAlarm(const QString &colorAlarm)
} }
} }
DeviceButton::ButtonStyle DeviceButton::getButtonStyle() const
{
return this->buttonStyle;
}
void DeviceButton::setButtonStyle(const DeviceButton::ButtonStyle &buttonStyle) void DeviceButton::setButtonStyle(const DeviceButton::ButtonStyle &buttonStyle)
{ {
this->buttonStyle = buttonStyle; this->buttonStyle = buttonStyle;
@ -217,6 +212,11 @@ void DeviceButton::setButtonStyle(const DeviceButton::ButtonStyle &buttonStyle)
setButtonColor(buttonColor); setButtonColor(buttonColor);
} }
DeviceButton::ButtonColor DeviceButton::getButtonColor() const
{
return this->buttonColor;
}
void DeviceButton::setButtonColor(const DeviceButton::ButtonColor &buttonColor) void DeviceButton::setButtonColor(const DeviceButton::ButtonColor &buttonColor)
{ {
//先停止定时器 //先停止定时器

View File

@ -46,13 +46,13 @@ public:
//设备按钮颜色 //设备按钮颜色
enum ButtonColor { enum ButtonColor {
ButtonColor_Green = 0, //绿色 激活状态 ButtonColor_Green = 0, //绿色(激活状态)
ButtonColor_Blue = 1, //蓝色 在线状态 ButtonColor_Blue = 1, //蓝色(在线状态)
ButtonColor_Red = 2, //红色 报警状态 ButtonColor_Red = 2, //红色(报警状态)
ButtonColor_Gray = 3, //灰色 离线状态 ButtonColor_Gray = 3, //灰色(离线状态)
ButtonColor_Black = 4, //黑色 故障状态 ButtonColor_Black = 4, //黑色(故障状态)
ButtonColor_Purple = 5, //紫色 其他状态 ButtonColor_Purple = 5, //紫色(其他状态)
ButtonColor_Yellow = 6 //黄色 其他状态 ButtonColor_Yellow = 6 //黄色(其他状态)
}; };
explicit DeviceButton(QWidget *parent = 0); explicit DeviceButton(QWidget *parent = 0);
@ -63,54 +63,55 @@ protected:
bool eventFilter(QObject *watched, QEvent *event); bool eventFilter(QObject *watched, QEvent *event);
private: private:
bool canMove; //是否可移动 bool canMove; //是否可移动
QString text; //显示文字 QString text; //显示文字
QString colorNormal; //正常颜色 QString colorNormal; //正常颜色
QString colorAlarm; //报警颜色 QString colorAlarm; //报警颜色
ButtonStyle buttonStyle; //按钮样式 ButtonStyle buttonStyle;//按钮样式
ButtonColor buttonColor; //按钮颜色 ButtonColor buttonColor;//按钮颜色
bool isPressed; //鼠标是否按下 bool isPressed; //鼠标是否按下
QPoint lastPoint; //鼠标按下最后坐标 QPoint lastPoint; //鼠标按下最后坐标
QString type; //图片末尾类型 QString type; //图片末尾类型
QString imgPath; //背景图片路径 QString imgPath; //背景图片路径
QString imgName; //背景图片名称 QString imgName; //背景图片名称
bool isDark; //是否加深报警 bool isDark; //是否加深报警
QTimer *timer; //报警闪烁定时器 QTimer *timer; //报警闪烁定时器
private slots: private slots:
void checkAlarm(); //切换报警状态 void checkAlarm(); //切换报警状态
public: public:
bool getCanMove() const; //默认尺寸和最小尺寸
QString getText() const; QSize sizeHint() const;
QSize minimumSizeHint() const;
QString getColorNormal() const; //获取和设置可移动
QString getColorAlarm() const; bool getCanMove() const;
ButtonStyle getButtonStyle() const;
ButtonColor getButtonColor() const;
QSize sizeHint() const;
QSize minimumSizeHint() const;
public Q_SLOTS:
//设置可移动
void setCanMove(bool canMove); void setCanMove(bool canMove);
//设置显示文字
//获取和设置显示文字
QString getText() const;
void setText(const QString &text); void setText(const QString &text);
//设置正常颜色和报警颜色 //获取和设置正常颜色
QString getColorNormal() const;
void setColorNormal(const QString &colorNormal); void setColorNormal(const QString &colorNormal);
//获取和设置报警颜色
QString getColorAlarm() const;
void setColorAlarm(const QString &colorAlarm); void setColorAlarm(const QString &colorAlarm);
//设置样式 //获取和设置样式
ButtonStyle getButtonStyle() const;
void setButtonStyle(const ButtonStyle &buttonStyle); void setButtonStyle(const ButtonStyle &buttonStyle);
//设置颜色
//获取和设置颜色
ButtonColor getButtonColor() const;
void setButtonColor(const ButtonColor &buttonColor); void setButtonColor(const ButtonColor &buttonColor);
Q_SIGNALS: Q_SIGNALS:

View File

@ -59,128 +59,6 @@ DeviceSizeTable::DeviceSizeTable(QWidget *parent) : QTableWidget(parent)
//QTimer::singleShot(10, this, SLOT(load())); //QTimer::singleShot(10, this, SLOT(load()));
} }
QColor DeviceSizeTable::getBgColor() const
{
return this->bgColor;
}
QColor DeviceSizeTable::getChunkColor1() const
{
return this->chunkColor1;
}
QColor DeviceSizeTable::getChunkColor2() const
{
return this->chunkColor2;
}
QColor DeviceSizeTable::getChunkColor3() const
{
return this->chunkColor3;
}
QColor DeviceSizeTable::getTextColor1() const
{
return this->textColor1;
}
QColor DeviceSizeTable::getTextColor2() const
{
return this->textColor2;
}
QColor DeviceSizeTable::getTextColor3() const
{
return this->textColor3;
}
void DeviceSizeTable::load()
{
//清空原有数据
int row = this->rowCount();
for (int i = 0; i < row; ++i) {
this->removeRow(0);
}
#ifdef Q_OS_WIN
QFileInfoList list = QDir::drives();
foreach (QFileInfo dir, list) {
QString dirName = dir.absolutePath();
LPCWSTR lpcwstrDriver = (LPCWSTR)dirName.utf16();
ULARGE_INTEGER liFreeBytesAvailable, liTotalBytes, liTotalFreeBytes;
if (GetDiskFreeSpaceEx(lpcwstrDriver, &liFreeBytesAvailable, &liTotalBytes, &liTotalFreeBytes)) {
QString use = QString::number((double)(liTotalBytes.QuadPart - liTotalFreeBytes.QuadPart) / GB, 'f', 1);
use += "G";
QString free = QString::number((double) liTotalFreeBytes.QuadPart / GB, 'f', 1);
free += "G";
QString all = QString::number((double) liTotalBytes.QuadPart / GB, 'f', 1);
all += "G";
int percent = 100 - ((double)liTotalFreeBytes.QuadPart / liTotalBytes.QuadPart) * 100;
insertSize(dirName, use, free, all, percent);
}
}
#elif defined(Q_OS_UNIX) && !defined(Q_OS_WASM)
process->start("df", QStringList() << "-h");
#endif
}
void DeviceSizeTable::setBgColor(const QColor &bgColor)
{
if (this->bgColor != bgColor) {
this->bgColor = bgColor;
this->load();
}
}
void DeviceSizeTable::setChunkColor1(const QColor &chunkColor1)
{
if (this->chunkColor1 != chunkColor1) {
this->chunkColor1 = chunkColor1;
this->load();
}
}
void DeviceSizeTable::setChunkColor2(const QColor &chunkColor2)
{
if (this->chunkColor2 != chunkColor2) {
this->chunkColor2 = chunkColor2;
this->load();
}
}
void DeviceSizeTable::setChunkColor3(const QColor &chunkColor3)
{
if (this->chunkColor3 != chunkColor3) {
this->chunkColor3 = chunkColor3;
this->load();
}
}
void DeviceSizeTable::setTextColor1(const QColor &textColor1)
{
if (this->textColor1 != textColor1) {
this->textColor1 = textColor1;
this->load();
}
}
void DeviceSizeTable::setTextColor2(const QColor &textColor2)
{
if (this->textColor2 != textColor2) {
this->textColor2 = textColor2;
this->load();
}
}
void DeviceSizeTable::setTextColor3(const QColor &textColor3)
{
if (this->textColor3 != textColor3) {
this->textColor3 = textColor3;
this->load();
}
}
void DeviceSizeTable::readData() void DeviceSizeTable::readData()
{ {
#if defined(Q_OS_UNIX) && !defined(Q_OS_WASM) #if defined(Q_OS_UNIX) && !defined(Q_OS_WASM)
@ -292,3 +170,125 @@ QSize DeviceSizeTable::minimumSizeHint() const
{ {
return QSize(200, 150); return QSize(200, 150);
} }
QColor DeviceSizeTable::getBgColor() const
{
return this->bgColor;
}
void DeviceSizeTable::setBgColor(const QColor &bgColor)
{
if (this->bgColor != bgColor) {
this->bgColor = bgColor;
this->load();
}
}
QColor DeviceSizeTable::getChunkColor1() const
{
return this->chunkColor1;
}
void DeviceSizeTable::setChunkColor1(const QColor &chunkColor1)
{
if (this->chunkColor1 != chunkColor1) {
this->chunkColor1 = chunkColor1;
this->load();
}
}
QColor DeviceSizeTable::getChunkColor2() const
{
return this->chunkColor2;
}
void DeviceSizeTable::setChunkColor2(const QColor &chunkColor2)
{
if (this->chunkColor2 != chunkColor2) {
this->chunkColor2 = chunkColor2;
this->load();
}
}
QColor DeviceSizeTable::getChunkColor3() const
{
return this->chunkColor3;
}
void DeviceSizeTable::setChunkColor3(const QColor &chunkColor3)
{
if (this->chunkColor3 != chunkColor3) {
this->chunkColor3 = chunkColor3;
this->load();
}
}
QColor DeviceSizeTable::getTextColor1() const
{
return this->textColor1;
}
void DeviceSizeTable::setTextColor1(const QColor &textColor1)
{
if (this->textColor1 != textColor1) {
this->textColor1 = textColor1;
this->load();
}
}
QColor DeviceSizeTable::getTextColor2() const
{
return this->textColor2;
}
void DeviceSizeTable::setTextColor2(const QColor &textColor2)
{
if (this->textColor2 != textColor2) {
this->textColor2 = textColor2;
this->load();
}
}
QColor DeviceSizeTable::getTextColor3() const
{
return this->textColor3;
}
void DeviceSizeTable::setTextColor3(const QColor &textColor3)
{
if (this->textColor3 != textColor3) {
this->textColor3 = textColor3;
this->load();
}
}
void DeviceSizeTable::load()
{
//清空原有数据
int row = this->rowCount();
for (int i = 0; i < row; ++i) {
this->removeRow(0);
}
#ifdef Q_OS_WIN
QFileInfoList list = QDir::drives();
foreach (QFileInfo dir, list) {
QString dirName = dir.absolutePath();
LPCWSTR lpcwstrDriver = (LPCWSTR)dirName.utf16();
ULARGE_INTEGER liFreeBytesAvailable, liTotalBytes, liTotalFreeBytes;
if (GetDiskFreeSpaceEx(lpcwstrDriver, &liFreeBytesAvailable, &liTotalBytes, &liTotalFreeBytes)) {
QString use = QString::number((double)(liTotalBytes.QuadPart - liTotalFreeBytes.QuadPart) / GB, 'f', 1);
use += "G";
QString free = QString::number((double) liTotalFreeBytes.QuadPart / GB, 'f', 1);
free += "G";
QString all = QString::number((double) liTotalBytes.QuadPart / GB, 'f', 1);
all += "G";
int percent = 100 - ((double)liTotalFreeBytes.QuadPart / liTotalBytes.QuadPart) * 100;
insertSize(dirName, use, free, all, percent);
}
}
#elif defined(Q_OS_UNIX) && !defined(Q_OS_WASM)
process->start("df", QStringList() << "-h");
#endif
}

View File

@ -26,6 +26,7 @@ class DeviceSizeTable : public QTableWidget
Q_PROPERTY(QColor chunkColor1 READ getChunkColor1 WRITE setChunkColor1) Q_PROPERTY(QColor chunkColor1 READ getChunkColor1 WRITE setChunkColor1)
Q_PROPERTY(QColor chunkColor2 READ getChunkColor2 WRITE setChunkColor2) Q_PROPERTY(QColor chunkColor2 READ getChunkColor2 WRITE setChunkColor2)
Q_PROPERTY(QColor chunkColor3 READ getChunkColor3 WRITE setChunkColor3) Q_PROPERTY(QColor chunkColor3 READ getChunkColor3 WRITE setChunkColor3)
Q_PROPERTY(QColor textColor1 READ getTextColor1 WRITE setTextColor1) Q_PROPERTY(QColor textColor1 READ getTextColor1 WRITE setTextColor1)
Q_PROPERTY(QColor textColor2 READ getTextColor2 WRITE setTextColor2) Q_PROPERTY(QColor textColor2 READ getTextColor2 WRITE setTextColor2)
Q_PROPERTY(QColor textColor3 READ getTextColor3 WRITE setTextColor3) Q_PROPERTY(QColor textColor3 READ getTextColor3 WRITE setTextColor3)
@ -34,15 +35,16 @@ public:
explicit DeviceSizeTable(QWidget *parent = 0); explicit DeviceSizeTable(QWidget *parent = 0);
private: private:
QProcess *process; //执行命令进程 QProcess *process; //执行命令进程
QColor bgColor; //背景颜色 QColor bgColor; //背景颜色
QColor chunkColor1; //进度颜色1 QColor chunkColor1; //进度颜色1
QColor chunkColor2; //进度颜色2 QColor chunkColor2; //进度颜色2
QColor chunkColor3; //进度颜色3 QColor chunkColor3; //进度颜色3
QColor textColor1; //文字颜色1
QColor textColor2; //文字颜色2 QColor textColor1; //文字颜色1
QColor textColor3; //文字颜色3 QColor textColor2; //文字颜色2
QColor textColor3; //文字颜色3
private slots: private slots:
void readData(); void readData();
@ -50,34 +52,42 @@ private slots:
void insertSize(const QString &name, const QString &use, const QString &free, const QString &all, int percent); void insertSize(const QString &name, const QString &use, const QString &free, const QString &all, int percent);
public: public:
QColor getBgColor() const; //默认尺寸和最小尺寸
QColor getChunkColor1() const; QSize sizeHint() const;
QColor getChunkColor2() const; QSize minimumSizeHint() const;
QColor getChunkColor3() const;
QColor getTextColor1() const;
QColor getTextColor2() const;
QColor getTextColor3() const;
QSize sizeHint() const; //获取和设置背景颜色
QSize minimumSizeHint() const; QColor getBgColor() const;
void setBgColor(const QColor &bgColor);
//获取和设置进度颜色1
QColor getChunkColor1() const;
void setChunkColor1(const QColor &chunkColor1);
//获取和设置进度颜色2
QColor getChunkColor2() const;
void setChunkColor2(const QColor &chunkColor2);
//获取和设置进度颜色3
QColor getChunkColor3() const;
void setChunkColor3(const QColor &chunkColor3);
//获取和设置文字颜色1
QColor getTextColor1() const;
void setTextColor1(const QColor &textColor1);
//获取和设置文字颜色2
QColor getTextColor2() const;
void setTextColor2(const QColor &textColor2);
//获取和设置文字颜色3
QColor getTextColor3() const;
void setTextColor3(const QColor &textColor3);
public Q_SLOTS: public Q_SLOTS:
//载入容量 //载入容量
void load(); void load();
//设置背景颜色
void setBgColor(const QColor &bgColor);
//设置进度颜色
void setChunkColor1(const QColor &chunkColor1);
void setChunkColor2(const QColor &chunkColor2);
void setChunkColor3(const QColor &chunkColor3);
//设置文字颜色
void setTextColor1(const QColor &textColor1);
void setTextColor2(const QColor &textColor2);
void setTextColor3(const QColor &textColor3);
Q_SIGNALS: Q_SIGNALS:
void sdcardReceive(const QString &sdcardName); void sdcardReceive(const QString &sdcardName);
void udiskReceive(const QString &udiskName); void udiskReceive(const QString &udiskName);

View File

@ -36,16 +36,6 @@ void ImageSwitch::paintEvent(QPaintEvent *)
painter.drawImage(point, img); painter.drawImage(point, img);
} }
bool ImageSwitch::getChecked() const
{
return isChecked;
}
ImageSwitch::ButtonStyle ImageSwitch::getButtonStyle() const
{
return this->buttonStyle;
}
QSize ImageSwitch::sizeHint() const QSize ImageSwitch::sizeHint() const
{ {
return QSize(87, 28); return QSize(87, 28);
@ -56,6 +46,11 @@ QSize ImageSwitch::minimumSizeHint() const
return QSize(87, 28); return QSize(87, 28);
} }
bool ImageSwitch::getChecked() const
{
return isChecked;
}
void ImageSwitch::setChecked(bool isChecked) void ImageSwitch::setChecked(bool isChecked)
{ {
if (this->isChecked != isChecked) { if (this->isChecked != isChecked) {
@ -65,6 +60,11 @@ void ImageSwitch::setChecked(bool isChecked)
} }
} }
ImageSwitch::ButtonStyle ImageSwitch::getButtonStyle() const
{
return this->buttonStyle;
}
void ImageSwitch::setButtonStyle(const ImageSwitch::ButtonStyle &buttonStyle) void ImageSwitch::setButtonStyle(const ImageSwitch::ButtonStyle &buttonStyle)
{ {
if (this->buttonStyle != buttonStyle) { if (this->buttonStyle != buttonStyle) {

View File

@ -36,24 +36,24 @@ protected:
void paintEvent(QPaintEvent *event); void paintEvent(QPaintEvent *event);
private: private:
bool isChecked; bool isChecked; //是否选中
ButtonStyle buttonStyle; ButtonStyle buttonStyle; //按钮样式
QString imgOffFile; QString imgOffFile; //关闭图片
QString imgOnFile; QString imgOnFile; //开启图片
QString imgFile; QString imgFile; //当前图片
public: public:
bool getChecked() const; //默认尺寸和最小尺寸
ButtonStyle getButtonStyle() const; QSize sizeHint() const;
QSize minimumSizeHint() const;
QSize sizeHint() const; //获取和设置是否选中
QSize minimumSizeHint() const; bool getChecked() const;
public Q_SLOTS:
//设置是否选中
void setChecked(bool isChecked); void setChecked(bool isChecked);
//设置按钮样式
//获取和设置按钮样式
ButtonStyle getButtonStyle() const;
void setButtonStyle(const ImageSwitch::ButtonStyle &buttonStyle); void setButtonStyle(const ImageSwitch::ButtonStyle &buttonStyle);
Q_SIGNALS: Q_SIGNALS:

View File

@ -144,11 +144,6 @@ void IPAddress::textChanged(const QString &text)
ip = QString("%1.%2.%3.%4").arg(txtIP1->text()).arg(txtIP2->text()).arg(txtIP3->text()).arg(txtIP4->text()); ip = QString("%1.%2.%3.%4").arg(txtIP1->text()).arg(txtIP2->text()).arg(txtIP3->text()).arg(txtIP4->text());
} }
QString IPAddress::getIP() const
{
return this->ip;
}
QSize IPAddress::sizeHint() const QSize IPAddress::sizeHint() const
{ {
return QSize(250, 20); return QSize(250, 20);
@ -159,6 +154,11 @@ QSize IPAddress::minimumSizeHint() const
return QSize(30, 10); return QSize(30, 10);
} }
QString IPAddress::getIP() const
{
return this->ip;
}
void IPAddress::setIP(const QString &ip) void IPAddress::setIP(const QString &ip)
{ {
//先检测IP地址是否合法 //先检测IP地址是否合法

View File

@ -52,15 +52,14 @@ private slots:
void textChanged(const QString &text); void textChanged(const QString &text);
public: public:
//获取IP地址 //默认尺寸和最小尺寸
QString getIP() const; QSize sizeHint() const;
QSize minimumSizeHint() const;
QSize sizeHint() const; //获取和设置IP地址
QSize minimumSizeHint() const; QString getIP() const;
public Q_SLOTS:
//设置IP地址
void setIP(const QString &ip); void setIP(const QString &ip);
//清空 //清空
void clear(); void clear();
@ -70,7 +69,6 @@ public Q_SLOTS:
void setBorderColor(const QString &borderColor); void setBorderColor(const QString &borderColor);
//设置边框圆角角度 //设置边框圆角角度
void setBorderRadius(int borderRadius); void setBorderRadius(int borderRadius);
}; };
#endif // IPADDRESS_H #endif // IPADDRESS_H

Binary file not shown.

View File

@ -185,71 +185,6 @@ void LightButton::drawOverlay(QPainter *painter)
painter->restore(); painter->restore();
} }
QString LightButton::getText() const
{
return this->text;
}
QColor LightButton::getTextColor() const
{
return this->textColor;
}
QColor LightButton::getAlarmColor() const
{
return this->alarmColor;
}
QColor LightButton::getNormalColor() const
{
return this->normalColor;
}
QColor LightButton::getBorderOutColorStart() const
{
return this->borderOutColorStart;
}
QColor LightButton::getBorderOutColorEnd() const
{
return this->borderOutColorEnd;
}
QColor LightButton::getBorderInColorStart() const
{
return this->borderInColorStart;
}
QColor LightButton::getBorderInColorEnd() const
{
return this->borderInColorEnd;
}
QColor LightButton::getBgColor() const
{
return this->bgColor;
}
bool LightButton::getCanMove() const
{
return this->canMove;
}
bool LightButton::getShowRect() const
{
return this->showRect;
}
bool LightButton::getShowOverlay() const
{
return this->showOverlay;
}
QColor LightButton::getOverlayColor() const
{
return this->overlayColor;
}
QSize LightButton::sizeHint() const QSize LightButton::sizeHint() const
{ {
return QSize(100, 100); return QSize(100, 100);
@ -260,6 +195,11 @@ QSize LightButton::minimumSizeHint() const
return QSize(10, 10); return QSize(10, 10);
} }
QString LightButton::getText() const
{
return this->text;
}
void LightButton::setText(const QString &text) void LightButton::setText(const QString &text)
{ {
if (this->text != text) { if (this->text != text) {
@ -268,6 +208,11 @@ void LightButton::setText(const QString &text)
} }
} }
QColor LightButton::getTextColor() const
{
return this->textColor;
}
void LightButton::setTextColor(const QColor &textColor) void LightButton::setTextColor(const QColor &textColor)
{ {
if (this->textColor != textColor) { if (this->textColor != textColor) {
@ -276,6 +221,11 @@ void LightButton::setTextColor(const QColor &textColor)
} }
} }
QColor LightButton::getAlarmColor() const
{
return this->alarmColor;
}
void LightButton::setAlarmColor(const QColor &alarmColor) void LightButton::setAlarmColor(const QColor &alarmColor)
{ {
if (this->alarmColor != alarmColor) { if (this->alarmColor != alarmColor) {
@ -284,6 +234,11 @@ void LightButton::setAlarmColor(const QColor &alarmColor)
} }
} }
QColor LightButton::getNormalColor() const
{
return this->normalColor;
}
void LightButton::setNormalColor(const QColor &normalColor) void LightButton::setNormalColor(const QColor &normalColor)
{ {
if (this->normalColor != normalColor) { if (this->normalColor != normalColor) {
@ -292,6 +247,11 @@ void LightButton::setNormalColor(const QColor &normalColor)
} }
} }
QColor LightButton::getBorderOutColorStart() const
{
return this->borderOutColorStart;
}
void LightButton::setBorderOutColorStart(const QColor &borderOutColorStart) void LightButton::setBorderOutColorStart(const QColor &borderOutColorStart)
{ {
if (this->borderOutColorStart != borderOutColorStart) { if (this->borderOutColorStart != borderOutColorStart) {
@ -300,6 +260,11 @@ void LightButton::setBorderOutColorStart(const QColor &borderOutColorStart)
} }
} }
QColor LightButton::getBorderOutColorEnd() const
{
return this->borderOutColorEnd;
}
void LightButton::setBorderOutColorEnd(const QColor &borderOutColorEnd) void LightButton::setBorderOutColorEnd(const QColor &borderOutColorEnd)
{ {
if (this->borderOutColorEnd != borderOutColorEnd) { if (this->borderOutColorEnd != borderOutColorEnd) {
@ -308,6 +273,11 @@ void LightButton::setBorderOutColorEnd(const QColor &borderOutColorEnd)
} }
} }
QColor LightButton::getBorderInColorStart() const
{
return this->borderInColorStart;
}
void LightButton::setBorderInColorStart(const QColor &borderInColorStart) void LightButton::setBorderInColorStart(const QColor &borderInColorStart)
{ {
if (this->borderInColorStart != borderInColorStart) { if (this->borderInColorStart != borderInColorStart) {
@ -316,6 +286,11 @@ void LightButton::setBorderInColorStart(const QColor &borderInColorStart)
} }
} }
QColor LightButton::getBorderInColorEnd() const
{
return this->borderInColorEnd;
}
void LightButton::setBorderInColorEnd(const QColor &borderInColorEnd) void LightButton::setBorderInColorEnd(const QColor &borderInColorEnd)
{ {
if (this->borderInColorEnd != borderInColorEnd) { if (this->borderInColorEnd != borderInColorEnd) {
@ -324,6 +299,11 @@ void LightButton::setBorderInColorEnd(const QColor &borderInColorEnd)
} }
} }
QColor LightButton::getBgColor() const
{
return this->bgColor;
}
void LightButton::setBgColor(const QColor &bgColor) void LightButton::setBgColor(const QColor &bgColor)
{ {
if (this->bgColor != bgColor) { if (this->bgColor != bgColor) {
@ -332,6 +312,11 @@ void LightButton::setBgColor(const QColor &bgColor)
} }
} }
bool LightButton::getCanMove() const
{
return this->canMove;
}
void LightButton::setCanMove(bool canMove) void LightButton::setCanMove(bool canMove)
{ {
if (this->canMove != canMove) { if (this->canMove != canMove) {
@ -340,6 +325,11 @@ void LightButton::setCanMove(bool canMove)
} }
} }
bool LightButton::getShowRect() const
{
return this->showRect;
}
void LightButton::setShowRect(bool showRect) void LightButton::setShowRect(bool showRect)
{ {
if (this->showRect != showRect) { if (this->showRect != showRect) {
@ -348,6 +338,11 @@ void LightButton::setShowRect(bool showRect)
} }
} }
bool LightButton::getShowOverlay() const
{
return this->showOverlay;
}
void LightButton::setShowOverlay(bool showOverlay) void LightButton::setShowOverlay(bool showOverlay)
{ {
if (this->showOverlay != showOverlay) { if (this->showOverlay != showOverlay) {
@ -356,6 +351,11 @@ void LightButton::setShowOverlay(bool showOverlay)
} }
} }
QColor LightButton::getOverlayColor() const
{
return this->overlayColor;
}
void LightButton::setOverlayColor(const QColor &overlayColor) void LightButton::setOverlayColor(const QColor &overlayColor)
{ {
if (this->overlayColor != overlayColor) { if (this->overlayColor != overlayColor) {

View File

@ -55,78 +55,84 @@ protected:
void drawOverlay(QPainter *painter); void drawOverlay(QPainter *painter);
private: private:
QString text; //文本 QString text; //文本
QColor textColor; //文字颜色 QColor textColor; //文字颜色
QColor alarmColor; //报警颜色 QColor alarmColor; //报警颜色
QColor normalColor; //正常颜色 QColor normalColor; //正常颜色
QColor borderOutColorStart; //外边框渐变开始颜色 QColor borderOutColorStart; //外边框渐变开始颜色
QColor borderOutColorEnd; //外边框渐变结束颜色 QColor borderOutColorEnd; //外边框渐变结束颜色
QColor borderInColorStart; //里边框渐变开始颜色 QColor borderInColorStart; //里边框渐变开始颜色
QColor borderInColorEnd; //里边框渐变结束颜色 QColor borderInColorEnd; //里边框渐变结束颜色
QColor bgColor; //背景颜色 QColor bgColor; //背景颜色
bool showRect; //显示成矩形 bool showRect; //显示成矩形
bool canMove; //是否能够移动 bool canMove; //是否能够移动
bool showOverlay; //是否显示遮罩层 bool showOverlay; //是否显示遮罩层
QColor overlayColor; //遮罩层颜色 QColor overlayColor; //遮罩层颜色
bool pressed; //鼠标是否按下 bool pressed; //鼠标是否按下
QPoint lastPoint; //鼠标最后按下坐标 QPoint lastPoint; //鼠标最后按下坐标
bool isAlarm; //是否报警 bool isAlarm; //是否报警
QTimer *timerAlarm; //定时器切换颜色 QTimer *timerAlarm; //定时器切换颜色
public: public:
QString getText() const; //默认尺寸和最小尺寸
QColor getTextColor() const; QSize sizeHint() const;
QColor getAlarmColor() const; QSize minimumSizeHint() const;
QColor getNormalColor() const;
QColor getBorderOutColorStart() const; //获取和设置文本
QColor getBorderOutColorEnd() const; QString getText() const;
QColor getBorderInColorStart() const;
QColor getBorderInColorEnd() const;
QColor getBgColor() const;
bool getCanMove() const;
bool getShowRect() const;
bool getShowOverlay() const;
QColor getOverlayColor() const;
QSize sizeHint() const;
QSize minimumSizeHint() const;
public Q_SLOTS:
//设置文本
void setText(const QString &text); void setText(const QString &text);
//设置文本颜色
//获取和设置文本颜色
QColor getTextColor() const;
void setTextColor(const QColor &textColor); void setTextColor(const QColor &textColor);
//设置报警颜色+正常颜色 //获取和设置报警颜色
QColor getAlarmColor() const;
void setAlarmColor(const QColor &alarmColor); void setAlarmColor(const QColor &alarmColor);
//获取和设置正常颜色
QColor getNormalColor() const;
void setNormalColor(const QColor &normalColor); void setNormalColor(const QColor &normalColor);
//设置外边框渐变颜色 //获取和设置外边框渐变颜色
QColor getBorderOutColorStart() const;
void setBorderOutColorStart(const QColor &borderOutColorStart); void setBorderOutColorStart(const QColor &borderOutColorStart);
QColor getBorderOutColorEnd() const;
void setBorderOutColorEnd(const QColor &borderOutColorEnd); void setBorderOutColorEnd(const QColor &borderOutColorEnd);
//设置里边框渐变颜色 //获取和设置里边框渐变颜色
QColor getBorderInColorStart() const;
void setBorderInColorStart(const QColor &borderInColorStart); void setBorderInColorStart(const QColor &borderInColorStart);
QColor getBorderInColorEnd() const;
void setBorderInColorEnd(const QColor &borderInColorEnd); void setBorderInColorEnd(const QColor &borderInColorEnd);
//设置背景色 //获取和设置背景色
QColor getBgColor() const;
void setBgColor(const QColor &bgColor); void setBgColor(const QColor &bgColor);
//设置是否可移动 //获取和设置是否可移动
bool getCanMove() const;
void setCanMove(bool canMove); void setCanMove(bool canMove);
//设置是否显示矩形
//获取和设置是否显示矩形
bool getShowRect() const;
void setShowRect(bool showRect); void setShowRect(bool showRect);
//设置是否显示遮罩层
//获取和设置是否显示遮罩层
bool getShowOverlay() const;
void setShowOverlay(bool showOverlay); void setShowOverlay(bool showOverlay);
//设置遮罩层颜色
//获取和设置遮罩层颜色
QColor getOverlayColor() const;
void setOverlayColor(const QColor &overlayColor); void setOverlayColor(const QColor &overlayColor);
public Q_SLOTS:
//设置为绿色 //设置为绿色
void setGreen(); void setGreen();
//设置为红色 //设置为红色
@ -139,6 +145,7 @@ public Q_SLOTS:
void setGray(); void setGray();
//设置为蓝色 //设置为蓝色
void setBlue(); void setBlue();
//设置为淡蓝色 //设置为淡蓝色
void setLightBlue(); void setLightBlue();
//设置为淡红色 //设置为淡红色

View File

@ -249,136 +249,6 @@ void NavButton::drawTriangle(QPainter *painter)
painter->restore(); painter->restore();
} }
int NavButton::getPaddingLeft() const
{
return this->paddingLeft;
}
int NavButton::getPaddingRight() const
{
return this->paddingRight;
}
int NavButton::getPaddingTop() const
{
return this->paddingTop;
}
int NavButton::getPaddingBottom() const
{
return this->paddingBottom;
}
NavButton::TextAlign NavButton::getTextAlign() const
{
return this->textAlign;
}
bool NavButton::getShowTriangle() const
{
return this->showTriangle;
}
int NavButton::getTriangleLen() const
{
return this->triangleLen;
}
NavButton::TrianglePosition NavButton::getTrianglePosition() const
{
return this->trianglePosition;
}
QColor NavButton::getTriangleColor() const
{
return this->triangleColor;
}
bool NavButton::getShowIcon() const
{
return this->showIcon;
}
int NavButton::getIconSpace() const
{
return this->iconSpace;
}
QSize NavButton::getIconSize() const
{
return this->iconSize;
}
QPixmap NavButton::getIconNormal() const
{
return this->iconNormal;
}
QPixmap NavButton::getIconHover() const
{
return this->iconHover;
}
QPixmap NavButton::getIconCheck() const
{
return this->iconCheck;
}
bool NavButton::getShowLine() const
{
return this->showLine;
}
int NavButton::getLineSpace() const
{
return this->lineSpace;
}
int NavButton::getLineWidth() const
{
return this->lineWidth;
}
NavButton::LinePosition NavButton::getLinePosition() const
{
return this->linePosition;
}
QColor NavButton::getLineColor() const
{
return this->lineColor;
}
QColor NavButton::getNormalBgColor() const
{
return this->normalBgColor;
}
QColor NavButton::getHoverBgColor() const
{
return this->hoverBgColor;
}
QColor NavButton::getCheckBgColor() const
{
return this->checkBgColor;
}
QColor NavButton::getNormalTextColor() const
{
return this->normalTextColor;
}
QColor NavButton::getHoverTextColor() const
{
return this->hoverTextColor;
}
QColor NavButton::getCheckTextColor() const
{
return this->checkTextColor;
}
QSize NavButton::sizeHint() const QSize NavButton::sizeHint() const
{ {
return QSize(100, 30); return QSize(100, 30);
@ -389,6 +259,11 @@ QSize NavButton::minimumSizeHint() const
return QSize(20, 10); return QSize(20, 10);
} }
int NavButton::getPaddingLeft() const
{
return this->paddingLeft;
}
void NavButton::setPaddingLeft(int paddingLeft) void NavButton::setPaddingLeft(int paddingLeft)
{ {
if (this->paddingLeft != paddingLeft) { if (this->paddingLeft != paddingLeft) {
@ -397,6 +272,11 @@ void NavButton::setPaddingLeft(int paddingLeft)
} }
} }
int NavButton::getPaddingRight() const
{
return this->paddingRight;
}
void NavButton::setPaddingRight(int paddingRight) void NavButton::setPaddingRight(int paddingRight)
{ {
if (this->paddingRight != paddingRight) { if (this->paddingRight != paddingRight) {
@ -405,6 +285,11 @@ void NavButton::setPaddingRight(int paddingRight)
} }
} }
int NavButton::getPaddingTop() const
{
return this->paddingTop;
}
void NavButton::setPaddingTop(int paddingTop) void NavButton::setPaddingTop(int paddingTop)
{ {
if (this->paddingTop != paddingTop) { if (this->paddingTop != paddingTop) {
@ -413,6 +298,11 @@ void NavButton::setPaddingTop(int paddingTop)
} }
} }
int NavButton::getPaddingBottom() const
{
return this->paddingBottom;
}
void NavButton::setPaddingBottom(int paddingBottom) void NavButton::setPaddingBottom(int paddingBottom)
{ {
if (this->paddingBottom != paddingBottom) { if (this->paddingBottom != paddingBottom) {
@ -435,6 +325,11 @@ void NavButton::setPadding(int paddingLeft, int paddingRight, int paddingTop, in
this->update(); this->update();
} }
NavButton::TextAlign NavButton::getTextAlign() const
{
return this->textAlign;
}
void NavButton::setTextAlign(const NavButton::TextAlign &textAlign) void NavButton::setTextAlign(const NavButton::TextAlign &textAlign)
{ {
if (this->textAlign != textAlign) { if (this->textAlign != textAlign) {
@ -443,6 +338,11 @@ void NavButton::setTextAlign(const NavButton::TextAlign &textAlign)
} }
} }
bool NavButton::getShowTriangle() const
{
return this->showTriangle;
}
void NavButton::setShowTriangle(bool showTriangle) void NavButton::setShowTriangle(bool showTriangle)
{ {
if (this->showTriangle != showTriangle) { if (this->showTriangle != showTriangle) {
@ -451,6 +351,11 @@ void NavButton::setShowTriangle(bool showTriangle)
} }
} }
int NavButton::getTriangleLen() const
{
return this->triangleLen;
}
void NavButton::setTriangleLen(int triangleLen) void NavButton::setTriangleLen(int triangleLen)
{ {
if (this->triangleLen != triangleLen) { if (this->triangleLen != triangleLen) {
@ -459,6 +364,11 @@ void NavButton::setTriangleLen(int triangleLen)
} }
} }
NavButton::TrianglePosition NavButton::getTrianglePosition() const
{
return this->trianglePosition;
}
void NavButton::setTrianglePosition(const NavButton::TrianglePosition &trianglePosition) void NavButton::setTrianglePosition(const NavButton::TrianglePosition &trianglePosition)
{ {
if (this->trianglePosition != trianglePosition) { if (this->trianglePosition != trianglePosition) {
@ -467,6 +377,11 @@ void NavButton::setTrianglePosition(const NavButton::TrianglePosition &triangleP
} }
} }
QColor NavButton::getTriangleColor() const
{
return this->triangleColor;
}
void NavButton::setTriangleColor(const QColor &triangleColor) void NavButton::setTriangleColor(const QColor &triangleColor)
{ {
if (this->triangleColor != triangleColor) { if (this->triangleColor != triangleColor) {
@ -475,6 +390,11 @@ void NavButton::setTriangleColor(const QColor &triangleColor)
} }
} }
bool NavButton::getShowIcon() const
{
return this->showIcon;
}
void NavButton::setShowIcon(bool showIcon) void NavButton::setShowIcon(bool showIcon)
{ {
if (this->showIcon != showIcon) { if (this->showIcon != showIcon) {
@ -483,6 +403,11 @@ void NavButton::setShowIcon(bool showIcon)
} }
} }
int NavButton::getIconSpace() const
{
return this->iconSpace;
}
void NavButton::setIconSpace(int iconSpace) void NavButton::setIconSpace(int iconSpace)
{ {
if (this->iconSpace != iconSpace) { if (this->iconSpace != iconSpace) {
@ -491,6 +416,11 @@ void NavButton::setIconSpace(int iconSpace)
} }
} }
QSize NavButton::getIconSize() const
{
return this->iconSize;
}
void NavButton::setIconSize(const QSize &iconSize) void NavButton::setIconSize(const QSize &iconSize)
{ {
if (this->iconSize != iconSize) { if (this->iconSize != iconSize) {
@ -499,24 +429,44 @@ void NavButton::setIconSize(const QSize &iconSize)
} }
} }
QPixmap NavButton::getIconNormal() const
{
return this->iconNormal;
}
void NavButton::setIconNormal(const QPixmap &iconNormal) void NavButton::setIconNormal(const QPixmap &iconNormal)
{ {
this->iconNormal = iconNormal; this->iconNormal = iconNormal;
this->update(); this->update();
} }
QPixmap NavButton::getIconHover() const
{
return this->iconHover;
}
void NavButton::setIconHover(const QPixmap &iconHover) void NavButton::setIconHover(const QPixmap &iconHover)
{ {
this->iconHover = iconHover; this->iconHover = iconHover;
this->update(); this->update();
} }
QPixmap NavButton::getIconCheck() const
{
return this->iconCheck;
}
void NavButton::setIconCheck(const QPixmap &iconCheck) void NavButton::setIconCheck(const QPixmap &iconCheck)
{ {
this->iconCheck = iconCheck; this->iconCheck = iconCheck;
this->update(); this->update();
} }
bool NavButton::getShowLine() const
{
return this->showLine;
}
void NavButton::setShowLine(bool showLine) void NavButton::setShowLine(bool showLine)
{ {
if (this->showLine != showLine) { if (this->showLine != showLine) {
@ -525,6 +475,11 @@ void NavButton::setShowLine(bool showLine)
} }
} }
int NavButton::getLineSpace() const
{
return this->lineSpace;
}
void NavButton::setLineSpace(int lineSpace) void NavButton::setLineSpace(int lineSpace)
{ {
if (this->lineSpace != lineSpace) { if (this->lineSpace != lineSpace) {
@ -533,6 +488,11 @@ void NavButton::setLineSpace(int lineSpace)
} }
} }
int NavButton::getLineWidth() const
{
return this->lineWidth;
}
void NavButton::setLineWidth(int lineWidth) void NavButton::setLineWidth(int lineWidth)
{ {
if (this->lineWidth != lineWidth) { if (this->lineWidth != lineWidth) {
@ -541,6 +501,11 @@ void NavButton::setLineWidth(int lineWidth)
} }
} }
NavButton::LinePosition NavButton::getLinePosition() const
{
return this->linePosition;
}
void NavButton::setLinePosition(const NavButton::LinePosition &linePosition) void NavButton::setLinePosition(const NavButton::LinePosition &linePosition)
{ {
if (this->linePosition != linePosition) { if (this->linePosition != linePosition) {
@ -549,6 +514,11 @@ void NavButton::setLinePosition(const NavButton::LinePosition &linePosition)
} }
} }
QColor NavButton::getLineColor() const
{
return this->lineColor;
}
void NavButton::setLineColor(const QColor &lineColor) void NavButton::setLineColor(const QColor &lineColor)
{ {
if (this->lineColor != lineColor) { if (this->lineColor != lineColor) {
@ -557,6 +527,11 @@ void NavButton::setLineColor(const QColor &lineColor)
} }
} }
QColor NavButton::getNormalBgColor() const
{
return this->normalBgColor;
}
void NavButton::setNormalBgColor(const QColor &normalBgColor) void NavButton::setNormalBgColor(const QColor &normalBgColor)
{ {
if (this->normalBgColor != normalBgColor) { if (this->normalBgColor != normalBgColor) {
@ -565,6 +540,11 @@ void NavButton::setNormalBgColor(const QColor &normalBgColor)
} }
} }
QColor NavButton::getHoverBgColor() const
{
return this->hoverBgColor;
}
void NavButton::setHoverBgColor(const QColor &hoverBgColor) void NavButton::setHoverBgColor(const QColor &hoverBgColor)
{ {
if (this->hoverBgColor != hoverBgColor) { if (this->hoverBgColor != hoverBgColor) {
@ -573,6 +553,11 @@ void NavButton::setHoverBgColor(const QColor &hoverBgColor)
} }
} }
QColor NavButton::getCheckBgColor() const
{
return this->checkBgColor;
}
void NavButton::setCheckBgColor(const QColor &checkBgColor) void NavButton::setCheckBgColor(const QColor &checkBgColor)
{ {
if (this->checkBgColor != checkBgColor) { if (this->checkBgColor != checkBgColor) {
@ -581,6 +566,11 @@ void NavButton::setCheckBgColor(const QColor &checkBgColor)
} }
} }
QColor NavButton::getNormalTextColor() const
{
return this->normalTextColor;
}
void NavButton::setNormalTextColor(const QColor &normalTextColor) void NavButton::setNormalTextColor(const QColor &normalTextColor)
{ {
if (this->normalTextColor != normalTextColor) { if (this->normalTextColor != normalTextColor) {
@ -589,6 +579,12 @@ void NavButton::setNormalTextColor(const QColor &normalTextColor)
} }
} }
QColor NavButton::getHoverTextColor() const
{
return this->hoverTextColor;
}
void NavButton::setHoverTextColor(const QColor &hoverTextColor) void NavButton::setHoverTextColor(const QColor &hoverTextColor)
{ {
if (this->hoverTextColor != hoverTextColor) { if (this->hoverTextColor != hoverTextColor) {
@ -597,6 +593,11 @@ void NavButton::setHoverTextColor(const QColor &hoverTextColor)
} }
} }
QColor NavButton::getCheckTextColor() const
{
return this->checkTextColor;
}
void NavButton::setCheckTextColor(const QColor &checkTextColor) void NavButton::setCheckTextColor(const QColor &checkTextColor)
{ {
if (this->checkTextColor != checkTextColor) { if (this->checkTextColor != checkTextColor) {

View File

@ -102,135 +102,154 @@ protected:
void drawTriangle(QPainter *painter); void drawTriangle(QPainter *painter);
private: private:
int paddingLeft; //文字左侧间隔 int paddingLeft; //文字左侧间隔
int paddingRight; //文字右侧间隔 int paddingRight; //文字右侧间隔
int paddingTop; //文字顶部间隔 int paddingTop; //文字顶部间隔
int paddingBottom; //文字底部间隔 int paddingBottom; //文字底部间隔
TextAlign textAlign; //文字对齐 TextAlign textAlign; //文字对齐
bool showTriangle; //显示倒三角 bool showTriangle; //显示倒三角
int triangleLen; //倒三角边长 int triangleLen; //倒三角边长
TrianglePosition trianglePosition; //倒三角位置 TrianglePosition trianglePosition;//倒三角位置
QColor triangleColor; //倒三角颜色 QColor triangleColor; //倒三角颜色
bool showIcon; //显示图标 bool showIcon; //显示图标
int iconSpace; //图标间隔 int iconSpace; //图标间隔
QSize iconSize; //图标尺寸 QSize iconSize; //图标尺寸
QPixmap iconNormal; //正常图标 QPixmap iconNormal; //正常图标
QPixmap iconHover; //悬停图标 QPixmap iconHover; //悬停图标
QPixmap iconCheck; //选中图标 QPixmap iconCheck; //选中图标
bool showLine; //显示线条 bool showLine; //显示线条
int lineSpace; //线条间隔 int lineSpace; //线条间隔
int lineWidth; //线条宽度 int lineWidth; //线条宽度
LinePosition linePosition; //线条位置 LinePosition linePosition; //线条位置
QColor lineColor; //线条颜色 QColor lineColor; //线条颜色
QColor normalBgColor; //正常背景颜色 QColor normalBgColor; //正常背景颜色
QColor hoverBgColor; //悬停背景颜色 QColor hoverBgColor; //悬停背景颜色
QColor checkBgColor; //选中背景颜色 QColor checkBgColor; //选中背景颜色
QColor normalTextColor; //正常文字颜色 QColor normalTextColor; //正常文字颜色
QColor hoverTextColor; //悬停文字颜色 QColor hoverTextColor; //悬停文字颜色
QColor checkTextColor; //选中文字颜色 QColor checkTextColor; //选中文字颜色
QBrush normalBgBrush; //正常背景画刷 QBrush normalBgBrush; //正常背景画刷
QBrush hoverBgBrush; //悬停背景画刷 QBrush hoverBgBrush; //悬停背景画刷
QBrush checkBgBrush; //选中背景画刷 QBrush checkBgBrush; //选中背景画刷
bool hover; //悬停标志位 bool hover; //悬停标志位
public: public:
int getPaddingLeft() const; //默认尺寸和最小尺寸
int getPaddingRight() const; QSize sizeHint() const;
int getPaddingTop() const; QSize minimumSizeHint() const;
int getPaddingBottom() const;
TextAlign getTextAlign() const;
bool getShowTriangle() const; //获取和设置文字左侧间隔
int getTriangleLen() const; int getPaddingLeft() const;
TrianglePosition getTrianglePosition()const;
QColor getTriangleColor() const;
bool getShowIcon() const;
int getIconSpace() const;
QSize getIconSize() const;
QPixmap getIconNormal() const;
QPixmap getIconHover() const;
QPixmap getIconCheck() const;
bool getShowLine() const;
int getLineSpace() const;
int getLineWidth() const;
LinePosition getLinePosition() const;
QColor getLineColor() const;
QColor getNormalBgColor() const;
QColor getHoverBgColor() const;
QColor getCheckBgColor() const;
QColor getNormalTextColor() const;
QColor getHoverTextColor() const;
QColor getCheckTextColor() const;
QSize sizeHint() const;
QSize minimumSizeHint() const;
public Q_SLOTS:
//设置文字间隔
void setPaddingLeft(int paddingLeft); void setPaddingLeft(int paddingLeft);
//获取和设置文字左侧间隔
int getPaddingRight() const;
void setPaddingRight(int paddingRight); void setPaddingRight(int paddingRight);
//获取和设置文字顶部间隔
int getPaddingTop() const;
void setPaddingTop(int paddingTop); void setPaddingTop(int paddingTop);
//获取和设置文字底部间隔
int getPaddingBottom() const;
void setPaddingBottom(int paddingBottom); void setPaddingBottom(int paddingBottom);
//设置边距
void setPadding(int padding); void setPadding(int padding);
void setPadding(int paddingLeft, int paddingRight, int paddingTop, int paddingBottom); void setPadding(int paddingLeft, int paddingRight, int paddingTop, int paddingBottom);
//设置文字对齐 //获取和设置文字对齐
TextAlign getTextAlign() const;
void setTextAlign(const TextAlign &textAlign); void setTextAlign(const TextAlign &textAlign);
//设置显示倒三角 //获取和设置显示倒三角
bool getShowTriangle() const;
void setShowTriangle(bool showTriangle); void setShowTriangle(bool showTriangle);
//设置倒三角边长
//获取和设置倒三角边长
int getTriangleLen() const;
void setTriangleLen(int triangleLen); void setTriangleLen(int triangleLen);
//设置倒三角位置
//获取和设置倒三角位置
TrianglePosition getTrianglePosition() const;
void setTrianglePosition(const TrianglePosition &trianglePosition); void setTrianglePosition(const TrianglePosition &trianglePosition);
//设置倒三角颜色
//获取和设置倒三角颜色
QColor getTriangleColor() const;
void setTriangleColor(const QColor &triangleColor); void setTriangleColor(const QColor &triangleColor);
//设置显示图标 //获取和设置显示图标
bool getShowIcon() const;
void setShowIcon(bool showIcon); void setShowIcon(bool showIcon);
//设置图标间隔
//获取和设置图标间隔
int getIconSpace() const;
void setIconSpace(int iconSpace); void setIconSpace(int iconSpace);
//设置图标尺寸
//获取和设置图标尺寸
QSize getIconSize() const;
void setIconSize(const QSize &iconSize); void setIconSize(const QSize &iconSize);
//设置正常图标
//获取和设置正常图标
QPixmap getIconNormal() const;
void setIconNormal(const QPixmap &iconNormal); void setIconNormal(const QPixmap &iconNormal);
//设置悬停图标
//获取和设置悬停图标
QPixmap getIconHover() const;
void setIconHover(const QPixmap &iconHover); void setIconHover(const QPixmap &iconHover);
//设置按下图标
//获取和设置按下图标
QPixmap getIconCheck() const;
void setIconCheck(const QPixmap &iconCheck); void setIconCheck(const QPixmap &iconCheck);
//设置显示线条 //获取和设置显示线条
bool getShowLine() const;
void setShowLine(bool showLine); void setShowLine(bool showLine);
//设置线条间隔
//获取和设置线条间隔
int getLineSpace() const;
void setLineSpace(int lineSpace); void setLineSpace(int lineSpace);
//设置线条宽度
//获取和设置线条宽度
int getLineWidth() const;
void setLineWidth(int lineWidth); void setLineWidth(int lineWidth);
//设置线条位置
//获取和设置线条位置
LinePosition getLinePosition() const;
void setLinePosition(const LinePosition &linePosition); void setLinePosition(const LinePosition &linePosition);
//设置线条颜色
//获取和设置线条颜色
QColor getLineColor() const;
void setLineColor(const QColor &lineColor); void setLineColor(const QColor &lineColor);
//设置正常背景颜色 //获取和设置正常背景颜色
QColor getNormalBgColor() const;
void setNormalBgColor(const QColor &normalBgColor); void setNormalBgColor(const QColor &normalBgColor);
//设置悬停背景颜色
//获取和设置悬停背景颜色
QColor getHoverBgColor() const;
void setHoverBgColor(const QColor &hoverBgColor); void setHoverBgColor(const QColor &hoverBgColor);
//设置选中背景颜色
//获取和设置选中背景颜色
QColor getCheckBgColor() const;
void setCheckBgColor(const QColor &checkBgColor); void setCheckBgColor(const QColor &checkBgColor);
//设置正常文字颜色 //获取和设置正常文字颜色
QColor getNormalTextColor() const;
void setNormalTextColor(const QColor &normalTextColor); void setNormalTextColor(const QColor &normalTextColor);
//设置悬停文字颜色
//获取和设置悬停文字颜色
QColor getHoverTextColor() const;
void setHoverTextColor(const QColor &hoverTextColor); void setHoverTextColor(const QColor &hoverTextColor);
//设置选中文字颜色
//获取和设置选中文字颜色
QColor getCheckTextColor() const;
void setCheckTextColor(const QColor &checkTextColor); void setCheckTextColor(const QColor &checkTextColor);
//设置正常背景画刷 //设置正常背景画刷
@ -239,7 +258,6 @@ public Q_SLOTS:
void setHoverBgBrush(const QBrush &hoverBgBrush); void setHoverBgBrush(const QBrush &hoverBgBrush);
//设置选中背景画刷 //设置选中背景画刷
void setCheckBgBrush(const QBrush &checkBgBrush); void setCheckBgBrush(const QBrush &checkBgBrush);
}; };
#endif // NAVBUTTON_H #endif // NAVBUTTON_H

View File

@ -123,7 +123,7 @@ SaveLog::SaveLog(QObject *parent) : QObject(parent)
SaveLog::~SaveLog() SaveLog::~SaveLog()
{ {
file->close(); this->stop();
} }
void SaveLog::openFile(const QString &fileName) void SaveLog::openFile(const QString &fileName)

View File

@ -39,6 +39,11 @@ SaveRunTime::SaveRunTime(QObject *parent) : QObject(parent)
connect(timerSave, SIGNAL(timeout()), this, SLOT(saveLog())); connect(timerSave, SIGNAL(timeout()), this, SLOT(saveLog()));
} }
SaveRunTime::~SaveRunTime()
{
this->stop();
}
void SaveRunTime::getDiffValue(const QDateTime &startTime, const QDateTime &endTime, int &day, int &hour, int &minute) void SaveRunTime::getDiffValue(const QDateTime &startTime, const QDateTime &endTime, int &day, int &hour, int &minute)
{ {
qint64 sec = startTime.secsTo(endTime); qint64 sec = startTime.secsTo(endTime);

View File

@ -26,6 +26,7 @@ class SaveRunTime : public QObject
public: public:
static SaveRunTime *Instance(); static SaveRunTime *Instance();
explicit SaveRunTime(QObject *parent = 0); explicit SaveRunTime(QObject *parent = 0);
~SaveRunTime();
private: private:
static QScopedPointer<SaveRunTime> self; static QScopedPointer<SaveRunTime> self;

File diff suppressed because one or more lines are too long

Binary file not shown.

Before

Width:  |  Height:  |  Size: 48 KiB

After

Width:  |  Height:  |  Size: 50 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 55 KiB

After

Width:  |  Height:  |  Size: 44 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 57 KiB

After

Width:  |  Height:  |  Size: 47 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 58 KiB

After

Width:  |  Height:  |  Size: 50 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 51 KiB

After

Width:  |  Height:  |  Size: 56 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 54 KiB

After

Width:  |  Height:  |  Size: 41 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 56 KiB

After

Width:  |  Height:  |  Size: 50 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 50 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 117 KiB

After

Width:  |  Height:  |  Size: 63 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 147 KiB

After

Width:  |  Height:  |  Size: 117 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 147 KiB

View File

@ -44,11 +44,6 @@ void TrayIcon::iconIsActived(QSystemTrayIcon::ActivationReason reason)
} }
} }
bool TrayIcon::getVisible() const
{
return trayIcon->isVisible();
}
void TrayIcon::setExitDirect(bool exitDirect) void TrayIcon::setExitDirect(bool exitDirect)
{ {
if (this->exitDirect != exitDirect) { if (this->exitDirect != exitDirect) {
@ -93,6 +88,11 @@ void TrayIcon::setToolTip(const QString &tip)
trayIcon->setToolTip(tip); trayIcon->setToolTip(tip);
} }
bool TrayIcon::getVisible() const
{
return trayIcon->isVisible();
}
void TrayIcon::setVisible(bool visible) void TrayIcon::setVisible(bool visible)
{ {
trayIcon->setVisible(visible); trayIcon->setVisible(visible);

View File

@ -37,16 +37,11 @@ private slots:
void iconIsActived(QSystemTrayIcon::ActivationReason reason); void iconIsActived(QSystemTrayIcon::ActivationReason reason);
public: public:
bool getVisible() const;
public Q_SLOTS:
//设置是否直接退出,如果不是直接退出则发送信号给主界面 //设置是否直接退出,如果不是直接退出则发送信号给主界面
void setExitDirect(bool exitDirect); void setExitDirect(bool exitDirect);
//设置所属主窗体 //设置所属主窗体
void setMainWidget(QWidget *mainWidget); void setMainWidget(QWidget *mainWidget);
//显示主窗体
void showMainWidget();
//显示消息 //显示消息
void showMessage(const QString &title, const QString &msg, void showMessage(const QString &title, const QString &msg,
@ -56,10 +51,16 @@ public Q_SLOTS:
void setIcon(const QString &strIcon); void setIcon(const QString &strIcon);
//设置提示信息 //设置提示信息
void setToolTip(const QString &tip); void setToolTip(const QString &tip);
//设置是否可见
//获取和设置是否可见
bool getVisible() const;
void setVisible(bool visible); void setVisible(bool visible);
public Q_SLOTS:
//退出所有 //退出所有
void closeAll(); void closeAll();
//显示主窗体
void showMainWidget();
Q_SIGNALS: Q_SIGNALS:
void trayIconExit(); void trayIconExit();

View File

@ -44,11 +44,6 @@ void TrayIcon::iconIsActived(QSystemTrayIcon::ActivationReason reason)
} }
} }
bool TrayIcon::getVisible() const
{
return trayIcon->isVisible();
}
void TrayIcon::setExitDirect(bool exitDirect) void TrayIcon::setExitDirect(bool exitDirect)
{ {
if (this->exitDirect != exitDirect) { if (this->exitDirect != exitDirect) {
@ -93,6 +88,11 @@ void TrayIcon::setToolTip(const QString &tip)
trayIcon->setToolTip(tip); trayIcon->setToolTip(tip);
} }
bool TrayIcon::getVisible() const
{
return trayIcon->isVisible();
}
void TrayIcon::setVisible(bool visible) void TrayIcon::setVisible(bool visible)
{ {
trayIcon->setVisible(visible); trayIcon->setVisible(visible);

View File

@ -37,16 +37,11 @@ private slots:
void iconIsActived(QSystemTrayIcon::ActivationReason reason); void iconIsActived(QSystemTrayIcon::ActivationReason reason);
public: public:
bool getVisible() const;
public Q_SLOTS:
//设置是否直接退出,如果不是直接退出则发送信号给主界面 //设置是否直接退出,如果不是直接退出则发送信号给主界面
void setExitDirect(bool exitDirect); void setExitDirect(bool exitDirect);
//设置所属主窗体 //设置所属主窗体
void setMainWidget(QWidget *mainWidget); void setMainWidget(QWidget *mainWidget);
//显示主窗体
void showMainWidget();
//显示消息 //显示消息
void showMessage(const QString &title, const QString &msg, void showMessage(const QString &title, const QString &msg,
@ -56,10 +51,16 @@ public Q_SLOTS:
void setIcon(const QString &strIcon); void setIcon(const QString &strIcon);
//设置提示信息 //设置提示信息
void setToolTip(const QString &tip); void setToolTip(const QString &tip);
//设置是否可见
//获取和设置是否可见
bool getVisible() const;
void setVisible(bool visible); void setVisible(bool visible);
public Q_SLOTS:
//退出所有 //退出所有
void closeAll(); void closeAll();
//显示主窗体
void showMainWidget();
Q_SIGNALS: Q_SIGNALS:
void trayIconExit(); void trayIconExit();

View File

@ -44,36 +44,6 @@ void PanelWidget::resizeEvent(QResizeEvent *)
scrollArea->resize(this->size()); scrollArea->resize(this->size());
} }
int PanelWidget::getMargin() const
{
return this->margin;
}
int PanelWidget::getSpace() const
{
return this->space;
}
bool PanelWidget::getAutoWidth() const
{
return this->autoWidth;
}
bool PanelWidget::getAutoHeight() const
{
return this->autoHeight;
}
int PanelWidget::getColumnCount() const
{
return this->columnCount;
}
QList<QWidget *> PanelWidget::getWidgets() const
{
return this->widgets;
}
QSize PanelWidget::sizeHint() const QSize PanelWidget::sizeHint() const
{ {
return QSize(300, 200); return QSize(300, 200);
@ -89,6 +59,11 @@ void PanelWidget::setMargin(int left, int top, int right, int bottom)
gridLayout->setContentsMargins(left, top, right, bottom); gridLayout->setContentsMargins(left, top, right, bottom);
} }
int PanelWidget::getMargin() const
{
return this->margin;
}
void PanelWidget::setMargin(int margin) void PanelWidget::setMargin(int margin)
{ {
if (this->margin != margin) { if (this->margin != margin) {
@ -96,6 +71,11 @@ void PanelWidget::setMargin(int margin)
} }
} }
int PanelWidget::getSpace() const
{
return this->space;
}
void PanelWidget::setSpace(int space) void PanelWidget::setSpace(int space)
{ {
if (this->space != space) { if (this->space != space) {
@ -103,6 +83,11 @@ void PanelWidget::setSpace(int space)
} }
} }
bool PanelWidget::getAutoWidth() const
{
return this->autoWidth;
}
void PanelWidget::setAutoWidth(bool autoWidth) void PanelWidget::setAutoWidth(bool autoWidth)
{ {
if (this->autoWidth != autoWidth) { if (this->autoWidth != autoWidth) {
@ -110,6 +95,11 @@ void PanelWidget::setAutoWidth(bool autoWidth)
} }
} }
bool PanelWidget::getAutoHeight() const
{
return this->autoHeight;
}
void PanelWidget::setAutoHeight(bool autoHeight) void PanelWidget::setAutoHeight(bool autoHeight)
{ {
if (this->autoHeight != autoHeight) { if (this->autoHeight != autoHeight) {
@ -117,6 +107,11 @@ void PanelWidget::setAutoHeight(bool autoHeight)
} }
} }
int PanelWidget::getColumnCount() const
{
return this->columnCount;
}
void PanelWidget::setColumnCount(int columnCount) void PanelWidget::setColumnCount(int columnCount)
{ {
if (this->columnCount != columnCount) { if (this->columnCount != columnCount) {
@ -124,6 +119,11 @@ void PanelWidget::setColumnCount(int columnCount)
} }
} }
QList<QWidget *> PanelWidget::getWidgets() const
{
return this->widgets;
}
void PanelWidget::setWidgets(QList<QWidget *> widgets) void PanelWidget::setWidgets(QList<QWidget *> widgets)
{ {
this->widgets = widgets; this->widgets = widgets;

View File

@ -26,6 +26,7 @@ class PanelWidget : public QWidget
{ {
Q_OBJECT Q_OBJECT
Q_PROPERTY(int margin READ getMargin WRITE setMargin) Q_PROPERTY(int margin READ getMargin WRITE setMargin)
Q_PROPERTY(int space READ getSpace WRITE setSpace) Q_PROPERTY(int space READ getSpace WRITE setSpace)
Q_PROPERTY(bool autoWidth READ getAutoWidth WRITE setAutoWidth) Q_PROPERTY(bool autoWidth READ getAutoWidth WRITE setAutoWidth)
@ -39,52 +40,61 @@ protected:
void resizeEvent(QResizeEvent *); void resizeEvent(QResizeEvent *);
private: private:
QScrollArea *scrollArea; //滚动区域 QScrollArea *scrollArea; //滚动区域
QWidget *scrollAreaContents; //滚动区域载体 QWidget *scrollAreaContents;//滚动区域载体
QFrame *frame; //放置设备的框架,自动变宽变高 QFrame *frame; //放置设备的框架,自动变宽变高
QVBoxLayout *verticalLayout; //设备面板总布局 QVBoxLayout *verticalLayout;//设备面板总布局
QGridLayout *gridLayout; //设备表格布局 QGridLayout *gridLayout; //设备表格布局
QSpacerItem *hSpacer; //横向弹簧 QSpacerItem *hSpacer; //横向弹簧
QSpacerItem *vSpacer; //垂直弹簧 QSpacerItem *vSpacer; //垂直弹簧
int margin; //边距 int margin; //边距
int space; //设备之间的间隔 int space; //设备之间的间隔
bool autoWidth; //宽度自动拉伸 bool autoWidth; //宽度自动拉伸
bool autoHeight; //高度自动拉伸 bool autoHeight; //高度自动拉伸
int columnCount; //面板列数 int columnCount; //面板列数
QList<QWidget *> widgets; //设备面板对象集合 QList<QWidget *> widgets; //设备面板对象集合
public: public:
int getMargin() const; //默认尺寸和最小尺寸
int getSpace() const; QSize sizeHint() const;
bool getAutoWidth() const; QSize minimumSizeHint() const;
bool getAutoHeight() const;
int getColumnCount() const; //设置边距
QList<QWidget *> getWidgets() const;
QSize sizeHint() const;
QSize minimumSizeHint() const;
public Q_SLOTS:
//设置边距+间距
void setMargin(int left, int top, int right, int bottom); void setMargin(int left, int top, int right, int bottom);
//获取和设置边距
int getMargin() const;
void setMargin(int margin); void setMargin(int margin);
//获取和设置间距
int getSpace() const;
void setSpace(int space); void setSpace(int space);
//设置自动填充宽度+自动填充高度 //获取和设置自动填充宽度
bool getAutoWidth() const;
void setAutoWidth(bool autoWidth); void setAutoWidth(bool autoWidth);
//获取和设置自自动填充高度
bool getAutoHeight() const;
void setAutoHeight(bool autoHeight); void setAutoHeight(bool autoHeight);
//设置列数+窗体集合 //获取和设置列数
int getColumnCount() const;
void setColumnCount(int columnCount); void setColumnCount(int columnCount);
//获取和设置窗体集合
QList<QWidget *> getWidgets() const;
void setWidgets(QList<QWidget *> widgets); void setWidgets(QList<QWidget *> widgets);
//载入窗体集合+指定位置插入新窗体+移除指定的窗体+清空窗体 //载入窗体集合
void loadWidgets(); void loadWidgets();
//指定位置插入新窗体
void insertWidget(int index, QWidget *widget); void insertWidget(int index, QWidget *widget);
//移除指定的窗体
void removeWidget(QWidget *widget); void removeWidget(QWidget *widget);
//清空窗体
void clearWidgets(); void clearWidgets();
}; };

BIN
ui/ui.zip

Binary file not shown.

View File

@ -232,121 +232,6 @@ void LunarCalendarItem::drawLunar(QPainter *painter)
painter->restore(); painter->restore();
} }
bool LunarCalendarItem::getSelect() const
{
return this->select;
}
bool LunarCalendarItem::getShowLunar() const
{
return this->showLunar;
}
QString LunarCalendarItem::getBgImage() const
{
return this->bgImage;
}
LunarCalendarItem::SelectType LunarCalendarItem::getSelectType() const
{
return this->selectType;
}
QDate LunarCalendarItem::getDate() const
{
return this->date;
}
QString LunarCalendarItem::getLunar() const
{
return this->lunar;
}
LunarCalendarItem::DayType LunarCalendarItem::getDayType() const
{
return this->dayType;
}
QColor LunarCalendarItem::getBorderColor() const
{
return this->borderColor;
}
QColor LunarCalendarItem::getWeekColor() const
{
return this->weekColor;
}
QColor LunarCalendarItem::getSuperColor() const
{
return this->superColor;
}
QColor LunarCalendarItem::getLunarColor() const
{
return this->lunarColor;
}
QColor LunarCalendarItem::getCurrentTextColor() const
{
return this->currentTextColor;
}
QColor LunarCalendarItem::getOtherTextColor() const
{
return this->otherTextColor;
}
QColor LunarCalendarItem::getSelectTextColor() const
{
return this->selectTextColor;
}
QColor LunarCalendarItem::getHoverTextColor() const
{
return this->hoverTextColor;
}
QColor LunarCalendarItem::getCurrentLunarColor() const
{
return this->currentLunarColor;
}
QColor LunarCalendarItem::getOtherLunarColor() const
{
return this->otherLunarColor;
}
QColor LunarCalendarItem::getSelectLunarColor() const
{
return this->selectLunarColor;
}
QColor LunarCalendarItem::getHoverLunarColor() const
{
return this->hoverLunarColor;
}
QColor LunarCalendarItem::getCurrentBgColor() const
{
return this->currentBgColor;
}
QColor LunarCalendarItem::getOtherBgColor() const
{
return this->otherBgColor;
}
QColor LunarCalendarItem::getSelectBgColor() const
{
return this->selectBgColor;
}
QColor LunarCalendarItem::getHoverBgColor() const
{
return this->hoverBgColor;
}
QSize LunarCalendarItem::sizeHint() const QSize LunarCalendarItem::sizeHint() const
{ {
return QSize(100, 100); return QSize(100, 100);
@ -357,6 +242,11 @@ QSize LunarCalendarItem::minimumSizeHint() const
return QSize(20, 20); return QSize(20, 20);
} }
bool LunarCalendarItem::getSelect() const
{
return this->select;
}
void LunarCalendarItem::setSelect(bool select) void LunarCalendarItem::setSelect(bool select)
{ {
if (this->select != select) { if (this->select != select) {
@ -365,6 +255,11 @@ void LunarCalendarItem::setSelect(bool select)
} }
} }
bool LunarCalendarItem::getShowLunar() const
{
return this->showLunar;
}
void LunarCalendarItem::setShowLunar(bool showLunar) void LunarCalendarItem::setShowLunar(bool showLunar)
{ {
if (this->showLunar != showLunar) { if (this->showLunar != showLunar) {
@ -373,6 +268,11 @@ void LunarCalendarItem::setShowLunar(bool showLunar)
} }
} }
QString LunarCalendarItem::getBgImage() const
{
return this->bgImage;
}
void LunarCalendarItem::setBgImage(const QString &bgImage) void LunarCalendarItem::setBgImage(const QString &bgImage)
{ {
if (this->bgImage != bgImage) { if (this->bgImage != bgImage) {
@ -381,6 +281,11 @@ void LunarCalendarItem::setBgImage(const QString &bgImage)
} }
} }
LunarCalendarItem::SelectType LunarCalendarItem::getSelectType() const
{
return this->selectType;
}
void LunarCalendarItem::setSelectType(const LunarCalendarItem::SelectType &selectType) void LunarCalendarItem::setSelectType(const LunarCalendarItem::SelectType &selectType)
{ {
if (this->selectType != selectType) { if (this->selectType != selectType) {
@ -389,6 +294,11 @@ void LunarCalendarItem::setSelectType(const LunarCalendarItem::SelectType &selec
} }
} }
QDate LunarCalendarItem::getDate() const
{
return this->date;
}
void LunarCalendarItem::setDate(const QDate &date) void LunarCalendarItem::setDate(const QDate &date)
{ {
if (this->date != date) { if (this->date != date) {
@ -397,6 +307,11 @@ void LunarCalendarItem::setDate(const QDate &date)
} }
} }
QString LunarCalendarItem::getLunar() const
{
return this->lunar;
}
void LunarCalendarItem::setLunar(const QString &lunar) void LunarCalendarItem::setLunar(const QString &lunar)
{ {
if (this->lunar != lunar) { if (this->lunar != lunar) {
@ -405,6 +320,11 @@ void LunarCalendarItem::setLunar(const QString &lunar)
} }
} }
LunarCalendarItem::DayType LunarCalendarItem::getDayType() const
{
return this->dayType;
}
void LunarCalendarItem::setDayType(const LunarCalendarItem::DayType &dayType) void LunarCalendarItem::setDayType(const LunarCalendarItem::DayType &dayType)
{ {
if (this->dayType != dayType) { if (this->dayType != dayType) {
@ -421,6 +341,11 @@ void LunarCalendarItem::setDate(const QDate &date, const QString &lunar, const D
this->update(); this->update();
} }
QColor LunarCalendarItem::getBorderColor() const
{
return this->borderColor;
}
void LunarCalendarItem::setBorderColor(const QColor &borderColor) void LunarCalendarItem::setBorderColor(const QColor &borderColor)
{ {
if (this->borderColor != borderColor) { if (this->borderColor != borderColor) {
@ -429,6 +354,12 @@ void LunarCalendarItem::setBorderColor(const QColor &borderColor)
} }
} }
QColor LunarCalendarItem::getWeekColor() const
{
return this->weekColor;
}
void LunarCalendarItem::setWeekColor(const QColor &weekColor) void LunarCalendarItem::setWeekColor(const QColor &weekColor)
{ {
if (this->weekColor != weekColor) { if (this->weekColor != weekColor) {
@ -437,6 +368,11 @@ void LunarCalendarItem::setWeekColor(const QColor &weekColor)
} }
} }
QColor LunarCalendarItem::getSuperColor() const
{
return this->superColor;
}
void LunarCalendarItem::setSuperColor(const QColor &superColor) void LunarCalendarItem::setSuperColor(const QColor &superColor)
{ {
if (this->superColor != superColor) { if (this->superColor != superColor) {
@ -445,6 +381,11 @@ void LunarCalendarItem::setSuperColor(const QColor &superColor)
} }
} }
QColor LunarCalendarItem::getLunarColor() const
{
return this->lunarColor;
}
void LunarCalendarItem::setLunarColor(const QColor &lunarColor) void LunarCalendarItem::setLunarColor(const QColor &lunarColor)
{ {
if (this->lunarColor != lunarColor) { if (this->lunarColor != lunarColor) {
@ -453,6 +394,11 @@ void LunarCalendarItem::setLunarColor(const QColor &lunarColor)
} }
} }
QColor LunarCalendarItem::getCurrentTextColor() const
{
return this->currentTextColor;
}
void LunarCalendarItem::setCurrentTextColor(const QColor &currentTextColor) void LunarCalendarItem::setCurrentTextColor(const QColor &currentTextColor)
{ {
if (this->currentTextColor != currentTextColor) { if (this->currentTextColor != currentTextColor) {
@ -461,6 +407,11 @@ void LunarCalendarItem::setCurrentTextColor(const QColor &currentTextColor)
} }
} }
QColor LunarCalendarItem::getOtherTextColor() const
{
return this->otherTextColor;
}
void LunarCalendarItem::setOtherTextColor(const QColor &otherTextColor) void LunarCalendarItem::setOtherTextColor(const QColor &otherTextColor)
{ {
if (this->otherTextColor != otherTextColor) { if (this->otherTextColor != otherTextColor) {
@ -469,6 +420,11 @@ void LunarCalendarItem::setOtherTextColor(const QColor &otherTextColor)
} }
} }
QColor LunarCalendarItem::getSelectTextColor() const
{
return this->selectTextColor;
}
void LunarCalendarItem::setSelectTextColor(const QColor &selectTextColor) void LunarCalendarItem::setSelectTextColor(const QColor &selectTextColor)
{ {
if (this->selectTextColor != selectTextColor) { if (this->selectTextColor != selectTextColor) {
@ -477,6 +433,11 @@ void LunarCalendarItem::setSelectTextColor(const QColor &selectTextColor)
} }
} }
QColor LunarCalendarItem::getHoverTextColor() const
{
return this->hoverTextColor;
}
void LunarCalendarItem::setHoverTextColor(const QColor &hoverTextColor) void LunarCalendarItem::setHoverTextColor(const QColor &hoverTextColor)
{ {
if (this->hoverTextColor != hoverTextColor) { if (this->hoverTextColor != hoverTextColor) {
@ -485,6 +446,11 @@ void LunarCalendarItem::setHoverTextColor(const QColor &hoverTextColor)
} }
} }
QColor LunarCalendarItem::getCurrentLunarColor() const
{
return this->currentLunarColor;
}
void LunarCalendarItem::setCurrentLunarColor(const QColor &currentLunarColor) void LunarCalendarItem::setCurrentLunarColor(const QColor &currentLunarColor)
{ {
if (this->currentLunarColor != currentLunarColor) { if (this->currentLunarColor != currentLunarColor) {
@ -493,6 +459,12 @@ void LunarCalendarItem::setCurrentLunarColor(const QColor &currentLunarColor)
} }
} }
QColor LunarCalendarItem::getOtherLunarColor() const
{
return this->otherLunarColor;
}
void LunarCalendarItem::setOtherLunarColor(const QColor &otherLunarColor) void LunarCalendarItem::setOtherLunarColor(const QColor &otherLunarColor)
{ {
if (this->otherLunarColor != otherLunarColor) { if (this->otherLunarColor != otherLunarColor) {
@ -501,6 +473,11 @@ void LunarCalendarItem::setOtherLunarColor(const QColor &otherLunarColor)
} }
} }
QColor LunarCalendarItem::getSelectLunarColor() const
{
return this->selectLunarColor;
}
void LunarCalendarItem::setSelectLunarColor(const QColor &selectLunarColor) void LunarCalendarItem::setSelectLunarColor(const QColor &selectLunarColor)
{ {
if (this->selectLunarColor != selectLunarColor) { if (this->selectLunarColor != selectLunarColor) {
@ -509,6 +486,11 @@ void LunarCalendarItem::setSelectLunarColor(const QColor &selectLunarColor)
} }
} }
QColor LunarCalendarItem::getHoverLunarColor() const
{
return this->hoverLunarColor;
}
void LunarCalendarItem::setHoverLunarColor(const QColor &hoverLunarColor) void LunarCalendarItem::setHoverLunarColor(const QColor &hoverLunarColor)
{ {
if (this->hoverLunarColor != hoverLunarColor) { if (this->hoverLunarColor != hoverLunarColor) {
@ -517,6 +499,11 @@ void LunarCalendarItem::setHoverLunarColor(const QColor &hoverLunarColor)
} }
} }
QColor LunarCalendarItem::getCurrentBgColor() const
{
return this->currentBgColor;
}
void LunarCalendarItem::setCurrentBgColor(const QColor &currentBgColor) void LunarCalendarItem::setCurrentBgColor(const QColor &currentBgColor)
{ {
if (this->currentBgColor != currentBgColor) { if (this->currentBgColor != currentBgColor) {
@ -525,6 +512,12 @@ void LunarCalendarItem::setCurrentBgColor(const QColor &currentBgColor)
} }
} }
QColor LunarCalendarItem::getOtherBgColor() const
{
return this->otherBgColor;
}
void LunarCalendarItem::setOtherBgColor(const QColor &otherBgColor) void LunarCalendarItem::setOtherBgColor(const QColor &otherBgColor)
{ {
if (this->otherBgColor != otherBgColor) { if (this->otherBgColor != otherBgColor) {
@ -533,6 +526,11 @@ void LunarCalendarItem::setOtherBgColor(const QColor &otherBgColor)
} }
} }
QColor LunarCalendarItem::getSelectBgColor() const
{
return this->selectBgColor;
}
void LunarCalendarItem::setSelectBgColor(const QColor &selectBgColor) void LunarCalendarItem::setSelectBgColor(const QColor &selectBgColor)
{ {
if (this->selectBgColor != selectBgColor) { if (this->selectBgColor != selectBgColor) {
@ -541,6 +539,11 @@ void LunarCalendarItem::setSelectBgColor(const QColor &selectBgColor)
} }
} }
QColor LunarCalendarItem::getHoverBgColor() const
{
return this->hoverBgColor;
}
void LunarCalendarItem::setHoverBgColor(const QColor &hoverBgColor) void LunarCalendarItem::setHoverBgColor(const QColor &hoverBgColor)
{ {
if (this->hoverBgColor != hoverBgColor) { if (this->hoverBgColor != hoverBgColor) {

View File

@ -73,125 +73,137 @@ protected:
void drawLunar(QPainter *painter); void drawLunar(QPainter *painter);
private: private:
bool hover; //鼠标是否悬停 bool hover; //鼠标是否悬停
bool pressed; //鼠标是否按下 bool pressed; //鼠标是否按下
QStringList listDayName; //农历日期 QStringList listDayName; //农历日期
bool select; //是否选中 bool select; //是否选中
bool showLunar; //显示农历 bool showLunar; //显示农历
QString bgImage; //背景图片 QString bgImage; //背景图片
SelectType selectType; //选中模式 SelectType selectType; //选中模式
QDate date; //当前日期 QDate date; //当前日期
QString lunar; //农历信息 QString lunar; //农历信息
DayType dayType; //当前日类型 DayType dayType; //当前日类型
QColor borderColor; //边框颜色 QColor borderColor; //边框颜色
QColor weekColor; //周末颜色 QColor weekColor; //周末颜色
QColor superColor; //角标颜色 QColor superColor; //角标颜色
QColor lunarColor; //农历节日颜色 QColor lunarColor; //农历节日颜色
QColor currentTextColor; //当前月文字颜色 QColor currentTextColor; //当前月文字颜色
QColor otherTextColor; //其他月文字颜色 QColor otherTextColor; //其他月文字颜色
QColor selectTextColor; //选中日期文字颜色 QColor selectTextColor; //选中日期文字颜色
QColor hoverTextColor; //悬停日期文字颜色 QColor hoverTextColor; //悬停日期文字颜色
QColor currentLunarColor; //当前月农历文字颜色 QColor currentLunarColor; //当前月农历文字颜色
QColor otherLunarColor; //其他月农历文字颜色 QColor otherLunarColor; //其他月农历文字颜色
QColor selectLunarColor; //选中日期农历文字颜色 QColor selectLunarColor; //选中日期农历文字颜色
QColor hoverLunarColor; //悬停日期农历文字颜色 QColor hoverLunarColor; //悬停日期农历文字颜色
QColor currentBgColor; //当前月背景颜色 QColor currentBgColor; //当前月背景颜色
QColor otherBgColor; //其他月背景颜色 QColor otherBgColor; //其他月背景颜色
QColor selectBgColor; //选中日期背景颜色 QColor selectBgColor; //选中日期背景颜色
QColor hoverBgColor; //悬停日期背景颜色 QColor hoverBgColor; //悬停日期背景颜色
public: public:
bool getSelect() const; //默认尺寸和最小尺寸
bool getShowLunar() const; QSize sizeHint() const;
QString getBgImage() const; QSize minimumSizeHint() const;
SelectType getSelectType() const;
QDate getDate() const; //获取和设置是否选中
QString getLunar() const; bool getSelect() const;
DayType getDayType() const;
QColor getBorderColor() const;
QColor getWeekColor() const;
QColor getSuperColor() const;
QColor getLunarColor() const;
QColor getCurrentTextColor() const;
QColor getOtherTextColor() const;
QColor getSelectTextColor() const;
QColor getHoverTextColor() const;
QColor getCurrentLunarColor() const;
QColor getOtherLunarColor() const;
QColor getSelectLunarColor() const;
QColor getHoverLunarColor() const;
QColor getCurrentBgColor() const;
QColor getOtherBgColor() const;
QColor getSelectBgColor() const;
QColor getHoverBgColor() const;
QSize sizeHint() const;
QSize minimumSizeHint() const;
public Q_SLOTS:
//设置是否选中
void setSelect(bool select); void setSelect(bool select);
//设置是否显示农历信息
//获取和设置是否显示农历信息
bool getShowLunar() const;
void setShowLunar(bool showLunar); void setShowLunar(bool showLunar);
//设置背景图片
//获取和设置背景图片
QString getBgImage() const;
void setBgImage(const QString &bgImage); void setBgImage(const QString &bgImage);
//设置选中背景样式
//获取和设置选中背景样式
SelectType getSelectType() const;
void setSelectType(const SelectType &selectType); void setSelectType(const SelectType &selectType);
//设置日期 //获取和设置日期
QDate getDate() const;
void setDate(const QDate &date); void setDate(const QDate &date);
//设置农历
//获取和设置农历
QString getLunar() const;
void setLunar(const QString &lunar); void setLunar(const QString &lunar);
//设置类型
//获取和设置类型
DayType getDayType() const;
void setDayType(const DayType &dayType); void setDayType(const DayType &dayType);
//设置日期/农历/类型 //设置日期/农历/类型
void setDate(const QDate &date, const QString &lunar, const DayType &dayType); void setDate(const QDate &date, const QString &lunar, const DayType &dayType);
//设置边框颜色 //获取和设置边框颜色
QColor getBorderColor() const;
void setBorderColor(const QColor &borderColor); void setBorderColor(const QColor &borderColor);
//设置周末颜色
//获取和设置周末颜色
QColor getWeekColor() const;
void setWeekColor(const QColor &weekColor); void setWeekColor(const QColor &weekColor);
//设置角标颜色
//获取和设置角标颜色
QColor getSuperColor() const;
void setSuperColor(const QColor &superColor); void setSuperColor(const QColor &superColor);
//设置农历节日颜色
//获取和设置农历节日颜色
QColor getLunarColor() const;
void setLunarColor(const QColor &lunarColor); void setLunarColor(const QColor &lunarColor);
//设置当前月文字颜色 //获取和设置当前月文字颜色
QColor getCurrentTextColor() const;
void setCurrentTextColor(const QColor &currentTextColor); void setCurrentTextColor(const QColor &currentTextColor);
//设置其他月文字颜色
//获取和设置其他月文字颜色
QColor getOtherTextColor() const;
void setOtherTextColor(const QColor &otherTextColor); void setOtherTextColor(const QColor &otherTextColor);
//设置选中日期文字颜色
//获取和设置选中日期文字颜色
QColor getSelectTextColor() const;
void setSelectTextColor(const QColor &selectTextColor); void setSelectTextColor(const QColor &selectTextColor);
//设置悬停日期文字颜色
//获取和设置悬停日期文字颜色
QColor getHoverTextColor() const;
void setHoverTextColor(const QColor &hoverTextColor); void setHoverTextColor(const QColor &hoverTextColor);
//设置当前月农历文字颜色 //获取和设置当前月农历文字颜色
QColor getCurrentLunarColor() const;
void setCurrentLunarColor(const QColor &currentLunarColor); void setCurrentLunarColor(const QColor &currentLunarColor);
//设置其他月农历文字颜色
//获取和设置其他月农历文字颜色
QColor getOtherLunarColor() const;
void setOtherLunarColor(const QColor &otherLunarColor); void setOtherLunarColor(const QColor &otherLunarColor);
//设置选中日期农历文字颜色
//获取和设置选中日期农历文字颜色
QColor getSelectLunarColor() const;
void setSelectLunarColor(const QColor &selectLunarColor); void setSelectLunarColor(const QColor &selectLunarColor);
//设置悬停日期农历文字颜色
//获取和设置悬停日期农历文字颜色
QColor getHoverLunarColor() const;
void setHoverLunarColor(const QColor &hoverLunarColor); void setHoverLunarColor(const QColor &hoverLunarColor);
//设置当前月背景颜色 //获取和设置当前月背景颜色
QColor getCurrentBgColor() const;
void setCurrentBgColor(const QColor &currentBgColor); void setCurrentBgColor(const QColor &currentBgColor);
//设置其他月背景颜色
//获取和设置其他月背景颜色
QColor getOtherBgColor() const;
void setOtherBgColor(const QColor &otherBgColor); void setOtherBgColor(const QColor &otherBgColor);
//设置选中日期背景颜色
//获取和设置选中日期背景颜色
QColor getSelectBgColor() const;
void setSelectBgColor(const QColor &selectBgColor); void setSelectBgColor(const QColor &selectBgColor);
//设置悬停日期背景颜色
//获取和设置悬停日期背景颜色
QColor getHoverBgColor() const;
void setHoverBgColor(const QColor &hoverBgColor); void setHoverBgColor(const QColor &hoverBgColor);
Q_SIGNALS: Q_SIGNALS:

View File

@ -183,10 +183,10 @@ void LunarCalendarWidget::initWidget()
//逐个添加日标签 //逐个添加日标签
for (int i = 0; i < 42; ++i) { for (int i = 0; i < 42; ++i) {
LunarCalendarItem *lab = new LunarCalendarItem; LunarCalendarItem *item = new LunarCalendarItem;
connect(lab, SIGNAL(clicked(QDate, LunarCalendarItem::DayType)), this, SLOT(clicked(QDate, LunarCalendarItem::DayType))); connect(item, SIGNAL(clicked(QDate, LunarCalendarItem::DayType)), this, SLOT(clicked(QDate, LunarCalendarItem::DayType)));
layoutBody->addWidget(lab, i / 7, i % 7); layoutBody->addWidget(item, i / 7, i % 7);
dayItems.append(lab); items << item;
} }
//主布局 //主布局
@ -309,7 +309,7 @@ void LunarCalendarWidget::initDate()
QDate date(tempYear, tempMonth, tempDay); QDate date(tempYear, tempMonth, tempDay);
QString lunar = LunarCalendarInfo::Instance()->getLunarDay(tempYear, tempMonth, tempDay); QString lunar = LunarCalendarInfo::Instance()->getLunarDay(tempYear, tempMonth, tempDay);
dayItems.at(index)->setDate(date, lunar, LunarCalendarItem::DayType_MonthPre); items.at(index)->setDate(date, lunar, LunarCalendarItem::DayType_MonthPre);
} }
//纠正12月份后面部分偏差,12月份后面部分是下一年1月份 //纠正12月份后面部分偏差,12月份后面部分是下一年1月份
@ -327,7 +327,7 @@ void LunarCalendarWidget::initDate()
QDate date(tempYear, tempMonth, tempDay); QDate date(tempYear, tempMonth, tempDay);
QString lunar = LunarCalendarInfo::Instance()->getLunarDay(tempYear, tempMonth, tempDay); QString lunar = LunarCalendarInfo::Instance()->getLunarDay(tempYear, tempMonth, tempDay);
dayItems.at(index)->setDate(date, lunar, LunarCalendarItem::DayType_MonthNext); items.at(index)->setDate(date, lunar, LunarCalendarItem::DayType_MonthNext);
} }
//重新置为当前年月 //重新置为当前年月
@ -342,9 +342,9 @@ void LunarCalendarWidget::initDate()
QDate date(tempYear, tempMonth, tempDay); QDate date(tempYear, tempMonth, tempDay);
QString lunar = LunarCalendarInfo::Instance()->getLunarDay(tempYear, tempMonth, tempDay); QString lunar = LunarCalendarInfo::Instance()->getLunarDay(tempYear, tempMonth, tempDay);
if (0 == (i % 7) || 6 == (i % 7)) { if (0 == (i % 7) || 6 == (i % 7)) {
dayItems.at(index)->setDate(date, lunar, LunarCalendarItem::DayType_WeekEnd); items.at(index)->setDate(date, lunar, LunarCalendarItem::DayType_WeekEnd);
} else { } else {
dayItems.at(index)->setDate(date, lunar, LunarCalendarItem::DayType_MonthCurrent); items.at(index)->setDate(date, lunar, LunarCalendarItem::DayType_MonthCurrent);
} }
} }
@ -408,7 +408,7 @@ void LunarCalendarWidget::dayChanged(const QDate &date)
index = day + 6; index = day + 6;
} }
dayItems.at(i)->setSelect(i == index); items.at(i)->setSelect(i == index);
} }
//发送日期单击信号 //发送日期单击信号
@ -424,126 +424,6 @@ void LunarCalendarWidget::dateChanged(int year, int month, int day)
initDate(); initDate();
} }
LunarCalendarWidget::CalendarStyle LunarCalendarWidget::getCalendarStyle() const
{
return this->calendarStyle;
}
LunarCalendarWidget::WeekNameFormat LunarCalendarWidget::getWeekNameFormat() const
{
return this->weekNameFormat;
}
QDate LunarCalendarWidget::getDate() const
{
return this->date;
}
QColor LunarCalendarWidget::getWeekTextColor() const
{
return this->weekTextColor;
}
QColor LunarCalendarWidget::getWeekBgColor() const
{
return this->weekBgColor;
}
bool LunarCalendarWidget::getShowLunar() const
{
return this->showLunar;
}
QString LunarCalendarWidget::getBgImage() const
{
return this->bgImage;
}
LunarCalendarWidget::SelectType LunarCalendarWidget::getSelectType() const
{
return this->selectType;
}
QColor LunarCalendarWidget::getBorderColor() const
{
return this->borderColor;
}
QColor LunarCalendarWidget::getWeekColor() const
{
return this->weekColor;
}
QColor LunarCalendarWidget::getSuperColor() const
{
return this->superColor;
}
QColor LunarCalendarWidget::getLunarColor() const
{
return this->lunarColor;
}
QColor LunarCalendarWidget::getCurrentTextColor() const
{
return this->currentTextColor;
}
QColor LunarCalendarWidget::getOtherTextColor() const
{
return this->otherTextColor;
}
QColor LunarCalendarWidget::getSelectTextColor() const
{
return this->selectTextColor;
}
QColor LunarCalendarWidget::getHoverTextColor() const
{
return this->hoverTextColor;
}
QColor LunarCalendarWidget::getCurrentLunarColor() const
{
return this->currentLunarColor;
}
QColor LunarCalendarWidget::getOtherLunarColor() const
{
return this->otherLunarColor;
}
QColor LunarCalendarWidget::getSelectLunarColor() const
{
return this->selectLunarColor;
}
QColor LunarCalendarWidget::getHoverLunarColor() const
{
return this->hoverLunarColor;
}
QColor LunarCalendarWidget::getCurrentBgColor() const
{
return this->currentBgColor;
}
QColor LunarCalendarWidget::getOtherBgColor() const
{
return this->otherBgColor;
}
QColor LunarCalendarWidget::getSelectBgColor() const
{
return this->selectBgColor;
}
QColor LunarCalendarWidget::getHoverBgColor() const
{
return this->hoverBgColor;
}
QSize LunarCalendarWidget::sizeHint() const QSize LunarCalendarWidget::sizeHint() const
{ {
return QSize(600, 500); return QSize(600, 500);
@ -554,6 +434,335 @@ QSize LunarCalendarWidget::minimumSizeHint() const
return QSize(200, 150); return QSize(200, 150);
} }
LunarCalendarWidget::CalendarStyle LunarCalendarWidget::getCalendarStyle() const
{
return this->calendarStyle;
}
void LunarCalendarWidget::setCalendarStyle(const LunarCalendarWidget::CalendarStyle &calendarStyle)
{
if (this->calendarStyle != calendarStyle) {
this->calendarStyle = calendarStyle;
}
}
LunarCalendarWidget::WeekNameFormat LunarCalendarWidget::getWeekNameFormat() const
{
return this->weekNameFormat;
}
void LunarCalendarWidget::setWeekNameFormat(const LunarCalendarWidget::WeekNameFormat &weekNameFormat)
{
if (this->weekNameFormat != weekNameFormat) {
this->weekNameFormat = weekNameFormat;
QStringList listWeek;
if (weekNameFormat == WeekNameFormat_Short) {
listWeek << "" << "" << "" << "" << "" << "" << "";
} else if (weekNameFormat == WeekNameFormat_Normal) {
listWeek << "周日" << "周一" << "周二" << "周三" << "周四" << "周五" << "周六";
} else if (weekNameFormat == WeekNameFormat_Long) {
listWeek << "星期天" << "星期一" << "星期二" << "星期三" << "星期四" << "星期五" << "星期六";
} else if (weekNameFormat == WeekNameFormat_En) {
listWeek << "Sun" << "Mon" << "Tue" << "Wed" << "Thu" << "Fri" << "Sat";
}
//逐个添加日期文字
for (int i = 0; i < 7; ++i) {
labWeeks.at(i)->setText(listWeek.at(i));
}
}
}
QDate LunarCalendarWidget::getDate() const
{
return this->date;
}
void LunarCalendarWidget::setDate(const QDate &date)
{
if (this->date != date) {
this->date = date;
initDate();
}
}
QColor LunarCalendarWidget::getWeekTextColor() const
{
return this->weekTextColor;
}
void LunarCalendarWidget::setWeekTextColor(const QColor &weekTextColor)
{
if (this->weekTextColor != weekTextColor) {
this->weekTextColor = weekTextColor;
this->initStyle();
}
}
QColor LunarCalendarWidget::getWeekBgColor() const
{
return this->weekBgColor;
}
void LunarCalendarWidget::setWeekBgColor(const QColor &weekBgColor)
{
if (this->weekBgColor != weekBgColor) {
this->weekBgColor = weekBgColor;
this->initStyle();
}
}
bool LunarCalendarWidget::getShowLunar() const
{
return this->showLunar;
}
void LunarCalendarWidget::setShowLunar(bool showLunar)
{
if (this->showLunar != showLunar) {
this->showLunar = showLunar;
this->initStyle();
}
}
QString LunarCalendarWidget::getBgImage() const
{
return this->bgImage;
}
void LunarCalendarWidget::setBgImage(const QString &bgImage)
{
if (this->bgImage != bgImage) {
this->bgImage = bgImage;
this->initStyle();
}
}
LunarCalendarWidget::SelectType LunarCalendarWidget::getSelectType() const
{
return this->selectType;
}
void LunarCalendarWidget::setSelectType(const LunarCalendarWidget::SelectType &selectType)
{
if (this->selectType != selectType) {
this->selectType = selectType;
this->initStyle();
}
}
QColor LunarCalendarWidget::getBorderColor() const
{
return this->borderColor;
}
void LunarCalendarWidget::setBorderColor(const QColor &borderColor)
{
if (this->borderColor != borderColor) {
this->borderColor = borderColor;
this->initStyle();
}
}
QColor LunarCalendarWidget::getWeekColor() const
{
return this->weekColor;
}
void LunarCalendarWidget::setWeekColor(const QColor &weekColor)
{
if (this->weekColor != weekColor) {
this->weekColor = weekColor;
this->initStyle();
}
}
QColor LunarCalendarWidget::getSuperColor() const
{
return this->superColor;
}
void LunarCalendarWidget::setSuperColor(const QColor &superColor)
{
if (this->superColor != superColor) {
this->superColor = superColor;
this->initStyle();
}
}
QColor LunarCalendarWidget::getLunarColor() const
{
return this->lunarColor;
}
void LunarCalendarWidget::setLunarColor(const QColor &lunarColor)
{
if (this->lunarColor != lunarColor) {
this->lunarColor = lunarColor;
this->initStyle();
}
}
QColor LunarCalendarWidget::getCurrentTextColor() const
{
return this->currentTextColor;
}
void LunarCalendarWidget::setCurrentTextColor(const QColor &currentTextColor)
{
if (this->currentTextColor != currentTextColor) {
this->currentTextColor = currentTextColor;
this->initStyle();
}
}
QColor LunarCalendarWidget::getOtherTextColor() const
{
return this->otherTextColor;
}
void LunarCalendarWidget::setOtherTextColor(const QColor &otherTextColor)
{
if (this->otherTextColor != otherTextColor) {
this->otherTextColor = otherTextColor;
this->initStyle();
}
}
QColor LunarCalendarWidget::getSelectTextColor() const
{
return this->selectTextColor;
}
void LunarCalendarWidget::setSelectTextColor(const QColor &selectTextColor)
{
if (this->selectTextColor != selectTextColor) {
this->selectTextColor = selectTextColor;
this->initStyle();
}
}
QColor LunarCalendarWidget::getHoverTextColor() const
{
return this->hoverTextColor;
}
void LunarCalendarWidget::setHoverTextColor(const QColor &hoverTextColor)
{
if (this->hoverTextColor != hoverTextColor) {
this->hoverTextColor = hoverTextColor;
this->initStyle();
}
}
QColor LunarCalendarWidget::getCurrentLunarColor() const
{
return this->currentLunarColor;
}
void LunarCalendarWidget::setCurrentLunarColor(const QColor &currentLunarColor)
{
if (this->currentLunarColor != currentLunarColor) {
this->currentLunarColor = currentLunarColor;
this->initStyle();
}
}
QColor LunarCalendarWidget::getOtherLunarColor() const
{
return this->otherLunarColor;
}
void LunarCalendarWidget::setOtherLunarColor(const QColor &otherLunarColor)
{
if (this->otherLunarColor != otherLunarColor) {
this->otherLunarColor = otherLunarColor;
this->initStyle();
}
}
QColor LunarCalendarWidget::getSelectLunarColor() const
{
return this->selectLunarColor;
}
void LunarCalendarWidget::setSelectLunarColor(const QColor &selectLunarColor)
{
if (this->selectLunarColor != selectLunarColor) {
this->selectLunarColor = selectLunarColor;
this->initStyle();
}
}
QColor LunarCalendarWidget::getHoverLunarColor() const
{
return this->hoverLunarColor;
}
void LunarCalendarWidget::setHoverLunarColor(const QColor &hoverLunarColor)
{
if (this->hoverLunarColor != hoverLunarColor) {
this->hoverLunarColor = hoverLunarColor;
this->initStyle();
}
}
QColor LunarCalendarWidget::getCurrentBgColor() const
{
return this->currentBgColor;
}
void LunarCalendarWidget::setCurrentBgColor(const QColor &currentBgColor)
{
if (this->currentBgColor != currentBgColor) {
this->currentBgColor = currentBgColor;
this->initStyle();
}
}
QColor LunarCalendarWidget::getOtherBgColor() const
{
return this->otherBgColor;
}
void LunarCalendarWidget::setOtherBgColor(const QColor &otherBgColor)
{
if (this->otherBgColor != otherBgColor) {
this->otherBgColor = otherBgColor;
this->initStyle();
}
}
QColor LunarCalendarWidget::getSelectBgColor() const
{
return this->selectBgColor;
}
void LunarCalendarWidget::setSelectBgColor(const QColor &selectBgColor)
{
if (this->selectBgColor != selectBgColor) {
this->selectBgColor = selectBgColor;
this->initStyle();
}
}
QColor LunarCalendarWidget::getHoverBgColor() const
{
return this->hoverBgColor;
}
void LunarCalendarWidget::setHoverBgColor(const QColor &hoverBgColor)
{
if (this->hoverBgColor != hoverBgColor) {
this->hoverBgColor = hoverBgColor;
this->initStyle();
}
}
//显示上一年 //显示上一年
void LunarCalendarWidget::showPreviousYear() void LunarCalendarWidget::showPreviousYear()
{ {
@ -627,209 +836,3 @@ void LunarCalendarWidget::showToday()
initDate(); initDate();
dayChanged(date); dayChanged(date);
} }
void LunarCalendarWidget::setCalendarStyle(const LunarCalendarWidget::CalendarStyle &calendarStyle)
{
if (this->calendarStyle != calendarStyle) {
this->calendarStyle = calendarStyle;
}
}
void LunarCalendarWidget::setWeekNameFormat(const LunarCalendarWidget::WeekNameFormat &weekNameFormat)
{
if (this->weekNameFormat != weekNameFormat) {
this->weekNameFormat = weekNameFormat;
QStringList listWeek;
if (weekNameFormat == WeekNameFormat_Short) {
listWeek << "" << "" << "" << "" << "" << "" << "";
} else if (weekNameFormat == WeekNameFormat_Normal) {
listWeek << "周日" << "周一" << "周二" << "周三" << "周四" << "周五" << "周六";
} else if (weekNameFormat == WeekNameFormat_Long) {
listWeek << "星期天" << "星期一" << "星期二" << "星期三" << "星期四" << "星期五" << "星期六";
} else if (weekNameFormat == WeekNameFormat_En) {
listWeek << "Sun" << "Mon" << "Tue" << "Wed" << "Thu" << "Fri" << "Sat";
}
//逐个添加日期文字
for (int i = 0; i < 7; ++i) {
labWeeks.at(i)->setText(listWeek.at(i));
}
}
}
void LunarCalendarWidget::setDate(const QDate &date)
{
if (this->date != date) {
this->date = date;
initDate();
}
}
void LunarCalendarWidget::setWeekTextColor(const QColor &weekTextColor)
{
if (this->weekTextColor != weekTextColor) {
this->weekTextColor = weekTextColor;
initStyle();
}
}
void LunarCalendarWidget::setWeekBgColor(const QColor &weekBgColor)
{
if (this->weekBgColor != weekBgColor) {
this->weekBgColor = weekBgColor;
initStyle();
}
}
void LunarCalendarWidget::setShowLunar(bool showLunar)
{
if (this->showLunar != showLunar) {
this->showLunar = showLunar;
initStyle();
}
}
void LunarCalendarWidget::setBgImage(const QString &bgImage)
{
if (this->bgImage != bgImage) {
this->bgImage = bgImage;
initStyle();
}
}
void LunarCalendarWidget::setSelectType(const LunarCalendarWidget::SelectType &selectType)
{
if (this->selectType != selectType) {
this->selectType = selectType;
initStyle();
}
}
void LunarCalendarWidget::setBorderColor(const QColor &borderColor)
{
if (this->borderColor != borderColor) {
this->borderColor = borderColor;
initStyle();
}
}
void LunarCalendarWidget::setWeekColor(const QColor &weekColor)
{
if (this->weekColor != weekColor) {
this->weekColor = weekColor;
initStyle();
}
}
void LunarCalendarWidget::setSuperColor(const QColor &superColor)
{
if (this->superColor != superColor) {
this->superColor = superColor;
initStyle();
}
}
void LunarCalendarWidget::setLunarColor(const QColor &lunarColor)
{
if (this->lunarColor != lunarColor) {
this->lunarColor = lunarColor;
initStyle();
}
}
void LunarCalendarWidget::setCurrentTextColor(const QColor &currentTextColor)
{
if (this->currentTextColor != currentTextColor) {
this->currentTextColor = currentTextColor;
initStyle();
}
}
void LunarCalendarWidget::setOtherTextColor(const QColor &otherTextColor)
{
if (this->otherTextColor != otherTextColor) {
this->otherTextColor = otherTextColor;
initStyle();
}
}
void LunarCalendarWidget::setSelectTextColor(const QColor &selectTextColor)
{
if (this->selectTextColor != selectTextColor) {
this->selectTextColor = selectTextColor;
initStyle();
}
}
void LunarCalendarWidget::setHoverTextColor(const QColor &hoverTextColor)
{
if (this->hoverTextColor != hoverTextColor) {
this->hoverTextColor = hoverTextColor;
initStyle();
}
}
void LunarCalendarWidget::setCurrentLunarColor(const QColor &currentLunarColor)
{
if (this->currentLunarColor != currentLunarColor) {
this->currentLunarColor = currentLunarColor;
initStyle();
}
}
void LunarCalendarWidget::setOtherLunarColor(const QColor &otherLunarColor)
{
if (this->otherLunarColor != otherLunarColor) {
this->otherLunarColor = otherLunarColor;
initStyle();
}
}
void LunarCalendarWidget::setSelectLunarColor(const QColor &selectLunarColor)
{
if (this->selectLunarColor != selectLunarColor) {
this->selectLunarColor = selectLunarColor;
initStyle();
}
}
void LunarCalendarWidget::setHoverLunarColor(const QColor &hoverLunarColor)
{
if (this->hoverLunarColor != hoverLunarColor) {
this->hoverLunarColor = hoverLunarColor;
initStyle();
}
}
void LunarCalendarWidget::setCurrentBgColor(const QColor &currentBgColor)
{
if (this->currentBgColor != currentBgColor) {
this->currentBgColor = currentBgColor;
initStyle();
}
}
void LunarCalendarWidget::setOtherBgColor(const QColor &otherBgColor)
{
if (this->otherBgColor != otherBgColor) {
this->otherBgColor = otherBgColor;
initStyle();
}
}
void LunarCalendarWidget::setSelectBgColor(const QColor &selectBgColor)
{
if (this->selectBgColor != selectBgColor) {
this->selectBgColor = selectBgColor;
initStyle();
}
}
void LunarCalendarWidget::setHoverBgColor(const QColor &hoverBgColor)
{
if (this->hoverBgColor != hoverBgColor) {
this->hoverBgColor = hoverBgColor;
initStyle();
}
}

View File

@ -90,43 +90,43 @@ public:
~LunarCalendarWidget(); ~LunarCalendarWidget();
private: private:
QFont iconFont; //图形字体 QFont iconFont; //图形字体
bool btnClick; //按钮单击,避开下拉选择重复触发 bool btnClick; //按钮单击,避开下拉选择重复触发
QComboBox *cboxYear; //年份下拉框 QComboBox *cboxYear; //年份下拉框
QComboBox *cboxMonth; //月份下拉框 QComboBox *cboxMonth; //月份下拉框
QList<QLabel *> labWeeks; //顶部星期名称 QList<QLabel *> labWeeks; //顶部星期名称
QList<LunarCalendarItem *> dayItems;//日期元素 QList<LunarCalendarItem *> items;//日期元素
CalendarStyle calendarStyle; //整体样式 CalendarStyle calendarStyle; //整体样式
WeekNameFormat weekNameFormat; //星期名称格式 WeekNameFormat weekNameFormat; //星期名称格式
QDate date; //当前日期 QDate date; //当前日期
QColor weekTextColor; //星期名称文字颜色 QColor weekTextColor; //星期名称文字颜色
QColor weekBgColor; //星期名称背景色 QColor weekBgColor; //星期名称背景色
bool showLunar; //显示农历 bool showLunar; //显示农历
QString bgImage; //背景图片 QString bgImage; //背景图片
SelectType selectType; //选中模式 SelectType selectType; //选中模式
QColor borderColor; //边框颜色 QColor borderColor; //边框颜色
QColor weekColor; //周末颜色 QColor weekColor; //周末颜色
QColor superColor; //角标颜色 QColor superColor; //角标颜色
QColor lunarColor; //农历节日颜色 QColor lunarColor; //农历节日颜色
QColor currentTextColor; //当前月文字颜色 QColor currentTextColor; //当前月文字颜色
QColor otherTextColor; //其他月文字颜色 QColor otherTextColor; //其他月文字颜色
QColor selectTextColor; //选中日期文字颜色 QColor selectTextColor; //选中日期文字颜色
QColor hoverTextColor; //悬停日期文字颜色 QColor hoverTextColor; //悬停日期文字颜色
QColor currentLunarColor; //当前月农历文字颜色 QColor currentLunarColor; //当前月农历文字颜色
QColor otherLunarColor; //其他月农历文字颜色 QColor otherLunarColor; //其他月农历文字颜色
QColor selectLunarColor; //选中日期农历文字颜色 QColor selectLunarColor; //选中日期农历文字颜色
QColor hoverLunarColor; //悬停日期农历文字颜色 QColor hoverLunarColor; //悬停日期农历文字颜色
QColor currentBgColor; //当前月背景颜色 QColor currentBgColor; //当前月背景颜色
QColor otherBgColor; //其他月背景颜色 QColor otherBgColor; //其他月背景颜色
QColor selectBgColor; //选中日期背景颜色 QColor selectBgColor; //选中日期背景颜色
QColor hoverBgColor; //悬停日期背景颜色 QColor hoverBgColor; //悬停日期背景颜色
private slots: private slots:
void initWidget(); void initWidget();
@ -139,107 +139,120 @@ private slots:
void dateChanged(int year, int month, int day); void dateChanged(int year, int month, int day);
public: public:
CalendarStyle getCalendarStyle() const; //默认尺寸和最小尺寸
WeekNameFormat getWeekNameFormat() const; QSize sizeHint() const;
QDate getDate() const; QSize minimumSizeHint() const;
QColor getWeekTextColor() const; //获取和设置整体样式
QColor getWeekBgColor() const; CalendarStyle getCalendarStyle() const;
void setCalendarStyle(const CalendarStyle &calendarStyle);
bool getShowLunar() const; //获取和设置星期名称格式
QString getBgImage() const; WeekNameFormat getWeekNameFormat() const;
SelectType getSelectType() const; void setWeekNameFormat(const WeekNameFormat &weekNameFormat);
QColor getBorderColor() const; //获取和设置日期
QColor getWeekColor() const; QDate getDate() const;
QColor getSuperColor() const; void setDate(const QDate &date);
QColor getLunarColor() const;
QColor getCurrentTextColor() const; //获取和设置顶部星期名称文字颜色
QColor getOtherTextColor() const; QColor getWeekTextColor() const;
QColor getSelectTextColor() const; void setWeekTextColor(const QColor &weekTextColor);
QColor getHoverTextColor() const;
QColor getCurrentLunarColor() const; //获取和设置顶部星期名称文字背景色
QColor getOtherLunarColor() const; QColor getWeekBgColor() const;
QColor getSelectLunarColor() const; void setWeekBgColor(const QColor &weekBgColor);
QColor getHoverLunarColor() const;
QColor getCurrentBgColor() const; //获取和设置是否显示农历信息
QColor getOtherBgColor() const; bool getShowLunar() const;
QColor getSelectBgColor() const; void setShowLunar(bool showLunar);
QColor getHoverBgColor() const;
QSize sizeHint() const; //获取和设置背景图片
QSize minimumSizeHint() const; QString getBgImage() const;
void setBgImage(const QString &bgImage);
//获取和设置选中背景样式
SelectType getSelectType() const;
void setSelectType(const SelectType &selectType);
//获取和设置边框颜色
QColor getBorderColor() const;
void setBorderColor(const QColor &borderColor);
//获取和设置周末颜色
QColor getWeekColor() const;
void setWeekColor(const QColor &weekColor);
//获取和设置角标颜色
QColor getSuperColor() const;
void setSuperColor(const QColor &superColor);
//获取和设置农历节日颜色
QColor getLunarColor() const;
void setLunarColor(const QColor &lunarColor);
//获取和设置当前月文字颜色
QColor getCurrentTextColor() const;
void setCurrentTextColor(const QColor &currentTextColor);
//获取和设置其他月文字颜色
QColor getOtherTextColor() const;
void setOtherTextColor(const QColor &otherTextColor);
//获取和设置选中日期文字颜色
QColor getSelectTextColor() const;
void setSelectTextColor(const QColor &selectTextColor);
//获取和设置悬停日期文字颜色
QColor getHoverTextColor() const;
void setHoverTextColor(const QColor &hoverTextColor);
//获取和设置当前月农历文字颜色
QColor getCurrentLunarColor() const;
void setCurrentLunarColor(const QColor &currentLunarColor);
//获取和设置其他月农历文字颜色
QColor getOtherLunarColor() const;
void setOtherLunarColor(const QColor &otherLunarColor);
//获取和设置选中日期农历文字颜色
QColor getSelectLunarColor() const;
void setSelectLunarColor(const QColor &selectLunarColor);
//获取和设置悬停日期农历文字颜色
QColor getHoverLunarColor() const;
void setHoverLunarColor(const QColor &hoverLunarColor);
//获取和设置当前月背景颜色
QColor getCurrentBgColor() const;
void setCurrentBgColor(const QColor &currentBgColor);
//获取和设置其他月背景颜色
QColor getOtherBgColor() const;
void setOtherBgColor(const QColor &otherBgColor);
//获取和设置选中日期背景颜色
QColor getSelectBgColor() const;
void setSelectBgColor(const QColor &selectBgColor);
//获取和设置悬停日期背景颜色
QColor getHoverBgColor() const;
void setHoverBgColor(const QColor &hoverBgColor);
public Q_SLOTS: public Q_SLOTS:
//上一年,下一年 //转到上一年
void showPreviousYear(); void showPreviousYear();
//转到下一年
void showNextYear(); void showNextYear();
//上一月,下一月 //转到上一月
void showPreviousMonth(); void showPreviousMonth();
//转到下一月
void showNextMonth(); void showNextMonth();
//转到今天 //转到今天
void showToday(); void showToday();
//设置整体样式
void setCalendarStyle(const CalendarStyle &calendarStyle);
//设置星期名称格式
void setWeekNameFormat(const WeekNameFormat &weekNameFormat);
//设置日期
void setDate(const QDate &date);
//设置顶部星期名称文字颜色+背景色
void setWeekTextColor(const QColor &weekTextColor);
void setWeekBgColor(const QColor &weekBgColor);
//设置是否显示农历信息
void setShowLunar(bool showLunar);
//设置背景图片
void setBgImage(const QString &bgImage);
//设置选中背景样式
void setSelectType(const SelectType &selectType);
//设置边框颜色
void setBorderColor(const QColor &borderColor);
//设置周末颜色
void setWeekColor(const QColor &weekColor);
//设置角标颜色
void setSuperColor(const QColor &superColor);
//设置农历节日颜色
void setLunarColor(const QColor &lunarColor);
//设置当前月文字颜色
void setCurrentTextColor(const QColor &currentTextColor);
//设置其他月文字颜色
void setOtherTextColor(const QColor &otherTextColor);
//设置选中日期文字颜色
void setSelectTextColor(const QColor &selectTextColor);
//设置悬停日期文字颜色
void setHoverTextColor(const QColor &hoverTextColor);
//设置当前月农历文字颜色
void setCurrentLunarColor(const QColor &currentLunarColor);
//设置其他月农历文字颜色
void setOtherLunarColor(const QColor &otherLunarColor);
//设置选中日期农历文字颜色
void setSelectLunarColor(const QColor &selectLunarColor);
//设置悬停日期农历文字颜色
void setHoverLunarColor(const QColor &hoverLunarColor);
//设置当前月背景颜色
void setCurrentBgColor(const QColor &currentBgColor);
//设置其他月背景颜色
void setOtherBgColor(const QColor &otherBgColor);
//设置选中日期背景颜色
void setSelectBgColor(const QColor &selectBgColor);
//设置悬停日期背景颜色
void setHoverBgColor(const QColor &hoverBgColor);
Q_SIGNALS: Q_SIGNALS:
void clicked(const QDate &date); void clicked(const QDate &date);
void selectionChanged(); void selectionChanged();