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
wilder-5.25
Felipe Kinoshita 4 years ago
parent e1d08ebb5e
commit 9dad186438
No known key found for this signature in database
GPG Key ID: E5FF0D0C1A82B6A1
  1. 12
      applets/digital-clock/plugin/clipboardmenu.cpp

@ -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);

Loading…
Cancel
Save