feat: wide messages

This commit is contained in:
AlexeyZavar 2024-11-23 12:34:26 +03:00
parent d6145f383d
commit d6ba3ae332
11 changed files with 96 additions and 10 deletions

2
.gitmodules vendored
View file

@ -24,7 +24,7 @@
url = https://github.com/desktop-app/lib_base.git
[submodule "Telegram/codegen"]
path = Telegram/codegen
url = https://github.com/desktop-app/codegen.git
url = https://github.com/AyuGram/codegen.git
[submodule "Telegram/lib_ui"]
path = Telegram/lib_ui
url = https://github.com/AyuGram/lib_ui.git

View file

@ -5903,6 +5903,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
"ayu_MessageFieldElementVoice" = "Voice";
"ayu_DrawerElementsHeader" = "Drawer Elements";
"ayu_TrayElementsHeader" = "Tray Elements";
"ayu_SettingsWideMultiplier" = "Wide Messages Multiplier";
"ayu_SettingsSpoofWebviewAsAndroid" = "Spoof Client as Android";
"ayu_SettingsBiggerWindow" = "Bigger Window";
"ayu_SettingsIncreaseWebviewHeight" = "Increase Content Height";

View file

@ -8,8 +8,8 @@
#include "ayu/ayu_lang.h"
#include "ayu/ayu_worker.h"
#include "ayu/ayu_fonts.h"
#include "ayu/ayu_settings.h"
#include "ayu/ayu_ui_settings.h"
#include "ayu/data/ayu_database.h"
#include "lang/lang_instance.h"
@ -29,7 +29,8 @@ void initLang() {
void initFonts() {
auto settings = &AyuSettings::getInstance();
AyuFonts::setMonoFont(settings->monoFont);
AyuUiSettings::setMonoFont(settings->monoFont);
AyuUiSettings::setWideMultiplier(settings->wideMultiplier);
}
void initDatabase() {

View file

@ -222,6 +222,8 @@ AyuGramSettings::AyuGramSettings() {
collapseSimilarChannels = true;
hideSimilarChannels = false;
wideMultiplier = 1.0;
spoofWebviewAsAndroid = false;
increaseWebviewHeight = false;
increaseWebviewWidth = false;
@ -385,6 +387,10 @@ void AyuGramSettings::set_hideSimilarChannels(bool val) {
hideSimilarChannels = val;
}
void AyuGramSettings::set_wideMultiplier(double val) {
wideMultiplier = val;
}
void AyuGramSettings::set_spoofWebviewAsAndroid(bool val) {
spoofWebviewAsAndroid = val;
}

View file

@ -40,6 +40,8 @@ public:
bool collapseSimilarChannels;
bool hideSimilarChannels;
double wideMultiplier;
bool spoofWebviewAsAndroid;
bool increaseWebviewHeight;
bool increaseWebviewWidth;
@ -117,6 +119,8 @@ public:
void set_collapseSimilarChannels(bool val);
void set_hideSimilarChannels(bool val);
void set_wideMultiplier(double val);
void set_spoofWebviewAsAndroid(bool val);
void set_increaseWebviewHeight(bool val);
void set_increaseWebviewWidth(bool val);
@ -189,6 +193,7 @@ NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE_WITH_DEFAULT(
disableCustomBackgrounds,
collapseSimilarChannels,
hideSimilarChannels,
wideMultiplier,
spoofWebviewAsAndroid,
increaseWebviewHeight,
increaseWebviewWidth,

View file

@ -44,7 +44,7 @@
#include <ayu/ayu_settings.h>
#include "ayu/ayu_fonts.h"
#include "ayu/ayu_ui_settings.h"
#include "ui/ui_utility.h"
struct Font
@ -665,7 +665,7 @@ void Content::setupContent(
const std::vector<Font> &fonts) {
using namespace rpl::mappers;
const auto current = AyuFonts::getMonoFont();
const auto current = AyuUiSettings::getMonoFont();
const auto content = Ui::CreateChild<Ui::VerticalLayout>(this);
const auto add = [&](const std::vector<Font> &list)
{

View file

@ -34,6 +34,7 @@
#include "styles/style_ayu_icons.h"
#include "ui/painter.h"
#include "ui/vertical_list.h"
#include "ui/boxes/confirm_box.h"
#include "ui/boxes/single_choice_box.h"
#include "ui/text/text_utilities.h"
#include "ui/toast/toast.h"
@ -1296,6 +1297,75 @@ void SetupRecentStickersLimitSlider(not_null<Ui::VerticalLayout*> container) {
});
}
void SetupWideMultiplierSlider(not_null<Ui::VerticalLayout*> container,
not_null<Window::SessionController*> controller) {
auto settings = &AyuSettings::getInstance();
container->add(
object_ptr<Button>(container,
tr::ayu_SettingsWideMultiplier(),
st::settingsButtonNoIcon)
)->setAttribute(Qt::WA_TransparentForMouseEvents);
auto wideMultiplierSlider = MakeSliderWithLabel(
container,
st::autoDownloadLimitSlider,
st::settingsScaleLabel,
0,
st::settingsScaleLabel.style.font->width("8%%%"));
container->add(std::move(wideMultiplierSlider.widget), st::recentStickersLimitPadding);
const auto slider = wideMultiplierSlider.slider;
const auto label = wideMultiplierSlider.label;
const auto updateLabel = [=](double val)
{
label->setText(QString::number(val, 'f', 2));
};
constexpr auto kSizeAmount = 61; // (4.00 - 1.00) / 0.05 + 1
constexpr auto kMinSize = 1.00;
// const auto kMaxSize = 4.00;
constexpr auto kStep = 0.05;
const auto valueToIndex = [=](double value) {
return static_cast<int>(std::round((value - kMinSize) / kStep));
};
const auto indexToValue = [=](int index)
{
return kMinSize + index * kStep;
};
updateLabel(settings->wideMultiplier);
slider->setPseudoDiscrete(
kSizeAmount,
[=](int index) { return index; },
valueToIndex(settings->wideMultiplier),
[=](int index)
{
updateLabel(indexToValue(index));
},
[=](int index)
{
updateLabel(indexToValue(index));
settings->set_wideMultiplier(indexToValue(index));
AyuSettings::save();
// fix slider
crl::on_main([=]
{
controller->show(Ui::MakeConfirmBox({
.text = tr::lng_settings_need_restart(),
.confirmed = []
{
Core::Restart();
},
.confirmText = tr::lng_settings_restart_now(),
.cancelText = tr::lng_settings_restart_later(),
}));
});
});
}
void SetupFonts(not_null<Ui::VerticalLayout*> container, not_null<Window::SessionController*> controller) {
const auto settings = &AyuSettings::getInstance();
@ -1606,6 +1676,10 @@ void SetupCustomization(not_null<Ui::VerticalLayout*> container,
AddSkip(container);
SetupRecentStickersLimitSlider(container);
AddSkip(container);
AddDivider(container);
AddSkip(container);
SetupWideMultiplierSlider(container, controller);
AddSkip(container);
AddDivider(container);

View file

@ -113,6 +113,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include <QtGui/QWindow>
// AyuGram includes
#include "ayu/ayu_infra.h"
#include "ayu/features/streamer_mode/streamer_mode.h"
@ -305,6 +306,7 @@ void Application::run() {
_translator = std::make_unique<Lang::Translator>();
QCoreApplication::instance()->installTranslator(_translator.get());
AyuInfra::init();
style::StartManager(cScale());
Ui::InitTextOptions();
Ui::StartCachedCorners();

View file

@ -37,7 +37,6 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#endif // Q_OS_WIN
// AyuGram includes
#include "ayu/ayu_infra.h"
#include "ayu/ayu_settings.h"
@ -427,8 +426,6 @@ void start() {
}
readLangPack();
AyuInfra::init();
}
void writeSettings() {

@ -1 +1 @@
Subproject commit 4155b9ae2d4c5a37b9738afa8ef9fa20d8fdcb44
Subproject commit 46545f547e75afa8500fc21b6e18d60ba3405cfa

@ -1 +1 @@
Subproject commit c0ca053ccc756a85cd9bed488c53374a84a4b726
Subproject commit d06417f78976489a4e3705c3acf00603939a5487