Skip to content

Commit

Permalink
[nemo-qml-plugin-devicelock] Boolean properties for things that are r…
Browse files Browse the repository at this point in the history
…eally boolean. Contributes to JB#37921

Still saved to .ini file as integers but users of DeviceLockSettings
don't need to know that.

Peeking and showNotifications have been saved earlier as -1 & 1, but
since all the usage I could find only compared to 1 it should be ok
to start using more natural zero for false.
  • Loading branch information
pvuorela committed Mar 2, 2017
1 parent 0c31122 commit 707a49c
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 22 deletions.
24 changes: 12 additions & 12 deletions src/nemo-devicelock/devicelocksettings.cpp
Expand Up @@ -152,9 +152,9 @@ void DeviceLockSettings::setMaximumAttempts(const QVariant &authenticationToken,
This property holds whether peeking from the lock screen is allowed when the device is locked.
*/

int DeviceLockSettings::peekingAllowed() const
bool DeviceLockSettings::peekingAllowed() const
{
return m_settings->peekingAllowed;
return m_settings->peekingAllowed > 0;
}

/*!
Expand All @@ -164,9 +164,9 @@ int DeviceLockSettings::peekingAllowed() const
\a authenticationToken produced passed as an argument.
*/

void DeviceLockSettings::setPeekingAllowed(const QVariant &authenticationToken, int value)
void DeviceLockSettings::setPeekingAllowed(const QVariant &authenticationToken, bool value)
{
changeSetting(authenticationToken, QString::fromUtf8(SettingsWatcher::peekingAllowedKey), value);
changeSetting(authenticationToken, QString::fromUtf8(SettingsWatcher::peekingAllowedKey), value ? 1 : 0);
}

/*!
Expand All @@ -175,9 +175,9 @@ void DeviceLockSettings::setPeekingAllowed(const QVariant &authenticationToken,
This property holds whether sideloading of APK packages is allowed.
*/

int DeviceLockSettings::sideloadingAllowed() const
bool DeviceLockSettings::sideloadingAllowed() const
{
return m_settings->sideloadingAllowed;
return m_settings->sideloadingAllowed > 0;
}

/*!
Expand All @@ -187,9 +187,9 @@ int DeviceLockSettings::sideloadingAllowed() const
\a authenticationToken produced passed as an argument.
*/

void DeviceLockSettings::setSideloadingAllowed(const QVariant &authenticationToken, int value)
void DeviceLockSettings::setSideloadingAllowed(const QVariant &authenticationToken, bool value)
{
changeSetting(authenticationToken, QString::fromUtf8(SettingsWatcher::sideloadingAllowedKey), value);
changeSetting(authenticationToken, QString::fromUtf8(SettingsWatcher::sideloadingAllowedKey), value ? 1 : 0);
}

/*!
Expand All @@ -198,9 +198,9 @@ void DeviceLockSettings::setSideloadingAllowed(const QVariant &authenticationTok
This property holds whether notifications are shown on the lock screen when the device is locked.
*/

int DeviceLockSettings::showNotifications() const
bool DeviceLockSettings::showNotifications() const
{
return m_settings->showNotifications;
return m_settings->showNotifications > 0;
}

/*!
Expand All @@ -210,9 +210,9 @@ int DeviceLockSettings::showNotifications() const
\a authenticationToken produced passed as an argument.
*/

void DeviceLockSettings::setShowNotifications(const QVariant &authenticationToken, int value)
void DeviceLockSettings::setShowNotifications(const QVariant &authenticationToken, bool value)
{
changeSetting(authenticationToken, QString::fromUtf8(SettingsWatcher::showNotificationsKey), value);
changeSetting(authenticationToken, QString::fromUtf8(SettingsWatcher::showNotificationsKey), value ? 1 : 0);
}

/*!
Expand Down
20 changes: 10 additions & 10 deletions src/nemo-devicelock/devicelocksettings.h
Expand Up @@ -40,15 +40,15 @@ namespace NemoDeviceLock

class SettingsWatcher;

class NEMODEVICELOCK_EXPORT DeviceLockSettings : public QObject, private ConnectionClient
class NEMODEVICELOCK_EXPORT DeviceLockSettings : public QObject, private ConnectionClient
{
Q_OBJECT
Q_PROPERTY(NemoDeviceLock::Authorization *authorization READ authorization CONSTANT)
Q_PROPERTY(int automaticLocking READ automaticLocking NOTIFY automaticLockingChanged)
Q_PROPERTY(int maximumAttempts READ maximumAttempts NOTIFY maximumAttemptsChanged)
Q_PROPERTY(int peekingAllowed READ peekingAllowed NOTIFY peekingAllowedChanged)
Q_PROPERTY(int sideloadingAllowed READ sideloadingAllowed NOTIFY sideloadingAllowedChanged)
Q_PROPERTY(int showNotifications READ showNotifications NOTIFY showNotificationsChanged)
Q_PROPERTY(bool peekingAllowed READ peekingAllowed NOTIFY peekingAllowedChanged)
Q_PROPERTY(bool sideloadingAllowed READ sideloadingAllowed NOTIFY sideloadingAllowedChanged)
Q_PROPERTY(bool showNotifications READ showNotifications NOTIFY showNotificationsChanged)
Q_PROPERTY(bool inputIsKeyboard READ inputIsKeyboard NOTIFY inputIsKeyboardChanged)
Q_PROPERTY(bool currentCodeIsDigitOnly READ currentCodeIsDigitOnly NOTIFY currentCodeIsDigitOnlyChanged)
Q_PROPERTY(bool homeEncrypted READ isHomeEncrypted CONSTANT)
Expand All @@ -64,14 +64,14 @@ class NEMODEVICELOCK_EXPORT DeviceLockSettings : public QObject, private Connec
int maximumAttempts() const;
Q_INVOKABLE void setMaximumAttempts(const QVariant &authenticationToken, int value);

int peekingAllowed() const;
Q_INVOKABLE void setPeekingAllowed(const QVariant &authenticationToken, int value);
bool peekingAllowed() const;
Q_INVOKABLE void setPeekingAllowed(const QVariant &authenticationToken, bool value);

int sideloadingAllowed() const;
Q_INVOKABLE void setSideloadingAllowed(const QVariant &authenticationToken, int value);
bool sideloadingAllowed() const;
Q_INVOKABLE void setSideloadingAllowed(const QVariant &authenticationToken, bool value);

int showNotifications() const;
Q_INVOKABLE void setShowNotifications(const QVariant &authenticationToken,int value);
bool showNotifications() const;
Q_INVOKABLE void setShowNotifications(const QVariant &authenticationToken, bool value);

bool inputIsKeyboard() const;
Q_INVOKABLE void setInputIsKeyboard(const QVariant &authenticationToken, bool value);
Expand Down

0 comments on commit 707a49c

Please sign in to comment.