Commit 2fd753e3 authored by Glen Ditchfield's avatar Glen Ditchfield 🐛
Browse files

Use standaloneMonthName in the printed month's header

Use `standaloneMonthName()` to generate the month name in the printed
month's header, as is done by KOrganizer's date navigator, because
`monthName()` produces inappropriate month names for Slavic
languages in this context.

BUG: 453292

Related: eventviews!68
parent 0b4e5959
Pipeline #175212 skipped
......@@ -156,7 +156,6 @@ QString FreePeriodModel::stringify(int index) const
const QString longMonthName = QLocale::system().monthName(startDate.month(), QLocale::LongFormat);
const QString dayofWeek = QLocale::system().dayName(startDate.dayOfWeek(), QLocale::LongFormat);
// TODO i18n, ping chusslove
return ki18nc(
"@label A time period duration. KLocale is used to format the components. "
"example: Monday, 12 June, 8:00am to 9:30am",
......
......@@ -1412,13 +1412,13 @@ void CalPrintMonth::setDateRange(const QDate &from, const QDate &to)
CalPrintPluginBase::setDateRange(from, to);
auto cfg = dynamic_cast<CalPrintMonthConfig *>((QWidget *)mConfigWidget);
if (cfg) {
const QLocale locale;
cfg->mFromMonth->clear();
for (int i = 0; i < 12; ++i) {
cfg->mFromMonth->addItem(QLocale().monthName(i + 1, QLocale::LongFormat));
}
cfg->mToMonth->clear();
for (int i = 0; i < 12; ++i) {
cfg->mToMonth->addItem(QLocale().monthName(i + 1, QLocale::LongFormat));
for (int i = 1; i < 13; ++i) {
const auto monthName = locale.standaloneMonthName(i, QLocale::LongFormat);
cfg->mFromMonth->addItem(monthName);
cfg->mToMonth->addItem(monthName);
}
cfg->mFromMonth->setCurrentIndex(from.month() - 1);
cfg->mFromYear->setValue(to.year());
......@@ -1446,7 +1446,9 @@ void CalPrintMonth::print(QPainter &p, int width, int height)
monthBox.setTop(headerBox.bottom() + padding());
do {
QString title(i18nc("monthname year", "%1 %2", QLocale::system().monthName(curMonth.month()), QString::number(curMonth.year())));
QString title(i18nc("monthname year", "%1 %2",
QLocale::system().standaloneMonthName(curMonth.month(), QLocale::LongFormat),
QString::number(curMonth.year())));
QDate tmp(fromMonth);
int weekdayCol = weekdayColumn(tmp.dayOfWeek());
tmp = tmp.addDays(-weekdayCol);
......
......@@ -636,10 +636,12 @@ void CalPrintPluginBase::drawSmallMonth(QPainter &p, QDate qd, QRect box)
newFont.setPixelSize(cellHeight);
p.setFont(newFont);
const QLocale locale;
// draw the title
QRect titleBox(box);
titleBox.setHeight(p.fontMetrics().height());
p.drawText(titleBox, Qt::AlignTop | Qt::AlignHCenter, QLocale::system().monthName(month));
p.drawText(titleBox, Qt::AlignTop | Qt::AlignHCenter, locale.standaloneMonthName(month));
// draw days of week
QRect wdayBox(box);
......@@ -647,10 +649,10 @@ void CalPrintPluginBase::drawSmallMonth(QPainter &p, QDate qd, QRect box)
wdayBox.setHeight(int(2 * cellHeight) - int(cellHeight));
for (int col = 0; col < 7; ++col) {
QString tmpStr = QLocale::system().dayName(monthDate2.dayOfWeek())[0].toUpper();
const auto dayLetter = locale.standaloneDayName(monthDate2.dayOfWeek(), QLocale::ShortFormat)[0].toUpper();
wdayBox.setLeft(int(box.left() + col * cellWidth));
wdayBox.setRight(int(box.left() + (col + 1) * cellWidth));
p.drawText(wdayBox, Qt::AlignCenter, tmpStr);
p.drawText(wdayBox, Qt::AlignCenter, dayLetter);
monthDate2 = monthDate2.addDays(1);
}
......@@ -1271,7 +1273,7 @@ void CalPrintPluginBase::drawMonth(QPainter &p,
subheaderBox.setHeight(subHeaderHeight());
QRect borderBox(box);
borderBox.setTop(subheaderBox.bottom() + 1);
drawSubHeaderBox(p, QLocale::system().monthName(dt.month()), subheaderBox);
drawSubHeaderBox(p, QLocale().standaloneMonthName(dt.month()), subheaderBox);
// correct for half the border width
int correction = (BOX_BORDER_WIDTH /*-1*/) / 2;
QRect daysBox(borderBox);
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment