diff --git a/src/datetime/time.cpp b/src/datetime/time.cpp index d5498e4..6f90875 100644 --- a/src/datetime/time.cpp +++ b/src/datetime/time.cpp @@ -32,6 +32,8 @@ Time::Time(QObject *parent) OrgFreedesktopTimedate1Interface iface(QStringLiteral("org.freedesktop.timedate1"), QStringLiteral("/org/freedesktop/timedate1"), QDBusConnection::systemBus()); + + m_canNTP = iface.canNTP(); m_useNtp = iface.nTP(); } @@ -40,6 +42,11 @@ bool Time::useNtp() const return m_useNtp; } +bool Time::canNTP() const +{ + return m_canNTP; +} + void Time::setUseNtp(bool enabled) { if (m_useNtp != enabled) { diff --git a/src/datetime/time.h b/src/datetime/time.h index 2907d3c..f16f418 100644 --- a/src/datetime/time.h +++ b/src/datetime/time.h @@ -29,6 +29,7 @@ class Time : public QObject { Q_OBJECT Q_PROPERTY(bool useNtp READ useNtp WRITE setUseNtp NOTIFY useNtpChanged) + Q_PROPERTY(bool canNTP READ canNTP CONSTANT) Q_PROPERTY(QTime currentTime READ currentTime WRITE setCurrentTime NOTIFY currentTimeChanged) Q_PROPERTY(QDate currentDate READ currentDate WRITE setCurrentDate NOTIFY currentDateChanged) Q_PROPERTY(bool twentyFour READ twentyFour WRITE setTwentyFour NOTIFY twentyFourChanged) @@ -37,6 +38,7 @@ class Time : public QObject explicit Time(QObject *parent = nullptr); bool useNtp() const; + bool canNTP() const; void setUseNtp(bool enabled); Q_INVOKABLE void save(); @@ -57,6 +59,7 @@ class Time : public QObject void twentyFourChanged(); private: + bool m_canNTP; bool m_useNtp; bool m_twentyFour; QTime m_currentTime; diff --git a/src/qml/DateTime/Main.qml b/src/qml/DateTime/Main.qml index 7b68062..06a10be 100644 --- a/src/qml/DateTime/Main.qml +++ b/src/qml/DateTime/Main.qml @@ -64,11 +64,22 @@ ItemPage { Layout.fillHeight: true rightPadding: 0 rightInset: 0 + checkable: time.canNTP checked: time.useNtp onCheckedChanged: time.useNtp = checked } } + Label { + text: qsTr("Unable to use Auto Sync. Please ensure your NTP service is installed.") + color: FishUI.Theme.disabledTextColor + visible: !time.canNTP + } + } + + RoundedItem { + spacing: FishUI.Units.largeSpacing * 1.5 + RowLayout { Label { text: qsTr("24-Hour Time")