| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
#pragma once |
| 6 |
|
| 7 |
#include <QAbstractListModel> |
| 8 |
#include <QProcessEnvironment> |
| 9 |
#include <QQmlEngine> |
| 10 |
#include <QSettings> |
| 11 |
#include <QSharedPointer> |
| 12 |
|
| 13 |
#include <optional> |
| 14 |
|
| 15 |
class UserSettings final : public QObject |
| 16 |
{ |
| 17 |
Q_OBJECT |
| 18 |
QML_NAMED_ELEMENT(Settings) |
| 19 |
QML_SINGLETON |
| 20 |
|
| 21 |
Q_PROPERTY(QString theme READ theme WRITE setTheme NOTIFY themeChanged) |
| 22 |
Q_PROPERTY(bool messageHoverHighlight READ messageHoverHighlight WRITE setMessageHoverHighlight |
| 23 |
NOTIFY messageHoverHighlightChanged) |
| 24 |
Q_PROPERTY(bool enlargeEmojiOnlyMessages READ enlargeEmojiOnlyMessages WRITE |
| 25 |
setEnlargeEmojiOnlyMessages NOTIFY enlargeEmojiOnlyMessagesChanged) |
| 26 |
Q_PROPERTY(bool tray READ tray WRITE setTray NOTIFY trayChanged) |
| 27 |
Q_PROPERTY(bool startInTray READ startInTray WRITE setStartInTray NOTIFY startInTrayChanged) |
| 28 |
Q_PROPERTY(bool groupView READ groupView WRITE setGroupView NOTIFY groupViewStateChanged) |
| 29 |
Q_PROPERTY(bool scrollbarsInRoomlist READ scrollbarsInRoomlist WRITE setScrollbarsInRoomlist |
| 30 |
NOTIFY scrollbarsInRoomlistChanged) |
| 31 |
Q_PROPERTY(bool markdown READ markdown WRITE setMarkdown NOTIFY markdownChanged) |
| 32 |
Q_PROPERTY( |
| 33 |
bool invertEnterKey READ invertEnterKey WRITE setInvertEnterKey NOTIFY invertEnterKeyChanged) |
| 34 |
Q_PROPERTY(bool bubbles READ bubbles WRITE setBubbles NOTIFY bubblesChanged) |
| 35 |
Q_PROPERTY(bool smallAvatars READ smallAvatars WRITE setSmallAvatars NOTIFY smallAvatarsChanged) |
| 36 |
Q_PROPERTY(bool animateImagesOnHover READ animateImagesOnHover WRITE setAnimateImagesOnHover |
| 37 |
NOTIFY animateImagesOnHoverChanged) |
| 38 |
Q_PROPERTY(bool typingNotifications READ typingNotifications WRITE setTypingNotifications NOTIFY |
| 39 |
typingNotificationsChanged) |
| 40 |
Q_PROPERTY(bool sortByImportance READ sortByImportance WRITE setSortByImportance NOTIFY |
| 41 |
roomSortingChangedImportance) |
| 42 |
Q_PROPERTY(bool sortByAlphabet READ sortByAlphabet WRITE setSortByAlphabet NOTIFY |
| 43 |
roomSortingChangedAlphabetical) |
| 44 |
Q_PROPERTY(bool buttonsInTimeline READ buttonsInTimeline WRITE setButtonsInTimeline NOTIFY |
| 45 |
buttonInTimelineChanged) |
| 46 |
Q_PROPERTY(bool readReceipts READ readReceipts WRITE setReadReceipts NOTIFY readReceiptsChanged) |
| 47 |
Q_PROPERTY(bool desktopNotifications READ hasDesktopNotifications WRITE setDesktopNotifications |
| 48 |
NOTIFY desktopNotificationsChanged) |
| 49 |
Q_PROPERTY(bool alertOnNotification READ hasAlertOnNotification WRITE setAlertOnNotification |
| 50 |
NOTIFY alertOnNotificationChanged) |
| 51 |
Q_PROPERTY( |
| 52 |
bool avatarCircles READ avatarCircles WRITE setAvatarCircles NOTIFY avatarCirclesChanged) |
| 53 |
Q_PROPERTY( |
| 54 |
bool decryptSidebar READ decryptSidebar WRITE setDecryptSidebar NOTIFY decryptSidebarChanged) |
| 55 |
Q_PROPERTY(bool decryptNotifications READ decryptNotifications WRITE setDecryptNotifications |
| 56 |
NOTIFY decryptNotificationsChanged) |
| 57 |
Q_PROPERTY(bool spaceNotifications READ spaceNotifications WRITE setSpaceNotifications NOTIFY |
| 58 |
spaceNotificationsChanged) |
| 59 |
Q_PROPERTY(bool fancyEffects READ fancyEffects WRITE setFancyEffects NOTIFY fancyEffectsChanged) |
| 60 |
Q_PROPERTY( |
| 61 |
bool reducedMotion READ reducedMotion WRITE setReducedMotion NOTIFY reducedMotionChanged) |
| 62 |
Q_PROPERTY( |
| 63 |
bool privacyScreen READ privacyScreen WRITE setPrivacyScreen NOTIFY privacyScreenChanged) |
| 64 |
Q_PROPERTY(int privacyScreenTimeout READ privacyScreenTimeout WRITE setPrivacyScreenTimeout |
| 65 |
NOTIFY privacyScreenTimeoutChanged) |
| 66 |
Q_PROPERTY(int timelineMaxWidth READ timelineMaxWidth WRITE setTimelineMaxWidth NOTIFY |
| 67 |
timelineMaxWidthChanged) |
| 68 |
Q_PROPERTY( |
| 69 |
int roomListWidth READ roomListWidth WRITE setRoomListWidth NOTIFY roomListWidthChanged) |
| 70 |
Q_PROPERTY(int communityListWidth READ communityListWidth WRITE setCommunityListWidth NOTIFY |
| 71 |
communityListWidthChanged) |
| 72 |
Q_PROPERTY(bool mobileMode READ mobileMode WRITE setMobileMode NOTIFY mobileModeChanged) |
| 73 |
Q_PROPERTY(bool disableSwipe READ disableSwipe WRITE setDisableSwipe NOTIFY disableSwipeChanged) |
| 74 |
Q_PROPERTY(double fontSize READ fontSize WRITE setFontSize NOTIFY fontSizeChanged) |
| 75 |
Q_PROPERTY(QString font READ font WRITE setFontFamily NOTIFY fontChanged) |
| 76 |
Q_PROPERTY(QString emojiFont READ emojiFont WRITE setEmojiFontFamily NOTIFY emojiFontChanged) |
| 77 |
Q_PROPERTY(Presence presence READ presence WRITE setPresence NOTIFY presenceChanged) |
| 78 |
Q_PROPERTY(ShowImage showImage READ showImage WRITE setShowImage NOTIFY showImageChanged) |
| 79 |
Q_PROPERTY(QString ringtone READ ringtone WRITE setRingtone NOTIFY ringtoneChanged) |
| 80 |
Q_PROPERTY(QString microphone READ microphone WRITE setMicrophone NOTIFY microphoneChanged) |
| 81 |
Q_PROPERTY(QString camera READ camera WRITE setCamera NOTIFY cameraChanged) |
| 82 |
Q_PROPERTY(QString cameraResolution READ cameraResolution WRITE setCameraResolution NOTIFY |
| 83 |
cameraResolutionChanged) |
| 84 |
Q_PROPERTY(QString cameraFrameRate READ cameraFrameRate WRITE setCameraFrameRate NOTIFY |
| 85 |
cameraFrameRateChanged) |
| 86 |
Q_PROPERTY(int screenShareFrameRate READ screenShareFrameRate WRITE setScreenShareFrameRate |
| 87 |
NOTIFY screenShareFrameRateChanged) |
| 88 |
Q_PROPERTY( |
| 89 |
bool screenSharePiP READ screenSharePiP WRITE setScreenSharePiP NOTIFY screenSharePiPChanged) |
| 90 |
Q_PROPERTY(bool screenShareRemoteVideo READ screenShareRemoteVideo WRITE |
| 91 |
setScreenShareRemoteVideo NOTIFY screenShareRemoteVideoChanged) |
| 92 |
Q_PROPERTY(bool screenShareHideCursor READ screenShareHideCursor WRITE setScreenShareHideCursor |
| 93 |
NOTIFY screenShareHideCursorChanged) |
| 94 |
Q_PROPERTY( |
| 95 |
bool useStunServer READ useStunServer WRITE setUseStunServer NOTIFY useStunServerChanged) |
| 96 |
Q_PROPERTY(bool onlyShareKeysWithVerifiedUsers READ onlyShareKeysWithVerifiedUsers WRITE |
| 97 |
setOnlyShareKeysWithVerifiedUsers NOTIFY onlyShareKeysWithVerifiedUsersChanged) |
| 98 |
Q_PROPERTY(bool shareKeysWithTrustedUsers READ shareKeysWithTrustedUsers WRITE |
| 99 |
setShareKeysWithTrustedUsers NOTIFY shareKeysWithTrustedUsersChanged) |
| 100 |
Q_PROPERTY(bool useOnlineKeyBackup READ useOnlineKeyBackup WRITE setUseOnlineKeyBackup NOTIFY |
| 101 |
useOnlineKeyBackupChanged) |
| 102 |
Q_PROPERTY(QString profile READ profile WRITE setProfile NOTIFY profileChanged) |
| 103 |
Q_PROPERTY(QString userId READ userId WRITE setUserId NOTIFY userIdChanged) |
| 104 |
Q_PROPERTY(QString accessToken READ accessToken WRITE setAccessToken NOTIFY accessTokenChanged) |
| 105 |
Q_PROPERTY(QString deviceId READ deviceId WRITE setDeviceId NOTIFY deviceIdChanged) |
| 106 |
Q_PROPERTY(QString homeserver READ homeserver WRITE setHomeserver NOTIFY homeserverChanged) |
| 107 |
Q_PROPERTY(bool disableCertificateValidation READ disableCertificateValidation WRITE |
| 108 |
setDisableCertificateValidation NOTIFY disableCertificateValidationChanged) |
| 109 |
Q_PROPERTY(bool useIdenticon READ useIdenticon WRITE setUseIdenticon NOTIFY useIdenticonChanged) |
| 110 |
Q_PROPERTY(bool openImageExternal READ openImageExternal WRITE setOpenImageExternal NOTIFY |
| 111 |
openImageExternalChanged) |
| 112 |
Q_PROPERTY(bool openVideoExternal READ openVideoExternal WRITE setOpenVideoExternal NOTIFY |
| 113 |
openVideoExternalChanged) |
| 114 |
|
| 115 |
Q_PROPERTY(QStringList hiddenPins READ hiddenPins WRITE setHiddenPins NOTIFY hiddenPinsChanged) |
| 116 |
Q_PROPERTY(QStringList recentReactions READ recentReactions WRITE setRecentReactions NOTIFY |
| 117 |
recentReactionsChanged) |
| 118 |
Q_PROPERTY(QStringList hiddenWidgets READ hiddenWidgets WRITE setHiddenWidgets NOTIFY |
| 119 |
hiddenWidgetsChanged) |
| 120 |
Q_PROPERTY( |
| 121 |
bool exposeDBusApi READ exposeDBusApi WRITE setExposeDBusApi NOTIFY exposeDBusApiChanged) |
| 122 |
Q_PROPERTY(bool updateSpaceVias READ updateSpaceVias WRITE setUpdateSpaceVias NOTIFY |
| 123 |
updateSpaceViasChanged) |
| 124 |
Q_PROPERTY(bool expireEvents READ expireEvents WRITE setExpireEvents NOTIFY expireEventsChanged) |
| 125 |
|
| 126 |
UserSettings(); |
| 127 |
|
| 128 |
public: |
| 129 |
static QSharedPointer<UserSettings> instance(); |
| 130 |
static void initialize(std::optional<QString> profile); |
| 131 |
static UserSettings *create(QQmlEngine *qmlEngine, QJSEngine *) |
| 132 |
{ |
| 133 |
|
| 134 |
Q_ASSERT(instance()); |
| 135 |
|
| 136 |
|
| 137 |
Q_ASSERT(qmlEngine->thread() == instance()->thread()); |
| 138 |
|
| 139 |
|
| 140 |
static QJSEngine *s_engine = nullptr; |
| 141 |
if (s_engine) |
| 142 |
Q_ASSERT(qmlEngine == s_engine); |
| 143 |
else |
| 144 |
s_engine = qmlEngine; |
| 145 |
|
| 146 |
QJSEngine::setObjectOwnership(instance().get(), QJSEngine::CppOwnership); |
| 147 |
return instance().get(); |
| 148 |
} |
| 149 |
|
| 150 |
QSettings *qsettings() { return &settings; } |
| 151 |
|
| 152 |
enum class Presence |
| 153 |
{ |
| 154 |
AutomaticPresence, |
| 155 |
Online, |
| 156 |
Unavailable, |
| 157 |
Offline, |
| 158 |
}; |
| 159 |
Q_ENUM(Presence) |
| 160 |
|
| 161 |
enum class ShowImage |
| 162 |
{ |
| 163 |
Always, |
| 164 |
OnlyPrivate, |
| 165 |
Never, |
| 166 |
}; |
| 167 |
Q_ENUM(ShowImage) |
| 168 |
|
| 169 |
void save(); |
| 170 |
void load(std::optional<QString> profile); |
| 171 |
void applyTheme(); |
| 172 |
void setTheme(QString theme); |
| 173 |
void setMessageHoverHighlight(bool state); |
| 174 |
void setEnlargeEmojiOnlyMessages(bool state); |
| 175 |
void setTray(bool state); |
| 176 |
void setStartInTray(bool state); |
| 177 |
void setMobileMode(bool mode); |
| 178 |
void setDisableSwipe(bool mode); |
| 179 |
void setFontSize(double size); |
| 180 |
void setFontFamily(QString family); |
| 181 |
void setEmojiFontFamily(QString family); |
| 182 |
void setGroupView(bool state); |
| 183 |
void setScrollbarsInRoomlist(bool state); |
| 184 |
void setMarkdown(bool state); |
| 185 |
void setInvertEnterKey(bool state); |
| 186 |
void setBubbles(bool state); |
| 187 |
void setSmallAvatars(bool state); |
| 188 |
void setAnimateImagesOnHover(bool state); |
| 189 |
void setReadReceipts(bool state); |
| 190 |
void setTypingNotifications(bool state); |
| 191 |
void setSortByImportance(bool state); |
| 192 |
void setSortByAlphabet(bool state); |
| 193 |
void setButtonsInTimeline(bool state); |
| 194 |
void setTimelineMaxWidth(int state); |
| 195 |
void setCommunityListWidth(int state); |
| 196 |
void setRoomListWidth(int state); |
| 197 |
void setDesktopNotifications(bool state); |
| 198 |
void setAlertOnNotification(bool state); |
| 199 |
void setAvatarCircles(bool state); |
| 200 |
void setDecryptSidebar(bool state); |
| 201 |
void setDecryptNotifications(bool state); |
| 202 |
void setSpaceNotifications(bool state); |
| 203 |
void setFancyEffects(bool state); |
| 204 |
void setReducedMotion(bool state); |
| 205 |
void setPrivacyScreen(bool state); |
| 206 |
void setPrivacyScreenTimeout(int state); |
| 207 |
void setPresence(Presence state); |
| 208 |
void setShowImage(ShowImage state); |
| 209 |
void setRingtone(QString ringtone); |
| 210 |
void setMicrophone(QString microphone); |
| 211 |
void setCamera(QString camera); |
| 212 |
void setCameraResolution(QString resolution); |
| 213 |
void setCameraFrameRate(QString frameRate); |
| 214 |
void setScreenShareFrameRate(int frameRate); |
| 215 |
void setScreenSharePiP(bool state); |
| 216 |
void setScreenShareRemoteVideo(bool state); |
| 217 |
void setScreenShareHideCursor(bool state); |
| 218 |
void setUseStunServer(bool state); |
| 219 |
void setOnlyShareKeysWithVerifiedUsers(bool state); |
| 220 |
void setShareKeysWithTrustedUsers(bool state); |
| 221 |
void setUseOnlineKeyBackup(bool state); |
| 222 |
void setProfile(QString profile); |
| 223 |
void setUserId(QString userId); |
| 224 |
void setAccessToken(QString accessToken); |
| 225 |
void setDeviceId(QString deviceId); |
| 226 |
void setCurrentTagId(QString currentTagId); |
| 227 |
void setHomeserver(QString homeserver); |
| 228 |
void setDisableCertificateValidation(bool disabled); |
| 229 |
void setHiddenTags(const QStringList &hiddenTags); |
| 230 |
void setMutedTags(const QStringList &mutedTags); |
| 231 |
void setHiddenPins(const QStringList &hiddenTags); |
| 232 |
void setHiddenWidgets(const QStringList &hiddenTags); |
| 233 |
void setRecentReactions(QStringList recent); |
| 234 |
void setUseIdenticon(bool state); |
| 235 |
void setOpenImageExternal(bool state); |
| 236 |
void setOpenVideoExternal(bool state); |
| 237 |
void setCollapsedSpaces(QList<QStringList> spaces); |
| 238 |
void setExposeDBusApi(bool state); |
| 239 |
void setUpdateSpaceVias(bool state); |
| 240 |
void setExpireEvents(bool state); |
| 241 |
|
| 242 |
QString theme() const { return !theme_.isEmpty() ? theme_ : defaultTheme_; } |
| 243 |
bool messageHoverHighlight() const { return messageHoverHighlight_; } |
| 244 |
bool enlargeEmojiOnlyMessages() const { return enlargeEmojiOnlyMessages_; } |
| 245 |
bool tray() const { return tray_; } |
| 246 |
bool startInTray() const { return startInTray_; } |
| 247 |
bool groupView() const { return groupView_; } |
| 248 |
bool scrollbarsInRoomlist() const { return scrollbarsInRoomlist_; } |
| 249 |
bool avatarCircles() const { return avatarCircles_; } |
| 250 |
bool decryptSidebar() const { return decryptSidebar_; } |
| 251 |
bool decryptNotifications() const { return decryptNotifications_; } |
| 252 |
bool spaceNotifications() const { return spaceNotifications_; } |
| 253 |
bool fancyEffects() const { return fancyEffects_; } |
| 254 |
bool reducedMotion() const { return reducedMotion_; } |
| 255 |
bool privacyScreen() const { return privacyScreen_; } |
| 256 |
int privacyScreenTimeout() const { return privacyScreenTimeout_; } |
| 257 |
bool markdown() const { return markdown_; } |
| 258 |
bool invertEnterKey() const { return invertEnterKey_; } |
| 259 |
bool bubbles() const { return bubbles_; } |
| 260 |
bool smallAvatars() const { return smallAvatars_; } |
| 261 |
bool animateImagesOnHover() const { return animateImagesOnHover_; } |
| 262 |
bool typingNotifications() const { return typingNotifications_; } |
| 263 |
bool sortByImportance() const { return sortByImportance_; } |
| 264 |
bool sortByAlphabet() const { return sortByAlphabet_; } |
| 265 |
bool buttonsInTimeline() const { return buttonsInTimeline_; } |
| 266 |
bool mobileMode() const { return mobileMode_; } |
| 267 |
bool disableSwipe() const { return disableSwipe_; } |
| 268 |
bool readReceipts() const { return readReceipts_; } |
| 269 |
bool hasDesktopNotifications() const { return hasDesktopNotifications_; } |
| 270 |
bool hasAlertOnNotification() const { return hasAlertOnNotification_; } |
| 271 |
bool hasNotifications() const { return hasDesktopNotifications() || hasAlertOnNotification(); } |
| 272 |
int timelineMaxWidth() const { return timelineMaxWidth_; } |
| 273 |
int communityListWidth() const { return communityListWidth_; } |
| 274 |
int roomListWidth() const { return roomListWidth_; } |
| 275 |
double fontSize() const { return baseFontSize_; } |
| 276 |
QString font() const { return font_; } |
| 277 |
QString emojiFont() const |
| 278 |
{ |
| 279 |
if (emojiFont_ == QLatin1String("Default")) { |
| 280 |
return tr("Default"); |
| 281 |
} |
| 282 |
|
| 283 |
return emojiFont_; |
| 284 |
} |
| 285 |
Presence presence() const { return presence_; } |
| 286 |
ShowImage showImage() const { return showImage_; } |
| 287 |
QString ringtone() const { return ringtone_; } |
| 288 |
QString microphone() const { return microphone_; } |
| 289 |
QString camera() const { return camera_; } |
| 290 |
QString cameraResolution() const { return cameraResolution_; } |
| 291 |
QString cameraFrameRate() const { return cameraFrameRate_; } |
| 292 |
int screenShareFrameRate() const { return screenShareFrameRate_; } |
| 293 |
bool screenSharePiP() const { return screenSharePiP_; } |
| 294 |
bool screenShareRemoteVideo() const { return screenShareRemoteVideo_; } |
| 295 |
bool screenShareHideCursor() const { return screenShareHideCursor_; } |
| 296 |
bool useStunServer() const { return useStunServer_; } |
| 297 |
bool shareKeysWithTrustedUsers() const { return shareKeysWithTrustedUsers_; } |
| 298 |
bool onlyShareKeysWithVerifiedUsers() const { return onlyShareKeysWithVerifiedUsers_; } |
| 299 |
bool useOnlineKeyBackup() const { return useOnlineKeyBackup_; } |
| 300 |
QString profile() const { return profile_; } |
| 301 |
QString userId() const { return userId_; } |
| 302 |
QString accessToken() const { return accessToken_; } |
| 303 |
QString deviceId() const { return deviceId_; } |
| 304 |
QString currentTagId() const { return currentTagId_; } |
| 305 |
QString homeserver() const { return homeserver_; } |
| 306 |
bool disableCertificateValidation() const { return disableCertificateValidation_; } |
| 307 |
QStringList hiddenTags() const { return hiddenTags_; } |
| 308 |
QStringList mutedTags() const { return mutedTags_; } |
| 309 |
QStringList hiddenPins() const { return hiddenPins_; } |
| 310 |
QStringList hiddenWidgets() const { return hiddenWidgets_; } |
| 311 |
QStringList recentReactions() const { return recentReactions_; } |
| 312 |
bool useIdenticon() const; |
| 313 |
bool openImageExternal() const { return openImageExternal_; } |
| 314 |
bool openVideoExternal() const { return openVideoExternal_; } |
| 315 |
QList<QStringList> collapsedSpaces() const { return collapsedSpaces_; } |
| 316 |
bool exposeDBusApi() const { return exposeDBusApi_; } |
| 317 |
bool updateSpaceVias() const { return updateSpaceVias_; } |
| 318 |
bool expireEvents() const { return expireEvents_; } |
| 319 |
|
| 320 |
signals: |
| 321 |
void groupViewStateChanged(bool state); |
| 322 |
void scrollbarsInRoomlistChanged(bool state); |
| 323 |
void roomSortingChangedImportance(bool state); |
| 324 |
void roomSortingChangedAlphabetical(bool state); |
| 325 |
void themeChanged(QString state); |
| 326 |
void messageHoverHighlightChanged(bool state); |
| 327 |
void enlargeEmojiOnlyMessagesChanged(bool state); |
| 328 |
void trayChanged(bool state); |
| 329 |
void startInTrayChanged(bool state); |
| 330 |
void markdownChanged(bool state); |
| 331 |
void invertEnterKeyChanged(bool state); |
| 332 |
void bubblesChanged(bool state); |
| 333 |
void smallAvatarsChanged(bool state); |
| 334 |
void animateImagesOnHoverChanged(bool state); |
| 335 |
void typingNotificationsChanged(bool state); |
| 336 |
void buttonInTimelineChanged(bool state); |
| 337 |
void readReceiptsChanged(bool state); |
| 338 |
void desktopNotificationsChanged(bool state); |
| 339 |
void alertOnNotificationChanged(bool state); |
| 340 |
void avatarCirclesChanged(bool state); |
| 341 |
void decryptSidebarChanged(bool state); |
| 342 |
void decryptNotificationsChanged(bool state); |
| 343 |
void spaceNotificationsChanged(bool state); |
| 344 |
void fancyEffectsChanged(bool state); |
| 345 |
void reducedMotionChanged(bool state); |
| 346 |
void privacyScreenChanged(bool state); |
| 347 |
void privacyScreenTimeoutChanged(int state); |
| 348 |
void timelineMaxWidthChanged(int state); |
| 349 |
void roomListWidthChanged(int state); |
| 350 |
void communityListWidthChanged(int state); |
| 351 |
void mobileModeChanged(bool mode); |
| 352 |
void disableSwipeChanged(bool state); |
| 353 |
void fontSizeChanged(double state); |
| 354 |
void fontChanged(QString state); |
| 355 |
void emojiFontChanged(QString state); |
| 356 |
void presenceChanged(Presence state); |
| 357 |
void showImageChanged(ShowImage state); |
| 358 |
void ringtoneChanged(QString ringtone); |
| 359 |
void microphoneChanged(QString microphone); |
| 360 |
void cameraChanged(QString camera); |
| 361 |
void cameraResolutionChanged(QString resolution); |
| 362 |
void cameraFrameRateChanged(QString frameRate); |
| 363 |
void screenShareFrameRateChanged(int frameRate); |
| 364 |
void screenSharePiPChanged(bool state); |
| 365 |
void screenShareRemoteVideoChanged(bool state); |
| 366 |
void screenShareHideCursorChanged(bool state); |
| 367 |
void useStunServerChanged(bool state); |
| 368 |
void onlyShareKeysWithVerifiedUsersChanged(bool state); |
| 369 |
void shareKeysWithTrustedUsersChanged(bool state); |
| 370 |
void useOnlineKeyBackupChanged(bool state); |
| 371 |
void profileChanged(QString profile); |
| 372 |
void userIdChanged(QString userId); |
| 373 |
void accessTokenChanged(QString accessToken); |
| 374 |
void deviceIdChanged(QString deviceId); |
| 375 |
void homeserverChanged(QString homeserver); |
| 376 |
void disableCertificateValidationChanged(bool disabled); |
| 377 |
void useIdenticonChanged(bool state); |
| 378 |
void openImageExternalChanged(bool state); |
| 379 |
void openVideoExternalChanged(bool state); |
| 380 |
void hiddenPinsChanged(); |
| 381 |
void hiddenWidgetsChanged(); |
| 382 |
void recentReactionsChanged(); |
| 383 |
void exposeDBusApiChanged(bool state); |
| 384 |
void updateSpaceViasChanged(bool state); |
| 385 |
void expireEventsChanged(bool state); |
| 386 |
|
| 387 |
private: |
| 388 |
|
| 389 |
QString defaultTheme_ = QProcessEnvironment::systemEnvironment() |
| 390 |
.value(QStringLiteral("QT_QPA_PLATFORMTHEME"), QLatin1String("")) |
| 391 |
.isEmpty() |
| 392 |
? "light" |
| 393 |
: "system"; |
| 394 |
QString theme_; |
| 395 |
bool messageHoverHighlight_; |
| 396 |
bool enlargeEmojiOnlyMessages_; |
| 397 |
bool tray_; |
| 398 |
bool startInTray_; |
| 399 |
bool groupView_; |
| 400 |
bool scrollbarsInRoomlist_; |
| 401 |
bool markdown_; |
| 402 |
bool invertEnterKey_; |
| 403 |
bool bubbles_; |
| 404 |
bool smallAvatars_; |
| 405 |
bool animateImagesOnHover_; |
| 406 |
bool typingNotifications_; |
| 407 |
bool sortByImportance_; |
| 408 |
bool sortByAlphabet_; |
| 409 |
bool buttonsInTimeline_; |
| 410 |
bool readReceipts_; |
| 411 |
bool hasDesktopNotifications_; |
| 412 |
bool hasAlertOnNotification_; |
| 413 |
bool avatarCircles_; |
| 414 |
bool decryptSidebar_; |
| 415 |
bool decryptNotifications_; |
| 416 |
bool spaceNotifications_; |
| 417 |
bool fancyEffects_; |
| 418 |
bool reducedMotion_; |
| 419 |
bool privacyScreen_; |
| 420 |
int privacyScreenTimeout_; |
| 421 |
bool shareKeysWithTrustedUsers_; |
| 422 |
bool onlyShareKeysWithVerifiedUsers_; |
| 423 |
bool useOnlineKeyBackup_; |
| 424 |
bool mobileMode_; |
| 425 |
bool disableSwipe_; |
| 426 |
int timelineMaxWidth_; |
| 427 |
int roomListWidth_; |
| 428 |
int communityListWidth_; |
| 429 |
double baseFontSize_; |
| 430 |
QString font_; |
| 431 |
QString emojiFont_; |
| 432 |
Presence presence_; |
| 433 |
ShowImage showImage_; |
| 434 |
QString ringtone_; |
| 435 |
QString microphone_; |
| 436 |
QString camera_; |
| 437 |
QString cameraResolution_; |
| 438 |
QString cameraFrameRate_; |
| 439 |
int screenShareFrameRate_; |
| 440 |
bool screenSharePiP_; |
| 441 |
bool screenShareRemoteVideo_; |
| 442 |
bool screenShareHideCursor_; |
| 443 |
bool useStunServer_; |
| 444 |
bool disableCertificateValidation_ = false; |
| 445 |
QString profile_; |
| 446 |
QString userId_; |
| 447 |
QString accessToken_; |
| 448 |
QString deviceId_; |
| 449 |
QString currentTagId_; |
| 450 |
QString homeserver_; |
| 451 |
QStringList hiddenTags_; |
| 452 |
QStringList mutedTags_; |
| 453 |
QStringList hiddenPins_; |
| 454 |
QStringList hiddenWidgets_; |
| 455 |
QStringList recentReactions_; |
| 456 |
QList<QStringList> collapsedSpaces_; |
| 457 |
bool useIdenticon_; |
| 458 |
bool openImageExternal_; |
| 459 |
bool openVideoExternal_; |
| 460 |
bool exposeDBusApi_; |
| 461 |
bool updateSpaceVias_; |
| 462 |
bool expireEvents_; |
| 463 |
|
| 464 |
QSettings settings; |
| 465 |
|
| 466 |
static QSharedPointer<UserSettings> instance_; |
| 467 |
}; |
| 468 |
|
| 469 |
class UserSettingsModel : public QAbstractListModel |
| 470 |
{ |
| 471 |
Q_OBJECT |
| 472 |
QML_ELEMENT |
| 473 |
QML_SINGLETON |
| 474 |
|
| 475 |
enum Indices |
| 476 |
{ |
| 477 |
GeneralSection, |
| 478 |
Theme, |
| 479 |
MobileMode, |
| 480 |
DisableSwipe, |
| 481 |
#ifndef Q_OS_MACOS |
| 482 |
ScaleFactor, |
| 483 |
#endif |
| 484 |
Font, |
| 485 |
FontSize, |
| 486 |
EmojiFont, |
| 487 |
AvatarCircles, |
| 488 |
UseIdenticon, |
| 489 |
PrivacyScreen, |
| 490 |
PrivacyScreenTimeout, |
| 491 |
ScrollbarsInRoomlist, |
| 492 |
#ifdef NHEKO_DBUS_SYS |
| 493 |
ExposeDBusApi, |
| 494 |
#endif |
| 495 |
UpdateSpaceVias, |
| 496 |
|
| 497 |
AccessibilitySection, |
| 498 |
ReducedMotion, |
| 499 |
FancyEffects, |
| 500 |
AnimateImagesOnHover, |
| 501 |
MessageHoverHighlight, |
| 502 |
|
| 503 |
TimelineSection, |
| 504 |
TimelineMaxWidth, |
| 505 |
EnlargeEmojiOnlyMessages, |
| 506 |
ShowImage, |
| 507 |
OpenImageExternal, |
| 508 |
OpenVideoExternal, |
| 509 |
ButtonsInTimeline, |
| 510 |
TypingNotifications, |
| 511 |
ReadReceipts, |
| 512 |
Markdown, |
| 513 |
InvertEnterKey, |
| 514 |
Bubbles, |
| 515 |
SmallAvatars, |
| 516 |
|
| 517 |
SidebarSection, |
| 518 |
GroupView, |
| 519 |
SortByImportance, |
| 520 |
SortByAlphabet, |
| 521 |
DecryptSidebar, |
| 522 |
SpaceNotifications, |
| 523 |
|
| 524 |
TraySection, |
| 525 |
Tray, |
| 526 |
StartInTray, |
| 527 |
|
| 528 |
MessageVisibilitySection, |
| 529 |
ExpireEvents, |
| 530 |
HiddenTimelineEvents, |
| 531 |
IgnoredUsers, |
| 532 |
|
| 533 |
NotificationsSection, |
| 534 |
DesktopNotifications, |
| 535 |
AlertOnNotification, |
| 536 |
DecryptNotifications, |
| 537 |
|
| 538 |
VoipSection, |
| 539 |
UseStunServer, |
| 540 |
Microphone, |
| 541 |
Camera, |
| 542 |
CameraResolution, |
| 543 |
CameraFrameRate, |
| 544 |
Ringtone, |
| 545 |
|
| 546 |
EncryptionSection, |
| 547 |
OnlyShareKeysWithVerifiedUsers, |
| 548 |
ShareKeysWithTrustedUsers, |
| 549 |
SessionKeys, |
| 550 |
UseOnlineKeyBackup, |
| 551 |
OnlineBackupKey, |
| 552 |
SelfSigningKey, |
| 553 |
UserSigningKey, |
| 554 |
MasterKey, |
| 555 |
CrossSigningSecrets, |
| 556 |
DeviceId, |
| 557 |
DeviceFingerprint, |
| 558 |
|
| 559 |
LoginInfoSection, |
| 560 |
UserId, |
| 561 |
Homeserver, |
| 562 |
Profile, |
| 563 |
Version, |
| 564 |
Platform, |
| 565 |
COUNT, |
| 566 |
|
| 567 |
AccessToken, |
| 568 |
#ifdef Q_OS_MACOS |
| 569 |
ScaleFactor, |
| 570 |
#endif |
| 571 |
#ifndef NHEKO_DBUS_SYS |
| 572 |
ExposeDBusApi, |
| 573 |
#endif |
| 574 |
}; |
| 575 |
|
| 576 |
public: |
| 577 |
enum Types |
| 578 |
{ |
| 579 |
Toggle, |
| 580 |
ReadOnlyText, |
| 581 |
Options, |
| 582 |
Integer, |
| 583 |
Double, |
| 584 |
SectionTitle, |
| 585 |
SectionBar, |
| 586 |
KeyStatus, |
| 587 |
SessionKeyImportExport, |
| 588 |
XSignKeysRequestDownload, |
| 589 |
ConfigureHiddenEvents, |
| 590 |
ManageIgnoredUsers, |
| 591 |
}; |
| 592 |
Q_ENUM(Types); |
| 593 |
|
| 594 |
enum Roles |
| 595 |
{ |
| 596 |
Name, |
| 597 |
Description, |
| 598 |
Value, |
| 599 |
Type, |
| 600 |
ValueLowerBound, |
| 601 |
ValueUpperBound, |
| 602 |
ValueStep, |
| 603 |
Values, |
| 604 |
Good, |
| 605 |
Enabled, |
| 606 |
}; |
| 607 |
|
| 608 |
UserSettingsModel(QObject *parent = nullptr); |
| 609 |
QHash<int, QByteArray> roleNames() const override; |
| 610 |
int rowCount(const QModelIndex &parent = QModelIndex()) const override |
| 611 |
{ |
| 612 |
(void)parent; |
| 613 |
return (int)COUNT; |
| 614 |
} |
| 615 |
QVariant data(const QModelIndex &index, int role) const override; |
| 616 |
bool setData(const QModelIndex &index, const QVariant &value, int role) override; |
| 617 |
|
| 618 |
Q_INVOKABLE void importSessionKeys(); |
| 619 |
Q_INVOKABLE void exportSessionKeys(); |
| 620 |
Q_INVOKABLE void requestCrossSigningSecrets(); |
| 621 |
Q_INVOKABLE void downloadCrossSigningSecrets(); |
| 622 |
}; |