49 lines
1.8 KiB
Diff
49 lines
1.8 KiB
Diff
From c152213d0f5cad71381a1d2b436b83df44f834f0 Mon Sep 17 00:00:00 2001
|
||
From: liuxinhao <liuxinhao@kylinos.com.cn>
|
||
Date: Thu, 16 Dec 2021 10:49:43 +0800
|
||
Subject: [PATCH 0/1] fix(timedate): fixed issue where month 1 could not adjust
|
||
date
|
||
MIME-Version: 1.0
|
||
Content-Type: text/plain; charset=UTF-8
|
||
Content-Transfer-Encoding: 8bit
|
||
|
||
- 修复当前设置为1月份,重新打开日期时间设置加载当前日期未触发对应槽函数更新日期spinbox限制导致的"日"不能正常加减
|
||
|
||
Closes #47649
|
||
---
|
||
src/widgets/kiran-date-picker-widget.cpp | 5 ++++-
|
||
1 file changed, 4 insertions(+), 1 deletion(-)
|
||
|
||
diff --git a/src/widgets/kiran-date-picker-widget.cpp b/src/widgets/kiran-date-picker-widget.cpp
|
||
index 2738caf..4b3ea8f 100644
|
||
--- a/src/widgets/kiran-date-picker-widget.cpp
|
||
+++ b/src/widgets/kiran-date-picker-widget.cpp
|
||
@@ -41,6 +41,7 @@ void KiranDatePickerWidget::initUI()
|
||
//年
|
||
ui->spinbox_year->setMaximum(2070);
|
||
ui->spinbox_year->setMinimum(1970);
|
||
+ ui->spinbox_year->setValue(1970);
|
||
connect(ui->spinbox_year,QOverload<int>::of(&QSpinBox::valueChanged),[this](int year){
|
||
//年份切换只影响二月天数
|
||
if(ui->spinbox_month->value()!=2){
|
||
@@ -53,6 +54,7 @@ void KiranDatePickerWidget::initUI()
|
||
//月
|
||
ui->spinbox_month->setMaximum(12);
|
||
ui->spinbox_month->setMinimum(1);
|
||
+ ui->spinbox_month->setValue(1);
|
||
connect(ui->spinbox_month,QOverload<int>::of(&QSpinBox::valueChanged),[this](int month){
|
||
QDate date(ui->spinbox_year->value(),month,1);
|
||
ui->spinbox_day->setMaximum(date.daysInMonth());
|
||
@@ -60,6 +62,7 @@ void KiranDatePickerWidget::initUI()
|
||
|
||
//日
|
||
ui->spinbox_day->setMinimum(1);
|
||
-
|
||
+ QDate date(ui->spinbox_year->value(),ui->spinbox_month->value(),1);
|
||
+ ui->spinbox_day->setMaximum(date.daysInMonth());
|
||
setCurrentDate(QDate::currentDate());
|
||
}
|
||
--
|
||
2.27.0
|
||
|