Added ability to save icon of last voice playback speed.

This commit is contained in:
23rd 2021-09-04 22:39:50 +03:00 committed by John Preston
parent 81a72caf07
commit 150dbef19f
3 changed files with 26 additions and 10 deletions

View File

@ -140,7 +140,7 @@ QByteArray Settings::serialize() const {
<< qint32(_askDownloadPath ? 1 : 0)
<< _downloadPath.current()
<< _downloadPathBookmark
<< qint32(0) // Old double voice playback speed.
<< qint32(_nonDefaultVoicePlaybackSpeed ? 1 : 0)
<< qint32(_soundNotify ? 1 : 0)
<< qint32(_desktopNotify ? 1 : 0)
<< qint32(_flashBounceNotify ? 1 : 0)
@ -241,7 +241,7 @@ void Settings::addFromSerialized(const QByteArray &serialized) {
qint32 askDownloadPath = _askDownloadPath ? 1 : 0;
QString downloadPath = _downloadPath.current();
QByteArray downloadPathBookmark = _downloadPathBookmark;
qint32 oldVoiceMsgPlaybackDoubled = 0;
qint32 nonDefaultVoicePlaybackSpeed = _nonDefaultVoicePlaybackSpeed ? 1 : 0;
qint32 soundNotify = _soundNotify ? 1 : 0;
qint32 desktopNotify = _desktopNotify ? 1 : 0;
qint32 flashBounceNotify = _flashBounceNotify ? 1 : 0;
@ -314,7 +314,7 @@ void Settings::addFromSerialized(const QByteArray &serialized) {
>> askDownloadPath
>> downloadPath
>> downloadPathBookmark
>> oldVoiceMsgPlaybackDoubled
>> nonDefaultVoicePlaybackSpeed
>> soundNotify
>> desktopNotify
>> flashBounceNotify
@ -529,9 +529,17 @@ void Settings::addFromSerialized(const QByteArray &serialized) {
_suggestStickersByEmoji = (suggestStickersByEmoji == 1);
_spellcheckerEnabled = (spellcheckerEnabled == 1);
_videoPlaybackSpeed = DeserializePlaybackSpeed(videoPlaybackSpeed);
_voicePlaybackSpeed = oldVoiceMsgPlaybackDoubled
? 2.0
: voicePlaybackSpeed / 100.;
{
// Restore settings from 3.0.1 version.
if (voicePlaybackSpeed == 100) {
_nonDefaultVoicePlaybackSpeed = false;
_voicePlaybackSpeed = 2.0;
} else {
_nonDefaultVoicePlaybackSpeed =
(nonDefaultVoicePlaybackSpeed == 1);
_voicePlaybackSpeed = voicePlaybackSpeed / 100.;
}
}
_videoPipGeometry = (videoPipGeometry);
_dictionariesEnabled = std::move(dictionariesEnabled);
_autoDownloadDictionaries = (autoDownloadDictionaries == 1);
@ -789,6 +797,7 @@ void Settings::resetOnLastLogout() {
_downloadPath = QString();
_downloadPathBookmark = QByteArray();
_nonDefaultVoicePlaybackSpeed = false;
_soundNotify = true;
_desktopNotify = true;
_flashBounceNotify = true;

View File

@ -421,11 +421,16 @@ public:
void setVideoPlaybackSpeed(float64 speed) {
_videoPlaybackSpeed = speed;
}
[[nodiscard]] float64 voicePlaybackSpeed() const {
return _voicePlaybackSpeed;
[[nodiscard]] float64 voicePlaybackSpeed(
bool lastNonDefault = false) const {
return (_nonDefaultVoicePlaybackSpeed || lastNonDefault)
? _voicePlaybackSpeed
: 1.0;
}
void setVoicePlaybackSpeed(float64 speed) {
_voicePlaybackSpeed = speed;
if ((_nonDefaultVoicePlaybackSpeed = (speed != 1.0))) {
_voicePlaybackSpeed = speed;
}
}
[[nodiscard]] QByteArray videoPipGeometry() const {
return _videoPipGeometry;
@ -669,7 +674,8 @@ private:
bool _suggestStickersByEmoji = true;
rpl::variable<bool> _spellcheckerEnabled = true;
rpl::variable<float64> _videoPlaybackSpeed = 1.;
float64 _voicePlaybackSpeed = 1.;
float64 _voicePlaybackSpeed = 2.;
bool _nonDefaultVoicePlaybackSpeed = false;
QByteArray _videoPipGeometry;
rpl::variable<std::vector<int>> _dictionariesEnabled;
rpl::variable<bool> _autoDownloadDictionaries = true;

View File

@ -75,6 +75,7 @@ private:
public:
SpeedController() {
setSpeed(Core::App().settings().voicePlaybackSpeed());
_speed = Core::App().settings().voicePlaybackSpeed(true);
}
[[nodiscard]] rpl::producer<float64> speedValue() const {