mirror of https://github.com/procxx/kepka.git
Move dialogsWidthRatio to AuthSessionData.
This commit is contained in:
parent
4771ea7cd4
commit
9a56b2d20f
|
@ -73,6 +73,7 @@ QByteArray AuthSessionData::serialize() const {
|
||||||
}
|
}
|
||||||
stream << qint32(_variables.thirdSectionInfoEnabled ? 1 : 0);
|
stream << qint32(_variables.thirdSectionInfoEnabled ? 1 : 0);
|
||||||
stream << qint32(_variables.smallDialogsList ? 1 : 0);
|
stream << qint32(_variables.smallDialogsList ? 1 : 0);
|
||||||
|
stream << qint32(snap(qRound(_variables.dialogsWidthRatio.current() * 1000000), 0, 1000000));
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
@ -94,6 +95,7 @@ void AuthSessionData::constructFromSerialized(const QByteArray &serialized) {
|
||||||
base::flat_set<PeerId> groupStickersSectionHidden;
|
base::flat_set<PeerId> groupStickersSectionHidden;
|
||||||
qint32 thirdSectionInfoEnabled = 0;
|
qint32 thirdSectionInfoEnabled = 0;
|
||||||
qint32 smallDialogsList = 0;
|
qint32 smallDialogsList = 0;
|
||||||
|
float64 dialogsWidthRatio = _variables.dialogsWidthRatio.current();
|
||||||
stream >> selectorTab;
|
stream >> selectorTab;
|
||||||
stream >> lastSeenWarningSeen;
|
stream >> lastSeenWarningSeen;
|
||||||
if (!stream.atEnd()) {
|
if (!stream.atEnd()) {
|
||||||
|
@ -131,6 +133,11 @@ void AuthSessionData::constructFromSerialized(const QByteArray &serialized) {
|
||||||
stream >> thirdSectionInfoEnabled;
|
stream >> thirdSectionInfoEnabled;
|
||||||
stream >> smallDialogsList;
|
stream >> smallDialogsList;
|
||||||
}
|
}
|
||||||
|
if (!stream.atEnd()) {
|
||||||
|
qint32 value = 0;
|
||||||
|
stream >> value;
|
||||||
|
dialogsWidthRatio = snap(value / 1000000., 0., 1.);
|
||||||
|
}
|
||||||
if (stream.status() != QDataStream::Ok) {
|
if (stream.status() != QDataStream::Ok) {
|
||||||
LOG(("App Error: Bad data for AuthSessionData::constructFromSerialized()"));
|
LOG(("App Error: Bad data for AuthSessionData::constructFromSerialized()"));
|
||||||
return;
|
return;
|
||||||
|
@ -162,7 +169,7 @@ void AuthSessionData::constructFromSerialized(const QByteArray &serialized) {
|
||||||
_variables.groupStickersSectionHidden = std::move(groupStickersSectionHidden);
|
_variables.groupStickersSectionHidden = std::move(groupStickersSectionHidden);
|
||||||
_variables.thirdSectionInfoEnabled = thirdSectionInfoEnabled;
|
_variables.thirdSectionInfoEnabled = thirdSectionInfoEnabled;
|
||||||
_variables.smallDialogsList = smallDialogsList;
|
_variables.smallDialogsList = smallDialogsList;
|
||||||
|
_variables.dialogsWidthRatio = dialogsWidthRatio;
|
||||||
if (_variables.thirdSectionInfoEnabled) {
|
if (_variables.thirdSectionInfoEnabled) {
|
||||||
_variables.tabbedSelectorSectionEnabled = false;
|
_variables.tabbedSelectorSectionEnabled = false;
|
||||||
}
|
}
|
||||||
|
|
|
@ -22,6 +22,7 @@ Copyright (c) 2014-2017 John Preston, https://desktop.telegram.org
|
||||||
|
|
||||||
#include <rpl/event_stream.h>
|
#include <rpl/event_stream.h>
|
||||||
#include <rpl/filter.h>
|
#include <rpl/filter.h>
|
||||||
|
#include <rpl/variable.h>
|
||||||
#include "base/timer.h"
|
#include "base/timer.h"
|
||||||
|
|
||||||
namespace Storage {
|
namespace Storage {
|
||||||
|
@ -144,8 +145,8 @@ public:
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
void copyFrom(const AuthSessionData &other) {
|
void moveFrom(AuthSessionData &&other) {
|
||||||
_variables = other._variables;
|
_variables = std::move(other._variables);
|
||||||
}
|
}
|
||||||
QByteArray serialize() const;
|
QByteArray serialize() const;
|
||||||
void constructFromSerialized(const QByteArray &serialized);
|
void constructFromSerialized(const QByteArray &serialized);
|
||||||
|
@ -219,6 +220,16 @@ public:
|
||||||
RectPart floatPlayerCorner() const {
|
RectPart floatPlayerCorner() const {
|
||||||
return _variables.floatPlayerCorner;
|
return _variables.floatPlayerCorner;
|
||||||
}
|
}
|
||||||
|
void setDialogsWidthRatio(float64 ratio) {
|
||||||
|
_variables.dialogsWidthRatio = ratio;
|
||||||
|
}
|
||||||
|
float64 dialogsWidthRatio() const {
|
||||||
|
return _variables.dialogsWidthRatio.current();
|
||||||
|
}
|
||||||
|
rpl::producer<float64> dialogsWidthRatioChanges() const {
|
||||||
|
return _variables.dialogsWidthRatio.changes();
|
||||||
|
}
|
||||||
|
|
||||||
void setGroupStickersSectionHidden(PeerId peerId) {
|
void setGroupStickersSectionHidden(PeerId peerId) {
|
||||||
_variables.groupStickersSectionHidden.insert(peerId);
|
_variables.groupStickersSectionHidden.insert(peerId);
|
||||||
}
|
}
|
||||||
|
@ -233,16 +244,19 @@ private:
|
||||||
struct Variables {
|
struct Variables {
|
||||||
Variables();
|
Variables();
|
||||||
|
|
||||||
|
static constexpr auto kDefaultDialogsWidthRatio = 5. / 14;
|
||||||
|
|
||||||
bool lastSeenWarningSeen = false;
|
bool lastSeenWarningSeen = false;
|
||||||
ChatHelpers::SelectorTab selectorTab;
|
ChatHelpers::SelectorTab selectorTab; // per-window
|
||||||
bool tabbedSelectorSectionEnabled = false;
|
bool tabbedSelectorSectionEnabled = false; // per-window
|
||||||
int tabbedSelectorSectionTooltipShown = 0;
|
int tabbedSelectorSectionTooltipShown = 0;
|
||||||
QMap<QString, QString> soundOverrides;
|
QMap<QString, QString> soundOverrides;
|
||||||
Window::Column floatPlayerColumn;
|
Window::Column floatPlayerColumn; // per-window
|
||||||
RectPart floatPlayerCorner;
|
RectPart floatPlayerCorner; // per-window
|
||||||
base::flat_set<PeerId> groupStickersSectionHidden;
|
base::flat_set<PeerId> groupStickersSectionHidden;
|
||||||
bool thirdSectionInfoEnabled = true;
|
bool thirdSectionInfoEnabled = true; // per-window
|
||||||
bool smallDialogsList = false;
|
bool smallDialogsList = false; // per-window
|
||||||
|
rpl::variable<float64> dialogsWidthRatio = kDefaultDialogsWidthRatio; // per-window
|
||||||
};
|
};
|
||||||
|
|
||||||
base::Variable<bool> _contactsLoaded = { false };
|
base::Variable<bool> _contactsLoaded = { false };
|
||||||
|
|
|
@ -166,10 +166,6 @@ void joinGroupByHash(const QString &hash) {
|
||||||
if (MainWidget *m = main()) m->joinGroupByHash(hash);
|
if (MainWidget *m = main()) m->joinGroupByHash(hash);
|
||||||
}
|
}
|
||||||
|
|
||||||
void stickersBox(const QString &name) {
|
|
||||||
if (MainWidget *m = main()) m->stickersBox(MTP_inputStickerSetShortName(MTP_string(name)));
|
|
||||||
}
|
|
||||||
|
|
||||||
void removeDialog(History *history) {
|
void removeDialog(History *history) {
|
||||||
if (MainWidget *m = main()) {
|
if (MainWidget *m = main()) {
|
||||||
m->removeDialog(history);
|
m->removeDialog(history);
|
||||||
|
|
|
@ -136,7 +136,6 @@ void activateBotCommand(const HistoryItem *msg, int row, int col);
|
||||||
void searchByHashtag(const QString &tag, PeerData *inPeer);
|
void searchByHashtag(const QString &tag, PeerData *inPeer);
|
||||||
void openPeerByName(const QString &username, MsgId msgId = ShowAtUnreadMsgId, const QString &startToken = QString());
|
void openPeerByName(const QString &username, MsgId msgId = ShowAtUnreadMsgId, const QString &startToken = QString());
|
||||||
void joinGroupByHash(const QString &hash);
|
void joinGroupByHash(const QString &hash);
|
||||||
void stickersBox(const QString &name);
|
|
||||||
void removeDialog(History *history);
|
void removeDialog(History *history);
|
||||||
void showSettings();
|
void showSettings();
|
||||||
|
|
||||||
|
|
|
@ -262,9 +262,10 @@ MainWidget::MainWidget(
|
||||||
subscribe(_controller->dialogsListDisplayForced(), [this](bool) {
|
subscribe(_controller->dialogsListDisplayForced(), [this](bool) {
|
||||||
updateDialogsWidthAnimated();
|
updateDialogsWidthAnimated();
|
||||||
});
|
});
|
||||||
subscribe(_controller->dialogsWidthRatio(), [this](float64) {
|
Auth().data().dialogsWidthRatioChanges()
|
||||||
updateControlsGeometry();
|
| rpl::start_with_next(
|
||||||
});
|
[this] { updateControlsGeometry(); },
|
||||||
|
lifetime());
|
||||||
subscribe(_controller->floatPlayerAreaUpdated(), [this] {
|
subscribe(_controller->floatPlayerAreaUpdated(), [this] {
|
||||||
checkFloatPlayerVisibility();
|
checkFloatPlayerVisibility();
|
||||||
});
|
});
|
||||||
|
@ -3516,7 +3517,7 @@ void MainWidget::resizeEvent(QResizeEvent *e) {
|
||||||
|
|
||||||
void MainWidget::updateControlsGeometry() {
|
void MainWidget::updateControlsGeometry() {
|
||||||
updateWindowAdaptiveLayout();
|
updateWindowAdaptiveLayout();
|
||||||
if (_controller->dialogsWidthRatio().value() > 0) {
|
if (Auth().data().dialogsWidthRatio() > 0) {
|
||||||
_a_dialogsWidth.finish();
|
_a_dialogsWidth.finish();
|
||||||
}
|
}
|
||||||
if (!_a_dialogsWidth.animating()) {
|
if (!_a_dialogsWidth.animating()) {
|
||||||
|
@ -3616,12 +3617,12 @@ void MainWidget::updateControlsGeometry() {
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainWidget::updateDialogsWidthAnimated() {
|
void MainWidget::updateDialogsWidthAnimated() {
|
||||||
if (_controller->dialogsWidthRatio().value() > 0) {
|
if (Auth().data().dialogsWidthRatio() > 0) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
auto dialogsWidth = _dialogsWidth;
|
auto dialogsWidth = _dialogsWidth;
|
||||||
updateWindowAdaptiveLayout();
|
updateWindowAdaptiveLayout();
|
||||||
if (!_controller->dialogsWidthRatio().value()
|
if (!Auth().data().dialogsWidthRatio()
|
||||||
&& (_dialogsWidth != dialogsWidth
|
&& (_dialogsWidth != dialogsWidth
|
||||||
|| _a_dialogsWidth.animating())) {
|
|| _a_dialogsWidth.animating())) {
|
||||||
_dialogs->startWidthAnimation();
|
_dialogs->startWidthAnimation();
|
||||||
|
@ -3722,16 +3723,15 @@ bool MainWidget::eventFilter(QObject *o, QEvent *e) {
|
||||||
} else if (e->type() == QEvent::MouseButtonRelease) {
|
} else if (e->type() == QEvent::MouseButtonRelease) {
|
||||||
_resizingSide = false;
|
_resizingSide = false;
|
||||||
if (!Adaptive::OneColumn()
|
if (!Adaptive::OneColumn()
|
||||||
&& _controller->dialogsWidthRatio().value() > 0) {
|
&& Auth().data().dialogsWidthRatio() > 0) {
|
||||||
_controller->dialogsWidthRatio().set(
|
Auth().data().setDialogsWidthRatio(
|
||||||
float64(_dialogsWidth) / width(),
|
float64(_dialogsWidth) / width());
|
||||||
true);
|
|
||||||
}
|
}
|
||||||
Local::writeUserSettings();
|
Local::writeUserSettings();
|
||||||
} else if (e->type() == QEvent::MouseMove && _resizingSide) {
|
} else if (e->type() == QEvent::MouseMove && _resizingSide) {
|
||||||
auto newWidth = mouseLeft() - _resizingSideShift;
|
auto newWidth = mouseLeft() - _resizingSideShift;
|
||||||
auto newRatio = (newWidth < st::dialogsWidthMin / 2) ? 0. : float64(newWidth) / width();
|
auto newRatio = (newWidth < st::dialogsWidthMin / 2) ? 0. : float64(newWidth) / width();
|
||||||
_controller->dialogsWidthRatio().set(newRatio, true);
|
Auth().data().setDialogsWidthRatio(newRatio);
|
||||||
}
|
}
|
||||||
} else if (e->type() == QEvent::FocusIn) {
|
} else if (e->type() == QEvent::FocusIn) {
|
||||||
if (auto widget = qobject_cast<QWidget*>(o)) {
|
if (auto widget = qobject_cast<QWidget*>(o)) {
|
||||||
|
@ -3771,7 +3771,7 @@ void MainWidget::handleAdaptiveLayoutUpdate() {
|
||||||
|
|
||||||
void MainWidget::updateWindowAdaptiveLayout() {
|
void MainWidget::updateWindowAdaptiveLayout() {
|
||||||
auto layout = _controller->computeColumnLayout();
|
auto layout = _controller->computeColumnLayout();
|
||||||
auto dialogsWidthRatio = _controller->dialogsWidthRatio().value();
|
auto dialogsWidthRatio = Auth().data().dialogsWidthRatio();
|
||||||
|
|
||||||
// Check if we are in a single-column layout in a wide enough window
|
// 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.
|
// for the normal layout. If so, switch to the normal layout.
|
||||||
|
@ -3814,7 +3814,7 @@ void MainWidget::updateWindowAdaptiveLayout() {
|
||||||
//}
|
//}
|
||||||
}
|
}
|
||||||
|
|
||||||
_controller->dialogsWidthRatio().set(dialogsWidthRatio, true);
|
Auth().data().setDialogsWidthRatio(dialogsWidthRatio);
|
||||||
|
|
||||||
auto useSmallColumnWidth = !Adaptive::OneColumn()
|
auto useSmallColumnWidth = !Adaptive::OneColumn()
|
||||||
&& !dialogsWidthRatio
|
&& !dialogsWidthRatio
|
||||||
|
|
|
@ -68,7 +68,7 @@ Messenger *Messenger::InstancePointer() {
|
||||||
|
|
||||||
struct Messenger::Private {
|
struct Messenger::Private {
|
||||||
UserId authSessionUserId = 0;
|
UserId authSessionUserId = 0;
|
||||||
std::unique_ptr<Local::StoredAuthSession> storedAuthSession;
|
std::unique_ptr<AuthSessionData> storedAuthSession;
|
||||||
MTP::Instance::Config mtpConfig;
|
MTP::Instance::Config mtpConfig;
|
||||||
MTP::AuthKeysList mtpKeysToDestroy;
|
MTP::AuthKeysList mtpKeysToDestroy;
|
||||||
base::Timer quitTimer;
|
base::Timer quitTimer;
|
||||||
|
@ -337,14 +337,14 @@ void Messenger::setAuthSessionUserId(UserId userId) {
|
||||||
_private->authSessionUserId = userId;
|
_private->authSessionUserId = userId;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Messenger::setAuthSessionFromStorage(std::unique_ptr<Local::StoredAuthSession> data) {
|
void Messenger::setAuthSessionFromStorage(std::unique_ptr<AuthSessionData> data) {
|
||||||
Expects(!authSession());
|
Expects(!authSession());
|
||||||
_private->storedAuthSession = std::move(data);
|
_private->storedAuthSession = std::move(data);
|
||||||
}
|
}
|
||||||
|
|
||||||
AuthSessionData *Messenger::getAuthSessionData() {
|
AuthSessionData *Messenger::getAuthSessionData() {
|
||||||
if (_private->authSessionUserId) {
|
if (_private->authSessionUserId) {
|
||||||
return _private->storedAuthSession ? &_private->storedAuthSession->data : nullptr;
|
return _private->storedAuthSession ? _private->storedAuthSession.get() : nullptr;
|
||||||
} else if (_authSession) {
|
} else if (_authSession) {
|
||||||
return &_authSession->data();
|
return &_authSession->data();
|
||||||
}
|
}
|
||||||
|
@ -414,11 +414,8 @@ void Messenger::startMtp() {
|
||||||
}
|
}
|
||||||
if (_private->storedAuthSession) {
|
if (_private->storedAuthSession) {
|
||||||
if (_authSession) {
|
if (_authSession) {
|
||||||
_authSession->data().copyFrom(_private->storedAuthSession->data);
|
_authSession->data().moveFrom(
|
||||||
if (auto window = App::wnd()) {
|
std::move(*_private->storedAuthSession));
|
||||||
Assert(window->controller() != nullptr);
|
|
||||||
window->controller()->dialogsWidthRatio().set(_private->storedAuthSession->dialogsWidthRatio);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
_private->storedAuthSession.reset();
|
_private->storedAuthSession.reset();
|
||||||
}
|
}
|
||||||
|
|
|
@ -43,10 +43,6 @@ class FileUploader;
|
||||||
class Translator;
|
class Translator;
|
||||||
class MediaView;
|
class MediaView;
|
||||||
|
|
||||||
namespace Local {
|
|
||||||
struct StoredAuthSession;
|
|
||||||
} // namespace Local
|
|
||||||
|
|
||||||
namespace Media {
|
namespace Media {
|
||||||
namespace Audio {
|
namespace Audio {
|
||||||
class Instance;
|
class Instance;
|
||||||
|
@ -112,7 +108,7 @@ public:
|
||||||
void setMtpMainDcId(MTP::DcId mainDcId);
|
void setMtpMainDcId(MTP::DcId mainDcId);
|
||||||
void setMtpKey(MTP::DcId dcId, const MTP::AuthKey::Data &keyData);
|
void setMtpKey(MTP::DcId dcId, const MTP::AuthKey::Data &keyData);
|
||||||
void setAuthSessionUserId(UserId userId);
|
void setAuthSessionUserId(UserId userId);
|
||||||
void setAuthSessionFromStorage(std::unique_ptr<Local::StoredAuthSession> data);
|
void setAuthSessionFromStorage(std::unique_ptr<AuthSessionData> data);
|
||||||
AuthSessionData *getAuthSessionData();
|
AuthSessionData *getAuthSessionData();
|
||||||
|
|
||||||
// Serialization.
|
// Serialization.
|
||||||
|
|
|
@ -571,7 +571,7 @@ enum {
|
||||||
dbiNotificationsCount = 0x45,
|
dbiNotificationsCount = 0x45,
|
||||||
dbiNotificationsCorner = 0x46,
|
dbiNotificationsCorner = 0x46,
|
||||||
dbiThemeKey = 0x47,
|
dbiThemeKey = 0x47,
|
||||||
dbiDialogsWidthRatio = 0x48,
|
dbiDialogsWidthRatioOld = 0x48,
|
||||||
dbiUseExternalVideoPlayer = 0x49,
|
dbiUseExternalVideoPlayer = 0x49,
|
||||||
dbiDcOptions = 0x4a,
|
dbiDcOptions = 0x4a,
|
||||||
dbiMtpAuthorization = 0x4b,
|
dbiMtpAuthorization = 0x4b,
|
||||||
|
@ -646,10 +646,10 @@ enum class WriteMapWhen {
|
||||||
Soon,
|
Soon,
|
||||||
};
|
};
|
||||||
|
|
||||||
std::unique_ptr<StoredAuthSession> StoredAuthSessionCache;
|
std::unique_ptr<AuthSessionData> StoredAuthSessionCache;
|
||||||
StoredAuthSession &GetStoredAuthSessionCache() {
|
AuthSessionData &GetStoredAuthSessionCache() {
|
||||||
if (!StoredAuthSessionCache) {
|
if (!StoredAuthSessionCache) {
|
||||||
StoredAuthSessionCache = std::make_unique<StoredAuthSession>();
|
StoredAuthSessionCache = std::make_unique<AuthSessionData>();
|
||||||
}
|
}
|
||||||
return *StoredAuthSessionCache;
|
return *StoredAuthSessionCache;
|
||||||
}
|
}
|
||||||
|
@ -1102,12 +1102,12 @@ bool _readSetting(quint32 blockId, QDataStream &stream, int version, ReadSetting
|
||||||
Global::SetNotificationsCorner(static_cast<Notify::ScreenCorner>((v >= 0 && v < 4) ? v : 2));
|
Global::SetNotificationsCorner(static_cast<Notify::ScreenCorner>((v >= 0 && v < 4) ? v : 2));
|
||||||
} break;
|
} break;
|
||||||
|
|
||||||
case dbiDialogsWidthRatio: {
|
case dbiDialogsWidthRatioOld: {
|
||||||
qint32 v;
|
qint32 v;
|
||||||
stream >> v;
|
stream >> v;
|
||||||
if (!_checkStreamStatus(stream)) return false;
|
if (!_checkStreamStatus(stream)) return false;
|
||||||
|
|
||||||
GetStoredAuthSessionCache().dialogsWidthRatio = v / 1000000.;
|
GetStoredAuthSessionCache().setDialogsWidthRatio(v / 1000000.);
|
||||||
} break;
|
} break;
|
||||||
|
|
||||||
case dbiLastSeenWarningSeenOld: {
|
case dbiLastSeenWarningSeenOld: {
|
||||||
|
@ -1115,7 +1115,7 @@ bool _readSetting(quint32 blockId, QDataStream &stream, int version, ReadSetting
|
||||||
stream >> v;
|
stream >> v;
|
||||||
if (!_checkStreamStatus(stream)) return false;
|
if (!_checkStreamStatus(stream)) return false;
|
||||||
|
|
||||||
GetStoredAuthSessionCache().data.setLastSeenWarningSeen(v == 1);
|
GetStoredAuthSessionCache().setLastSeenWarningSeen(v == 1);
|
||||||
} break;
|
} break;
|
||||||
|
|
||||||
case dbiAuthSessionData: {
|
case dbiAuthSessionData: {
|
||||||
|
@ -1123,7 +1123,7 @@ bool _readSetting(quint32 blockId, QDataStream &stream, int version, ReadSetting
|
||||||
stream >> v;
|
stream >> v;
|
||||||
if (!_checkStreamStatus(stream)) return false;
|
if (!_checkStreamStatus(stream)) return false;
|
||||||
|
|
||||||
GetStoredAuthSessionCache().data.constructFromSerialized(v);
|
GetStoredAuthSessionCache().constructFromSerialized(v);
|
||||||
} break;
|
} break;
|
||||||
|
|
||||||
case dbiWorkMode: {
|
case dbiWorkMode: {
|
||||||
|
@ -1766,18 +1766,8 @@ void _writeUserSettings() {
|
||||||
recentEmojiPreloadData.push_back(qMakePair(item.first->id(), item.second));
|
recentEmojiPreloadData.push_back(qMakePair(item.first->id(), item.second));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
auto userDataInstance = StoredAuthSessionCache ? &StoredAuthSessionCache->data : Messenger::Instance().getAuthSessionData();
|
auto userDataInstance = StoredAuthSessionCache ? StoredAuthSessionCache.get() : Messenger::Instance().getAuthSessionData();
|
||||||
auto userData = userDataInstance ? userDataInstance->serialize() : QByteArray();
|
auto userData = userDataInstance ? userDataInstance->serialize() : QByteArray();
|
||||||
auto dialogsWidthRatio = [] {
|
|
||||||
if (StoredAuthSessionCache) {
|
|
||||||
return StoredAuthSessionCache->dialogsWidthRatio;
|
|
||||||
} else if (auto window = App::wnd()) {
|
|
||||||
if (auto controller = window->controller()) {
|
|
||||||
return controller->dialogsWidthRatio().value();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return Window::Controller::kDefaultDialogsWidthRatio;
|
|
||||||
};
|
|
||||||
|
|
||||||
uint32 size = 21 * (sizeof(quint32) + sizeof(qint32));
|
uint32 size = 21 * (sizeof(quint32) + sizeof(qint32));
|
||||||
size += sizeof(quint32) + Serialize::stringSize(Global::AskDownloadPath() ? QString() : Global::DownloadPath()) + Serialize::bytearraySize(Global::AskDownloadPath() ? QByteArray() : Global::DownloadPathBookmark());
|
size += sizeof(quint32) + Serialize::stringSize(Global::AskDownloadPath() ? QString() : Global::DownloadPath()) + Serialize::bytearraySize(Global::AskDownloadPath() ? QByteArray() : Global::DownloadPathBookmark());
|
||||||
|
@ -1822,7 +1812,6 @@ void _writeUserSettings() {
|
||||||
data.stream << quint32(dbiDialogsMode) << qint32(Global::DialogsModeEnabled() ? 1 : 0) << static_cast<qint32>(Global::DialogsMode());
|
data.stream << quint32(dbiDialogsMode) << qint32(Global::DialogsModeEnabled() ? 1 : 0) << static_cast<qint32>(Global::DialogsMode());
|
||||||
data.stream << quint32(dbiModerateMode) << qint32(Global::ModerateModeEnabled() ? 1 : 0);
|
data.stream << quint32(dbiModerateMode) << qint32(Global::ModerateModeEnabled() ? 1 : 0);
|
||||||
data.stream << quint32(dbiAutoPlay) << qint32(cAutoPlayGif() ? 1 : 0);
|
data.stream << quint32(dbiAutoPlay) << qint32(cAutoPlayGif() ? 1 : 0);
|
||||||
data.stream << quint32(dbiDialogsWidthRatio) << qint32(snap(qRound(dialogsWidthRatio() * 1000000), 0, 1000000));
|
|
||||||
data.stream << quint32(dbiUseExternalVideoPlayer) << qint32(cUseExternalVideoPlayer());
|
data.stream << quint32(dbiUseExternalVideoPlayer) << qint32(cUseExternalVideoPlayer());
|
||||||
if (!userData.isEmpty()) {
|
if (!userData.isEmpty()) {
|
||||||
data.stream << quint32(dbiAuthSessionData) << userData;
|
data.stream << quint32(dbiAuthSessionData) << userData;
|
||||||
|
|
|
@ -32,11 +32,6 @@ struct Cached;
|
||||||
|
|
||||||
namespace Local {
|
namespace Local {
|
||||||
|
|
||||||
struct StoredAuthSession {
|
|
||||||
AuthSessionData data;
|
|
||||||
float64 dialogsWidthRatio;
|
|
||||||
};
|
|
||||||
|
|
||||||
void start();
|
void start();
|
||||||
void finish();
|
void finish();
|
||||||
|
|
||||||
|
|
|
@ -108,13 +108,13 @@ Controller::ColumnLayout Controller::computeColumnLayout() const {
|
||||||
dialogsWidth = chatWidth = bodyWidth;
|
dialogsWidth = chatWidth = bodyWidth;
|
||||||
} else if (useNormalLayout()) {
|
} else if (useNormalLayout()) {
|
||||||
layout = Adaptive::WindowLayout::Normal;
|
layout = Adaptive::WindowLayout::Normal;
|
||||||
dialogsWidth = qRound(bodyWidth * dialogsWidthRatio().value());
|
dialogsWidth = qRound(bodyWidth * Auth().data().dialogsWidthRatio());
|
||||||
accumulate_max(dialogsWidth, st::columnMinimalWidthLeft);
|
accumulate_max(dialogsWidth, st::columnMinimalWidthLeft);
|
||||||
accumulate_min(dialogsWidth, bodyWidth - st::columnMinimalWidthMain);
|
accumulate_min(dialogsWidth, bodyWidth - st::columnMinimalWidthMain);
|
||||||
chatWidth = bodyWidth - dialogsWidth;
|
chatWidth = bodyWidth - dialogsWidth;
|
||||||
} else {
|
} else {
|
||||||
layout = Adaptive::WindowLayout::ThreeColumn;
|
layout = Adaptive::WindowLayout::ThreeColumn;
|
||||||
dialogsWidth = qRound(bodyWidth * dialogsWidthRatio().value());
|
dialogsWidth = qRound(bodyWidth * Auth().data().dialogsWidthRatio());
|
||||||
accumulate_max(dialogsWidth, st::columnMinimalWidthLeft);
|
accumulate_max(dialogsWidth, st::columnMinimalWidthLeft);
|
||||||
thirdWidth = st::columnMinimalWidthThird;
|
thirdWidth = st::columnMinimalWidthThird;
|
||||||
accumulate_min(
|
accumulate_min(
|
||||||
|
@ -161,9 +161,8 @@ void Controller::resizeForThirdSection() {
|
||||||
minimalThreeColumnWidth() - layout.bodyWidth,
|
minimalThreeColumnWidth() - layout.bodyWidth,
|
||||||
st::columnMinimalWidthThird);
|
st::columnMinimalWidthThird);
|
||||||
auto newBodyWidth = layout.bodyWidth + extendBy;
|
auto newBodyWidth = layout.bodyWidth + extendBy;
|
||||||
dialogsWidthRatio().set(
|
auto currentRatio = Auth().data().dialogsWidthRatio();
|
||||||
(dialogsWidthRatio().value() * layout.bodyWidth) / newBodyWidth,
|
Auth().data().setDialogsWidthRatio((currentRatio * layout.bodyWidth) / newBodyWidth);
|
||||||
true);
|
|
||||||
window()->tryToExtendWidthBy(extendBy);
|
window()->tryToExtendWidthBy(extendBy);
|
||||||
|
|
||||||
Auth().data().setTabbedSelectorSectionEnabled(
|
Auth().data().setTabbedSelectorSectionEnabled(
|
||||||
|
@ -181,9 +180,8 @@ void Controller::closeThirdSection() {
|
||||||
auto newBodyWidth = noResize
|
auto newBodyWidth = noResize
|
||||||
? layout.bodyWidth
|
? layout.bodyWidth
|
||||||
: (layout.bodyWidth - layout.thirdWidth);
|
: (layout.bodyWidth - layout.thirdWidth);
|
||||||
dialogsWidthRatio().set(
|
auto currentRatio = Auth().data().dialogsWidthRatio();
|
||||||
(dialogsWidthRatio().value() * layout.bodyWidth) / newBodyWidth,
|
Auth().data().setDialogsWidthRatio((currentRatio * layout.bodyWidth) / newBodyWidth);
|
||||||
true);
|
|
||||||
newWindowSize = QSize(
|
newWindowSize = QSize(
|
||||||
window()->width() + (newBodyWidth - layout.bodyWidth),
|
window()->width() + (newBodyWidth - layout.bodyWidth),
|
||||||
window()->height());
|
window()->height());
|
||||||
|
|
|
@ -76,8 +76,6 @@ class SectionMemento;
|
||||||
|
|
||||||
class Controller {
|
class Controller {
|
||||||
public:
|
public:
|
||||||
static constexpr auto kDefaultDialogsWidthRatio = 5. / 14;
|
|
||||||
|
|
||||||
Controller(not_null<MainWindow*> window) : _window(window) {
|
Controller(not_null<MainWindow*> window) : _window(window) {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -170,12 +168,6 @@ public:
|
||||||
not_null<PeerData*> peer,
|
not_null<PeerData*> peer,
|
||||||
QDate requestedDate);
|
QDate requestedDate);
|
||||||
|
|
||||||
base::Variable<float64> &dialogsWidthRatio() {
|
|
||||||
return _dialogsWidthRatio;
|
|
||||||
}
|
|
||||||
const base::Variable<float64> &dialogsWidthRatio() const {
|
|
||||||
return _dialogsWidthRatio;
|
|
||||||
}
|
|
||||||
base::Variable<bool> &dialogsListFocused() {
|
base::Variable<bool> &dialogsListFocused() {
|
||||||
return _dialogsListFocused;
|
return _dialogsListFocused;
|
||||||
}
|
}
|
||||||
|
@ -199,7 +191,6 @@ private:
|
||||||
base::Observable<void> _gifPauseLevelChanged;
|
base::Observable<void> _gifPauseLevelChanged;
|
||||||
base::Observable<void> _floatPlayerAreaUpdated;
|
base::Observable<void> _floatPlayerAreaUpdated;
|
||||||
|
|
||||||
base::Variable<float64> _dialogsWidthRatio = { kDefaultDialogsWidthRatio };
|
|
||||||
base::Variable<bool> _dialogsListFocused = { false };
|
base::Variable<bool> _dialogsListFocused = { false };
|
||||||
base::Variable<bool> _dialogsListDisplayForced = { false };
|
base::Variable<bool> _dialogsListDisplayForced = { false };
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue