mirror of
https://invent.kde.org/plasma/plasma-desktop.git
synced 2026-11-03 22:59:45 -09:00
kcms/dateandtime: Calculate timeDiff before doing blocking things
It can take an arbitrary amount of time until the user answers authorizes the change, during that time in the real world keeps running, the set time by the user doesn't change once set. Calculate the diffrence in time beforehand to keep it as close as possible to what the user wanted.
This commit is contained in:
parent
10b3bda631
commit
e4805a6d4a
1 changed files with 2 additions and 2 deletions
|
|
@ -41,6 +41,8 @@ KclockModule::KclockModule(QObject *parent, const KPluginMetaData &metaData)
|
|||
|
||||
bool KclockModule::timedatedSave()
|
||||
{
|
||||
const qint64 timeDiff = dtime->userTime().toMSecsSinceEpoch() - QDateTime::currentMSecsSinceEpoch();
|
||||
|
||||
OrgFreedesktopTimedate1Interface timedateIface(QStringLiteral("org.freedesktop.timedate1"),
|
||||
QStringLiteral("/org/freedesktop/timedate1"),
|
||||
QDBusConnection::systemBus());
|
||||
|
|
@ -59,9 +61,7 @@ bool KclockModule::timedatedSave()
|
|||
qWarning() << "Failed to enable NTP" << reply.error().name() << reply.error().message();
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!dtime->ntpEnabled()) {
|
||||
qint64 timeDiff = dtime->userTime().toMSecsSinceEpoch() - QDateTime::currentMSecsSinceEpoch();
|
||||
//*1000 for milliseconds -> microseconds
|
||||
auto reply = timedateIface.SetTime(timeDiff * 1000, true, true);
|
||||
reply.waitForFinished();
|
||||
|
|
|
|||
Loading…
Reference in a new issue