Add space notification configuration
This commit is contained in:
parent
c2b6728955
commit
863eaa1910
4 changed files with 92 additions and 7 deletions
|
|
@ -88,7 +88,15 @@ 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();
|
||||
privacyScreen_ = settings.value(QStringLiteral("user/privacy_screen"), false).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();
|
||||
privacyScreenTimeout_ =
|
||||
settings.value(QStringLiteral("user/privacy_screen_timeout"), 0).toInt();
|
||||
exposeDBusApi_ = settings.value(QStringLiteral("user/expose_dbus_api"), false).toBool();
|
||||
|
|
@ -416,6 +424,16 @@ UserSettings::setDecryptSidebar(bool state)
|
|||
save();
|
||||
}
|
||||
|
||||
void
|
||||
UserSettings::setSpaceNotifications(SpaceNotificationOptions state)
|
||||
{
|
||||
if (state == spaceNotifications_)
|
||||
return;
|
||||
spaceNotifications_ = state;
|
||||
emit spaceNotificationsChanged(state);
|
||||
save();
|
||||
}
|
||||
|
||||
void
|
||||
UserSettings::setPrivacyScreen(bool state)
|
||||
{
|
||||
|
|
@ -777,6 +795,9 @@ 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("privacy_screen"), privacyScreen_);
|
||||
settings.setValue(QStringLiteral("privacy_screen_timeout"), privacyScreenTimeout_);
|
||||
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");
|
||||
case DecryptSidebar:
|
||||
return tr("Decrypt messages in sidebar");
|
||||
case SpaceNotifications:
|
||||
return tr("Show message counts for spaces");
|
||||
case PrivacyScreen:
|
||||
return tr("Privacy Screen");
|
||||
case PrivacyScreenTimeout:
|
||||
|
|
@ -1053,6 +1076,8 @@ UserSettingsModel::data(const QModelIndex &index, int role) const
|
|||
return i->openVideoExternal();
|
||||
case DecryptSidebar:
|
||||
return i->decryptSidebar();
|
||||
case SpaceNotifications:
|
||||
return static_cast<int>(i->spaceNotifications());
|
||||
case PrivacyScreen:
|
||||
return i->privacyScreen();
|
||||
case PrivacyScreenTimeout:
|
||||
|
|
@ -1208,6 +1233,9 @@ UserSettingsModel::data(const QModelIndex &index, int role) const
|
|||
case DecryptSidebar:
|
||||
return tr("Decrypt the messages shown in the sidebar.\nOnly affects messages in "
|
||||
"encrypted chats.");
|
||||
case SpaceNotifications:
|
||||
return tr(
|
||||
"Choose where to show the total number of notifications contained within a space.");
|
||||
case PrivacyScreen:
|
||||
return tr("When the window loses focus, the timeline will\nbe blurred.");
|
||||
case MobileMode:
|
||||
|
|
@ -1283,6 +1311,7 @@ UserSettingsModel::data(const QModelIndex &index, int role) const
|
|||
case CameraResolution:
|
||||
case CameraFrameRate:
|
||||
case Ringtone:
|
||||
case SpaceNotifications:
|
||||
return Options;
|
||||
case TimelineMaxWidth:
|
||||
case PrivacyScreenTimeout:
|
||||
|
|
@ -1409,7 +1438,7 @@ UserSettingsModel::data(const QModelIndex &index, int role) const
|
|||
return fontDb.families();
|
||||
case EmojiFont:
|
||||
return fontDb.families(QFontDatabase::WritingSystem::Symbol);
|
||||
case Ringtone:
|
||||
case Ringtone: {
|
||||
QStringList l{
|
||||
QStringLiteral("Mute"),
|
||||
QStringLiteral("Default"),
|
||||
|
|
@ -1419,6 +1448,12 @@ 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 rooms only)"),
|
||||
QStringLiteral("Off")};
|
||||
}
|
||||
} else if (role == Good) {
|
||||
switch (index.row()) {
|
||||
case OnlineBackupKey:
|
||||
|
|
@ -1624,6 +1659,15 @@ UserSettingsModel::setData(const QModelIndex &index, const QVariant &value, int
|
|||
return false;
|
||||
}
|
||||
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: {
|
||||
if (value.userType() == QMetaType::Bool) {
|
||||
i->setPrivacyScreen(value.toBool());
|
||||
|
|
@ -1936,7 +1980,9 @@ UserSettingsModel::UserSettingsModel(QObject *p)
|
|||
connect(s.get(), &UserSettings::decryptSidebarChanged, this, [this]() {
|
||||
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]() {
|
||||
emit dataChanged(index(Tray), index(Tray), {Value});
|
||||
emit dataChanged(index(StartInTray), index(StartInTray), {Enabled});
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue