summary refs log tree commit diff
path: root/src
diff options
context:
space:
mode:
authorLoren Burkholder <computersemiexpert@outlook.com>2022-06-06 12:07:25 -0400
committerLoren Burkholder <computersemiexpert@outlook.com>2022-06-29 22:04:37 -0400
commit885a790b1fa16524058a5c8aacf3ec8e9641709d (patch)
tree4e032e0c31d2bfb023eee73a130b52d4da2ecf45 /src
parentmake license (diff)
downloadnheko-885a790b1fa16524058a5c8aacf3ec8e9641709d.tar.xz
Simplify space notification options
Diffstat (limited to 'src')
-rw-r--r--src/UserSettingsPage.cpp34
-rw-r--r--src/UserSettingsPage.h19
2 files changed, 14 insertions, 39 deletions
diff --git a/src/UserSettingsPage.cpp b/src/UserSettingsPage.cpp

index 2c6dc782..b850d2e5 100644 --- a/src/UserSettingsPage.cpp +++ b/src/UserSettingsPage.cpp
@@ -88,14 +88,7 @@ UserSettings::load(std::optional<QString> profile) openImageExternal_ = settings.value(QStringLiteral("user/open_image_external"), false).toBool(); openVideoExternal_ = settings.value(QStringLiteral("user/open_video_external"), false).toBool(); decryptSidebar_ = settings.value(QStringLiteral("user/decrypt_sidebar"), true).toBool(); - auto tempSpaceNotifs = settings.value(QStringLiteral("user/space_notifications"), QString{}) - .toString() - .toStdString(); - auto spaceNotifsValue = - QMetaEnum::fromType<SpaceNotificationOptions>().keyToValue(tempSpaceNotifs.c_str()); - if (spaceNotifsValue < 0) - spaceNotifsValue = 0; - spaceNotifications_ = static_cast<SpaceNotificationOptions>(spaceNotifsValue); + spaceNotifications_ = settings.value(QStringLiteral("user/space_notifications"), true).toBool(); privacyScreen_ = settings.value(QStringLiteral("user/privacy_screen"), false).toBool(); privacyScreenTimeout_ = settings.value(QStringLiteral("user/privacy_screen_timeout"), 0).toInt(); @@ -433,7 +426,7 @@ UserSettings::setDecryptSidebar(bool state) } void -UserSettings::setSpaceNotifications(SpaceNotificationOptions state) +UserSettings::setSpaceNotifications(bool state) { if (state == spaceNotifications_) return; @@ -803,9 +796,7 @@ UserSettings::save() settings.setValue(QStringLiteral("avatar_circles"), avatarCircles_); settings.setValue(QStringLiteral("decrypt_sidebar"), decryptSidebar_); - settings.setValue(QStringLiteral("space_notifications"), - QString::fromUtf8(QMetaEnum::fromType<SpaceNotificationOptions>().valueToKey( - static_cast<int>(spaceNotifications_)))); + settings.setValue(QStringLiteral("space_notifications"), spaceNotifications_); settings.setValue(QStringLiteral("privacy_screen"), privacyScreen_); settings.setValue(QStringLiteral("privacy_screen_timeout"), privacyScreenTimeout_); settings.setValue(QStringLiteral("mobile_mode"), mobileMode_); @@ -1086,7 +1077,7 @@ UserSettingsModel::data(const QModelIndex &index, int role) const case DecryptSidebar: return i->decryptSidebar(); case SpaceNotifications: - return static_cast<int>(i->spaceNotifications()); + return i->spaceNotifications(); case PrivacyScreen: return i->privacyScreen(); case PrivacyScreenTimeout: @@ -1320,7 +1311,6 @@ UserSettingsModel::data(const QModelIndex &index, int role) const case CameraResolution: case CameraFrameRate: case Ringtone: - case SpaceNotifications: return Options; case TimelineMaxWidth: case PrivacyScreenTimeout: @@ -1355,6 +1345,7 @@ UserSettingsModel::data(const QModelIndex &index, int role) const case ShareKeysWithTrustedUsers: case UseOnlineKeyBackup: case ExposeDBusApi: + case SpaceNotifications: return Toggle; case Profile: case UserId: @@ -1457,11 +1448,6 @@ UserSettingsModel::data(const QModelIndex &index, int role) const l.push_back(i->ringtone()); return l; } - case SpaceNotifications: - return QStringList{QStringLiteral("Sidebar and room list"), - QStringLiteral("Sidebar"), - QStringLiteral("Sidebar (hidden spaces and tags only)"), - QStringLiteral("Off")}; } } else if (role == Good) { switch (index.row()) { @@ -1669,13 +1655,11 @@ UserSettingsModel::setData(const QModelIndex &index, const QVariant &value, int } return i->decryptSidebar(); case SpaceNotifications: { - if (value.toInt() > - static_cast<int>(UserSettings::SpaceNotificationOptions::SpaceNotificationsOff) || - value.toInt() < 0) + if (value.userType() == QMetaType::Bool) { + i->setSpaceNotifications(value.toBool()); + return true; + } else return false; - - i->setSpaceNotifications(value.value<UserSettings::SpaceNotificationOptions>()); - return true; } case PrivacyScreen: { if (value.userType() == QMetaType::Bool) { diff --git a/src/UserSettingsPage.h b/src/UserSettingsPage.h
index db12b1e6..7bb722f1 100644 --- a/src/UserSettingsPage.h +++ b/src/UserSettingsPage.h
@@ -58,7 +58,7 @@ class UserSettings : public QObject bool avatarCircles READ avatarCircles WRITE setAvatarCircles NOTIFY avatarCirclesChanged) Q_PROPERTY( bool decryptSidebar READ decryptSidebar WRITE setDecryptSidebar NOTIFY decryptSidebarChanged) - Q_PROPERTY(SpaceNotificationOptions spaceNotifications READ spaceNotifications WRITE + Q_PROPERTY(bool spaceNotifications READ spaceNotifications WRITE setSpaceNotifications NOTIFY spaceNotificationsChanged) Q_PROPERTY( bool privacyScreen READ privacyScreen WRITE setPrivacyScreen NOTIFY privacyScreenChanged) @@ -136,15 +136,6 @@ public: }; Q_ENUM(Presence) - enum class SpaceNotificationOptions - { - SidebarAndRoomlist = 0, - Sidebar, - SidebarHiddenRooms, - SpaceNotificationsOff, - }; - Q_ENUM(SpaceNotificationOptions) - void save(); void load(std::optional<QString> profile); void applyTheme(); @@ -173,7 +164,7 @@ public: void setAlertOnNotification(bool state); void setAvatarCircles(bool state); void setDecryptSidebar(bool state); - void setSpaceNotifications(SpaceNotificationOptions state); + void setSpaceNotifications(bool state); void setPrivacyScreen(bool state); void setPrivacyScreenTimeout(int state); void setPresence(Presence state); @@ -215,7 +206,7 @@ public: bool groupView() const { return groupView_; } bool avatarCircles() const { return avatarCircles_; } bool decryptSidebar() const { return decryptSidebar_; } - SpaceNotificationOptions spaceNotifications() const { return spaceNotifications_; } + bool spaceNotifications() const { return spaceNotifications_; } bool privacyScreen() const { return privacyScreen_; } int privacyScreenTimeout() const { return privacyScreenTimeout_; } bool markdown() const { return markdown_; } @@ -293,7 +284,7 @@ signals: void alertOnNotificationChanged(bool state); void avatarCirclesChanged(bool state); void decryptSidebarChanged(bool state); - void spaceNotificationsChanged(SpaceNotificationOptions state); + void spaceNotificationsChanged(bool state); void privacyScreenChanged(bool state); void privacyScreenTimeoutChanged(int state); void timelineMaxWidthChanged(int state); @@ -356,7 +347,7 @@ private: bool hasAlertOnNotification_; bool avatarCircles_; bool decryptSidebar_; - SpaceNotificationOptions spaceNotifications_; + bool spaceNotifications_; bool privacyScreen_; int privacyScreenTimeout_; bool shareKeysWithTrustedUsers_;