feat: add new app icons

fix: refactor font picker
This commit is contained in:
ZavaruKitsu 2023-09-28 00:30:59 +03:00
parent 8fecdfad21
commit e144d5cb10
46 changed files with 189 additions and 149 deletions

Binary file not shown.

After

Width:  |  Height:  |  Size: 8.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 8.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 15 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 11 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 6.3 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 8.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 30 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 30 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 32 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 9.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 10 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 19 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 12 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 6.9 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 9.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 9.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 9.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 17 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 8.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 9.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 17 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 8.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 16 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 7 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 4.6 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 6.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 8.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 9.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 17 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 18 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 18 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 22 KiB

View file

@ -4184,12 +4184,15 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
"ayu_RegexFilters" = "Message Filters";
"ayu_RegexFiltersAmount" = "filters";
"ayu_RegexFiltersHeader" = "Filters";
"ayu_RegexFiltersShared" = "Shared filters";
"ayu_FiltersHideFromBlocked" = "Hide from blocked users";
"ayu_RegexFiltersEnableInChats" = "Enable in chats";
"ayu_RegexFiltersCaseInsensitive" = "Case insensitive expressions";
"ayu_FiltersHideFromBlockedNote" = "Message filters were enabled.";
"ayu_RegexFiltersEnableSharedInChats" = "Enable shared filters in chats";
"ayu_RegexFiltersAdd" = "Add filter";
"ayu_RegexFiltersEdit" = "Edit filter";
"ayu_RegexFiltersPlaceholder" = "Expression";
"ayu_EnableExpression" = "Enable expression";
"ayu_CaseInsensitiveExpression" = "Case insensitive expression";
"ayu_RegexFiltersAddError" = "Regex syntax error";
"ayu_AyuSyncHeader" = "AyuSync";
"ayu_AyuSyncStatusTitle" = "Sync status";
@ -4215,6 +4218,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
"ayu_IconAlternative" = "AyuGram Alt";
"ayu_IconNothing" = "Nothing";
"ayu_WALMode" = "Enable WAL mode";
"ayu_PushNotificationCount" = "FCM notifications received";
"ayu_ClearAyuDatabase" = "Clear Ayu Database";
"ayu_ClearAyuDatabaseNotification" = "AyuGram database cleared";
"ayu_ClearAyuAttachments" = "Clear Ayu Attachments";
@ -4240,6 +4244,8 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
"ayu_EditsHistoryTitle" = "Edits history";
"ayu_EditsHistoryMenuText" = "History";
"ayu_ClearDeletedMenuText" = "Clear Deleted";
"ayu_ViewFiltersMenuText" = "View Filters";
"ayu_OneViewTTL" = "one view";
"ayu_ReadUntilMenuText" = "Read Message";
"ayu_DeleteKeepLocally" = "Keep locally";
"ayu_BoxActionReset" = "Reset";
@ -4254,6 +4260,10 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
"ayu_HideNextViewsDescriptionAyu" = "Hide my views forever, until Ghost Mode disabled.";
"ayu_EnableGhostModeStories" = "Enable Ghost Mode";
"ayu_GhostModeIsActive" = "Ghost Mode Is Active";
"ayu_MainFont" = "Application font";
"ayu_MonospaceFont" = "Monospace font";
"ayu_FontDefault" = "Default";
"ayu_CustomizeFontTitle" = "Customize font";
"ayu_AyuForwardStatusForwarding" = "Forwarding messages…";
"ayu_AyuForwardStatusLoadingMedia" = "Loading media…";
"ayu_AyuForwardForwardingDescription" = "Please keep this window open while AyuGram is forwarding your messages.";

View file

@ -1,13 +1,28 @@
<RCC>
<qresource prefix="/gui">
<file alias="art/ayu/default/logo256.png">../../art/ayu/default/logo256.png</file>
<file alias="art/ayu/default/logo256_no_margin.png">../../art/ayu/default/logo256_no_margin.png</file>
<file alias="art/ayu/default/logo256_no_margin.ico">../../art/ayu/default/logo256_no_margin.ico</file>
<file alias="art/ayu/alt/logo256.png">../../art/ayu/alt/logo256.png</file>
<file alias="art/ayu/alt/logo256_no_margin.png">../../art/ayu/alt/logo256_no_margin.png</file>
<file alias="art/ayu/alt/logo256_no_margin.ico">../../art/ayu/alt/logo256_no_margin.ico</file>
<file alias="art/ayu/nothing/logo256.png">../../art/ayu/nothing/logo256.png</file>
<file alias="art/ayu/nothing/logo256_no_margin.png">../../art/ayu/nothing/logo256_no_margin.png</file>
<file alias="art/ayu/nothing/logo256_no_margin.ico">../../art/ayu/nothing/logo256_no_margin.ico</file>
<file alias="art/ayu/alt/app.png">../../art/ayu/alt/app.png</file>
<file alias="art/ayu/alt/app_preview.png">../../art/ayu/alt/app_preview.png</file>
<file alias="art/ayu/alt/app_icon.ico">../../art/ayu/alt/app_icon.ico</file>
<file alias="art/ayu/bard/app.png">../../art/ayu/bard/app.png</file>
<file alias="art/ayu/bard/app_preview.png">../../art/ayu/bard/app_preview.png</file>
<file alias="art/ayu/bard/app_icon.ico">../../art/ayu/bard/app_icon.ico</file>
<file alias="art/ayu/default/app.png">../../art/ayu/default/app.png</file>
<file alias="art/ayu/default/app_preview.png">../../art/ayu/default/app_preview.png</file>
<file alias="art/ayu/default/app_icon.ico">../../art/ayu/default/app_icon.ico</file>
<file alias="art/ayu/discord/app.png">../../art/ayu/discord/app.png</file>
<file alias="art/ayu/discord/app_preview.png">../../art/ayu/discord/app_preview.png</file>
<file alias="art/ayu/discord/app_icon.ico">../../art/ayu/discord/app_icon.ico</file>
<file alias="art/ayu/extera/app.png">../../art/ayu/extera/app.png</file>
<file alias="art/ayu/extera/app_preview.png">../../art/ayu/extera/app_preview.png</file>
<file alias="art/ayu/extera/app_icon.ico">../../art/ayu/extera/app_icon.ico</file>
<file alias="art/ayu/nothing/app.png">../../art/ayu/nothing/app.png</file>
<file alias="art/ayu/nothing/app_preview.png">../../art/ayu/nothing/app_preview.png</file>
<file alias="art/ayu/nothing/app_icon.ico">../../art/ayu/nothing/app_icon.ico</file>
<file alias="art/ayu/spotify/app.png">../../art/ayu/spotify/app.png</file>
<file alias="art/ayu/spotify/app_preview.png">../../art/ayu/spotify/app_preview.png</file>
<file alias="art/ayu/spotify/app_icon.ico">../../art/ayu/spotify/app_icon.ico</file>
<file alias="art/ayu/yaplus/app.png">../../art/ayu/yaplus/app.png</file>
<file alias="art/ayu/yaplus/app_preview.png">../../art/ayu/yaplus/app_preview.png</file>
<file alias="art/ayu/yaplus/app_icon.ico">../../art/ayu/yaplus/app_icon.ico</file>
</qresource>
</RCC>

View file

@ -40,10 +40,10 @@ void initDatabase()
void initFonts()
{
auto ayuSettings = AyuSettings::getInstance();
auto settings = &AyuSettings::getInstance();
AyuFonts::setCommonFont(ayuSettings.commonFont);
AyuFonts::setMonoFont(ayuSettings.monoFont);
AyuFonts::setMainFont(settings->mainFont);
AyuFonts::setMonoFont(settings->monoFont);
}
void init()

View file

