mirror of
https://github.com/AyuGram/AyuGramDesktop.git
synced 2025-04-11 11:47:09 +02:00
feat: wide messages
This commit is contained in:
parent
d6145f383d
commit
d6ba3ae332
11 changed files with 96 additions and 10 deletions
2
.gitmodules
vendored
2
.gitmodules
vendored
|
@ -24,7 +24,7 @@
|
||||||
url = https://github.com/desktop-app/lib_base.git
|
url = https://github.com/desktop-app/lib_base.git
|
||||||
[submodule "Telegram/codegen"]
|
[submodule "Telegram/codegen"]
|
||||||
path = Telegram/codegen
|
path = Telegram/codegen
|
||||||
url = https://github.com/desktop-app/codegen.git
|
url = https://github.com/AyuGram/codegen.git
|
||||||
[submodule "Telegram/lib_ui"]
|
[submodule "Telegram/lib_ui"]
|
||||||
path = Telegram/lib_ui
|
path = Telegram/lib_ui
|
||||||
url = https://github.com/AyuGram/lib_ui.git
|
url = https://github.com/AyuGram/lib_ui.git
|
||||||
|
|
|
@ -5903,6 +5903,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||||
"ayu_MessageFieldElementVoice" = "Voice";
|
"ayu_MessageFieldElementVoice" = "Voice";
|
||||||
"ayu_DrawerElementsHeader" = "Drawer Elements";
|
"ayu_DrawerElementsHeader" = "Drawer Elements";
|
||||||
"ayu_TrayElementsHeader" = "Tray Elements";
|
"ayu_TrayElementsHeader" = "Tray Elements";
|
||||||
|
"ayu_SettingsWideMultiplier" = "Wide Messages Multiplier";
|
||||||
"ayu_SettingsSpoofWebviewAsAndroid" = "Spoof Client as Android";
|
"ayu_SettingsSpoofWebviewAsAndroid" = "Spoof Client as Android";
|
||||||
"ayu_SettingsBiggerWindow" = "Bigger Window";
|
"ayu_SettingsBiggerWindow" = "Bigger Window";
|
||||||
"ayu_SettingsIncreaseWebviewHeight" = "Increase Content Height";
|
"ayu_SettingsIncreaseWebviewHeight" = "Increase Content Height";
|
||||||
|
|
|
@ -8,8 +8,8 @@
|
||||||
|
|
||||||
#include "ayu/ayu_lang.h"
|
#include "ayu/ayu_lang.h"
|
||||||
#include "ayu/ayu_worker.h"
|
#include "ayu/ayu_worker.h"
|
||||||
#include "ayu/ayu_fonts.h"
|
|
||||||
#include "ayu/ayu_settings.h"
|
#include "ayu/ayu_settings.h"
|
||||||
|
#include "ayu/ayu_ui_settings.h"
|
||||||
#include "ayu/data/ayu_database.h"
|
#include "ayu/data/ayu_database.h"
|
||||||
#include "lang/lang_instance.h"
|
#include "lang/lang_instance.h"
|
||||||
|
|
||||||
|
@ -29,7 +29,8 @@ void initLang() {
|
||||||
void initFonts() {
|
void initFonts() {
|
||||||
auto settings = &AyuSettings::getInstance();
|
auto settings = &AyuSettings::getInstance();
|
||||||
|
|
||||||
AyuFonts::setMonoFont(settings->monoFont);
|
AyuUiSettings::setMonoFont(settings->monoFont);
|
||||||
|
AyuUiSettings::setWideMultiplier(settings->wideMultiplier);
|
||||||
}
|
}
|
||||||
|
|
||||||
void initDatabase() {
|
void initDatabase() {
|
||||||
|
|
|
@ -222,6 +222,8 @@ AyuGramSettings::AyuGramSettings() {
|
||||||
collapseSimilarChannels = true;
|
collapseSimilarChannels = true;
|
||||||
hideSimilarChannels = false;
|
hideSimilarChannels = false;
|
||||||
|
|
||||||
|
wideMultiplier = 1.0;
|
||||||
|
|
||||||
spoofWebviewAsAndroid = false;
|
spoofWebviewAsAndroid = false;
|
||||||
increaseWebviewHeight = false;
|
increaseWebviewHeight = false;
|
||||||
increaseWebviewWidth = false;
|
increaseWebviewWidth = false;
|
||||||
|
@ -385,6 +387,10 @@ void AyuGramSettings::set_hideSimilarChannels(bool val) {
|
||||||
hideSimilarChannels = val;
|
hideSimilarChannels = val;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void AyuGramSettings::set_wideMultiplier(double val) {
|
||||||
|
wideMultiplier = val;
|
||||||
|
}
|
||||||
|
|
||||||
void AyuGramSettings::set_spoofWebviewAsAndroid(bool val) {
|
void AyuGramSettings::set_spoofWebviewAsAndroid(bool val) {
|
||||||
spoofWebviewAsAndroid = val;
|
spoofWebviewAsAndroid = val;
|
||||||
}
|
}
|
||||||
|
|
|
@ -40,6 +40,8 @@ public:
|
||||||
bool collapseSimilarChannels;
|
bool collapseSimilarChannels;
|
||||||
bool hideSimilarChannels;
|
bool hideSimilarChannels;
|
||||||
|
|
||||||
|
double wideMultiplier;
|
||||||
|
|
||||||
bool spoofWebviewAsAndroid;
|
bool spoofWebviewAsAndroid;
|
||||||
bool increaseWebviewHeight;
|
bool increaseWebviewHeight;
|
||||||
bool increaseWebviewWidth;
|
bool increaseWebviewWidth;
|
||||||
|
@ -117,6 +119,8 @@ public:
|
||||||
void set_collapseSimilarChannels(bool val);
|
void set_collapseSimilarChannels(bool val);
|
||||||
void set_hideSimilarChannels(bool val);
|
void set_hideSimilarChannels(bool val);
|
||||||
|
|
||||||
|
void set_wideMultiplier(double val);
|
||||||
|
|
||||||
void set_spoofWebviewAsAndroid(bool val);
|
void set_spoofWebviewAsAndroid(bool val);
|
||||||
void set_increaseWebviewHeight(bool val);
|
void set_increaseWebviewHeight(bool val);
|
||||||
void set_increaseWebviewWidth(bool val);
|
void set_increaseWebviewWidth(bool val);
|
||||||
|
@ -189,6 +193,7 @@ NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE_WITH_DEFAULT(
|
||||||
disableCustomBackgrounds,
|
disableCustomBackgrounds,
|
||||||
collapseSimilarChannels,
|
collapseSimilarChannels,
|
||||||
hideSimilarChannels,
|
hideSimilarChannels,
|
||||||
|
wideMultiplier,
|
||||||
spoofWebviewAsAndroid,
|
spoofWebviewAsAndroid,
|
||||||
increaseWebviewHeight,
|
increaseWebviewHeight,
|
||||||
increaseWebviewWidth,
|
increaseWebviewWidth,
|
||||||
|
|
|
@ -44,7 +44,7 @@
|
||||||
|
|
||||||
#include <ayu/ayu_settings.h>
|
#include <ayu/ayu_settings.h>
|
||||||
|
|
||||||
#include "ayu/ayu_fonts.h"
|
#include "ayu/ayu_ui_settings.h"
|
||||||
#include "ui/ui_utility.h"
|
#include "ui/ui_utility.h"
|
||||||
|
|
||||||
struct Font
|
struct Font
|
||||||
|
@ -665,7 +665,7 @@ void Content::setupContent(
|
||||||
const std::vector<Font> &fonts) {
|
const std::vector<Font> &fonts) {
|
||||||
using namespace rpl::mappers;
|
using namespace rpl::mappers;
|
||||||
|
|
||||||
const auto current = AyuFonts::getMonoFont();
|
const auto current = AyuUiSettings::getMonoFont();
|
||||||
const auto content = Ui::CreateChild<Ui::VerticalLayout>(this);
|
const auto content = Ui::CreateChild<Ui::VerticalLayout>(this);
|
||||||
const auto add = [&](const std::vector<Font> &list)
|
const auto add = [&](const std::vector<Font> &list)
|
||||||
{
|
{
|
||||||
|
|
|
@ -34,6 +34,7 @@
|
||||||
#include "styles/style_ayu_icons.h"
|
#include "styles/style_ayu_icons.h"
|
||||||
#include "ui/painter.h"
|
#include "ui/painter.h"
|
||||||
#include "ui/vertical_list.h"
|
#include "ui/vertical_list.h"
|
||||||
|
#include "ui/boxes/confirm_box.h"
|
||||||
#include "ui/boxes/single_choice_box.h"
|
#include "ui/boxes/single_choice_box.h"
|
||||||
#include "ui/text/text_utilities.h"
|
#include "ui/text/text_utilities.h"
|
||||||
#include "ui/toast/toast.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) {
|
void SetupFonts(not_null<Ui::VerticalLayout*> container, not_null<Window::SessionController*> controller) {
|
||||||
const auto settings = &AyuSettings::getInstance();
|
const auto settings = &AyuSettings::getInstance();
|
||||||
|
|
||||||
|
@ -1606,6 +1676,10 @@ void SetupCustomization(not_null<Ui::VerticalLayout*> container,
|
||||||
AddSkip(container);
|
AddSkip(container);
|
||||||
|
|
||||||
SetupRecentStickersLimitSlider(container);
|
SetupRecentStickersLimitSlider(container);
|
||||||
|
AddSkip(container);
|
||||||
|
AddDivider(container);
|
||||||
|
AddSkip(container);
|
||||||
|
SetupWideMultiplierSlider(container, controller);
|
||||||
|
|
||||||
AddSkip(container);
|
AddSkip(container);
|
||||||
AddDivider(container);
|
AddDivider(container);
|
||||||
|
|
|
@ -113,6 +113,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||||
#include <QtGui/QWindow>
|
#include <QtGui/QWindow>
|
||||||
|
|
||||||
// AyuGram includes
|
// AyuGram includes
|
||||||
|
#include "ayu/ayu_infra.h"
|
||||||
#include "ayu/features/streamer_mode/streamer_mode.h"
|
#include "ayu/features/streamer_mode/streamer_mode.h"
|
||||||
|
|
||||||
|
|
||||||
|
@ -305,6 +306,7 @@ void Application::run() {
|
||||||
_translator = std::make_unique<Lang::Translator>();
|
_translator = std::make_unique<Lang::Translator>();
|
||||||
QCoreApplication::instance()->installTranslator(_translator.get());
|
QCoreApplication::instance()->installTranslator(_translator.get());
|
||||||
|
|
||||||
|
AyuInfra::init();
|
||||||
style::StartManager(cScale());
|
style::StartManager(cScale());
|
||||||
Ui::InitTextOptions();
|
Ui::InitTextOptions();
|
||||||
Ui::StartCachedCorners();
|
Ui::StartCachedCorners();
|
||||||
|
|
|
@ -37,7 +37,6 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||||
#endif // Q_OS_WIN
|
#endif // Q_OS_WIN
|
||||||
|
|
||||||
// AyuGram includes
|
// AyuGram includes
|
||||||
#include "ayu/ayu_infra.h"
|
|
||||||
#include "ayu/ayu_settings.h"
|
#include "ayu/ayu_settings.h"
|
||||||
|
|
||||||
|
|
||||||
|
@ -427,8 +426,6 @@ void start() {
|
||||||
}
|
}
|
||||||
|
|
||||||
readLangPack();
|
readLangPack();
|
||||||
|
|
||||||
AyuInfra::init();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void writeSettings() {
|
void writeSettings() {
|
||||||
|
|
|
@ -1 +1 @@
|
||||||
Subproject commit 4155b9ae2d4c5a37b9738afa8ef9fa20d8fdcb44
|
Subproject commit 46545f547e75afa8500fc21b6e18d60ba3405cfa
|
|
@ -1 +1 @@
|
||||||
Subproject commit c0ca053ccc756a85cd9bed488c53374a84a4b726
|
Subproject commit d06417f78976489a4e3705c3acf00603939a5487
|
Loading…
Add table
Reference in a new issue