Verified Commit 9dad1864 authored by Felipe Kinoshita's avatar Felipe Kinoshita 🌎
Browse files

applets/digital-clock: Make "Copy to Clipboard" menu follow system locale

This means that if your locale uses the 24 hour format the items
in that menu will use that format as well and vice-versa.

BUG: 452888
parent e1d08ebb
Pipeline #174429 passed with stage
in 11 minutes and 42 seconds
......@@ -67,28 +67,28 @@ void ClipboardMenu::setupMenu(QAction *action)
QAction *a;
// e.g 12:30 PM or 12:30:01 PM
s = m_secondsIncluded ? QLocale().toString(time, QLocale::LongFormat) : QLocale().toString(time, QLocale::ShortFormat);
s = m_secondsIncluded ? QLocale::system().toString(time, QLocale::LongFormat) : QLocale::system().toString(time, QLocale::ShortFormat);
a = menu->addAction(s);
a->setData(s);
// the same as the option above but shows the opposite of the "show seconds" setting
// e.g if "show seconds" is enabled it will show the time without seconds and vice-versa
s = m_secondsIncluded ? QLocale().toString(time, QLocale::ShortFormat) : QLocale().toString(time, QLocale::LongFormat);
s = m_secondsIncluded ? QLocale::system().toString(time, QLocale::ShortFormat) : QLocale::system().toString(time, QLocale::LongFormat);
a = menu->addAction(s);
a->setData(s);
// e.g 4/28/22
s = QLocale().toString(date, QLocale::ShortFormat);
s = QLocale::system().toString(date, QLocale::ShortFormat);
a = menu->addAction(s);
a->setData(s);
// e.g Thursday, April 28, 2022
s = QLocale().toString(date, QLocale::LongFormat);
s = QLocale::system().toString(date, QLocale::LongFormat);
a = menu->addAction(s);
a->setData(s);
// e.g Thursday, April 28, 2022 12:30 PM or Thursday, April 28, 2022 12:30:01 PM -03
s = m_secondsIncluded ? QLocale().toString(date, QLocale::LongFormat) + ws + QLocale().toString(time, QLocale::LongFormat) : QLocale().toString(date, QLocale::LongFormat) + ws + QLocale().toString(time, QLocale::ShortFormat);
s = m_secondsIncluded ? QLocale::system().toString(date, QLocale::LongFormat) + ws + QLocale::system().toString(time, QLocale::LongFormat) : QLocale::system().toString(date, QLocale::LongFormat) + ws + QLocale::system().toString(time, QLocale::ShortFormat);
a = menu->addAction(s);
a->setData(s);
......@@ -98,7 +98,7 @@ void ClipboardMenu::setupMenu(QAction *action)
a->setData(s);
// e.g 2022-04-28 12:30 PM or 2022-04-28 12:30:01 PM -03
s = m_secondsIncluded ? date.toString(Qt::ISODate) + ws + QLocale().toString(time, QLocale::LongFormat) : date.toString(Qt::ISODate) + ws + QLocale().toString(time, QLocale::ShortFormat);
s = m_secondsIncluded ? date.toString(Qt::ISODate) + ws + QLocale::system().toString(time, QLocale::LongFormat) : date.toString(Qt::ISODate) + ws + QLocale::system().toString(time, QLocale::ShortFormat);
a = menu->addAction(s);
a->setData(s);
......
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