mirror of
https://github.com/telegramdesktop/tdesktop
synced 2025-01-16 12:13:02 +00:00
Add animations enable/disable setting.
Open chats / users on mouse press if animations are disabled.
This commit is contained in:
parent
04dd4e30a8
commit
fd0719db6d
@ -336,7 +336,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||
"lng_settings_use_night_mode" = "Use night mode";
|
||||
"lng_settings_privacy_title" = "Privacy";
|
||||
"lng_settings_last_seen" = "Last seen";
|
||||
"lng_settings_calls" = "Calls";
|
||||
"lng_settings_calls" = "Voice calls";
|
||||
"lng_settings_groups_invite" = "Groups";
|
||||
"lng_settings_group_privacy_about" = "Change who can add you to groups and channel.";
|
||||
"lng_settings_sessions_about" = "Control your sessions on other devices.";
|
||||
@ -348,7 +348,6 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||
"lng_settings_phone_label" = "Phone number";
|
||||
"lng_settings_username_add" = "Add username";
|
||||
"lng_settings_close_sure" = "Are you sure you want to close this page? You didn't save your changes.";
|
||||
"lng_settings_calls_title" = "Calls";
|
||||
"lng_settings_peer_to_peer" = "Peer-to-Peer";
|
||||
"lng_settings_peer_to_peer_about" = "Disabling peer-to-peer will relay all calls through Telegram servers to avoid revealing your IP address, but may slightly decrease audio quality.";
|
||||
"lng_settings_advanced" = "Advanced";
|
||||
@ -364,6 +363,9 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||
"lng_settings_network_proxy" = "Network and proxy";
|
||||
"lng_settings_version_info" = "Version and updates";
|
||||
"lng_settings_system_integration" = "System integration";
|
||||
"lng_settings_performance" = "Performance";
|
||||
"lng_settings_enable_animations" = "Enable animations";
|
||||
"lng_settings_autoplay_gifs" = "Autoplay GIFs";
|
||||
|
||||
"lng_backgrounds_header" = "Choose your new chat background";
|
||||
"lng_theme_sure_keep" = "Keep this theme?";
|
||||
@ -515,9 +517,6 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||
"lng_proxy_sponsor_warning" = "This proxy may display a sponsored channel in your chat list. This doesn't reveal any of your Telegram traffic.";
|
||||
|
||||
"lng_settings_blocked_users" = "Blocked users";
|
||||
"lng_settings_last_seen_privacy" = "Last seen privacy";
|
||||
"lng_settings_calls_privacy" = "Phone calls privacy";
|
||||
"lng_settings_groups_invite_privacy" = "Group invite settings";
|
||||
"lng_settings_show_sessions" = "Show all sessions";
|
||||
"lng_settings_export_data" = "Export Telegram data";
|
||||
"lng_settings_destroy_if" = "If away for...";
|
||||
@ -578,7 +577,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||
"lng_edit_privacy_groups_always_title" = "Always allow";
|
||||
"lng_edit_privacy_groups_never_title" = "Never allow";
|
||||
|
||||
"lng_edit_privacy_calls_title" = "Telegram call privacy";
|
||||
"lng_edit_privacy_calls_title" = "Voice calls privacy";
|
||||
"lng_edit_privacy_calls_header" = "Who can call you";
|
||||
"lng_edit_privacy_calls_always_empty" = "Always allow";
|
||||
"lng_edit_privacy_calls_never_empty" = "Never allow";
|
||||
@ -1015,7 +1014,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||
"lng_stickers_packs_archived" = "Some of your unused stickers have been archived to make room for the sets you've activated.";
|
||||
"lng_stickers_copied" = "Sticker pack link copied to clipboard.";
|
||||
"lng_stickers_default_set" = "Great Minds";
|
||||
"lng_stickers_you_have" = "Manage and reorder sticker packs";
|
||||
"lng_stickers_you_have" = "Manage sticker packs";
|
||||
"lng_stickers_return" = "Undo";
|
||||
"lng_stickers_count#one" = "{count} sticker";
|
||||
"lng_stickers_count#other" = "{count} stickers";
|
||||
|
@ -924,15 +924,14 @@ AutoDownloadBox::AutoDownloadBox(QWidget *parent)
|
||||
, _audioGroups(this, lang(lng_media_auto_groups), !(cAutoDownloadAudio() & dbiadNoGroups), st::defaultBoxCheckbox)
|
||||
, _gifPrivate(this, lang(lng_media_auto_private_chats), !(cAutoDownloadGif() & dbiadNoPrivate), st::defaultBoxCheckbox)
|
||||
, _gifGroups(this, lang(lng_media_auto_groups), !(cAutoDownloadGif() & dbiadNoGroups), st::defaultBoxCheckbox)
|
||||
, _gifPlay(this, lang(lng_media_auto_play), cAutoPlayGif(), st::defaultBoxCheckbox)
|
||||
, _sectionHeight(st::boxTitleHeight + 2 * (st::defaultCheck.diameter + st::setLittleSkip)) {
|
||||
}
|
||||
|
||||
void AutoDownloadBox::prepare() {
|
||||
addButton(langFactory(lng_connection_save), [this] { onSave(); });
|
||||
addButton(langFactory(lng_cancel), [this] { closeBox(); });
|
||||
addButton(langFactory(lng_connection_save), [=] { save(); });
|
||||
addButton(langFactory(lng_cancel), [=] { closeBox(); });
|
||||
|
||||
setDimensions(st::boxWidth, 3 * _sectionHeight - st::autoDownloadTopDelta + st::setLittleSkip + _gifPlay->heightNoMargins() + st::setLittleSkip);
|
||||
setDimensions(st::boxWidth, 3 * _sectionHeight - st::autoDownloadTopDelta + st::setLittleSkip);
|
||||
}
|
||||
|
||||
void AutoDownloadBox::paintEvent(QPaintEvent *e) {
|
||||
@ -959,13 +958,11 @@ void AutoDownloadBox::resizeEvent(QResizeEvent *e) {
|
||||
|
||||
_gifPrivate->moveToLeft(st::boxTitlePosition.x(), 2 * _sectionHeight + top + st::setLittleSkip);
|
||||
_gifGroups->moveToLeft(st::boxTitlePosition.x(), _gifPrivate->bottomNoMargins() + st::setLittleSkip);
|
||||
_gifPlay->moveToLeft(st::boxTitlePosition.x(), _gifGroups->bottomNoMargins() + st::setLittleSkip);
|
||||
}
|
||||
|
||||
void AutoDownloadBox::onSave() {
|
||||
void AutoDownloadBox::save() {
|
||||
auto photosChanged = false;
|
||||
auto documentsChanged = false;
|
||||
auto autoplayChanged = false;
|
||||
auto photosEnabled = false;
|
||||
auto voiceEnabled = false;
|
||||
auto animationsEnabled = false;
|
||||
@ -1002,14 +999,7 @@ void AutoDownloadBox::onSave() {
|
||||
documentsChanged = true;
|
||||
cSetAutoDownloadGif(autoDownloadGif);
|
||||
}
|
||||
if (cAutoPlayGif() != _gifPlay->checked()) {
|
||||
cSetAutoPlayGif(_gifPlay->checked());
|
||||
if (!cAutoPlayGif()) {
|
||||
Auth().data().stopAutoplayAnimations();
|
||||
}
|
||||
autoplayChanged = true;
|
||||
}
|
||||
if (photosChanged || documentsChanged || autoplayChanged) {
|
||||
if (photosChanged || documentsChanged) {
|
||||
Local::writeUserSettings();
|
||||
}
|
||||
if (photosEnabled) {
|
||||
|
@ -23,8 +23,6 @@ class Radioenum;
|
||||
} // namespace Ui
|
||||
|
||||
class AutoDownloadBox : public BoxContent {
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
AutoDownloadBox(QWidget *parent);
|
||||
|
||||
@ -34,17 +32,15 @@ protected:
|
||||
void paintEvent(QPaintEvent *e) override;
|
||||
void resizeEvent(QResizeEvent *e) override;
|
||||
|
||||
private slots:
|
||||
void onSave();
|
||||
|
||||
private:
|
||||
void save();
|
||||
|
||||
object_ptr<Ui::Checkbox> _photoPrivate;
|
||||
object_ptr<Ui::Checkbox> _photoGroups;
|
||||
object_ptr<Ui::Checkbox> _audioPrivate;
|
||||
object_ptr<Ui::Checkbox> _audioGroups;
|
||||
object_ptr<Ui::Checkbox> _gifPrivate;
|
||||
object_ptr<Ui::Checkbox> _gifGroups;
|
||||
object_ptr<Ui::Checkbox> _gifPlay;
|
||||
|
||||
int _sectionHeight = 0;
|
||||
|
||||
|
@ -982,6 +982,9 @@ void PeerListContent::mousePressEvent(QMouseEvent *e) {
|
||||
row->addRipple(_st.item, size, point, std::move(updateCallback));
|
||||
}
|
||||
}
|
||||
if (anim::Disabled()) {
|
||||
mousePressReleased(e->button());
|
||||
}
|
||||
}
|
||||
|
||||
void PeerListContent::mouseReleaseEvent(QMouseEvent *e) {
|
||||
|
@ -2127,6 +2127,7 @@ void UpdateApplication() {
|
||||
}();
|
||||
UrlClickHandler::Open(url);
|
||||
} else {
|
||||
cSetAutoUpdate(true);
|
||||
if (const auto window = App::wnd()) {
|
||||
if (const auto controller = window->controller()) {
|
||||
controller->showSection(
|
||||
|
@ -834,6 +834,10 @@ void DialogsInner::mousePressEvent(QMouseEvent *e) {
|
||||
rtlupdate(0, searchedOffset() + index * st::dialogsRowHeight, getFullWidth(), st::dialogsRowHeight);
|
||||
});
|
||||
}
|
||||
if (anim::Disabled()
|
||||
&& (!_pressed || !_pressed->entry()->isPinnedDialog())) {
|
||||
mousePressReleased(e->button());
|
||||
}
|
||||
}
|
||||
|
||||
void DialogsInner::checkReorderPinnedStart(QPoint localPosition) {
|
||||
@ -1002,6 +1006,7 @@ bool DialogsInner::updateReorderPinned(QPoint localPosition) {
|
||||
void DialogsInner::step_pinnedShifting(TimeMs ms, bool timer) {
|
||||
if (anim::Disabled()) {
|
||||
ms += st::stickersRowDuration;
|
||||
update();
|
||||
}
|
||||
|
||||
auto animating = false;
|
||||
|
@ -22,6 +22,8 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||
#include "lang/lang_keys.h"
|
||||
#include "core/update_checker.h"
|
||||
#include "storage/localstorage.h"
|
||||
#include "data/data_session.h"
|
||||
#include "auth_session.h"
|
||||
#include "layout.h"
|
||||
#include "styles/style_settings.h"
|
||||
|
||||
@ -380,12 +382,49 @@ void SetupTray(not_null<Ui::VerticalLayout*> container) {
|
||||
AddSkip(container, st::settingsCheckboxesSkip);
|
||||
}
|
||||
|
||||
General::General(QWidget *parent, UserData *self)
|
||||
void SetupAnimations(not_null<Ui::VerticalLayout*> container) {
|
||||
AddButton(
|
||||
container,
|
||||
lng_settings_enable_animations,
|
||||
st::settingsButton
|
||||
)->toggleOn(
|
||||
rpl::single(!anim::Disabled())
|
||||
)->toggledValue(
|
||||
) | rpl::filter([](bool enabled) {
|
||||
return (enabled == anim::Disabled());
|
||||
}) | rpl::start_with_next([](bool enabled) {
|
||||
anim::SetDisabled(!enabled);
|
||||
Local::writeSettings();
|
||||
}, container->lifetime());
|
||||
}
|
||||
|
||||
void SetupPerformance(not_null<Ui::VerticalLayout*> container) {
|
||||
SetupAnimations(container);
|
||||
|
||||
AddButton(
|
||||
container,
|
||||
lng_settings_autoplay_gifs,
|
||||
st::settingsButton
|
||||
)->toggleOn(
|
||||
rpl::single(cAutoPlayGif())
|
||||
)->toggledValue(
|
||||
) | rpl::filter([](bool enabled) {
|
||||
return (enabled != cAutoPlayGif());
|
||||
}) | rpl::start_with_next([](bool enabled) {
|
||||
cSetAutoPlayGif(enabled);
|
||||
if (!cAutoPlayGif()) {
|
||||
Auth().data().stopAutoplayAnimations();
|
||||
}
|
||||
Local::writeUserSettings();
|
||||
}, container->lifetime());
|
||||
}
|
||||
|
||||
Advanced::Advanced(QWidget *parent, UserData *self)
|
||||
: Section(parent) {
|
||||
setupContent();
|
||||
}
|
||||
|
||||
void General::setupContent() {
|
||||
void Advanced::setupContent() {
|
||||
const auto content = Ui::CreateChild<Ui::VerticalLayout>(this);
|
||||
|
||||
auto empty = true;
|
||||
@ -423,6 +462,11 @@ void General::setupContent() {
|
||||
SetupTray(content);
|
||||
AddSkip(content);
|
||||
}
|
||||
addDivider();
|
||||
AddSkip(content);
|
||||
AddSubsectionTitle(content, lng_settings_performance);
|
||||
SetupPerformance(content);
|
||||
AddSkip(content);
|
||||
if (cAutoUpdate()) {
|
||||
addUpdate();
|
||||
}
|
||||
|
@ -17,6 +17,7 @@ bool HasUpdate();
|
||||
void SetupUpdate(not_null<Ui::VerticalLayout*> container);
|
||||
bool HasTray();
|
||||
void SetupTray(not_null<Ui::VerticalLayout*> container);
|
||||
void SetupAnimations(not_null<Ui::VerticalLayout*> container);
|
||||
|
||||
class Advanced : public Section {
|
||||
public:
|
||||
|
@ -83,6 +83,13 @@ object_ptr<Ui::RpWidget> CreateIntroSettings(QWidget *parent) {
|
||||
SetupUseDefaultTheme(result);
|
||||
AddSkip(result);
|
||||
|
||||
if (anim::Disabled()) {
|
||||
AddDivider(result);
|
||||
AddSkip(result);
|
||||
SetupAnimations(result);
|
||||
AddSkip(result);
|
||||
}
|
||||
|
||||
AddDivider(result);
|
||||
AddSkip(result);
|
||||
SetupFaq(result, false);
|
||||
|
@ -199,15 +199,17 @@ void SetupInterfaceScale(
|
||||
}, slider->lifetime());
|
||||
}
|
||||
|
||||
void OpenFaq() {
|
||||
QDesktopServices::openUrl(telegramFaqLink());
|
||||
}
|
||||
|
||||
void SetupFaq(not_null<Ui::VerticalLayout*> container, bool icon) {
|
||||
AddButton(
|
||||
container,
|
||||
lng_settings_faq,
|
||||
icon ? st::settingsSectionButton : st::settingsButton,
|
||||
icon ? &st::settingsIconFaq : nullptr
|
||||
)->addClickHandler([] {
|
||||
QDesktopServices::openUrl(telegramFaqLink());
|
||||
});
|
||||
)->addClickHandler(OpenFaq);
|
||||
}
|
||||
|
||||
void SetupHelp(not_null<Ui::VerticalLayout*> container) {
|
||||
@ -228,7 +230,17 @@ void SetupHelp(not_null<Ui::VerticalLayout*> container) {
|
||||
Ui::showPeerHistory(user, ShowAtUnreadMsgId);
|
||||
}
|
||||
});
|
||||
Auth().api().requestSupportContact(ready);
|
||||
const auto sure = crl::guard(button, [=] {
|
||||
Auth().api().requestSupportContact(ready);
|
||||
});
|
||||
auto box = Box<ConfirmBox>(
|
||||
lang(lng_settings_ask_sure),
|
||||
lang(lng_settings_ask_ok),
|
||||
lang(lng_settings_faq_button),
|
||||
sure,
|
||||
OpenFaq);
|
||||
box->setStrictCancel(true);
|
||||
Ui::show(std::move(box));
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -214,15 +214,17 @@ bool BlockedBoxController::prependRow(UserData *user) {
|
||||
std::unique_ptr<PeerListRow> BlockedBoxController::createRow(UserData *user) const {
|
||||
auto row = std::make_unique<PeerListRowWithLink>(user);
|
||||
row->setActionLink(lang(lng_blocked_list_unblock));
|
||||
auto status = [user]() -> QString {
|
||||
if (user->botInfo) {
|
||||
const auto status = [&] {
|
||||
if (!user->phone().isEmpty()) {
|
||||
return App::formatPhone(user->phone());
|
||||
} else if (!user->username.isEmpty()) {
|
||||
return '@' + user->username;
|
||||
} else if (user->botInfo) {
|
||||
return lang(lng_status_bot);
|
||||
} else if (user->phone().isEmpty()) {
|
||||
return lang(lng_blocked_list_unknown_phone);
|
||||
}
|
||||
return App::formatPhone(user->phone());
|
||||
};
|
||||
row->setCustomStatus(status());
|
||||
return lang(lng_blocked_list_unknown_phone);
|
||||
}();
|
||||
row->setCustomStatus(status);
|
||||
return std::move(row);
|
||||
}
|
||||
|
||||
|
@ -594,6 +594,7 @@ enum {
|
||||
dbiThemeKey = 0x54,
|
||||
dbiTileBackground = 0x55,
|
||||
dbiCacheSettings = 0x56,
|
||||
dbiAnimationsDisabled = 0x57,
|
||||
|
||||
dbiEncryptedWithSalt = 333,
|
||||
dbiEncrypted = 444,
|
||||
@ -1030,6 +1031,16 @@ bool _readSetting(quint32 blockId, QDataStream &stream, int version, ReadSetting
|
||||
_cacheTotalTimeLimit = time;
|
||||
} break;
|
||||
|
||||
case dbiAnimationsDisabled: {
|
||||
qint32 disabled;
|
||||
stream >> disabled;
|
||||
if (!_checkStreamStatus(stream)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
anim::SetDisabled(disabled == 1);
|
||||
} break;
|
||||
|
||||
case dbiSoundNotify: {
|
||||
qint32 v;
|
||||
stream >> v;
|
||||
@ -2541,6 +2552,7 @@ void writeSettings() {
|
||||
data.stream << quint32(dbiDcOptions) << dcOptionsSerialized;
|
||||
data.stream << quint32(dbiLoggedPhoneNumber) << cLoggedPhoneNumber();
|
||||
data.stream << quint32(dbiTxtDomainString) << Global::TxtDomainString();
|
||||
data.stream << quint32(dbiAnimationsDisabled) << qint32(anim::Disabled() ? 1 : 0);
|
||||
|
||||
data.stream << quint32(dbiConnectionType) << qint32(dbictProxiesList);
|
||||
data.stream << qint32(proxies.size());
|
||||
|
Loading…
Reference in New Issue
Block a user