| 1 | // SPDX-FileCopyrightText: Nheko Contributors |
| 2 | // |
| 3 | // SPDX-License-Identifier: GPL-3.0-or-later |
| 4 | |
| 5 | #include <QApplication> |
| 6 | #include <QCoreApplication> |
| 7 | #include <QFileDialog> |
| 8 | #include <QFontDatabase> |
| 9 | #include <QInputDialog> |
| 10 | #include <QMessageBox> |
| 11 | #include <QStandardPaths> |
| 12 | #include <QString> |
| 13 | #include <QTextStream> |
| 14 | #include <mtx/secret_storage.hpp> |
| 15 | |
| 16 | #include "Cache.h" |
| 17 | #include "JdenticonProvider.h" |
| 18 | #include "MainWindow.h" |
| 19 | #include "MatrixClient.h" |
| 20 | #include "UserSettingsPage.h" |
| 21 | #include "Utils.h" |
| 22 | #include "encryption/Olm.h" |
| 23 | #include "ui/Theme.h" |
| 24 | #include "voip/CallDevices.h" |
| 25 | |
| 26 | #include "config/nheko.h" |
| 27 | |
| 28 | QSharedPointer<UserSettings> UserSettings::instance_; |
| 29 | |
| 30 | UserSettings::UserSettings() |
| 31 | { |
| 32 | connect( |
| 33 | QCoreApplication::instance(), &QCoreApplication::aboutToQuit, []() { instance_.clear(); }); |
| 34 | } |
| 35 | |
| 36 | QSharedPointer<UserSettings> |
| 37 | UserSettings::instance() |
| 38 | { |
| 39 | return instance_; |
| 40 | } |
| 41 | |
| 42 | void |
| 43 | UserSettings::initialize(std::optional<QString> profile) |
| 44 | { |
| 45 | instance_.reset(new UserSettings()); |
| 46 | instance_->load(profile); |
| 47 | } |
| 48 | |
| 49 | void |
| 50 | UserSettings::load(std::optional<QString> profile) |
| 51 | { |
| 52 | tray_ = settings.value("user/window/tray", false).toBool(); |
| 53 | startInTray_ = settings.value("user/window/start_in_tray", false).toBool(); |
| 54 | |
| 55 | roomListWidth_ = settings.value("user/sidebar/room_list_width", -1).toInt(); |
| 56 | communityListWidth_ = settings.value("user/sidebar/community_list_width", -1).toInt(); |
| 57 | |
| 58 | hasDesktopNotifications_ = settings.value("user/desktop_notifications", true).toBool(); |
| 59 | hasAlertOnNotification_ = settings.value("user/alert_on_notification", false).toBool(); |
| 60 | groupView_ = settings.value("user/group_view", true).toBool(); |
| 61 | scrollbarsInRoomlist_ = settings.value("user/scrollbars_in_roomlist", false).toBool(); |
| 62 | buttonsInTimeline_ = settings.value("user/timeline/buttons", true).toBool(); |
| 63 | timelineMaxWidth_ = settings.value("user/timeline/max_width", 0).toInt(); |
| 64 | messageHoverHighlight_ = |
| 65 | settings.value("user/timeline/message_hover_highlight", false).toBool(); |
| 66 | enlargeEmojiOnlyMessages_ = |
| 67 | settings.value("user/timeline/enlarge_emoji_only_msg", false).toBool(); |
| 68 | markdown_ = settings.value("user/markdown_enabled", true).toBool(); |
| 69 | invertEnterKey_ = settings.value("user/invert_enter_key", false).toBool(); |
| 70 | bubbles_ = settings.value("user/bubbles_enabled", false).toBool(); |
| 71 | smallAvatars_ = settings.value("user/small_avatars_enabled", false).toBool(); |
| 72 | animateImagesOnHover_ = settings.value("user/animate_images_on_hover", false).toBool(); |
| 73 | typingNotifications_ = settings.value("user/typing_notifications", true).toBool(); |
| 74 | sortByImportance_ = settings.value("user/sort_by_unread", true).toBool(); |
| 75 | sortByAlphabet_ = settings.value("user/sort_by_alphabet", false).toBool(); |
| 76 | readReceipts_ = settings.value("user/read_receipts", true).toBool(); |
| 77 | theme_ = settings.value("user/theme", defaultTheme_).toString(); |
| 78 | |
| 79 | font_ = settings.value("user/font_family", "").toString(); |
| 80 | |
| 81 | avatarCircles_ = settings.value("user/avatar_circles", true).toBool(); |
| 82 | useIdenticon_ = settings.value("user/use_identicon", true).toBool(); |
| 83 | openImageExternal_ = settings.value("user/open_image_external", false).toBool(); |
| 84 | openVideoExternal_ = settings.value("user/open_video_external", false).toBool(); |
| 85 | decryptSidebar_ = settings.value("user/decrypt_sidebar", true).toBool(); |
| 86 | decryptNotifications_ = settings.value("user/decrypt_notifications", true).toBool(); |
| 87 | spaceNotifications_ = settings.value("user/space_notifications", true).toBool(); |
| 88 | fancyEffects_ = settings.value("user/fancy_effects", true).toBool(); |
| 89 | reducedMotion_ = settings.value("user/reduced_motion", false).toBool(); |
| 90 | privacyScreen_ = settings.value("user/privacy_screen", false).toBool(); |
| 91 | privacyScreenTimeout_ = settings.value("user/privacy_screen_timeout", 0).toInt(); |
| 92 | exposeDBusApi_ = settings.value("user/expose_dbus_api", false).toBool(); |
| 93 | updateSpaceVias_ = settings.value("user/space_background_maintenance", true).toBool(); |
| 94 | expireEvents_ = settings.value("user/expired_events_background_maintenance", false).toBool(); |
| 95 | |
| 96 | mobileMode_ = settings.value("user/mobile_mode", false).toBool(); |
| 97 | disableSwipe_ = settings.value("user/disable_swipe", false).toBool(); |
| 98 | emojiFont_ = settings.value("user/emoji_font_family", "emoji").toString(); |
| 99 | baseFontSize_ = settings.value("user/font_size", QFont().pointSizeF()).toDouble(); |
| 100 | ringtone_ = settings.value("user/ringtone", "Default").toString(); |
| 101 | microphone_ = settings.value("user/microphone", QString()).toString(); |
| 102 | camera_ = settings.value("user/camera", QString()).toString(); |
| 103 | cameraResolution_ = settings.value("user/camera_resolution", QString()).toString(); |
| 104 | cameraFrameRate_ = settings.value("user/camera_frame_rate", QString()).toString(); |
| 105 | screenShareFrameRate_ = settings.value("user/screen_share_frame_rate", 5).toInt(); |
| 106 | screenSharePiP_ = settings.value("user/screen_share_pip", true).toBool(); |
| 107 | screenShareRemoteVideo_ = settings.value("user/screen_share_remote_video", false).toBool(); |
| 108 | screenShareHideCursor_ = settings.value("user/screen_share_hide_cursor", false).toBool(); |
| 109 | useStunServer_ = settings.value("user/use_stun_server", false).toBool(); |
| 110 | |
| 111 | if (profile) // set to "" if it's the default to maintain compatibility |
| 112 | profile_ = (*profile == QLatin1String("default")) ? QLatin1String("") : *profile; |
| 113 | else |
| 114 | profile_ = settings.value("user/currentProfile", "").toString(); |
| 115 | |
| 116 | QString prefix = (profile_ != QLatin1String("") && profile_ != QLatin1String("default")) |
| 117 | ? "profile/" + profile_ + "/" |
| 118 | : QLatin1String(""); |
| 119 | accessToken_ = settings.value(prefix + "auth/access_token", "").toString(); |
| 120 | homeserver_ = settings.value(prefix + "auth/home_server", "").toString(); |
| 121 | userId_ = settings.value(prefix + "auth/user_id", "").toString(); |
| 122 | deviceId_ = settings.value(prefix + "auth/device_id", "").toString(); |
| 123 | currentTagId_ = settings.value(prefix + "user/current_tag_id", "").toString(); |
| 124 | hiddenTags_ = settings.value(prefix + "user/hidden_tags", QStringList{}).toStringList(); |
| 125 | mutedTags_ = settings.value(prefix + "user/muted_tags", QStringList{"global"}).toStringList(); |
| 126 | hiddenPins_ = settings.value(prefix + "user/hidden_pins", QStringList{}).toStringList(); |
| 127 | hiddenWidgets_ = settings.value(prefix + "user/hidden_widgets", QStringList{}).toStringList(); |
| 128 | recentReactions_ = |
| 129 | settings.value(prefix + "user/recent_reactions", QStringList{}).toStringList(); |
| 130 | auto tempPresence = settings.value(prefix + "user/presence", "").toString().toStdString(); |
| 131 | auto presenceValue = QMetaEnum::fromType<Presence>().keyToValue(tempPresence.c_str()); |
| 132 | if (presenceValue < 0) |
| 133 | presenceValue = 0; |
| 134 | presence_ = static_cast<Presence>(presenceValue); |
| 135 | |
| 136 | auto tempShowImage = settings.value(prefix + "user/show_images", "").toString().toStdString(); |
| 137 | auto showImageValue = QMetaEnum::fromType<ShowImage>().keyToValue(tempShowImage.c_str()); |
| 138 | if (showImageValue < 0) |
| 139 | showImageValue = 0; |
| 140 | showImage_ = static_cast<ShowImage>(showImageValue); |
| 141 | |
| 142 | collapsedSpaces_.clear(); |
| 143 | auto tempSpaces = settings.value(prefix + "user/collapsed_spaces", QList<QVariant>{}).toList(); |
| 144 | for (const auto &e : std::as_const(tempSpaces)) |
| 145 | collapsedSpaces_.push_back(e.toStringList()); |
| 146 | |
| 147 | shareKeysWithTrustedUsers_ = |
| 148 | settings.value(prefix + "user/automatically_share_keys_with_trusted_users", false).toBool(); |
| 149 | onlyShareKeysWithVerifiedUsers_ = |
| 150 | settings.value(prefix + "user/only_share_keys_with_verified_users", false).toBool(); |
| 151 | useOnlineKeyBackup_ = settings.value(prefix + "user/online_key_backup", true).toBool(); |
| 152 | |
| 153 | disableCertificateValidation_ = |
| 154 | settings.value("disable_certificate_validation", false).toBool(); |
| 155 | |
| 156 | applyTheme(); |
| 157 | |
| 158 | if (profile) |
| 159 | setProfile(profile_); |
| 160 | } |
| 161 | |
| 162 | bool |
| 163 | UserSettings::useIdenticon() const |
| 164 | { |
| 165 | return useIdenticon_ && JdenticonProvider::isAvailable(); |
| 166 | } |
| 167 | |
| 168 | void |
| 169 | UserSettings::setMessageHoverHighlight(bool state) |
| 170 | { |
| 171 | if (state == messageHoverHighlight_) |
| 172 | return; |
| 173 | messageHoverHighlight_ = state; |
| 174 | emit messageHoverHighlightChanged(state); |
| 175 | save(); |
| 176 | } |
| 177 | void |
| 178 | UserSettings::setEnlargeEmojiOnlyMessages(bool state) |
| 179 | { |
| 180 | if (state == enlargeEmojiOnlyMessages_) |
| 181 | return; |
| 182 | enlargeEmojiOnlyMessages_ = state; |
| 183 | emit enlargeEmojiOnlyMessagesChanged(state); |
| 184 | save(); |
| 185 | } |
| 186 | void |
| 187 | UserSettings::setTray(bool state) |
| 188 | { |
| 189 | if (state == tray_) |
| 190 | return; |
| 191 | tray_ = state; |
| 192 | emit trayChanged(state); |
| 193 | save(); |
| 194 | } |
| 195 | |
| 196 | void |
| 197 | UserSettings::setStartInTray(bool state) |
| 198 | { |
| 199 | if (state == startInTray_) |
| 200 | return; |
| 201 | startInTray_ = state; |
| 202 | emit startInTrayChanged(state); |
| 203 | save(); |
| 204 | } |
| 205 | |
| 206 | void |
| 207 | UserSettings::setMobileMode(bool state) |
| 208 | { |
| 209 | if (state == mobileMode_) |
| 210 | return; |
| 211 | mobileMode_ = state; |
| 212 | emit mobileModeChanged(state); |
| 213 | save(); |
| 214 | } |
| 215 | |
| 216 | void |
| 217 | UserSettings::setDisableSwipe(bool state) |
| 218 | { |
| 219 | if (state == disableSwipe_) |
| 220 | return; |
| 221 | disableSwipe_ = state; |
| 222 | emit disableSwipeChanged(state); |
| 223 | save(); |
| 224 | } |
| 225 | |
| 226 | void |
| 227 | UserSettings::setGroupView(bool state) |
| 228 | { |
| 229 | if (groupView_ == state) |
| 230 | return; |
| 231 | |
| 232 | groupView_ = state; |
| 233 | emit groupViewStateChanged(state); |
| 234 | save(); |
| 235 | } |
| 236 | |
| 237 | void |
| 238 | UserSettings::setScrollbarsInRoomlist(bool state) |
| 239 | { |
| 240 | if (scrollbarsInRoomlist_ == state) |
| 241 | return; |
| 242 | |
| 243 | scrollbarsInRoomlist_ = state; |
| 244 | emit scrollbarsInRoomlistChanged(state); |
| 245 | save(); |
| 246 | } |
| 247 | |
| 248 | void |
| 249 | UserSettings::setHiddenTags(const QStringList &hiddenTags) |
| 250 | { |
| 251 | hiddenTags_ = hiddenTags; |
| 252 | save(); |
| 253 | } |
| 254 | |
| 255 | void |
| 256 | UserSettings::setMutedTags(const QStringList &mutedTags) |
| 257 | { |
| 258 | mutedTags_ = mutedTags; |
| 259 | save(); |
| 260 | } |
| 261 | |
| 262 | void |
| 263 | UserSettings::setHiddenPins(const QStringList &hiddenTags) |
| 264 | { |
| 265 | hiddenPins_ = hiddenTags; |
| 266 | save(); |
| 267 | emit hiddenPinsChanged(); |
| 268 | } |
| 269 | |
| 270 | void |
| 271 | UserSettings::setHiddenWidgets(const QStringList &hiddenTags) |
| 272 | { |
| 273 | hiddenWidgets_ = hiddenTags; |
| 274 | save(); |
| 275 | emit hiddenWidgetsChanged(); |
| 276 | } |
| 277 | |
| 278 | void |
| 279 | UserSettings::setRecentReactions(QStringList recent) |
| 280 | { |
| 281 | recentReactions_ = recent; |
| 282 | save(); |
| 283 | emit recentReactionsChanged(); |
| 284 | } |
| 285 | |
| 286 | void |
| 287 | UserSettings::setCollapsedSpaces(QList<QStringList> spaces) |
| 288 | { |
| 289 | collapsedSpaces_ = spaces; |
| 290 | save(); |
| 291 | } |
| 292 | |
| 293 | void |
| 294 | UserSettings::setExposeDBusApi(bool state) |
| 295 | { |
| 296 | if (exposeDBusApi_ == state) |
| 297 | return; |
| 298 | |
| 299 | exposeDBusApi_ = state; |
| 300 | emit exposeDBusApiChanged(state); |
| 301 | save(); |
| 302 | } |
| 303 | |
| 304 | void |
| 305 | UserSettings::setUpdateSpaceVias(bool state) |
| 306 | { |
| 307 | if (updateSpaceVias_ == state) |
| 308 | return; |
| 309 | |
| 310 | updateSpaceVias_ = state; |
| 311 | emit updateSpaceViasChanged(state); |
| 312 | save(); |
| 313 | } |
| 314 | |
| 315 | void |
| 316 | UserSettings::setExpireEvents(bool state) |
| 317 | { |
| 318 | if (expireEvents_ == state) |
| 319 | return; |
| 320 | |
| 321 | expireEvents_ = state; |
| 322 | emit expireEventsChanged(state); |
| 323 | save(); |
| 324 | } |
| 325 | |
| 326 | void |
| 327 | UserSettings::setMarkdown(bool state) |
| 328 | { |
| 329 | if (state == markdown_) |
| 330 | return; |
| 331 | markdown_ = state; |
| 332 | emit markdownChanged(state); |
| 333 | save(); |
| 334 | } |
| 335 | |
| 336 | void |
| 337 | UserSettings::setInvertEnterKey(bool state) |
| 338 | { |
| 339 | if (state == invertEnterKey_) |
| 340 | return; |
| 341 | |
| 342 | invertEnterKey_ = state; |
| 343 | emit invertEnterKeyChanged(state); |
| 344 | save(); |
| 345 | } |
| 346 | |
| 347 | void |
| 348 | UserSettings::setBubbles(bool state) |
| 349 | { |
| 350 | if (state == bubbles_) |
| 351 | return; |
| 352 | bubbles_ = state; |
| 353 | emit bubblesChanged(state); |
| 354 | save(); |
| 355 | } |
| 356 | |
| 357 | void |
| 358 | UserSettings::setSmallAvatars(bool state) |
| 359 | { |
| 360 | if (state == smallAvatars_) |
| 361 | return; |
| 362 | smallAvatars_ = state; |
| 363 | emit smallAvatarsChanged(state); |
| 364 | save(); |
| 365 | } |
| 366 | |
| 367 | void |
| 368 | UserSettings::setAnimateImagesOnHover(bool state) |
| 369 | { |
| 370 | if (state == animateImagesOnHover_) |
| 371 | return; |
| 372 | animateImagesOnHover_ = state; |
| 373 | emit animateImagesOnHoverChanged(state); |
| 374 | save(); |
| 375 | } |
| 376 | |
| 377 | void |
| 378 | UserSettings::setReadReceipts(bool state) |
| 379 | { |
| 380 | if (state == readReceipts_) |
| 381 | return; |
| 382 | readReceipts_ = state; |
| 383 | emit readReceiptsChanged(state); |
| 384 | save(); |
| 385 | } |
| 386 | |
| 387 | void |
| 388 | UserSettings::setTypingNotifications(bool state) |
| 389 | { |
| 390 | if (state == typingNotifications_) |
| 391 | return; |
| 392 | typingNotifications_ = state; |
| 393 | emit typingNotificationsChanged(state); |
| 394 | save(); |
| 395 | } |
| 396 | |
| 397 | void |
| 398 | UserSettings::setSortByImportance(bool state) |
| 399 | { |
| 400 | if (state == sortByImportance_) |
| 401 | return; |
| 402 | sortByImportance_ = state; |
| 403 | emit roomSortingChangedImportance(state); |
| 404 | save(); |
| 405 | } |
| 406 | |
| 407 | void |
| 408 | UserSettings::setSortByAlphabet(bool state) |
| 409 | { |
| 410 | if (state == sortByAlphabet_) |
| 411 | return; |
| 412 | sortByAlphabet_ = state; |
| 413 | emit roomSortingChangedAlphabetical(state); |
| 414 | save(); |
| 415 | } |
| 416 | |
| 417 | void |
| 418 | UserSettings::setButtonsInTimeline(bool state) |
| 419 | { |
| 420 | if (state == buttonsInTimeline_) |
| 421 | return; |
| 422 | buttonsInTimeline_ = state; |
| 423 | emit buttonInTimelineChanged(state); |
| 424 | save(); |
| 425 | } |
| 426 | |
| 427 | void |
| 428 | UserSettings::setTimelineMaxWidth(int state) |
| 429 | { |
| 430 | if (state == timelineMaxWidth_) |
| 431 | return; |
| 432 | timelineMaxWidth_ = state; |
| 433 | emit timelineMaxWidthChanged(state); |
| 434 | save(); |
| 435 | } |
| 436 | void |
| 437 | UserSettings::setCommunityListWidth(int state) |
| 438 | { |
| 439 | if (state == communityListWidth_) |
| 440 | return; |
| 441 | communityListWidth_ = state; |
| 442 | emit communityListWidthChanged(state); |
| 443 | save(); |
| 444 | } |
| 445 | void |
| 446 | UserSettings::setRoomListWidth(int state) |
| 447 | { |
| 448 | if (state == roomListWidth_) |
| 449 | return; |
| 450 | roomListWidth_ = state; |
| 451 | emit roomListWidthChanged(state); |
| 452 | save(); |
| 453 | } |
| 454 | |
| 455 | void |
| 456 | UserSettings::setDesktopNotifications(bool state) |
| 457 | { |
| 458 | if (state == hasDesktopNotifications_) |
| 459 | return; |
| 460 | hasDesktopNotifications_ = state; |
| 461 | emit desktopNotificationsChanged(state); |
| 462 | save(); |
| 463 | } |
| 464 | |
| 465 | void |
| 466 | UserSettings::setAlertOnNotification(bool state) |
| 467 | { |
| 468 | if (state == hasAlertOnNotification_) |
| 469 | return; |
| 470 | hasAlertOnNotification_ = state; |
| 471 | emit alertOnNotificationChanged(state); |
| 472 | save(); |
| 473 | } |
| 474 | |
| 475 | void |
| 476 | UserSettings::setAvatarCircles(bool state) |
| 477 | { |
| 478 | if (state == avatarCircles_) |
| 479 | return; |
| 480 | avatarCircles_ = state; |
| 481 | emit avatarCirclesChanged(state); |
| 482 | save(); |
| 483 | } |
| 484 | |
| 485 | void |
| 486 | UserSettings::setDecryptSidebar(bool state) |
| 487 | { |
| 488 | if (state == decryptSidebar_) |
| 489 | return; |
| 490 | decryptSidebar_ = state; |
| 491 | emit decryptSidebarChanged(state); |
| 492 | save(); |
| 493 | } |
| 494 | |
| 495 | void |
| 496 | UserSettings::setDecryptNotifications(bool state) |
| 497 | { |
| 498 | if (state == decryptNotifications_) |
| 499 | return; |
| 500 | decryptNotifications_ = state; |
| 501 | emit decryptNotificationsChanged(state); |
| 502 | save(); |
| 503 | } |
| 504 | |
| 505 | void |
| 506 | UserSettings::setSpaceNotifications(bool state) |
| 507 | { |
| 508 | if (state == spaceNotifications_) |
| 509 | return; |
| 510 | spaceNotifications_ = state; |
| 511 | emit spaceNotificationsChanged(state); |
| 512 | save(); |
| 513 | } |
| 514 | |
| 515 | void |
| 516 | UserSettings::setFancyEffects(bool state) |
| 517 | { |
| 518 | if (state == fancyEffects_) |
| 519 | return; |
| 520 | fancyEffects_ = state; |
| 521 | emit fancyEffectsChanged(state); |
| 522 | save(); |
| 523 | } |
| 524 | |
| 525 | void |
| 526 | UserSettings::setReducedMotion(bool state) |
| 527 | { |
| 528 | if (state == reducedMotion_) |
| 529 | return; |
| 530 | reducedMotion_ = state; |
| 531 | emit reducedMotionChanged(state); |
| 532 | save(); |
| 533 | |
| 534 | // Also toggle other motion related settings |
| 535 | if (reducedMotion_) { |
| 536 | setFancyEffects(false); |
| 537 | setAnimateImagesOnHover(true); |
| 538 | } |
| 539 | } |
| 540 | |
| 541 | void |
| 542 | UserSettings::setPrivacyScreen(bool state) |
| 543 | { |
| 544 | if (state == privacyScreen_) { |
| 545 | return; |
| 546 | } |
| 547 | privacyScreen_ = state; |
| 548 | emit privacyScreenChanged(state); |
| 549 | save(); |
| 550 | } |
| 551 | |
| 552 | void |
| 553 | UserSettings::setPrivacyScreenTimeout(int state) |
| 554 | { |
| 555 | if (state == privacyScreenTimeout_) { |
| 556 | return; |
| 557 | } |
| 558 | privacyScreenTimeout_ = state; |
| 559 | emit privacyScreenTimeoutChanged(state); |
| 560 | save(); |
| 561 | } |
| 562 | |
| 563 | void |
| 564 | UserSettings::setFontSize(double size) |
| 565 | { |
| 566 | if (size == baseFontSize_) |
| 567 | return; |
| 568 | baseFontSize_ = size; |
| 569 | |
| 570 | const static auto defaultFamily = QFont().defaultFamily(); |
| 571 | QFont f((font_.isEmpty() || font_ == QStringLiteral("default")) ? defaultFamily : font_); |
| 572 | f.setPointSizeF(fontSize()); |
| 573 | QApplication::setFont(f); |
| 574 | |
| 575 | emit fontSizeChanged(size); |
| 576 | save(); |
| 577 | } |
| 578 | |
| 579 | void |
| 580 | UserSettings::setFontFamily(QString family) |
| 581 | { |
| 582 | if (family == font_) |
| 583 | return; |
| 584 | font_ = family; |
| 585 | |
| 586 | const static auto defaultFamily = QFont().defaultFamily(); |
| 587 | QFont f((family.isEmpty() || family == QStringLiteral("default")) ? defaultFamily : family); |
| 588 | f.setPointSizeF(fontSize()); |
| 589 | QApplication::setFont(f); |
| 590 | |
| 591 | emit fontChanged(family); |
| 592 | save(); |
| 593 | } |
| 594 | |
| 595 | void |
| 596 | UserSettings::setEmojiFontFamily(QString family) |
| 597 | { |
| 598 | if (family == emojiFont_) |
| 599 | return; |
| 600 | |
| 601 | #if QT_VERSION >= QT_VERSION_CHECK(6, 9, 0) |
| 602 | if (emojiFont_.isEmpty()) { |
| 603 | QFontDatabase::removeApplicationEmojiFontFamily(emojiFont_); |
| 604 | } |
| 605 | #endif |
| 606 | |
| 607 | if (family.isEmpty() || family == QStringLiteral("emoji")) { |
| 608 | emojiFont_.clear(); |
| 609 | } else { |
| 610 | #if QT_VERSION >= QT_VERSION_CHECK(6, 9, 0) |
| 611 | QFontDatabase::addApplicationEmojiFontFamily(family); |
| 612 | #endif |
| 613 | emojiFont_ = family; |
| 614 | } |
| 615 | |
| 616 | emit emojiFontChanged(family); |
| 617 | save(); |
| 618 | } |
| 619 | |
| 620 | void |
| 621 | UserSettings::setPresence(Presence state) |
| 622 | { |
| 623 | if (state == presence_) |
| 624 | return; |
| 625 | presence_ = state; |
| 626 | emit presenceChanged(state); |
| 627 | save(); |
| 628 | } |
| 629 | |
| 630 | void |
| 631 | UserSettings::setShowImage(ShowImage state) |
| 632 | { |
| 633 | if (state == showImage_) |
| 634 | return; |
| 635 | showImage_ = state; |
| 636 | emit showImageChanged(state); |
| 637 | save(); |
| 638 | } |
| 639 | |
| 640 | void |
| 641 | UserSettings::setTheme(QString theme) |
| 642 | { |
| 643 | if (theme == theme_) |
| 644 | return; |
| 645 | theme_ = theme; |
| 646 | save(); |
| 647 | applyTheme(); |
| 648 | emit themeChanged(theme); |
| 649 | } |
| 650 | |
| 651 | void |
| 652 | UserSettings::setUseStunServer(bool useStunServer) |
| 653 | { |
| 654 | if (useStunServer == useStunServer_) |
| 655 | return; |
| 656 | useStunServer_ = useStunServer; |
| 657 | emit useStunServerChanged(useStunServer); |
| 658 | save(); |
| 659 | } |
| 660 | |
| 661 | void |
| 662 | UserSettings::setOnlyShareKeysWithVerifiedUsers(bool shareKeys) |
| 663 | { |
| 664 | if (shareKeys == onlyShareKeysWithVerifiedUsers_) |
| 665 | return; |
| 666 | |
| 667 | onlyShareKeysWithVerifiedUsers_ = shareKeys; |
| 668 | emit onlyShareKeysWithVerifiedUsersChanged(shareKeys); |
| 669 | save(); |
| 670 | } |
| 671 | |
| 672 | void |
| 673 | UserSettings::setShareKeysWithTrustedUsers(bool shareKeys) |
| 674 | { |
| 675 | if (shareKeys == shareKeysWithTrustedUsers_) |
| 676 | return; |
| 677 | |
| 678 | shareKeysWithTrustedUsers_ = shareKeys; |
| 679 | emit shareKeysWithTrustedUsersChanged(shareKeys); |
| 680 | save(); |
| 681 | } |
| 682 | |
| 683 | void |
| 684 | UserSettings::setUseOnlineKeyBackup(bool useBackup) |
| 685 | { |
| 686 | if (useBackup == useOnlineKeyBackup_) |
| 687 | return; |
| 688 | |
| 689 | useOnlineKeyBackup_ = useBackup; |
| 690 | emit useOnlineKeyBackupChanged(useBackup); |
| 691 | save(); |
| 692 | |
| 693 | if (useBackup) |
| 694 | olm::download_full_keybackup(); |
| 695 | } |
| 696 | |
| 697 | void |
| 698 | UserSettings::setRingtone(QString ringtone) |
| 699 | { |
| 700 | if (ringtone == ringtone_) |
| 701 | return; |
| 702 | ringtone_ = ringtone; |
| 703 | emit ringtoneChanged(ringtone); |
| 704 | save(); |
| 705 | } |
| 706 | |
| 707 | void |
| 708 | UserSettings::setMicrophone(QString microphone) |
| 709 | { |
| 710 | if (microphone == microphone_) |
| 711 | return; |
| 712 | microphone_ = microphone; |
| 713 | emit microphoneChanged(microphone); |
| 714 | save(); |
| 715 | } |
| 716 | |
| 717 | void |
| 718 | UserSettings::setCamera(QString camera) |
| 719 | { |
| 720 | if (camera == camera_) |
| 721 | return; |
| 722 | camera_ = camera; |
| 723 | emit cameraChanged(camera); |
| 724 | save(); |
| 725 | } |
| 726 | |
| 727 | void |
| 728 | UserSettings::setCameraResolution(QString resolution) |
| 729 | { |
| 730 | if (resolution == cameraResolution_) |
| 731 | return; |
| 732 | cameraResolution_ = resolution; |
| 733 | emit cameraResolutionChanged(resolution); |
| 734 | save(); |
| 735 | } |
| 736 | |
| 737 | void |
| 738 | UserSettings::setCameraFrameRate(QString frameRate) |
| 739 | { |
| 740 | if (frameRate == cameraFrameRate_) |
| 741 | return; |
| 742 | cameraFrameRate_ = frameRate; |
| 743 | emit cameraFrameRateChanged(frameRate); |
| 744 | save(); |
| 745 | } |
| 746 | |
| 747 | void |
| 748 | UserSettings::setScreenShareFrameRate(int frameRate) |
| 749 | { |
| 750 | if (frameRate == screenShareFrameRate_) |
| 751 | return; |
| 752 | screenShareFrameRate_ = frameRate; |
| 753 | emit screenShareFrameRateChanged(frameRate); |
| 754 | save(); |
| 755 | } |
| 756 | |
| 757 | void |
| 758 | UserSettings::setScreenSharePiP(bool state) |
| 759 | { |
| 760 | if (state == screenSharePiP_) |
| 761 | return; |
| 762 | screenSharePiP_ = state; |
| 763 | emit screenSharePiPChanged(state); |
| 764 | save(); |
| 765 | } |
| 766 | |
| 767 | void |
| 768 | UserSettings::setScreenShareRemoteVideo(bool state) |
| 769 | { |
| 770 | if (state == screenShareRemoteVideo_) |
| 771 | return; |
| 772 | screenShareRemoteVideo_ = state; |
| 773 | emit screenShareRemoteVideoChanged(state); |
| 774 | save(); |
| 775 | } |
| 776 | |
| 777 | void |
| 778 | UserSettings::setScreenShareHideCursor(bool state) |
| 779 | { |
| 780 | if (state == screenShareHideCursor_) |
| 781 | return; |
| 782 | screenShareHideCursor_ = state; |
| 783 | emit screenShareHideCursorChanged(state); |
| 784 | save(); |
| 785 | } |
| 786 | |
| 787 | void |
| 788 | UserSettings::setProfile(QString profile) |
| 789 | { |
| 790 | // always set this to allow setting this when loading and it is overwritten on the cli |
| 791 | profile_ = profile; |
| 792 | emit profileChanged(profile_); |
| 793 | save(); |
| 794 | } |
| 795 | |
| 796 | void |
| 797 | UserSettings::setUserId(QString userId) |
| 798 | { |
| 799 | if (userId == userId_) |
| 800 | return; |
| 801 | userId_ = userId; |
| 802 | emit userIdChanged(userId_); |
| 803 | save(); |
| 804 | } |
| 805 | |
| 806 | void |
| 807 | UserSettings::setAccessToken(QString accessToken) |
| 808 | { |
| 809 | if (accessToken == accessToken_) |
| 810 | return; |
| 811 | accessToken_ = accessToken; |
| 812 | emit accessTokenChanged(accessToken_); |
| 813 | save(); |
| 814 | } |
| 815 | |
| 816 | void |
| 817 | UserSettings::setDeviceId(QString deviceId) |
| 818 | { |
| 819 | if (deviceId == deviceId_) |
| 820 | return; |
| 821 | deviceId_ = deviceId; |
| 822 | emit deviceIdChanged(deviceId_); |
| 823 | save(); |
| 824 | } |
| 825 | |
| 826 | void |
| 827 | UserSettings::setCurrentTagId(const QString currentTagId) |
| 828 | { |
| 829 | if (currentTagId == currentTagId_) |
| 830 | return; |
| 831 | currentTagId_ = currentTagId; |
| 832 | save(); |
| 833 | } |
| 834 | |
| 835 | void |
| 836 | UserSettings::setHomeserver(QString homeserver) |
| 837 | { |
| 838 | if (homeserver == homeserver_) |
| 839 | return; |
| 840 | homeserver_ = homeserver; |
| 841 | emit homeserverChanged(homeserver_); |
| 842 | save(); |
| 843 | } |
| 844 | |
| 845 | void |
| 846 | UserSettings::setDisableCertificateValidation(bool disabled) |
| 847 | { |
| 848 | if (disabled == disableCertificateValidation_) |
| 849 | return; |
| 850 | disableCertificateValidation_ = disabled; |
| 851 | http::client()->verify_certificates(!disabled); |
| 852 | emit disableCertificateValidationChanged(disabled); |
| 853 | } |
| 854 | |
| 855 | void |
| 856 | UserSettings::setUseIdenticon(bool state) |
| 857 | { |
| 858 | if (state == useIdenticon_) |
| 859 | return; |
| 860 | useIdenticon_ = state; |
| 861 | emit useIdenticonChanged(useIdenticon_); |
| 862 | save(); |
| 863 | } |
| 864 | |
| 865 | void |
| 866 | UserSettings::setOpenImageExternal(bool state) |
| 867 | { |
| 868 | if (state == openImageExternal_) |
| 869 | return; |
| 870 | openImageExternal_ = state; |
| 871 | emit openImageExternalChanged(openImageExternal_); |
| 872 | save(); |
| 873 | } |
| 874 | |
| 875 | void |
| 876 | UserSettings::setOpenVideoExternal(bool state) |
| 877 | { |
| 878 | if (state == openVideoExternal_) |
| 879 | return; |
| 880 | openVideoExternal_ = state; |
| 881 | emit openVideoExternalChanged(openVideoExternal_); |
| 882 | save(); |
| 883 | } |
| 884 | |
| 885 | void |
| 886 | UserSettings::applyTheme() |
| 887 | { |
| 888 | QGuiApplication::setPalette(Theme::paletteFromTheme(this->theme())); |
| 889 | QApplication::setPalette(Theme::paletteFromTheme(this->theme())); |
| 890 | } |
| 891 | |
| 892 | void |
| 893 | UserSettings::save() |
| 894 | { |
| 895 | settings.beginGroup("user"); |
| 896 | |
| 897 | settings.beginGroup("window"); |
| 898 | settings.setValue("tray", tray_); |
| 899 | settings.setValue("start_in_tray", startInTray_); |
| 900 | settings.endGroup(); // window |
| 901 | |
| 902 | settings.beginGroup("sidebar"); |
| 903 | settings.setValue("community_list_width", communityListWidth_); |
| 904 | settings.setValue("room_list_width", roomListWidth_); |
| 905 | settings.endGroup(); // window |
| 906 | |
| 907 | settings.beginGroup("timeline"); |
| 908 | settings.setValue("buttons", buttonsInTimeline_); |
| 909 | settings.setValue("message_hover_highlight", messageHoverHighlight_); |
| 910 | settings.setValue("enlarge_emoji_only_msg", enlargeEmojiOnlyMessages_); |
| 911 | settings.setValue("max_width", timelineMaxWidth_); |
| 912 | settings.endGroup(); // timeline |
| 913 | |
| 914 | settings.setValue("avatar_circles", avatarCircles_); |
| 915 | settings.setValue("decrypt_sidebar", decryptSidebar_); |
| 916 | settings.setValue("decrypt_notifications", decryptNotifications_); |
| 917 | settings.setValue("space_notifications", spaceNotifications_); |
| 918 | settings.setValue("fancy_effects", fancyEffects_); |
| 919 | settings.setValue("reduced_motion", reducedMotion_); |
| 920 | settings.setValue("privacy_screen", privacyScreen_); |
| 921 | settings.setValue("privacy_screen_timeout", privacyScreenTimeout_); |
| 922 | settings.setValue("mobile_mode", mobileMode_); |
| 923 | settings.setValue("disable_swipe", disableSwipe_); |
| 924 | settings.setValue("font_size", baseFontSize_); |
| 925 | settings.setValue("typing_notifications", typingNotifications_); |
| 926 | settings.setValue("sort_by_unread", sortByImportance_); |
| 927 | settings.setValue("sort_by_alphabet", sortByAlphabet_); |
| 928 | settings.setValue("minor_events", sortByImportance_); |
| 929 | settings.setValue("read_receipts", readReceipts_); |
| 930 | settings.setValue("group_view", groupView_); |
| 931 | settings.setValue("scrollbars_in_roomlist", scrollbarsInRoomlist_); |
| 932 | settings.setValue("markdown_enabled", markdown_); |
| 933 | settings.setValue("invert_enter_key", invertEnterKey_); |
| 934 | settings.setValue("bubbles_enabled", bubbles_); |
| 935 | settings.setValue("small_avatars_enabled", smallAvatars_); |
| 936 | settings.setValue("animate_images_on_hover", animateImagesOnHover_); |
| 937 | settings.setValue("desktop_notifications", hasDesktopNotifications_); |
| 938 | settings.setValue("alert_on_notification", hasAlertOnNotification_); |
| 939 | settings.setValue("theme", theme()); |
| 940 | settings.setValue("font_family", font_); |
| 941 | settings.setValue("emoji_font_family", emojiFont_); |
| 942 | settings.setValue("ringtone", ringtone_); |
| 943 | settings.setValue("microphone", microphone_); |
| 944 | settings.setValue("camera", camera_); |
| 945 | settings.setValue("camera_resolution", cameraResolution_); |
| 946 | settings.setValue("camera_frame_rate", cameraFrameRate_); |
| 947 | settings.setValue("screen_share_frame_rate", screenShareFrameRate_); |
| 948 | settings.setValue("screen_share_pip", screenSharePiP_); |
| 949 | settings.setValue("screen_share_remote_video", screenShareRemoteVideo_); |
| 950 | settings.setValue("screen_share_hide_cursor", screenShareHideCursor_); |
| 951 | settings.setValue("use_stun_server", useStunServer_); |
| 952 | settings.setValue("currentProfile", profile_); |
| 953 | settings.setValue("use_identicon", useIdenticon_); |
| 954 | settings.setValue("open_image_external", openImageExternal_); |
| 955 | settings.setValue("open_video_external", openVideoExternal_); |
| 956 | settings.setValue("expose_dbus_api", exposeDBusApi_); |
| 957 | settings.setValue("space_background_maintenance", updateSpaceVias_); |
| 958 | settings.setValue("expired_events_background_maintenance", expireEvents_); |
| 959 | |
| 960 | settings.endGroup(); // user |
| 961 | |
| 962 | QString prefix = (profile_ != QLatin1String("") && profile_ != QLatin1String("default")) |
| 963 | ? "profile/" + profile_ + "/" |
| 964 | : QLatin1String(""); |
| 965 | settings.setValue(prefix + "auth/access_token", accessToken_); |
| 966 | settings.setValue(prefix + "auth/home_server", homeserver_); |
| 967 | settings.setValue(prefix + "auth/user_id", userId_); |
| 968 | settings.setValue(prefix + "auth/device_id", deviceId_); |
| 969 | settings.setValue(prefix + "user/current_tag_id", currentTagId_); |
| 970 | settings.setValue(prefix + "user/automatically_share_keys_with_trusted_users", |
| 971 | shareKeysWithTrustedUsers_); |
| 972 | settings.setValue(prefix + "user/only_share_keys_with_verified_users", |
| 973 | onlyShareKeysWithVerifiedUsers_); |
| 974 | settings.setValue(prefix + "user/online_key_backup", useOnlineKeyBackup_); |
| 975 | settings.setValue(prefix + "user/hidden_tags", hiddenTags_); |
| 976 | settings.setValue(prefix + "user/muted_tags", mutedTags_); |
| 977 | settings.setValue(prefix + "user/hidden_pins", hiddenPins_); |
| 978 | settings.setValue(prefix + "user/hidden_widgets", hiddenWidgets_); |
| 979 | settings.setValue(prefix + "user/recent_reactions", recentReactions_); |
| 980 | settings.setValue( |
| 981 | prefix + "user/presence", |
| 982 | QString::fromUtf8(QMetaEnum::fromType<Presence>().valueToKey(static_cast<int>(presence_)))); |
| 983 | settings.setValue( |
| 984 | prefix + "user/show_images", |
| 985 | QString::fromUtf8(QMetaEnum::fromType<ShowImage>().valueToKey(static_cast<int>(showImage_)))); |
| 986 | |
| 987 | QVariantList v; |
| 988 | v.reserve(collapsedSpaces_.size()); |
| 989 | for (const auto &e : std::as_const(collapsedSpaces_)) |
| 990 | v.push_back(e); |
| 991 | settings.setValue(prefix + "user/collapsed_spaces", v); |
| 992 | |
| 993 | settings.setValue("disable_certificate_validation", disableCertificateValidation_); |
| 994 | |
| 995 | settings.sync(); |
| 996 | } |
| 997 | |
| 998 | QHash<int, QByteArray> |
| 999 | UserSettingsModel::roleNames() const |
| 1000 | { |
| 1001 | static QHash<int, QByteArray> roles{ |
| 1002 | {Name, "name"}, |
| 1003 | {Description, "description"}, |
| 1004 | {Value, "value"}, |
| 1005 | {Type, "type"}, |
| 1006 | {ValueLowerBound, "valueLowerBound"}, |
| 1007 | {ValueUpperBound, "valueUpperBound"}, |
| 1008 | {ValueStep, "valueStep"}, |
| 1009 | {Values, "values"}, |
| 1010 | {Good, "good"}, |
| 1011 | {Enabled, "enabled"}, |
| 1012 | }; |
| 1013 | |
| 1014 | return roles; |
| 1015 | } |
| 1016 | |
| 1017 | QVariant |
| 1018 | UserSettingsModel::data(const QModelIndex &index, int role) const |
| 1019 | { |
| 1020 | if (index.row() >= COUNT) |
| 1021 | return {}; |
| 1022 | |
| 1023 | auto i = UserSettings::instance(); |
| 1024 | if (!i) |
| 1025 | return {}; |
| 1026 | |
| 1027 | if (role == Name) { |
| 1028 | switch (index.row()) { |
| 1029 | case Theme: |
| 1030 | return tr("Theme"); |
| 1031 | case ScaleFactor: |
| 1032 | return tr("Scale factor"); |
| 1033 | case MessageHoverHighlight: |
| 1034 | return tr("Highlight message on hover"); |
| 1035 | case EnlargeEmojiOnlyMessages: |
| 1036 | return tr("Large Emoji in timeline"); |
| 1037 | case Tray: |
| 1038 | return tr("Minimize to tray"); |
| 1039 | case StartInTray: |
| 1040 | return tr("Start in tray"); |
| 1041 | case GroupView: |
| 1042 | return tr("Communities sidebar"); |
| 1043 | case ScrollbarsInRoomlist: |
| 1044 | return tr("Scrollbars in room list"); |
| 1045 | case Markdown: |
| 1046 | return tr("Send messages as Markdown"); |
| 1047 | case InvertEnterKey: |
| 1048 | return tr("Use shift+enter to send and enter to start a new line"); |
| 1049 | case Bubbles: |
| 1050 | return tr("Enable message bubbles"); |
| 1051 | case SmallAvatars: |
| 1052 | return tr("Enable small Avatars"); |
| 1053 | case AnimateImagesOnHover: |
| 1054 | return tr("Play animated images only on hover"); |
| 1055 | case ShowImage: |
| 1056 | return tr("Show images automatically"); |
| 1057 | case TypingNotifications: |
| 1058 | return tr("Typing notifications"); |
| 1059 | case SortByImportance: |
| 1060 | return tr("Sort rooms by unreads"); |
| 1061 | case SortByAlphabet: |
| 1062 | return tr("Sort rooms alphabetically"); |
| 1063 | case ButtonsInTimeline: |
| 1064 | return tr("Show buttons in timeline"); |
| 1065 | case TimelineMaxWidth: |
| 1066 | return tr("Limit width of timeline"); |
| 1067 | case ReadReceipts: |
| 1068 | return tr("Read receipts"); |
| 1069 | case HiddenTimelineEvents: |
| 1070 | return tr("Hidden events"); |
| 1071 | case IgnoredUsers: |
| 1072 | return tr("Ignored users"); |
| 1073 | case DesktopNotifications: |
| 1074 | return tr("Desktop notifications"); |
| 1075 | case AlertOnNotification: |
| 1076 | return tr("Alert on notification"); |
| 1077 | case AvatarCircles: |
| 1078 | return tr("Circular Avatars"); |
| 1079 | case UseIdenticon: |
| 1080 | return tr("Use identicons"); |
| 1081 | case OpenImageExternal: |
| 1082 | return tr("Open images with external program"); |
| 1083 | case OpenVideoExternal: |
| 1084 | return tr("Open videos with external program"); |
| 1085 | case DecryptSidebar: |
| 1086 | return tr("Decrypt messages in sidebar"); |
| 1087 | case DecryptNotifications: |
| 1088 | return tr("Decrypt notifications"); |
| 1089 | case SpaceNotifications: |
| 1090 | return tr("Show message counts for communities and tags"); |
| 1091 | case FancyEffects: |
| 1092 | return tr("Display fancy effects such as confetti"); |
| 1093 | case ReducedMotion: |
| 1094 | return tr("Reduce or disable animations"); |
| 1095 | case PrivacyScreen: |
| 1096 | return tr("Privacy Screen"); |
| 1097 | case PrivacyScreenTimeout: |
| 1098 | return tr("Privacy screen timeout (in seconds [0 - 3600])"); |
| 1099 | case MobileMode: |
| 1100 | return tr("Touchscreen mode"); |
| 1101 | case DisableSwipe: |
| 1102 | return tr("Disable swipe motions"); |
| 1103 | case FontSize: |
| 1104 | return tr("Font size"); |
| 1105 | case Font: |
| 1106 | return tr("Font Family"); |
| 1107 | case EmojiFont: |
| 1108 | return tr("Emoji Font Family"); |
| 1109 | case Ringtone: |
| 1110 | return tr("Ringtone"); |
| 1111 | case Microphone: |
| 1112 | return tr("Microphone"); |
| 1113 | case Camera: |
| 1114 | return tr("Camera"); |
| 1115 | case CameraResolution: |
| 1116 | return tr("Camera resolution"); |
| 1117 | case CameraFrameRate: |
| 1118 | return tr("Camera frame rate"); |
| 1119 | case UseStunServer: |
| 1120 | return tr("Allow fallback call assist server"); |
| 1121 | case OnlyShareKeysWithVerifiedUsers: |
| 1122 | return tr("Send encrypted messages to verified users only"); |
| 1123 | case ShareKeysWithTrustedUsers: |
| 1124 | return tr("Share keys with verified users and devices"); |
| 1125 | case UseOnlineKeyBackup: |
| 1126 | return tr("Online Key Backup"); |
| 1127 | case Profile: |
| 1128 | return tr("Profile"); |
| 1129 | case UserId: |
| 1130 | return tr("User ID"); |
| 1131 | case AccessToken: |
| 1132 | return tr("Accesstoken"); |
| 1133 | case DeviceId: |
| 1134 | return tr("Device ID"); |
| 1135 | case DeviceFingerprint: |
| 1136 | return tr("Device Fingerprint"); |
| 1137 | case Homeserver: |
| 1138 | return tr("Homeserver"); |
| 1139 | case Version: |
| 1140 | return tr("Version"); |
| 1141 | case Platform: |
| 1142 | return tr("Platform"); |
| 1143 | case GeneralSection: |
| 1144 | return tr("GENERAL"); |
| 1145 | case AccessibilitySection: |
| 1146 | return tr("ACCESSIBILITY"); |
| 1147 | case TimelineSection: |
| 1148 | return tr("TIMELINE"); |
| 1149 | case SidebarSection: |
| 1150 | return tr("SIDEBAR"); |
| 1151 | case TraySection: |
| 1152 | return tr("TRAY"); |
| 1153 | case MessageVisibilitySection: |
| 1154 | return tr("GLOBAL MESSAGE VISIBILITY"); |
| 1155 | case NotificationsSection: |
| 1156 | return tr("NOTIFICATIONS"); |
| 1157 | case VoipSection: |
| 1158 | return tr("CALLS"); |
| 1159 | case EncryptionSection: |
| 1160 | return tr("ENCRYPTION"); |
| 1161 | case LoginInfoSection: |
| 1162 | return tr("INFO"); |
| 1163 | case SessionKeys: |
| 1164 | return tr("Session Keys"); |
| 1165 | case CrossSigningSecrets: |
| 1166 | return tr("Cross Signing Secrets"); |
| 1167 | case OnlineBackupKey: |
| 1168 | return tr("Online backup key"); |
| 1169 | case SelfSigningKey: |
| 1170 | return tr("Self signing key"); |
| 1171 | case UserSigningKey: |
| 1172 | return tr("User signing key"); |
| 1173 | case MasterKey: |
| 1174 | return tr("Master signing key"); |
| 1175 | case ExposeDBusApi: |
| 1176 | return tr("Expose room information via D-Bus"); |
| 1177 | case UpdateSpaceVias: |
| 1178 | return tr("Periodically update community routing information"); |
| 1179 | case ExpireEvents: |
| 1180 | return tr("Periodically delete expired events"); |
| 1181 | } |
| 1182 | } else if (role == Value) { |
| 1183 | switch (index.row()) { |
| 1184 | case Theme: |
| 1185 | return QStringList{ |
| 1186 | QStringLiteral("light"), |
| 1187 | QStringLiteral("dark"), |
| 1188 | QStringLiteral("system"), |
| 1189 | } |
| 1190 | .indexOf(i->theme()); |
| 1191 | case ScaleFactor: |
| 1192 | return utils::scaleFactor(); |
| 1193 | case MessageHoverHighlight: |
| 1194 | return i->messageHoverHighlight(); |
| 1195 | case EnlargeEmojiOnlyMessages: |
| 1196 | return i->enlargeEmojiOnlyMessages(); |
| 1197 | case Tray: |
| 1198 | return i->tray(); |
| 1199 | case StartInTray: |
| 1200 | return i->startInTray(); |
| 1201 | case GroupView: |
| 1202 | return i->groupView(); |
| 1203 | case ScrollbarsInRoomlist: |
| 1204 | return i->scrollbarsInRoomlist(); |
| 1205 | case Markdown: |
| 1206 | return i->markdown(); |
| 1207 | case InvertEnterKey: |
| 1208 | return i->invertEnterKey(); |
| 1209 | case Bubbles: |
| 1210 | return i->bubbles(); |
| 1211 | case SmallAvatars: |
| 1212 | return i->smallAvatars(); |
| 1213 | case AnimateImagesOnHover: |
| 1214 | return i->animateImagesOnHover(); |
| 1215 | case ShowImage: |
| 1216 | return static_cast<int>(i->showImage()); |
| 1217 | case TypingNotifications: |
| 1218 | return i->typingNotifications(); |
| 1219 | case SortByImportance: |
| 1220 | return i->sortByImportance(); |
| 1221 | case SortByAlphabet: |
| 1222 | return i->sortByAlphabet(); |
| 1223 | case ButtonsInTimeline: |
| 1224 | return i->buttonsInTimeline(); |
| 1225 | case TimelineMaxWidth: |
| 1226 | return i->timelineMaxWidth(); |
| 1227 | case ReadReceipts: |
| 1228 | return i->readReceipts(); |
| 1229 | case DesktopNotifications: |
| 1230 | return i->hasDesktopNotifications(); |
| 1231 | case AlertOnNotification: |
| 1232 | return i->hasAlertOnNotification(); |
| 1233 | case AvatarCircles: |
| 1234 | return i->avatarCircles(); |
| 1235 | case UseIdenticon: |
| 1236 | return i->useIdenticon(); |
| 1237 | case OpenImageExternal: |
| 1238 | return i->openImageExternal(); |
| 1239 | case OpenVideoExternal: |
| 1240 | return i->openVideoExternal(); |
| 1241 | case DecryptSidebar: |
| 1242 | return i->decryptSidebar(); |
| 1243 | case DecryptNotifications: |
| 1244 | return i->decryptNotifications(); |
| 1245 | case SpaceNotifications: |
| 1246 | return i->spaceNotifications(); |
| 1247 | case FancyEffects: |
| 1248 | return i->fancyEffects(); |
| 1249 | case ReducedMotion: |
| 1250 | return i->reducedMotion(); |
| 1251 | case PrivacyScreen: |
| 1252 | return i->privacyScreen(); |
| 1253 | case PrivacyScreenTimeout: |
| 1254 | return i->privacyScreenTimeout(); |
| 1255 | case MobileMode: |
| 1256 | return i->mobileMode(); |
| 1257 | case DisableSwipe: |
| 1258 | return i->disableSwipe(); |
| 1259 | case FontSize: |
| 1260 | return i->fontSize(); |
| 1261 | case Font: { |
| 1262 | if (i->font().isEmpty()) |
| 1263 | return 0; |
| 1264 | else |
| 1265 | return data(index, Values).toStringList().indexOf(i->font()); |
| 1266 | } |
| 1267 | case EmojiFont: { |
| 1268 | if (i->emojiFont().isEmpty() || i->emojiFont() == QLatin1String("emoji")) |
| 1269 | return 0; |
| 1270 | else |
| 1271 | return data(index, Values).toStringList().indexOf(i->emojiFont()); |
| 1272 | } |
| 1273 | case Ringtone: { |
| 1274 | auto v = i->ringtone(); |
| 1275 | if (v == QStringView(u"Mute")) |
| 1276 | return 0; |
| 1277 | else if (v == QStringView(u"Default")) |
| 1278 | return 1; |
| 1279 | else if (v == QStringView(u"Other")) |
| 1280 | return 2; |
| 1281 | else |
| 1282 | return 3; |
| 1283 | } |
| 1284 | case Microphone: |
| 1285 | return data(index, Values).toStringList().indexOf(i->microphone()); |
| 1286 | case Camera: |
| 1287 | return data(index, Values).toStringList().indexOf(i->camera()); |
| 1288 | case CameraResolution: |
| 1289 | return data(index, Values).toStringList().indexOf(i->cameraResolution()); |
| 1290 | case CameraFrameRate: |
| 1291 | return data(index, Values).toStringList().indexOf(i->cameraFrameRate()); |
| 1292 | case UseStunServer: |
| 1293 | return i->useStunServer(); |
| 1294 | case OnlyShareKeysWithVerifiedUsers: |
| 1295 | return i->onlyShareKeysWithVerifiedUsers(); |
| 1296 | case ShareKeysWithTrustedUsers: |
| 1297 | return i->shareKeysWithTrustedUsers(); |
| 1298 | case UseOnlineKeyBackup: |
| 1299 | return i->useOnlineKeyBackup(); |
| 1300 | case Profile: |
| 1301 | return i->profile().isEmpty() ? tr("Default") : i->profile(); |
| 1302 | case UserId: |
| 1303 | return i->userId(); |
| 1304 | case AccessToken: |
| 1305 | return i->accessToken(); |
| 1306 | case DeviceId: |
| 1307 | return i->deviceId(); |
| 1308 | case DeviceFingerprint: |
| 1309 | return utils::humanReadableFingerprint(olm::client()->identity_keys().ed25519); |
| 1310 | case Homeserver: |
| 1311 | return i->homeserver(); |
| 1312 | case Version: |
| 1313 | return QString::fromStdString(nheko::version); |
| 1314 | case Platform: |
| 1315 | return QString::fromStdString(nheko::build_os); |
| 1316 | case OnlineBackupKey: |
| 1317 | return cache::secret(mtx::secret_storage::secrets::megolm_backup_v1).has_value(); |
| 1318 | case SelfSigningKey: |
| 1319 | return cache::secret(mtx::secret_storage::secrets::cross_signing_self_signing) |
| 1320 | .has_value(); |
| 1321 | case UserSigningKey: |
| 1322 | return cache::secret(mtx::secret_storage::secrets::cross_signing_user_signing) |
| 1323 | .has_value(); |
| 1324 | case MasterKey: |
| 1325 | return cache::secret(mtx::secret_storage::secrets::cross_signing_master).has_value(); |
| 1326 | case ExposeDBusApi: |
| 1327 | return i->exposeDBusApi(); |
| 1328 | case UpdateSpaceVias: |
| 1329 | return i->updateSpaceVias(); |
| 1330 | case ExpireEvents: |
| 1331 | return i->expireEvents(); |
| 1332 | } |
| 1333 | } else if (role == Description) { |
| 1334 | switch (index.row()) { |
| 1335 | case Theme: |
| 1336 | case Font: |
| 1337 | case EmojiFont: |
| 1338 | return {}; |
| 1339 | case Microphone: |
| 1340 | return tr("Set the notification sound to play when a call invite arrives"); |
| 1341 | case Camera: |
| 1342 | case CameraResolution: |
| 1343 | case CameraFrameRate: |
| 1344 | case Ringtone: |
| 1345 | return {}; |
| 1346 | case TimelineMaxWidth: |
| 1347 | return tr("Set the max width of messages in the timeline (in pixels). This can help " |
| 1348 | "readability on wide screen when Nheko is maximized"); |
| 1349 | case PrivacyScreenTimeout: |
| 1350 | return tr( |
| 1351 | "Set timeout (in seconds) for how long after window loses\nfocus before the screen" |
| 1352 | " will be blurred.\nSet to 0 to blur immediately after focus loss. Max value of 1 " |
| 1353 | "hour (3600 seconds)"); |
| 1354 | case FontSize: |
| 1355 | return {}; |
| 1356 | case MessageHoverHighlight: |
| 1357 | return tr("Change the background color of messages when you hover over them."); |
| 1358 | case EnlargeEmojiOnlyMessages: |
| 1359 | return tr("Make font size larger if messages with only a few emojis are displayed."); |
| 1360 | case Tray: |
| 1361 | return tr( |
| 1362 | "Keep the application running in the background after closing the client window."); |
| 1363 | case StartInTray: |
| 1364 | return tr("Start the application in the background without showing the client window."); |
| 1365 | case GroupView: |
| 1366 | return tr("Show a column containing communities and tags next to the room list."); |
| 1367 | case ScrollbarsInRoomlist: |
| 1368 | return tr("Shows scrollbars in the room list and communities list."); |
| 1369 | case Markdown: |
| 1370 | return tr( |
| 1371 | "Allow using markdown in messages.\nWhen disabled, all messages are sent as a plain " |
| 1372 | "text."); |
| 1373 | case InvertEnterKey: |
| 1374 | return tr( |
| 1375 | "Invert the behavior of the enter key in the text input, making it send the message " |
| 1376 | "when shift+enter is pressed and starting a new line when enter is pressed."); |
| 1377 | case Bubbles: |
| 1378 | return tr( |
| 1379 | "Messages get a bubble background. This also triggers some layout changes (WIP)."); |
| 1380 | case SmallAvatars: |
| 1381 | return tr("Avatars are resized to fit above the message."); |
| 1382 | case AnimateImagesOnHover: |
| 1383 | return tr("Plays media like GIFs or WEBPs only when explicitly hovering over them."); |
| 1384 | case ShowImage: |
| 1385 | return tr("If images should be automatically displayed. You can select between always " |
| 1386 | "showing images by default, only show them by default in private rooms or " |
| 1387 | "always require interaction to show images."); |
| 1388 | case TypingNotifications: |
| 1389 | return tr( |
| 1390 | "Show who is typing in a room.\nThis will also enable or disable sending typing " |
| 1391 | "notifications to others."); |
| 1392 | case SortByImportance: |
| 1393 | return tr( |
| 1394 | "Display rooms with new messages first.\nIf this is off, the list of rooms will only " |
| 1395 | "be sorted by the preferred sorting order.\nIf this is on, rooms " |
| 1396 | "which " |
| 1397 | "have active notifications (the small circle with a number in it) will be sorted on " |
| 1398 | "top. Rooms that you have muted will still be sorted by the preferred sorting order, " |
| 1399 | "since you don't " |
| 1400 | "seem to consider them as important as the other rooms."); |
| 1401 | case SortByAlphabet: |
| 1402 | return tr( |
| 1403 | "Sort rooms alphabetically.\nIf this is off, the list of rooms will be sorted by the " |
| 1404 | "timestamp of the last message in a room.\nIf this is on, rooms that come first " |
| 1405 | "alphabetically " |
| 1406 | "will be sorted earlier than ones that come later."); |
| 1407 | case ButtonsInTimeline: |
| 1408 | return tr( |
| 1409 | "Show buttons to quickly reply, react or access additional options next to each " |
| 1410 | "message."); |
| 1411 | case ReadReceipts: |
| 1412 | return tr( |
| 1413 | "Show if your message was read.\nStatus is displayed next to timestamps.\nWarning: " |
| 1414 | "If your homeserver does not support this, your rooms will never be marked as read!"); |
| 1415 | case HiddenTimelineEvents: |
| 1416 | return tr("Configure whether to show or hide certain events like room joins."); |
| 1417 | case DesktopNotifications: |
| 1418 | return tr("Notify about received messages when the client is not currently focused."); |
| 1419 | case AlertOnNotification: |
| 1420 | return tr( |
| 1421 | "Show an alert when a message is received.\nThis usually causes the application " |
| 1422 | "icon in the task bar to animate in some fashion."); |
| 1423 | case AvatarCircles: |
| 1424 | return tr( |
| 1425 | "Change the appearance of user avatars in chats.\nOFF - square, ON - circle."); |
| 1426 | case UseIdenticon: |
| 1427 | return tr("Display an identicon instead of a letter when no avatar is set."); |
| 1428 | case OpenImageExternal: |
| 1429 | return tr("Opens images with an external program when tapping the image.\nNote that " |
| 1430 | "when this option is ON, opened files are left unencrypted on disk and must " |
| 1431 | "be manually deleted."); |
| 1432 | case OpenVideoExternal: |
| 1433 | return tr("Opens videos with an external program when tapping the video.\nNote that " |
| 1434 | "when this option is ON, opened files are left unencrypted on disk and must " |
| 1435 | "be manually deleted."); |
| 1436 | case DecryptSidebar: |
| 1437 | return tr("Decrypt the messages shown in the sidebar.\nOnly affects messages in " |
| 1438 | "encrypted chats."); |
| 1439 | case DecryptNotifications: |
| 1440 | return tr("Decrypt messages shown in notifications for encrypted chats."); |
| 1441 | case SpaceNotifications: |
| 1442 | return tr("Choose where to show the total number of notifications contained within a " |
| 1443 | "community or tag."); |
| 1444 | case FancyEffects: |
| 1445 | return tr("Some messages can be sent with fancy effects. For example, messages sent " |
| 1446 | "with '/confetti' will show confetti on screen."); |
| 1447 | case ReducedMotion: |
| 1448 | return tr("Nheko uses animations in several places to make stuff pretty. This allows " |
| 1449 | "you to turn those off if they make you feel unwell."); |
| 1450 | case PrivacyScreen: |
| 1451 | return tr("When the window loses focus, the timeline will\nbe blurred."); |
| 1452 | case MobileMode: |
| 1453 | return tr( |
| 1454 | "Will prevent text selection in the timeline to make touch scrolling easier."); |
| 1455 | case DisableSwipe: |
| 1456 | return tr("Will prevent swipe motions like swiping left/right between Rooms and " |
| 1457 | "Timeline, or swiping a message to reply."); |
| 1458 | case ScaleFactor: |
| 1459 | return tr("Change the scale factor of the whole user interface. Requires a restart to " |
| 1460 | "take effect."); |
| 1461 | case UseStunServer: |
| 1462 | return tr( |
| 1463 | "Will use turn.matrix.org as assist when your home server does not offer one."); |
| 1464 | case OnlyShareKeysWithVerifiedUsers: |
| 1465 | return tr("Requires a user to be verified to send encrypted messages to them. This " |
| 1466 | "improves safety but makes E2EE more tedious."); |
| 1467 | case ShareKeysWithTrustedUsers: |
| 1468 | return tr( |
| 1469 | "Automatically replies to key requests from other users if they are verified, " |
| 1470 | "even if that device shouldn't have access to those keys otherwise."); |
| 1471 | case UseOnlineKeyBackup: |
| 1472 | return tr( |
| 1473 | "Download message encryption keys from and upload to the encrypted online key " |
| 1474 | "backup."); |
| 1475 | case Profile: |
| 1476 | case UserId: |
| 1477 | case AccessToken: |
| 1478 | case DeviceId: |
| 1479 | case DeviceFingerprint: |
| 1480 | case Homeserver: |
| 1481 | case Version: |
| 1482 | case Platform: |
| 1483 | case GeneralSection: |
| 1484 | case AccessibilitySection: |
| 1485 | case TimelineSection: |
| 1486 | case SidebarSection: |
| 1487 | case TraySection: |
| 1488 | case MessageVisibilitySection: |
| 1489 | case NotificationsSection: |
| 1490 | case VoipSection: |
| 1491 | case EncryptionSection: |
| 1492 | case LoginInfoSection: |
| 1493 | case SessionKeys: |
| 1494 | case CrossSigningSecrets: |
| 1495 | return {}; |
| 1496 | case OnlineBackupKey: |
| 1497 | return tr( |
| 1498 | "The key to decrypt online key backups. If it is cached, you can enable online " |
| 1499 | "key backup to store encryption keys securely encrypted on the server."); |
| 1500 | case SelfSigningKey: |
| 1501 | return tr( |
| 1502 | "The key to verify your own devices. If it is cached, verifying one of your devices " |
| 1503 | "will mark it verified for all your other devices and for users that have verified " |
| 1504 | "you."); |
| 1505 | case UserSigningKey: |
| 1506 | return tr( |
| 1507 | "The key to verify other users. If it is cached, verifying a user will verify " |
| 1508 | "all their devices."); |
| 1509 | case MasterKey: |
| 1510 | return tr( |
| 1511 | "Your most important key. You don't need to have it cached, since not caching " |
| 1512 | "it makes it less likely it can be stolen and it is only needed to rotate your " |
| 1513 | "other signing keys."); |
| 1514 | case ExposeDBusApi: |
| 1515 | return tr("Allow third-party plugins and applications to load information about rooms " |
| 1516 | "you are in via D-Bus. " |
| 1517 | "This can have useful applications, but it also could be used for nefarious " |
| 1518 | "purposes. Enable at your own risk.\n\n" |
| 1519 | "This setting will take effect upon restart."); |
| 1520 | case UpdateSpaceVias: |
| 1521 | return tr( |
| 1522 | "To allow new users to join a community, the community needs to expose some " |
| 1523 | "information about what servers participate in a room to community members. Since " |
| 1524 | "the room participants can change over time, this needs to be updated from time to " |
| 1525 | "time. This setting enables a background job to do that automatically."); |
| 1526 | case ExpireEvents: |
| 1527 | return tr("Regularly redact expired events as specified in the event expiration " |
| 1528 | "configuration. Since this is currently not executed server side, you need " |
| 1529 | "to have one client running this regularly."); |
| 1530 | case IgnoredUsers: |
| 1531 | return tr("Manage your ignored users."); |
| 1532 | } |
| 1533 | } else if (role == Type) { |
| 1534 | switch (index.row()) { |
| 1535 | case Theme: |
| 1536 | case Font: |
| 1537 | case EmojiFont: |
| 1538 | case Microphone: |
| 1539 | case Camera: |
| 1540 | case CameraResolution: |
| 1541 | case CameraFrameRate: |
| 1542 | case Ringtone: |
| 1543 | case ShowImage: |
| 1544 | return Options; |
| 1545 | case TimelineMaxWidth: |
| 1546 | case PrivacyScreenTimeout: |
| 1547 | return Integer; |
| 1548 | case FontSize: |
| 1549 | case ScaleFactor: |
| 1550 | return Double; |
| 1551 | case MessageHoverHighlight: |
| 1552 | case EnlargeEmojiOnlyMessages: |
| 1553 | case Tray: |
| 1554 | case StartInTray: |
| 1555 | case GroupView: |
| 1556 | case ScrollbarsInRoomlist: |
| 1557 | case Markdown: |
| 1558 | case InvertEnterKey: |
| 1559 | case Bubbles: |
| 1560 | case SmallAvatars: |
| 1561 | case AnimateImagesOnHover: |
| 1562 | case TypingNotifications: |
| 1563 | case SortByImportance: |
| 1564 | case SortByAlphabet: |
| 1565 | case ButtonsInTimeline: |
| 1566 | case ReadReceipts: |
| 1567 | case DesktopNotifications: |
| 1568 | case AlertOnNotification: |
| 1569 | case AvatarCircles: |
| 1570 | case UseIdenticon: |
| 1571 | case OpenImageExternal: |
| 1572 | case OpenVideoExternal: |
| 1573 | case DecryptSidebar: |
| 1574 | case DecryptNotifications: |
| 1575 | case PrivacyScreen: |
| 1576 | case MobileMode: |
| 1577 | case DisableSwipe: |
| 1578 | case UseStunServer: |
| 1579 | case OnlyShareKeysWithVerifiedUsers: |
| 1580 | case ShareKeysWithTrustedUsers: |
| 1581 | case UseOnlineKeyBackup: |
| 1582 | case ExposeDBusApi: |
| 1583 | case UpdateSpaceVias: |
| 1584 | case ExpireEvents: |
| 1585 | case SpaceNotifications: |
| 1586 | case FancyEffects: |
| 1587 | case ReducedMotion: |
| 1588 | return Toggle; |
| 1589 | case Profile: |
| 1590 | case UserId: |
| 1591 | case AccessToken: |
| 1592 | case DeviceId: |
| 1593 | case DeviceFingerprint: |
| 1594 | case Homeserver: |
| 1595 | case Version: |
| 1596 | case Platform: |
| 1597 | return ReadOnlyText; |
| 1598 | case GeneralSection: |
| 1599 | case AccessibilitySection: |
| 1600 | case TimelineSection: |
| 1601 | case SidebarSection: |
| 1602 | case TraySection: |
| 1603 | case MessageVisibilitySection: |
| 1604 | case NotificationsSection: |
| 1605 | case VoipSection: |
| 1606 | case EncryptionSection: |
| 1607 | case LoginInfoSection: |
| 1608 | return SectionTitle; |
| 1609 | case SessionKeys: |
| 1610 | return SessionKeyImportExport; |
| 1611 | case CrossSigningSecrets: |
| 1612 | return XSignKeysRequestDownload; |
| 1613 | case OnlineBackupKey: |
| 1614 | case SelfSigningKey: |
| 1615 | case UserSigningKey: |
| 1616 | case MasterKey: |
| 1617 | return KeyStatus; |
| 1618 | case HiddenTimelineEvents: |
| 1619 | return ConfigureHiddenEvents; |
| 1620 | case IgnoredUsers: |
| 1621 | return ManageIgnoredUsers; |
| 1622 | } |
| 1623 | } else if (role == ValueLowerBound) { |
| 1624 | switch (index.row()) { |
| 1625 | case TimelineMaxWidth: |
| 1626 | return 0; |
| 1627 | case PrivacyScreenTimeout: |
| 1628 | return 0; |
| 1629 | case FontSize: |
| 1630 | return 8.0; |
| 1631 | case ScaleFactor: |
| 1632 | return 1.0; |
| 1633 | } |
| 1634 | } else if (role == ValueUpperBound) { |
| 1635 | switch (index.row()) { |
| 1636 | case TimelineMaxWidth: |
| 1637 | return 20000; |
| 1638 | case PrivacyScreenTimeout: |
| 1639 | return 3600; |
| 1640 | case FontSize: |
| 1641 | return 24.0; |
| 1642 | case ScaleFactor: |
| 1643 | return 3.0; |
| 1644 | } |
| 1645 | } else if (role == ValueStep) { |
| 1646 | switch (index.row()) { |
| 1647 | case TimelineMaxWidth: |
| 1648 | return 20; |
| 1649 | case PrivacyScreenTimeout: |
| 1650 | return 10; |
| 1651 | case FontSize: |
| 1652 | return 0.5; |
| 1653 | case ScaleFactor: |
| 1654 | return .25; |
| 1655 | } |
| 1656 | } else if (role == Values) { |
| 1657 | auto vecToList = [](const std::vector<std::string> &vec) { |
| 1658 | QStringList l; |
| 1659 | for (const auto &d : vec) |
| 1660 | l.push_back(QString::fromStdString(d)); |
| 1661 | |
| 1662 | return l; |
| 1663 | }; |
| 1664 | switch (index.row()) { |
| 1665 | case Theme: |
| 1666 | return QStringList{ |
| 1667 | QStringLiteral("Light"), |
| 1668 | QStringLiteral("Dark"), |
| 1669 | QStringLiteral("System"), |
| 1670 | }; |
| 1671 | case ShowImage: |
| 1672 | return QStringList{ |
| 1673 | tr("Always"), |
| 1674 | tr("Only in private rooms"), |
| 1675 | tr("Never"), |
| 1676 | }; |
| 1677 | case Microphone: |
| 1678 | return vecToList(CallDevices::instance().names(false, i->microphone().toStdString())); |
| 1679 | case Camera: |
| 1680 | return vecToList(CallDevices::instance().names(true, i->camera().toStdString())); |
| 1681 | case CameraResolution: |
| 1682 | return vecToList(CallDevices::instance().resolutions(i->camera().toStdString())); |
| 1683 | case CameraFrameRate: |
| 1684 | return vecToList(CallDevices::instance().frameRates( |
| 1685 | i->camera().toStdString(), i->cameraResolution().toStdString())); |
| 1686 | |
| 1687 | case Font: { |
| 1688 | auto fonts = QFontDatabase::families(); |
| 1689 | fonts.prepend(tr("System font")); |
| 1690 | return fonts; |
| 1691 | } |
| 1692 | case EmojiFont: { |
| 1693 | auto fonts = QFontDatabase::families(QFontDatabase::WritingSystem::Symbol); |
| 1694 | fonts.prepend(tr("System emoji font")); |
| 1695 | return fonts; |
| 1696 | } |
| 1697 | case Ringtone: { |
| 1698 | QStringList l{ |
| 1699 | QStringLiteral("Mute"), |
| 1700 | QStringLiteral("Default"), |
| 1701 | QStringLiteral("Other"), |
| 1702 | }; |
| 1703 | if (!l.contains(i->ringtone())) |
| 1704 | l.push_back(i->ringtone()); |
| 1705 | return l; |
| 1706 | } |
| 1707 | } |
| 1708 | } else if (role == Good) { |
| 1709 | switch (index.row()) { |
| 1710 | case OnlineBackupKey: |
| 1711 | return cache::secret(mtx::secret_storage::secrets::megolm_backup_v1).has_value(); |
| 1712 | case SelfSigningKey: |
| 1713 | return cache::secret(mtx::secret_storage::secrets::cross_signing_self_signing) |
| 1714 | .has_value(); |
| 1715 | case UserSigningKey: |
| 1716 | return cache::secret(mtx::secret_storage::secrets::cross_signing_user_signing) |
| 1717 | .has_value(); |
| 1718 | case MasterKey: |
| 1719 | return true; |
| 1720 | } |
| 1721 | } else if (role == Enabled) { |
| 1722 | switch (index.row()) { |
| 1723 | case StartInTray: |
| 1724 | return i->tray(); |
| 1725 | case PrivacyScreenTimeout: |
| 1726 | return i->privacyScreen(); |
| 1727 | case UseIdenticon: |
| 1728 | return JdenticonProvider::isAvailable(); |
| 1729 | default: |
| 1730 | return true; |
| 1731 | } |
| 1732 | } |
| 1733 | |
| 1734 | return {}; |
| 1735 | } |
| 1736 | |
| 1737 | bool |
| 1738 | UserSettingsModel::setData(const QModelIndex &index, const QVariant &value, int role) |
| 1739 | { |
| 1740 | auto i = UserSettings::instance(); |
| 1741 | if (role == Value) { |
| 1742 | switch (index.row()) { |
| 1743 | case Theme: { |
| 1744 | if (value == 0) { |
| 1745 | i->setTheme("light"); |
| 1746 | return true; |
| 1747 | } else if (value == 1) { |
| 1748 | i->setTheme("dark"); |
| 1749 | return true; |
| 1750 | } else if (value == 2) { |
| 1751 | i->setTheme("system"); |
| 1752 | return true; |
| 1753 | } else |
| 1754 | return false; |
| 1755 | } |
| 1756 | case ShowImage: { |
| 1757 | auto showImageValue = value.toInt(); |
| 1758 | if (showImageValue < 0 || |
| 1759 | |
| 1760 | QMetaEnum::fromType<UserSettings::ShowImage>().keyCount() <= showImageValue) |
| 1761 | return false; |
| 1762 | |
| 1763 | i->setShowImage(static_cast<UserSettings::ShowImage>(showImageValue)); |
| 1764 | return true; |
| 1765 | } |
| 1766 | case MessageHoverHighlight: { |
| 1767 | if (value.userType() == QMetaType::Bool) { |
| 1768 | i->setMessageHoverHighlight(value.toBool()); |
| 1769 | return true; |
| 1770 | } else |
| 1771 | return false; |
| 1772 | } |
| 1773 | case ScaleFactor: { |
| 1774 | if (value.canConvert(QMetaType::fromType<double>())) { |
| 1775 | utils::setScaleFactor(static_cast<float>(value.toDouble())); |
| 1776 | return true; |
| 1777 | } else |
| 1778 | return false; |
| 1779 | } |
| 1780 | case EnlargeEmojiOnlyMessages: { |
| 1781 | if (value.userType() == QMetaType::Bool) { |
| 1782 | i->setEnlargeEmojiOnlyMessages(value.toBool()); |
| 1783 | return true; |
| 1784 | } else |
| 1785 | return false; |
| 1786 | } |
| 1787 | case Tray: { |
| 1788 | if (value.userType() == QMetaType::Bool) { |
| 1789 | i->setTray(value.toBool()); |
| 1790 | return true; |
| 1791 | } else |
| 1792 | return false; |
| 1793 | } |
| 1794 | case StartInTray: { |
| 1795 | if (value.userType() == QMetaType::Bool) { |
| 1796 | i->setStartInTray(value.toBool()); |
| 1797 | return true; |
| 1798 | } else |
| 1799 | return false; |
| 1800 | } |
| 1801 | case GroupView: { |
| 1802 | if (value.userType() == QMetaType::Bool) { |
| 1803 | i->setGroupView(value.toBool()); |
| 1804 | return true; |
| 1805 | } else |
| 1806 | return false; |
| 1807 | } |
| 1808 | case ScrollbarsInRoomlist: { |
| 1809 | if (value.userType() == QMetaType::Bool) { |
| 1810 | i->setScrollbarsInRoomlist(value.toBool()); |
| 1811 | return true; |
| 1812 | } else |
| 1813 | return false; |
| 1814 | } |
| 1815 | case Markdown: { |
| 1816 | if (value.userType() == QMetaType::Bool) { |
| 1817 | i->setMarkdown(value.toBool()); |
| 1818 | return true; |
| 1819 | } else |
| 1820 | return false; |
| 1821 | } |
| 1822 | case InvertEnterKey: { |
| 1823 | if (value.userType() == QMetaType::Bool) { |
| 1824 | i->setInvertEnterKey(value.toBool()); |
| 1825 | return true; |
| 1826 | } else |
| 1827 | return false; |
| 1828 | } |
| 1829 | case Bubbles: { |
| 1830 | if (value.userType() == QMetaType::Bool) { |
| 1831 | i->setBubbles(value.toBool()); |
| 1832 | return true; |
| 1833 | } else |
| 1834 | return false; |
| 1835 | } |
| 1836 | case SmallAvatars: { |
| 1837 | if (value.userType() == QMetaType::Bool) { |
| 1838 | i->setSmallAvatars(value.toBool()); |
| 1839 | return true; |
| 1840 | } else |
| 1841 | return false; |
| 1842 | } |
| 1843 | case AnimateImagesOnHover: { |
| 1844 | if (value.userType() == QMetaType::Bool) { |
| 1845 | i->setAnimateImagesOnHover(value.toBool()); |
| 1846 | return true; |
| 1847 | } else |
| 1848 | return false; |
| 1849 | } |
| 1850 | case TypingNotifications: { |
| 1851 | if (value.userType() == QMetaType::Bool) { |
| 1852 | i->setTypingNotifications(value.toBool()); |
| 1853 | return true; |
| 1854 | } else |
| 1855 | return false; |
| 1856 | } |
| 1857 | case SortByImportance: { |
| 1858 | if (value.userType() == QMetaType::Bool) { |
| 1859 | i->setSortByImportance(value.toBool()); |
| 1860 | return true; |
| 1861 | } else |
| 1862 | return false; |
| 1863 | } |
| 1864 | case SortByAlphabet: { |
| 1865 | if (value.userType() == QMetaType::Bool) { |
| 1866 | i->setSortByAlphabet(value.toBool()); |
| 1867 | return true; |
| 1868 | } else |
| 1869 | return false; |
| 1870 | } |
| 1871 | case ButtonsInTimeline: { |
| 1872 | if (value.userType() == QMetaType::Bool) { |
| 1873 | i->setButtonsInTimeline(value.toBool()); |
| 1874 | return true; |
| 1875 | } else |
| 1876 | return false; |
| 1877 | } |
| 1878 | case TimelineMaxWidth: { |
| 1879 | if (value.canConvert(QMetaType::fromType<int>())) { |
| 1880 | i->setTimelineMaxWidth(value.toInt()); |
| 1881 | return true; |
| 1882 | } else |
| 1883 | return false; |
| 1884 | } |
| 1885 | case ReadReceipts: { |
| 1886 | if (value.userType() == QMetaType::Bool) { |
| 1887 | i->setReadReceipts(value.toBool()); |
| 1888 | return true; |
| 1889 | } else |
| 1890 | return false; |
| 1891 | } |
| 1892 | case DesktopNotifications: { |
| 1893 | if (value.userType() == QMetaType::Bool) { |
| 1894 | i->setDesktopNotifications(value.toBool()); |
| 1895 | return true; |
| 1896 | } else |
| 1897 | return false; |
| 1898 | } |
| 1899 | case AlertOnNotification: { |
| 1900 | if (value.userType() == QMetaType::Bool) { |
| 1901 | i->setAlertOnNotification(value.toBool()); |
| 1902 | return true; |
| 1903 | } else |
| 1904 | return false; |
| 1905 | } |
| 1906 | case AvatarCircles: { |
| 1907 | if (value.userType() == QMetaType::Bool) { |
| 1908 | i->setAvatarCircles(value.toBool()); |
| 1909 | return true; |
| 1910 | } else |
| 1911 | return false; |
| 1912 | } |
| 1913 | case UseIdenticon: { |
| 1914 | if (value.userType() == QMetaType::Bool) { |
| 1915 | i->setUseIdenticon(value.toBool()); |
| 1916 | return true; |
| 1917 | } else |
| 1918 | return false; |
| 1919 | } |
| 1920 | case OpenImageExternal: { |
| 1921 | if (value.userType() == QMetaType::Bool) { |
| 1922 | i->setOpenImageExternal(value.toBool()); |
| 1923 | return true; |
| 1924 | } else |
| 1925 | return false; |
| 1926 | } |
| 1927 | case OpenVideoExternal: { |
| 1928 | if (value.userType() == QMetaType::Bool) { |
| 1929 | i->setOpenVideoExternal(value.toBool()); |
| 1930 | return true; |
| 1931 | } else |
| 1932 | return false; |
| 1933 | } |
| 1934 | case DecryptSidebar: { |
| 1935 | if (value.userType() == QMetaType::Bool) { |
| 1936 | i->setDecryptSidebar(value.toBool()); |
| 1937 | return true; |
| 1938 | } else |
| 1939 | return false; |
| 1940 | } |
| 1941 | case DecryptNotifications: { |
| 1942 | if (value.userType() == QMetaType::Bool) { |
| 1943 | i->setDecryptNotifications(value.toBool()); |
| 1944 | return true; |
| 1945 | } else |
| 1946 | return false; |
| 1947 | } |
| 1948 | case SpaceNotifications: { |
| 1949 | if (value.userType() == QMetaType::Bool) { |
| 1950 | i->setSpaceNotifications(value.toBool()); |
| 1951 | return true; |
| 1952 | } else |
| 1953 | return false; |
| 1954 | } |
| 1955 | case FancyEffects: { |
| 1956 | if (value.userType() == QMetaType::Bool) { |
| 1957 | i->setFancyEffects(value.toBool()); |
| 1958 | return true; |
| 1959 | } else |
| 1960 | return false; |
| 1961 | } |
| 1962 | case ReducedMotion: { |
| 1963 | if (value.userType() == QMetaType::Bool) { |
| 1964 | i->setReducedMotion(value.toBool()); |
| 1965 | return true; |
| 1966 | } else |
| 1967 | return false; |
| 1968 | } |
| 1969 | case PrivacyScreen: { |
| 1970 | if (value.userType() == QMetaType::Bool) { |
| 1971 | i->setPrivacyScreen(value.toBool()); |
| 1972 | return true; |
| 1973 | } else |
| 1974 | return false; |
| 1975 | } |
| 1976 | case PrivacyScreenTimeout: { |
| 1977 | if (value.canConvert(QMetaType::fromType<int>())) { |
| 1978 | i->setPrivacyScreenTimeout(value.toInt()); |
| 1979 | return true; |
| 1980 | } else |
| 1981 | return false; |
| 1982 | } |
| 1983 | case MobileMode: { |
| 1984 | if (value.userType() == QMetaType::Bool) { |
| 1985 | i->setMobileMode(value.toBool()); |
| 1986 | return true; |
| 1987 | } else |
| 1988 | return false; |
| 1989 | } |
| 1990 | case DisableSwipe: { |
| 1991 | if (value.userType() == QMetaType::Bool) { |
| 1992 | i->setDisableSwipe(value.toBool()); |
| 1993 | return true; |
| 1994 | } else |
| 1995 | return false; |
| 1996 | } |
| 1997 | case FontSize: { |
| 1998 | if (value.canConvert(QMetaType::fromType<double>())) { |
| 1999 | i->setFontSize(value.toDouble()); |
| 2000 | return true; |
| 2001 | } else |
| 2002 | return false; |
| 2003 | } |
| 2004 | case Font: { |
| 2005 | if (value.userType() == QMetaType::Int) { |
| 2006 | // Special handling to grab our injected system font option |
| 2007 | auto v = value.toInt(); |
| 2008 | i->setFontFamily(v == 0 ? QString{} : QFontDatabase::families().at(v - 1)); |
| 2009 | return true; |
| 2010 | } else |
| 2011 | return false; |
| 2012 | } |
| 2013 | case EmojiFont: { |
| 2014 | if (value.userType() == QMetaType::Int) { |
| 2015 | // More special handling for the default font option |
| 2016 | auto v = value.toInt(); |
| 2017 | i->setEmojiFontFamily( |
| 2018 | v <= 0 ? QString() |
| 2019 | : QFontDatabase::families(QFontDatabase::WritingSystem::Symbol).at(v - 1)); |
| 2020 | return true; |
| 2021 | } else |
| 2022 | return false; |
| 2023 | } |
| 2024 | case Ringtone: { |
| 2025 | if (value.userType() == QMetaType::Int) { |
| 2026 | int ringtone = value.toInt(); |
| 2027 | |
| 2028 | // setRingtone is called twice, because updating the list breaks the set value, |
| 2029 | // because it does not exist yet! |
| 2030 | if (ringtone == 2) { |
| 2031 | QString homeFolder = |
| 2032 | QStandardPaths::writableLocation(QStandardPaths::HomeLocation); |
| 2033 | auto filepath = QFileDialog::getOpenFileName( |
| 2034 | nullptr, tr("Select a file"), homeFolder, tr("All Files (*)")); |
| 2035 | if (!filepath.isEmpty()) { |
| 2036 | i->setRingtone(filepath); |
| 2037 | i->setRingtone(filepath); |
| 2038 | } |
| 2039 | } else if (ringtone == 0) { |
| 2040 | i->setRingtone(QStringLiteral("Mute")); |
| 2041 | i->setRingtone(QStringLiteral("Mute")); |
| 2042 | } else if (ringtone == 1) { |
| 2043 | i->setRingtone(QStringLiteral("Default")); |
| 2044 | i->setRingtone(QStringLiteral("Default")); |
| 2045 | } |
| 2046 | return true; |
| 2047 | } |
| 2048 | return false; |
| 2049 | } |
| 2050 | case Microphone: { |
| 2051 | if (value.userType() == QMetaType::Int) { |
| 2052 | i->setMicrophone(data(index, Values).toStringList().at(value.toInt())); |
| 2053 | return true; |
| 2054 | } else |
| 2055 | return false; |
| 2056 | } |
| 2057 | case Camera: { |
| 2058 | if (value.userType() == QMetaType::Int) { |
| 2059 | i->setCamera(data(index, Values).toStringList().at(value.toInt())); |
| 2060 | return true; |
| 2061 | } else |
| 2062 | return false; |
| 2063 | } |
| 2064 | case CameraResolution: { |
| 2065 | if (value.userType() == QMetaType::Int) { |
| 2066 | i->setCameraResolution(data(index, Values).toStringList().at(value.toInt())); |
| 2067 | return true; |
| 2068 | } else |
| 2069 | return false; |
| 2070 | } |
| 2071 | case CameraFrameRate: { |
| 2072 | if (value.userType() == QMetaType::Int) { |
| 2073 | i->setCameraFrameRate(data(index, Values).toStringList().at(value.toInt())); |
| 2074 | return true; |
| 2075 | } else |
| 2076 | return false; |
| 2077 | } |
| 2078 | case UseStunServer: { |
| 2079 | if (value.userType() == QMetaType::Bool) { |
| 2080 | i->setUseStunServer(value.toBool()); |
| 2081 | return true; |
| 2082 | } else |
| 2083 | return false; |
| 2084 | } |
| 2085 | case OnlyShareKeysWithVerifiedUsers: { |
| 2086 | if (value.userType() == QMetaType::Bool) { |
| 2087 | i->setOnlyShareKeysWithVerifiedUsers(value.toBool()); |
| 2088 | return true; |
| 2089 | } else |
| 2090 | return false; |
| 2091 | } |
| 2092 | case ShareKeysWithTrustedUsers: { |
| 2093 | if (value.userType() == QMetaType::Bool) { |
| 2094 | i->setShareKeysWithTrustedUsers(value.toBool()); |
| 2095 | return true; |
| 2096 | } else |
| 2097 | return false; |
| 2098 | } |
| 2099 | case UseOnlineKeyBackup: { |
| 2100 | if (value.userType() == QMetaType::Bool) { |
| 2101 | i->setUseOnlineKeyBackup(value.toBool()); |
| 2102 | return true; |
| 2103 | } else |
| 2104 | return false; |
| 2105 | } |
| 2106 | case ExposeDBusApi: { |
| 2107 | if (value.userType() == QMetaType::Bool) { |
| 2108 | i->setExposeDBusApi(value.toBool()); |
| 2109 | return true; |
| 2110 | } else |
| 2111 | return false; |
| 2112 | } |
| 2113 | case UpdateSpaceVias: { |
| 2114 | if (value.userType() == QMetaType::Bool) { |
| 2115 | i->setUpdateSpaceVias(value.toBool()); |
| 2116 | return true; |
| 2117 | } else |
| 2118 | return false; |
| 2119 | } |
| 2120 | case ExpireEvents: { |
| 2121 | if (value.userType() == QMetaType::Bool) { |
| 2122 | i->setExpireEvents(value.toBool()); |
| 2123 | return true; |
| 2124 | } else |
| 2125 | return false; |
| 2126 | } |
| 2127 | } |
| 2128 | } |
| 2129 | return false; |
| 2130 | } |
| 2131 | |
| 2132 | void |
| 2133 | UserSettingsModel::importSessionKeys() |
| 2134 | { |
| 2135 | const QString homeFolder = QStandardPaths::writableLocation(QStandardPaths::HomeLocation); |
| 2136 | const QString fileName = QFileDialog::getOpenFileName( |
| 2137 | nullptr, tr("Open Sessions File"), homeFolder, QLatin1String("")); |
| 2138 | |
| 2139 | QFile file(fileName); |
| 2140 | if (!file.open(QIODevice::ReadOnly)) { |
| 2141 | QMessageBox::warning(nullptr, tr("Error"), file.errorString()); |
| 2142 | return; |
| 2143 | } |
| 2144 | |
| 2145 | auto bin = file.peek(file.size()); |
| 2146 | auto payload = std::string(bin.data(), bin.size()); |
| 2147 | |
| 2148 | bool ok; |
| 2149 | auto password = QInputDialog::getText(nullptr, |
| 2150 | tr("File Password"), |
| 2151 | tr("Enter the passphrase to decrypt the file:"), |
| 2152 | QLineEdit::Password, |
| 2153 | QLatin1String(""), |
| 2154 | &ok); |
| 2155 | if (!ok) |
| 2156 | return; |
| 2157 | |
| 2158 | if (password.isEmpty()) { |
| 2159 | QMessageBox::warning(nullptr, tr("Error"), tr("The password cannot be empty")); |
| 2160 | return; |
| 2161 | } |
| 2162 | |
| 2163 | try { |
| 2164 | auto sessions = mtx::crypto::decrypt_exported_sessions(payload, password.toStdString()); |
| 2165 | cache::importSessionKeys(std::move(sessions)); |
| 2166 | } catch (const std::exception &e) { |
| 2167 | QMessageBox::warning(nullptr, tr("Error"), e.what()); |
| 2168 | } |
| 2169 | } |
| 2170 | void |
| 2171 | UserSettingsModel::exportSessionKeys() |
| 2172 | { |
| 2173 | // Open password dialog. |
| 2174 | bool ok; |
| 2175 | auto password = QInputDialog::getText(nullptr, |
| 2176 | tr("File Password"), |
| 2177 | tr("Enter passphrase to encrypt your session keys:"), |
| 2178 | QLineEdit::Password, |
| 2179 | QLatin1String(""), |
| 2180 | &ok); |
| 2181 | if (!ok) |
| 2182 | return; |
| 2183 | |
| 2184 | if (password.isEmpty()) { |
| 2185 | QMessageBox::warning(nullptr, tr("Error"), tr("The password cannot be empty")); |
| 2186 | return; |
| 2187 | } |
| 2188 | |
| 2189 | auto repeatedPassword = QInputDialog::getText(nullptr, |
| 2190 | tr("Repeat File Password"), |
| 2191 | tr("Repeat the passphrase:"), |
| 2192 | QLineEdit::Password, |
| 2193 | QLatin1String(""), |
| 2194 | &ok); |
| 2195 | if (!ok) |
| 2196 | return; |
| 2197 | |
| 2198 | if (password != repeatedPassword) { |
| 2199 | QMessageBox::warning(nullptr, tr("Error"), tr("Passwords don't match")); |
| 2200 | return; |
| 2201 | } |
| 2202 | |
| 2203 | // Open file dialog to save the file. |
| 2204 | const QString homeFolder = QStandardPaths::writableLocation(QStandardPaths::HomeLocation); |
| 2205 | const QString fileName = QFileDialog::getSaveFileName( |
| 2206 | nullptr, tr("File to save the exported session keys"), homeFolder); |
| 2207 | |
| 2208 | QFile file(fileName); |
| 2209 | if (!file.open(QIODevice::WriteOnly | QIODevice::Text)) { |
| 2210 | QMessageBox::warning(nullptr, tr("Error"), file.errorString()); |
| 2211 | return; |
| 2212 | } |
| 2213 | |
| 2214 | // Export sessions & save to file. |
| 2215 | try { |
| 2216 | auto encrypted_blob = mtx::crypto::encrypt_exported_sessions(cache::exportSessionKeys(), |
| 2217 | password.toStdString()); |
| 2218 | |
| 2219 | QString b64 = QString::fromStdString(mtx::crypto::bin2base64(encrypted_blob)); |
| 2220 | |
| 2221 | QString prefix(QStringLiteral("-----BEGIN MEGOLM SESSION DATA-----")); |
| 2222 | QString suffix(QStringLiteral("-----END MEGOLM SESSION DATA-----")); |
| 2223 | QString newline(QStringLiteral("\n")); |
| 2224 | QTextStream out(&file); |
| 2225 | out << prefix << newline << b64 << newline << suffix << newline; |
| 2226 | file.close(); |
| 2227 | } catch (const std::exception &e) { |
| 2228 | QMessageBox::warning(nullptr, tr("Error"), e.what()); |
| 2229 | } |
| 2230 | } |
| 2231 | void |
| 2232 | UserSettingsModel::requestCrossSigningSecrets() |
| 2233 | { |
| 2234 | olm::request_cross_signing_keys(); |
| 2235 | } |
| 2236 | void |
| 2237 | UserSettingsModel::downloadCrossSigningSecrets() |
| 2238 | { |
| 2239 | olm::download_cross_signing_keys(); |
| 2240 | } |
| 2241 | |
| 2242 | UserSettingsModel::UserSettingsModel(QObject *p) |
| 2243 | : QAbstractListModel(p) |
| 2244 | { |
| 2245 | auto s = UserSettings::instance(); |
| 2246 | connect(s.get(), &UserSettings::themeChanged, this, [this]() { |
| 2247 | emit dataChanged(index(Theme), index(Theme), {Value}); |
| 2248 | }); |
| 2249 | connect(s.get(), &UserSettings::mobileModeChanged, this, [this]() { |
| 2250 | emit dataChanged(index(MobileMode), index(MobileMode), {Value}); |
| 2251 | }); |
| 2252 | connect(s.get(), &UserSettings::disableSwipeChanged, this, [this]() { |
| 2253 | emit dataChanged(index(DisableSwipe), index(DisableSwipe), {Value}); |
| 2254 | }); |
| 2255 | |
| 2256 | connect(s.get(), &UserSettings::fontChanged, this, [this]() { |
| 2257 | emit dataChanged(index(Font), index(Font), {Value}); |
| 2258 | }); |
| 2259 | connect(s.get(), &UserSettings::fontSizeChanged, this, [this]() { |
| 2260 | emit dataChanged(index(FontSize), index(FontSize), {Value}); |
| 2261 | }); |
| 2262 | connect(s.get(), &UserSettings::emojiFontChanged, this, [this]() { |
| 2263 | emit dataChanged(index(EmojiFont), index(EmojiFont), {Value}); |
| 2264 | }); |
| 2265 | connect(s.get(), &UserSettings::avatarCirclesChanged, this, [this]() { |
| 2266 | emit dataChanged(index(AvatarCircles), index(AvatarCircles), {Value}); |
| 2267 | }); |
| 2268 | connect(s.get(), &UserSettings::useIdenticonChanged, this, [this]() { |
| 2269 | emit dataChanged(index(UseIdenticon), index(UseIdenticon), {Value}); |
| 2270 | }); |
| 2271 | connect(s.get(), &UserSettings::openImageExternalChanged, this, [this]() { |
| 2272 | emit dataChanged(index(OpenImageExternal), index(OpenImageExternal), {Value}); |
| 2273 | }); |
| 2274 | connect(s.get(), &UserSettings::openVideoExternalChanged, this, [this]() { |
| 2275 | emit dataChanged(index(OpenVideoExternal), index(OpenVideoExternal), {Value}); |
| 2276 | }); |
| 2277 | connect(s.get(), &UserSettings::privacyScreenChanged, this, [this]() { |
| 2278 | emit dataChanged(index(PrivacyScreen), index(PrivacyScreen), {Value}); |
| 2279 | emit dataChanged(index(PrivacyScreenTimeout), index(PrivacyScreenTimeout), {Enabled}); |
| 2280 | }); |
| 2281 | connect(s.get(), &UserSettings::privacyScreenTimeoutChanged, this, [this]() { |
| 2282 | emit dataChanged(index(PrivacyScreenTimeout), index(PrivacyScreenTimeout), {Value}); |
| 2283 | }); |
| 2284 | |
| 2285 | connect(s.get(), &UserSettings::timelineMaxWidthChanged, this, [this]() { |
| 2286 | emit dataChanged(index(TimelineMaxWidth), index(TimelineMaxWidth), {Value}); |
| 2287 | }); |
| 2288 | connect(s.get(), &UserSettings::messageHoverHighlightChanged, this, [this]() { |
| 2289 | emit dataChanged(index(MessageHoverHighlight), index(MessageHoverHighlight), {Value}); |
| 2290 | }); |
| 2291 | connect(s.get(), &UserSettings::enlargeEmojiOnlyMessagesChanged, this, [this]() { |
| 2292 | emit dataChanged(index(EnlargeEmojiOnlyMessages), index(EnlargeEmojiOnlyMessages), {Value}); |
| 2293 | }); |
| 2294 | connect(s.get(), &UserSettings::animateImagesOnHoverChanged, this, [this]() { |
| 2295 | emit dataChanged(index(AnimateImagesOnHover), index(AnimateImagesOnHover), {Value}); |
| 2296 | }); |
| 2297 | connect(s.get(), &UserSettings::showImageChanged, this, [this]() { |
| 2298 | emit dataChanged(index(ShowImage), index(ShowImage), {Value}); |
| 2299 | }); |
| 2300 | connect(s.get(), &UserSettings::typingNotificationsChanged, this, [this]() { |
| 2301 | emit dataChanged(index(TypingNotifications), index(TypingNotifications), {Value}); |
| 2302 | }); |
| 2303 | connect(s.get(), &UserSettings::readReceiptsChanged, this, [this]() { |
| 2304 | emit dataChanged(index(ReadReceipts), index(ReadReceipts), {Value}); |
| 2305 | }); |
| 2306 | connect(s.get(), &UserSettings::buttonInTimelineChanged, this, [this]() { |
| 2307 | emit dataChanged(index(ButtonsInTimeline), index(ButtonsInTimeline), {Value}); |
| 2308 | }); |
| 2309 | connect(s.get(), &UserSettings::markdownChanged, this, [this]() { |
| 2310 | emit dataChanged(index(Markdown), index(Markdown), {Value}); |
| 2311 | }); |
| 2312 | connect(s.get(), &UserSettings::invertEnterKeyChanged, this, [this]() { |
| 2313 | emit dataChanged(index(InvertEnterKey), index(InvertEnterKey), {Value}); |
| 2314 | }); |
| 2315 | connect(s.get(), &UserSettings::bubblesChanged, this, [this]() { |
| 2316 | emit dataChanged(index(Bubbles), index(Bubbles), {Value}); |
| 2317 | }); |
| 2318 | connect(s.get(), &UserSettings::smallAvatarsChanged, this, [this]() { |
| 2319 | emit dataChanged(index(SmallAvatars), index(SmallAvatars), {Value}); |
| 2320 | }); |
| 2321 | connect(s.get(), &UserSettings::groupViewStateChanged, this, [this]() { |
| 2322 | emit dataChanged(index(GroupView), index(GroupView), {Value}); |
| 2323 | }); |
| 2324 | connect(s.get(), &UserSettings::scrollbarsInRoomlistChanged, this, [this]() { |
| 2325 | emit dataChanged(index(ScrollbarsInRoomlist), index(ScrollbarsInRoomlist), {Value}); |
| 2326 | }); |
| 2327 | connect(s.get(), &UserSettings::roomSortingChangedImportance, this, [this]() { |
| 2328 | emit dataChanged(index(SortByImportance), index(SortByImportance), {Value}); |
| 2329 | }); |
| 2330 | connect(s.get(), &UserSettings::roomSortingChangedAlphabetical, this, [this]() { |
| 2331 | emit dataChanged(index(SortByAlphabet), index(SortByAlphabet), {Value}); |
| 2332 | }); |
| 2333 | connect(s.get(), &UserSettings::decryptSidebarChanged, this, [this]() { |
| 2334 | emit dataChanged(index(DecryptSidebar), index(DecryptSidebar), {Value}); |
| 2335 | }); |
| 2336 | connect(s.get(), &UserSettings::decryptNotificationsChanged, this, [this]() { |
| 2337 | emit dataChanged(index(DecryptNotifications), index(DecryptNotifications), {Value}); |
| 2338 | }); |
| 2339 | connect(s.get(), &UserSettings::spaceNotificationsChanged, this, [this]() { |
| 2340 | emit dataChanged(index(SpaceNotifications), index(SpaceNotifications), {Value}); |
| 2341 | }); |
| 2342 | connect(s.get(), &UserSettings::fancyEffectsChanged, this, [this]() { |
| 2343 | emit dataChanged(index(FancyEffects), index(FancyEffects), {Value}); |
| 2344 | }); |
| 2345 | connect(s.get(), &UserSettings::reducedMotionChanged, this, [this]() { |
| 2346 | emit dataChanged(index(ReducedMotion), index(ReducedMotion), {Value}); |
| 2347 | }); |
| 2348 | connect(s.get(), &UserSettings::trayChanged, this, [this]() { |
| 2349 | emit dataChanged(index(Tray), index(Tray), {Value}); |
| 2350 | emit dataChanged(index(StartInTray), index(StartInTray), {Enabled}); |
| 2351 | }); |
| 2352 | connect(s.get(), &UserSettings::startInTrayChanged, this, [this]() { |
| 2353 | emit dataChanged(index(StartInTray), index(StartInTray), {Value}); |
| 2354 | }); |
| 2355 | |
| 2356 | connect(s.get(), &UserSettings::desktopNotificationsChanged, this, [this]() { |
| 2357 | emit dataChanged(index(DesktopNotifications), index(DesktopNotifications), {Value}); |
| 2358 | }); |
| 2359 | connect(s.get(), &UserSettings::alertOnNotificationChanged, this, [this]() { |
| 2360 | emit dataChanged(index(AlertOnNotification), index(AlertOnNotification), {Value}); |
| 2361 | }); |
| 2362 | |
| 2363 | connect(s.get(), &UserSettings::useStunServerChanged, this, [this]() { |
| 2364 | emit dataChanged(index(UseStunServer), index(UseStunServer), {Value}); |
| 2365 | }); |
| 2366 | connect(s.get(), &UserSettings::microphoneChanged, this, [this]() { |
| 2367 | emit dataChanged(index(Microphone), index(Microphone), {Value, Values}); |
| 2368 | }); |
| 2369 | connect(s.get(), &UserSettings::cameraChanged, this, [this]() { |
| 2370 | emit dataChanged(index(Camera), index(Camera), {Value, Values}); |
| 2371 | }); |
| 2372 | connect(s.get(), &UserSettings::cameraResolutionChanged, this, [this]() { |
| 2373 | emit dataChanged(index(CameraResolution), index(CameraResolution), {Value, Values}); |
| 2374 | }); |
| 2375 | connect(s.get(), &UserSettings::cameraFrameRateChanged, this, [this]() { |
| 2376 | emit dataChanged(index(CameraFrameRate), index(CameraFrameRate), {Value, Values}); |
| 2377 | }); |
| 2378 | connect(s.get(), &UserSettings::ringtoneChanged, this, [this]() { |
| 2379 | emit dataChanged(index(Ringtone), index(Ringtone), {Values, Value}); |
| 2380 | }); |
| 2381 | |
| 2382 | connect(s.get(), &UserSettings::onlyShareKeysWithVerifiedUsersChanged, this, [this]() { |
| 2383 | emit dataChanged( |
| 2384 | index(OnlyShareKeysWithVerifiedUsers), index(OnlyShareKeysWithVerifiedUsers), {Value}); |
| 2385 | }); |
| 2386 | connect(s.get(), &UserSettings::shareKeysWithTrustedUsersChanged, this, [this]() { |
| 2387 | emit dataChanged( |
| 2388 | index(ShareKeysWithTrustedUsers), index(ShareKeysWithTrustedUsers), {Value}); |
| 2389 | }); |
| 2390 | connect(s.get(), &UserSettings::useOnlineKeyBackupChanged, this, [this]() { |
| 2391 | emit dataChanged(index(UseOnlineKeyBackup), index(UseOnlineKeyBackup), {Value}); |
| 2392 | }); |
| 2393 | connect(MainWindow::instance(), &MainWindow::secretsChanged, this, [this]() { |
| 2394 | emit dataChanged(index(OnlineBackupKey), index(MasterKey), {Value, Good}); |
| 2395 | }); |
| 2396 | connect(s.get(), &UserSettings::exposeDBusApiChanged, this, [this] { |
| 2397 | emit dataChanged(index(ExposeDBusApi), index(ExposeDBusApi), {Value}); |
| 2398 | }); |
| 2399 | connect(s.get(), &UserSettings::updateSpaceViasChanged, this, [this] { |
| 2400 | emit dataChanged(index(UpdateSpaceVias), index(UpdateSpaceVias), {Value}); |
| 2401 | }); |
| 2402 | connect(s.get(), &UserSettings::expireEventsChanged, this, [this] { |
| 2403 | emit dataChanged(index(ExpireEvents), index(ExpireEvents), {Value}); |
| 2404 | }); |
| 2405 | } |
| 2406 | |
| 2407 | #include "moc_UserSettingsPage.cpp" |