2023-02-22 01:48:49 +03:00
|
|
|
// SPDX-FileCopyrightText: Nheko Contributors
|
2021-03-05 02:35:15 +03:00
|
|
|
//
|
|
|
|
// SPDX-License-Identifier: GPL-3.0-or-later
|
2017-11-02 01:41:13 +03:00
|
|
|
|
2017-11-25 23:47:06 +03:00
|
|
|
#include <QApplication>
|
2020-10-27 22:29:53 +03:00
|
|
|
#include <QCoreApplication>
|
2018-09-15 23:52:14 +03:00
|
|
|
#include <QFileDialog>
|
2022-01-30 15:31:39 +03:00
|
|
|
#include <QFontDatabase>
|
2018-09-15 23:52:14 +03:00
|
|
|
#include <QInputDialog>
|
|
|
|
#include <QMessageBox>
|
2020-02-15 04:35:26 +03:00
|
|
|
#include <QStandardPaths>
|
2019-08-10 20:14:37 +03:00
|
|
|
#include <QString>
|
2019-03-28 02:13:38 +03:00
|
|
|
#include <QTextStream>
|
2022-01-09 02:28:03 +03:00
|
|
|
#include <mtx/secret_storage.hpp>
|
2017-11-02 01:41:13 +03:00
|
|
|
|
2019-12-15 05:34:17 +03:00
|
|
|
#include "Cache.h"
|
2022-06-18 02:35:30 +03:00
|
|
|
#include "JdenticonProvider.h"
|
2022-01-09 02:28:03 +03:00
|
|
|
#include "MainWindow.h"
|
2018-08-21 09:22:51 +03:00
|
|
|
#include "MatrixClient.h"
|
2017-11-02 01:41:13 +03:00
|
|
|
#include "UserSettingsPage.h"
|
2018-07-22 19:48:58 +03:00
|
|
|
#include "Utils.h"
|
2021-10-14 23:53:11 +03:00
|
|
|
#include "encryption/Olm.h"
|
2022-01-30 15:16:36 +03:00
|
|
|
#include "ui/Theme.h"
|
2021-10-14 23:53:11 +03:00
|
|
|
#include "voip/CallDevices.h"
|
2017-11-02 01:41:13 +03:00
|
|
|
|
2018-09-30 14:33:54 +03:00
|
|
|
#include "config/nheko.h"
|
2018-03-22 17:20:22 +03:00
|
|
|
|
2020-12-28 00:56:43 +03:00
|
|
|
QSharedPointer<UserSettings> UserSettings::instance_;
|
|
|
|
|
|
|
|
UserSettings::UserSettings()
|
|
|
|
{
|
2021-09-18 01:22:33 +03:00
|
|
|
connect(
|
|
|
|
QCoreApplication::instance(), &QCoreApplication::aboutToQuit, []() { instance_.clear(); });
|
2020-12-28 00:56:43 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
QSharedPointer<UserSettings>
|
|
|
|
UserSettings::instance()
|
|
|
|
{
|
2021-09-18 01:22:33 +03:00
|
|
|
return instance_;
|
2020-12-28 00:56:43 +03:00
|
|
|
}
|
2017-11-02 01:41:13 +03:00
|
|
|
|
|
|
|
void
|
2020-12-28 00:56:43 +03:00
|
|
|
UserSettings::initialize(std::optional<QString> profile)
|
|
|
|
{
|
2021-09-18 01:22:33 +03:00
|
|
|
instance_.reset(new UserSettings());
|
|
|
|
instance_->load(profile);
|
2020-12-28 00:56:43 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
UserSettings::load(std::optional<QString> profile)
|
2017-11-02 01:41:13 +03:00
|
|
|
{
|
2023-11-01 08:10:58 +03:00
|
|
|
tray_ = settings.value("user/window/tray", false).toBool();
|
|
|
|
startInTray_ = settings.value("user/window/start_in_tray", false).toBool();
|
|
|
|
|
|
|
|
roomListWidth_ = settings.value("user/sidebar/room_list_width", -1).toInt();
|
|
|
|
communityListWidth_ = settings.value("user/sidebar/community_list_width", -1).toInt();
|
|
|
|
|
|
|
|
hasDesktopNotifications_ = settings.value("user/desktop_notifications", true).toBool();
|
|
|
|
hasAlertOnNotification_ = settings.value("user/alert_on_notification", false).toBool();
|
|
|
|
groupView_ = settings.value("user/group_view", true).toBool();
|
|
|
|
scrollbarsInRoomlist_ = settings.value("user/scrollbars_in_roomlist", false).toBool();
|
|
|
|
buttonsInTimeline_ = settings.value("user/timeline/buttons", true).toBool();
|
|
|
|
timelineMaxWidth_ = settings.value("user/timeline/max_width", 0).toInt();
|
2021-09-18 01:22:33 +03:00
|
|
|
messageHoverHighlight_ =
|
2023-11-01 08:10:58 +03:00
|
|
|
settings.value("user/timeline/message_hover_highlight", false).toBool();
|
2021-09-18 01:22:33 +03:00
|
|
|
enlargeEmojiOnlyMessages_ =
|
2023-11-01 08:10:58 +03:00
|
|
|
settings.value("user/timeline/enlarge_emoji_only_msg", false).toBool();
|
|
|
|
markdown_ = settings.value("user/markdown_enabled", true).toBool();
|
|
|
|
invertEnterKey_ = settings.value("user/invert_enter_key", false).toBool();
|
|
|
|
bubbles_ = settings.value("user/bubbles_enabled", false).toBool();
|
|
|
|
smallAvatars_ = settings.value("user/small_avatars_enabled", false).toBool();
|
|
|
|
animateImagesOnHover_ = settings.value("user/animate_images_on_hover", false).toBool();
|
|
|
|
typingNotifications_ = settings.value("user/typing_notifications", true).toBool();
|
|
|
|
sortByImportance_ = settings.value("user/sort_by_unread", true).toBool();
|
|
|
|
sortByAlphabet_ = settings.value("user/sort_by_alphabet", false).toBool();
|
|
|
|
readReceipts_ = settings.value("user/read_receipts", true).toBool();
|
|
|
|
theme_ = settings.value("user/theme", defaultTheme_).toString();
|
|
|
|
|
|
|
|
font_ = settings.value("user/font_family", "").toString();
|
|
|
|
|
|
|
|
avatarCircles_ = settings.value("user/avatar_circles", true).toBool();
|
|
|
|
useIdenticon_ = settings.value("user/use_identicon", true).toBool();
|
|
|
|
openImageExternal_ = settings.value("user/open_image_external", false).toBool();
|
|
|
|
openVideoExternal_ = settings.value("user/open_video_external", false).toBool();
|
|
|
|
decryptSidebar_ = settings.value("user/decrypt_sidebar", true).toBool();
|
|
|
|
decryptNotifications_ = settings.value("user/decrypt_notifications", true).toBool();
|
|
|
|
spaceNotifications_ = settings.value("user/space_notifications", true).toBool();
|
|
|
|
fancyEffects_ = settings.value("user/fancy_effects", true).toBool();
|
|
|
|
reducedMotion_ = settings.value("user/reduced_motion", false).toBool();
|
|
|
|
privacyScreen_ = settings.value("user/privacy_screen", false).toBool();
|
|
|
|
privacyScreenTimeout_ = settings.value("user/privacy_screen_timeout", 0).toInt();
|
|
|
|
exposeDBusApi_ = settings.value("user/expose_dbus_api", false).toBool();
|
|
|
|
updateSpaceVias_ = settings.value("user/space_background_maintenance", true).toBool();
|
|
|
|
expireEvents_ = settings.value("user/expired_events_background_maintenance", false).toBool();
|
|
|
|
|
|
|
|
mobileMode_ = settings.value("user/mobile_mode", false).toBool();
|
2023-12-31 22:18:46 +03:00
|
|
|
disableSwipe_ = settings.value("user/disable_swipe", false).toBool();
|
2023-11-01 08:10:58 +03:00
|
|
|
emojiFont_ = settings.value("user/emoji_font_family", "emoji").toString();
|
|
|
|
baseFontSize_ = settings.value("user/font_size", QFont().pointSizeF()).toDouble();
|
|
|
|
auto tempPresence = settings.value("user/presence", "").toString().toStdString();
|
2021-12-29 08:01:38 +03:00
|
|
|
auto presenceValue = QMetaEnum::fromType<Presence>().keyToValue(tempPresence.c_str());
|
2021-09-18 01:22:33 +03:00
|
|
|
if (presenceValue < 0)
|
|
|
|
presenceValue = 0;
|
2023-11-01 08:10:58 +03:00
|
|
|
presence_ = static_cast<Presence>(presenceValue);
|
|
|
|
ringtone_ = settings.value("user/ringtone", "Default").toString();
|
|
|
|
microphone_ = settings.value("user/microphone", QString()).toString();
|
|
|
|
camera_ = settings.value("user/camera", QString()).toString();
|
|
|
|
cameraResolution_ = settings.value("user/camera_resolution", QString()).toString();
|
|
|
|
cameraFrameRate_ = settings.value("user/camera_frame_rate", QString()).toString();
|
|
|
|
screenShareFrameRate_ = settings.value("user/screen_share_frame_rate", 5).toInt();
|
|
|
|
screenSharePiP_ = settings.value("user/screen_share_pip", true).toBool();
|
|
|
|
screenShareRemoteVideo_ = settings.value("user/screen_share_remote_video", false).toBool();
|
|
|
|
screenShareHideCursor_ = settings.value("user/screen_share_hide_cursor", false).toBool();
|
|
|
|
useStunServer_ = settings.value("user/use_stun_server", false).toBool();
|
2021-09-18 01:22:33 +03:00
|
|
|
|
|
|
|
if (profile) // set to "" if it's the default to maintain compatibility
|
2021-12-29 06:28:08 +03:00
|
|
|
profile_ = (*profile == QLatin1String("default")) ? QLatin1String("") : *profile;
|
2021-09-18 01:22:33 +03:00
|
|
|
else
|
2023-11-01 08:10:58 +03:00
|
|
|
profile_ = settings.value("user/currentProfile", "").toString();
|
2021-09-18 01:22:33 +03:00
|
|
|
|
2021-12-29 08:01:38 +03:00
|
|
|
QString prefix = (profile_ != QLatin1String("") && profile_ != QLatin1String("default"))
|
|
|
|
? "profile/" + profile_ + "/"
|
|
|
|
: QLatin1String("");
|
2021-09-18 01:22:33 +03:00
|
|
|
accessToken_ = settings.value(prefix + "auth/access_token", "").toString();
|
|
|
|
homeserver_ = settings.value(prefix + "auth/home_server", "").toString();
|
|
|
|
userId_ = settings.value(prefix + "auth/user_id", "").toString();
|
|
|
|
deviceId_ = settings.value(prefix + "auth/device_id", "").toString();
|
2023-05-30 02:28:25 +03:00
|
|
|
currentTagId_ = settings.value(prefix + "user/current_tag_id", "").toString();
|
2021-12-01 05:46:55 +03:00
|
|
|
hiddenTags_ = settings.value(prefix + "user/hidden_tags", QStringList{}).toStringList();
|
2022-04-29 00:00:12 +03:00
|
|
|
mutedTags_ = settings.value(prefix + "user/muted_tags", QStringList{"global"}).toStringList();
|
|
|
|
hiddenPins_ = settings.value(prefix + "user/hidden_pins", QStringList{}).toStringList();
|
2022-02-04 20:47:17 +03:00
|
|
|
hiddenWidgets_ = settings.value(prefix + "user/hidden_widgets", QStringList{}).toStringList();
|
2021-12-13 02:43:05 +03:00
|
|
|
recentReactions_ =
|
|
|
|
settings.value(prefix + "user/recent_reactions", QStringList{}).toStringList();
|
2021-12-01 05:46:55 +03:00
|
|
|
|
|
|
|
collapsedSpaces_.clear();
|
2021-12-29 01:22:01 +03:00
|
|
|
auto tempSpaces = settings.value(prefix + "user/collapsed_spaces", QList<QVariant>{}).toList();
|
2023-10-14 00:28:57 +03:00
|
|
|
for (const auto &e : std::as_const(tempSpaces))
|
2021-12-01 05:46:55 +03:00
|
|
|
collapsedSpaces_.push_back(e.toStringList());
|
2021-09-18 01:22:33 +03:00
|
|
|
|
|
|
|
shareKeysWithTrustedUsers_ =
|
|
|
|
settings.value(prefix + "user/automatically_share_keys_with_trusted_users", false).toBool();
|
|
|
|
onlyShareKeysWithVerifiedUsers_ =
|
|
|
|
settings.value(prefix + "user/only_share_keys_with_verified_users", false).toBool();
|
2022-03-10 22:46:06 +03:00
|
|
|
useOnlineKeyBackup_ = settings.value(prefix + "user/online_key_backup", true).toBool();
|
2021-09-18 01:22:33 +03:00
|
|
|
|
|
|
|
disableCertificateValidation_ =
|
2023-11-01 08:10:58 +03:00
|
|
|
settings.value("disable_certificate_validation", false).toBool();
|
2021-09-18 01:22:33 +03:00
|
|
|
|
|
|
|
applyTheme();
|
2023-11-01 08:20:44 +03:00
|
|
|
|
|
|
|
if (profile)
|
|
|
|
setProfile(profile_);
|
2017-11-25 23:47:06 +03:00
|
|
|
}
|
2022-06-18 02:35:30 +03:00
|
|
|
|
|
|
|
bool
|
|
|
|
UserSettings::useIdenticon() const
|
|
|
|
{
|
|
|
|
return useIdenticon_ && JdenticonProvider::isAvailable();
|
|
|
|
}
|
|
|
|
|
2020-05-26 23:27:05 +03:00
|
|
|
void
|
|
|
|
UserSettings::setMessageHoverHighlight(bool state)
|
|
|
|
{
|
2021-09-18 01:22:33 +03:00
|
|
|
if (state == messageHoverHighlight_)
|
|
|
|
return;
|
|
|
|
messageHoverHighlight_ = state;
|
|
|
|
emit messageHoverHighlightChanged(state);
|
|
|
|
save();
|
2020-05-26 23:27:05 +03:00
|
|
|
}
|
|
|
|
void
|
|
|
|
UserSettings::setEnlargeEmojiOnlyMessages(bool state)
|
|
|
|
{
|
2021-09-18 01:22:33 +03:00
|
|
|
if (state == enlargeEmojiOnlyMessages_)
|
|
|
|
return;
|
|
|
|
enlargeEmojiOnlyMessages_ = state;
|
|
|
|
emit enlargeEmojiOnlyMessagesChanged(state);
|
|
|
|
save();
|
2020-05-26 23:27:05 +03:00
|
|
|
}
|
|
|
|
void
|
|
|
|
UserSettings::setTray(bool state)
|
|
|
|
{
|
2021-09-18 01:22:33 +03:00
|
|
|
if (state == tray_)
|
|
|
|
return;
|
|
|
|
tray_ = state;
|
|
|
|
emit trayChanged(state);
|
|
|
|
save();
|
2020-05-26 23:27:05 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
UserSettings::setStartInTray(bool state)
|
|
|
|
{
|
2021-09-18 01:22:33 +03:00
|
|
|
if (state == startInTray_)
|
|
|
|
return;
|
|
|
|
startInTray_ = state;
|
|
|
|
emit startInTrayChanged(state);
|
|
|
|
save();
|
2020-05-26 23:27:05 +03:00
|
|
|
}
|
|
|
|
|
2020-10-24 17:21:00 +03:00
|
|
|
void
|
|
|
|
UserSettings::setMobileMode(bool state)
|
|
|
|
{
|
2021-09-18 01:22:33 +03:00
|
|
|
if (state == mobileMode_)
|
|
|
|
return;
|
|
|
|
mobileMode_ = state;
|
|
|
|
emit mobileModeChanged(state);
|
|
|
|
save();
|
2020-10-24 17:21:00 +03:00
|
|
|
}
|
|
|
|
|
2023-12-31 22:15:38 +03:00
|
|
|
void
|
|
|
|
UserSettings::setDisableSwipe(bool state)
|
|
|
|
{
|
|
|
|
if (state == disableSwipe_)
|
|
|
|
return;
|
|
|
|
disableSwipe_ = state;
|
|
|
|
emit disableSwipeChanged(state);
|
|
|
|
save();
|
|
|
|
}
|
|
|
|
|
2020-05-26 23:27:05 +03:00
|
|
|
void
|
|
|
|
UserSettings::setGroupView(bool state)
|
|
|
|
{
|
2021-09-18 01:22:33 +03:00
|
|
|
if (groupView_ == state)
|
|
|
|
return;
|
2020-05-26 23:27:05 +03:00
|
|
|
|
2021-09-18 01:22:33 +03:00
|
|
|
groupView_ = state;
|
|
|
|
emit groupViewStateChanged(state);
|
|
|
|
save();
|
2020-05-26 23:27:05 +03:00
|
|
|
}
|
|
|
|
|
2023-02-15 00:00:05 +03:00
|
|
|
void
|
|
|
|
UserSettings::setScrollbarsInRoomlist(bool state)
|
|
|
|
{
|
|
|
|
if (scrollbarsInRoomlist_ == state)
|
|
|
|
return;
|
|
|
|
|
|
|
|
scrollbarsInRoomlist_ = state;
|
|
|
|
emit scrollbarsInRoomlistChanged(state);
|
|
|
|
save();
|
|
|
|
}
|
|
|
|
|
2021-01-23 02:49:14 +03:00
|
|
|
void
|
2022-04-29 00:00:12 +03:00
|
|
|
UserSettings::setHiddenTags(const QStringList &hiddenTags)
|
2021-01-23 02:49:14 +03:00
|
|
|
{
|
2021-09-18 01:22:33 +03:00
|
|
|
hiddenTags_ = hiddenTags;
|
|
|
|
save();
|
2021-01-23 02:49:14 +03:00
|
|
|
}
|
|
|
|
|
2021-12-11 08:10:41 +03:00
|
|
|
void
|
2022-04-29 00:00:12 +03:00
|
|
|
UserSettings::setMutedTags(const QStringList &mutedTags)
|
|
|
|
{
|
|
|
|
mutedTags_ = mutedTags;
|
|
|
|
save();
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
UserSettings::setHiddenPins(const QStringList &hiddenTags)
|
2021-12-11 08:10:41 +03:00
|
|
|
{
|
|
|
|
hiddenPins_ = hiddenTags;
|
|
|
|
save();
|
|
|
|
emit hiddenPinsChanged();
|
|
|
|
}
|
|
|
|
|
2022-02-04 20:47:17 +03:00
|
|
|
void
|
2022-04-29 00:00:12 +03:00
|
|
|
UserSettings::setHiddenWidgets(const QStringList &hiddenTags)
|
2022-02-04 20:47:17 +03:00
|
|
|
{
|
|
|
|
hiddenWidgets_ = hiddenTags;
|
|
|
|
save();
|
|
|
|
emit hiddenWidgetsChanged();
|
|
|
|
}
|
|
|
|
|
2021-12-13 02:43:05 +03:00
|
|
|
void
|
|
|
|
UserSettings::setRecentReactions(QStringList recent)
|
|
|
|
{
|
|
|
|
recentReactions_ = recent;
|
|
|
|
save();
|
|
|
|
emit recentReactionsChanged();
|
|
|
|
}
|
|
|
|
|
2021-12-01 05:46:55 +03:00
|
|
|
void
|
|
|
|
UserSettings::setCollapsedSpaces(QList<QStringList> spaces)
|
|
|
|
{
|
|
|
|
collapsedSpaces_ = spaces;
|
|
|
|
save();
|
|
|
|
}
|
|
|
|
|
2022-04-14 18:02:55 +03:00
|
|
|
void
|
|
|
|
UserSettings::setExposeDBusApi(bool state)
|
|
|
|
{
|
|
|
|
if (exposeDBusApi_ == state)
|
|
|
|
return;
|
|
|
|
|
|
|
|
exposeDBusApi_ = state;
|
|
|
|
emit exposeDBusApiChanged(state);
|
|
|
|
save();
|
|
|
|
}
|
|
|
|
|
2023-03-14 05:02:54 +03:00
|
|
|
void
|
|
|
|
UserSettings::setUpdateSpaceVias(bool state)
|
|
|
|
{
|
|
|
|
if (updateSpaceVias_ == state)
|
|
|
|
return;
|
|
|
|
|
|
|
|
updateSpaceVias_ = state;
|
|
|
|
emit updateSpaceViasChanged(state);
|
|
|
|
save();
|
|
|
|
}
|
|
|
|
|
2023-07-05 01:08:37 +03:00
|
|
|
void
|
|
|
|
UserSettings::setExpireEvents(bool state)
|
|
|
|
{
|
|
|
|
if (expireEvents_ == state)
|
|
|
|
return;
|
|
|
|
|
|
|
|
expireEvents_ = state;
|
|
|
|
emit expireEventsChanged(state);
|
|
|
|
save();
|
|
|
|
}
|
|
|
|
|
2020-05-26 23:27:05 +03:00
|
|
|
void
|
2020-05-26 23:53:21 +03:00
|
|
|
UserSettings::setMarkdown(bool state)
|
2020-05-26 23:27:05 +03:00
|
|
|
{
|
2021-09-18 01:22:33 +03:00
|
|
|
if (state == markdown_)
|
|
|
|
return;
|
|
|
|
markdown_ = state;
|
|
|
|
emit markdownChanged(state);
|
|
|
|
save();
|
2020-05-26 23:27:05 +03:00
|
|
|
}
|
|
|
|
|
2022-11-05 01:53:36 +03:00
|
|
|
void
|
|
|
|
UserSettings::setInvertEnterKey(bool state)
|
|
|
|
{
|
|
|
|
if (state == invertEnterKey_)
|
|
|
|
return;
|
|
|
|
|
|
|
|
invertEnterKey_ = state;
|
|
|
|
emit invertEnterKeyChanged(state);
|
|
|
|
save();
|
|
|
|
}
|
|
|
|
|
2022-02-05 01:12:30 +03:00
|
|
|
void
|
|
|
|
UserSettings::setBubbles(bool state)
|
|
|
|
{
|
|
|
|
if (state == bubbles_)
|
|
|
|
return;
|
|
|
|
bubbles_ = state;
|
|
|
|
emit bubblesChanged(state);
|
|
|
|
save();
|
|
|
|
}
|
|
|
|
|
2022-02-13 15:12:51 +03:00
|
|
|
void
|
|
|
|
UserSettings::setSmallAvatars(bool state)
|
|
|
|
{
|
|
|
|
if (state == smallAvatars_)
|
|
|
|
return;
|
|
|
|
smallAvatars_ = state;
|
|
|
|
emit smallAvatarsChanged(state);
|
|
|
|
save();
|
|
|
|
}
|
|
|
|
|
2021-08-29 16:33:39 +03:00
|
|
|
void
|
|
|
|
UserSettings::setAnimateImagesOnHover(bool state)
|
|
|
|
{
|
2021-09-18 01:22:33 +03:00
|
|
|
if (state == animateImagesOnHover_)
|
|
|
|
return;
|
|
|
|
animateImagesOnHover_ = state;
|
|
|
|
emit animateImagesOnHoverChanged(state);
|
|
|
|
save();
|
2021-08-29 16:33:39 +03:00
|
|
|
}
|
|
|
|
|
2020-05-26 23:27:05 +03:00
|
|
|
void
|
|
|
|
UserSettings::setReadReceipts(bool state)
|
|
|
|
{
|
2021-09-18 01:22:33 +03:00
|
|
|
if (state == readReceipts_)
|
|
|
|
return;
|
|
|
|
readReceipts_ = state;
|
|
|
|
emit readReceiptsChanged(state);
|
|
|
|
save();
|
2020-05-26 23:27:05 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
UserSettings::setTypingNotifications(bool state)
|
|
|
|
{
|
2021-09-18 01:22:33 +03:00
|
|
|
if (state == typingNotifications_)
|
|
|
|
return;
|
|
|
|
typingNotifications_ = state;
|
|
|
|
emit typingNotificationsChanged(state);
|
|
|
|
save();
|
2020-05-26 23:27:05 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
UserSettings::setSortByImportance(bool state)
|
|
|
|
{
|
2021-09-18 01:22:33 +03:00
|
|
|
if (state == sortByImportance_)
|
|
|
|
return;
|
|
|
|
sortByImportance_ = state;
|
2023-04-13 14:45:00 +03:00
|
|
|
emit roomSortingChangedImportance(state);
|
|
|
|
save();
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
UserSettings::setSortByAlphabet(bool state)
|
|
|
|
{
|
|
|
|
if (state == sortByAlphabet_)
|
|
|
|
return;
|
|
|
|
sortByAlphabet_ = state;
|
|
|
|
emit roomSortingChangedAlphabetical(state);
|
2021-09-18 01:22:33 +03:00
|
|
|
save();
|
2020-05-26 23:27:05 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
UserSettings::setButtonsInTimeline(bool state)
|
|
|
|
{
|
2021-09-18 01:22:33 +03:00
|
|
|
if (state == buttonsInTimeline_)
|
|
|
|
return;
|
|
|
|
buttonsInTimeline_ = state;
|
|
|
|
emit buttonInTimelineChanged(state);
|
|
|
|
save();
|
2020-05-26 23:27:05 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
UserSettings::setTimelineMaxWidth(int state)
|
|
|
|
{
|
2021-09-18 01:22:33 +03:00
|
|
|
if (state == timelineMaxWidth_)
|
|
|
|
return;
|
|
|
|
timelineMaxWidth_ = state;
|
|
|
|
emit timelineMaxWidthChanged(state);
|
|
|
|
save();
|
2020-05-26 23:27:05 +03:00
|
|
|
}
|
2021-06-12 15:07:32 +03:00
|
|
|
void
|
|
|
|
UserSettings::setCommunityListWidth(int state)
|
|
|
|
{
|
2021-09-18 01:22:33 +03:00
|
|
|
if (state == communityListWidth_)
|
|
|
|
return;
|
|
|
|
communityListWidth_ = state;
|
|
|
|
emit communityListWidthChanged(state);
|
|
|
|
save();
|
2021-06-12 15:07:32 +03:00
|
|
|
}
|
|
|
|
void
|
|
|
|
UserSettings::setRoomListWidth(int state)
|
|
|
|
{
|
2021-09-18 01:22:33 +03:00
|
|
|
if (state == roomListWidth_)
|
|
|
|
return;
|
|
|
|
roomListWidth_ = state;
|
|
|
|
emit roomListWidthChanged(state);
|
|
|
|
save();
|
2021-06-12 15:07:32 +03:00
|
|
|
}
|
2020-05-26 23:27:05 +03:00
|
|
|
|
|
|
|
void
|
|
|
|
UserSettings::setDesktopNotifications(bool state)
|
|
|
|
{
|
2021-09-18 01:22:33 +03:00
|
|
|
if (state == hasDesktopNotifications_)
|
|
|
|
return;
|
|
|
|
hasDesktopNotifications_ = state;
|
|
|
|
emit desktopNotificationsChanged(state);
|
|
|
|
save();
|
2020-05-26 23:27:05 +03:00
|
|
|
}
|
|
|
|
|
2020-06-10 12:27:21 +03:00
|
|
|
void
|
|
|
|
UserSettings::setAlertOnNotification(bool state)
|
|
|
|
{
|
2021-09-18 01:22:33 +03:00
|
|
|
if (state == hasAlertOnNotification_)
|
|
|
|
return;
|
|
|
|
hasAlertOnNotification_ = state;
|
|
|
|
emit alertOnNotificationChanged(state);
|
|
|
|
save();
|
2020-06-10 12:27:21 +03:00
|
|
|
}
|
|
|
|
|
2020-05-26 23:27:05 +03:00
|
|
|
void
|
|
|
|
UserSettings::setAvatarCircles(bool state)
|
|
|
|
{
|
2021-09-18 01:22:33 +03:00
|
|
|
if (state == avatarCircles_)
|
|
|
|
return;
|
|
|
|
avatarCircles_ = state;
|
|
|
|
emit avatarCirclesChanged(state);
|
|
|
|
save();
|
2020-05-26 23:27:05 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
UserSettings::setDecryptSidebar(bool state)
|
|
|
|
{
|
2021-09-18 01:22:33 +03:00
|
|
|
if (state == decryptSidebar_)
|
|
|
|
return;
|
|
|
|
decryptSidebar_ = state;
|
|
|
|
emit decryptSidebarChanged(state);
|
|
|
|
save();
|
2020-05-26 23:27:05 +03:00
|
|
|
}
|
2017-11-25 23:47:06 +03:00
|
|
|
|
2022-10-13 18:37:28 +03:00
|
|
|
void
|
|
|
|
UserSettings::setDecryptNotifications(bool state)
|
|
|
|
{
|
|
|
|
if (state == decryptNotifications_)
|
|
|
|
return;
|
|
|
|
decryptNotifications_ = state;
|
|
|
|
emit decryptNotificationsChanged(state);
|
|
|
|
save();
|
|
|
|
}
|
|
|
|
|
2022-04-23 03:34:15 +03:00
|
|
|
void
|
2022-06-06 19:07:25 +03:00
|
|
|
UserSettings::setSpaceNotifications(bool state)
|
2022-04-23 03:34:15 +03:00
|
|
|
{
|
|
|
|
if (state == spaceNotifications_)
|
|
|
|
return;
|
|
|
|
spaceNotifications_ = state;
|
|
|
|
emit spaceNotificationsChanged(state);
|
|
|
|
save();
|
|
|
|
}
|
|
|
|
|
2022-12-10 18:17:15 +03:00
|
|
|
void
|
|
|
|
UserSettings::setFancyEffects(bool state)
|
|
|
|
{
|
|
|
|
if (state == fancyEffects_)
|
|
|
|
return;
|
|
|
|
fancyEffects_ = state;
|
|
|
|
emit fancyEffectsChanged(state);
|
|
|
|
save();
|
|
|
|
}
|
|
|
|
|
2023-02-06 15:56:23 +03:00
|
|
|
void
|
|
|
|
UserSettings::setReducedMotion(bool state)
|
|
|
|
{
|
|
|
|
if (state == reducedMotion_)
|
|
|
|
return;
|
|
|
|
reducedMotion_ = state;
|
|
|
|
emit reducedMotionChanged(state);
|
|
|
|
save();
|
|
|
|
|
|
|
|
// Also toggle other motion related settings
|
|
|
|
if (reducedMotion_) {
|
|
|
|
setFancyEffects(false);
|
|
|
|
setAnimateImagesOnHover(true);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-01-26 07:46:55 +03:00
|
|
|
void
|
|
|
|
UserSettings::setPrivacyScreen(bool state)
|
|
|
|
{
|
2021-09-18 01:22:33 +03:00
|
|
|
if (state == privacyScreen_) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
privacyScreen_ = state;
|
|
|
|
emit privacyScreenChanged(state);
|
|
|
|
save();
|
2021-01-26 07:46:55 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
UserSettings::setPrivacyScreenTimeout(int state)
|
|
|
|
{
|
2021-09-18 01:22:33 +03:00
|
|
|
if (state == privacyScreenTimeout_) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
privacyScreenTimeout_ = state;
|
|
|
|
emit privacyScreenTimeoutChanged(state);
|
|
|
|
save();
|
2021-01-26 07:46:55 +03:00
|
|
|
}
|
|
|
|
|
2018-10-06 17:21:03 +03:00
|
|
|
void
|
|
|
|
UserSettings::setFontSize(double size)
|
|
|
|
{
|
2021-09-18 01:22:33 +03:00
|
|
|
if (size == baseFontSize_)
|
|
|
|
return;
|
|
|
|
baseFontSize_ = size;
|
2022-03-05 05:25:24 +03:00
|
|
|
|
|
|
|
const static auto defaultFamily = QFont().defaultFamily();
|
|
|
|
QFont f((font_.isEmpty() || font_ == QStringLiteral("default")) ? defaultFamily : font_);
|
|
|
|
f.setPointSizeF(fontSize());
|
|
|
|
QApplication::setFont(f);
|
|
|
|
|
2021-09-18 01:22:33 +03:00
|
|
|
emit fontSizeChanged(size);
|
|
|
|
save();
|
2018-10-06 17:21:03 +03:00
|
|
|
}
|
|
|
|
|
2019-01-19 19:20:41 +03:00
|
|
|
void
|
|
|
|
UserSettings::setFontFamily(QString family)
|
|
|
|
{
|
2021-09-18 01:22:33 +03:00
|
|
|
if (family == font_)
|
|
|
|
return;
|
|
|
|
font_ = family;
|
2022-03-05 05:25:24 +03:00
|
|
|
|
|
|
|
const static auto defaultFamily = QFont().defaultFamily();
|
|
|
|
QFont f((family.isEmpty() || family == QStringLiteral("default")) ? defaultFamily : family);
|
|
|
|
f.setPointSizeF(fontSize());
|
|
|
|
QApplication::setFont(f);
|
|
|
|
|
2021-09-18 01:22:33 +03:00
|
|
|
emit fontChanged(family);
|
|
|
|
save();
|
2019-01-19 19:20:41 +03:00
|
|
|
}
|
|
|
|
|
2019-07-27 00:31:59 +03:00
|
|
|
void
|
|
|
|
UserSettings::setEmojiFontFamily(QString family)
|
|
|
|
{
|
2021-09-18 01:22:33 +03:00
|
|
|
if (family == emojiFont_)
|
|
|
|
return;
|
2021-02-07 19:45:06 +03:00
|
|
|
|
2021-09-18 01:22:33 +03:00
|
|
|
if (family == tr("Default")) {
|
2022-03-05 05:25:24 +03:00
|
|
|
emojiFont_ = QStringLiteral("emoji");
|
2021-09-18 01:22:33 +03:00
|
|
|
} else {
|
|
|
|
emojiFont_ = family;
|
|
|
|
}
|
2021-02-07 19:45:06 +03:00
|
|
|
|
2021-09-18 01:22:33 +03:00
|
|
|
emit emojiFontChanged(family);
|
|
|
|
save();
|
2019-07-27 00:31:59 +03:00
|
|
|
}
|
|
|
|
|
2020-06-08 21:26:37 +03:00
|
|
|
void
|
|
|
|
UserSettings::setPresence(Presence state)
|
|
|
|
{
|
2021-09-18 01:22:33 +03:00
|
|
|
if (state == presence_)
|
|
|
|
return;
|
|
|
|
presence_ = state;
|
|
|
|
emit presenceChanged(state);
|
|
|
|
save();
|
2020-06-08 21:26:37 +03:00
|
|
|
}
|
|
|
|
|
2017-11-25 23:47:06 +03:00
|
|
|
void
|
|
|
|
UserSettings::setTheme(QString theme)
|
|
|
|
{
|
2021-09-18 01:22:33 +03:00
|
|
|
if (theme == theme_)
|
|
|
|
return;
|
|
|
|
theme_ = theme;
|
|
|
|
save();
|
|
|
|
applyTheme();
|
|
|
|
emit themeChanged(theme);
|
2017-11-25 23:47:06 +03:00
|
|
|
}
|
|
|
|
|
2020-07-11 02:19:48 +03:00
|
|
|
void
|
|
|
|
UserSettings::setUseStunServer(bool useStunServer)
|
|
|
|
{
|
2021-09-18 01:22:33 +03:00
|
|
|
if (useStunServer == useStunServer_)
|
|
|
|
return;
|
|
|
|
useStunServer_ = useStunServer;
|
|
|
|
emit useStunServerChanged(useStunServer);
|
|
|
|
save();
|
2020-07-11 02:19:48 +03:00
|
|
|
}
|
|
|
|
|
2021-08-01 01:59:46 +03:00
|
|
|
void
|
|
|
|
UserSettings::setOnlyShareKeysWithVerifiedUsers(bool shareKeys)
|
|
|
|
{
|
2021-09-18 01:22:33 +03:00
|
|
|
if (shareKeys == onlyShareKeysWithVerifiedUsers_)
|
|
|
|
return;
|
2021-08-01 01:59:46 +03:00
|
|
|
|
2021-09-18 01:22:33 +03:00
|
|
|
onlyShareKeysWithVerifiedUsers_ = shareKeys;
|
|
|
|
emit onlyShareKeysWithVerifiedUsersChanged(shareKeys);
|
|
|
|
save();
|
2021-08-01 01:59:46 +03:00
|
|
|
}
|
|
|
|
|
2020-10-18 01:52:35 +03:00
|
|
|
void
|
|
|
|
UserSettings::setShareKeysWithTrustedUsers(bool shareKeys)
|
|
|
|
{
|
2021-09-18 01:22:33 +03:00
|
|
|
if (shareKeys == shareKeysWithTrustedUsers_)
|
|
|
|
return;
|
2020-10-23 17:59:18 +03:00
|
|
|
|
2021-09-18 01:22:33 +03:00
|
|
|
shareKeysWithTrustedUsers_ = shareKeys;
|
|
|
|
emit shareKeysWithTrustedUsersChanged(shareKeys);
|
|
|
|
save();
|
2020-10-18 01:52:35 +03:00
|
|
|
}
|
|
|
|
|
2021-08-17 04:23:51 +03:00
|
|
|
void
|
|
|
|
UserSettings::setUseOnlineKeyBackup(bool useBackup)
|
|
|
|
{
|
2021-09-18 01:22:33 +03:00
|
|
|
if (useBackup == useOnlineKeyBackup_)
|
|
|
|
return;
|
2021-08-17 04:23:51 +03:00
|
|
|
|
2021-09-18 01:22:33 +03:00
|
|
|
useOnlineKeyBackup_ = useBackup;
|
|
|
|
emit useOnlineKeyBackupChanged(useBackup);
|
|
|
|
save();
|
2022-06-18 21:16:52 +03:00
|
|
|
|
|
|
|
if (useBackup)
|
|
|
|
olm::download_full_keybackup();
|
2021-08-17 04:23:51 +03:00
|
|
|
}
|
|
|
|
|
2020-11-13 03:55:35 +03:00
|
|
|
void
|
|
|
|
UserSettings::setRingtone(QString ringtone)
|
|
|
|
{
|
2021-09-18 01:22:33 +03:00
|
|
|
if (ringtone == ringtone_)
|
|
|
|
return;
|
|
|
|
ringtone_ = ringtone;
|
|
|
|
emit ringtoneChanged(ringtone);
|
|
|
|
save();
|
2020-11-13 03:55:35 +03:00
|
|
|
}
|
|
|
|
|
2020-08-06 00:56:44 +03:00
|
|
|
void
|
2020-10-27 20:14:06 +03:00
|
|
|
UserSettings::setMicrophone(QString microphone)
|
2020-08-06 00:56:44 +03:00
|
|
|
{
|
2021-09-18 01:22:33 +03:00
|
|
|
if (microphone == microphone_)
|
|
|
|
return;
|
|
|
|
microphone_ = microphone;
|
|
|
|
emit microphoneChanged(microphone);
|
|
|
|
save();
|
2020-10-27 20:14:06 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
UserSettings::setCamera(QString camera)
|
|
|
|
{
|
2021-09-18 01:22:33 +03:00
|
|
|
if (camera == camera_)
|
|
|
|
return;
|
|
|
|
camera_ = camera;
|
|
|
|
emit cameraChanged(camera);
|
|
|
|
save();
|
2020-10-27 20:14:06 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
UserSettings::setCameraResolution(QString resolution)
|
|
|
|
{
|
2021-09-18 01:22:33 +03:00
|
|
|
if (resolution == cameraResolution_)
|
|
|
|
return;
|
|
|
|
cameraResolution_ = resolution;
|
|
|
|
emit cameraResolutionChanged(resolution);
|
|
|
|
save();
|
2020-10-27 20:14:06 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
UserSettings::setCameraFrameRate(QString frameRate)
|
|
|
|
{
|
2021-09-18 01:22:33 +03:00
|
|
|
if (frameRate == cameraFrameRate_)
|
|
|
|
return;
|
|
|
|
cameraFrameRate_ = frameRate;
|
|
|
|
emit cameraFrameRateChanged(frameRate);
|
|
|
|
save();
|
2020-08-06 00:56:44 +03:00
|
|
|
}
|
|
|
|
|
2021-02-18 23:55:29 +03:00
|
|
|
void
|
|
|
|
UserSettings::setScreenShareFrameRate(int frameRate)
|
|
|
|
{
|
2021-09-18 01:22:33 +03:00
|
|
|
if (frameRate == screenShareFrameRate_)
|
|
|
|
return;
|
|
|
|
screenShareFrameRate_ = frameRate;
|
|
|
|
emit screenShareFrameRateChanged(frameRate);
|
|
|
|
save();
|
2021-02-18 23:55:29 +03:00
|
|
|
}
|
|
|
|
|
2021-02-20 19:26:53 +03:00
|
|
|
void
|
|
|
|
UserSettings::setScreenSharePiP(bool state)
|
|
|
|
{
|
2021-09-18 01:22:33 +03:00
|
|
|
if (state == screenSharePiP_)
|
|
|
|
return;
|
|
|
|
screenSharePiP_ = state;
|
|
|
|
emit screenSharePiPChanged(state);
|
|
|
|
save();
|
2021-02-20 19:26:53 +03:00
|
|
|
}
|
|
|
|
|
2021-02-18 23:55:29 +03:00
|
|
|
void
|
|
|
|
UserSettings::setScreenShareRemoteVideo(bool state)
|
|
|
|
{
|
2021-09-18 01:22:33 +03:00
|
|
|
if (state == screenShareRemoteVideo_)
|
|
|
|
return;
|
|
|
|
screenShareRemoteVideo_ = state;
|
|
|
|
emit screenShareRemoteVideoChanged(state);
|
|
|
|
save();
|
2021-02-18 23:55:29 +03:00
|
|
|
}
|
|
|
|
|
2021-02-19 00:53:30 +03:00
|
|
|
void
|
|
|
|
UserSettings::setScreenShareHideCursor(bool state)
|
|
|
|
{
|
2021-09-18 01:22:33 +03:00
|
|
|
if (state == screenShareHideCursor_)
|
|
|
|
return;
|
|
|
|
screenShareHideCursor_ = state;
|
|
|
|
emit screenShareHideCursorChanged(state);
|
|
|
|
save();
|
2021-02-19 00:53:30 +03:00
|
|
|
}
|
|
|
|
|
2020-11-10 05:28:41 +03:00
|
|
|
void
|
|
|
|
UserSettings::setProfile(QString profile)
|
|
|
|
{
|
2023-11-01 08:20:44 +03:00
|
|
|
// always set this to allow setting this when loading and it is overwritten on the cli
|
2021-09-18 01:22:33 +03:00
|
|
|
profile_ = profile;
|
|
|
|
emit profileChanged(profile_);
|
|
|
|
save();
|
2020-11-10 05:28:41 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
UserSettings::setUserId(QString userId)
|
|
|
|
{
|
2021-09-18 01:22:33 +03:00
|
|
|
if (userId == userId_)
|
|
|
|
return;
|
|
|
|
userId_ = userId;
|
|
|
|
emit userIdChanged(userId_);
|
|
|
|
save();
|
2020-11-10 05:28:41 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
UserSettings::setAccessToken(QString accessToken)
|
|
|
|
{
|
2021-09-18 01:22:33 +03:00
|
|
|
if (accessToken == accessToken_)
|
|
|
|
return;
|
|
|
|
accessToken_ = accessToken;
|
|
|
|
emit accessTokenChanged(accessToken_);
|
|
|
|
save();
|
2020-11-10 05:28:41 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
UserSettings::setDeviceId(QString deviceId)
|
|
|
|
{
|
2021-09-18 01:22:33 +03:00
|
|
|
if (deviceId == deviceId_)
|
|
|
|
return;
|
|
|
|
deviceId_ = deviceId;
|
|
|
|
emit deviceIdChanged(deviceId_);
|
|
|
|
save();
|
2020-11-10 05:28:41 +03:00
|
|
|
}
|
|
|
|
|
2023-05-30 02:28:25 +03:00
|
|
|
void
|
|
|
|
UserSettings::setCurrentTagId(const QString currentTagId)
|
|
|
|
{
|
|
|
|
if (currentTagId == currentTagId_)
|
|
|
|
return;
|
|
|
|
currentTagId_ = currentTagId;
|
|
|
|
save();
|
|
|
|
}
|
|
|
|
|
2020-11-10 05:28:41 +03:00
|
|
|
void
|
|
|
|
UserSettings::setHomeserver(QString homeserver)
|
|
|
|
{
|
2021-09-18 01:22:33 +03:00
|
|
|
if (homeserver == homeserver_)
|
|
|
|
return;
|
|
|
|
homeserver_ = homeserver;
|
|
|
|
emit homeserverChanged(homeserver_);
|
|
|
|
save();
|
2020-11-10 05:28:41 +03:00
|
|
|
}
|
|
|
|
|
2021-03-06 22:52:08 +03:00
|
|
|
void
|
|
|
|
UserSettings::setDisableCertificateValidation(bool disabled)
|
|
|
|
{
|
2021-09-18 01:22:33 +03:00
|
|
|
if (disabled == disableCertificateValidation_)
|
|
|
|
return;
|
|
|
|
disableCertificateValidation_ = disabled;
|
|
|
|
http::client()->verify_certificates(!disabled);
|
|
|
|
emit disableCertificateValidationChanged(disabled);
|
2020-12-25 17:14:00 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
UserSettings::setUseIdenticon(bool state)
|
|
|
|
{
|
2021-09-18 01:22:33 +03:00
|
|
|
if (state == useIdenticon_)
|
|
|
|
return;
|
|
|
|
useIdenticon_ = state;
|
|
|
|
emit useIdenticonChanged(useIdenticon_);
|
|
|
|
save();
|
2021-03-06 22:52:08 +03:00
|
|
|
}
|
|
|
|
|
2022-03-19 07:54:02 +03:00
|
|
|
void
|
|
|
|
UserSettings::setOpenImageExternal(bool state)
|
|
|
|
{
|
|
|
|
if (state == openImageExternal_)
|
|
|
|
return;
|
|
|
|
openImageExternal_ = state;
|
|
|
|
emit openImageExternalChanged(openImageExternal_);
|
|
|
|
save();
|
|
|
|
}
|
|
|
|
|
2022-03-19 08:31:43 +03:00
|
|
|
void
|
|
|
|
UserSettings::setOpenVideoExternal(bool state)
|
|
|
|
{
|
|
|
|
if (state == openVideoExternal_)
|
|
|
|
return;
|
|
|
|
openVideoExternal_ = state;
|
|
|
|
emit openVideoExternalChanged(openVideoExternal_);
|
|
|
|
save();
|
|
|
|
}
|
|
|
|
|
2017-11-25 23:47:06 +03:00
|
|
|
void
|
|
|
|
UserSettings::applyTheme()
|
|
|
|
{
|
2023-06-02 03:58:36 +03:00
|
|
|
QGuiApplication::setPalette(Theme::paletteFromTheme(this->theme()));
|
|
|
|
QApplication::setPalette(Theme::paletteFromTheme(this->theme()));
|
2017-11-02 01:41:13 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
UserSettings::save()
|
|
|
|
{
|
2023-11-01 08:10:58 +03:00
|
|
|
settings.beginGroup("user");
|
2021-09-18 01:22:33 +03:00
|
|
|
|
2023-11-01 08:10:58 +03:00
|
|
|
settings.beginGroup("window");
|
|
|
|
settings.setValue("tray", tray_);
|
|
|
|
settings.setValue("start_in_tray", startInTray_);
|
2021-09-18 01:22:33 +03:00
|
|
|
settings.endGroup(); // window
|
|
|
|
|
2023-11-01 08:10:58 +03:00
|
|
|
settings.beginGroup("sidebar");
|
|
|
|
settings.setValue("community_list_width", communityListWidth_);
|
|
|
|
settings.setValue("room_list_width", roomListWidth_);
|
2021-09-18 01:22:33 +03:00
|
|
|
settings.endGroup(); // window
|
|
|
|
|
2023-11-01 08:10:58 +03:00
|
|
|
settings.beginGroup("timeline");
|
|
|
|
settings.setValue("buttons", buttonsInTimeline_);
|
|
|
|
settings.setValue("message_hover_highlight", messageHoverHighlight_);
|
|
|
|
settings.setValue("enlarge_emoji_only_msg", enlargeEmojiOnlyMessages_);
|
|
|
|
settings.setValue("max_width", timelineMaxWidth_);
|
2021-09-18 01:22:33 +03:00
|
|
|
settings.endGroup(); // timeline
|
|
|
|
|
2023-11-01 08:10:58 +03:00
|
|
|
settings.setValue("avatar_circles", avatarCircles_);
|
|
|
|
settings.setValue("decrypt_sidebar", decryptSidebar_);
|
|
|
|
settings.setValue("decrypt_notifications", decryptNotifications_);
|
|
|
|
settings.setValue("space_notifications", spaceNotifications_);
|
|
|
|
settings.setValue("fancy_effects", fancyEffects_);
|
|
|
|
settings.setValue("reduced_motion", reducedMotion_);
|
|
|
|
settings.setValue("privacy_screen", privacyScreen_);
|
|
|
|
settings.setValue("privacy_screen_timeout", privacyScreenTimeout_);
|
|
|
|
settings.setValue("mobile_mode", mobileMode_);
|
2023-12-31 22:15:38 +03:00
|
|
|
settings.setValue("disable_swipe", disableSwipe_);
|
2023-11-01 08:10:58 +03:00
|
|
|
settings.setValue("font_size", baseFontSize_);
|
|
|
|
settings.setValue("typing_notifications", typingNotifications_);
|
|
|
|
settings.setValue("sort_by_unread", sortByImportance_);
|
|
|
|
settings.setValue("sort_by_alphabet", sortByAlphabet_);
|
|
|
|
settings.setValue("minor_events", sortByImportance_);
|
|
|
|
settings.setValue("read_receipts", readReceipts_);
|
|
|
|
settings.setValue("group_view", groupView_);
|
|
|
|
settings.setValue("scrollbars_in_roomlist", scrollbarsInRoomlist_);
|
|
|
|
settings.setValue("markdown_enabled", markdown_);
|
|
|
|
settings.setValue("invert_enter_key", invertEnterKey_);
|
|
|
|
settings.setValue("bubbles_enabled", bubbles_);
|
|
|
|
settings.setValue("small_avatars_enabled", smallAvatars_);
|
|
|
|
settings.setValue("animate_images_on_hover", animateImagesOnHover_);
|
|
|
|
settings.setValue("desktop_notifications", hasDesktopNotifications_);
|
|
|
|
settings.setValue("alert_on_notification", hasAlertOnNotification_);
|
|
|
|
settings.setValue("theme", theme());
|
|
|
|
settings.setValue("font_family", font_);
|
|
|
|
settings.setValue("emoji_font_family", emojiFont_);
|
2021-09-18 01:22:33 +03:00
|
|
|
settings.setValue(
|
2023-11-01 08:10:58 +03:00
|
|
|
"presence",
|
2021-09-18 01:22:33 +03:00
|
|
|
QString::fromUtf8(QMetaEnum::fromType<Presence>().valueToKey(static_cast<int>(presence_))));
|
2023-11-01 08:10:58 +03:00
|
|
|
settings.setValue("ringtone", ringtone_);
|
|
|
|
settings.setValue("microphone", microphone_);
|
|
|
|
settings.setValue("camera", camera_);
|
|
|
|
settings.setValue("camera_resolution", cameraResolution_);
|
|
|
|
settings.setValue("camera_frame_rate", cameraFrameRate_);
|
|
|
|
settings.setValue("screen_share_frame_rate", screenShareFrameRate_);
|
|
|
|
settings.setValue("screen_share_pip", screenSharePiP_);
|
|
|
|
settings.setValue("screen_share_remote_video", screenShareRemoteVideo_);
|
|
|
|
settings.setValue("screen_share_hide_cursor", screenShareHideCursor_);
|
|
|
|
settings.setValue("use_stun_server", useStunServer_);
|
|
|
|
settings.setValue("currentProfile", profile_);
|
|
|
|
settings.setValue("use_identicon", useIdenticon_);
|
|
|
|
settings.setValue("open_image_external", openImageExternal_);
|
|
|
|
settings.setValue("open_video_external", openVideoExternal_);
|
|
|
|
settings.setValue("expose_dbus_api", exposeDBusApi_);
|
|
|
|
settings.setValue("space_background_maintenance", updateSpaceVias_);
|
|
|
|
settings.setValue("expired_events_background_maintenance", expireEvents_);
|
2021-09-18 01:22:33 +03:00
|
|
|
|
|
|
|
settings.endGroup(); // user
|
|
|
|
|
2021-12-29 08:01:38 +03:00
|
|
|
QString prefix = (profile_ != QLatin1String("") && profile_ != QLatin1String("default"))
|
|
|
|
? "profile/" + profile_ + "/"
|
|
|
|
: QLatin1String("");
|
2021-09-18 01:22:33 +03:00
|
|
|
settings.setValue(prefix + "auth/access_token", accessToken_);
|
|
|
|
settings.setValue(prefix + "auth/home_server", homeserver_);
|
|
|
|
settings.setValue(prefix + "auth/user_id", userId_);
|
|
|
|
settings.setValue(prefix + "auth/device_id", deviceId_);
|
2023-05-30 02:28:25 +03:00
|
|
|
settings.setValue(prefix + "user/current_tag_id", currentTagId_);
|
2021-09-18 01:22:33 +03:00
|
|
|
settings.setValue(prefix + "user/automatically_share_keys_with_trusted_users",
|
|
|
|
shareKeysWithTrustedUsers_);
|
|
|
|
settings.setValue(prefix + "user/only_share_keys_with_verified_users",
|
|
|
|
onlyShareKeysWithVerifiedUsers_);
|
|
|
|
settings.setValue(prefix + "user/online_key_backup", useOnlineKeyBackup_);
|
2021-12-01 05:46:55 +03:00
|
|
|
settings.setValue(prefix + "user/hidden_tags", hiddenTags_);
|
2022-04-29 00:00:12 +03:00
|
|
|
settings.setValue(prefix + "user/muted_tags", mutedTags_);
|
2021-12-11 08:10:41 +03:00
|
|
|
settings.setValue(prefix + "user/hidden_pins", hiddenPins_);
|
2022-02-04 20:47:17 +03:00
|
|
|
settings.setValue(prefix + "user/hidden_widgets", hiddenWidgets_);
|
2021-12-13 02:43:05 +03:00
|
|
|
settings.setValue(prefix + "user/recent_reactions", recentReactions_);
|
2021-12-01 05:46:55 +03:00
|
|
|
|
|
|
|
QVariantList v;
|
2021-12-29 08:01:38 +03:00
|
|
|
v.reserve(collapsedSpaces_.size());
|
2023-10-14 00:28:57 +03:00
|
|
|
for (const auto &e : std::as_const(collapsedSpaces_))
|
2021-12-01 05:46:55 +03:00
|
|
|
v.push_back(e);
|
|
|
|
settings.setValue(prefix + "user/collapsed_spaces", v);
|
2021-09-18 01:22:33 +03:00
|
|
|
|
2023-11-01 08:10:58 +03:00
|
|
|
settings.setValue("disable_certificate_validation", disableCertificateValidation_);
|
2021-09-18 01:22:33 +03:00
|
|
|
|
|
|
|
settings.sync();
|
2017-11-02 01:41:13 +03:00
|
|
|
}
|
|
|
|
|
2022-01-09 02:28:03 +03:00
|
|
|
QHash<int, QByteArray>
|
|
|
|
UserSettingsModel::roleNames() const
|
|
|
|
{
|
|
|
|
static QHash<int, QByteArray> roles{
|
|
|
|
{Name, "name"},
|
|
|
|
{Description, "description"},
|
|
|
|
{Value, "value"},
|
|
|
|
{Type, "type"},
|
|
|
|
{ValueLowerBound, "valueLowerBound"},
|
|
|
|
{ValueUpperBound, "valueUpperBound"},
|
|
|
|
{ValueStep, "valueStep"},
|
|
|
|
{Values, "values"},
|
|
|
|
{Good, "good"},
|
|
|
|
{Enabled, "enabled"},
|
|
|
|
};
|
2020-04-22 04:42:17 +03:00
|
|
|
|
2022-01-09 02:28:03 +03:00
|
|
|
return roles;
|
|
|
|
}
|
2021-08-01 01:59:46 +03:00
|
|
|
|
2022-01-09 02:28:03 +03:00
|
|
|
QVariant
|
|
|
|
UserSettingsModel::data(const QModelIndex &index, int role) const
|
|
|
|
{
|
|
|
|
if (index.row() >= COUNT)
|
|
|
|
return {};
|
|
|
|
|
|
|
|
auto i = UserSettings::instance();
|
|
|
|
if (!i)
|
|
|
|
return {};
|
|
|
|
|
|
|
|
if (role == Name) {
|
|
|
|
switch (index.row()) {
|
|
|
|
case Theme:
|
|
|
|
return tr("Theme");
|
|
|
|
case ScaleFactor:
|
|
|
|
return tr("Scale factor");
|
|
|
|
case MessageHoverHighlight:
|
|
|
|
return tr("Highlight message on hover");
|
|
|
|
case EnlargeEmojiOnlyMessages:
|
|
|
|
return tr("Large Emoji in timeline");
|
|
|
|
case Tray:
|
|
|
|
return tr("Minimize to tray");
|
|
|
|
case StartInTray:
|
|
|
|
return tr("Start in tray");
|
|
|
|
case GroupView:
|
2022-09-21 01:03:25 +03:00
|
|
|
return tr("Communities sidebar");
|
2023-02-15 00:00:05 +03:00
|
|
|
case ScrollbarsInRoomlist:
|
|
|
|
return tr("Scrollbars in room list");
|
2022-01-09 02:28:03 +03:00
|
|
|
case Markdown:
|
|
|
|
return tr("Send messages as Markdown");
|
2022-11-05 01:53:36 +03:00
|
|
|
case InvertEnterKey:
|
|
|
|
return tr("Use shift+enter to send and enter to start a new line");
|
2022-02-05 01:12:30 +03:00
|
|
|
case Bubbles:
|
2022-02-05 23:53:21 +03:00
|
|
|
return tr("Enable message bubbles");
|
2022-02-13 15:12:51 +03:00
|
|
|
case SmallAvatars:
|
|
|
|
return tr("Enable small Avatars");
|
2022-01-09 02:28:03 +03:00
|
|
|
case AnimateImagesOnHover:
|
|
|
|
return tr("Play animated images only on hover");
|
|
|
|
case TypingNotifications:
|
|
|
|
return tr("Typing notifications");
|
|
|
|
case SortByImportance:
|
|
|
|
return tr("Sort rooms by unreads");
|
2023-04-13 14:45:00 +03:00
|
|
|
case SortByAlphabet:
|
2023-04-14 20:14:28 +03:00
|
|
|
return tr("Sort rooms alphabetically");
|
2022-01-09 02:28:03 +03:00
|
|
|
case ButtonsInTimeline:
|
|
|
|
return tr("Show buttons in timeline");
|
|
|
|
case TimelineMaxWidth:
|
|
|
|
return tr("Limit width of timeline");
|
|
|
|
case ReadReceipts:
|
|
|
|
return tr("Read receipts");
|
2023-07-24 04:20:01 +03:00
|
|
|
case HiddenTimelineEvents:
|
|
|
|
return tr("Hidden events");
|
2023-10-25 01:46:04 +03:00
|
|
|
case IgnoredUsers:
|
|
|
|
return tr("Ignored users");
|
2022-01-09 02:28:03 +03:00
|
|
|
case DesktopNotifications:
|
|
|
|
return tr("Desktop notifications");
|
|
|
|
case AlertOnNotification:
|
|
|
|
return tr("Alert on notification");
|
|
|
|
case AvatarCircles:
|
|
|
|
return tr("Circular Avatars");
|
|
|
|
case UseIdenticon:
|
|
|
|
return tr("Use identicons");
|
2022-03-19 08:31:43 +03:00
|
|
|
case OpenImageExternal:
|
2022-03-19 07:54:02 +03:00
|
|
|
return tr("Open images with external program");
|
2022-03-19 08:31:43 +03:00
|
|
|
case OpenVideoExternal:
|
|
|
|
return tr("Open videos with external program");
|
2022-01-09 02:28:03 +03:00
|
|
|
case DecryptSidebar:
|
|
|
|
return tr("Decrypt messages in sidebar");
|
2022-10-13 18:37:28 +03:00
|
|
|
case DecryptNotifications:
|
|
|
|
return tr("Decrypt notifications");
|
2022-04-23 03:34:15 +03:00
|
|
|
case SpaceNotifications:
|
2022-10-01 16:20:38 +03:00
|
|
|
return tr("Show message counts for communities and tags");
|
2022-12-10 18:17:15 +03:00
|
|
|
case FancyEffects:
|
|
|
|
return tr("Display fancy effects such as confetti");
|
2023-02-06 15:56:23 +03:00
|
|
|
case ReducedMotion:
|
|
|
|
return tr("Reduce or disable animations");
|
2022-01-09 02:28:03 +03:00
|
|
|
case PrivacyScreen:
|
|
|
|
return tr("Privacy Screen");
|
|
|
|
case PrivacyScreenTimeout:
|
|
|
|
return tr("Privacy screen timeout (in seconds [0 - 3600])");
|
|
|
|
case MobileMode:
|
|
|
|
return tr("Touchscreen mode");
|
2023-12-31 22:15:38 +03:00
|
|
|
case DisableSwipe:
|
|
|
|
return tr("Disable swipe motions");
|
2022-01-09 02:28:03 +03:00
|
|
|
case FontSize:
|
|
|
|
return tr("Font size");
|
|
|
|
case Font:
|
|
|
|
return tr("Font Family");
|
|
|
|
case EmojiFont:
|
|
|
|
return tr("Emoji Font Family");
|
|
|
|
case Ringtone:
|
|
|
|
return tr("Ringtone");
|
|
|
|
case Microphone:
|
|
|
|
return tr("Microphone");
|
|
|
|
case Camera:
|
|
|
|
return tr("Camera");
|
|
|
|
case CameraResolution:
|
|
|
|
return tr("Camera resolution");
|
|
|
|
case CameraFrameRate:
|
|
|
|
return tr("Camera frame rate");
|
|
|
|
case UseStunServer:
|
|
|
|
return tr("Allow fallback call assist server");
|
|
|
|
case OnlyShareKeysWithVerifiedUsers:
|
|
|
|
return tr("Send encrypted messages to verified users only");
|
|
|
|
case ShareKeysWithTrustedUsers:
|
|
|
|
return tr("Share keys with verified users and devices");
|
|
|
|
case UseOnlineKeyBackup:
|
|
|
|
return tr("Online Key Backup");
|
|
|
|
case Profile:
|
|
|
|
return tr("Profile");
|
|
|
|
case UserId:
|
|
|
|
return tr("User ID");
|
|
|
|
case AccessToken:
|
|
|
|
return tr("Accesstoken");
|
|
|
|
case DeviceId:
|
|
|
|
return tr("Device ID");
|
|
|
|
case DeviceFingerprint:
|
|
|
|
return tr("Device Fingerprint");
|
|
|
|
case Homeserver:
|
|
|
|
return tr("Homeserver");
|
|
|
|
case Version:
|
|
|
|
return tr("Version");
|
|
|
|
case Platform:
|
|
|
|
return tr("Platform");
|
|
|
|
case GeneralSection:
|
|
|
|
return tr("GENERAL");
|
2023-02-06 15:56:23 +03:00
|
|
|
case AccessibilitySection:
|
|
|
|
return tr("ACCESSIBILITY");
|
2022-01-09 02:28:03 +03:00
|
|
|
case TimelineSection:
|
|
|
|
return tr("TIMELINE");
|
|
|
|
case SidebarSection:
|
|
|
|
return tr("SIDEBAR");
|
|
|
|
case TraySection:
|
|
|
|
return tr("TRAY");
|
2023-07-24 04:20:01 +03:00
|
|
|
case MessageVisibilitySection:
|
|
|
|
return tr("GLOBAL MESSAGE VISIBILITY");
|
2022-01-09 02:28:03 +03:00
|
|
|
case NotificationsSection:
|
|
|
|
return tr("NOTIFICATIONS");
|
|
|
|
case VoipSection:
|
|
|
|
return tr("CALLS");
|
|
|
|
case EncryptionSection:
|
|
|
|
return tr("ENCRYPTION");
|
|
|
|
case LoginInfoSection:
|
|
|
|
return tr("INFO");
|
|
|
|
case SessionKeys:
|
|
|
|
return tr("Session Keys");
|
|
|
|
case CrossSigningSecrets:
|
|
|
|
return tr("Cross Signing Secrets");
|
|
|
|
case OnlineBackupKey:
|
|
|
|
return tr("Online backup key");
|
|
|
|
case SelfSigningKey:
|
|
|
|
return tr("Self signing key");
|
|
|
|
case UserSigningKey:
|
|
|
|
return tr("User signing key");
|
|
|
|
case MasterKey:
|
|
|
|
return tr("Master signing key");
|
2022-04-14 18:02:55 +03:00
|
|
|
case ExposeDBusApi:
|
|
|
|
return tr("Expose room information via D-Bus");
|
2023-03-14 05:02:54 +03:00
|
|
|
case UpdateSpaceVias:
|
|
|
|
return tr("Periodically update community routing information");
|
2023-07-05 01:08:37 +03:00
|
|
|
case ExpireEvents:
|
|
|
|
return tr("Periodically delete expired events");
|
2021-09-18 01:22:33 +03:00
|
|
|
}
|
2022-01-09 02:28:03 +03:00
|
|
|
} else if (role == Value) {
|
|
|
|
switch (index.row()) {
|
|
|
|
case Theme:
|
|
|
|
return QStringList{
|
|
|
|
QStringLiteral("light"),
|
|
|
|
QStringLiteral("dark"),
|
|
|
|
QStringLiteral("system"),
|
2021-09-18 01:22:33 +03:00
|
|
|
}
|
2022-01-09 02:28:03 +03:00
|
|
|
.indexOf(i->theme());
|
|
|
|
case ScaleFactor:
|
|
|
|
return utils::scaleFactor();
|
|
|
|
case MessageHoverHighlight:
|
|
|
|
return i->messageHoverHighlight();
|
|
|
|
case EnlargeEmojiOnlyMessages:
|
|
|
|
return i->enlargeEmojiOnlyMessages();
|
|
|
|
case Tray:
|
|
|
|
return i->tray();
|
|
|
|
case StartInTray:
|
|
|
|
return i->startInTray();
|
|
|
|
case GroupView:
|
|
|
|
return i->groupView();
|
2023-02-15 00:00:05 +03:00
|
|
|
case ScrollbarsInRoomlist:
|
|
|
|
return i->scrollbarsInRoomlist();
|
2022-01-09 02:28:03 +03:00
|
|
|
case Markdown:
|
|
|
|
return i->markdown();
|
2022-11-05 01:53:36 +03:00
|
|
|
case InvertEnterKey:
|
|
|
|
return i->invertEnterKey();
|
2022-02-05 01:12:30 +03:00
|
|
|
case Bubbles:
|
|
|
|
return i->bubbles();
|
2022-02-13 15:12:51 +03:00
|
|
|
case SmallAvatars:
|
|
|
|
return i->smallAvatars();
|
2022-01-09 02:28:03 +03:00
|
|
|
case AnimateImagesOnHover:
|
|
|
|
return i->animateImagesOnHover();
|
|
|
|
case TypingNotifications:
|
|
|
|
return i->typingNotifications();
|
|
|
|
case SortByImportance:
|
|
|
|
return i->sortByImportance();
|
2023-04-13 14:45:00 +03:00
|
|
|
case SortByAlphabet:
|
|
|
|
return i->sortByAlphabet();
|
2022-01-09 02:28:03 +03:00
|
|
|
case ButtonsInTimeline:
|
|
|
|
return i->buttonsInTimeline();
|
|
|
|
case TimelineMaxWidth:
|
|
|
|
return i->timelineMaxWidth();
|
|
|
|
case ReadReceipts:
|
|
|
|
return i->readReceipts();
|
|
|
|
case DesktopNotifications:
|
|
|
|
return i->hasDesktopNotifications();
|
|
|
|
case AlertOnNotification:
|
|
|
|
return i->hasAlertOnNotification();
|
|
|
|
case AvatarCircles:
|
|
|
|
return i->avatarCircles();
|
|
|
|
case UseIdenticon:
|
|
|
|
return i->useIdenticon();
|
2022-03-19 08:31:43 +03:00
|
|
|
case OpenImageExternal:
|
2022-03-19 07:54:02 +03:00
|
|
|
return i->openImageExternal();
|
2022-03-19 08:31:43 +03:00
|
|
|
case OpenVideoExternal:
|
|
|
|
return i->openVideoExternal();
|
2022-01-09 02:28:03 +03:00
|
|
|
case DecryptSidebar:
|
|
|
|
return i->decryptSidebar();
|
2022-10-13 18:37:28 +03:00
|
|
|
case DecryptNotifications:
|
|
|
|
return i->decryptNotifications();
|
2022-04-23 03:34:15 +03:00
|
|
|
case SpaceNotifications:
|
2022-06-06 19:07:25 +03:00
|
|
|
return i->spaceNotifications();
|
2022-12-10 18:17:15 +03:00
|
|
|
case FancyEffects:
|
|
|
|
return i->fancyEffects();
|
2023-02-06 15:56:23 +03:00
|
|
|
case ReducedMotion:
|
|
|
|
return i->reducedMotion();
|
2022-01-09 02:28:03 +03:00
|
|
|
case PrivacyScreen:
|
|
|
|
return i->privacyScreen();
|
|
|
|
case PrivacyScreenTimeout:
|
|
|
|
return i->privacyScreenTimeout();
|
|
|
|
case MobileMode:
|
|
|
|
return i->mobileMode();
|
2023-12-31 22:15:38 +03:00
|
|
|
case DisableSwipe:
|
|
|
|
return i->disableSwipe();
|
2022-01-09 02:28:03 +03:00
|
|
|
case FontSize:
|
|
|
|
return i->fontSize();
|
2023-07-24 03:44:28 +03:00
|
|
|
case Font: {
|
|
|
|
if (i->font().isEmpty())
|
|
|
|
return 0;
|
|
|
|
else
|
|
|
|
return data(index, Values).toStringList().indexOf(i->font());
|
|
|
|
}
|
|
|
|
case EmojiFont: {
|
|
|
|
if (i->emojiFont().isEmpty())
|
|
|
|
return 0;
|
|
|
|
else
|
|
|
|
return data(index, Values).toStringList().indexOf(i->emojiFont());
|
|
|
|
}
|
2022-01-09 02:28:03 +03:00
|
|
|
case Ringtone: {
|
|
|
|
auto v = i->ringtone();
|
|
|
|
if (v == QStringView(u"Mute"))
|
|
|
|
return 0;
|
|
|
|
else if (v == QStringView(u"Default"))
|
|
|
|
return 1;
|
|
|
|
else if (v == QStringView(u"Other"))
|
|
|
|
return 2;
|
|
|
|
else
|
|
|
|
return 3;
|
2021-09-18 01:22:33 +03:00
|
|
|
}
|
2022-01-09 02:28:03 +03:00
|
|
|
case Microphone:
|
|
|
|
return data(index, Values).toStringList().indexOf(i->microphone());
|
|
|
|
case Camera:
|
|
|
|
return data(index, Values).toStringList().indexOf(i->camera());
|
|
|
|
case CameraResolution:
|
|
|
|
return data(index, Values).toStringList().indexOf(i->cameraResolution());
|
|
|
|
case CameraFrameRate:
|
|
|
|
return data(index, Values).toStringList().indexOf(i->cameraFrameRate());
|
|
|
|
case UseStunServer:
|
|
|
|
return i->useStunServer();
|
|
|
|
case OnlyShareKeysWithVerifiedUsers:
|
|
|
|
return i->onlyShareKeysWithVerifiedUsers();
|
|
|
|
case ShareKeysWithTrustedUsers:
|
|
|
|
return i->shareKeysWithTrustedUsers();
|
|
|
|
case UseOnlineKeyBackup:
|
|
|
|
return i->useOnlineKeyBackup();
|
|
|
|
case Profile:
|
|
|
|
return i->profile().isEmpty() ? tr("Default") : i->profile();
|
|
|
|
case UserId:
|
|
|
|
return i->userId();
|
|
|
|
case AccessToken:
|
|
|
|
return i->accessToken();
|
|
|
|
case DeviceId:
|
|
|
|
return i->deviceId();
|
|
|
|
case DeviceFingerprint:
|
|
|
|
return utils::humanReadableFingerprint(olm::client()->identity_keys().ed25519);
|
|
|
|
case Homeserver:
|
|
|
|
return i->homeserver();
|
|
|
|
case Version:
|
|
|
|
return QString::fromStdString(nheko::version);
|
|
|
|
case Platform:
|
|
|
|
return QString::fromStdString(nheko::build_os);
|
|
|
|
case OnlineBackupKey:
|
|
|
|
return cache::secret(mtx::secret_storage::secrets::megolm_backup_v1).has_value();
|
|
|
|
case SelfSigningKey:
|
|
|
|
return cache::secret(mtx::secret_storage::secrets::cross_signing_self_signing)
|
|
|
|
.has_value();
|
|
|
|
case UserSigningKey:
|
|
|
|
return cache::secret(mtx::secret_storage::secrets::cross_signing_user_signing)
|
|
|
|
.has_value();
|
|
|
|
case MasterKey:
|
|
|
|
return cache::secret(mtx::secret_storage::secrets::cross_signing_master).has_value();
|
2022-04-14 18:02:55 +03:00
|
|
|
case ExposeDBusApi:
|
|
|
|
return i->exposeDBusApi();
|
2023-03-14 05:02:54 +03:00
|
|
|
case UpdateSpaceVias:
|
|
|
|
return i->updateSpaceVias();
|
2023-07-05 01:08:37 +03:00
|
|
|
case ExpireEvents:
|
|
|
|
return i->expireEvents();
|
2022-01-09 02:28:03 +03:00
|
|
|
}
|
|
|
|
} else if (role == Description) {
|
|
|
|
switch (index.row()) {
|
|
|
|
case Theme:
|
|
|
|
case Font:
|
|
|
|
case EmojiFont:
|
|
|
|
return {};
|
|
|
|
case Microphone:
|
|
|
|
return tr("Set the notification sound to play when a call invite arrives");
|
|
|
|
case Camera:
|
|
|
|
case CameraResolution:
|
|
|
|
case CameraFrameRate:
|
|
|
|
case Ringtone:
|
|
|
|
return {};
|
|
|
|
case TimelineMaxWidth:
|
|
|
|
return tr("Set the max width of messages in the timeline (in pixels). This can help "
|
2022-09-30 07:23:39 +03:00
|
|
|
"readability on wide screen when Nheko is maximized");
|
2022-01-09 02:28:03 +03:00
|
|
|
case PrivacyScreenTimeout:
|
|
|
|
return tr(
|
|
|
|
"Set timeout (in seconds) for how long after window loses\nfocus before the screen"
|
|
|
|
" will be blurred.\nSet to 0 to blur immediately after focus loss. Max value of 1 "
|
|
|
|
"hour (3600 seconds)");
|
|
|
|
case FontSize:
|
|
|
|
return {};
|
|
|
|
case MessageHoverHighlight:
|
|
|
|
return tr("Change the background color of messages when you hover over them.");
|
|
|
|
case EnlargeEmojiOnlyMessages:
|
|
|
|
return tr("Make font size larger if messages with only a few emojis are displayed.");
|
|
|
|
case Tray:
|
|
|
|
return tr(
|
|
|
|
"Keep the application running in the background after closing the client window.");
|
|
|
|
case StartInTray:
|
|
|
|
return tr("Start the application in the background without showing the client window.");
|
|
|
|
case GroupView:
|
2022-09-21 01:03:25 +03:00
|
|
|
return tr("Show a column containing communities and tags next to the room list.");
|
2023-02-15 00:00:05 +03:00
|
|
|
case ScrollbarsInRoomlist:
|
|
|
|
return tr("Shows scrollbars in the room list and communities list.");
|
2022-01-09 02:28:03 +03:00
|
|
|
case Markdown:
|
|
|
|
return tr(
|
|
|
|
"Allow using markdown in messages.\nWhen disabled, all messages are sent as a plain "
|
|
|
|
"text.");
|
2022-11-05 01:53:36 +03:00
|
|
|
case InvertEnterKey:
|
|
|
|
return tr(
|
|
|
|
"Invert the behavior of the enter key in the text input, making it send the message "
|
|
|
|
"when shift+enter is pressed and starting a new line when enter is pressed.");
|
2022-02-05 01:12:30 +03:00
|
|
|
case Bubbles:
|
2022-02-05 23:53:21 +03:00
|
|
|
return tr(
|
|
|
|
"Messages get a bubble background. This also triggers some layout changes (WIP).");
|
2022-02-13 15:12:51 +03:00
|
|
|
case SmallAvatars:
|
2022-02-13 15:22:29 +03:00
|
|
|
return tr("Avatars are resized to fit above the message.");
|
2022-01-09 02:28:03 +03:00
|
|
|
case AnimateImagesOnHover:
|
|
|
|
return tr("Plays media like GIFs or WEBPs only when explicitly hovering over them.");
|
|
|
|
case TypingNotifications:
|
|
|
|
return tr(
|
|
|
|
"Show who is typing in a room.\nThis will also enable or disable sending typing "
|
|
|
|
"notifications to others.");
|
|
|
|
case SortByImportance:
|
|
|
|
return tr(
|
|
|
|
"Display rooms with new messages first.\nIf this is off, the list of rooms will only "
|
2023-04-13 14:45:00 +03:00
|
|
|
"be sorted by the preferred sorting order.\nIf this is on, rooms "
|
2022-01-09 02:28:03 +03:00
|
|
|
"which "
|
|
|
|
"have active notifications (the small circle with a number in it) will be sorted on "
|
2023-04-13 14:45:00 +03:00
|
|
|
"top. Rooms that you have muted will still be sorted by the preferred sorting order, "
|
|
|
|
"since you don't "
|
2022-01-09 02:28:03 +03:00
|
|
|
"seem to consider them as important as the other rooms.");
|
2023-04-13 14:45:00 +03:00
|
|
|
case SortByAlphabet:
|
|
|
|
return tr(
|
|
|
|
"Sort rooms alphabetically.\nIf this is off, the list of rooms will be sorted by the "
|
|
|
|
"timestamp of the last message in a room.\nIf this is on, rooms that come first "
|
|
|
|
"alphabetically "
|
|
|
|
"will be sorted earlier than ones that come later.");
|
2022-01-09 02:28:03 +03:00
|
|
|
case ButtonsInTimeline:
|
|
|
|
return tr(
|
|
|
|
"Show buttons to quickly reply, react or access additional options next to each "
|
|
|
|
"message.");
|
|
|
|
case ReadReceipts:
|
2022-06-14 01:35:28 +03:00
|
|
|
return tr(
|
|
|
|
"Show if your message was read.\nStatus is displayed next to timestamps.\nWarning: "
|
|
|
|
"If your homeserver does not support this, your rooms will never be marked as read!");
|
2023-07-24 04:20:01 +03:00
|
|
|
case HiddenTimelineEvents:
|
|
|
|
return tr("Configure whether to show or hide certain events like room joins.");
|
2022-01-09 02:28:03 +03:00
|
|
|
case DesktopNotifications:
|
2022-03-03 00:58:06 +03:00
|
|
|
return tr("Notify about received messages when the client is not currently focused.");
|
2022-01-09 02:28:03 +03:00
|
|
|
case AlertOnNotification:
|
|
|
|
return tr(
|
|
|
|
"Show an alert when a message is received.\nThis usually causes the application "
|
|
|
|
"icon in the task bar to animate in some fashion.");
|
|
|
|
case AvatarCircles:
|
|
|
|
return tr(
|
2022-03-03 00:58:59 +03:00
|
|
|
"Change the appearance of user avatars in chats.\nOFF - square, ON - circle.");
|
2022-01-09 02:28:03 +03:00
|
|
|
case UseIdenticon:
|
|
|
|
return tr("Display an identicon instead of a letter when no avatar is set.");
|
2022-03-19 08:31:43 +03:00
|
|
|
case OpenImageExternal:
|
2022-03-21 15:34:08 +03:00
|
|
|
return tr("Opens images with an external program when tapping the image.\nNote that "
|
|
|
|
"when this option is ON, opened files are left unencrypted on disk and must "
|
|
|
|
"be manually deleted.");
|
2022-03-19 08:31:43 +03:00
|
|
|
case OpenVideoExternal:
|
2022-03-21 15:34:08 +03:00
|
|
|
return tr("Opens videos with an external program when tapping the video.\nNote that "
|
|
|
|
"when this option is ON, opened files are left unencrypted on disk and must "
|
|
|
|
"be manually deleted.");
|
2022-01-09 02:28:03 +03:00
|
|
|
case DecryptSidebar:
|
|
|
|
return tr("Decrypt the messages shown in the sidebar.\nOnly affects messages in "
|
|
|
|
"encrypted chats.");
|
2022-10-13 18:37:28 +03:00
|
|
|
case DecryptNotifications:
|
|
|
|
return tr("Decrypt messages shown in notifications for encrypted chats.");
|
2022-04-23 03:34:15 +03:00
|
|
|
case SpaceNotifications:
|
2022-10-01 16:20:38 +03:00
|
|
|
return tr("Choose where to show the total number of notifications contained within a "
|
|
|
|
"community or tag.");
|
2022-12-10 18:17:15 +03:00
|
|
|
case FancyEffects:
|
|
|
|
return tr("Some messages can be sent with fancy effects. For example, messages sent "
|
|
|
|
"with '/confetti' will show confetti on screen.");
|
2023-02-06 15:56:23 +03:00
|
|
|
case ReducedMotion:
|
|
|
|
return tr("Nheko uses animations in several places to make stuff pretty. This allows "
|
|
|
|
"you to turn those off if they make you feel unwell.");
|
2022-01-09 02:28:03 +03:00
|
|
|
case PrivacyScreen:
|
|
|
|
return tr("When the window loses focus, the timeline will\nbe blurred.");
|
|
|
|
case MobileMode:
|
|
|
|
return tr(
|
|
|
|
"Will prevent text selection in the timeline to make touch scrolling easier.");
|
2023-12-31 22:15:38 +03:00
|
|
|
case DisableSwipe:
|
2023-12-31 22:18:46 +03:00
|
|
|
return tr("Will prevent swipe motions like swiping left/right between Rooms and "
|
|
|
|
"Timeline, or swiping a message to reply.");
|
2022-01-09 02:28:03 +03:00
|
|
|
case ScaleFactor:
|
|
|
|
return tr("Change the scale factor of the whole user interface.");
|
|
|
|
case UseStunServer:
|
|
|
|
return tr(
|
|
|
|
"Will use turn.matrix.org as assist when your home server does not offer one.");
|
|
|
|
case OnlyShareKeysWithVerifiedUsers:
|
|
|
|
return tr("Requires a user to be verified to send encrypted messages to them. This "
|
|
|
|
"improves safety but makes E2EE more tedious.");
|
|
|
|
case ShareKeysWithTrustedUsers:
|
|
|
|
return tr(
|
2022-09-30 07:23:39 +03:00
|
|
|
"Automatically replies to key requests from other users if they are verified, "
|
2022-01-09 02:28:03 +03:00
|
|
|
"even if that device shouldn't have access to those keys otherwise.");
|
|
|
|
case UseOnlineKeyBackup:
|
|
|
|
return tr(
|
|
|
|
"Download message encryption keys from and upload to the encrypted online key "
|
|
|
|
"backup.");
|
|
|
|
case Profile:
|
|
|
|
case UserId:
|
|
|
|
case AccessToken:
|
|
|
|
case DeviceId:
|
|
|
|
case DeviceFingerprint:
|
|
|
|
case Homeserver:
|
|
|
|
case Version:
|
|
|
|
case Platform:
|
|
|
|
case GeneralSection:
|
2023-02-06 15:56:23 +03:00
|
|
|
case AccessibilitySection:
|
2022-01-09 02:28:03 +03:00
|
|
|
case TimelineSection:
|
|
|
|
case SidebarSection:
|
|
|
|
case TraySection:
|
2023-07-24 04:20:01 +03:00
|
|
|
case MessageVisibilitySection:
|
2022-01-09 02:28:03 +03:00
|
|
|
case NotificationsSection:
|
|
|
|
case VoipSection:
|
|
|
|
case EncryptionSection:
|
|
|
|
case LoginInfoSection:
|
|
|
|
case SessionKeys:
|
|
|
|
case CrossSigningSecrets:
|
|
|
|
return {};
|
|
|
|
case OnlineBackupKey:
|
|
|
|
return tr(
|
|
|
|
"The key to decrypt online key backups. If it is cached, you can enable online "
|
|
|
|
"key backup to store encryption keys securely encrypted on the server.");
|
|
|
|
case SelfSigningKey:
|
|
|
|
return tr(
|
|
|
|
"The key to verify your own devices. If it is cached, verifying one of your devices "
|
2022-03-03 01:11:28 +03:00
|
|
|
"will mark it verified for all your other devices and for users that have verified "
|
2022-01-09 02:28:03 +03:00
|
|
|
"you.");
|
|
|
|
case UserSigningKey:
|
|
|
|
return tr(
|
|
|
|
"The key to verify other users. If it is cached, verifying a user will verify "
|
|
|
|
"all their devices.");
|
|
|
|
case MasterKey:
|
|
|
|
return tr(
|
|
|
|
"Your most important key. You don't need to have it cached, since not caching "
|
|
|
|
"it makes it less likely it can be stolen and it is only needed to rotate your "
|
|
|
|
"other signing keys.");
|
2022-04-14 18:02:55 +03:00
|
|
|
case ExposeDBusApi:
|
|
|
|
return tr("Allow third-party plugins and applications to load information about rooms "
|
|
|
|
"you are in via D-Bus. "
|
|
|
|
"This can have useful applications, but it also could be used for nefarious "
|
|
|
|
"purposes. Enable at your own risk.\n\n"
|
|
|
|
"This setting will take effect upon restart.");
|
2023-03-14 05:02:54 +03:00
|
|
|
case UpdateSpaceVias:
|
|
|
|
return tr(
|
|
|
|
"To allow new users to join a community, the community needs to expose some "
|
|
|
|
"information about what servers participate in a room to community members. Since "
|
|
|
|
"the room participants can change over time, this needs to be updated from time to "
|
|
|
|
"time. This setting enables a background job to do that automatically.");
|
2023-07-05 01:08:37 +03:00
|
|
|
case ExpireEvents:
|
|
|
|
return tr("Regularly redact expired events as specified in the event expiration "
|
|
|
|
"configuration. Since this is currently not executed server side, you need "
|
|
|
|
"to have one client running this regularly.");
|
2023-10-25 01:46:04 +03:00
|
|
|
case IgnoredUsers:
|
|
|
|
return tr("Manage your ignored users.");
|
2022-01-09 02:28:03 +03:00
|
|
|
}
|
|
|
|
} else if (role == Type) {
|
|
|
|
switch (index.row()) {
|
|
|
|
case Theme:
|
|
|
|
case Font:
|
|
|
|
case EmojiFont:
|
|
|
|
case Microphone:
|
|
|
|
case Camera:
|
|
|
|
case CameraResolution:
|
|
|
|
case CameraFrameRate:
|
|
|
|
case Ringtone:
|
|
|
|
return Options;
|
|
|
|
case TimelineMaxWidth:
|
|
|
|
case PrivacyScreenTimeout:
|
2022-01-13 07:51:57 +03:00
|
|
|
return Integer;
|
2022-01-09 02:28:03 +03:00
|
|
|
case FontSize:
|
|
|
|
case ScaleFactor:
|
2022-01-13 07:51:57 +03:00
|
|
|
return Double;
|
2022-01-09 02:28:03 +03:00
|
|
|
case MessageHoverHighlight:
|
|
|
|
case EnlargeEmojiOnlyMessages:
|
|
|
|
case Tray:
|
|
|
|
case StartInTray:
|
|
|
|
case GroupView:
|
2023-02-15 00:00:05 +03:00
|
|
|
case ScrollbarsInRoomlist:
|
2022-01-09 02:28:03 +03:00
|
|
|
case Markdown:
|
2022-11-05 01:53:36 +03:00
|
|
|
case InvertEnterKey:
|
2022-02-05 01:12:30 +03:00
|
|
|
case Bubbles:
|
2022-02-13 15:12:51 +03:00
|
|
|
case SmallAvatars:
|
2022-01-09 02:28:03 +03:00
|
|
|
case AnimateImagesOnHover:
|
|
|
|
case TypingNotifications:
|
|
|
|
case SortByImportance:
|
2023-04-13 14:45:00 +03:00
|
|
|
case SortByAlphabet:
|
2022-01-09 02:28:03 +03:00
|
|
|
case ButtonsInTimeline:
|
|
|
|
case ReadReceipts:
|
|
|
|
case DesktopNotifications:
|
|
|
|
case AlertOnNotification:
|
|
|
|
case AvatarCircles:
|
|
|
|
case UseIdenticon:
|
2022-03-19 08:31:43 +03:00
|
|
|
case OpenImageExternal:
|
|
|
|
case OpenVideoExternal:
|
2022-01-09 02:28:03 +03:00
|
|
|
case DecryptSidebar:
|
2022-10-13 18:37:28 +03:00
|
|
|
case DecryptNotifications:
|
2022-01-09 02:28:03 +03:00
|
|
|
case PrivacyScreen:
|
|
|
|
case MobileMode:
|
2023-12-31 22:15:38 +03:00
|
|
|
case DisableSwipe:
|
2022-01-09 02:28:03 +03:00
|
|
|
case UseStunServer:
|
|
|
|
case OnlyShareKeysWithVerifiedUsers:
|
|
|
|
case ShareKeysWithTrustedUsers:
|
|
|
|
case UseOnlineKeyBackup:
|
2022-04-14 18:02:55 +03:00
|
|
|
case ExposeDBusApi:
|
2023-03-14 05:02:54 +03:00
|
|
|
case UpdateSpaceVias:
|
2023-07-05 01:08:37 +03:00
|
|
|
case ExpireEvents:
|
2022-06-06 19:07:25 +03:00
|
|
|
case SpaceNotifications:
|
2022-12-10 18:17:15 +03:00
|
|
|
case FancyEffects:
|
2023-02-06 15:56:23 +03:00
|
|
|
case ReducedMotion:
|
2022-01-09 02:28:03 +03:00
|
|
|
return Toggle;
|
|
|
|
case Profile:
|
|
|
|
case UserId:
|
|
|
|
case AccessToken:
|
|
|
|
case DeviceId:
|
|
|
|
case DeviceFingerprint:
|
|
|
|
case Homeserver:
|
|
|
|
case Version:
|
|
|
|
case Platform:
|
|
|
|
return ReadOnlyText;
|
|
|
|
case GeneralSection:
|
2023-02-06 15:56:23 +03:00
|
|
|
case AccessibilitySection:
|
2022-01-09 02:28:03 +03:00
|
|
|
case TimelineSection:
|
|
|
|
case SidebarSection:
|
|
|
|
case TraySection:
|
2023-07-24 04:20:01 +03:00
|
|
|
case MessageVisibilitySection:
|
2022-01-09 02:28:03 +03:00
|
|
|
case NotificationsSection:
|
|
|
|
case VoipSection:
|
|
|
|
case EncryptionSection:
|
|
|
|
case LoginInfoSection:
|
|
|
|
return SectionTitle;
|
|
|
|
case SessionKeys:
|
|
|
|
return SessionKeyImportExport;
|
|
|
|
case CrossSigningSecrets:
|
|
|
|
return XSignKeysRequestDownload;
|
|
|
|
case OnlineBackupKey:
|
|
|
|
case SelfSigningKey:
|
|
|
|
case UserSigningKey:
|
|
|
|
case MasterKey:
|
|
|
|
return KeyStatus;
|
2023-07-24 04:20:01 +03:00
|
|
|
case HiddenTimelineEvents:
|
|
|
|
return ConfigureHiddenEvents;
|
2023-10-25 01:46:04 +03:00
|
|
|
case IgnoredUsers:
|
|
|
|
return ManageIgnoredUsers;
|
2022-01-09 02:28:03 +03:00
|
|
|
}
|
|
|
|
} else if (role == ValueLowerBound) {
|
|
|
|
switch (index.row()) {
|
|
|
|
case TimelineMaxWidth:
|
|
|
|
return 0;
|
|
|
|
case PrivacyScreenTimeout:
|
|
|
|
return 0;
|
|
|
|
case FontSize:
|
|
|
|
return 8.0;
|
|
|
|
case ScaleFactor:
|
|
|
|
return 1.0;
|
|
|
|
}
|
|
|
|
} else if (role == ValueUpperBound) {
|
|
|
|
switch (index.row()) {
|
|
|
|
case TimelineMaxWidth:
|
|
|
|
return 20000;
|
|
|
|
case PrivacyScreenTimeout:
|
|
|
|
return 3600;
|
|
|
|
case FontSize:
|
|
|
|
return 24.0;
|
|
|
|
case ScaleFactor:
|
|
|
|
return 3.0;
|
|
|
|
}
|
|
|
|
} else if (role == ValueStep) {
|
|
|
|
switch (index.row()) {
|
|
|
|
case TimelineMaxWidth:
|
|
|
|
return 20;
|
|
|
|
case PrivacyScreenTimeout:
|
|
|
|
return 10;
|
|
|
|
case FontSize:
|
|
|
|
return 0.5;
|
|
|
|
case ScaleFactor:
|
|
|
|
return .25;
|
|
|
|
}
|
|
|
|
} else if (role == Values) {
|
|
|
|
auto vecToList = [](const std::vector<std::string> &vec) {
|
|
|
|
QStringList l;
|
|
|
|
for (const auto &d : vec)
|
|
|
|
l.push_back(QString::fromStdString(d));
|
2023-11-01 08:10:58 +03:00
|
|
|
|
2022-01-09 02:28:03 +03:00
|
|
|
return l;
|
|
|
|
};
|
|
|
|
switch (index.row()) {
|
|
|
|
case Theme:
|
|
|
|
return QStringList{
|
|
|
|
QStringLiteral("Light"),
|
|
|
|
QStringLiteral("Dark"),
|
|
|
|
QStringLiteral("System"),
|
|
|
|
};
|
|
|
|
case Microphone:
|
|
|
|
return vecToList(CallDevices::instance().names(false, i->microphone().toStdString()));
|
|
|
|
case Camera:
|
|
|
|
return vecToList(CallDevices::instance().names(true, i->camera().toStdString()));
|
|
|
|
case CameraResolution:
|
|
|
|
return vecToList(CallDevices::instance().resolutions(i->camera().toStdString()));
|
|
|
|
case CameraFrameRate:
|
|
|
|
return vecToList(CallDevices::instance().frameRates(
|
|
|
|
i->camera().toStdString(), i->cameraResolution().toStdString()));
|
|
|
|
|
2023-07-24 03:44:28 +03:00
|
|
|
case Font: {
|
|
|
|
auto fonts = QFontDatabase::families();
|
|
|
|
fonts.prepend(tr("System font"));
|
|
|
|
return fonts;
|
|
|
|
}
|
|
|
|
case EmojiFont: {
|
|
|
|
auto fonts = QFontDatabase::families(QFontDatabase::WritingSystem::Symbol);
|
|
|
|
fonts.prepend(tr("System emoji font"));
|
|
|
|
return fonts;
|
|
|
|
}
|
2022-04-23 03:34:15 +03:00
|
|
|
case Ringtone: {
|
2022-01-09 02:28:03 +03:00
|
|
|
QStringList l{
|
|
|
|
QStringLiteral("Mute"),
|
|
|
|
QStringLiteral("Default"),
|
|
|
|
QStringLiteral("Other"),
|
|
|
|
};
|
|
|
|
if (!l.contains(i->ringtone()))
|
|
|
|
l.push_back(i->ringtone());
|
|
|
|
return l;
|
|
|
|
}
|
2022-04-23 03:34:15 +03:00
|
|
|
}
|
2022-01-09 02:28:03 +03:00
|
|
|
} else if (role == Good) {
|
|
|
|
switch (index.row()) {
|
|
|
|
case OnlineBackupKey:
|
|
|
|
return cache::secret(mtx::secret_storage::secrets::megolm_backup_v1).has_value();
|
|
|
|
case SelfSigningKey:
|
|
|
|
return cache::secret(mtx::secret_storage::secrets::cross_signing_self_signing)
|
|
|
|
.has_value();
|
|
|
|
case UserSigningKey:
|
|
|
|
return cache::secret(mtx::secret_storage::secrets::cross_signing_user_signing)
|
|
|
|
.has_value();
|
|
|
|
case MasterKey:
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
} else if (role == Enabled) {
|
|
|
|
switch (index.row()) {
|
|
|
|
case StartInTray:
|
|
|
|
return i->tray();
|
|
|
|
case PrivacyScreenTimeout:
|
|
|
|
return i->privacyScreen();
|
|
|
|
case UseIdenticon:
|
|
|
|
return JdenticonProvider::isAvailable();
|
|
|
|
default:
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
2017-11-02 01:41:13 +03:00
|
|
|
|
2022-01-09 02:28:03 +03:00
|
|
|
return {};
|
2017-11-02 01:41:13 +03:00
|
|
|
}
|
2017-11-09 23:04:40 +03:00
|
|
|
|
2022-01-09 02:28:03 +03:00
|
|
|
bool
|
|
|
|
UserSettingsModel::setData(const QModelIndex &index, const QVariant &value, int role)
|
2017-11-22 20:52:38 +03:00
|
|
|
{
|
2022-01-09 02:28:03 +03:00
|
|
|
auto i = UserSettings::instance();
|
|
|
|
if (role == Value) {
|
|
|
|
switch (index.row()) {
|
|
|
|
case Theme: {
|
|
|
|
if (value == 0) {
|
|
|
|
i->setTheme("light");
|
|
|
|
return true;
|
|
|
|
} else if (value == 1) {
|
|
|
|
i->setTheme("dark");
|
|
|
|
return true;
|
|
|
|
} else if (value == 2) {
|
|
|
|
i->setTheme("system");
|
|
|
|
return true;
|
|
|
|
} else
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
case MessageHoverHighlight: {
|
|
|
|
if (value.userType() == QMetaType::Bool) {
|
|
|
|
i->setMessageHoverHighlight(value.toBool());
|
|
|
|
return true;
|
|
|
|
} else
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
case ScaleFactor: {
|
2023-06-02 01:24:26 +03:00
|
|
|
if (value.canConvert(QMetaType::fromType<double>())) {
|
2022-01-09 02:28:03 +03:00
|
|
|
utils::setScaleFactor(static_cast<float>(value.toDouble()));
|
|
|
|
return true;
|
|
|
|
} else
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
case EnlargeEmojiOnlyMessages: {
|
|
|
|
if (value.userType() == QMetaType::Bool) {
|
|
|
|
i->setEnlargeEmojiOnlyMessages(value.toBool());
|
|
|
|
return true;
|
|
|
|
} else
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
case Tray: {
|
|
|
|
if (value.userType() == QMetaType::Bool) {
|
|
|
|
i->setTray(value.toBool());
|
|
|
|
return true;
|
|
|
|
} else
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
case StartInTray: {
|
|
|
|
if (value.userType() == QMetaType::Bool) {
|
|
|
|
i->setStartInTray(value.toBool());
|
|
|
|
return true;
|
|
|
|
} else
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
case GroupView: {
|
|
|
|
if (value.userType() == QMetaType::Bool) {
|
|
|
|
i->setGroupView(value.toBool());
|
|
|
|
return true;
|
|
|
|
} else
|
|
|
|
return false;
|
|
|
|
}
|
2023-02-15 00:00:05 +03:00
|
|
|
case ScrollbarsInRoomlist: {
|
|
|
|
if (value.userType() == QMetaType::Bool) {
|
|
|
|
i->setScrollbarsInRoomlist(value.toBool());
|
|
|
|
return true;
|
|
|
|
} else
|
|
|
|
return false;
|
|
|
|
}
|
2022-01-09 02:28:03 +03:00
|
|
|
case Markdown: {
|
|
|
|
if (value.userType() == QMetaType::Bool) {
|
|
|
|
i->setMarkdown(value.toBool());
|
|
|
|
return true;
|
|
|
|
} else
|
|
|
|
return false;
|
|
|
|
}
|
2022-11-05 01:53:36 +03:00
|
|
|
case InvertEnterKey: {
|
2022-02-05 01:12:30 +03:00
|
|
|
if (value.userType() == QMetaType::Bool) {
|
2022-11-05 01:53:36 +03:00
|
|
|
i->setInvertEnterKey(value.toBool());
|
2022-02-05 01:12:30 +03:00
|
|
|
return true;
|
|
|
|
} else
|
|
|
|
return false;
|
|
|
|
}
|
2022-11-05 01:53:36 +03:00
|
|
|
case Bubbles: {
|
2022-02-13 15:12:51 +03:00
|
|
|
if (value.userType() == QMetaType::Bool) {
|
2022-11-05 01:53:36 +03:00
|
|
|
i->setBubbles(value.toBool());
|
2022-02-13 15:12:51 +03:00
|
|
|
return true;
|
|
|
|
} else
|
|
|
|
return false;
|
|
|
|
}
|
2022-11-05 01:53:36 +03:00
|
|
|
case SmallAvatars: {
|
2022-11-05 01:42:35 +03:00
|
|
|
if (value.userType() == QMetaType::Bool) {
|
2022-11-05 01:53:36 +03:00
|
|
|
i->setSmallAvatars(value.toBool());
|
2022-11-05 01:42:35 +03:00
|
|
|
return true;
|
|
|
|
} else
|
|
|
|
return false;
|
|
|
|
}
|
2022-01-09 02:28:03 +03:00
|
|
|
case AnimateImagesOnHover: {
|
|
|
|
if (value.userType() == QMetaType::Bool) {
|
|
|
|
i->setAnimateImagesOnHover(value.toBool());
|
|
|
|
return true;
|
|
|
|
} else
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
case TypingNotifications: {
|
|
|
|
if (value.userType() == QMetaType::Bool) {
|
|
|
|
i->setTypingNotifications(value.toBool());
|
|
|
|
return true;
|
|
|
|
} else
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
case SortByImportance: {
|
|
|
|
if (value.userType() == QMetaType::Bool) {
|
|
|
|
i->setSortByImportance(value.toBool());
|
|
|
|
return true;
|
|
|
|
} else
|
|
|
|
return false;
|
|
|
|
}
|
2023-04-13 14:45:00 +03:00
|
|
|
case SortByAlphabet: {
|
|
|
|
if (value.userType() == QMetaType::Bool) {
|
|
|
|
i->setSortByAlphabet(value.toBool());
|
|
|
|
return true;
|
|
|
|
} else
|
|
|
|
return false;
|
|
|
|
}
|
2022-01-09 02:28:03 +03:00
|
|
|
case ButtonsInTimeline: {
|
|
|
|
if (value.userType() == QMetaType::Bool) {
|
|
|
|
i->setButtonsInTimeline(value.toBool());
|
|
|
|
return true;
|
|
|
|
} else
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
case TimelineMaxWidth: {
|
2023-06-02 01:24:26 +03:00
|
|
|
if (value.canConvert(QMetaType::fromType<int>())) {
|
2022-01-09 02:28:03 +03:00
|
|
|
i->setTimelineMaxWidth(value.toInt());
|
|
|
|
return true;
|
|
|
|
} else
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
case ReadReceipts: {
|
|
|
|
if (value.userType() == QMetaType::Bool) {
|
|
|
|
i->setReadReceipts(value.toBool());
|
|
|
|
return true;
|
|
|
|
} else
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
case DesktopNotifications: {
|
|
|
|
if (value.userType() == QMetaType::Bool) {
|
|
|
|
i->setDesktopNotifications(value.toBool());
|
|
|
|
return true;
|
|
|
|
} else
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
case AlertOnNotification: {
|
|
|
|
if (value.userType() == QMetaType::Bool) {
|
|
|
|
i->setAlertOnNotification(value.toBool());
|
|
|
|
return true;
|
|
|
|
} else
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
case AvatarCircles: {
|
|
|
|
if (value.userType() == QMetaType::Bool) {
|
|
|
|
i->setAvatarCircles(value.toBool());
|
|
|
|
return true;
|
|
|
|
} else
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
case UseIdenticon: {
|
|
|
|
if (value.userType() == QMetaType::Bool) {
|
|
|
|
i->setUseIdenticon(value.toBool());
|
|
|
|
return true;
|
|
|
|
} else
|
|
|
|
return false;
|
|
|
|
}
|
2022-03-19 08:31:43 +03:00
|
|
|
case OpenImageExternal: {
|
2022-03-19 07:54:02 +03:00
|
|
|
if (value.userType() == QMetaType::Bool) {
|
|
|
|
i->setOpenImageExternal(value.toBool());
|
|
|
|
return true;
|
|
|
|
} else
|
|
|
|
return false;
|
|
|
|
}
|
2022-03-19 08:31:43 +03:00
|
|
|
case OpenVideoExternal: {
|
|
|
|
if (value.userType() == QMetaType::Bool) {
|
|
|
|
i->setOpenVideoExternal(value.toBool());
|
|
|
|
return true;
|
|
|
|
} else
|
|
|
|
return false;
|
|
|
|
}
|
2022-01-09 02:28:03 +03:00
|
|
|
case DecryptSidebar: {
|
|
|
|
if (value.userType() == QMetaType::Bool) {
|
|
|
|
i->setDecryptSidebar(value.toBool());
|
|
|
|
return true;
|
|
|
|
} else
|
|
|
|
return false;
|
|
|
|
}
|
2022-10-13 18:37:28 +03:00
|
|
|
case DecryptNotifications: {
|
|
|
|
if (value.userType() == QMetaType::Bool) {
|
|
|
|
i->setDecryptNotifications(value.toBool());
|
|
|
|
return true;
|
|
|
|
} else
|
|
|
|
return false;
|
|
|
|
}
|
2022-04-23 03:34:15 +03:00
|
|
|
case SpaceNotifications: {
|
2022-06-06 19:07:25 +03:00
|
|
|
if (value.userType() == QMetaType::Bool) {
|
|
|
|
i->setSpaceNotifications(value.toBool());
|
|
|
|
return true;
|
|
|
|
} else
|
2022-04-23 03:34:15 +03:00
|
|
|
return false;
|
|
|
|
}
|
2022-12-10 18:17:15 +03:00
|
|
|
case FancyEffects: {
|
|
|
|
if (value.userType() == QMetaType::Bool) {
|
|
|
|
i->setFancyEffects(value.toBool());
|
|
|
|
return true;
|
|
|
|
} else
|
|
|
|
return false;
|
|
|
|
}
|
2023-02-06 15:56:23 +03:00
|
|
|
case ReducedMotion: {
|
|
|
|
if (value.userType() == QMetaType::Bool) {
|
|
|
|
i->setReducedMotion(value.toBool());
|
|
|
|
return true;
|
|
|
|
} else
|
|
|
|
return false;
|
|
|
|
}
|
2022-01-09 02:28:03 +03:00
|
|
|
case PrivacyScreen: {
|
|
|
|
if (value.userType() == QMetaType::Bool) {
|
|
|
|
i->setPrivacyScreen(value.toBool());
|
|
|
|
return true;
|
|
|
|
} else
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
case PrivacyScreenTimeout: {
|
2023-06-02 01:24:26 +03:00
|
|
|
if (value.canConvert(QMetaType::fromType<int>())) {
|
2022-01-09 02:28:03 +03:00
|
|
|
i->setPrivacyScreenTimeout(value.toInt());
|
|
|
|
return true;
|
|
|
|
} else
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
case MobileMode: {
|
|
|
|
if (value.userType() == QMetaType::Bool) {
|
|
|
|
i->setMobileMode(value.toBool());
|
|
|
|
return true;
|
|
|
|
} else
|
|
|
|
return false;
|
|
|
|
}
|
2023-12-31 22:15:38 +03:00
|
|
|
case DisableSwipe: {
|
|
|
|
if (value.userType() == QMetaType::Bool) {
|
|
|
|
i->setDisableSwipe(value.toBool());
|
|
|
|
return true;
|
|
|
|
} else
|
|
|
|
return false;
|
|
|
|
}
|
2022-01-09 02:28:03 +03:00
|
|
|
case FontSize: {
|
2023-06-02 01:24:26 +03:00
|
|
|
if (value.canConvert(QMetaType::fromType<double>())) {
|
2022-01-13 07:51:57 +03:00
|
|
|
i->setFontSize(value.toDouble());
|
2022-01-09 02:28:03 +03:00
|
|
|
return true;
|
|
|
|
} else
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
case Font: {
|
|
|
|
if (value.userType() == QMetaType::Int) {
|
2023-07-24 03:44:28 +03:00
|
|
|
// Special handling to grab our injected system font option
|
|
|
|
auto v = value.toInt();
|
|
|
|
i->setFontFamily(v == 0 ? QString{} : QFontDatabase::families().at(v - 1));
|
2022-01-09 02:28:03 +03:00
|
|
|
return true;
|
|
|
|
} else
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
case EmojiFont: {
|
2022-02-13 01:06:45 +03:00
|
|
|
if (value.userType() == QMetaType::Int) {
|
2023-07-24 03:44:28 +03:00
|
|
|
// More special handling for the default font option
|
|
|
|
auto v = value.toInt();
|
2022-02-13 01:06:45 +03:00
|
|
|
i->setEmojiFontFamily(
|
2023-07-24 03:44:28 +03:00
|
|
|
v == 0 ? QStringLiteral("emoji")
|
|
|
|
: QFontDatabase::families(QFontDatabase::WritingSystem::Symbol).at(v - 1));
|
2022-01-09 02:28:03 +03:00
|
|
|
return true;
|
|
|
|
} else
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
case Ringtone: {
|
|
|
|
if (value.userType() == QMetaType::Int) {
|
|
|
|
int ringtone = value.toInt();
|
|
|
|
|
|
|
|
// setRingtone is called twice, because updating the list breaks the set value,
|
|
|
|
// because it does not exist yet!
|
|
|
|
if (ringtone == 2) {
|
|
|
|
QString homeFolder =
|
|
|
|
QStandardPaths::writableLocation(QStandardPaths::HomeLocation);
|
|
|
|
auto filepath = QFileDialog::getOpenFileName(
|
2022-01-12 21:09:46 +03:00
|
|
|
nullptr, tr("Select a file"), homeFolder, tr("All Files (*)"));
|
2022-01-09 02:28:03 +03:00
|
|
|
if (!filepath.isEmpty()) {
|
|
|
|
i->setRingtone(filepath);
|
|
|
|
i->setRingtone(filepath);
|
|
|
|
}
|
|
|
|
} else if (ringtone == 0) {
|
|
|
|
i->setRingtone(QStringLiteral("Mute"));
|
|
|
|
i->setRingtone(QStringLiteral("Mute"));
|
|
|
|
} else if (ringtone == 1) {
|
|
|
|
i->setRingtone(QStringLiteral("Default"));
|
|
|
|
i->setRingtone(QStringLiteral("Default"));
|
|
|
|
}
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
case Microphone: {
|
|
|
|
if (value.userType() == QMetaType::Int) {
|
|
|
|
i->setMicrophone(data(index, Values).toStringList().at(value.toInt()));
|
|
|
|
return true;
|
|
|
|
} else
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
case Camera: {
|
|
|
|
if (value.userType() == QMetaType::Int) {
|
|
|
|
i->setCamera(data(index, Values).toStringList().at(value.toInt()));
|
|
|
|
return true;
|
|
|
|
} else
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
case CameraResolution: {
|
|
|
|
if (value.userType() == QMetaType::Int) {
|
|
|
|
i->setCameraResolution(data(index, Values).toStringList().at(value.toInt()));
|
|
|
|
return true;
|
|
|
|
} else
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
case CameraFrameRate: {
|
|
|
|
if (value.userType() == QMetaType::Int) {
|
|
|
|
i->setCameraFrameRate(data(index, Values).toStringList().at(value.toInt()));
|
|
|
|
return true;
|
|
|
|
} else
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
case UseStunServer: {
|
|
|
|
if (value.userType() == QMetaType::Bool) {
|
|
|
|
i->setUseStunServer(value.toBool());
|
|
|
|
return true;
|
|
|
|
} else
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
case OnlyShareKeysWithVerifiedUsers: {
|
|
|
|
if (value.userType() == QMetaType::Bool) {
|
|
|
|
i->setOnlyShareKeysWithVerifiedUsers(value.toBool());
|
|
|
|
return true;
|
|
|
|
} else
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
case ShareKeysWithTrustedUsers: {
|
|
|
|
if (value.userType() == QMetaType::Bool) {
|
|
|
|
i->setShareKeysWithTrustedUsers(value.toBool());
|
|
|
|
return true;
|
|
|
|
} else
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
case UseOnlineKeyBackup: {
|
|
|
|
if (value.userType() == QMetaType::Bool) {
|
|
|
|
i->setUseOnlineKeyBackup(value.toBool());
|
|
|
|
return true;
|
|
|
|
} else
|
|
|
|
return false;
|
|
|
|
}
|
2022-04-14 18:02:55 +03:00
|
|
|
case ExposeDBusApi: {
|
|
|
|
if (value.userType() == QMetaType::Bool) {
|
|
|
|
i->setExposeDBusApi(value.toBool());
|
|
|
|
return true;
|
|
|
|
} else
|
|
|
|
return false;
|
|
|
|
}
|
2023-03-14 05:02:54 +03:00
|
|
|
case UpdateSpaceVias: {
|
|
|
|
if (value.userType() == QMetaType::Bool) {
|
|
|
|
i->setUpdateSpaceVias(value.toBool());
|
|
|
|
return true;
|
|
|
|
} else
|
|
|
|
return false;
|
|
|
|
}
|
2023-07-05 01:08:37 +03:00
|
|
|
case ExpireEvents: {
|
|
|
|
if (value.userType() == QMetaType::Bool) {
|
|
|
|
i->setExpireEvents(value.toBool());
|
|
|
|
return true;
|
|
|
|
} else
|
|
|
|
return false;
|
|
|
|
}
|
2022-01-09 02:28:03 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
return false;
|
2017-11-22 20:52:38 +03:00
|
|
|
}
|
2017-11-25 19:19:58 +03:00
|
|
|
|
2018-09-15 23:52:14 +03:00
|
|
|
void
|
2022-01-09 02:28:03 +03:00
|
|
|
UserSettingsModel::importSessionKeys()
|
2018-09-15 23:52:14 +03:00
|
|
|
{
|
2021-09-18 01:22:33 +03:00
|
|
|
const QString homeFolder = QStandardPaths::writableLocation(QStandardPaths::HomeLocation);
|
2022-01-09 02:28:03 +03:00
|
|
|
const QString fileName = QFileDialog::getOpenFileName(
|
2022-01-12 21:09:46 +03:00
|
|
|
nullptr, tr("Open Sessions File"), homeFolder, QLatin1String(""));
|
2021-09-18 01:22:33 +03:00
|
|
|
|
|
|
|
QFile file(fileName);
|
|
|
|
if (!file.open(QIODevice::ReadOnly)) {
|
2022-01-12 21:09:46 +03:00
|
|
|
QMessageBox::warning(nullptr, tr("Error"), file.errorString());
|
2021-09-18 01:22:33 +03:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
auto bin = file.peek(file.size());
|
|
|
|
auto payload = std::string(bin.data(), bin.size());
|
|
|
|
|
|
|
|
bool ok;
|
2022-01-12 21:09:46 +03:00
|
|
|
auto password = QInputDialog::getText(nullptr,
|
2021-09-18 01:22:33 +03:00
|
|
|
tr("File Password"),
|
|
|
|
tr("Enter the passphrase to decrypt the file:"),
|
|
|
|
QLineEdit::Password,
|
2021-12-29 06:28:08 +03:00
|
|
|
QLatin1String(""),
|
2021-09-18 01:22:33 +03:00
|
|
|
&ok);
|
|
|
|
if (!ok)
|
|
|
|
return;
|
|
|
|
|
|
|
|
if (password.isEmpty()) {
|
2022-01-12 21:09:46 +03:00
|
|
|
QMessageBox::warning(nullptr, tr("Error"), tr("The password cannot be empty"));
|
2021-09-18 01:22:33 +03:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
try {
|
|
|
|
auto sessions = mtx::crypto::decrypt_exported_sessions(payload, password.toStdString());
|
|
|
|
cache::importSessionKeys(std::move(sessions));
|
|
|
|
} catch (const std::exception &e) {
|
2022-01-12 21:09:46 +03:00
|
|
|
QMessageBox::warning(nullptr, tr("Error"), e.what());
|
2021-09-18 01:22:33 +03:00
|
|
|
}
|
2018-09-15 23:52:14 +03:00
|
|
|
}
|
|
|
|
void
|
2022-01-09 02:28:03 +03:00
|
|
|
UserSettingsModel::exportSessionKeys()
|
2018-09-15 23:52:14 +03:00
|
|
|
{
|
2021-09-18 01:22:33 +03:00
|
|
|
// Open password dialog.
|
|
|
|
bool ok;
|
2022-01-12 21:09:46 +03:00
|
|
|
auto password = QInputDialog::getText(nullptr,
|
2021-09-18 01:22:33 +03:00
|
|
|
tr("File Password"),
|
|
|
|
tr("Enter passphrase to encrypt your session keys:"),
|
|
|
|
QLineEdit::Password,
|
2021-12-29 06:28:08 +03:00
|
|
|
QLatin1String(""),
|
2021-09-18 01:22:33 +03:00
|
|
|
&ok);
|
|
|
|
if (!ok)
|
|
|
|
return;
|
|
|
|
|
|
|
|
if (password.isEmpty()) {
|
2022-01-12 21:09:46 +03:00
|
|
|
QMessageBox::warning(nullptr, tr("Error"), tr("The password cannot be empty"));
|
2021-09-18 01:22:33 +03:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Open file dialog to save the file.
|
|
|
|
const QString homeFolder = QStandardPaths::writableLocation(QStandardPaths::HomeLocation);
|
2022-01-09 02:28:03 +03:00
|
|
|
const QString fileName = QFileDialog::getSaveFileName(
|
2022-01-12 21:09:46 +03:00
|
|
|
nullptr, tr("File to save the exported session keys"), homeFolder);
|
2021-09-18 01:22:33 +03:00
|
|
|
|
|
|
|
QFile file(fileName);
|
|
|
|
if (!file.open(QIODevice::WriteOnly | QIODevice::Text)) {
|
2022-01-12 21:09:46 +03:00
|
|
|
QMessageBox::warning(nullptr, tr("Error"), file.errorString());
|
2021-09-18 01:22:33 +03:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Export sessions & save to file.
|
|
|
|
try {
|
|
|
|
auto encrypted_blob = mtx::crypto::encrypt_exported_sessions(cache::exportSessionKeys(),
|
|
|
|
password.toStdString());
|
|
|
|
|
|
|
|
QString b64 = QString::fromStdString(mtx::crypto::bin2base64(encrypted_blob));
|
|
|
|
|
2021-12-29 06:28:08 +03:00
|
|
|
QString prefix(QStringLiteral("-----BEGIN MEGOLM SESSION DATA-----"));
|
|
|
|
QString suffix(QStringLiteral("-----END MEGOLM SESSION DATA-----"));
|
|
|
|
QString newline(QStringLiteral("\n"));
|
2021-09-18 01:22:33 +03:00
|
|
|
QTextStream out(&file);
|
|
|
|
out << prefix << newline << b64 << newline << suffix << newline;
|
|
|
|
file.close();
|
|
|
|
} catch (const std::exception &e) {
|
2022-01-12 21:09:46 +03:00
|
|
|
QMessageBox::warning(nullptr, tr("Error"), e.what());
|
2021-09-18 01:22:33 +03:00
|
|
|
}
|
2018-09-15 23:52:14 +03:00
|
|
|
}
|
2020-12-17 00:10:09 +03:00
|
|
|
void
|
2022-01-09 02:28:03 +03:00
|
|
|
UserSettingsModel::requestCrossSigningSecrets()
|
|
|
|
{
|
|
|
|
olm::request_cross_signing_keys();
|
|
|
|
}
|
|
|
|
void
|
|
|
|
UserSettingsModel::downloadCrossSigningSecrets()
|
|
|
|
{
|
|
|
|
olm::download_cross_signing_keys();
|
|
|
|
}
|
|
|
|
|
|
|
|
UserSettingsModel::UserSettingsModel(QObject *p)
|
|
|
|
: QAbstractListModel(p)
|
|
|
|
{
|
|
|
|
auto s = UserSettings::instance();
|
|
|
|
connect(s.get(), &UserSettings::themeChanged, this, [this]() {
|
|
|
|
emit dataChanged(index(Theme), index(Theme), {Value});
|
|
|
|
});
|
|
|
|
connect(s.get(), &UserSettings::mobileModeChanged, this, [this]() {
|
|
|
|
emit dataChanged(index(MobileMode), index(MobileMode), {Value});
|
|
|
|
});
|
2023-12-31 22:15:38 +03:00
|
|
|
connect(s.get(), &UserSettings::disableSwipeChanged, this, [this]() {
|
|
|
|
emit dataChanged(index(DisableSwipe), index(DisableSwipe), {Value});
|
|
|
|
});
|
2022-01-09 02:28:03 +03:00
|
|
|
|
|
|
|
connect(s.get(), &UserSettings::fontChanged, this, [this]() {
|
|
|
|
emit dataChanged(index(Font), index(Font), {Value});
|
|
|
|
});
|
|
|
|
connect(s.get(), &UserSettings::fontSizeChanged, this, [this]() {
|
|
|
|
emit dataChanged(index(FontSize), index(FontSize), {Value});
|
|
|
|
});
|
|
|
|
connect(s.get(), &UserSettings::emojiFontChanged, this, [this]() {
|
|
|
|
emit dataChanged(index(EmojiFont), index(EmojiFont), {Value});
|
|
|
|
});
|
|
|
|
connect(s.get(), &UserSettings::avatarCirclesChanged, this, [this]() {
|
|
|
|
emit dataChanged(index(AvatarCircles), index(AvatarCircles), {Value});
|
|
|
|
});
|
|
|
|
connect(s.get(), &UserSettings::useIdenticonChanged, this, [this]() {
|
|
|
|
emit dataChanged(index(UseIdenticon), index(UseIdenticon), {Value});
|
|
|
|
});
|
2022-03-19 07:54:02 +03:00
|
|
|
connect(s.get(), &UserSettings::openImageExternalChanged, this, [this]() {
|
|
|
|
emit dataChanged(index(OpenImageExternal), index(OpenImageExternal), {Value});
|
|
|
|
});
|
2022-03-19 08:31:43 +03:00
|
|
|
connect(s.get(), &UserSettings::openVideoExternalChanged, this, [this]() {
|
|
|
|
emit dataChanged(index(OpenVideoExternal), index(OpenVideoExternal), {Value});
|
|
|
|
});
|
2022-01-09 02:28:03 +03:00
|
|
|
connect(s.get(), &UserSettings::privacyScreenChanged, this, [this]() {
|
|
|
|
emit dataChanged(index(PrivacyScreen), index(PrivacyScreen), {Value});
|
|
|
|
emit dataChanged(index(PrivacyScreenTimeout), index(PrivacyScreenTimeout), {Enabled});
|
|
|
|
});
|
|
|
|
connect(s.get(), &UserSettings::privacyScreenTimeoutChanged, this, [this]() {
|
|
|
|
emit dataChanged(index(PrivacyScreenTimeout), index(PrivacyScreenTimeout), {Value});
|
|
|
|
});
|
|
|
|
|
|
|
|
connect(s.get(), &UserSettings::timelineMaxWidthChanged, this, [this]() {
|
|
|
|
emit dataChanged(index(TimelineMaxWidth), index(TimelineMaxWidth), {Value});
|
|
|
|
});
|
|
|
|
connect(s.get(), &UserSettings::messageHoverHighlightChanged, this, [this]() {
|
|
|
|
emit dataChanged(index(MessageHoverHighlight), index(MessageHoverHighlight), {Value});
|
|
|
|
});
|
|
|
|
connect(s.get(), &UserSettings::enlargeEmojiOnlyMessagesChanged, this, [this]() {
|
|
|
|
emit dataChanged(index(EnlargeEmojiOnlyMessages), index(EnlargeEmojiOnlyMessages), {Value});
|
|
|
|
});
|
|
|
|
connect(s.get(), &UserSettings::animateImagesOnHoverChanged, this, [this]() {
|
|
|
|
emit dataChanged(index(AnimateImagesOnHover), index(AnimateImagesOnHover), {Value});
|
|
|
|
});
|
|
|
|
connect(s.get(), &UserSettings::typingNotificationsChanged, this, [this]() {
|
|
|
|
emit dataChanged(index(TypingNotifications), index(TypingNotifications), {Value});
|
|
|
|
});
|
|
|
|
connect(s.get(), &UserSettings::readReceiptsChanged, this, [this]() {
|
|
|
|
emit dataChanged(index(ReadReceipts), index(ReadReceipts), {Value});
|
|
|
|
});
|
|
|
|
connect(s.get(), &UserSettings::buttonInTimelineChanged, this, [this]() {
|
|
|
|
emit dataChanged(index(ButtonsInTimeline), index(ButtonsInTimeline), {Value});
|
|
|
|
});
|
|
|
|
connect(s.get(), &UserSettings::markdownChanged, this, [this]() {
|
|
|
|
emit dataChanged(index(Markdown), index(Markdown), {Value});
|
|
|
|
});
|
2022-11-05 01:53:36 +03:00
|
|
|
connect(s.get(), &UserSettings::invertEnterKeyChanged, this, [this]() {
|
|
|
|
emit dataChanged(index(InvertEnterKey), index(InvertEnterKey), {Value});
|
|
|
|
});
|
2022-02-05 01:12:30 +03:00
|
|
|
connect(s.get(), &UserSettings::bubblesChanged, this, [this]() {
|
|
|
|
emit dataChanged(index(Bubbles), index(Bubbles), {Value});
|
|
|
|
});
|
2022-02-13 15:12:51 +03:00
|
|
|
connect(s.get(), &UserSettings::smallAvatarsChanged, this, [this]() {
|
|
|
|
emit dataChanged(index(SmallAvatars), index(SmallAvatars), {Value});
|
|
|
|
});
|
2022-01-09 02:28:03 +03:00
|
|
|
connect(s.get(), &UserSettings::groupViewStateChanged, this, [this]() {
|
|
|
|
emit dataChanged(index(GroupView), index(GroupView), {Value});
|
|
|
|
});
|
2023-02-15 00:00:05 +03:00
|
|
|
connect(s.get(), &UserSettings::scrollbarsInRoomlistChanged, this, [this]() {
|
|
|
|
emit dataChanged(index(ScrollbarsInRoomlist), index(ScrollbarsInRoomlist), {Value});
|
|
|
|
});
|
2023-04-13 14:45:00 +03:00
|
|
|
connect(s.get(), &UserSettings::roomSortingChangedImportance, this, [this]() {
|
2022-01-09 02:28:03 +03:00
|
|
|
emit dataChanged(index(SortByImportance), index(SortByImportance), {Value});
|
|
|
|
});
|
2023-04-13 14:45:00 +03:00
|
|
|
connect(s.get(), &UserSettings::roomSortingChangedAlphabetical, this, [this]() {
|
|
|
|
emit dataChanged(index(SortByAlphabet), index(SortByAlphabet), {Value});
|
|
|
|
});
|
2022-01-09 02:28:03 +03:00
|
|
|
connect(s.get(), &UserSettings::decryptSidebarChanged, this, [this]() {
|
|
|
|
emit dataChanged(index(DecryptSidebar), index(DecryptSidebar), {Value});
|
|
|
|
});
|
2022-10-13 18:37:28 +03:00
|
|
|
connect(s.get(), &UserSettings::decryptNotificationsChanged, this, [this]() {
|
|
|
|
emit dataChanged(index(DecryptNotifications), index(DecryptNotifications), {Value});
|
|
|
|
});
|
2022-11-05 01:42:35 +03:00
|
|
|
connect(s.get(), &UserSettings::spaceNotificationsChanged, this, [this]() {
|
2022-04-23 03:34:15 +03:00
|
|
|
emit dataChanged(index(SpaceNotifications), index(SpaceNotifications), {Value});
|
|
|
|
});
|
2022-12-10 18:17:15 +03:00
|
|
|
connect(s.get(), &UserSettings::fancyEffectsChanged, this, [this]() {
|
|
|
|
emit dataChanged(index(FancyEffects), index(FancyEffects), {Value});
|
|
|
|
});
|
2023-02-06 15:56:23 +03:00
|
|
|
connect(s.get(), &UserSettings::reducedMotionChanged, this, [this]() {
|
|
|
|
emit dataChanged(index(ReducedMotion), index(ReducedMotion), {Value});
|
|
|
|
});
|
2022-01-09 02:28:03 +03:00
|
|
|
connect(s.get(), &UserSettings::trayChanged, this, [this]() {
|
|
|
|
emit dataChanged(index(Tray), index(Tray), {Value});
|
|
|
|
emit dataChanged(index(StartInTray), index(StartInTray), {Enabled});
|
|
|
|
});
|
|
|
|
connect(s.get(), &UserSettings::startInTrayChanged, this, [this]() {
|
|
|
|
emit dataChanged(index(StartInTray), index(StartInTray), {Value});
|
|
|
|
});
|
|
|
|
|
|
|
|
connect(s.get(), &UserSettings::desktopNotificationsChanged, this, [this]() {
|
|
|
|
emit dataChanged(index(DesktopNotifications), index(DesktopNotifications), {Value});
|
|
|
|
});
|
|
|
|
connect(s.get(), &UserSettings::alertOnNotificationChanged, this, [this]() {
|
|
|
|
emit dataChanged(index(AlertOnNotification), index(AlertOnNotification), {Value});
|
|
|
|
});
|
|
|
|
|
|
|
|
connect(s.get(), &UserSettings::useStunServerChanged, this, [this]() {
|
|
|
|
emit dataChanged(index(UseStunServer), index(UseStunServer), {Value});
|
|
|
|
});
|
|
|
|
connect(s.get(), &UserSettings::microphoneChanged, this, [this]() {
|
|
|
|
emit dataChanged(index(Microphone), index(Microphone), {Value, Values});
|
|
|
|
});
|
|
|
|
connect(s.get(), &UserSettings::cameraChanged, this, [this]() {
|
|
|
|
emit dataChanged(index(Camera), index(Camera), {Value, Values});
|
|
|
|
});
|
|
|
|
connect(s.get(), &UserSettings::cameraResolutionChanged, this, [this]() {
|
|
|
|
emit dataChanged(index(CameraResolution), index(CameraResolution), {Value, Values});
|
|
|
|
});
|
|
|
|
connect(s.get(), &UserSettings::cameraFrameRateChanged, this, [this]() {
|
|
|
|
emit dataChanged(index(CameraFrameRate), index(CameraFrameRate), {Value, Values});
|
|
|
|
});
|
|
|
|
connect(s.get(), &UserSettings::ringtoneChanged, this, [this]() {
|
|
|
|
emit dataChanged(index(Ringtone), index(Ringtone), {Values, Value});
|
|
|
|
});
|
|
|
|
|
|
|
|
connect(s.get(), &UserSettings::onlyShareKeysWithVerifiedUsersChanged, this, [this]() {
|
|
|
|
emit dataChanged(
|
|
|
|
index(OnlyShareKeysWithVerifiedUsers), index(OnlyShareKeysWithVerifiedUsers), {Value});
|
|
|
|
});
|
|
|
|
connect(s.get(), &UserSettings::shareKeysWithTrustedUsersChanged, this, [this]() {
|
|
|
|
emit dataChanged(
|
|
|
|
index(ShareKeysWithTrustedUsers), index(ShareKeysWithTrustedUsers), {Value});
|
|
|
|
});
|
|
|
|
connect(s.get(), &UserSettings::useOnlineKeyBackupChanged, this, [this]() {
|
|
|
|
emit dataChanged(index(UseOnlineKeyBackup), index(UseOnlineKeyBackup), {Value});
|
|
|
|
});
|
|
|
|
connect(MainWindow::instance(), &MainWindow::secretsChanged, this, [this]() {
|
|
|
|
emit dataChanged(index(OnlineBackupKey), index(MasterKey), {Value, Good});
|
|
|
|
});
|
2022-04-14 18:02:55 +03:00
|
|
|
connect(s.get(), &UserSettings::exposeDBusApiChanged, this, [this] {
|
|
|
|
emit dataChanged(index(ExposeDBusApi), index(ExposeDBusApi), {Value});
|
|
|
|
});
|
2023-03-14 05:02:54 +03:00
|
|
|
connect(s.get(), &UserSettings::updateSpaceViasChanged, this, [this] {
|
|
|
|
emit dataChanged(index(UpdateSpaceVias), index(UpdateSpaceVias), {Value});
|
|
|
|
});
|
2023-07-05 01:08:37 +03:00
|
|
|
connect(s.get(), &UserSettings::expireEventsChanged, this, [this] {
|
|
|
|
emit dataChanged(index(ExpireEvents), index(ExpireEvents), {Value});
|
|
|
|
});
|
2020-12-17 00:10:09 +03:00
|
|
|
}
|