mirror of https://github.com/procxx/kepka.git
Add a separate setting for video files autoplay.
This commit is contained in:
parent
041670b8e7
commit
c4319a7370
|
@ -416,6 +416,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
|||
"lng_settings_performance" = "Performance";
|
||||
"lng_settings_enable_animations" = "Enable animations";
|
||||
"lng_settings_autoplay_gifs" = "Autoplay GIFs";
|
||||
"lng_settings_autoplay_videos" = "Autoplay video files";
|
||||
"lng_settings_sensitive_title" = "Sensitive content";
|
||||
"lng_settings_sensitive_disable_filtering" = "Disable filtering";
|
||||
"lng_settings_sensitive_about" = "Display sensitive media in public channels on all your Telegram devices.";
|
||||
|
|
|
@ -1706,9 +1706,8 @@ void HistoryWidget::showHistory(
|
|||
cancelTypingAction();
|
||||
}
|
||||
|
||||
if (!session().settings().autoplayGifs()) {
|
||||
session().data().stopPlayingVideoFiles();
|
||||
}
|
||||
session().data().stopPlayingVideoFiles();
|
||||
|
||||
clearReplyReturns();
|
||||
clearAllLoadRequests();
|
||||
|
||||
|
|
|
@ -238,7 +238,9 @@ bool Gif::downloadInCorner() const {
|
|||
}
|
||||
|
||||
bool Gif::autoplayEnabled() const {
|
||||
return history()->session().settings().autoplayGifs();
|
||||
return _data->isVideoFile()
|
||||
? history()->session().settings().autoplayVideos()
|
||||
: history()->session().settings().autoplayGifs();
|
||||
}
|
||||
|
||||
void Gif::draw(Painter &p, const QRect &r, TextSelection selection, crl::time ms) const {
|
||||
|
|
|
@ -90,6 +90,7 @@ QByteArray Settings::serialize() const {
|
|||
stream << qint32(_variables.suggestEmoji ? 1 : 0);
|
||||
stream << qint32(_variables.suggestStickersByEmoji ? 1 : 0);
|
||||
stream << qint32(_variables.spellcheckerEnabled.current() ? 1 : 0);
|
||||
stream << qint32(_variables.autoplayVideos ? 1 : 0);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
@ -137,6 +138,7 @@ void Settings::constructFromSerialized(const QByteArray &serialized) {
|
|||
qint32 suggestEmoji = _variables.suggestEmoji ? 1 : 0;
|
||||
qint32 suggestStickersByEmoji = _variables.suggestStickersByEmoji ? 1 : 0;
|
||||
qint32 spellcheckerEnabled = _variables.spellcheckerEnabled.current() ? 1 : 0;
|
||||
qint32 autoplayVideos = _variables.autoplayVideos ? 1 : 0;
|
||||
|
||||
stream >> selectorTab;
|
||||
stream >> lastSeenWarningSeen;
|
||||
|
@ -239,6 +241,9 @@ void Settings::constructFromSerialized(const QByteArray &serialized) {
|
|||
if (!stream.atEnd()) {
|
||||
stream >> spellcheckerEnabled;
|
||||
}
|
||||
if (!stream.atEnd()) {
|
||||
stream >> autoplayVideos;
|
||||
}
|
||||
if (stream.status() != QDataStream::Ok) {
|
||||
LOG(("App Error: "
|
||||
"Bad data for Main::Settings::constructFromSerialized()"));
|
||||
|
@ -319,6 +324,7 @@ void Settings::constructFromSerialized(const QByteArray &serialized) {
|
|||
_variables.suggestEmoji = (suggestEmoji == 1);
|
||||
_variables.suggestStickersByEmoji = (suggestStickersByEmoji == 1);
|
||||
_variables.spellcheckerEnabled = (spellcheckerEnabled == 1);
|
||||
_variables.autoplayVideos = (autoplayVideos == 1);
|
||||
}
|
||||
|
||||
void Settings::setSupportChatsTimeSlice(int slice) {
|
||||
|
|
|
@ -204,6 +204,12 @@ public:
|
|||
void setAutoplayGifs(bool value) {
|
||||
_variables.autoplayGifs = value;
|
||||
}
|
||||
[[nodiscard]] bool autoplayVideos() const {
|
||||
return _variables.autoplayVideos;
|
||||
}
|
||||
void setAutoplayVideos(bool value) {
|
||||
_variables.autoplayVideos = value;
|
||||
}
|
||||
[[nodiscard]] bool loopAnimatedStickers() const {
|
||||
return _variables.loopAnimatedStickers;
|
||||
}
|
||||
|
@ -278,6 +284,7 @@ private:
|
|||
rpl::variable<bool> notifyAboutPinned = true;
|
||||
rpl::variable<bool> skipArchiveInSearch = false;
|
||||
bool autoplayGifs = true;
|
||||
bool autoplayVideos = true;
|
||||
bool loopAnimatedStickers = true;
|
||||
rpl::variable<bool> largeEmoji = true;
|
||||
rpl::variable<bool> replaceEmoji = true;
|
||||
|
|
|
@ -470,6 +470,23 @@ void SetupPerformance(
|
|||
}
|
||||
session->saveSettingsDelayed();
|
||||
}, container->lifetime());
|
||||
|
||||
AddButton(
|
||||
container,
|
||||
tr::lng_settings_autoplay_videos(),
|
||||
st::settingsButton
|
||||
)->toggleOn(
|
||||
rpl::single(session->settings().autoplayVideos())
|
||||
)->toggledValue(
|
||||
) | rpl::filter([=](bool enabled) {
|
||||
return (enabled != session->settings().autoplayVideos());
|
||||
}) | rpl::start_with_next([=](bool enabled) {
|
||||
session->settings().setAutoplayVideos(enabled);
|
||||
if (!enabled) {
|
||||
session->data().checkPlayingVideoFiles();
|
||||
}
|
||||
session->saveSettingsDelayed();
|
||||
}, container->lifetime());
|
||||
}
|
||||
|
||||
void SetupSystemIntegration(
|
||||
|
|
Loading…
Reference in New Issue