Fix presence unknown type warning

This commit is contained in:
Nicolas Werner 2021-01-19 03:16:59 +01:00
parent 38dee9b7f9
commit 74c9af0432
2 changed files with 11 additions and 10 deletions

View File

@ -97,12 +97,14 @@ UserSettings::load(std::optional<QString> profile)
decryptSidebar_ = settings.value("user/decrypt_sidebar", true).toBool(); decryptSidebar_ = settings.value("user/decrypt_sidebar", true).toBool();
shareKeysWithTrustedUsers_ = shareKeysWithTrustedUsers_ =
settings.value("user/share_keys_with_trusted_users", true).toBool(); settings.value("user/share_keys_with_trusted_users", true).toBool();
mobileMode_ = settings.value("user/mobile_mode", false).toBool(); mobileMode_ = settings.value("user/mobile_mode", false).toBool();
emojiFont_ = settings.value("user/emoji_font_family", "default").toString(); emojiFont_ = settings.value("user/emoji_font_family", "default").toString();
baseFontSize_ = settings.value("user/font_size", QFont().pointSizeF()).toDouble(); baseFontSize_ = settings.value("user/font_size", QFont().pointSizeF()).toDouble();
presence_ = auto tempPresence = settings.value("user/presence", "").toString().toStdString();
settings.value("user/presence", QVariant::fromValue(Presence::AutomaticPresence)) auto presenceValue = QMetaEnum::fromType<Presence>().keyToValue(tempPresence.c_str());
.value<Presence>(); if (presenceValue < 0)
presenceValue = 0;
presence_ = static_cast<Presence>(presenceValue);
ringtone_ = settings.value("user/ringtone", "Default").toString(); ringtone_ = settings.value("user/ringtone", "Default").toString();
microphone_ = settings.value("user/microphone", QString()).toString(); microphone_ = settings.value("user/microphone", QString()).toString();
camera_ = settings.value("user/camera", QString()).toString(); camera_ = settings.value("user/camera", QString()).toString();
@ -542,7 +544,9 @@ UserSettings::save()
settings.setValue("theme", theme()); settings.setValue("theme", theme());
settings.setValue("font_family", font_); settings.setValue("font_family", font_);
settings.setValue("emoji_font_family", emojiFont_); settings.setValue("emoji_font_family", emojiFont_);
settings.setValue("presence", QVariant::fromValue(presence_)); settings.setValue("presence",
QString::fromUtf8(QMetaEnum::fromType<Presence>().valueToKey(
static_cast<int>(presence_))));
settings.setValue("ringtone", ringtone_); settings.setValue("ringtone", ringtone_);
settings.setValue("microphone", microphone_); settings.setValue("microphone", microphone_);
settings.setValue("camera", camera_); settings.setValue("camera", camera_);

View File

@ -106,9 +106,6 @@ createCacheDirectory()
int int
main(int argc, char *argv[]) main(int argc, char *argv[])
{ {
// needed for settings so need to register before any settings are read to prevent warnings
qRegisterMetaType<UserSettings::Presence>();
QCoreApplication::setApplicationName("nheko"); QCoreApplication::setApplicationName("nheko");
QCoreApplication::setApplicationVersion(nheko::version); QCoreApplication::setApplicationVersion(nheko::version);
QCoreApplication::setOrganizationName("nheko"); QCoreApplication::setOrganizationName("nheko");