@ -273,9 +273,9 @@ void AyuGramSettings::set_showGhostToggleInDrawer(bool val)
showGhostToggleInDrawer = val;
}
void AyuGramSettings::set_commonFont(QString val)
void AyuGramSettings::set_mainFont(QString val)
{
commonFont = val;
mainFont = val;
}
void AyuGramSettings::set_monoFont(QString val)

View file

@ -18,8 +18,18 @@ const auto DEFAULT_ICON = QString("default");
const auto ALT_ICON = QString("alt");
const auto DISCORD_ICON = QString("discord");
const auto SPOTIFY_ICON = QString("spotify");
const auto EXTERA_ICON = QString("extera");
const auto NOTHING_ICON = QString("nothing");
const auto BARD_ICON = QString("bard");
const auto YAPLUS_ICON = QString("yaplus");
class AyuGramSettings
{
public:
@ -51,7 +61,7 @@ public:
editedMark = tr::lng_edited(tr::now);
recentStickersCount = 20;
showGhostToggleInDrawer = true;
commonFont = "";
mainFont = "";
monoFont = "";
/*
@ -88,7 +98,7 @@ public:
QString editedMark;
int recentStickersCount;
bool showGhostToggleInDrawer;
QString commonFont;
QString mainFont;
QString monoFont;
int showPeerId;
bool hideAllChatsFolder;
@ -136,7 +146,7 @@ public:
void set_showGhostToggleInDrawer(bool val);
void set_commonFont(QString val);
void set_mainFont(QString val);
void set_monoFont(QString val);
@ -173,7 +183,7 @@ NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE_WITH_DEFAULT(
editedMark,
recentStickersCount,
showGhostToggleInDrawer,
commonFont,
mainFont,
monoFont,
showPeerId,
showMessageSeconds,

View file

@ -28,7 +28,7 @@ void loadAppIco()
f.remove();
}
f.close();
QFile::copy(qsl(":/gui/art/ayu/%1/logo256_no_margin.ico").arg(settings->appIcon), tempIconPath);
QFile::copy(qsl(":/gui/art/ayu/%1/app_icon.ico").arg(settings->appIcon), tempIconPath);
}
void loadIcons()
@ -37,24 +37,14 @@ void loadIcons()
if (LAST_LOADED_NAME != settings->appIcon) {
LAST_LOADED_NAME = settings->appIcon;
LAST_LOADED = QImage(qsl(":/gui/art/ayu/%1/logo256.png").arg(settings->appIcon));
LAST_LOADED_NO_MARGIN = QImage(qsl(":/gui/art/ayu/%1/logo256_no_margin.png").arg(settings->appIcon));
LAST_LOADED = QImage(qsl(":/gui/art/ayu/%1/app.png").arg(settings->appIcon));
LAST_LOADED_NO_MARGIN = QImage(qsl(":/gui/art/ayu/%1/app_preview.png").arg(settings->appIcon));
}
}
QImage logoPreview()
QImage loadPreview(QString name)
{
return QImage(qsl(":/gui/art/ayu/default/logo256.png"));
}
QImage logoAltPreview()
{
return QImage(qsl(":/gui/art/ayu/alt/logo256.png"));
}
QImage logoNothingPreview()
{
return QImage(qsl(":/gui/art/ayu/nothing/logo256.png"));
return QImage(qsl(":/gui/art/ayu/%1/app_preview.png").arg(name));
}
QString currentAppLogoName()

View file

@ -8,9 +8,7 @@
void loadAppIco();
QImage logoPreview();
QImage logoAltPreview();
QImage logoNothingPreview();
QImage loadPreview(QString name);
QString currentAppLogoName();
QImage currentAppLogo();

View file

@ -1,14 +1,10 @@
// This is the source code of AyuGram for Desktop.
//
// Created by MaxPlays on 12/09/2023.
// We do not and cannot prevent the use of our code,
// but be respectful and credit the original author.
//
/*
This file is part of Telegram Desktop,
the official desktop application for the Telegram messaging service.
For license and copyright information please follow this link:
https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
*/
#include "boxes/language_box.h"
// Copyright @Radolyn, 2023
#include "font_selector.h"
#include "data/data_peer_values.h"
#include "ui/widgets/checkbox.h"
@ -41,7 +37,6 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include "styles/style_info.h"
#include "styles/style_passport.h"
#include "styles/style_chat_helpers.h"
#include "font_selector.h"
#include <QtGui/QGuiApplication>
#include <QFontDatabase>
@ -58,7 +53,7 @@ struct Font
namespace AyuUi
{
class Rows: public Ui::RpWidget
class Rows : public Ui::RpWidget
{
public:
Rows(
@ -229,7 +224,7 @@ private:
};
class Content: public Ui::RpWidget
class Content : public Ui::RpWidget
{
public:
Content(
@ -263,7 +258,7 @@ std::vector<Font> PrepareFonts()
auto fonts = std::vector<Font>();
QFontDatabase base;
for (const auto &font: base.families()) {
for (const auto &font : base.families()) {
Font fontItem = {
.FontName=font,
.id=font
@ -289,7 +284,7 @@ Rows::Rows(
Qt::LayoutDirectionAuto
};
_rows.reserve(data.size());
for (const auto &item: data) {
for (const auto &item : data) {
_rows.push_back(Row{item});
auto &row = _rows.back();
row.check = std::make_unique<Ui::RadioView>(
@ -448,7 +443,7 @@ void Rows::mouseReleaseEvent(QMouseEvent *e)
{
showMenu(data.index);
}, [](v::null_t)
{});
{ });
}
}
@ -544,14 +539,14 @@ void Rows::filter(const QString &query)
const QStringList &haystack,
const QString &needle)
{
for (const auto &item: haystack) {
for (const auto &item : haystack) {
if (item.startsWith(needle)) {
return true;
}
}
return false;
};
for (const auto &needle: needles) {
for (const auto &needle : needles) {
if (!find(haystack, needle)) {
return true;
}
@ -562,7 +557,7 @@ void Rows::filter(const QString &query)
if (!_query.isEmpty()) {
_filtered.clear();
_filtered.reserve(_rows.size());
for (auto &row: _rows) {
for (auto &row : _rows) {
if (!skip(row.keywords, _query)) {
_filtered.push_back(&row);
}
@ -617,7 +612,7 @@ rpl::producer<Font> Rows::activations() const
void Rows::changeChosen(const QString &chosen)
{
for (const auto &row: _rows) {
for (const auto &row : _rows) {
row.check->setChecked(row.data.id == chosen, anim::type::normal);
}
}
@ -871,12 +866,12 @@ void Content::setupContent(
{
using namespace rpl::mappers;
const auto current = AyuFonts::getCommonFont();
const auto current = AyuFonts::getMainFont();
const auto content = Ui::CreateChild<Ui::VerticalLayout>(this);
const auto add = [&](const std::vector<Font> &list)
{
if (list.empty()) {
return (Rows *) nullptr;
return (Rows *)nullptr;
}
const auto wrap = content->add(
object_ptr<Ui::SlideWrap<Ui::VerticalLayout>>(
@ -1105,7 +1100,7 @@ void AyuUi::FontSelectorBox::prepare()
closeBox();
});
setTitle(rpl::single(qs("Font customisation")));
setTitle(tr::ayu_CustomizeFontTitle());
const auto topContainer = Ui::CreateChild<Ui::VerticalLayout>(this);
setupTop(topContainer);
@ -1226,5 +1221,4 @@ AyuUi::FontSelectorBox::Show(Window::SessionController *controller, const Fn<voi
Ui::show(Box<FontSelectorBox>(controller, hook));
return result;
}

View file

@ -1,17 +1,9 @@
// This is the source code of AyuGram for Desktop.
//
// Created by MaxPlays on 12/09/2023.
// We do not and cannot prevent the use of our code,
// but be respectful and credit the original author.
//
#ifndef TELEGRAM_FONT_SELECTOR_H
#define TELEGRAM_FONT_SELECTOR_H
/*
This file is part of Telegram Desktop,
the official desktop application for the Telegram messaging service.
For license and copyright information please follow this link:
https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
*/
// Copyright @Radolyn, 2023
#pragma once
#include "lang/lang_cloud_manager.h"
@ -36,10 +28,12 @@ namespace Window
class SessionController;
} // namespace Window
namespace AyuUi
{
class FontSelectorBox: public Ui::BoxContent
class FontSelectorBox : public Ui::BoxContent
{
public:
FontSelectorBox(QWidget *, Window::SessionController *controller, Fn<void(QString font)> hook);
@ -69,5 +63,3 @@ private:
};
}
#endif //TELEGRAM_FONT_SELECTOR_H

View file

@ -20,23 +20,40 @@
#include "ayu/utils/windows_utils.h"
#endif
void drawIcon(QPainter &p, const QImage &icon, int offset, bool selected)
const QVector<QString> icons{
AyuSettings::DEFAULT_ICON,
AyuSettings::ALT_ICON,
AyuSettings::DISCORD_ICON,
AyuSettings::SPOTIFY_ICON,
AyuSettings::EXTERA_ICON,
AyuSettings::NOTHING_ICON,
AyuSettings::BARD_ICON,
AyuSettings::YAPLUS_ICON
};
const auto rows = icons.size() / 4 + std::min(1, icons.size() % 4);
const auto padding = 14;
void drawIcon(QPainter &p, const QImage &icon, int xOffset, int yOffset, bool selected)
{
xOffset += padding;
if (selected) {
p.save();
p.setPen(QPen(st::iconPreviewStroke, 2));
p.drawEllipse(offset + 2, 2, 68, 68);
p.drawEllipse(xOffset + 2, yOffset + 2, 68, 68);
p.restore();
}
auto rect = QRect(offset + 4, 4, 64, 64);
auto rect = QRect(xOffset + 4, yOffset + 4, 64, 64);
p.drawImage(rect, icon);
}
IconPicker::IconPicker(QWidget *parent)
: RpWidget(parent)
{
setMinimumSize(st::boxWidth, 72);
setMinimumSize(st::boxWidth, 72 * rows);
}
void IconPicker::paintEvent(QPaintEvent *e)
@ -44,14 +61,16 @@ void IconPicker::paintEvent(QPaintEvent *e)
Painter p(this);
PainterHighQualityEnabler hq(p);
auto icon1 = logoPreview().scaled(64, 64, Qt::KeepAspectRatio, Qt::SmoothTransformation);
auto icon2 = logoAltPreview().scaled(64, 64, Qt::KeepAspectRatio, Qt::SmoothTransformation);
auto icon3 = logoNothingPreview().scaled(64, 64, Qt::KeepAspectRatio, Qt::SmoothTransformation);
for (int row = 0; row < rows; row++) {
const auto columns = std::min(4, icons.size() - row * 4);
for (int i = 0; i < columns; i++) {
auto const idx = i + row * 4;
// todo: center
drawIcon(p, icon1, 0, currentAppLogoName() == AyuSettings::DEFAULT_ICON);
drawIcon(p, icon2, 0 + 64 + 16, currentAppLogoName() == AyuSettings::ALT_ICON);
drawIcon(p, icon3, 0 + 64 + 16 + 64 + 16, currentAppLogoName() == AyuSettings::NOTHING_ICON);
const auto &iconName = icons[idx];
auto icon = loadPreview(iconName).scaled(64, 64, Qt::KeepAspectRatio, Qt::SmoothTransformation);
drawIcon(p, icon, (64 + 16) * i, row * (64 + 8), currentAppLogoName() == iconName);
}
}
}
void IconPicker::mousePressEvent(QMouseEvent *e)
@ -60,17 +79,22 @@ void IconPicker::mousePressEvent(QMouseEvent *e)
auto changed = false;
auto x = e->pos().x();
if (x <= 64 && settings->appIcon != AyuSettings::DEFAULT_ICON) {
settings->set_appIcon(AyuSettings::DEFAULT_ICON);
changed = true;
}
else if (x >= 64 + 16 && x <= 64 + 16 + 64 && settings->appIcon != AyuSettings::ALT_ICON) {
settings->set_appIcon(AyuSettings::ALT_ICON);
changed = true;
}
else if (x >= 64 + 16 + 64 + 16 && x < 64 + 16 + 64 + 16 + 64 && settings->appIcon != AyuSettings::NOTHING_ICON) {
settings->set_appIcon(AyuSettings::NOTHING_ICON);
changed = true;
for (int row = 0; row < rows; row++) {
const auto columns = std::min(4, icons.size() - row * 4);
for (int i = 0; i < columns; i++) {
auto const idx = i + row * 4;
auto const xOffset = (64 + 16) * i + padding;
auto const yOffset = row * (64 + 8);
if (x >= xOffset && x <= xOffset + 64 && e->pos().y() >= yOffset && e->pos().y() <= yOffset + 64) {
const auto &iconName = icons[idx];
if (settings->appIcon != iconName) {
settings->set_appIcon(iconName);
changed = true;
break;
}
}
}
}
if (changed) {

View file

@ -109,7 +109,7 @@ not_null<Ui::RpWidget *> AddInnerToggle(
[](const auto &v)
{ return v->checked(); });
};
for (const auto &innerCheck: state->innerChecks) {
for (const auto &innerCheck : state->innerChecks) {
innerCheck->checkedChanges(
) | rpl::to_empty | start_to_stream(
state->anyChanges,
@ -260,7 +260,7 @@ not_null<Ui::RpWidget *> AddInnerToggle(
{
if (!handleLocked()) {
const auto checked = !checkView->checked();
for (const auto &innerCheck: state->innerChecks) {
for (const auto &innerCheck : state->innerChecks) {
innerCheck->setChecked(checked, anim::type::normal);
}
}
@ -452,7 +452,7 @@ void Ayu::SetupGhostModeToggle(not_null<Ui::VerticalLayout *> container)
object_ptr<Ui::VerticalLayout>(container));
const auto verticalLayout = wrap->entity();
auto innerChecks = std::vector<not_null<Ui::AbstractCheckView *>>();
for (const auto &entry: checkboxes) {
for (const auto &entry : checkboxes) {
const auto c = addCheckbox(verticalLayout, entry.checkboxLabel, entry.initial);
c->checkedValue(
) | start_with_next([=](bool enabled)
@ -573,7 +573,7 @@ void Ayu::SetupReadAfterActionToggle(not_null<Ui::VerticalLayout *> container)
object_ptr<Ui::VerticalLayout>(container));
const auto verticalLayout = wrap->entity();
auto innerChecks = std::vector<not_null<Ui::AbstractCheckView *>>();
for (const auto &entry: checkboxes) {
for (const auto &entry : checkboxes) {
const auto c = addCheckbox(verticalLayout, entry.checkboxLabel, entry.initial);
c->checkedValue(
) | start_with_next([=](bool enabled)
@ -828,6 +828,11 @@ void Ayu::SetupCustomization(not_null<Ui::VerticalLayout *> container,
settings->set_showMessageSeconds(enabled);
AyuSettings::save();
}, container->lifetime());
AddSkip(container);
AddDivider(container);
AddSkip(container);
SetupFonts(container, controller);
}
void Ayu::SetupShowPeerId(not_null<Ui::VerticalLayout *> container,
@ -915,6 +920,52 @@ void Ayu::SetupRecentStickersLimitSlider(not_null<Ui::VerticalLayout *> containe
});
}
void Ayu::SetupFonts(not_null<Ui::VerticalLayout *> container, not_null<Window::SessionController *> controller)
{
const auto settings = &AyuSettings::getInstance();
const auto commonButton = AddButtonWithLabel(
container,
tr::ayu_MainFont(),
rpl::single(
settings->mainFont.isEmpty() ? tr::ayu_FontDefault(tr::now) : settings->mainFont
),
st::settingsButtonNoIcon);
const auto commonGuard = Ui::CreateChild<base::binary_guard>(commonButton.get());
commonButton->addClickHandler([=]
{
*commonGuard = AyuUi::FontSelectorBox::Show(controller, [=](QString font)
{
auto ayuSettings = &AyuSettings::getInstance();
ayuSettings->set_mainFont(std::move(font));
AyuSettings::save();
});
});
const auto monoButton = AddButtonWithLabel(
container,
tr::ayu_MonospaceFont(),
rpl::single(
settings->monoFont.isEmpty() ? tr::ayu_FontDefault(tr::now) : settings->monoFont
),
st::settingsButtonNoIcon);
const auto monoGuard = Ui::CreateChild<base::binary_guard>(monoButton.get());
monoButton->addClickHandler([=]
{
*monoGuard = AyuUi::FontSelectorBox::Show(controller, [=](QString font)
{
auto ayuSettings = &AyuSettings::getInstance();
ayuSettings->set_monoFont(std::move(font));
AyuSettings::save();
});
});
}
void Ayu::SetupAyuSync(not_null<Ui::VerticalLayout *> container)
{
AddSubsectionTitle(container, tr::ayu_AyuSyncHeader());
@ -992,52 +1043,6 @@ void Ayu::SetupExperimental(not_null<Ui::VerticalLayout *> container,
{
AddSubsectionTitle(container, tr::lng_settings_experimental());
AddPlatformOption(controller, container, StreamerMode, rpl::producer<>());
const auto commonButton = AddButtonWithLabel(
container,
rpl::single(qs("Customise main font")),
rpl::single(
AyuSettings::getInstance().commonFont.isEmpty() ? qs("Default") : AyuSettings::getInstance().commonFont
),
st::settingsButtonNoIcon);
const auto commonGuard = Ui::CreateChild<base::binary_guard>(commonButton.get());
commonButton->addClickHandler([=]
{
const auto m = commonButton->clickModifiers();
*commonGuard = AyuUi::FontSelectorBox::Show(controller, [=](QString font)
{
auto ayuSettings = &AyuSettings::getInstance();
ayuSettings->set_commonFont(std::move(font));
AyuSettings::save();
});
});
const auto monoButton = AddButtonWithLabel(
container,
rpl::single(qs("Customise mono font")),
rpl::single(
AyuSettings::getInstance().monoFont.isEmpty() ? qs("Default")
: AyuSettings::getInstance().monoFont
),
st::settingsButtonNoIcon);
const auto monoGuard = Ui::CreateChild<base::binary_guard>(monoButton.get());
monoButton->addClickHandler([=]
{
const auto m = monoButton->clickModifiers();
*monoGuard = AyuUi::FontSelectorBox::Show(controller, [=](QString font)
{
auto ayuSettings = &AyuSettings::getInstance();
ayuSettings->set_monoFont(std::move(font));
AyuSettings::save();
});
});
AddDividerText(container, rpl::single(qs("Here you can customise fonts for AyuGram")));
}
void Ayu::SetupAyuGramSettings(not_null<Ui::VerticalLayout *> container,

View file

@ -57,6 +57,8 @@ private:
void SetupRecentStickersLimitSlider(not_null<Ui::VerticalLayout *> container);
void SetupFonts(not_null<Ui::VerticalLayout *> container, not_null<Window::SessionController *> controller);
void SetupAyuSync(not_null<Ui::VerticalLayout *> container);
void SetupSendConfirmations(not_null<Ui::VerticalLayout *> container);

@ -1 +1 @@
Subproject commit 1edb7981b1c1023d71812f07cb18ec1e51f1289b
Subproject commit 312da65aa0c5bea95b39a48f6066d49df7bcf4f9