194 lines
6 KiB
C++
194 lines
6 KiB
C++
/*
|
|
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"
|
|
|
|
#define DEBUG_MODULE AppSettings
|
|
#include "debuglog.h"
|
|
|
|
namespace {
|
|
const QString KEY_SEND_BY_ENTER("sendByEnter");
|
|
const QString KEY_FOCUS_TEXTAREA_AFTER_SEND("focusTextAreaAfterSend");
|
|
const QString KEY_USE_OPEN_WITH("useOpenWith");
|
|
const QString KEY_SHOW_STICKERS_AS_IMAGES("showStickersAsImages");
|
|
const QString KEY_ANIMATE_STICKERS("animateStickers");
|
|
const QString KEY_NOTIFICATION_TURNS_DISPLAY_ON("notificationTurnsDisplayOn");
|
|
const QString KEY_NOTIFICATION_FEEDBACK("notificationFeedback");
|
|
const QString KEY_STORAGE_OPTIMIZER("storageOptimizer");
|
|
const QString KEY_INLINEBOT_LOCATION_ACCESS("allowInlineBotLocationAccess");
|
|
const QString KEY_REMAINING_INTERACTION_HINTS("remainingInteractionHints");
|
|
const QString KEY_ONLINE_ONLY_MODE("onlineOnlyMode");
|
|
}
|
|
|
|
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();
|
|
}
|
|
}
|
|
|
|
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();
|
|
}
|
|
}
|
|
|
|
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();
|
|
}
|
|
}
|
|
|
|
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();
|
|
}
|
|
}
|
|
|
|
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();
|
|
}
|
|
}
|
|
|
|
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();
|
|
}
|
|
}
|
|
|
|
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();
|
|
}
|
|
}
|
|
|
|
bool AppSettings::storageOptimizer() const
|
|
{
|
|
return settings.value(KEY_STORAGE_OPTIMIZER, false).toBool();
|
|
}
|
|
|
|
void AppSettings::setStorageOptimizer(bool enable)
|
|
{
|
|
if (storageOptimizer() != enable) {
|
|
LOG(KEY_STORAGE_OPTIMIZER << enable);
|
|
settings.setValue(KEY_STORAGE_OPTIMIZER, enable);
|
|
emit storageOptimizerChanged();
|
|
}
|
|
}
|
|
|
|
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();
|
|
}
|
|
}
|
|
|
|
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();
|
|
}
|
|
}
|
|
|
|
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();
|
|
}
|
|
}
|