Added font selection box
This commit is contained in:
parent
005ddd23cf
commit
c0e20dacf1
8 changed files with 164 additions and 2 deletions
|
|
@ -2258,5 +2258,15 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
|||
"ktg_settings_sticker_height" = "Sticker height: {pixels}px";
|
||||
"ktg_settings_emoji_outline" = "Big emoji outline";
|
||||
"ktg_settings_always_show_scheduled" = "Always show scheduled";
|
||||
"ktg_settings_fonts" = "Change application fonts";
|
||||
|
||||
"ktg_fonts_title" = "Fonts";
|
||||
"ktg_fonts_reset" = "Reset";
|
||||
"ktg_fonts_about" = "If you want to use \"Bold\" font for your semibold, do not put \"Bold\" in font name, use \"Make semibold bold\" option.\n\nYou will need to restart app to apply and see changes.";
|
||||
|
||||
"ktg_fonts_main" = "Main font";
|
||||
"ktg_fonts_semibold" = "Semibold font";
|
||||
"ktg_fonts_semibold_is_bold" = "Make semibold bold";
|
||||
"ktg_fonts_monospaced" = "Monospaced font";
|
||||
|
||||
// Keys finished
|
||||
|
|
|
|||
|
|
@ -31,5 +31,13 @@
|
|||
"ktg_settings_chats": "Чаты",
|
||||
"ktg_settings_sticker_height": "Высота стикеров: {pixels} пикс.",
|
||||
"ktg_settings_emoji_outline": "Обводка у больших эмодзи",
|
||||
"ktg_settings_always_show_scheduled": "Всегда показывать отложенные"
|
||||
"ktg_settings_always_show_scheduled": "Всегда показывать отложенные",
|
||||
"ktg_settings_fonts": "Изменить шрифты приложения",
|
||||
"ktg_fonts_title": "Шрифты",
|
||||
"ktg_fonts_reset": "Сброс",
|
||||
"ktg_fonts_about": "Если вы хотите использовать жирное начертание для полужирного шрифта, не пишите «Bold» в названии, используйте настройку «Сделать полужирный жирным».\n\nДля применения и просмотра изменений требуется перезапуск.",
|
||||
"ktg_fonts_main": "Основной шрифт",
|
||||
"ktg_fonts_semibold": "Полужирный шрифт",
|
||||
"ktg_fonts_semibold_is_bold": "Сделать полужирный жирным",
|
||||
"ktg_fonts_monospaced": "Моноширинный шрифт"
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1030,3 +1030,10 @@ customBadgeField: InputField(defaultInputField) {
|
|||
|
||||
heightMin: 32px;
|
||||
}
|
||||
|
||||
fontsBoxTextStyle: TextStyle(defaultTextStyle) {
|
||||
font: font(13px);
|
||||
linkFont: font(13px);
|
||||
linkFontOver: font(13px underline);
|
||||
}
|
||||
|
||||
|
|
|
|||
85
Telegram/SourceFiles/boxes/fonts_box.cpp
Normal file
85
Telegram/SourceFiles/boxes/fonts_box.cpp
Normal file
|
|
@ -0,0 +1,85 @@
|
|||
/*
|
||||
This file is part of Kotatogram Desktop,
|
||||
the unofficial app based on Telegram Desktop.
|
||||
|
||||
For license and copyright information please follow this link:
|
||||
https://github.com/kotatogram/kotatogram-desktop/blob/dev/LEGAL
|
||||
*/
|
||||
#include "boxes/fonts_box.h"
|
||||
|
||||
#include "ui/widgets/checkbox.h"
|
||||
#include "ui/widgets/buttons.h"
|
||||
#include "ui/widgets/input_fields.h"
|
||||
#include "styles/style_boxes.h"
|
||||
#include "lang/lang_keys.h"
|
||||
|
||||
FontsBox::FontsBox(QWidget* parent)
|
||||
: _mainFontName(this, st::defaultInputField, tr::ktg_fonts_main())
|
||||
, _semiboldFontName(this, st::defaultInputField, tr::ktg_fonts_semibold())
|
||||
, _semiboldIsBold(this, tr::ktg_fonts_semibold_is_bold(tr::now), cSemiboldFontIsBold())
|
||||
, _monospacedFontName(this, st::defaultInputField, tr::ktg_fonts_monospaced())
|
||||
, _about(st::boxWidth - st::boxPadding.left() * 1.5)
|
||||
{
|
||||
}
|
||||
|
||||
void FontsBox::prepare() {
|
||||
setTitle(tr::ktg_fonts_title());
|
||||
|
||||
addButton(tr::lng_settings_save(), [=] { save(); });
|
||||
addButton(tr::lng_cancel(), [=] { closeBox(); });
|
||||
|
||||
addLeftButton(tr::ktg_fonts_reset(), [=] { resetToDefault(); });
|
||||
|
||||
if (!cMainFont().isEmpty()) {
|
||||
_mainFontName->setText(cMainFont());
|
||||
}
|
||||
|
||||
if (!cSemiboldFont().isEmpty()) {
|
||||
_semiboldFontName->setText(cSemiboldFont());
|
||||
}
|
||||
|
||||
if (!cMonospaceFont().isEmpty()) {
|
||||
_monospacedFontName->setText(cMonospaceFont());
|
||||
}
|
||||
|
||||
_about.setText(st::fontsBoxTextStyle, tr::ktg_fonts_about(tr::now));
|
||||
_aboutHeight = _about.countHeight(st::boxWidth - st::boxPadding.left() * 1.5);
|
||||
|
||||
setDimensions(st::boxWidth, _mainFontName->height() + _semiboldFontName->height() + _semiboldIsBold->height() + _monospacedFontName->height() + _aboutHeight + st::boxLittleSkip * 2);
|
||||
}
|
||||
|
||||
|
||||
void FontsBox::paintEvent(QPaintEvent *e) {
|
||||
BoxContent::paintEvent(e);
|
||||
|
||||
Painter p(this);
|
||||
int32 w = st::boxWidth - st::boxPadding.left() * 1.5;
|
||||
int32 abouty = _mainFontName->height() + _semiboldFontName->height() + _semiboldIsBold->height() + _monospacedFontName->height() + st::boxLittleSkip * 2;
|
||||
p.setPen(st::windowSubTextFg);
|
||||
_about.drawLeft(p, st::boxPadding.left(), abouty, w, width());
|
||||
|
||||
}
|
||||
|
||||
void FontsBox::resizeEvent(QResizeEvent *e) {
|
||||
BoxContent::resizeEvent(e);
|
||||
|
||||
int32 w = st::boxWidth - st::boxPadding.left() - st::boxPadding.right();
|
||||
_mainFontName->resize(w, _mainFontName->height());
|
||||
_mainFontName->moveToLeft(st::boxPadding.left(), 0);
|
||||
_semiboldFontName->resize(w, _semiboldFontName->height());
|
||||
_semiboldFontName->moveToLeft(st::boxPadding.left(), _mainFontName->y() + _mainFontName->height());
|
||||
_semiboldIsBold->resize(w, _semiboldIsBold->height());
|
||||
_semiboldIsBold->moveToLeft(st::boxPadding.left(), _semiboldFontName->y() + _semiboldFontName->height() + st::boxLittleSkip);
|
||||
_monospacedFontName->resize(w, _monospacedFontName->height());
|
||||
_monospacedFontName->moveToLeft(st::boxPadding.left(), _semiboldIsBold->y() + _semiboldIsBold->height());
|
||||
}
|
||||
|
||||
void FontsBox::setInnerFocus() {
|
||||
_mainFontName->setFocusFast();
|
||||
}
|
||||
|
||||
void FontsBox::save() {
|
||||
}
|
||||
|
||||
void FontsBox::resetToDefault() {
|
||||
}
|
||||
38
Telegram/SourceFiles/boxes/fonts_box.h
Normal file
38
Telegram/SourceFiles/boxes/fonts_box.h
Normal file
|
|
@ -0,0 +1,38 @@
|
|||
/*
|
||||
This file is part of Kotatogram Desktop,
|
||||
the unofficial app based on Telegram Desktop.
|
||||
|
||||
For license and copyright information please follow this link:
|
||||
https://github.com/kotatogram/kotatogram-desktop/blob/dev/LEGAL
|
||||
*/
|
||||
#pragma once
|
||||
|
||||
#include "boxes/abstract_box.h"
|
||||
|
||||
namespace Ui {
|
||||
class Checkbox;
|
||||
class InputField;
|
||||
} // namespace Ui
|
||||
|
||||
class FontsBox : public BoxContent {
|
||||
public:
|
||||
FontsBox(QWidget* parent);
|
||||
|
||||
protected:
|
||||
void prepare() override;
|
||||
void setInnerFocus() override;
|
||||
|
||||
void paintEvent(QPaintEvent *e) override;
|
||||
void resizeEvent(QResizeEvent *e) override;
|
||||
private:
|
||||
void save();
|
||||
void resetToDefault();
|
||||
|
||||
object_ptr<Ui::InputField> _mainFontName = { nullptr };
|
||||
object_ptr<Ui::InputField> _semiboldFontName = { nullptr };
|
||||
object_ptr<Ui::Checkbox> _semiboldIsBold = { nullptr };
|
||||
object_ptr<Ui::InputField> _monospacedFontName = { nullptr };
|
||||
Ui::Text::String _about;
|
||||
|
||||
int _aboutHeight = 0;
|
||||
};
|
||||
|
|
@ -16,6 +16,7 @@ https://github.com/kotatogram/kotatogram-desktop/blob/dev/LEGAL
|
|||
#include "ui/widgets/continuous_sliders.h"
|
||||
#include "ui/text/text_utilities.h" // Ui::Text::ToUpper
|
||||
#include "boxes/connection_box.h"
|
||||
#include "boxes/fonts_box.h"
|
||||
#include "boxes/about_box.h"
|
||||
#include "boxes/confirm_box.h"
|
||||
#include "info/profile/info_profile_button.h"
|
||||
|
|
@ -95,7 +96,15 @@ void SetupKotatoChats(not_null<Ui::VerticalLayout*> container) {
|
|||
cSetAlwaysShowScheduled(enabled);
|
||||
Notify::showScheduledButtonChanged();
|
||||
KotatoSettings::Write();
|
||||
}, container->lifetime());
|
||||
}, container->lifetime());
|
||||
|
||||
AddButton(
|
||||
container,
|
||||
tr::ktg_settings_fonts(),
|
||||
st::settingsButton
|
||||
)->addClickHandler([=] {
|
||||
Ui::show(Box<FontsBox>());
|
||||
});
|
||||
|
||||
AddSkip(container);
|
||||
}
|
||||
|
|
@ -119,3 +128,4 @@ void Kotato::setupContent(not_null<Window::SessionController*> controller) {
|
|||
}
|
||||
|
||||
} // namespace Settings
|
||||
|
||||
|
|
|
|||
|
|
@ -9,6 +9,8 @@ https://github.com/kotatogram/kotatogram-desktop/blob/dev/LEGAL
|
|||
|
||||
#include "settings/settings_common.h"
|
||||
|
||||
class BoxContent;
|
||||
|
||||
namespace Settings {
|
||||
|
||||
void SetupKotatoChats(not_null<Ui::VerticalLayout*> container);
|
||||
|
|
|
|||
|
|
@ -58,6 +58,8 @@
|
|||
<(src_loc)/boxes/edit_color_box.h
|
||||
<(src_loc)/boxes/edit_privacy_box.cpp
|
||||
<(src_loc)/boxes/edit_privacy_box.h
|
||||
<(src_loc)/boxes/fonts_box.cpp
|
||||
<(src_loc)/boxes/fonts_box.h
|
||||
<(src_loc)/boxes/generic_box.cpp
|
||||
<(src_loc)/boxes/generic_box.h
|
||||
<(src_loc)/boxes/language_box.cpp
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue