Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
[nemo-qml-plugin-systemsettings] Add DateTimeSettings::ready property…
…. Contributes to JB#33755

This property indicates when the initial timed signal has been
received and the other property values have been initialized.
  • Loading branch information
blammit committed Aug 31, 2017
1 parent 9828130 commit 7eb7b5b
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 0 deletions.
11 changes: 11 additions & 0 deletions src/datetimesettings.cpp
Expand Up @@ -79,6 +79,11 @@ void DateTimeSettings::onGetWallClockInfoFinished(QDBusPendingCallWatcher *watch
watcher->deleteLater();
}

bool DateTimeSettings::ready() const
{
return m_timedInfoValid;
}

void DateTimeSettings::setTime(int hour, int minute)
{
QDate currentDate = QDate::currentDate();
Expand Down Expand Up @@ -195,6 +200,8 @@ bool DateTimeSettings::setTime(time_t time)

void DateTimeSettings::onTimedSignal(const Maemo::Timed::WallClock::Info &info, bool time_changed)
{
const bool prevReady = ready();

m_timedInfo = info;
m_timedInfoValid = true;

Expand All @@ -219,4 +226,8 @@ void DateTimeSettings::onTimedSignal(const Maemo::Timed::WallClock::Info &info,
m_timezone = newTimezone;
emit timezoneChanged();
}

if (prevReady != ready()) {
emit readyChanged();
}
}
4 changes: 4 additions & 0 deletions src/datetimesettings.h
Expand Up @@ -45,6 +45,7 @@ class SYSTEMSETTINGS_EXPORT DateTimeSettings: public QObject
Q_OBJECT

Q_ENUMS(HourMode)
Q_PROPERTY(bool ready READ ready NOTIFY readyChanged)
Q_PROPERTY(bool automaticTimeUpdate READ automaticTimeUpdate WRITE setAutomaticTimeUpdate NOTIFY automaticTimeUpdateChanged)
Q_PROPERTY(bool automaticTimezoneUpdate READ automaticTimezoneUpdate WRITE setAutomaticTimezoneUpdate NOTIFY automaticTimezoneUpdateChanged)
Q_PROPERTY(QString timezone READ timezone WRITE setTimezone NOTIFY timezoneChanged)
Expand All @@ -61,6 +62,8 @@ class SYSTEMSETTINGS_EXPORT DateTimeSettings: public QObject
Q_INVOKABLE void setTime(int hour, int minute);
Q_INVOKABLE void setDate(const QDate &date);

bool ready() const;

bool automaticTimeUpdate();
void setAutomaticTimeUpdate(bool enable);

Expand All @@ -73,6 +76,7 @@ class SYSTEMSETTINGS_EXPORT DateTimeSettings: public QObject
Q_INVOKABLE void setHourMode(HourMode mode);

signals:
void readyChanged();
void timeChanged();
void automaticTimeUpdateChanged();
void automaticTimezoneUpdateChanged();
Expand Down

0 comments on commit 7eb7b5b

Please sign in to comment.