-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[foilnotes] Made auto-lock configurable
- Loading branch information
Showing
3 changed files
with
63 additions
and
18 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
/* | ||
* Copyright (C) 2018-2021 Jolla Ltd. | ||
* Copyright (C) 2018-2021 Slava Monich <[email protected]> | ||
* Copyright (C) 2018-2023 Slava Monich <[email protected]> | ||
* | ||
* You may use this file under the terms of the BSD license as follows: | ||
* | ||
|
@@ -45,11 +45,13 @@ | |
#define KEY_NEXT_COLOR_INDEX DCONF_KEY("nextColorIndex") | ||
#define KEY_SHARED_KEY_WARNING DCONF_KEY("sharedKeyWarning") | ||
#define KEY_SHARED_KEY_WARNING2 DCONF_KEY("sharedKeyWarning2") | ||
#define KEY_AUTO_LOCK DCONF_KEY("autoLock") | ||
#define KEY_AUTO_LOCK_TIME DCONF_KEY("autoLockTime") | ||
#define KEY_PLAINTEXT_VIEW DCONF_KEY("plaintextView") | ||
|
||
#define DEFAULT_NEXT_COLOR_INDEX 0 | ||
#define DEFAULT_SHARED_KEY_WARNING true | ||
#define DEFAULT_AUTO_LOCK true | ||
#define DEFAULT_AUTO_LOCK_TIME 15000 | ||
#define DEFAULT_PLAINTEXT_VIEW false | ||
|
||
|
@@ -76,6 +78,7 @@ public Q_SLOTS: | |
MGConfItem* iNextColorIndex; | ||
MGConfItem* iSharedKeyWarning; | ||
MGConfItem* iSharedKeyWarning2; | ||
MGConfItem* iAutoLock; | ||
MGConfItem* iAutoLockTime; | ||
MGConfItem* iPlainTextView; | ||
const QStringList iDefaultColors; | ||
|
@@ -98,6 +101,7 @@ FoilNotesSettings::Private::Private(QObject* aParent) : | |
iNextColorIndex(new MGConfItem(KEY_NEXT_COLOR_INDEX, aParent)), | ||
iSharedKeyWarning(new MGConfItem(KEY_SHARED_KEY_WARNING, aParent)), | ||
iSharedKeyWarning2(new MGConfItem(KEY_SHARED_KEY_WARNING2, aParent)), | ||
iAutoLock(new MGConfItem(KEY_AUTO_LOCK, aParent)), | ||
iAutoLockTime(new MGConfItem(KEY_AUTO_LOCK_TIME, aParent)), | ||
iPlainTextView(new MGConfItem(KEY_PLAINTEXT_VIEW, aParent)), | ||
iDefaultColors(defaultColors()), | ||
|
@@ -112,14 +116,17 @@ FoilNotesSettings::Private::Private(QObject* aParent) : | |
aParent, SIGNAL(sharedKeyWarningChanged())); | ||
QObject::connect(iSharedKeyWarning2, SIGNAL(valueChanged()), | ||
aParent, SIGNAL(sharedKeyWarning2Changed())); | ||
QObject::connect(iAutoLock, SIGNAL(valueChanged()), | ||
aParent, SIGNAL(autoLockChanged())); | ||
QObject::connect(iAutoLockTime, SIGNAL(valueChanged()), | ||
aParent, SIGNAL(autoLockTimeChanged())); | ||
QObject::connect(iPlainTextView, SIGNAL(valueChanged()), | ||
aParent, SIGNAL(plaintextViewChanged())); | ||
iAvailableColors = availableColors(); | ||
} | ||
|
||
QStringList FoilNotesSettings::Private::defaultColors() | ||
QStringList | ||
FoilNotesSettings::Private::defaultColors() | ||
{ | ||
QStringList colors; | ||
const uint n = sizeof(gAvailableColors)/sizeof(gAvailableColors[0]); | ||
|
@@ -130,12 +137,14 @@ QStringList FoilNotesSettings::Private::defaultColors() | |
return colors; | ||
} | ||
|
||
QStringList FoilNotesSettings::Private::availableColors() const | ||
QStringList | ||
FoilNotesSettings::Private::availableColors() const | ||
{ | ||
return iAvailableColorsConf->value(iDefaultColors).toStringList(); | ||
} | ||
|
||
void FoilNotesSettings::Private::onAvailableColorsChanged() | ||
void | ||
FoilNotesSettings::Private::onAvailableColorsChanged() | ||
{ | ||
const QStringList newColors(availableColors()); | ||
if (iAvailableColors != newColors) { | ||
|
@@ -162,8 +171,8 @@ FoilNotesSettings::~FoilNotesSettings() | |
// Callback for qmlRegisterSingletonType<FoilNotesSettings> | ||
QObject* | ||
FoilNotesSettings::createSingleton( | ||
QQmlEngine* aEngine, | ||
QJSEngine* aScript) | ||
QQmlEngine*, | ||
QJSEngine*) | ||
{ | ||
return new FoilNotesSettings(); | ||
} | ||
|
@@ -184,7 +193,8 @@ FoilNotesSettings::availableColors() const | |
} | ||
|
||
void | ||
FoilNotesSettings::setAvailableColors(QStringList aColors) | ||
FoilNotesSettings::setAvailableColors( | ||
QStringList aColors) | ||
{ | ||
iPrivate->iAvailableColorsConf->set(aColors); | ||
if (iPrivate->iAvailableColors != aColors) { | ||
|
@@ -256,6 +266,22 @@ FoilNotesSettings::setSharedKeyWarning2( | |
iPrivate->iSharedKeyWarning2->set(aValue); | ||
} | ||
|
||
// autoLock | ||
|
||
bool | ||
FoilNotesSettings::autoLock() const | ||
{ | ||
return iPrivate->iAutoLock->value(DEFAULT_AUTO_LOCK).toBool(); | ||
} | ||
|
||
void | ||
FoilNotesSettings::setAutoLock( | ||
bool aValue) | ||
{ | ||
HDEBUG(aValue); | ||
iPrivate->iAutoLock->set(aValue); | ||
} | ||
|
||
// autoLockTime | ||
|
||
int | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
/* | ||
* Copyright (C) 2018-2021 Jolla Ltd. | ||
* Copyright (C) 2018-2021 Slava Monich <[email protected]> | ||
* Copyright (C) 2018-2023 Slava Monich <[email protected]> | ||
* | ||
* You may use this file under the terms of the BSD license as follows: | ||
* | ||
|
@@ -40,13 +40,15 @@ | |
class QQmlEngine; | ||
class QJSEngine; | ||
|
||
class FoilNotesSettings : public QObject { | ||
class FoilNotesSettings : public QObject | ||
{ | ||
Q_OBJECT | ||
Q_PROPERTY(QStringList defaultColors READ defaultColors CONSTANT) | ||
Q_PROPERTY(QStringList availableColors READ availableColors WRITE setAvailableColors NOTIFY availableColorsChanged) | ||
Q_PROPERTY(int nextColorIndex READ nextColorIndex WRITE setNextColorIndex NOTIFY nextColorIndexChanged) | ||
Q_PROPERTY(bool sharedKeyWarning READ sharedKeyWarning WRITE setSharedKeyWarning NOTIFY sharedKeyWarningChanged) | ||
Q_PROPERTY(bool sharedKeyWarning2 READ sharedKeyWarning2 WRITE setSharedKeyWarning2 NOTIFY sharedKeyWarning2Changed) | ||
Q_PROPERTY(bool autoLock READ autoLock WRITE setAutoLock NOTIFY autoLockChanged) | ||
Q_PROPERTY(int autoLockTime READ autoLockTime WRITE setAutoLockTime NOTIFY autoLockTimeChanged) | ||
Q_PROPERTY(bool plaintextView READ plaintextView WRITE setPlaintextView NOTIFY plaintextViewChanged) | ||
|
||
|
@@ -55,25 +57,28 @@ class FoilNotesSettings : public QObject { | |
~FoilNotesSettings(); | ||
|
||
// Callback for qmlRegisterSingletonType<FoilNotesSettings> | ||
static QObject* createSingleton(QQmlEngine* aEngine, QJSEngine* aScript); | ||
static QObject* createSingleton(QQmlEngine*, QJSEngine*); | ||
|
||
const QStringList defaultColors() const; | ||
QStringList availableColors() const; | ||
void setAvailableColors(QStringList aColors); | ||
void setAvailableColors(QStringList); | ||
|
||
int nextColorIndex() const; | ||
void setNextColorIndex(int aValue); | ||
void setNextColorIndex(int); | ||
|
||
bool sharedKeyWarning() const; | ||
bool sharedKeyWarning2() const; | ||
void setSharedKeyWarning(bool aValue); | ||
void setSharedKeyWarning2(bool aValue); | ||
void setSharedKeyWarning(bool); | ||
void setSharedKeyWarning2(bool); | ||
|
||
bool autoLock() const; | ||
void setAutoLock(bool); | ||
|
||
int autoLockTime() const; | ||
void setAutoLockTime(int aValue); | ||
void setAutoLockTime(int); | ||
|
||
bool plaintextView() const; | ||
void setPlaintextView(bool aValue); | ||
void setPlaintextView(bool); | ||
|
||
Q_INVOKABLE int pickColorIndex(); | ||
Q_INVOKABLE QColor pickColor(); | ||
|
@@ -83,6 +88,7 @@ class FoilNotesSettings : public QObject { | |
void nextColorIndexChanged(); | ||
void sharedKeyWarningChanged(); | ||
void sharedKeyWarning2Changed(); | ||
void autoLockChanged(); | ||
void autoLockTimeChanged(); | ||
void plaintextViewChanged(); | ||
|
||
|