mirror of
https://github.com/AyuGram/AyuGramDesktop.git
synced 2025-06-03 21:54:05 +02:00
Added initial ability to change swipe dialog action from chat settings.
This commit is contained in:
parent
e28d29f276
commit
b95035e7a2
6 changed files with 85 additions and 4 deletions
|
@ -1180,6 +1180,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
|||
"lng_settings_restart_now" = "Restart";
|
||||
"lng_settings_restart_later" = "Later";
|
||||
|
||||
"lng_settings_swipe_subsection" = "Chat list swipe gesture";
|
||||
"lng_settings_swipe_mute" = "Mute";
|
||||
"lng_settings_swipe_unmute" = "Unmute";
|
||||
"lng_settings_swipe_pin" = "Pin";
|
||||
|
|
|
@ -240,7 +240,7 @@ QByteArray Settings::serialize() const {
|
|||
+ Serialize::stringSize(_customFontFamily)
|
||||
+ sizeof(qint32) * 3
|
||||
+ Serialize::bytearraySize(_tonsiteStorageToken)
|
||||
+ sizeof(qint32) * 7;
|
||||
+ sizeof(qint32) * 8;
|
||||
|
||||
auto result = QByteArray();
|
||||
result.reserve(size);
|
||||
|
@ -401,7 +401,8 @@ QByteArray Settings::serialize() const {
|
|||
<< qint32(_recordVideoMessages ? 1 : 0)
|
||||
<< SerializeVideoQuality(_videoQuality)
|
||||
<< qint32(_ivZoom.current())
|
||||
<< qint32(_systemDarkModeEnabled.current() ? 1 : 0);
|
||||
<< qint32(_systemDarkModeEnabled.current() ? 1 : 0)
|
||||
<< qint32(_swipeDialogAction);
|
||||
}
|
||||
|
||||
Ensures(result.size() == size);
|
||||
|
@ -530,6 +531,7 @@ void Settings::addFromSerialized(const QByteArray &serialized) {
|
|||
qint32 recordVideoMessages = _recordVideoMessages ? 1 : 0;
|
||||
quint32 videoQuality = SerializeVideoQuality(_videoQuality);
|
||||
quint32 chatFiltersHorizontal = _chatFiltersHorizontal.current() ? 1 : 0;
|
||||
quint32 swipeDialogAction = quint32(_swipeDialogAction);
|
||||
|
||||
stream >> themesAccentColors;
|
||||
if (!stream.atEnd()) {
|
||||
|
@ -858,6 +860,9 @@ void Settings::addFromSerialized(const QByteArray &serialized) {
|
|||
if (!stream.atEnd()) {
|
||||
stream >> systemDarkModeEnabled;
|
||||
}
|
||||
if (!stream.atEnd()) {
|
||||
stream >> swipeDialogAction;
|
||||
}
|
||||
if (stream.status() != QDataStream::Ok) {
|
||||
LOG(("App Error: "
|
||||
"Bad data for Core::Settings::constructFromSerialized()"));
|
||||
|
@ -1079,6 +1084,7 @@ void Settings::addFromSerialized(const QByteArray &serialized) {
|
|||
_recordVideoMessages = (recordVideoMessages == 1);
|
||||
_videoQuality = DeserializeVideoQuality(videoQuality);
|
||||
_chatFiltersHorizontal = (chatFiltersHorizontal == 1);
|
||||
_swipeDialogAction = Dialogs::Ui::SwipeDialogAction(swipeDialogAction);
|
||||
}
|
||||
|
||||
QString Settings::getSoundPath(const QString &key) const {
|
||||
|
@ -1470,6 +1476,7 @@ void Settings::resetOnLastLogout() {
|
|||
_recordVideoMessages = false;
|
||||
_videoQuality = {};
|
||||
_chatFiltersHorizontal = false;
|
||||
_swipeDialogAction = Dialogs::Ui::SwipeDialogAction::Disabled;
|
||||
|
||||
_recentEmojiPreload.clear();
|
||||
_recentEmoji.clear();
|
||||
|
@ -1657,4 +1664,12 @@ void Settings::setChatFiltersHorizontal(bool value) {
|
|||
_chatFiltersHorizontal = value;
|
||||
}
|
||||
|
||||
Dialogs::Ui::SwipeDialogAction Settings::swipeDialogAction() const {
|
||||
return _swipeDialogAction;
|
||||
}
|
||||
|
||||
void Settings::setSwipeDialogAction(Dialogs::Ui::SwipeDialogAction action) {
|
||||
_swipeDialogAction = action;
|
||||
}
|
||||
|
||||
} // namespace Core
|
||||
|
|
|
@ -9,6 +9,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
|||
|
||||
#include "core/core_settings_proxy.h"
|
||||
#include "media/media_common.h"
|
||||
#include "dialogs/ui/dialogs_swipe_context.h"
|
||||
#include "window/themes/window_themes_embedded.h"
|
||||
#include "ui/chat/attach/attach_send_files_way.h"
|
||||
#include "base/flags.h"
|
||||
|
@ -946,6 +947,9 @@ public:
|
|||
[[nodiscard]] static PlaybackSpeed DeserializePlaybackSpeed(
|
||||
qint32 speed);
|
||||
|
||||
[[nodiscard]] Dialogs::Ui::SwipeDialogAction swipeDialogAction() const;
|
||||
void setSwipeDialogAction(Dialogs::Ui::SwipeDialogAction);
|
||||
|
||||
void resetOnLastLogout();
|
||||
|
||||
private:
|
||||
|
@ -1086,6 +1090,9 @@ private:
|
|||
|
||||
bool _recordVideoMessages = false;
|
||||
|
||||
Dialogs::Ui::SwipeDialogAction _swipeDialogAction
|
||||
= Dialogs::Ui::SwipeDialogAction::Disabled;
|
||||
|
||||
QByteArray _photoEditorBrush;
|
||||
|
||||
};
|
||||
|
|
|
@ -728,7 +728,8 @@ void Widget::setupSwipeBack() {
|
|||
const auto isRightToLeft = direction == Qt::RightToLeft;
|
||||
if (!isRightToLeft && _inner) {
|
||||
if (const auto key = _inner->calcSwipeKey(top)) {
|
||||
const auto action = Dialogs::Ui::SwipeDialogAction::Mute;
|
||||
const auto action
|
||||
= Core::App().settings().swipeDialogAction();
|
||||
_inner->prepareSwipeAction(key, action);
|
||||
return Ui::Controls::SwipeHandlerFinishData{
|
||||
.callback = [=, session = &session()] {
|
||||
|
|
|
@ -928,7 +928,7 @@ void PaintRow(
|
|||
style::al_bottom);
|
||||
}
|
||||
p.translate(0, topTranslation);
|
||||
p.setClipRegion(QRegion());
|
||||
p.setClipping(false);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -1273,6 +1273,62 @@ void SetupChatBackground(
|
|||
}, adaptive->lifetime());
|
||||
}
|
||||
|
||||
void SetupChatListSwipe(
|
||||
not_null<Window::SessionController*> controller,
|
||||
not_null<Ui::VerticalLayout*> container) {
|
||||
Ui::AddDivider(container);
|
||||
Ui::AddSkip(container);
|
||||
Ui::AddSubsectionTitle(container, tr::lng_settings_swipe_subsection());
|
||||
|
||||
using Type = Dialogs::Ui::SwipeDialogAction;
|
||||
const auto group = std::make_shared<Ui::RadioenumGroup<Type>>(
|
||||
Core::App().settings().swipeDialogAction());
|
||||
container->add(
|
||||
object_ptr<Ui::SettingsButton>(
|
||||
container,
|
||||
group->value() | rpl::map([](Type value) {
|
||||
return ((value == Dialogs::Ui::SwipeDialogAction::Mute)
|
||||
? tr::lng_settings_swipe_mute
|
||||
: (value == Dialogs::Ui::SwipeDialogAction::Pin)
|
||||
? tr::lng_settings_swipe_pin
|
||||
: (value == Dialogs::Ui::SwipeDialogAction::Read)
|
||||
? tr::lng_settings_swipe_read
|
||||
: (value == Dialogs::Ui::SwipeDialogAction::Archive)
|
||||
? tr::lng_settings_swipe_archive
|
||||
: tr::lng_settings_swipe_disabled)();
|
||||
}) | rpl::flatten_latest(),
|
||||
st::settingsButtonNoIcon)
|
||||
)->setClickedCallback([=] {
|
||||
controller->uiShow()->showBox(Box([=](not_null<Ui::GenericBox*> box) {
|
||||
box->setTitle(tr::lng_settings_swipe_subsection());
|
||||
const auto addRadio = [&](Type value, tr::phrase<> phrase) {
|
||||
box->verticalLayout()->add(
|
||||
object_ptr<Ui::Radioenum<Type>>(
|
||||
box->verticalLayout(),
|
||||
group,
|
||||
value,
|
||||
phrase(tr::now),
|
||||
st::settingsSendType),
|
||||
st::settingsSendTypePadding);
|
||||
};
|
||||
addRadio(Type::Mute, tr::lng_settings_swipe_mute);
|
||||
addRadio(Type::Pin, tr::lng_settings_swipe_pin);
|
||||
addRadio(Type::Read, tr::lng_settings_swipe_read);
|
||||
addRadio(Type::Archive, tr::lng_settings_swipe_archive);
|
||||
addRadio(Type::Delete, tr::lng_settings_swipe_delete);
|
||||
addRadio(Type::Disabled, tr::lng_settings_swipe_disabled);
|
||||
box->addButton(tr::lng_settings_save(), [=] {
|
||||
Core::App().settings().setSwipeDialogAction(
|
||||
group->current());
|
||||
Core::App().saveSettingsDelayed();
|
||||
box->closeBox();
|
||||
});
|
||||
box->addButton(tr::lng_cancel(), [=] { box->closeBox(); });
|
||||
}));
|
||||
});
|
||||
Ui::AddSkip(container);
|
||||
}
|
||||
|
||||
void SetupDefaultThemes(
|
||||
not_null<Window::Controller*> window,
|
||||
not_null<Ui::VerticalLayout*> container) {
|
||||
|
@ -1803,6 +1859,7 @@ void Chat::setupContent(not_null<Window::SessionController*> controller) {
|
|||
SetupThemeSettings(controller, content);
|
||||
SetupCloudThemes(controller, content);
|
||||
SetupChatBackground(controller, content);
|
||||
SetupChatListSwipe(controller, content);
|
||||
SetupStickersEmoji(controller, content);
|
||||
SetupMessages(controller, content);
|
||||
Ui::AddDivider(content);
|
||||
|
|
Loading…
Add table
Reference in a new issue