@ -49,7 +49,7 @@ UserSettings::load()
isTypingNotificationsEnabled_ = settings . value ( " user/typing_notifications " , true ) . toBool ( ) ;
isReadReceiptsEnabled_ = settings . value ( " user/read_receipts " , true ) . toBool ( ) ;
theme_ = settings . value ( " user/theme " , " light " ) . toString ( ) ;
font_ = settings . value ( " user/font_family " , " default " ) . toString ( ) ;
baseFontSize_ = settings . value ( " user/font_size " , QFont ( ) . pointSizeF ( ) ) . toDouble ( ) ;
applyTheme ( ) ;
@ -62,6 +62,13 @@ UserSettings::setFontSize(double size)
save ( ) ;
}
void
UserSettings : : setFontFamily ( QString family )
{
font_ = family ;
save ( ) ;
}
void
UserSettings : : setTheme ( QString theme )
{
@ -106,6 +113,7 @@ UserSettings::save()
settings . setValue ( " group_view " , isGroupViewEnabled_ ) ;
settings . setValue ( " desktop_notifications " , hasDesktopNotifications_ ) ;
settings . setValue ( " theme " , theme ( ) ) ;
settings . setValue ( " font_family " , font_ ) ;
settings . endGroup ( ) ;
}
@ -220,6 +228,20 @@ UserSettingsPage::UserSettingsPage(QSharedPointer<UserSettings> settings, QWidge
fontSizeOptionLayout - > addWidget ( fontSizeLabel ) ;
fontSizeOptionLayout - > addWidget ( fontSizeCombo_ , 0 , Qt : : AlignRight ) ;
auto fontFamilyOptionLayout = new QHBoxLayout ;
fontFamilyOptionLayout - > setContentsMargins ( 0 , OptionMargin , 0 , OptionMargin ) ;
auto fontFamilyLabel = new QLabel ( tr ( " Font Family " ) , this ) ;
fontFamilyLabel - > setFont ( font ) ;
fontSelectionCombo_ = new QComboBox ( this ) ;
QFontDatabase fontDb ;
auto fontFamilies = fontDb . families ( ) ;
for ( const auto & family : fontFamilies ) {
fontSelectionCombo_ - > addItem ( family ) ;
}
fontFamilyOptionLayout - > addWidget ( fontFamilyLabel ) ;
fontFamilyOptionLayout - > addWidget ( fontSelectionCombo_ , 0 , Qt : : AlignRight ) ;
auto themeOptionLayout_ = new QHBoxLayout ;
themeOptionLayout_ - > setContentsMargins ( 0 , OptionMargin , 0 , OptionMargin ) ;
auto themeLabel_ = new QLabel ( tr ( " Theme " ) , this ) ;
@ -319,6 +341,7 @@ UserSettingsPage::UserSettingsPage(QSharedPointer<UserSettings> settings, QWidge
mainLayout_ - > addLayout ( scaleFactorOptionLayout ) ;
mainLayout_ - > addLayout ( fontSizeOptionLayout ) ;
mainLayout_ - > addLayout ( fontFamilyOptionLayout ) ;
mainLayout_ - > addWidget ( new HorizontalLine ( this ) ) ;
mainLayout_ - > addLayout ( themeOptionLayout_ ) ;
mainLayout_ - > addWidget ( new HorizontalLine ( this ) ) ;
@ -355,7 +378,9 @@ UserSettingsPage::UserSettingsPage(QSharedPointer<UserSettings> settings, QWidge
connect ( fontSizeCombo_ ,
static_cast < void ( QComboBox : : * ) ( const QString & ) > ( & QComboBox : : activated ) ,
[ this ] ( const QString & size ) { settings_ - > setFontSize ( size . trimmed ( ) . toDouble ( ) ) ; } ) ;
connect ( fontSelectionCombo_ ,
static_cast < void ( QComboBox : : * ) ( const QString & ) > ( & QComboBox : : activated ) ,
[ this ] ( const QString & family ) { settings_ - > setFontFamily ( family . trimmed ( ) ) ; } ) ;
connect ( trayToggle_ , & Toggle : : toggled , this , [ this ] ( bool isDisabled ) {
settings_ - > setTray ( ! isDisabled ) ;
if ( isDisabled ) {