2020-10-06 04:40:12 +03:00
|
|
|
/*
|
|
|
|
This file is part of Fernschreiber.
|
|
|
|
|
|
|
|
Fernschreiber is free software: you can redistribute it and/or modify
|
|
|
|
it under the terms of the GNU General Public License as published by
|
|
|
|
the Free Software Foundation, either version 3 of the License, or
|
|
|
|
(at your option) any later version.
|
|
|
|
|
|
|
|
Fernschreiber is distributed in the hope that it will be useful,
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
GNU General Public License for more details.
|
|
|
|
|
|
|
|
You should have received a copy of the GNU General Public License
|
|
|
|
along with Fernschreiber. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "appsettings.h"
|
|
|
|
|
2020-11-22 06:58:47 +03:00
|
|
|
#define DEBUG_MODULE AppSettings
|
|
|
|
#include "debuglog.h"
|
2020-10-06 04:40:12 +03:00
|
|
|
|
|
|
|
namespace {
|
|
|
|
const QString KEY_SEND_BY_ENTER("sendByEnter");
|
2021-01-01 03:30:23 +03:00
|
|
|
const QString KEY_FOCUS_TEXTAREA_AFTER_SEND("focusTextAreaAfterSend");
|
2020-11-08 23:13:04 +03:00
|
|
|
const QString KEY_USE_OPEN_WITH("useOpenWith");
|
2020-10-09 18:09:29 +03:00
|
|
|
const QString KEY_SHOW_STICKERS_AS_IMAGES("showStickersAsImages");
|
2020-11-11 04:10:34 +03:00
|
|
|
const QString KEY_ANIMATE_STICKERS("animateStickers");
|
2020-11-21 02:15:13 +03:00
|
|
|
const QString KEY_NOTIFICATION_TURNS_DISPLAY_ON("notificationTurnsDisplayOn");
|
2021-01-30 19:21:42 +03:00
|
|
|
const QString KEY_NOTIFICATION_SOUNDS_ENABLED("notificationSoundsEnabled");
|
2020-10-10 18:46:08 +03:00
|
|
|
const QString KEY_NOTIFICATION_FEEDBACK("notificationFeedback");
|
2021-02-09 23:55:45 +03:00
|
|
|
const QString KEY_STORAGE_OPTIMIZER("useStorageOptimizer");
|
2021-01-10 04:06:41 +03:00
|
|
|
const QString KEY_INLINEBOT_LOCATION_ACCESS("allowInlineBotLocationAccess");
|
2021-01-02 18:10:01 +03:00
|
|
|
const QString KEY_REMAINING_INTERACTION_HINTS("remainingInteractionHints");
|
2021-01-10 15:35:34 +03:00
|
|
|
const QString KEY_ONLINE_ONLY_MODE("onlineOnlyMode");
|
2021-02-04 00:16:22 +03:00
|
|
|
const QString KEY_DELAY_MESSAGE_READ("delayMessageRead");
|
2021-05-12 21:23:31 +03:00
|
|
|
const QString KEY_FOCUS_TEXTAREA_ON_CHAT_OPEN("focusTextAreaOnChatOpen");
|
2020-10-06 04:40:12 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
AppSettings::AppSettings(QObject *parent) : QObject(parent), settings("harbour-fernschreiber", "settings")
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
bool AppSettings::getSendByEnter() const
|
|
|
|
{
|
|
|
|
return settings.value(KEY_SEND_BY_ENTER, false).toBool();
|
|
|
|
}
|
|
|
|
|
|
|
|
void AppSettings::setSendByEnter(bool sendByEnter)
|
|
|
|
{
|
|
|
|
if (getSendByEnter() != sendByEnter) {
|
|
|
|
LOG(KEY_SEND_BY_ENTER << sendByEnter);
|
|
|
|
settings.setValue(KEY_SEND_BY_ENTER, sendByEnter);
|
|
|
|
emit sendByEnterChanged();
|
|
|
|
}
|
|
|
|
}
|
2020-10-09 18:09:29 +03:00
|
|
|
|
2021-01-01 03:30:23 +03:00
|
|
|
bool AppSettings::getFocusTextAreaAfterSend() const
|
|
|
|
{
|
|
|
|
return settings.value(KEY_FOCUS_TEXTAREA_AFTER_SEND, false).toBool();
|
|
|
|
}
|
|
|
|
|
|
|
|
void AppSettings::setFocusTextAreaAfterSend(bool focusTextAreaAfterSend)
|
|
|
|
{
|
|
|
|
if (getFocusTextAreaAfterSend() != focusTextAreaAfterSend) {
|
|
|
|
LOG(KEY_FOCUS_TEXTAREA_AFTER_SEND << focusTextAreaAfterSend);
|
|
|
|
settings.setValue(KEY_FOCUS_TEXTAREA_AFTER_SEND, focusTextAreaAfterSend);
|
|
|
|
emit focusTextAreaAfterSendChanged();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-11-08 23:13:04 +03:00
|
|
|
bool AppSettings::getUseOpenWith() const
|
|
|
|
{
|
|
|
|
return settings.value(KEY_USE_OPEN_WITH, true).toBool();
|
|
|
|
}
|
|
|
|
|
|
|
|
void AppSettings::setUseOpenWith(bool useOpenWith)
|
|
|
|
{
|
|
|
|
if (getUseOpenWith() != useOpenWith) {
|
|
|
|
LOG(KEY_USE_OPEN_WITH << useOpenWith);
|
|
|
|
settings.setValue(KEY_USE_OPEN_WITH, useOpenWith);
|
|
|
|
emit useOpenWithChanged();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-10-09 18:09:29 +03:00
|
|
|
bool AppSettings::showStickersAsImages() const
|
|
|
|
{
|
|
|
|
return settings.value(KEY_SHOW_STICKERS_AS_IMAGES, true).toBool();
|
|
|
|
}
|
|
|
|
|
|
|
|
void AppSettings::setShowStickersAsImages(bool showAsImages)
|
|
|
|
{
|
|
|
|
if (showStickersAsImages() != showAsImages) {
|
|
|
|
LOG(KEY_SHOW_STICKERS_AS_IMAGES << showAsImages);
|
|
|
|
settings.setValue(KEY_SHOW_STICKERS_AS_IMAGES, showAsImages);
|
|
|
|
emit showStickersAsImagesChanged();
|
|
|
|
}
|
|
|
|
}
|
2020-10-10 18:46:08 +03:00
|
|
|
|
2020-11-11 04:10:34 +03:00
|
|
|
bool AppSettings::animateStickers() const
|
|
|
|
{
|
|
|
|
return settings.value(KEY_ANIMATE_STICKERS, true).toBool();
|
|
|
|
}
|
|
|
|
|
|
|
|
void AppSettings::setAnimateStickers(bool animate)
|
|
|
|
{
|
|
|
|
if (animateStickers() != animate) {
|
|
|
|
LOG(KEY_ANIMATE_STICKERS << animate);
|
|
|
|
settings.setValue(KEY_ANIMATE_STICKERS, animate);
|
|
|
|
emit animateStickersChanged();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-11-21 02:15:13 +03:00
|
|
|
bool AppSettings::notificationTurnsDisplayOn() const
|
|
|
|
{
|
|
|
|
return settings.value(KEY_NOTIFICATION_TURNS_DISPLAY_ON, false).toBool();
|
|
|
|
}
|
|
|
|
|
|
|
|
void AppSettings::setNotificationTurnsDisplayOn(bool turnOn)
|
|
|
|
{
|
|
|
|
if (notificationTurnsDisplayOn() != turnOn) {
|
|
|
|
LOG(KEY_NOTIFICATION_TURNS_DISPLAY_ON << turnOn);
|
|
|
|
settings.setValue(KEY_NOTIFICATION_TURNS_DISPLAY_ON, turnOn);
|
|
|
|
emit notificationTurnsDisplayOnChanged();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-01-30 19:21:42 +03:00
|
|
|
bool AppSettings::notificationSoundsEnabled() const
|
|
|
|
{
|
|
|
|
return settings.value(KEY_NOTIFICATION_SOUNDS_ENABLED, true).toBool();
|
|
|
|
}
|
|
|
|
|
|
|
|
void AppSettings::setNotificationSoundsEnabled(bool enable)
|
|
|
|
{
|
|
|
|
if (notificationSoundsEnabled() != enable) {
|
|
|
|
LOG(KEY_NOTIFICATION_SOUNDS_ENABLED << enable);
|
|
|
|
settings.setValue(KEY_NOTIFICATION_SOUNDS_ENABLED, enable);
|
|
|
|
emit notificationSoundsEnabledChanged();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-10-10 18:46:08 +03:00
|
|
|
AppSettings::NotificationFeedback AppSettings::notificationFeedback() const
|
|
|
|
{
|
|
|
|
return (NotificationFeedback) settings.value(KEY_NOTIFICATION_FEEDBACK, (int) NotificationFeedbackAll).toInt();
|
|
|
|
}
|
|
|
|
|
|
|
|
void AppSettings::setNotificationFeedback(NotificationFeedback feedback)
|
|
|
|
{
|
|
|
|
if (notificationFeedback() != feedback) {
|
|
|
|
LOG(KEY_NOTIFICATION_FEEDBACK << feedback);
|
|
|
|
settings.setValue(KEY_NOTIFICATION_FEEDBACK, (int) feedback);
|
|
|
|
emit notificationFeedbackChanged();
|
|
|
|
}
|
|
|
|
}
|
2020-11-24 01:15:17 +03:00
|
|
|
|
|
|
|
bool AppSettings::storageOptimizer() const
|
|
|
|
{
|
2021-02-09 23:55:45 +03:00
|
|
|
return settings.value(KEY_STORAGE_OPTIMIZER, true).toBool();
|
2020-11-24 01:15:17 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
void AppSettings::setStorageOptimizer(bool enable)
|
|
|
|
{
|
|
|
|
if (storageOptimizer() != enable) {
|
|
|
|
LOG(KEY_STORAGE_OPTIMIZER << enable);
|
|
|
|
settings.setValue(KEY_STORAGE_OPTIMIZER, enable);
|
|
|
|
emit storageOptimizerChanged();
|
|
|
|
}
|
|
|
|
}
|
2021-01-02 18:10:01 +03:00
|
|
|
|
2021-01-10 04:06:41 +03:00
|
|
|
bool AppSettings::allowInlineBotLocationAccess() const
|
|
|
|
{
|
|
|
|
return settings.value(KEY_INLINEBOT_LOCATION_ACCESS, false).toBool();
|
|
|
|
}
|
|
|
|
|
|
|
|
void AppSettings::setAllowInlineBotLocationAccess(bool enable)
|
|
|
|
{
|
|
|
|
|
|
|
|
if (allowInlineBotLocationAccess() != enable) {
|
|
|
|
LOG(KEY_INLINEBOT_LOCATION_ACCESS << enable);
|
|
|
|
settings.setValue(KEY_INLINEBOT_LOCATION_ACCESS, enable);
|
|
|
|
emit allowInlineBotLocationAccessChanged();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-01-02 18:10:01 +03:00
|
|
|
int AppSettings::remainingInteractionHints() const
|
|
|
|
{
|
|
|
|
return settings.value(KEY_REMAINING_INTERACTION_HINTS, 3).toInt();
|
|
|
|
}
|
|
|
|
|
|
|
|
void AppSettings::setRemainingInteractionHints(int remainingHints)
|
|
|
|
{
|
|
|
|
if (remainingInteractionHints() != remainingHints) {
|
|
|
|
LOG(KEY_REMAINING_INTERACTION_HINTS << remainingHints);
|
|
|
|
settings.setValue(KEY_REMAINING_INTERACTION_HINTS, remainingHints);
|
|
|
|
emit remainingInteractionHintsChanged();
|
|
|
|
}
|
|
|
|
}
|
2021-01-10 15:35:34 +03:00
|
|
|
|
|
|
|
bool AppSettings::onlineOnlyMode() const
|
|
|
|
{
|
|
|
|
return settings.value(KEY_ONLINE_ONLY_MODE, false).toBool();
|
|
|
|
}
|
|
|
|
|
|
|
|
void AppSettings::setOnlineOnlyMode(bool enable)
|
|
|
|
{
|
|
|
|
if (onlineOnlyMode() != enable) {
|
|
|
|
LOG(KEY_ONLINE_ONLY_MODE << enable);
|
|
|
|
settings.setValue(KEY_ONLINE_ONLY_MODE, enable);
|
|
|
|
emit onlineOnlyModeChanged();
|
|
|
|
}
|
|
|
|
}
|
2021-02-04 00:16:22 +03:00
|
|
|
|
|
|
|
bool AppSettings::delayMessageRead() const
|
|
|
|
{
|
|
|
|
return settings.value(KEY_DELAY_MESSAGE_READ, true).toBool();
|
|
|
|
}
|
|
|
|
|
|
|
|
void AppSettings::setDelayMessageRead(bool enable)
|
|
|
|
{
|
|
|
|
if (delayMessageRead() != enable) {
|
|
|
|
LOG(KEY_DELAY_MESSAGE_READ << enable);
|
|
|
|
settings.setValue(KEY_DELAY_MESSAGE_READ, enable);
|
|
|
|
emit delayMessageReadChanged();
|
|
|
|
}
|
|
|
|
}
|
2021-05-12 21:23:31 +03:00
|
|
|
|
|
|
|
bool AppSettings::getFocusTextAreaOnChatOpen() const
|
|
|
|
{
|
|
|
|
return settings.value(KEY_FOCUS_TEXTAREA_ON_CHAT_OPEN, false).toBool();
|
|
|
|
}
|
|
|
|
|
|
|
|
void AppSettings::setFocusTextAreaOnChatOpen(bool focusTextAreaOnChatOpen)
|
|
|
|
{
|
|
|
|
if (getFocusTextAreaOnChatOpen() != focusTextAreaOnChatOpen) {
|
|
|
|
LOG(KEY_FOCUS_TEXTAREA_ON_CHAT_OPEN << focusTextAreaOnChatOpen);
|
|
|
|
settings.setValue(KEY_FOCUS_TEXTAREA_ON_CHAT_OPEN, focusTextAreaOnChatOpen);
|
|
|
|
emit focusTextAreaOnChatOpenChanged();
|
|
|
|
}
|
|
|
|
}
|