mirror of
https://github.com/AyuGram/AyuGramDesktop.git
synced 2025-04-22 17:17:15 +02:00
Move some more settings to Core::App.
This commit is contained in:
parent
90a9cb4f8d
commit
5d6a494934
15 changed files with 334 additions and 323 deletions
|
@ -11,13 +11,18 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
|||
#include "ui/widgets/input_fields.h"
|
||||
#include "storage/serialize_common.h"
|
||||
#include "window/themes/window_theme.h"
|
||||
#include "window/section_widget.h"
|
||||
#include "base/platform/base_platform_info.h"
|
||||
#include "facades.h"
|
||||
|
||||
namespace Core {
|
||||
|
||||
Settings::Settings()
|
||||
: _sendFilesWay(SendFilesWay::Album)
|
||||
, _sendSubmitWay(Ui::InputSubmitSettings::Enter) {
|
||||
, _sendSubmitWay(Ui::InputSubmitSettings::Enter)
|
||||
, _floatPlayerColumn(Window::Column::Second)
|
||||
, _floatPlayerCorner(RectPart::TopRight)
|
||||
, _dialogsWidthRatio(DefaultDialogsWidthRatio()) {
|
||||
}
|
||||
|
||||
QByteArray Settings::serialize() const {
|
||||
|
@ -291,6 +296,66 @@ QString Settings::getSoundPath(const QString &key) const {
|
|||
return qsl(":/sounds/") + key + qsl(".mp3");
|
||||
}
|
||||
|
||||
void Settings::setTabbedSelectorSectionEnabled(bool enabled) {
|
||||
_tabbedSelectorSectionEnabled = enabled;
|
||||
if (enabled) {
|
||||
setThirdSectionInfoEnabled(false);
|
||||
}
|
||||
setTabbedReplacedWithInfo(false);
|
||||
}
|
||||
|
||||
rpl::producer<bool> Settings::tabbedReplacedWithInfoValue() const {
|
||||
return _tabbedReplacedWithInfoValue.events_starting_with(
|
||||
tabbedReplacedWithInfo());
|
||||
}
|
||||
|
||||
void Settings::setThirdSectionInfoEnabled(bool enabled) {
|
||||
if (_thirdSectionInfoEnabled != enabled) {
|
||||
_thirdSectionInfoEnabled = enabled;
|
||||
if (enabled) {
|
||||
setTabbedSelectorSectionEnabled(false);
|
||||
}
|
||||
setTabbedReplacedWithInfo(false);
|
||||
_thirdSectionInfoEnabledValue.fire_copy(enabled);
|
||||
}
|
||||
}
|
||||
|
||||
rpl::producer<bool> Settings::thirdSectionInfoEnabledValue() const {
|
||||
return _thirdSectionInfoEnabledValue.events_starting_with(
|
||||
thirdSectionInfoEnabled());
|
||||
}
|
||||
|
||||
void Settings::setTabbedReplacedWithInfo(bool enabled) {
|
||||
if (_tabbedReplacedWithInfo != enabled) {
|
||||
_tabbedReplacedWithInfo = enabled;
|
||||
_tabbedReplacedWithInfoValue.fire_copy(enabled);
|
||||
}
|
||||
}
|
||||
|
||||
void Settings::setDialogsWidthRatio(float64 ratio) {
|
||||
_dialogsWidthRatio = ratio;
|
||||
}
|
||||
|
||||
float64 Settings::dialogsWidthRatio() const {
|
||||
return _dialogsWidthRatio.current();
|
||||
}
|
||||
|
||||
rpl::producer<float64> Settings::dialogsWidthRatioChanges() const {
|
||||
return _dialogsWidthRatio.changes();
|
||||
}
|
||||
|
||||
void Settings::setThirdColumnWidth(int width) {
|
||||
_thirdColumnWidth = width;
|
||||
}
|
||||
|
||||
int Settings::thirdColumnWidth() const {
|
||||
return _thirdColumnWidth.current();
|
||||
}
|
||||
|
||||
rpl::producer<int> Settings::thirdColumnWidthChanges() const {
|
||||
return _thirdColumnWidth.changes();
|
||||
}
|
||||
|
||||
void Settings::resetOnLastLogout() {
|
||||
_adaptiveForWide = true;
|
||||
_moderateModeEnabled = false;
|
||||
|
@ -340,6 +405,24 @@ void Settings::resetOnLastLogout() {
|
|||
_dictionariesEnabled = std::vector<int>();
|
||||
_autoDownloadDictionaries = true;
|
||||
_mainMenuAccountsShown = false;
|
||||
_tabbedSelectorSectionEnabled = false; // per-window
|
||||
_floatPlayerColumn = Window::Column::Second; // per-window
|
||||
_floatPlayerCorner = RectPart::TopRight; // per-window
|
||||
_thirdSectionInfoEnabled = true; // per-window
|
||||
_thirdSectionExtendedBy = -1; // per-window
|
||||
_dialogsWidthRatio = DefaultDialogsWidthRatio(); // per-window
|
||||
_thirdColumnWidth = kDefaultThirdColumnWidth; // p-w
|
||||
_tabbedReplacedWithInfo = false; // per-window
|
||||
}
|
||||
|
||||
bool Settings::ThirdColumnByDefault() {
|
||||
return Platform::IsMacStoreBuild();
|
||||
}
|
||||
|
||||
float64 Settings::DefaultDialogsWidthRatio() {
|
||||
return ThirdColumnByDefault()
|
||||
? kDefaultBigDialogsWidthRatio
|
||||
: kDefaultDialogsWidthRatio;
|
||||
}
|
||||
|
||||
} // namespace Core
|
||||
|
|
|
@ -10,11 +10,16 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
|||
#include "window/themes/window_themes_embedded.h"
|
||||
|
||||
enum class SendFilesWay;
|
||||
enum class RectPart;
|
||||
|
||||
namespace Ui {
|
||||
enum class InputSubmitSettings;
|
||||
} // namespace Ui
|
||||
|
||||
namespace Window {
|
||||
enum class Column;
|
||||
} // namespace Window
|
||||
|
||||
namespace Core {
|
||||
|
||||
class Settings final {
|
||||
|
@ -358,7 +363,47 @@ public:
|
|||
void setMainMenuAccountsShown(bool value) {
|
||||
_mainMenuAccountsShown = value;
|
||||
}
|
||||
[[nodiscard]] bool tabbedSelectorSectionEnabled() const {
|
||||
return _tabbedSelectorSectionEnabled;
|
||||
}
|
||||
void setTabbedSelectorSectionEnabled(bool enabled);
|
||||
[[nodiscard]] bool thirdSectionInfoEnabled() const {
|
||||
return _thirdSectionInfoEnabled;
|
||||
}
|
||||
void setThirdSectionInfoEnabled(bool enabled);
|
||||
[[nodiscard]] rpl::producer<bool> thirdSectionInfoEnabledValue() const;
|
||||
[[nodiscard]] int thirdSectionExtendedBy() const {
|
||||
return _thirdSectionExtendedBy;
|
||||
}
|
||||
void setThirdSectionExtendedBy(int savedValue) {
|
||||
_thirdSectionExtendedBy = savedValue;
|
||||
}
|
||||
[[nodiscard]] bool tabbedReplacedWithInfo() const {
|
||||
return _tabbedReplacedWithInfo;
|
||||
}
|
||||
void setTabbedReplacedWithInfo(bool enabled);
|
||||
[[nodiscard]] rpl::producer<bool> tabbedReplacedWithInfoValue() const;
|
||||
void setFloatPlayerColumn(Window::Column column) {
|
||||
_floatPlayerColumn = column;
|
||||
}
|
||||
[[nodiscard]] Window::Column floatPlayerColumn() const {
|
||||
return _floatPlayerColumn;
|
||||
}
|
||||
void setFloatPlayerCorner(RectPart corner) {
|
||||
_floatPlayerCorner = corner;
|
||||
}
|
||||
[[nodiscard]] RectPart floatPlayerCorner() const {
|
||||
return _floatPlayerCorner;
|
||||
}
|
||||
void setDialogsWidthRatio(float64 ratio);
|
||||
[[nodiscard]] float64 dialogsWidthRatio() const;
|
||||
[[nodiscard]] rpl::producer<float64> dialogsWidthRatioChanges() const;
|
||||
void setThirdColumnWidth(int width);
|
||||
[[nodiscard]] int thirdColumnWidth() const;
|
||||
[[nodiscard]] rpl::producer<int> thirdColumnWidthChanges() const;
|
||||
|
||||
[[nodiscard]] static bool ThirdColumnByDefault();
|
||||
[[nodiscard]] float64 DefaultDialogsWidthRatio();
|
||||
[[nodiscard]] static qint32 SerializePlaybackSpeed(float64 speed) {
|
||||
return int(std::round(std::clamp(speed * 4., 2., 8.))) - 2;
|
||||
}
|
||||
|
@ -369,16 +414,17 @@ public:
|
|||
void resetOnLastLogout();
|
||||
|
||||
private:
|
||||
static constexpr auto kDefaultThirdColumnWidth = 0;
|
||||
static constexpr auto kDefaultDialogsWidthRatio = 5. / 14;
|
||||
static constexpr auto kDefaultBigDialogsWidthRatio = 0.275;
|
||||
|
||||
bool _adaptiveForWide = true;
|
||||
bool _moderateModeEnabled = false;
|
||||
|
||||
rpl::variable<float64> _songVolume = kDefaultVolume;
|
||||
rpl::variable<float64> _videoVolume = kDefaultVolume;
|
||||
|
||||
bool _askDownloadPath = false;
|
||||
rpl::variable<QString> _downloadPath;
|
||||
QByteArray _downloadPathBookmark;
|
||||
|
||||
bool _voiceMsgPlaybackDoubled = false;
|
||||
bool _soundNotify = true;
|
||||
bool _desktopNotify = true;
|
||||
|
@ -391,20 +437,16 @@ private:
|
|||
bool _countUnreadMessages = true;
|
||||
rpl::variable<bool> _notifyAboutPinned = true;
|
||||
int _autoLock = 3600;
|
||||
|
||||
QString _callOutputDeviceID = u"default"_q;
|
||||
QString _callInputDeviceID = u"default"_q;
|
||||
int _callOutputVolume = 100;
|
||||
int _callInputVolume = 100;
|
||||
bool _callAudioDuckingEnabled = true;
|
||||
|
||||
Window::Theme::AccentColors _themesAccentColors;
|
||||
|
||||
bool _lastSeenWarningSeen = false;
|
||||
SendFilesWay _sendFilesWay;
|
||||
Ui::InputSubmitSettings _sendSubmitWay;
|
||||
base::flat_map<QString, QString> _soundOverrides;
|
||||
|
||||
bool _exeLaunchWarning = true;
|
||||
bool _loopAnimatedStickers = true;
|
||||
rpl::variable<bool> _largeEmoji = true;
|
||||
|
@ -417,6 +459,17 @@ private:
|
|||
rpl::variable<std::vector<int>> _dictionariesEnabled;
|
||||
rpl::variable<bool> _autoDownloadDictionaries = true;
|
||||
rpl::variable<bool> _mainMenuAccountsShown = false;
|
||||
bool _tabbedSelectorSectionEnabled = false; // per-window
|
||||
Window::Column _floatPlayerColumn; // per-window
|
||||
RectPart _floatPlayerCorner; // per-window
|
||||
bool _thirdSectionInfoEnabled = true; // per-window
|
||||
rpl::event_stream<bool> _thirdSectionInfoEnabledValue; // per-window
|
||||
int _thirdSectionExtendedBy = -1; // per-window
|
||||
rpl::variable<float64> _dialogsWidthRatio; // per-window
|
||||
rpl::variable<int> _thirdColumnWidth = kDefaultThirdColumnWidth; // p-w
|
||||
|
||||
bool _tabbedReplacedWithInfo = false; // per-window
|
||||
rpl::event_stream<bool> _tabbedReplacedWithInfoValue; // per-window
|
||||
|
||||
float64 _rememberedSongVolume = kDefaultVolume;
|
||||
bool _rememberedSoundNotifyFromTray = false;
|
||||
|
|
|
@ -4154,11 +4154,11 @@ bool HistoryWidget::pushTabbedSelectorToThirdSection(
|
|||
if (!_tabbedPanel) {
|
||||
return true;
|
||||
} else if (!peer->canWrite()) {
|
||||
session().settings().setTabbedReplacedWithInfo(true);
|
||||
Core::App().settings().setTabbedReplacedWithInfo(true);
|
||||
controller()->showPeerInfo(peer, params.withThirdColumn());
|
||||
return false;
|
||||
}
|
||||
session().settings().setTabbedReplacedWithInfo(false);
|
||||
Core::App().settings().setTabbedReplacedWithInfo(false);
|
||||
controller()->resizeForThirdSection();
|
||||
controller()->showSection(
|
||||
ChatHelpers::TabbedMemento(),
|
||||
|
@ -4198,8 +4198,8 @@ void HistoryWidget::toggleTabbedSelectorMode() {
|
|||
}
|
||||
if (_tabbedPanel) {
|
||||
if (controller()->canShowThirdSection() && !Adaptive::OneColumn()) {
|
||||
session().settings().setTabbedSelectorSectionEnabled(true);
|
||||
session().saveSettingsDelayed();
|
||||
Core::App().settings().setTabbedSelectorSectionEnabled(true);
|
||||
Core::App().saveSettingsDelayed();
|
||||
pushTabbedSelectorToThirdSection(
|
||||
_peer,
|
||||
Window::SectionShow::Way::ClearStack);
|
||||
|
|
|
@ -21,8 +21,6 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
|||
#include "chat_helpers/message_field.h"
|
||||
#include "chat_helpers/emoji_suggestions_widget.h"
|
||||
#include "window/window_session_controller.h"
|
||||
#include "main/main_session.h"
|
||||
#include "main/main_session_settings.h"
|
||||
#include "core/application.h"
|
||||
#include "core/core_settings.h"
|
||||
#include "inline_bots/inline_results_widget.h"
|
||||
|
@ -347,11 +345,11 @@ bool ComposeControls::pushTabbedSelectorToThirdSection(
|
|||
if (!_tabbedPanel) {
|
||||
return true;
|
||||
//} else if (!_canSendMessages) {
|
||||
// session().settings().setTabbedReplacedWithInfo(true);
|
||||
// Core::App().settings().setTabbedReplacedWithInfo(true);
|
||||
// _window->showPeerInfo(_peer, params.withThirdColumn());
|
||||
// return;
|
||||
}
|
||||
session().settings().setTabbedReplacedWithInfo(false);
|
||||
Core::App().settings().setTabbedReplacedWithInfo(false);
|
||||
_tabbedSelectorToggle->setColorOverrides(
|
||||
&st::historyAttachEmojiActive,
|
||||
&st::historyRecordVoiceFgActive,
|
||||
|
@ -396,8 +394,8 @@ void ComposeControls::toggleTabbedSelectorMode() {
|
|||
}
|
||||
if (_tabbedPanel) {
|
||||
if (_window->canShowThirdSection() && !Adaptive::OneColumn()) {
|
||||
session().settings().setTabbedSelectorSectionEnabled(true);
|
||||
session().saveSettingsDelayed();
|
||||
Core::App().settings().setTabbedSelectorSectionEnabled(true);
|
||||
Core::App().saveSettingsDelayed();
|
||||
pushTabbedSelectorToThirdSection(
|
||||
_history->peer,
|
||||
Window::SectionShow::Way::ClearStack);
|
||||
|
|
|
@ -18,10 +18,11 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
|||
#include "mainwidget.h"
|
||||
#include "mainwindow.h"
|
||||
#include "main/main_session.h"
|
||||
#include "main/main_session_settings.h"
|
||||
#include "mtproto/mtproto_config.h"
|
||||
#include "lang/lang_keys.h"
|
||||
#include "core/shortcuts.h"
|
||||
#include "core/application.h"
|
||||
#include "core/core_settings.h"
|
||||
#include "ui/widgets/buttons.h"
|
||||
#include "ui/widgets/dropdown_menu.h"
|
||||
#include "ui/effects/radial_animation.h"
|
||||
|
@ -137,17 +138,17 @@ TopBarWidget::TopBarWidget(
|
|||
}, lifetime());
|
||||
|
||||
rpl::combine(
|
||||
session().settings().thirdSectionInfoEnabledValue(),
|
||||
session().settings().tabbedReplacedWithInfoValue()
|
||||
) | rpl::start_with_next(
|
||||
[this] { updateInfoToggleActive(); },
|
||||
lifetime());
|
||||
Core::App().settings().thirdSectionInfoEnabledValue(),
|
||||
Core::App().settings().tabbedReplacedWithInfoValue()
|
||||
) | rpl::start_with_next([=] {
|
||||
updateInfoToggleActive();
|
||||
}, lifetime());
|
||||
|
||||
rpl::single(rpl::empty_value()) | rpl::then(
|
||||
base::ObservableViewer(Global::RefConnectionTypeChanged())
|
||||
) | rpl::start_with_next(
|
||||
[=] { updateConnectingState(); },
|
||||
lifetime());
|
||||
) | rpl::start_with_next([=] {
|
||||
updateConnectingState();
|
||||
}, lifetime());
|
||||
|
||||
setCursor(style::cur_pointer);
|
||||
}
|
||||
|
@ -252,13 +253,13 @@ void TopBarWidget::showMenu() {
|
|||
|
||||
void TopBarWidget::toggleInfoSection() {
|
||||
if (Adaptive::ThreeColumn()
|
||||
&& (session().settings().thirdSectionInfoEnabled()
|
||||
|| session().settings().tabbedReplacedWithInfo())) {
|
||||
&& (Core::App().settings().thirdSectionInfoEnabled()
|
||||
|| Core::App().settings().tabbedReplacedWithInfo())) {
|
||||
_controller->closeThirdSection();
|
||||
} else if (_activeChat.peer()) {
|
||||
if (_controller->canShowThirdSection()) {
|
||||
session().settings().setThirdSectionInfoEnabled(true);
|
||||
session().saveSettingsDelayed();
|
||||
Core::App().settings().setThirdSectionInfoEnabled(true);
|
||||
Core::App().saveSettingsDelayed();
|
||||
if (Adaptive::ThreeColumn()) {
|
||||
_controller->showSection(
|
||||
Info::Memento::Default(_activeChat.peer()),
|
||||
|
@ -791,8 +792,8 @@ void TopBarWidget::updateUnreadBadge() {
|
|||
|
||||
void TopBarWidget::updateInfoToggleActive() {
|
||||
auto infoThirdActive = Adaptive::ThreeColumn()
|
||||
&& (session().settings().thirdSectionInfoEnabled()
|
||||
|| session().settings().tabbedReplacedWithInfo());
|
||||
&& (Core::App().settings().thirdSectionInfoEnabled()
|
||||
|| Core::App().settings().tabbedReplacedWithInfo());
|
||||
auto iconOverride = infoThirdActive
|
||||
? &st::topBarInfoActive
|
||||
: nullptr;
|
||||
|
|
|
@ -8,14 +8,13 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
|||
#include "main/main_session_settings.h"
|
||||
|
||||
#include "chat_helpers/tabbed_selector.h"
|
||||
#include "window/section_widget.h"
|
||||
#include "ui/widgets/input_fields.h"
|
||||
#include "window/section_widget.h"
|
||||
#include "support/support_common.h"
|
||||
#include "storage/serialize_common.h"
|
||||
#include "boxes/send_files_box.h"
|
||||
#include "core/application.h"
|
||||
#include "core/core_settings.h"
|
||||
#include "base/platform/base_platform_info.h"
|
||||
|
||||
namespace Main {
|
||||
namespace {
|
||||
|
@ -29,18 +28,9 @@ constexpr auto kMaxSavedPlaybackPositions = 16;
|
|||
|
||||
SessionSettings::SessionSettings()
|
||||
: _selectorTab(ChatHelpers::SelectorTab::Emoji)
|
||||
, _floatPlayerColumn(Window::Column::Second)
|
||||
, _floatPlayerCorner(RectPart::TopRight)
|
||||
, _dialogsWidthRatio(ThirdColumnByDefault()
|
||||
? kDefaultBigDialogsWidthRatio
|
||||
: kDefaultDialogsWidthRatio)
|
||||
, _supportSwitch(Support::SwitchSettings::Next) {
|
||||
}
|
||||
|
||||
bool SessionSettings::ThirdColumnByDefault() {
|
||||
return Platform::IsMacStoreBuild();
|
||||
}
|
||||
|
||||
QByteArray SessionSettings::serialize() const {
|
||||
const auto autoDownload = _autoDownload.serialize();
|
||||
auto size = sizeof(qint32) * 38;
|
||||
|
@ -56,21 +46,10 @@ QByteArray SessionSettings::serialize() const {
|
|||
stream.setVersion(QDataStream::Qt_5_1);
|
||||
stream << qint32(kVersionTag) << qint32(kVersion);
|
||||
stream << static_cast<qint32>(_selectorTab);
|
||||
stream << qint32(_tabbedSelectorSectionEnabled ? 1 : 0);
|
||||
stream << qint32(_floatPlayerColumn);
|
||||
stream << qint32(_floatPlayerCorner);
|
||||
stream << qint32(_groupStickersSectionHidden.size());
|
||||
for (auto peerId : _groupStickersSectionHidden) {
|
||||
stream << quint64(peerId);
|
||||
}
|
||||
stream << qint32(_thirdSectionInfoEnabled ? 1 : 0);
|
||||
stream << qint32(_smallDialogsList ? 1 : 0);
|
||||
stream << qint32(snap(
|
||||
qRound(_dialogsWidthRatio.current() * 1000000),
|
||||
0,
|
||||
1000000));
|
||||
stream << qint32(_thirdColumnWidth.current());
|
||||
stream << qint32(_thirdSectionExtendedBy);
|
||||
stream << qint32(_supportSwitch);
|
||||
stream << qint32(_supportFixChatsOrder ? 1 : 0);
|
||||
stream << qint32(_supportTemplatesAutocomplete ? 1 : 0);
|
||||
|
@ -106,17 +85,17 @@ void SessionSettings::addFromSerialized(const QByteArray &serialized) {
|
|||
qint32 version = 0;
|
||||
qint32 selectorTab = static_cast<qint32>(ChatHelpers::SelectorTab::Emoji);
|
||||
qint32 appLastSeenWarningSeen = app.lastSeenWarningSeen() ? 1 : 0;
|
||||
qint32 tabbedSelectorSectionEnabled = 1;
|
||||
qint32 appTabbedSelectorSectionEnabled = 1;
|
||||
qint32 legacyTabbedSelectorSectionTooltipShown = 0;
|
||||
qint32 floatPlayerColumn = static_cast<qint32>(Window::Column::Second);
|
||||
qint32 floatPlayerCorner = static_cast<qint32>(RectPart::TopRight);
|
||||
qint32 appFloatPlayerColumn = static_cast<qint32>(Window::Column::Second);
|
||||
qint32 appFloatPlayerCorner = static_cast<qint32>(RectPart::TopRight);
|
||||
base::flat_map<QString, QString> appSoundOverrides;
|
||||
base::flat_set<PeerId> groupStickersSectionHidden;
|
||||
qint32 thirdSectionInfoEnabled = 0;
|
||||
qint32 smallDialogsList = 0;
|
||||
float64 dialogsWidthRatio = _dialogsWidthRatio.current();
|
||||
int thirdColumnWidth = _thirdColumnWidth.current();
|
||||
int thirdSectionExtendedBy = _thirdSectionExtendedBy;
|
||||
qint32 appThirdSectionInfoEnabled = 0;
|
||||
qint32 legacySmallDialogsList = 0;
|
||||
float64 appDialogsWidthRatio = app.dialogsWidthRatio();
|
||||
int appThirdColumnWidth = app.thirdColumnWidth();
|
||||
int appThirdSectionExtendedBy = app.thirdSectionExtendedBy();
|
||||
qint32 appSendFilesWay = static_cast<qint32>(app.sendFilesWay());
|
||||
qint32 legacyCallsPeerToPeer = qint32(0);
|
||||
qint32 appSendSubmitWay = static_cast<qint32>(app.sendSubmitWay());
|
||||
|
@ -157,11 +136,9 @@ void SessionSettings::addFromSerialized(const QByteArray &serialized) {
|
|||
}
|
||||
if (version < 2) {
|
||||
stream >> appLastSeenWarningSeen;
|
||||
}
|
||||
if (!stream.atEnd()) {
|
||||
stream >> tabbedSelectorSectionEnabled;
|
||||
stream >> appTabbedSelectorSectionEnabled;
|
||||
}
|
||||
if (version < 2) {
|
||||
if (!stream.atEnd()) {
|
||||
auto count = qint32(0);
|
||||
stream >> count;
|
||||
|
@ -169,6 +146,11 @@ void SessionSettings::addFromSerialized(const QByteArray &serialized) {
|
|||
for (auto i = 0; i != count; ++i) {
|
||||
QString key, value;
|
||||
stream >> key >> value;
|
||||
if (stream.status() != QDataStream::Ok) {
|
||||
LOG(("App Error: "
|
||||
"Bad data for SessionSettings::addFromSerialized()"));
|
||||
return;
|
||||
}
|
||||
appSoundOverrides.emplace(key, value);
|
||||
}
|
||||
}
|
||||
|
@ -176,9 +158,9 @@ void SessionSettings::addFromSerialized(const QByteArray &serialized) {
|
|||
if (!stream.atEnd()) {
|
||||
stream >> legacyTabbedSelectorSectionTooltipShown;
|
||||
}
|
||||
}
|
||||
if (!stream.atEnd()) {
|
||||
stream >> floatPlayerColumn >> floatPlayerCorner;
|
||||
stream >> appFloatPlayerColumn >> appFloatPlayerCorner;
|
||||
}
|
||||
}
|
||||
if (!stream.atEnd()) {
|
||||
auto count = qint32(0);
|
||||
|
@ -187,26 +169,31 @@ void SessionSettings::addFromSerialized(const QByteArray &serialized) {
|
|||
for (auto i = 0; i != count; ++i) {
|
||||
quint64 peerId;
|
||||
stream >> peerId;
|
||||
if (stream.status() != QDataStream::Ok) {
|
||||
LOG(("App Error: "
|
||||
"Bad data for SessionSettings::addFromSerialized()"));
|
||||
return;
|
||||
}
|
||||
groupStickersSectionHidden.insert(peerId);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (version < 2) {
|
||||
if (!stream.atEnd()) {
|
||||
stream >> thirdSectionInfoEnabled;
|
||||
stream >> smallDialogsList;
|
||||
stream >> appThirdSectionInfoEnabled;
|
||||
stream >> legacySmallDialogsList;
|
||||
}
|
||||
if (!stream.atEnd()) {
|
||||
qint32 value = 0;
|
||||
stream >> value;
|
||||
dialogsWidthRatio = snap(value / 1000000., 0., 1.);
|
||||
appDialogsWidthRatio = snap(value / 1000000., 0., 1.);
|
||||
|
||||
stream >> value;
|
||||
thirdColumnWidth = value;
|
||||
appThirdColumnWidth = value;
|
||||
|
||||
stream >> value;
|
||||
thirdSectionExtendedBy = value;
|
||||
appThirdSectionExtendedBy = value;
|
||||
}
|
||||
if (version < 2) {
|
||||
if (!stream.atEnd()) {
|
||||
stream >> appSendFilesWay;
|
||||
}
|
||||
|
@ -277,6 +264,11 @@ void SessionSettings::addFromSerialized(const QByteArray &serialized) {
|
|||
quint64 documentId;
|
||||
qint64 time;
|
||||
stream >> documentId >> time;
|
||||
if (stream.status() != QDataStream::Ok) {
|
||||
LOG(("App Error: "
|
||||
"Bad data for SessionSettings::addFromSerialized()"));
|
||||
return;
|
||||
}
|
||||
mediaLastPlaybackPosition.emplace_back(documentId, time);
|
||||
}
|
||||
}
|
||||
|
@ -295,6 +287,11 @@ void SessionSettings::addFromSerialized(const QByteArray &serialized) {
|
|||
for (auto i = 0; i != count; ++i) {
|
||||
qint64 langId;
|
||||
stream >> langId;
|
||||
if (stream.status() != QDataStream::Ok) {
|
||||
LOG(("App Error: "
|
||||
"Bad data for SessionSettings::addFromSerialized()"));
|
||||
return;
|
||||
}
|
||||
appDictionariesEnabled.emplace_back(langId);
|
||||
}
|
||||
}
|
||||
|
@ -311,6 +308,11 @@ void SessionSettings::addFromSerialized(const QByteArray &serialized) {
|
|||
auto key = quint64();
|
||||
auto value = qint32();
|
||||
stream >> key >> value;
|
||||
if (stream.status() != QDataStream::Ok) {
|
||||
LOG(("App Error: "
|
||||
"Bad data for SessionSettings::addFromSerialized()"));
|
||||
return;
|
||||
}
|
||||
hiddenPinnedMessages.emplace(key, value);
|
||||
}
|
||||
}
|
||||
|
@ -320,7 +322,7 @@ void SessionSettings::addFromSerialized(const QByteArray &serialized) {
|
|||
}
|
||||
if (stream.status() != QDataStream::Ok) {
|
||||
LOG(("App Error: "
|
||||
"Bad data for Main::SessionSettings::FromSerialized()"));
|
||||
"Bad data for SessionSettings::addFromSerialized()"));
|
||||
return;
|
||||
}
|
||||
if (!autoDownload.isEmpty()
|
||||
|
@ -340,29 +342,7 @@ void SessionSettings::addFromSerialized(const QByteArray &serialized) {
|
|||
case ChatHelpers::SelectorTab::Stickers:
|
||||
case ChatHelpers::SelectorTab::Gifs: _selectorTab = uncheckedTab; break;
|
||||
}
|
||||
_tabbedSelectorSectionEnabled = (tabbedSelectorSectionEnabled == 1);
|
||||
auto uncheckedColumn = static_cast<Window::Column>(floatPlayerColumn);
|
||||
switch (uncheckedColumn) {
|
||||
case Window::Column::First:
|
||||
case Window::Column::Second:
|
||||
case Window::Column::Third: _floatPlayerColumn = uncheckedColumn; break;
|
||||
}
|
||||
auto uncheckedCorner = static_cast<RectPart>(floatPlayerCorner);
|
||||
switch (uncheckedCorner) {
|
||||
case RectPart::TopLeft:
|
||||
case RectPart::TopRight:
|
||||
case RectPart::BottomLeft:
|
||||
case RectPart::BottomRight: _floatPlayerCorner = uncheckedCorner; break;
|
||||
}
|
||||
_groupStickersSectionHidden = std::move(groupStickersSectionHidden);
|
||||
_thirdSectionInfoEnabled = thirdSectionInfoEnabled;
|
||||
_smallDialogsList = smallDialogsList;
|
||||
_dialogsWidthRatio = dialogsWidthRatio;
|
||||
_thirdColumnWidth = thirdColumnWidth;
|
||||
_thirdSectionExtendedBy = thirdSectionExtendedBy;
|
||||
if (_thirdSectionInfoEnabled) {
|
||||
_tabbedSelectorSectionEnabled = false;
|
||||
}
|
||||
auto uncheckedSupportSwitch = static_cast<Support::SwitchSettings>(
|
||||
supportSwitch);
|
||||
switch (uncheckedSupportSwitch) {
|
||||
|
@ -413,6 +393,24 @@ void SessionSettings::addFromSerialized(const QByteArray &serialized) {
|
|||
app.setVideoPipGeometry(appVideoPipGeometry);
|
||||
app.setDictionariesEnabled(std::move(appDictionariesEnabled));
|
||||
app.setAutoDownloadDictionaries(appAutoDownloadDictionaries == 1);
|
||||
app.setTabbedSelectorSectionEnabled(appTabbedSelectorSectionEnabled == 1);
|
||||
auto uncheckedColumn = static_cast<Window::Column>(appFloatPlayerColumn);
|
||||
switch (uncheckedColumn) {
|
||||
case Window::Column::First:
|
||||
case Window::Column::Second:
|
||||
case Window::Column::Third: app.setFloatPlayerColumn(uncheckedColumn); break;
|
||||
}
|
||||
auto uncheckedCorner = static_cast<RectPart>(appFloatPlayerCorner);
|
||||
switch (uncheckedCorner) {
|
||||
case RectPart::TopLeft:
|
||||
case RectPart::TopRight:
|
||||
case RectPart::BottomLeft:
|
||||
case RectPart::BottomRight: app.setFloatPlayerCorner(uncheckedCorner); break;
|
||||
}
|
||||
app.setThirdSectionInfoEnabled(appThirdSectionInfoEnabled);
|
||||
app.setDialogsWidthRatio(appDialogsWidthRatio);
|
||||
app.setThirdColumnWidth(appThirdColumnWidth);
|
||||
app.setThirdSectionExtendedBy(appThirdSectionExtendedBy);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -440,66 +438,6 @@ rpl::producer<bool> SessionSettings::supportAllSearchResultsValue() const {
|
|||
return _supportAllSearchResults.value();
|
||||
}
|
||||
|
||||
void SessionSettings::setTabbedSelectorSectionEnabled(bool enabled) {
|
||||
_tabbedSelectorSectionEnabled = enabled;
|
||||
if (enabled) {
|
||||
setThirdSectionInfoEnabled(false);
|
||||
}
|
||||
setTabbedReplacedWithInfo(false);
|
||||
}
|
||||
|
||||
rpl::producer<bool> SessionSettings::tabbedReplacedWithInfoValue() const {
|
||||
return _tabbedReplacedWithInfoValue.events_starting_with(
|
||||
tabbedReplacedWithInfo());
|
||||
}
|
||||
|
||||
void SessionSettings::setThirdSectionInfoEnabled(bool enabled) {
|
||||
if (_thirdSectionInfoEnabled != enabled) {
|
||||
_thirdSectionInfoEnabled = enabled;
|
||||
if (enabled) {
|
||||
setTabbedSelectorSectionEnabled(false);
|
||||
}
|
||||
setTabbedReplacedWithInfo(false);
|
||||
_thirdSectionInfoEnabledValue.fire_copy(enabled);
|
||||
}
|
||||
}
|
||||
|
||||
rpl::producer<bool> SessionSettings::thirdSectionInfoEnabledValue() const {
|
||||
return _thirdSectionInfoEnabledValue.events_starting_with(
|
||||
thirdSectionInfoEnabled());
|
||||
}
|
||||
|
||||
void SessionSettings::setTabbedReplacedWithInfo(bool enabled) {
|
||||
if (_tabbedReplacedWithInfo != enabled) {
|
||||
_tabbedReplacedWithInfo = enabled;
|
||||
_tabbedReplacedWithInfoValue.fire_copy(enabled);
|
||||
}
|
||||
}
|
||||
|
||||
void SessionSettings::setDialogsWidthRatio(float64 ratio) {
|
||||
_dialogsWidthRatio = ratio;
|
||||
}
|
||||
|
||||
float64 SessionSettings::dialogsWidthRatio() const {
|
||||
return _dialogsWidthRatio.current();
|
||||
}
|
||||
|
||||
rpl::producer<float64> SessionSettings::dialogsWidthRatioChanges() const {
|
||||
return _dialogsWidthRatio.changes();
|
||||
}
|
||||
|
||||
void SessionSettings::setThirdColumnWidth(int width) {
|
||||
_thirdColumnWidth = width;
|
||||
}
|
||||
|
||||
int SessionSettings::thirdColumnWidth() const {
|
||||
return _thirdColumnWidth.current();
|
||||
}
|
||||
|
||||
rpl::producer<int> SessionSettings::thirdColumnWidthChanges() const {
|
||||
return _thirdColumnWidth.changes();
|
||||
}
|
||||
|
||||
void SessionSettings::setMediaLastPlaybackPosition(DocumentId id, crl::time time) {
|
||||
auto &map = _mediaLastPlaybackPosition;
|
||||
const auto i = ranges::find(
|
||||
|
|
|
@ -14,10 +14,6 @@ namespace Support {
|
|||
enum class SwitchSettings;
|
||||
} // namespace Support
|
||||
|
||||
namespace Window {
|
||||
enum class Column;
|
||||
} // namespace Window
|
||||
|
||||
namespace ChatHelpers {
|
||||
enum class SelectorTab;
|
||||
} // namespace ChatHelpers
|
||||
|
@ -62,50 +58,6 @@ public:
|
|||
void setSelectorTab(ChatHelpers::SelectorTab tab) {
|
||||
_selectorTab = tab;
|
||||
}
|
||||
[[nodiscard]] bool tabbedSelectorSectionEnabled() const {
|
||||
return _tabbedSelectorSectionEnabled;
|
||||
}
|
||||
void setTabbedSelectorSectionEnabled(bool enabled);
|
||||
[[nodiscard]] bool thirdSectionInfoEnabled() const {
|
||||
return _thirdSectionInfoEnabled;
|
||||
}
|
||||
void setThirdSectionInfoEnabled(bool enabled);
|
||||
[[nodiscard]] rpl::producer<bool> thirdSectionInfoEnabledValue() const;
|
||||
[[nodiscard]] int thirdSectionExtendedBy() const {
|
||||
return _thirdSectionExtendedBy;
|
||||
}
|
||||
void setThirdSectionExtendedBy(int savedValue) {
|
||||
_thirdSectionExtendedBy = savedValue;
|
||||
}
|
||||
[[nodiscard]] bool tabbedReplacedWithInfo() const {
|
||||
return _tabbedReplacedWithInfo;
|
||||
}
|
||||
void setTabbedReplacedWithInfo(bool enabled);
|
||||
[[nodiscard]] rpl::producer<bool> tabbedReplacedWithInfoValue() const;
|
||||
void setSmallDialogsList(bool enabled) {
|
||||
_smallDialogsList = enabled;
|
||||
}
|
||||
[[nodiscard]] bool smallDialogsList() const {
|
||||
return _smallDialogsList;
|
||||
}
|
||||
void setFloatPlayerColumn(Window::Column column) {
|
||||
_floatPlayerColumn = column;
|
||||
}
|
||||
[[nodiscard]] Window::Column floatPlayerColumn() const {
|
||||
return _floatPlayerColumn;
|
||||
}
|
||||
void setFloatPlayerCorner(RectPart corner) {
|
||||
_floatPlayerCorner = corner;
|
||||
}
|
||||
[[nodiscard]] RectPart floatPlayerCorner() const {
|
||||
return _floatPlayerCorner;
|
||||
}
|
||||
void setDialogsWidthRatio(float64 ratio);
|
||||
[[nodiscard]] float64 dialogsWidthRatio() const;
|
||||
[[nodiscard]] rpl::producer<float64> dialogsWidthRatioChanges() const;
|
||||
void setThirdColumnWidth(int width);
|
||||
[[nodiscard]] int thirdColumnWidth() const;
|
||||
[[nodiscard]] rpl::producer<int> thirdColumnWidthChanges() const;
|
||||
|
||||
void setGroupStickersSectionHidden(PeerId peerId) {
|
||||
_groupStickersSectionHidden.insert(peerId);
|
||||
|
@ -162,24 +114,11 @@ public:
|
|||
_dialogsFiltersEnabled = value;
|
||||
}
|
||||
|
||||
[[nodiscard]] static bool ThirdColumnByDefault();
|
||||
|
||||
private:
|
||||
static constexpr auto kDefaultDialogsWidthRatio = 5. / 14;
|
||||
static constexpr auto kDefaultBigDialogsWidthRatio = 0.275;
|
||||
static constexpr auto kDefaultThirdColumnWidth = 0;
|
||||
static constexpr auto kDefaultSupportChatsLimitSlice = 7 * 24 * 60 * 60;
|
||||
|
||||
ChatHelpers::SelectorTab _selectorTab; // per-window
|
||||
bool _tabbedSelectorSectionEnabled = false; // per-window
|
||||
Window::Column _floatPlayerColumn; // per-window
|
||||
RectPart _floatPlayerCorner; // per-window
|
||||
base::flat_set<PeerId> _groupStickersSectionHidden;
|
||||
bool _thirdSectionInfoEnabled = true; // per-window
|
||||
bool _smallDialogsList = false; // per-window
|
||||
int _thirdSectionExtendedBy = -1; // per-window
|
||||
rpl::variable<float64> _dialogsWidthRatio; // per-window
|
||||
rpl::variable<int> _thirdColumnWidth = kDefaultThirdColumnWidth; // p-w
|
||||
bool _hadLegacyCallsPeerToPeerNobody = false;
|
||||
Data::AutoDownload::Full _autoDownload;
|
||||
rpl::variable<bool> _archiveCollapsed = false;
|
||||
|
@ -196,10 +135,6 @@ private:
|
|||
= kDefaultSupportChatsLimitSlice;
|
||||
rpl::variable<bool> _supportAllSearchResults = false;
|
||||
|
||||
rpl::event_stream<bool> _thirdSectionInfoEnabledValue;
|
||||
bool _tabbedReplacedWithInfo = false;
|
||||
rpl::event_stream<bool> _tabbedReplacedWithInfoValue;
|
||||
|
||||
};
|
||||
|
||||
} // namespace Main
|
||||
|
|
|
@ -280,11 +280,11 @@ MainWidget::MainWidget(
|
|||
updateDialogsWidthAnimated();
|
||||
});
|
||||
rpl::merge(
|
||||
session().settings().dialogsWidthRatioChanges() | rpl::to_empty,
|
||||
session().settings().thirdColumnWidthChanges() | rpl::to_empty
|
||||
) | rpl::start_with_next(
|
||||
[this] { updateControlsGeometry(); },
|
||||
lifetime());
|
||||
Core::App().settings().dialogsWidthRatioChanges() | rpl::to_empty,
|
||||
Core::App().settings().thirdColumnWidthChanges() | rpl::to_empty
|
||||
) | rpl::start_with_next([=] {
|
||||
updateControlsGeometry();
|
||||
}, lifetime());
|
||||
|
||||
session().changes().historyUpdates(
|
||||
Data::HistoryUpdate::Flag::MessageSent
|
||||
|
@ -2107,7 +2107,7 @@ void MainWidget::resizeEvent(QResizeEvent *e) {
|
|||
|
||||
void MainWidget::updateControlsGeometry() {
|
||||
updateWindowAdaptiveLayout();
|
||||
if (session().settings().dialogsWidthRatio() > 0) {
|
||||
if (Core::App().settings().dialogsWidthRatio() > 0) {
|
||||
_a_dialogsWidth.stop();
|
||||
}
|
||||
if (!_a_dialogsWidth.animating()) {
|
||||
|
@ -2122,9 +2122,9 @@ void MainWidget::updateControlsGeometry() {
|
|||
anim::activation::background);
|
||||
const auto active = _controller->activeChatCurrent();
|
||||
if (const auto peer = active.peer()) {
|
||||
if (session().settings().tabbedSelectorSectionEnabled()) {
|
||||
if (Core::App().settings().tabbedSelectorSectionEnabled()) {
|
||||
_history->pushTabbedSelectorToThirdSection(peer, params);
|
||||
} else if (session().settings().thirdSectionInfoEnabled()) {
|
||||
} else if (Core::App().settings().thirdSectionInfoEnabled()) {
|
||||
_controller->showSection(
|
||||
Info::Memento::Default(peer),
|
||||
params.withThirdColumn());
|
||||
|
@ -2258,17 +2258,17 @@ void MainWidget::ensureFirstColumnResizeAreaCreated() {
|
|||
auto newRatio = (newWidth < st::columnMinimalWidthLeft / 2)
|
||||
? 0.
|
||||
: float64(newWidth) / width();
|
||||
session().settings().setDialogsWidthRatio(newRatio);
|
||||
Core::App().settings().setDialogsWidthRatio(newRatio);
|
||||
};
|
||||
auto moveFinishedCallback = [=] {
|
||||
if (Adaptive::OneColumn()) {
|
||||
return;
|
||||
}
|
||||
if (session().settings().dialogsWidthRatio() > 0) {
|
||||
session().settings().setDialogsWidthRatio(
|
||||
if (Core::App().settings().dialogsWidthRatio() > 0) {
|
||||
Core::App().settings().setDialogsWidthRatio(
|
||||
float64(_dialogsWidth) / width());
|
||||
}
|
||||
session().saveSettings();
|
||||
Core::App().saveSettingsDelayed();
|
||||
};
|
||||
createResizeArea(
|
||||
_firstColumnResizeArea,
|
||||
|
@ -2282,17 +2282,17 @@ void MainWidget::ensureThirdColumnResizeAreaCreated() {
|
|||
}
|
||||
auto moveLeftCallback = [=](int globalLeft) {
|
||||
auto newWidth = mapToGlobal(QPoint(width(), 0)).x() - globalLeft;
|
||||
session().settings().setThirdColumnWidth(newWidth);
|
||||
Core::App().settings().setThirdColumnWidth(newWidth);
|
||||
};
|
||||
auto moveFinishedCallback = [=] {
|
||||
if (!Adaptive::ThreeColumn() || !_thirdSection) {
|
||||
return;
|
||||
}
|
||||
session().settings().setThirdColumnWidth(snap(
|
||||
session().settings().thirdColumnWidth(),
|
||||
Core::App().settings().setThirdColumnWidth(snap(
|
||||
Core::App().settings().thirdColumnWidth(),
|
||||
st::columnMinimalWidthThird,
|
||||
st::columnMaximalWidthThird));
|
||||
session().saveSettings();
|
||||
Core::App().saveSettingsDelayed();
|
||||
};
|
||||
createResizeArea(
|
||||
_thirdColumnResizeArea,
|
||||
|
@ -2301,12 +2301,12 @@ void MainWidget::ensureThirdColumnResizeAreaCreated() {
|
|||
}
|
||||
|
||||
void MainWidget::updateDialogsWidthAnimated() {
|
||||
if (session().settings().dialogsWidthRatio() > 0) {
|
||||
if (Core::App().settings().dialogsWidthRatio() > 0) {
|
||||
return;
|
||||
}
|
||||
auto dialogsWidth = _dialogsWidth;
|
||||
updateWindowAdaptiveLayout();
|
||||
if (!session().settings().dialogsWidthRatio()
|
||||
if (!Core::App().settings().dialogsWidthRatio()
|
||||
&& (_dialogsWidth != dialogsWidth
|
||||
|| _a_dialogsWidth.animating())) {
|
||||
_dialogs->startWidthAnimation();
|
||||
|
@ -2353,6 +2353,7 @@ void MainWidget::updateThirdColumnToCurrentChat(
|
|||
_thirdSection.destroy();
|
||||
}
|
||||
};
|
||||
auto &settings = Core::App().settings();
|
||||
auto params = Window::SectionShow(
|
||||
Window::SectionShow::Way::ClearStack,
|
||||
anim::type::instant,
|
||||
|
@ -2364,9 +2365,9 @@ void MainWidget::updateThirdColumnToCurrentChat(
|
|||
// Like in _controller->showPeerInfo()
|
||||
//
|
||||
if (Adaptive::ThreeColumn()
|
||||
&& !session().settings().thirdSectionInfoEnabled()) {
|
||||
session().settings().setThirdSectionInfoEnabled(true);
|
||||
session().saveSettingsDelayed();
|
||||
&& !settings.thirdSectionInfoEnabled()) {
|
||||
settings.setThirdSectionInfoEnabled(true);
|
||||
Core::App().saveSettingsDelayed();
|
||||
}
|
||||
|
||||
_controller->showSection(
|
||||
|
@ -2378,19 +2379,19 @@ void MainWidget::updateThirdColumnToCurrentChat(
|
|||
return _history->pushTabbedSelectorToThirdSection(peer, params);
|
||||
};
|
||||
if (Adaptive::ThreeColumn()
|
||||
&& session().settings().tabbedSelectorSectionEnabled()
|
||||
&& settings.tabbedSelectorSectionEnabled()
|
||||
&& key) {
|
||||
if (!canWrite) {
|
||||
switchInfoFast();
|
||||
session().settings().setTabbedSelectorSectionEnabled(true);
|
||||
session().settings().setTabbedReplacedWithInfo(true);
|
||||
} else if (session().settings().tabbedReplacedWithInfo()
|
||||
settings.setTabbedSelectorSectionEnabled(true);
|
||||
settings.setTabbedReplacedWithInfo(true);
|
||||
} else if (settings.tabbedReplacedWithInfo()
|
||||
&& key.history()
|
||||
&& switchTabbedFast(key.history()->peer)) {
|
||||
session().settings().setTabbedReplacedWithInfo(false);
|
||||
settings.setTabbedReplacedWithInfo(false);
|
||||
}
|
||||
} else {
|
||||
session().settings().setTabbedReplacedWithInfo(false);
|
||||
settings.setTabbedReplacedWithInfo(false);
|
||||
if (!key) {
|
||||
if (_thirdSection) {
|
||||
_thirdSection.destroy();
|
||||
|
@ -2398,7 +2399,7 @@ void MainWidget::updateThirdColumnToCurrentChat(
|
|||
updateControlsGeometry();
|
||||
}
|
||||
} else if (Adaptive::ThreeColumn()
|
||||
&& session().settings().thirdSectionInfoEnabled()) {
|
||||
&& settings.thirdSectionInfoEnabled()) {
|
||||
switchInfoFast();
|
||||
}
|
||||
}
|
||||
|
@ -2487,7 +2488,7 @@ void MainWidget::handleHistoryBack() {
|
|||
|
||||
void MainWidget::updateWindowAdaptiveLayout() {
|
||||
auto layout = _controller->computeColumnLayout();
|
||||
auto dialogsWidthRatio = session().settings().dialogsWidthRatio();
|
||||
auto dialogsWidthRatio = Core::App().settings().dialogsWidthRatio();
|
||||
|
||||
// Check if we are in a single-column layout in a wide enough window
|
||||
// for the normal layout. If so, switch to the normal layout.
|
||||
|
@ -2530,7 +2531,7 @@ void MainWidget::updateWindowAdaptiveLayout() {
|
|||
//}
|
||||
}
|
||||
|
||||
session().settings().setDialogsWidthRatio(dialogsWidthRatio);
|
||||
Core::App().settings().setDialogsWidthRatio(dialogsWidthRatio);
|
||||
|
||||
auto useSmallColumnWidth = !Adaptive::OneColumn()
|
||||
&& !dialogsWidthRatio
|
||||
|
|
|
@ -284,8 +284,9 @@ void MainWindow::setupMain() {
|
|||
auto animated = (_intro || _passcodeLock);
|
||||
auto bg = animated ? grabInner() : QPixmap();
|
||||
|
||||
auto created = object_ptr<MainWidget>(bodyWidget(), sessionController());
|
||||
clearWidgets();
|
||||
_main.create(bodyWidget(), sessionController());
|
||||
_main = std::move(created);
|
||||
if (_passcodeLock) {
|
||||
_main->hide();
|
||||
} else {
|
||||
|
|
|
@ -13,6 +13,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
|||
#include "data/data_media_types.h"
|
||||
#include "history/view/media/history_view_media.h"
|
||||
#include "history/history_item.h"
|
||||
#include "history/history.h"
|
||||
#include "history/view/history_view_element.h"
|
||||
#include "media/audio/media_audio.h"
|
||||
#include "media/streaming/media_streaming_instance.h"
|
||||
|
@ -20,8 +21,9 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
|||
#include "media/player/media_player_instance.h"
|
||||
#include "window/window_session_controller.h"
|
||||
#include "window/section_widget.h"
|
||||
#include "core/application.h"
|
||||
#include "core/core_settings.h"
|
||||
#include "main/main_session.h"
|
||||
#include "main/main_session_settings.h"
|
||||
#include "facades.h"
|
||||
#include "app.h"
|
||||
#include "styles/style_media_player.h"
|
||||
|
@ -34,12 +36,10 @@ namespace Player {
|
|||
|
||||
Float::Float(
|
||||
QWidget *parent,
|
||||
not_null<Window::SessionController*> controller,
|
||||
not_null<HistoryItem*> item,
|
||||
Fn<void(bool visible)> toggleCallback,
|
||||
Fn<void(bool closed)> draggedCallback)
|
||||
: RpWidget(parent)
|
||||
, _controller(controller)
|
||||
, _item(item)
|
||||
, _toggleCallback(std::move(toggleCallback))
|
||||
, _draggedCallback(std::move(draggedCallback)) {
|
||||
|
@ -56,14 +56,14 @@ Float::Float(
|
|||
|
||||
prepareShadow();
|
||||
|
||||
_controller->session().data().itemRepaintRequest(
|
||||
document->session().data().itemRepaintRequest(
|
||||
) | rpl::start_with_next([this](auto item) {
|
||||
if (_item == item) {
|
||||
repaintItem();
|
||||
}
|
||||
}, lifetime());
|
||||
|
||||
_controller->session().data().itemRemoved(
|
||||
document->session().data().itemRemoved(
|
||||
) | rpl::start_with_next([this](auto item) {
|
||||
if (_item == item) {
|
||||
detach();
|
||||
|
@ -267,7 +267,6 @@ void Float::repaintItem() {
|
|||
template <typename ToggleCallback, typename DraggedCallback>
|
||||
FloatController::Item::Item(
|
||||
not_null<QWidget*> parent,
|
||||
not_null<Window::SessionController*> controller,
|
||||
not_null<HistoryItem*> item,
|
||||
ToggleCallback toggle,
|
||||
DraggedCallback dragged)
|
||||
|
@ -276,7 +275,6 @@ FloatController::Item::Item(
|
|||
, corner(RectPart::TopRight)
|
||||
, widget(
|
||||
parent,
|
||||
controller,
|
||||
item,
|
||||
[=, toggle = std::move(toggle)](bool visible) {
|
||||
toggle(this, visible);
|
||||
|
@ -310,9 +308,6 @@ void FloatController::replaceDelegate(not_null<FloatDelegate*> delegate) {
|
|||
_delegate = delegate;
|
||||
_parent = _delegate->floatPlayerWidget();
|
||||
|
||||
// Currently moving floats between windows is not supported.
|
||||
Assert(_controller == _delegate->floatPlayerController());
|
||||
|
||||
startDelegateHandling();
|
||||
|
||||
for (const auto &item : _items) {
|
||||
|
@ -356,17 +351,23 @@ void FloatController::startDelegateHandling() {
|
|||
|
||||
void FloatController::checkCurrent() {
|
||||
const auto state = Media::Player::instance()->current(AudioMsgId::Type::Voice);
|
||||
const auto audio = state.audio();
|
||||
const auto fullId = state.contextId();
|
||||
const auto last = current();
|
||||
if (last
|
||||
&& audio
|
||||
&& !last->widget->detached()
|
||||
&& last->widget->item()->fullId() == fullId) {
|
||||
&& (&last->widget->item()->history()->session() == &audio->session())
|
||||
&& (last->widget->item()->fullId() == fullId)) {
|
||||
return;
|
||||
}
|
||||
if (last) {
|
||||
last->widget->detach();
|
||||
}
|
||||
if (const auto item = _controller->session().data().message(fullId)) {
|
||||
if (!audio) {
|
||||
return;
|
||||
}
|
||||
if (const auto item = audio->session().data().message(fullId)) {
|
||||
if (const auto media = item->media()) {
|
||||
if (const auto document = media->document()) {
|
||||
if (document->isVideoMessage()) {
|
||||
|
@ -380,7 +381,6 @@ void FloatController::checkCurrent() {
|
|||
void FloatController::create(not_null<HistoryItem*> item) {
|
||||
_items.push_back(std::make_unique<Item>(
|
||||
_parent,
|
||||
_controller,
|
||||
item,
|
||||
[=](not_null<Item*> instance, bool visible) {
|
||||
instance->hiddenByWidget = !visible;
|
||||
|
@ -389,8 +389,8 @@ void FloatController::create(not_null<HistoryItem*> item) {
|
|||
[=](not_null<Item*> instance, bool closed) {
|
||||
finishDrag(instance, closed);
|
||||
}));
|
||||
current()->column = _controller->session().settings().floatPlayerColumn();
|
||||
current()->corner = _controller->session().settings().floatPlayerCorner();
|
||||
current()->column = Core::App().settings().floatPlayerColumn();
|
||||
current()->corner = Core::App().settings().floatPlayerCorner();
|
||||
checkVisibility();
|
||||
}
|
||||
|
||||
|
@ -563,8 +563,8 @@ void FloatController::updateColumnCorner(QPoint center) {
|
|||
|
||||
auto size = _items.back()->widget->size();
|
||||
auto min = INT_MAX;
|
||||
auto column = _controller->session().settings().floatPlayerColumn();
|
||||
auto corner = _controller->session().settings().floatPlayerCorner();
|
||||
auto column = Core::App().settings().floatPlayerColumn();
|
||||
auto corner = Core::App().settings().floatPlayerCorner();
|
||||
auto checkSection = [&](
|
||||
not_null<Window::AbstractSectionWidget*> widget,
|
||||
Window::Column widgetColumn) {
|
||||
|
@ -589,13 +589,14 @@ void FloatController::updateColumnCorner(QPoint center) {
|
|||
|
||||
_delegate->floatPlayerEnumerateSections(checkSection);
|
||||
|
||||
if (_controller->session().settings().floatPlayerColumn() != column) {
|
||||
_controller->session().settings().setFloatPlayerColumn(column);
|
||||
_controller->session().saveSettingsDelayed();
|
||||
auto &settings = Core::App().settings();
|
||||
if (settings.floatPlayerColumn() != column) {
|
||||
settings.setFloatPlayerColumn(column);
|
||||
Core::App().saveSettingsDelayed();
|
||||
}
|
||||
if (_controller->session().settings().floatPlayerCorner() != corner) {
|
||||
_controller->session().settings().setFloatPlayerCorner(corner);
|
||||
_controller->session().saveSettingsDelayed();
|
||||
if (settings.floatPlayerCorner() != corner) {
|
||||
settings.setFloatPlayerCorner(corner);
|
||||
Core::App().saveSettingsDelayed();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -607,8 +608,8 @@ void FloatController::finishDrag(not_null<Item*> instance, bool closed) {
|
|||
instance->animationSide = getSide(center);
|
||||
}
|
||||
updateColumnCorner(center);
|
||||
instance->column = _controller->session().settings().floatPlayerColumn();
|
||||
instance->corner = _controller->session().settings().floatPlayerCorner();
|
||||
instance->column = Core::App().settings().floatPlayerColumn();
|
||||
instance->corner = Core::App().settings().floatPlayerCorner();
|
||||
|
||||
instance->draggedAnimation.stop();
|
||||
instance->draggedAnimation.start(
|
||||
|
|
|
@ -37,7 +37,6 @@ class Float : public Ui::RpWidget, private base::Subscriber {
|
|||
public:
|
||||
Float(
|
||||
QWidget *parent,
|
||||
not_null<Window::SessionController*> controller,
|
||||
not_null<HistoryItem*> item,
|
||||
Fn<void(bool visible)> toggleCallback,
|
||||
Fn<void(bool closed)> draggedCallback);
|
||||
|
@ -90,7 +89,6 @@ private:
|
|||
void finishDrag(bool closed);
|
||||
void pauseResume();
|
||||
|
||||
not_null<Window::SessionController*> _controller;
|
||||
HistoryItem *_item = nullptr;
|
||||
Fn<void(bool visible)> _toggleCallback;
|
||||
|
||||
|
@ -194,7 +192,6 @@ private:
|
|||
template <typename ToggleCallback, typename DraggedCallback>
|
||||
Item(
|
||||
not_null<QWidget*> parent,
|
||||
not_null<Window::SessionController*> controller,
|
||||
not_null<HistoryItem*> item,
|
||||
ToggleCallback toggle,
|
||||
DraggedCallback dragged);
|
||||
|
|
|
@ -375,7 +375,7 @@ bool ReadSetting(
|
|||
stream >> v;
|
||||
if (!CheckStreamStatus(stream)) return false;
|
||||
|
||||
context.sessionSettings().setDialogsWidthRatio(v / 1000000.);
|
||||
Core::App().settings().setDialogsWidthRatio(v / 1000000.);
|
||||
} break;
|
||||
|
||||
case dbiLastSeenWarningSeenOld: {
|
||||
|
|
|
@ -324,10 +324,10 @@ void MainWindow::initSize() {
|
|||
? primaryScreen->availableGeometry()
|
||||
: QRect(0, 0, st::windowDefaultWidth, st::windowDefaultHeight);
|
||||
bool maximized = false;
|
||||
const auto initialWidth = Main::SessionSettings::ThirdColumnByDefault()
|
||||
const auto initialWidth = Core::Settings::ThirdColumnByDefault()
|
||||
? st::windowBigDefaultWidth
|
||||
: st::windowDefaultWidth;
|
||||
const auto initialHeight = Main::SessionSettings::ThirdColumnByDefault()
|
||||
const auto initialHeight = Core::Settings::ThirdColumnByDefault()
|
||||
? st::windowBigDefaultHeight
|
||||
: st::windowDefaultHeight;
|
||||
auto geometry = QRect(
|
||||
|
|
|
@ -258,9 +258,8 @@ bool Filler::showInfo() {
|
|||
return true;
|
||||
} else if (!Adaptive::ThreeColumn()) {
|
||||
return true;
|
||||
} else if (
|
||||
!_peer->session().settings().thirdSectionInfoEnabled() &&
|
||||
!_peer->session().settings().tabbedReplacedWithInfo()) {
|
||||
} else if (!Core::App().settings().thirdSectionInfoEnabled()
|
||||
&& !Core::App().settings().tabbedReplacedWithInfo()) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
|
|
|
@ -27,6 +27,8 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
|||
#include "passport/passport_form_controller.h"
|
||||
#include "chat_helpers/tabbed_selector.h"
|
||||
#include "core/shortcuts.h"
|
||||
#include "core/application.h"
|
||||
#include "core/core_settings.h"
|
||||
#include "base/unixtime.h"
|
||||
#include "boxes/calendar_box.h"
|
||||
#include "boxes/sticker_set_box.h" // requestAttachedStickerSets.
|
||||
|
@ -81,9 +83,9 @@ void SessionNavigation::showPeerInfo(
|
|||
not_null<PeerData*> peer,
|
||||
const SectionShow ¶ms) {
|
||||
//if (Adaptive::ThreeColumn()
|
||||
// && !_session->settings().thirdSectionInfoEnabled()) {
|
||||
// _session->settings().setThirdSectionInfoEnabled(true);
|
||||
// _session->saveSettingsDelayed();
|
||||
// && !Core::App().settings().thirdSectionInfoEnabled()) {
|
||||
// Core::App().settings().setThirdSectionInfoEnabled(true);
|
||||
// Core::App().saveSettingsDelayed();
|
||||
//}
|
||||
showSection(Info::Memento(peer), params);
|
||||
}
|
||||
|
@ -451,8 +453,8 @@ auto SessionController::computeColumnLayout() const -> ColumnLayout {
|
|||
if (bodyWidth < minimalThreeColumnWidth()) {
|
||||
return true;
|
||||
}
|
||||
if (!session().settings().tabbedSelectorSectionEnabled()
|
||||
&& !session().settings().thirdSectionInfoEnabled()) {
|
||||
if (!Core::App().settings().tabbedSelectorSectionEnabled()
|
||||
&& !Core::App().settings().thirdSectionInfoEnabled()) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
|
@ -482,14 +484,14 @@ auto SessionController::computeColumnLayout() const -> ColumnLayout {
|
|||
}
|
||||
|
||||
int SessionController::countDialogsWidthFromRatio(int bodyWidth) const {
|
||||
auto result = qRound(bodyWidth * session().settings().dialogsWidthRatio());
|
||||
auto result = qRound(bodyWidth * Core::App().settings().dialogsWidthRatio());
|
||||
accumulate_max(result, st::columnMinimalWidthLeft);
|
||||
// accumulate_min(result, st::columnMaximalWidthLeft);
|
||||
return result;
|
||||
}
|
||||
|
||||
int SessionController::countThirdColumnWidthFromRatio(int bodyWidth) const {
|
||||
auto result = session().settings().thirdColumnWidth();
|
||||
auto result = Core::App().settings().thirdColumnWidth();
|
||||
accumulate_max(result, st::columnMinimalWidthThird);
|
||||
accumulate_min(result, st::columnMaximalWidthThird);
|
||||
return result;
|
||||
|
@ -540,13 +542,14 @@ void SessionController::resizeForThirdSection() {
|
|||
return;
|
||||
}
|
||||
|
||||
auto &settings = Core::App().settings();
|
||||
auto layout = computeColumnLayout();
|
||||
auto tabbedSelectorSectionEnabled =
|
||||
session().settings().tabbedSelectorSectionEnabled();
|
||||
settings.tabbedSelectorSectionEnabled();
|
||||
auto thirdSectionInfoEnabled =
|
||||
session().settings().thirdSectionInfoEnabled();
|
||||
session().settings().setTabbedSelectorSectionEnabled(false);
|
||||
session().settings().setThirdSectionInfoEnabled(false);
|
||||
settings.thirdSectionInfoEnabled();
|
||||
settings.setTabbedSelectorSectionEnabled(false);
|
||||
settings.setThirdSectionInfoEnabled(false);
|
||||
|
||||
auto wanted = countThirdColumnWidthFromRatio(layout.bodyWidth);
|
||||
auto minimal = st::columnMinimalWidthThird;
|
||||
|
@ -567,46 +570,47 @@ void SessionController::resizeForThirdSection() {
|
|||
return widget()->tryToExtendWidthBy(minimal);
|
||||
}();
|
||||
if (extendedBy) {
|
||||
if (extendBy != session().settings().thirdColumnWidth()) {
|
||||
session().settings().setThirdColumnWidth(extendBy);
|
||||
if (extendBy != settings.thirdColumnWidth()) {
|
||||
settings.setThirdColumnWidth(extendBy);
|
||||
}
|
||||
auto newBodyWidth = layout.bodyWidth + extendedBy;
|
||||
auto currentRatio = session().settings().dialogsWidthRatio();
|
||||
session().settings().setDialogsWidthRatio(
|
||||
auto currentRatio = settings.dialogsWidthRatio();
|
||||
settings.setDialogsWidthRatio(
|
||||
(currentRatio * layout.bodyWidth) / newBodyWidth);
|
||||
}
|
||||
auto savedValue = (extendedBy == extendBy) ? -1 : extendedBy;
|
||||
session().settings().setThirdSectionExtendedBy(savedValue);
|
||||
settings.setThirdSectionExtendedBy(savedValue);
|
||||
|
||||
session().settings().setTabbedSelectorSectionEnabled(
|
||||
settings.setTabbedSelectorSectionEnabled(
|
||||
tabbedSelectorSectionEnabled);
|
||||
session().settings().setThirdSectionInfoEnabled(
|
||||
settings.setThirdSectionInfoEnabled(
|
||||
thirdSectionInfoEnabled);
|
||||
}
|
||||
|
||||
void SessionController::closeThirdSection() {
|
||||
auto &settings = Core::App().settings();
|
||||
auto newWindowSize = widget()->size();
|
||||
auto layout = computeColumnLayout();
|
||||
if (layout.windowLayout == Adaptive::WindowLayout::ThreeColumn) {
|
||||
auto noResize = widget()->isFullScreen()
|
||||
|| widget()->isMaximized();
|
||||
auto savedValue = session().settings().thirdSectionExtendedBy();
|
||||
auto savedValue = settings.thirdSectionExtendedBy();
|
||||
auto extendedBy = (savedValue == -1)
|
||||
? layout.thirdWidth
|
||||
: savedValue;
|
||||
auto newBodyWidth = noResize
|
||||
? layout.bodyWidth
|
||||
: (layout.bodyWidth - extendedBy);
|
||||
auto currentRatio = session().settings().dialogsWidthRatio();
|
||||
session().settings().setDialogsWidthRatio(
|
||||
auto currentRatio = settings.dialogsWidthRatio();
|
||||
settings.setDialogsWidthRatio(
|
||||
(currentRatio * layout.bodyWidth) / newBodyWidth);
|
||||
newWindowSize = QSize(
|
||||
widget()->width() + (newBodyWidth - layout.bodyWidth),
|
||||
widget()->height());
|
||||
}
|
||||
session().settings().setTabbedSelectorSectionEnabled(false);
|
||||
session().settings().setThirdSectionInfoEnabled(false);
|
||||
session().saveSettingsDelayed();
|
||||
settings.setTabbedSelectorSectionEnabled(false);
|
||||
settings.setThirdSectionInfoEnabled(false);
|
||||
Core::App().saveSettingsDelayed();
|
||||
if (widget()->size() != newWindowSize) {
|
||||
widget()->resize(newWindowSize);
|
||||
} else {
|
||||
|
|
Loading…
Add table
Reference in a new issue