DtkSystemSettings
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 "dsystemtimetypes.h"
12#include "dtksystemtime_global.h"
13
14#include <dexpected.h>
15#include <qdatetime.h>
16#include <qobject.h>
17#include <qscopedpointer.h>
18
19DSYSTEMTIME_BEGIN_NAMESPACE
20using DCORE_NAMESPACE::DExpected;
21class DSystemTimePrivate;
22
23class DSystemTime : public QObject
24{
25 Q_OBJECT
26public:
27 explicit DSystemTime(QObject *parent = nullptr);
28 virtual ~DSystemTime();
29 // properties
30 Q_PROPERTY(bool canNTP READ canNTP);
31 Q_PROPERTY(bool localRTC READ localRTC);
32 Q_PROPERTY(bool NTP READ NTP);
33 Q_PROPERTY(bool NTPSynchronized READ NTPSynchronized);
34 Q_PROPERTY(QString timezone READ timezone);
35 Q_PROPERTY(quint64 RTCTimeUSec READ RTCTimeUSec);
36 Q_PROPERTY(QDateTime timeDate READ timeDate);
37 bool canNTP() const;
38 bool localRTC() const;
39 bool NTP() const;
40 bool NTPSynchronized() const;
41 QString timezone() const;
42 quint64 RTCTimeUSec() const;
43 QDateTime timeDate() const;
44 // sync properties
45 Q_PROPERTY(QStringList fallbackNTPServers READ fallbackNTPServers);
46 Q_PROPERTY(QStringList linkNTPServers READ linkNTPServers);
47 Q_PROPERTY(QStringList systemNTPServers READ systemNTPServers);
48 Q_PROPERTY(qint64 frequency READ frequency);
49 Q_PROPERTY(QString serverName READ serverName);
50 Q_PROPERTY(Address serverAddress READ serverAddress);
51 Q_PROPERTY(Message NTPMessage READ NTPMessage);
52 Q_PROPERTY(quint64 pollIntervalMaxUSec READ pollIntervalMaxUSec);
53 Q_PROPERTY(quint64 pollIntervalMinUSec READ pollIntervalMinUSec);
54 Q_PROPERTY(quint64 pollIntervalUSec READ pollIntervalUSec);
55 Q_PROPERTY(quint64 rootDistanceMaxUSec READ rootDistanceMaxUSec);
56 QStringList fallbackNTPServers() const;
57 QStringList linkNTPServers() const;
58 QStringList systemNTPServers() const;
59 qint64 frequency() const;
60 QString serverName() const;
63 quint64 pollIntervalMaxUSec() const;
64 quint64 pollIntervalMinUSec() const;
65 quint64 pollIntervalUSec() const;
66 quint64 rootDistanceMaxUSec() const;
67 // slot
68public Q_SLOTS:
69 DExpected<QStringList> listTimezones() const;
70 DExpected<void> 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:24
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:15
存储NTP服务器返回的信息
Definition dsystemtimetypes.h:25