mirror of
https://github.com/Nheko-Reborn/nheko.git
synced 2024-11-26 04:58:49 +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
|
bubbleBackgroundColor: communityItem.bubbleBackground
|
||||||
bubbleTextColor: communityItem.bubbleText
|
bubbleTextColor: communityItem.bubbleText
|
||||||
font.pixelSize: fontMetrics.font.pixelSize * 0.6
|
font.pixelSize: fontMetrics.font.pixelSize * 0.6
|
||||||
mayBeVisible: {
|
mayBeVisible: communitySidebar.collapsed && !communityItem.muted && Settings.spaceNotifications
|
||||||
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
|
|
||||||
}
|
|
||||||
anchors.right: avatar.right
|
anchors.right: avatar.right
|
||||||
anchors.bottom: avatar.bottom
|
anchors.bottom: avatar.bottom
|
||||||
anchors.margins: -Nheko.paddingSmall
|
anchors.margins: -Nheko.paddingSmall
|
||||||
|
@ -228,23 +212,7 @@ Page {
|
||||||
hasLoudNotification: communityItem.hasLoudNotification
|
hasLoudNotification: communityItem.hasLoudNotification
|
||||||
bubbleBackgroundColor: communityItem.bubbleBackground
|
bubbleBackgroundColor: communityItem.bubbleBackground
|
||||||
bubbleTextColor: communityItem.bubbleText
|
bubbleTextColor: communityItem.bubbleText
|
||||||
mayBeVisible: {
|
mayBeVisible: !communitySidebar.collapsed && !communityItem.muted && Settings.spaceNotifications
|
||||||
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
|
|
||||||
}
|
|
||||||
Layout.alignment: Qt.AlignRight
|
Layout.alignment: Qt.AlignRight
|
||||||
Layout.leftMargin: Nheko.paddingSmall
|
Layout.leftMargin: Nheko.paddingSmall
|
||||||
}
|
}
|
||||||
|
|
|
@ -316,7 +316,7 @@ Page {
|
||||||
anchors.right: parent.right
|
anchors.right: parent.right
|
||||||
anchors.bottom: parent.bottom
|
anchors.bottom: parent.bottom
|
||||||
anchors.margins: -Nheko.paddingSmall
|
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.leftMargin: Nheko.paddingSmall
|
||||||
Layout.preferredWidth: implicitWidth
|
Layout.preferredWidth: implicitWidth
|
||||||
Layout.preferredHeight: implicitHeight
|
Layout.preferredHeight: implicitHeight
|
||||||
mayBeVisible: !collapsed && (isSpace ? Settings.spaceNotifications === Settings.SidebarAndRoomlist : true)
|
mayBeVisible: !collapsed && (isSpace ? Settings.spaceNotifications : true)
|
||||||
}
|
}
|
||||||
|
|
||||||
RowLayout {
|
RowLayout {
|
||||||
|
|
|
@ -88,14 +88,7 @@ UserSettings::load(std::optional<QString> profile)
|
||||||
openImageExternal_ = settings.value(QStringLiteral("user/open_image_external"), false).toBool();
|
openImageExternal_ = settings.value(QStringLiteral("user/open_image_external"), false).toBool();
|
||||||
openVideoExternal_ = settings.value(QStringLiteral("user/open_video_external"), false).toBool();
|
openVideoExternal_ = settings.value(QStringLiteral("user/open_video_external"), false).toBool();
|
||||||
decryptSidebar_ = settings.value(QStringLiteral("user/decrypt_sidebar"), true).toBool();
|
decryptSidebar_ = settings.value(QStringLiteral("user/decrypt_sidebar"), true).toBool();
|
||||||
auto tempSpaceNotifs = settings.value(QStringLiteral("user/space_notifications"), QString{})
|
spaceNotifications_ = settings.value(QStringLiteral("user/space_notifications"), true).toBool();
|
||||||
.toString()
|
|
||||||
.toStdString();
|
|
||||||
auto spaceNotifsValue =
|
|
||||||
QMetaEnum::fromType<SpaceNotificationOptions>().keyToValue(tempSpaceNotifs.c_str());
|
|
||||||
if (spaceNotifsValue < 0)
|
|
||||||
spaceNotifsValue = 0;
|
|
||||||
spaceNotifications_ = static_cast<SpaceNotificationOptions>(spaceNotifsValue);
|
|
||||||
privacyScreen_ = settings.value(QStringLiteral("user/privacy_screen"), false).toBool();
|
privacyScreen_ = settings.value(QStringLiteral("user/privacy_screen"), false).toBool();
|
||||||
privacyScreenTimeout_ =
|
privacyScreenTimeout_ =
|
||||||
settings.value(QStringLiteral("user/privacy_screen_timeout"), 0).toInt();
|
settings.value(QStringLiteral("user/privacy_screen_timeout"), 0).toInt();
|
||||||
|
@ -433,7 +426,7 @@ UserSettings::setDecryptSidebar(bool state)
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
UserSettings::setSpaceNotifications(SpaceNotificationOptions state)
|
UserSettings::setSpaceNotifications(bool state)
|
||||||
{
|
{
|
||||||
if (state == spaceNotifications_)
|
if (state == spaceNotifications_)
|
||||||
return;
|
return;
|
||||||
|
@ -803,9 +796,7 @@ UserSettings::save()
|
||||||
|
|
||||||
settings.setValue(QStringLiteral("avatar_circles"), avatarCircles_);
|
settings.setValue(QStringLiteral("avatar_circles"), avatarCircles_);
|
||||||
settings.setValue(QStringLiteral("decrypt_sidebar"), decryptSidebar_);
|
settings.setValue(QStringLiteral("decrypt_sidebar"), decryptSidebar_);
|
||||||
settings.setValue(QStringLiteral("space_notifications"),
|
settings.setValue(QStringLiteral("space_notifications"), spaceNotifications_);
|
||||||
QString::fromUtf8(QMetaEnum::fromType<SpaceNotificationOptions>().valueToKey(
|
|
||||||
static_cast<int>(spaceNotifications_))));
|
|
||||||
settings.setValue(QStringLiteral("privacy_screen"), privacyScreen_);
|
settings.setValue(QStringLiteral("privacy_screen"), privacyScreen_);
|
||||||
settings.setValue(QStringLiteral("privacy_screen_timeout"), privacyScreenTimeout_);
|
settings.setValue(QStringLiteral("privacy_screen_timeout"), privacyScreenTimeout_);
|
||||||
settings.setValue(QStringLiteral("mobile_mode"), mobileMode_);
|
settings.setValue(QStringLiteral("mobile_mode"), mobileMode_);
|
||||||
|
@ -1086,7 +1077,7 @@ UserSettingsModel::data(const QModelIndex &index, int role) const
|
||||||
case DecryptSidebar:
|
case DecryptSidebar:
|
||||||
return i->decryptSidebar();
|
return i->decryptSidebar();
|
||||||
case SpaceNotifications:
|
case SpaceNotifications:
|
||||||
return static_cast<int>(i->spaceNotifications());
|
return i->spaceNotifications();
|
||||||
case PrivacyScreen:
|
case PrivacyScreen:
|
||||||
return i->privacyScreen();
|
return i->privacyScreen();
|
||||||
case PrivacyScreenTimeout:
|
case PrivacyScreenTimeout:
|
||||||
|
@ -1320,7 +1311,6 @@ UserSettingsModel::data(const QModelIndex &index, int role) const
|
||||||
case CameraResolution:
|
case CameraResolution:
|
||||||
case CameraFrameRate:
|
case CameraFrameRate:
|
||||||
case Ringtone:
|
case Ringtone:
|
||||||
case SpaceNotifications:
|
|
||||||
return Options;
|
return Options;
|
||||||
case TimelineMaxWidth:
|
case TimelineMaxWidth:
|
||||||
case PrivacyScreenTimeout:
|
case PrivacyScreenTimeout:
|
||||||
|
@ -1355,6 +1345,7 @@ UserSettingsModel::data(const QModelIndex &index, int role) const
|
||||||
case ShareKeysWithTrustedUsers:
|
case ShareKeysWithTrustedUsers:
|
||||||
case UseOnlineKeyBackup:
|
case UseOnlineKeyBackup:
|
||||||
case ExposeDBusApi:
|
case ExposeDBusApi:
|
||||||
|
case SpaceNotifications:
|
||||||
return Toggle;
|
return Toggle;
|
||||||
case Profile:
|
case Profile:
|
||||||
case UserId:
|
case UserId:
|
||||||
|
@ -1457,11 +1448,6 @@ UserSettingsModel::data(const QModelIndex &index, int role) const
|
||||||
l.push_back(i->ringtone());
|
l.push_back(i->ringtone());
|
||||||
return l;
|
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) {
|
} else if (role == Good) {
|
||||||
switch (index.row()) {
|
switch (index.row()) {
|
||||||
|
@ -1669,13 +1655,11 @@ UserSettingsModel::setData(const QModelIndex &index, const QVariant &value, int
|
||||||
}
|
}
|
||||||
return i->decryptSidebar();
|
return i->decryptSidebar();
|
||||||
case SpaceNotifications: {
|
case SpaceNotifications: {
|
||||||
if (value.toInt() >
|
if (value.userType() == QMetaType::Bool) {
|
||||||
static_cast<int>(UserSettings::SpaceNotificationOptions::SpaceNotificationsOff) ||
|
i->setSpaceNotifications(value.toBool());
|
||||||
value.toInt() < 0)
|
|
||||||
return false;
|
|
||||||
|
|
||||||
i->setSpaceNotifications(value.value<UserSettings::SpaceNotificationOptions>());
|
|
||||||
return true;
|
return true;
|
||||||
|
} else
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
case PrivacyScreen: {
|
case PrivacyScreen: {
|
||||||
if (value.userType() == QMetaType::Bool) {
|
if (value.userType() == QMetaType::Bool) {
|
||||||
|
|
|
@ -58,7 +58,7 @@ class UserSettings : public QObject
|
||||||
bool avatarCircles READ avatarCircles WRITE setAvatarCircles NOTIFY avatarCirclesChanged)
|
bool avatarCircles READ avatarCircles WRITE setAvatarCircles NOTIFY avatarCirclesChanged)
|
||||||
Q_PROPERTY(
|
Q_PROPERTY(
|
||||||
bool decryptSidebar READ decryptSidebar WRITE setDecryptSidebar NOTIFY decryptSidebarChanged)
|
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)
|
setSpaceNotifications NOTIFY spaceNotificationsChanged)
|
||||||
Q_PROPERTY(
|
Q_PROPERTY(
|
||||||
bool privacyScreen READ privacyScreen WRITE setPrivacyScreen NOTIFY privacyScreenChanged)
|
bool privacyScreen READ privacyScreen WRITE setPrivacyScreen NOTIFY privacyScreenChanged)
|
||||||
|
@ -136,15 +136,6 @@ public:
|
||||||
};
|
};
|
||||||
Q_ENUM(Presence)
|
Q_ENUM(Presence)
|
||||||
|
|
||||||
enum class SpaceNotificationOptions
|
|
||||||
{
|
|
||||||
SidebarAndRoomlist = 0,
|
|
||||||
Sidebar,
|
|
||||||
SidebarHiddenRooms,
|
|
||||||
SpaceNotificationsOff,
|
|
||||||
};
|
|
||||||
Q_ENUM(SpaceNotificationOptions)
|
|
||||||
|
|
||||||
void save();
|
void save();
|
||||||
void load(std::optional<QString> profile);
|
void load(std::optional<QString> profile);
|
||||||
void applyTheme();
|
void applyTheme();
|
||||||
|
@ -173,7 +164,7 @@ public:
|
||||||
void setAlertOnNotification(bool state);
|
void setAlertOnNotification(bool state);
|
||||||
void setAvatarCircles(bool state);
|
void setAvatarCircles(bool state);
|
||||||
void setDecryptSidebar(bool state);
|
void setDecryptSidebar(bool state);
|
||||||
void setSpaceNotifications(SpaceNotificationOptions state);
|
void setSpaceNotifications(bool state);
|
||||||
void setPrivacyScreen(bool state);
|
void setPrivacyScreen(bool state);
|
||||||
void setPrivacyScreenTimeout(int state);
|
void setPrivacyScreenTimeout(int state);
|
||||||
void setPresence(Presence state);
|
void setPresence(Presence state);
|
||||||
|
@ -215,7 +206,7 @@ public:
|
||||||
bool groupView() const { return groupView_; }
|
bool groupView() const { return groupView_; }
|
||||||
bool avatarCircles() const { return avatarCircles_; }
|
bool avatarCircles() const { return avatarCircles_; }
|
||||||
bool decryptSidebar() const { return decryptSidebar_; }
|
bool decryptSidebar() const { return decryptSidebar_; }
|
||||||
SpaceNotificationOptions spaceNotifications() const { return spaceNotifications_; }
|
bool spaceNotifications() const { return spaceNotifications_; }
|
||||||
bool privacyScreen() const { return privacyScreen_; }
|
bool privacyScreen() const { return privacyScreen_; }
|
||||||
int privacyScreenTimeout() const { return privacyScreenTimeout_; }
|
int privacyScreenTimeout() const { return privacyScreenTimeout_; }
|
||||||
bool markdown() const { return markdown_; }
|
bool markdown() const { return markdown_; }
|
||||||
|
@ -293,7 +284,7 @@ signals:
|
||||||
void alertOnNotificationChanged(bool state);
|
void alertOnNotificationChanged(bool state);
|
||||||
void avatarCirclesChanged(bool state);
|
void avatarCirclesChanged(bool state);
|
||||||
void decryptSidebarChanged(bool state);
|
void decryptSidebarChanged(bool state);
|
||||||
void spaceNotificationsChanged(SpaceNotificationOptions state);
|
void spaceNotificationsChanged(bool state);
|
||||||
void privacyScreenChanged(bool state);
|
void privacyScreenChanged(bool state);
|
||||||
void privacyScreenTimeoutChanged(int state);
|
void privacyScreenTimeoutChanged(int state);
|
||||||
void timelineMaxWidthChanged(int state);
|
void timelineMaxWidthChanged(int state);
|
||||||
|
@ -356,7 +347,7 @@ private:
|
||||||
bool hasAlertOnNotification_;
|
bool hasAlertOnNotification_;
|
||||||
bool avatarCircles_;
|
bool avatarCircles_;
|
||||||
bool decryptSidebar_;
|
bool decryptSidebar_;
|
||||||
SpaceNotificationOptions spaceNotifications_;
|
bool spaceNotifications_;
|
||||||
bool privacyScreen_;
|
bool privacyScreen_;
|
||||||
int privacyScreenTimeout_;
|
int privacyScreenTimeout_;
|
||||||
bool shareKeysWithTrustedUsers_;
|
bool shareKeysWithTrustedUsers_;
|
||||||
|
|
Loading…
Reference in a new issue