mirror of
https://github.com/Nheko-Reborn/nheko.git
synced 2024-10-30 09:30:47 +03:00
Simplify space notification options
This commit is contained in:
parent
f264941615
commit
885a790b1f
4 changed files with 18 additions and 75 deletions
|
@ -185,23 +185,7 @@ Page {
|
|||
bubbleBackgroundColor: communityItem.bubbleBackground
|
||||
bubbleTextColor: communityItem.bubbleText
|
||||
font.pixelSize: fontMetrics.font.pixelSize * 0.6
|
||||
mayBeVisible: {
|
||||
if (!communitySidebar.collapsed)
|
||||
return false
|
||||
else if (communityItem.muted)
|
||||
return false
|
||||
else if (Settings.spaceNotifications === Settings.SpaceNotificationsOff)
|
||||
return false
|
||||
else if (Settings.spaceNotifications === Settings.SidebarHiddenRooms)
|
||||
{
|
||||
if (communityItem.hidden)
|
||||
return true
|
||||
else
|
||||
return false
|
||||
}
|
||||
else
|
||||
return true
|
||||
}
|
||||
mayBeVisible: communitySidebar.collapsed && !communityItem.muted && Settings.spaceNotifications
|
||||
anchors.right: avatar.right
|
||||
anchors.bottom: avatar.bottom
|
||||
anchors.margins: -Nheko.paddingSmall
|
||||
|
@ -228,23 +212,7 @@ Page {
|
|||
hasLoudNotification: communityItem.hasLoudNotification
|
||||
bubbleBackgroundColor: communityItem.bubbleBackground
|
||||
bubbleTextColor: communityItem.bubbleText
|
||||
mayBeVisible: {
|
||||
if (communitySidebar.collapsed)
|
||||
return false
|
||||
else if (communityItem.muted)
|
||||
return false
|
||||
else if (Settings.spaceNotification === Settings.SpaceNotificationsOff)
|
||||
return false
|
||||
else if (Settings.spaceNotifications === Settings.SidebarHiddenRooms)
|
||||
{
|
||||
if (communityItem.hidden)
|
||||
return true
|
||||
else
|
||||
return false
|
||||
}
|
||||
else
|
||||
return true
|
||||
}
|
||||
mayBeVisible: !communitySidebar.collapsed && !communityItem.muted && Settings.spaceNotifications
|
||||
Layout.alignment: Qt.AlignRight
|
||||
Layout.leftMargin: Nheko.paddingSmall
|
||||
}
|
||||
|
|
|
@ -316,7 +316,7 @@ Page {
|
|||
anchors.right: parent.right
|
||||
anchors.bottom: parent.bottom
|
||||
anchors.margins: -Nheko.paddingSmall
|
||||
mayBeVisible: collapsed && (isSpace ? Settings.spaceNotifications === Settings.SidebarAndRoomlist : true)
|
||||
mayBeVisible: collapsed && (isSpace ? Settings.spaceNotifications : true)
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -345,7 +345,7 @@ Page {
|
|||
Layout.leftMargin: Nheko.paddingSmall
|
||||
Layout.preferredWidth: implicitWidth
|
||||
Layout.preferredHeight: implicitHeight
|
||||
mayBeVisible: !collapsed && (isSpace ? Settings.spaceNotifications === Settings.SidebarAndRoomlist : true)
|
||||
mayBeVisible: !collapsed && (isSpace ? Settings.spaceNotifications : true)
|
||||
}
|
||||
|
||||
RowLayout {
|
||||
|
|
|
@ -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) {
|
||||
|
|
|
@ -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_;
|
||||
|
|
Loading…
Reference in a new issue