Commit 3a5927dd authored by David Jarvie's avatar David Jarvie
Browse files

Use translated forms of "am" and "pm" when displaying times

parent e59b9c7e
Pipeline #91236 passed with stage
in 6 minutes and 41 seconds
KAlarm Change Log
=== Version 3.3.2 (KDE Applications 21.08.3) --- 20 October 2021 ===
=== Version 3.3.2 (KDE Applications 21.08.3) --- 25 October 2021 ===
* Make time edit field arrows work with Breeze application style [KDE Bug 443062]
* Use translated forms of "am" and "pm" when displaying times.
=== Version 3.3.1 (KDE Applications 21.08.1) --- 29 August 2021 ===
* Fix crash when KAlarm is launched while already running [KDE Bug 441660]
......
/*
* timeedit.cpp - time-of-day edit widget, with AM/PM shown depending on locale
* Program: kalarm
* SPDX-FileCopyrightText: 2001-2020 David Jarvie <djarvie@kde.org>
* SPDX-FileCopyrightText: 2001-2021 David Jarvie <djarvie@kde.org>
*
* SPDX-License-Identifier: GPL-2.0-or-later
*/
......@@ -30,14 +30,12 @@ TimeEdit::TimeEdit(QWidget* parent)
setLayout(layout);
bool use12hour = use12HourClock();
mSpinBox = new TimeSpinBox(!use12hour, this);
mSpinBox->setFixedSize(mSpinBox->sizeHint());
connect(mSpinBox, &TimeSpinBox::valueChanged, this, &TimeEdit::slotValueChanged);
layout->addWidget(mSpinBox);
if (use12hour)
{
mAmPm = new ComboBox(this);
setAmPmCombo(1, 1); // add "am" and "pm" options to the combo box
mAmPm->setFixedSize(mAmPm->sizeHint());
connect(mAmPm, &ComboBox::highlighted, this, &TimeEdit::slotAmPmChanged);
layout->addWidget(mAmPm);
}
......@@ -165,11 +163,12 @@ void TimeEdit::slotAmPmChanged(int item)
*/
void TimeEdit::setAmPmCombo(int am, int pm)
{
QLocale locale;
if (am > 0 && mAmIndex < 0)
{
// Insert "am"
mAmIndex = 0;
mAmPm->insertItem(mAmIndex, i18nc("@item:inlistbox Morning, as in 2am", "am"));
mAmPm->insertItem(mAmIndex, locale.amText());
if (mPmIndex >= 0)
mPmIndex = 1;
mAmPm->setCurrentIndex(mPmIndex >= 0 ? mPmIndex : mAmIndex);
......@@ -188,7 +187,7 @@ void TimeEdit::setAmPmCombo(int am, int pm)
{
// Insert "pm"
mPmIndex = mAmIndex + 1;
mAmPm->insertItem(mPmIndex, i18nc("@item:inlistbox Afternoon, as in 2pm", "pm"));
mAmPm->insertItem(mPmIndex, locale.pmText());
if (mAmIndex < 0)
mAmPm->setCurrentIndex(mPmIndex);
}
......
Markdown is supported
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