mirror of
https://github.com/Nheko-Reborn/nheko.git
synced 2024-11-22 19:08:58 +03:00
Add space notification configuration
This commit is contained in:
parent
c2b6728955
commit
863eaa1910
4 changed files with 92 additions and 7 deletions
|
@ -171,7 +171,21 @@ 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: communitySidebar.collapsed
|
mayBeVisible: {
|
||||||
|
if (!communitySidebar.collapsed)
|
||||||
|
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
|
||||||
|
@ -198,7 +212,16 @@ Page {
|
||||||
hasLoudNotification: communityItem.hasLoudNotification
|
hasLoudNotification: communityItem.hasLoudNotification
|
||||||
bubbleBackgroundColor: communityItem.bubbleBackground
|
bubbleBackgroundColor: communityItem.bubbleBackground
|
||||||
bubbleTextColor: communityItem.bubbleText
|
bubbleTextColor: communityItem.bubbleText
|
||||||
mayBeVisible: !communitySidebar.collapsed
|
mayBeVisible: {
|
||||||
|
if (communitySidebar.collapsed)
|
||||||
|
return false
|
||||||
|
else if (Settings.spaceNotification === Settings.SpaceNotificationsOff)
|
||||||
|
return false
|
||||||
|
else if ((Settings.spaceNotifications === Settings.SidebarHiddenRooms) && communityItem.hidden)
|
||||||
|
return true
|
||||||
|
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
|
mayBeVisible: collapsed && (isSpace ? Settings.spaceNotifications === Settings.SidebarAndRoomlist : 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
|
mayBeVisible: !collapsed && (isSpace ? Settings.spaceNotifications === Settings.SidebarAndRoomlist : true)
|
||||||
}
|
}
|
||||||
|
|
||||||
RowLayout {
|
RowLayout {
|
||||||
|
|
|
@ -88,6 +88,14 @@ 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{})
|
||||||
|
.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();
|
||||||
|
@ -416,6 +424,16 @@ UserSettings::setDecryptSidebar(bool state)
|
||||||
save();
|
save();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
UserSettings::setSpaceNotifications(SpaceNotificationOptions state)
|
||||||
|
{
|
||||||
|
if (state == spaceNotifications_)
|
||||||
|
return;
|
||||||
|
spaceNotifications_ = state;
|
||||||
|
emit spaceNotificationsChanged(state);
|
||||||
|
save();
|
||||||
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
UserSettings::setPrivacyScreen(bool state)
|
UserSettings::setPrivacyScreen(bool state)
|
||||||
{
|
{
|
||||||
|
@ -777,6 +795,9 @@ 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"),
|
||||||
|
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_);
|
||||||
|
@ -923,6 +944,8 @@ UserSettingsModel::data(const QModelIndex &index, int role) const
|
||||||
return tr("Open videos with external program");
|
return tr("Open videos with external program");
|
||||||
case DecryptSidebar:
|
case DecryptSidebar:
|
||||||
return tr("Decrypt messages in sidebar");
|
return tr("Decrypt messages in sidebar");
|
||||||
|
case SpaceNotifications:
|
||||||
|
return tr("Show message counts for spaces");
|
||||||
case PrivacyScreen:
|
case PrivacyScreen:
|
||||||
return tr("Privacy Screen");
|
return tr("Privacy Screen");
|
||||||
case PrivacyScreenTimeout:
|
case PrivacyScreenTimeout:
|
||||||
|
@ -1053,6 +1076,8 @@ UserSettingsModel::data(const QModelIndex &index, int role) const
|
||||||
return i->openVideoExternal();
|
return i->openVideoExternal();
|
||||||
case DecryptSidebar:
|
case DecryptSidebar:
|
||||||
return i->decryptSidebar();
|
return i->decryptSidebar();
|
||||||
|
case SpaceNotifications:
|
||||||
|
return static_cast<int>(i->spaceNotifications());
|
||||||
case PrivacyScreen:
|
case PrivacyScreen:
|
||||||
return i->privacyScreen();
|
return i->privacyScreen();
|
||||||
case PrivacyScreenTimeout:
|
case PrivacyScreenTimeout:
|
||||||
|
@ -1208,6 +1233,9 @@ UserSettingsModel::data(const QModelIndex &index, int role) const
|
||||||
case DecryptSidebar:
|
case DecryptSidebar:
|
||||||
return tr("Decrypt the messages shown in the sidebar.\nOnly affects messages in "
|
return tr("Decrypt the messages shown in the sidebar.\nOnly affects messages in "
|
||||||
"encrypted chats.");
|
"encrypted chats.");
|
||||||
|
case SpaceNotifications:
|
||||||
|
return tr(
|
||||||
|
"Choose where to show the total number of notifications contained within a space.");
|
||||||
case PrivacyScreen:
|
case PrivacyScreen:
|
||||||
return tr("When the window loses focus, the timeline will\nbe blurred.");
|
return tr("When the window loses focus, the timeline will\nbe blurred.");
|
||||||
case MobileMode:
|
case MobileMode:
|
||||||
|
@ -1283,6 +1311,7 @@ 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:
|
||||||
|
@ -1409,7 +1438,7 @@ UserSettingsModel::data(const QModelIndex &index, int role) const
|
||||||
return fontDb.families();
|
return fontDb.families();
|
||||||
case EmojiFont:
|
case EmojiFont:
|
||||||
return fontDb.families(QFontDatabase::WritingSystem::Symbol);
|
return fontDb.families(QFontDatabase::WritingSystem::Symbol);
|
||||||
case Ringtone:
|
case Ringtone: {
|
||||||
QStringList l{
|
QStringList l{
|
||||||
QStringLiteral("Mute"),
|
QStringLiteral("Mute"),
|
||||||
QStringLiteral("Default"),
|
QStringLiteral("Default"),
|
||||||
|
@ -1419,6 +1448,12 @@ 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 rooms only)"),
|
||||||
|
QStringLiteral("Off")};
|
||||||
|
}
|
||||||
} else if (role == Good) {
|
} else if (role == Good) {
|
||||||
switch (index.row()) {
|
switch (index.row()) {
|
||||||
case OnlineBackupKey:
|
case OnlineBackupKey:
|
||||||
|
@ -1624,6 +1659,15 @@ UserSettingsModel::setData(const QModelIndex &index, const QVariant &value, int
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
return i->decryptSidebar();
|
return i->decryptSidebar();
|
||||||
|
case SpaceNotifications: {
|
||||||
|
if (value.toInt() >
|
||||||
|
static_cast<int>(UserSettings::SpaceNotificationOptions::SpaceNotificationsOff) ||
|
||||||
|
value.toInt() < 0)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
i->setSpaceNotifications(value.value<UserSettings::SpaceNotificationOptions>());
|
||||||
|
return true;
|
||||||
|
}
|
||||||
case PrivacyScreen: {
|
case PrivacyScreen: {
|
||||||
if (value.userType() == QMetaType::Bool) {
|
if (value.userType() == QMetaType::Bool) {
|
||||||
i->setPrivacyScreen(value.toBool());
|
i->setPrivacyScreen(value.toBool());
|
||||||
|
@ -1936,7 +1980,9 @@ UserSettingsModel::UserSettingsModel(QObject *p)
|
||||||
connect(s.get(), &UserSettings::decryptSidebarChanged, this, [this]() {
|
connect(s.get(), &UserSettings::decryptSidebarChanged, this, [this]() {
|
||||||
emit dataChanged(index(DecryptSidebar), index(DecryptSidebar), {Value});
|
emit dataChanged(index(DecryptSidebar), index(DecryptSidebar), {Value});
|
||||||
});
|
});
|
||||||
|
connect(s.get(), &UserSettings::spaceNotificationsChanged, this, [this] {
|
||||||
|
emit dataChanged(index(SpaceNotifications), index(SpaceNotifications), {Value});
|
||||||
|
});
|
||||||
connect(s.get(), &UserSettings::trayChanged, this, [this]() {
|
connect(s.get(), &UserSettings::trayChanged, this, [this]() {
|
||||||
emit dataChanged(index(Tray), index(Tray), {Value});
|
emit dataChanged(index(Tray), index(Tray), {Value});
|
||||||
emit dataChanged(index(StartInTray), index(StartInTray), {Enabled});
|
emit dataChanged(index(StartInTray), index(StartInTray), {Enabled});
|
||||||
|
|
|
@ -58,6 +58,8 @@ 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
|
||||||
|
setSpaceNotifications NOTIFY spaceNotificationsChanged)
|
||||||
Q_PROPERTY(
|
Q_PROPERTY(
|
||||||
bool privacyScreen READ privacyScreen WRITE setPrivacyScreen NOTIFY privacyScreenChanged)
|
bool privacyScreen READ privacyScreen WRITE setPrivacyScreen NOTIFY privacyScreenChanged)
|
||||||
Q_PROPERTY(int privacyScreenTimeout READ privacyScreenTimeout WRITE setPrivacyScreenTimeout
|
Q_PROPERTY(int privacyScreenTimeout READ privacyScreenTimeout WRITE setPrivacyScreenTimeout
|
||||||
|
@ -134,6 +136,15 @@ 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();
|
||||||
|
@ -162,6 +173,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 setPrivacyScreen(bool state);
|
void setPrivacyScreen(bool state);
|
||||||
void setPrivacyScreenTimeout(int state);
|
void setPrivacyScreenTimeout(int state);
|
||||||
void setPresence(Presence state);
|
void setPresence(Presence state);
|
||||||
|
@ -202,6 +214,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 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_; }
|
||||||
|
@ -278,6 +291,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 privacyScreenChanged(bool state);
|
void privacyScreenChanged(bool state);
|
||||||
void privacyScreenTimeoutChanged(int state);
|
void privacyScreenTimeoutChanged(int state);
|
||||||
void timelineMaxWidthChanged(int state);
|
void timelineMaxWidthChanged(int state);
|
||||||
|
@ -340,6 +354,7 @@ private:
|
||||||
bool hasAlertOnNotification_;
|
bool hasAlertOnNotification_;
|
||||||
bool avatarCircles_;
|
bool avatarCircles_;
|
||||||
bool decryptSidebar_;
|
bool decryptSidebar_;
|
||||||
|
SpaceNotificationOptions spaceNotifications_;
|
||||||
bool privacyScreen_;
|
bool privacyScreen_;
|
||||||
int privacyScreenTimeout_;
|
int privacyScreenTimeout_;
|
||||||
bool shareKeysWithTrustedUsers_;
|
bool shareKeysWithTrustedUsers_;
|
||||||
|
@ -424,6 +439,7 @@ class UserSettingsModel : public QAbstractListModel
|
||||||
GroupView,
|
GroupView,
|
||||||
SortByImportance,
|
SortByImportance,
|
||||||
DecryptSidebar,
|
DecryptSidebar,
|
||||||
|
SpaceNotifications,
|
||||||
|
|
||||||
TraySection,
|
TraySection,
|
||||||
Tray,
|
Tray,
|
||||||
|
|
Loading…
Reference in a new issue