DtkSystemSettings  1.0.3
dtk library for systemsettings.
dsystemtime.h
浏览该文件的文档.
1// SPDX-FileCopyrightText: 2022 UnionTech Software Technology Co., Ltd.
2//
3// SPDX-License-Identifier: LGPL-3.0-or-later
4// SPDX-FileCopyrightText: 2022 UnionTech Software Technology Co., Ltd.
5//
6// SPDX-License-Identifier: LGPL-3.0-or-later
7
8#ifndef DSYSTEMTIME_H
9#define DSYSTEMTIME_H
10
11#include <qobject.h>
12#include <qscopedpointer.h>
13#include <qdatetime.h>
14#include <dexpected.h>
15
16#include "dtksystemtime_global.h"
17#include "dsystemtimetypes.h"
18
19DSYSTEMTIME_BEGIN_NAMESPACE
20using DCORE_NAMESPACE::DExpected;
21class DSystemTimePrivate;
22class DSystemTime : public QObject
23{
24 Q_OBJECT
25public:
26 explicit DSystemTime(QObject *parent = nullptr);
27 virtual ~DSystemTime();
28 // properties
29 Q_PROPERTY(bool canNTP READ canNTP);
30 Q_PROPERTY(bool localRTC READ localRTC);
31 Q_PROPERTY(bool NTP READ NTP);
32 Q_PROPERTY(bool NTPSynchronized READ NTPSynchronized);
33 Q_PROPERTY(QString timezone READ timezone);
34 Q_PROPERTY(quint64 RTCTimeUSec READ RTCTimeUSec);
35 Q_PROPERTY(QDateTime timeDate READ timeDate);
36 bool canNTP() const;
37 bool localRTC() const;
38 bool NTP() const;
39 bool NTPSynchronized() const;
40 QString timezone() const;
41 quint64 RTCTimeUSec() const;
42 QDateTime timeDate() const;
43 // sync properties
44 Q_PROPERTY(QStringList fallbackNTPServers READ fallbackNTPServers);
45 Q_PROPERTY(QStringList linkNTPServers READ linkNTPServers);
46 Q_PROPERTY(QStringList systemNTPServers READ systemNTPServers);
47 Q_PROPERTY(qint64 frequency READ frequency);
48 Q_PROPERTY(QString serverName READ serverName);
49 Q_PROPERTY(Address serverAddress READ serverAddress);
50 Q_PROPERTY(Message NTPMessage READ NTPMessage);
51 Q_PROPERTY(quint64 pollIntervalMaxUSec READ pollIntervalMaxUSec);
52 Q_PROPERTY(quint64 pollIntervalMinUSec READ pollIntervalMinUSec);
53 Q_PROPERTY(quint64 pollIntervalUSec READ pollIntervalUSec);
54 Q_PROPERTY(quint64 rootDistanceMaxUSec READ rootDistanceMaxUSec);
55 QStringList fallbackNTPServers() const;
56 QStringList linkNTPServers() const;
57 QStringList systemNTPServers() const;
58 qint64 frequency() const;
59 QString serverName() const;
62 quint64 pollIntervalMaxUSec() const;
63 quint64 pollIntervalMinUSec() const;
64 quint64 pollIntervalUSec() const;
65 quint64 rootDistanceMaxUSec() const;
66 // slot
67public Q_SLOTS:
68 DExpected<QStringList> listTimezones() const;
69 DExpected<void>
70 setLocalRTC(bool localRTC, bool fixSystem, bool interactive);
71 DExpected<void> enableNTP(bool useNTP, bool interactive);
72 DExpected<void> setRelativeTime(qint64 usecUTC, bool interactive);
73 DExpected<void> setAbsoluteTime(const QDateTime &time, bool interactive);
74 DExpected<void> setTimezone(const QString &timezone, bool interactive);
75
76private:
77 QScopedPointer<DSystemTimePrivate> d_ptr;
78 Q_DECLARE_PRIVATE(DSystemTime)
79};
80
81DSYSTEMTIME_END_NAMESPACE
82#endif
用于管理系统时间和系统时间同步
Definition: dsystemtime.h:23
QStringList fallbackNTPServers() const
返回可用的NTP服务器列表
bool NTPSynchronized() const
NTPSynchronized显示内核是否报告时间是同步的
Message NTPMessage() const
NTP服务器传回信息
QString serverName() const
NTP服务器名
quint64 pollIntervalMaxUSec() const
与NTP服务器同步的最大周期时间
quint64 pollIntervalMinUSec() const
与NTP服务器同步的最小周期时间
quint64 RTCTimeUSec() const
显示RTC中当前时间
DExpected< void > enableNTP(bool useNTP, bool interactive)
设置是否使用NTP同步时间
DExpected< void > setTimezone(const QString &timezone, bool interactive)
设置本地时区
bool canNTP() const
是否有通过网络进行时间同步的服务
quint64 rootDistanceMaxUSec() const
与根NTP服务器通讯最大延时
DExpected< void > setLocalRTC(bool localRTC, bool fixSystem, bool interactive)
QStringList systemNTPServers() const
系统设置的NTP服务器
QDateTime timeDate() const
时区显示当前配置的时区
DExpected< void > setAbsoluteTime(const QDateTime &time, bool interactive)
设置绝对时间
quint64 pollIntervalUSec() const
与NTP服务器同步时间
DExpected< QStringList > listTimezones() const
列举时区
DExpected< void > setRelativeTime(qint64 usecUTC, bool interactive)
设置相对时间
bool NTP() const
是否启用了NTP服务
qint64 frequency() const
系统和NTP服务器同步频率
Address serverAddress() const
NTP服务器地址
存储NTP服务器地址信息
Definition: dsystemtimetypes.h:14
存储NTP服务器返回的信息
Definition: dsystemtimetypes.h:20