更新文档

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

View File

@@ -232,121 +232,6 @@ void LunarCalendarItem::drawLunar(QPainter *painter)
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
{
return QSize(100, 100);
@@ -357,6 +242,11 @@ QSize LunarCalendarItem::minimumSizeHint() const
return QSize(20, 20);
}
bool LunarCalendarItem::getSelect() const
{
return this->select;
}
void LunarCalendarItem::setSelect(bool 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)
{
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)
{
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)
{
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)
{
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)
{
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)
{
if (this->dayType != dayType) {
@@ -421,6 +341,11 @@ void LunarCalendarItem::setDate(const QDate &date, const QString &lunar, const D
this->update();
}
QColor LunarCalendarItem::getBorderColor() const
{
return this->borderColor;
}
void LunarCalendarItem::setBorderColor(const QColor &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)
{
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)
{
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)
{
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)
{
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)
{
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)
{
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)
{
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)
{
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)
{
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)
{
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)
{
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)
{
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)
{
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)
{
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)
{
if (this->hoverBgColor != hoverBgColor) {

View File

@@ -73,125 +73,137 @@ protected:
void drawLunar(QPainter *painter);
private:
bool hover; //鼠标是否悬停
bool pressed; //鼠标是否按下
QStringList listDayName; //农历日期
bool hover; //鼠标是否悬停
bool pressed; //鼠标是否按下
QStringList listDayName; //农历日期
bool select; //是否选中
bool showLunar; //显示农历
QString bgImage; //背景图片
SelectType selectType; //选中模式
bool select; //是否选中
bool showLunar; //显示农历
QString bgImage; //背景图片
SelectType selectType; //选中模式
QDate date; //当前日期
QString lunar; //农历信息
DayType dayType; //当前日类型
QDate date; //当前日期
QString lunar; //农历信息
DayType dayType; //当前日类型
QColor borderColor; //边框颜色
QColor weekColor; //周末颜色
QColor superColor; //角标颜色
QColor lunarColor; //农历节日颜色
QColor borderColor; //边框颜色
QColor weekColor; //周末颜色
QColor superColor; //角标颜色
QColor lunarColor; //农历节日颜色
QColor currentTextColor; //当前月文字颜色
QColor otherTextColor; //其他月文字颜色
QColor selectTextColor; //选中日期文字颜色
QColor hoverTextColor; //悬停日期文字颜色
QColor currentTextColor; //当前月文字颜色
QColor otherTextColor; //其他月文字颜色
QColor selectTextColor; //选中日期文字颜色
QColor hoverTextColor; //悬停日期文字颜色
QColor currentLunarColor; //当前月农历文字颜色
QColor otherLunarColor; //其他月农历文字颜色
QColor selectLunarColor; //选中日期农历文字颜色
QColor hoverLunarColor; //悬停日期农历文字颜色
QColor currentLunarColor; //当前月农历文字颜色
QColor otherLunarColor; //其他月农历文字颜色
QColor selectLunarColor; //选中日期农历文字颜色
QColor hoverLunarColor; //悬停日期农历文字颜色
QColor currentBgColor; //当前月背景颜色
QColor otherBgColor; //其他月背景颜色
QColor selectBgColor; //选中日期背景颜色
QColor hoverBgColor; //悬停日期背景颜色
QColor currentBgColor; //当前月背景颜色
QColor otherBgColor; //其他月背景颜色
QColor selectBgColor; //选中日期背景颜色
QColor hoverBgColor; //悬停日期背景颜色
public:
bool getSelect() const;
bool getShowLunar() const;
QString getBgImage() const;
SelectType getSelectType() const;
//默认尺寸和最小尺寸
QSize sizeHint() const;
QSize minimumSizeHint() const;
QDate getDate() const;
QString getLunar() 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:
//设置是否选中
//获取和设置是否选中
bool getSelect() const;
void setSelect(bool select);
//设置是否显示农历信息
//获取和设置是否显示农历信息
bool getShowLunar() const;
void setShowLunar(bool showLunar);
//设置背景图片
//获取和设置背景图片
QString getBgImage() const;
void setBgImage(const QString &bgImage);
//设置选中背景样式
//获取和设置选中背景样式
SelectType getSelectType() const;
void setSelectType(const SelectType &selectType);
//设置日期
//获取和设置日期
QDate getDate() const;
void setDate(const QDate &date);
//设置农历
//获取和设置农历
QString getLunar() const;
void setLunar(const QString &lunar);
//设置类型
//获取和设置类型
DayType getDayType() const;
void setDayType(const DayType &dayType);
//设置日期/农历/类型
void setDate(const QDate &date, const QString &lunar, const DayType &dayType);
//设置边框颜色
//获取和设置边框颜色
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);
Q_SIGNALS:

View File

@@ -183,10 +183,10 @@ void LunarCalendarWidget::initWidget()
//逐个添加日标签
for (int i = 0; i < 42; ++i) {
LunarCalendarItem *lab = new LunarCalendarItem;
connect(lab, SIGNAL(clicked(QDate, LunarCalendarItem::DayType)), this, SLOT(clicked(QDate, LunarCalendarItem::DayType)));
layoutBody->addWidget(lab, i / 7, i % 7);
dayItems.append(lab);
LunarCalendarItem *item = new LunarCalendarItem;
connect(item, SIGNAL(clicked(QDate, LunarCalendarItem::DayType)), this, SLOT(clicked(QDate, LunarCalendarItem::DayType)));
layoutBody->addWidget(item, i / 7, i % 7);
items << item;
}
//主布局
@@ -309,7 +309,7 @@ void LunarCalendarWidget::initDate()
QDate date(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月份
@@ -327,7 +327,7 @@ void LunarCalendarWidget::initDate()
QDate date(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);
QString lunar = LunarCalendarInfo::Instance()->getLunarDay(tempYear, tempMonth, tempDay);
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 {
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;
}
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();
}
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
{
return QSize(600, 500);
@@ -554,6 +434,335 @@ QSize LunarCalendarWidget::minimumSizeHint() const
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()
{
@@ -627,209 +836,3 @@ void LunarCalendarWidget::showToday()
initDate();
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();
private:
QFont iconFont; //图形字体
bool btnClick; //按钮单击,避开下拉选择重复触发
QComboBox *cboxYear; //年份下拉框
QComboBox *cboxMonth; //月份下拉框
QList<QLabel *> labWeeks; //顶部星期名称
QList<LunarCalendarItem *> dayItems;//日期元素
QFont iconFont; //图形字体
bool btnClick; //按钮单击,避开下拉选择重复触发
QComboBox *cboxYear; //年份下拉框
QComboBox *cboxMonth; //月份下拉框
QList<QLabel *> labWeeks; //顶部星期名称
QList<LunarCalendarItem *> items;//日期元素
CalendarStyle calendarStyle; //整体样式
WeekNameFormat weekNameFormat; //星期名称格式
QDate date; //当前日期
CalendarStyle calendarStyle; //整体样式
WeekNameFormat weekNameFormat; //星期名称格式
QDate date; //当前日期
QColor weekTextColor; //星期名称文字颜色
QColor weekBgColor; //星期名称背景色
QColor weekTextColor; //星期名称文字颜色
QColor weekBgColor; //星期名称背景色
bool showLunar; //显示农历
QString bgImage; //背景图片
SelectType selectType; //选中模式
bool showLunar; //显示农历
QString bgImage; //背景图片
SelectType selectType; //选中模式
QColor borderColor; //边框颜色
QColor weekColor; //周末颜色
QColor superColor; //角标颜色
QColor lunarColor; //农历节日颜色
QColor borderColor; //边框颜色
QColor weekColor; //周末颜色
QColor superColor; //角标颜色
QColor lunarColor; //农历节日颜色
QColor currentTextColor; //当前月文字颜色
QColor otherTextColor; //其他月文字颜色
QColor selectTextColor; //选中日期文字颜色
QColor hoverTextColor; //悬停日期文字颜色
QColor currentTextColor; //当前月文字颜色
QColor otherTextColor; //其他月文字颜色
QColor selectTextColor; //选中日期文字颜色
QColor hoverTextColor; //悬停日期文字颜色
QColor currentLunarColor; //当前月农历文字颜色
QColor otherLunarColor; //其他月农历文字颜色
QColor selectLunarColor; //选中日期农历文字颜色
QColor hoverLunarColor; //悬停日期农历文字颜色
QColor currentLunarColor; //当前月农历文字颜色
QColor otherLunarColor; //其他月农历文字颜色
QColor selectLunarColor; //选中日期农历文字颜色
QColor hoverLunarColor; //悬停日期农历文字颜色
QColor currentBgColor; //当前月背景颜色
QColor otherBgColor; //其他月背景颜色
QColor selectBgColor; //选中日期背景颜色
QColor hoverBgColor; //悬停日期背景颜色
QColor currentBgColor; //当前月背景颜色
QColor otherBgColor; //其他月背景颜色
QColor selectBgColor; //选中日期背景颜色
QColor hoverBgColor; //悬停日期背景颜色
private slots:
void initWidget();
@@ -139,107 +139,120 @@ private slots:
void dateChanged(int year, int month, int day);
public:
CalendarStyle getCalendarStyle() const;
WeekNameFormat getWeekNameFormat() const;
QDate getDate() const;
//默认尺寸和最小尺寸
QSize sizeHint() const;
QSize minimumSizeHint() const;
QColor getWeekTextColor() const;
QColor getWeekBgColor() const;
//获取和设置整体样式
CalendarStyle getCalendarStyle() const;
void setCalendarStyle(const CalendarStyle &calendarStyle);
bool getShowLunar() const;
QString getBgImage() const;
SelectType getSelectType() const;
//获取和设置星期名称格式
WeekNameFormat getWeekNameFormat() const;
void setWeekNameFormat(const WeekNameFormat &weekNameFormat);
QColor getBorderColor() const;
QColor getWeekColor() const;
QColor getSuperColor() const;
QColor getLunarColor() const;
//获取和设置日期
QDate getDate() const;
void setDate(const QDate &date);
QColor getCurrentTextColor() const;
QColor getOtherTextColor() const;
QColor getSelectTextColor() const;
QColor getHoverTextColor() const;
//获取和设置顶部星期名称文字颜色
QColor getWeekTextColor() const;
void setWeekTextColor(const QColor &weekTextColor);
QColor getCurrentLunarColor() const;
QColor getOtherLunarColor() const;
QColor getSelectLunarColor() const;
QColor getHoverLunarColor() const;
//获取和设置顶部星期名称文字背景色
QColor getWeekBgColor() const;
void setWeekBgColor(const QColor &weekBgColor);
QColor getCurrentBgColor() const;
QColor getOtherBgColor() const;
QColor getSelectBgColor() const;
QColor getHoverBgColor() const;
//获取和设置是否显示农历信息
bool getShowLunar() const;
void setShowLunar(bool showLunar);
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:
//上一年,下一年
//转到上一年
void showPreviousYear();
//转到下一年
void showNextYear();
//上一月,下一月
//转到上一月
void showPreviousMonth();
//转到下一月
void showNextMonth();
//转到今天
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:
void clicked(const QDate &date);
void selectionChanged();