mirror of
https://github.com/AyuGram/AyuGramDesktop.git
synced 2025-06-05 06:33:57 +02:00
feat: implement recentStickersCount
This commit is contained in:
parent
a5bd116b40
commit
89036a4c94
7 changed files with 60 additions and 2 deletions
|
@ -3881,6 +3881,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||||
"ayu_GhostModeShortcut" = "Enter with Ghost";
|
"ayu_GhostModeShortcut" = "Enter with Ghost";
|
||||||
"ayu_SettingsWatermark" = "AyuGram developed and maintained by Radolyn Labs.";
|
"ayu_SettingsWatermark" = "AyuGram developed and maintained by Radolyn Labs.";
|
||||||
"ayu_SettingsCustomizationHint" = "After making changes to the \"Customization\" section, you must restart the application.";
|
"ayu_SettingsCustomizationHint" = "After making changes to the \"Customization\" section, you must restart the application.";
|
||||||
|
"ayu_SettingsRecentStickersCount" = "Recent stickers count";
|
||||||
"ayu_SettingsShowID" = "Show peer ID";
|
"ayu_SettingsShowID" = "Show peer ID";
|
||||||
"ayu_SettingsShowID_Hide" = "Hide";
|
"ayu_SettingsShowID_Hide" = "Hide";
|
||||||
"ayu_SettingsShowMessageSeconds" = "Show message seconds";
|
"ayu_SettingsShowMessageSeconds" = "Show message seconds";
|
||||||
|
|
|
@ -128,6 +128,10 @@ namespace AyuSettings {
|
||||||
editedMarkReactive = editedMark;
|
editedMarkReactive = editedMark;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void AyuGramSettings::set_recentStickersCount(int val) {
|
||||||
|
recentStickersCount = val;
|
||||||
|
}
|
||||||
|
|
||||||
void AyuGramSettings::set_showGhostToggleInDrawer(bool val) {
|
void AyuGramSettings::set_showGhostToggleInDrawer(bool val) {
|
||||||
showGhostToggleInDrawer = val;
|
showGhostToggleInDrawer = val;
|
||||||
}
|
}
|
||||||
|
|
|
@ -33,6 +33,7 @@ namespace AyuSettings {
|
||||||
// ~ Customization
|
// ~ Customization
|
||||||
deletedMark = "🧹";
|
deletedMark = "🧹";
|
||||||
editedMark = tr::lng_edited(tr::now);
|
editedMark = tr::lng_edited(tr::now);
|
||||||
|
recentStickersCount = 20;
|
||||||
showGhostToggleInDrawer = true;
|
showGhostToggleInDrawer = true;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -69,6 +70,8 @@ namespace AyuSettings {
|
||||||
|
|
||||||
QS_FIELD(QString, editedMark)
|
QS_FIELD(QString, editedMark)
|
||||||
|
|
||||||
|
QS_FIELD(int, recentStickersCount)
|
||||||
|
|
||||||
QS_FIELD(bool, showGhostToggleInDrawer)
|
QS_FIELD(bool, showGhostToggleInDrawer)
|
||||||
|
|
||||||
QS_FIELD(int, showPeerId)
|
QS_FIELD(int, showPeerId)
|
||||||
|
@ -92,6 +95,7 @@ namespace AyuSettings {
|
||||||
|
|
||||||
void set_deletedMark(QString val);
|
void set_deletedMark(QString val);
|
||||||
void set_editedMark(QString val);
|
void set_editedMark(QString val);
|
||||||
|
void set_recentStickersCount(int val);
|
||||||
void set_showGhostToggleInDrawer(bool val);
|
void set_showGhostToggleInDrawer(bool val);
|
||||||
void set_showPeerId(int val);
|
void set_showPeerId(int val);
|
||||||
void set_showMessageSeconds(bool val);
|
void set_showMessageSeconds(bool val);
|
||||||
|
|
|
@ -11,7 +11,6 @@
|
||||||
#include "ui/widgets/buttons.h"
|
#include "ui/widgets/buttons.h"
|
||||||
#include "ui/widgets/checkbox.h"
|
#include "ui/widgets/checkbox.h"
|
||||||
#include "boxes/connection_box.h"
|
#include "boxes/connection_box.h"
|
||||||
#include "ui/boxes/confirm_box.h"
|
|
||||||
#include "platform/platform_specific.h"
|
#include "platform/platform_specific.h"
|
||||||
#include "window/window_session_controller.h"
|
#include "window/window_session_controller.h"
|
||||||
#include "lang/lang_instance.h"
|
#include "lang/lang_instance.h"
|
||||||
|
@ -22,6 +21,7 @@
|
||||||
#include "styles/style_settings.h"
|
#include "styles/style_settings.h"
|
||||||
#include "apiwrap.h"
|
#include "apiwrap.h"
|
||||||
#include "api/api_blocked_peers.h"
|
#include "api/api_blocked_peers.h"
|
||||||
|
#include "ui/widgets/continuous_sliders.h"
|
||||||
|
|
||||||
namespace Settings {
|
namespace Settings {
|
||||||
|
|
||||||
|
@ -207,6 +207,8 @@ namespace Settings {
|
||||||
Ui::show(std::move(box));
|
Ui::show(std::move(box));
|
||||||
});
|
});
|
||||||
|
|
||||||
|
SetupRecentStickersLimitSlider(container);
|
||||||
|
|
||||||
SetupShowPeerId(container, controller);
|
SetupShowPeerId(container, controller);
|
||||||
|
|
||||||
AddButton(
|
AddButton(
|
||||||
|
@ -274,6 +276,46 @@ namespace Settings {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Ayu::SetupRecentStickersLimitSlider(not_null<Ui::VerticalLayout *> container) {
|
||||||
|
auto settings = &AyuSettings::getInstance();
|
||||||
|
|
||||||
|
container->add(
|
||||||
|
CreateButton(
|
||||||
|
container,
|
||||||
|
tr::ayu_SettingsRecentStickersCount(),
|
||||||
|
st::settingsButtonNoIcon)
|
||||||
|
);
|
||||||
|
|
||||||
|
auto recentStickersLimitSlider = MakeSliderWithLabel(
|
||||||
|
container,
|
||||||
|
st::settingsScale,
|
||||||
|
st::settingsScaleLabel,
|
||||||
|
st::normalFont->spacew * 2,
|
||||||
|
st::settingsScaleLabel.style.font->width("300%"));
|
||||||
|
container->add(
|
||||||
|
std::move(recentStickersLimitSlider.widget),
|
||||||
|
st::settingsScalePadding);
|
||||||
|
const auto slider = recentStickersLimitSlider.slider;
|
||||||
|
const auto label = recentStickersLimitSlider.label;
|
||||||
|
|
||||||
|
const auto updateLabel = [=](int amount) {
|
||||||
|
label->setText(QString::number(amount));
|
||||||
|
};
|
||||||
|
updateLabel(settings->recentStickersCount);
|
||||||
|
|
||||||
|
slider->setPseudoDiscrete(
|
||||||
|
40 + 1, // thx tg
|
||||||
|
[=](int amount) { return amount; },
|
||||||
|
settings->recentStickersCount,
|
||||||
|
[=](int amount) { updateLabel(amount); },
|
||||||
|
[=](int amount) {
|
||||||
|
updateLabel(amount);
|
||||||
|
|
||||||
|
settings->set_recentStickersCount(amount);
|
||||||
|
AyuSettings::save();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
void Ayu::SetupAyuGramSettings(not_null<Ui::VerticalLayout *> container, not_null<Window::SessionController *> controller) {
|
void Ayu::SetupAyuGramSettings(not_null<Ui::VerticalLayout *> container, not_null<Window::SessionController *> controller) {
|
||||||
AddSkip(container);
|
AddSkip(container);
|
||||||
SetupGhostEssentials(container);
|
SetupGhostEssentials(container);
|
||||||
|
|
|
@ -22,7 +22,9 @@ namespace Settings {
|
||||||
void SetupSpyEssentials(not_null<Ui::VerticalLayout *> container);
|
void SetupSpyEssentials(not_null<Ui::VerticalLayout *> container);
|
||||||
void SetupQoLToggles(not_null<Ui::VerticalLayout *> container);
|
void SetupQoLToggles(not_null<Ui::VerticalLayout *> container);
|
||||||
void SetupCustomization(not_null<Ui::VerticalLayout *> container, not_null<Window::SessionController *> controller);
|
void SetupCustomization(not_null<Ui::VerticalLayout *> container, not_null<Window::SessionController *> controller);
|
||||||
|
|
||||||
void SetupShowPeerId(not_null<Ui::VerticalLayout *> container, not_null<Window::SessionController *> controller);
|
void SetupShowPeerId(not_null<Ui::VerticalLayout *> container, not_null<Window::SessionController *> controller);
|
||||||
|
void SetupRecentStickersLimitSlider(not_null<Ui::VerticalLayout *> container);
|
||||||
|
|
||||||
void SetupAyuGramSettings(not_null<Ui::VerticalLayout *> container, not_null<Window::SessionController *> null);
|
void SetupAyuGramSettings(not_null<Ui::VerticalLayout *> container, not_null<Window::SessionController *> null);
|
||||||
void setupContent(not_null<Window::SessionController *> controller);
|
void setupContent(not_null<Window::SessionController *> controller);
|
||||||
|
|
|
@ -54,6 +54,8 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||||
|
|
||||||
#include <QtWidgets/QApplication>
|
#include <QtWidgets/QApplication>
|
||||||
|
|
||||||
|
#include "ayu/ayu_settings.h"
|
||||||
|
|
||||||
namespace ChatHelpers {
|
namespace ChatHelpers {
|
||||||
namespace {
|
namespace {
|
||||||
|
|
||||||
|
@ -2089,8 +2091,10 @@ auto StickersListWidget::collectRecentStickers() -> std::vector<Sticker> {
|
||||||
result.reserve(cloudCount + recent.size() + customCount);
|
result.reserve(cloudCount + recent.size() + customCount);
|
||||||
_custom.reserve(cloudCount + recent.size() + customCount);
|
_custom.reserve(cloudCount + recent.size() + customCount);
|
||||||
|
|
||||||
|
auto settings = &AyuSettings::getInstance();
|
||||||
|
|
||||||
auto add = [&](not_null<DocumentData*> document, bool custom) {
|
auto add = [&](not_null<DocumentData*> document, bool custom) {
|
||||||
if (result.size() >= kRecentDisplayLimit) {
|
if (result.size() >= settings->recentStickersCount) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
const auto i = ranges::find(result, document, &Sticker::document);
|
const auto i = ranges::find(result, document, &Sticker::document);
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
{
|
{
|
||||||
"SettingsWatermark": "AyuGram developed and maintained by Radolyn Labs.",
|
"SettingsWatermark": "AyuGram developed and maintained by Radolyn Labs.",
|
||||||
"SettingsCustomizationHint": "After making changes to the \"Customization\" section, you must restart the application.",
|
"SettingsCustomizationHint": "After making changes to the \"Customization\" section, you must restart the application.",
|
||||||
|
"SettingsRecentStickersCount": "Recent stickers count",
|
||||||
"SettingsShowID": "Show peer ID",
|
"SettingsShowID": "Show peer ID",
|
||||||
"SettingsShowID_Hide": "Hide",
|
"SettingsShowID_Hide": "Hide",
|
||||||
"SettingsShowMessageSeconds": "Show message seconds",
|
"SettingsShowMessageSeconds": "Show message seconds",
|
||||||
|
|
Loading…
Add table
Reference in a new issue