Show the year correctly after it has been edited
When converting the year as an integer via the locale then it can add in group separators which would not be desired here. Therefore it should be converted via the QDate approach to get the right output for the year. Fixes: QTBUG-86307 Fixes: QTBUG-85966 Pick-to: 5.15 Change-Id: I092bd1e5f69e544843fd5f28c96b94c9066490c5 Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
This commit is contained in:
parent
ec258b8291
commit
d9edad8117
@ -1927,7 +1927,6 @@ void QCalendarWidgetPrivate::_q_nextMonthClicked()
|
||||
void QCalendarWidgetPrivate::_q_yearEditingFinished()
|
||||
{
|
||||
Q_Q(QCalendarWidget);
|
||||
yearButton->setText(q->locale().toString(yearEdit->value()));
|
||||
yearEdit->hide();
|
||||
q->setFocusPolicy(oldFocusPolicy);
|
||||
qApp->removeEventFilter(q);
|
||||
@ -1936,6 +1935,7 @@ void QCalendarWidgetPrivate::_q_yearEditingFinished()
|
||||
QDate currentDate = getCurrentDate();
|
||||
int newYear = q->locale().toInt(yearEdit->text());
|
||||
currentDate = currentDate.addYears(newYear - currentDate.year(m_model->m_calendar), m_model->m_calendar);
|
||||
yearButton->setText(q->locale().toString(currentDate, u"yyyy", m_model->m_calendar));
|
||||
updateCurrentPage(currentDate);
|
||||
}
|
||||
|
||||
|
@ -185,6 +185,10 @@ void tst_QCalendarWidget::buttonClickCheck()
|
||||
QTest::mouseMove(widget);
|
||||
QTest::mouseClick(widget, Qt::LeftButton);
|
||||
QCOMPARE(2006, object.yearShown());
|
||||
QTest::mouseClick(button, Qt::LeftButton, Qt::NoModifier, button->rect().center(), 2);
|
||||
QTest::mouseMove(widget);
|
||||
QTest::mouseClick(widget, Qt::LeftButton);
|
||||
QCOMPARE(button->text(), "2006"); // Check that it is shown as a year should be
|
||||
object.setSelectedDate(selectedDate);
|
||||
object.showSelectedDate();
|
||||
QTest::keyClick(widget, Qt::Key_Down);
|
||||
|
Loading…
Reference in New Issue
Block a user