mirror of
https://github.com/telegramdesktop/tdesktop
synced 2025-03-30 23:38:25 +00:00
Allow small dialogs list with three columns.
This commit is contained in:
parent
5c4daeee4c
commit
c0e780a28f
@ -46,7 +46,7 @@ AuthSessionData::Variables::Variables()
|
||||
}
|
||||
|
||||
QByteArray AuthSessionData::serialize() const {
|
||||
auto size = sizeof(qint32) * 8;
|
||||
auto size = sizeof(qint32) * 10;
|
||||
for (auto i = _variables.soundOverrides.cbegin(), e = _variables.soundOverrides.cend(); i != e; ++i) {
|
||||
size += Serialize::stringSize(i.key()) + Serialize::stringSize(i.value());
|
||||
}
|
||||
@ -72,6 +72,7 @@ QByteArray AuthSessionData::serialize() const {
|
||||
stream << quint64(peerId);
|
||||
}
|
||||
stream << qint32(_variables.thirdSectionInfoEnabled ? 1 : 0);
|
||||
stream << qint32(_variables.smallDialogsList ? 1 : 0);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
@ -92,6 +93,7 @@ void AuthSessionData::constructFromSerialized(const QByteArray &serialized) {
|
||||
QMap<QString, QString> soundOverrides;
|
||||
base::flat_set<PeerId> groupStickersSectionHidden;
|
||||
qint32 thirdSectionInfoEnabled = 0;
|
||||
qint32 smallDialogsList = 0;
|
||||
stream >> selectorTab;
|
||||
stream >> lastSeenWarningSeen;
|
||||
if (!stream.atEnd()) {
|
||||
@ -127,6 +129,7 @@ void AuthSessionData::constructFromSerialized(const QByteArray &serialized) {
|
||||
}
|
||||
if (!stream.atEnd()) {
|
||||
stream >> thirdSectionInfoEnabled;
|
||||
stream >> smallDialogsList;
|
||||
}
|
||||
if (stream.status() != QDataStream::Ok) {
|
||||
LOG(("App Error: Bad data for AuthSessionData::constructFromSerialized()"));
|
||||
@ -158,6 +161,7 @@ void AuthSessionData::constructFromSerialized(const QByteArray &serialized) {
|
||||
}
|
||||
_variables.groupStickersSectionHidden = std::move(groupStickersSectionHidden);
|
||||
_variables.thirdSectionInfoEnabled = thirdSectionInfoEnabled;
|
||||
_variables.smallDialogsList = smallDialogsList;
|
||||
}
|
||||
|
||||
void AuthSessionData::setTabbedSelectorSectionEnabled(bool enabled) {
|
||||
|
@ -110,6 +110,12 @@ public:
|
||||
return _thirdSectionInfoEnabledValue.events_starting_with(
|
||||
thirdSectionInfoEnabled());
|
||||
}
|
||||
void setSmallDialogsList(bool enabled) {
|
||||
_variables.smallDialogsList = enabled;
|
||||
}
|
||||
bool smallDialogsList() const {
|
||||
return _variables.smallDialogsList;
|
||||
}
|
||||
void setLastTimeVideoPlayedAt(TimeMs time) {
|
||||
_lastTimeVideoPlayedAt = time;
|
||||
}
|
||||
@ -164,6 +170,7 @@ private:
|
||||
RectPart floatPlayerCorner;
|
||||
base::flat_set<PeerId> groupStickersSectionHidden;
|
||||
bool thirdSectionInfoEnabled = false;
|
||||
bool smallDialogsList = false;
|
||||
};
|
||||
|
||||
base::Variable<bool> _contactsLoaded = { false };
|
||||
|
@ -236,7 +236,6 @@ namespace Adaptive {
|
||||
|
||||
enum class WindowLayout {
|
||||
OneColumn,
|
||||
SmallColumn,
|
||||
Normal,
|
||||
ThreeColumn,
|
||||
};
|
||||
@ -417,10 +416,6 @@ inline bool OneColumn() {
|
||||
return Global::AdaptiveWindowLayout() == WindowLayout::OneColumn;
|
||||
}
|
||||
|
||||
inline bool SmallColumn() {
|
||||
return Global::AdaptiveWindowLayout() == WindowLayout::SmallColumn;
|
||||
}
|
||||
|
||||
inline bool Normal() {
|
||||
return Global::AdaptiveWindowLayout() == WindowLayout::Normal;
|
||||
}
|
||||
|
@ -131,7 +131,7 @@ infoProfileSeparatorPadding: margins(
|
||||
infoProfileSkip);
|
||||
|
||||
infoIconFg: menuIconFg;
|
||||
infoIconPosition: point(28px, 8px);
|
||||
infoIconPosition: point(28px, 4px);
|
||||
infoIconInformation: icon {{ "info_information", infoIconFg }};
|
||||
infoIconMembers: icon {{ "info_members", infoIconFg }};
|
||||
infoIconNotifications: icon {{ "info_notifications", infoIconFg }};
|
||||
|
@ -395,9 +395,13 @@ void CoverLine::refreshStatusText() {
|
||||
}
|
||||
|
||||
void CoverLine::refreshNameGeometry(int newWidth) {
|
||||
_name->resizeToWidth(newWidth
|
||||
auto nameWidth = newWidth
|
||||
- st::infoProfileNameLeft
|
||||
- st::infoProfileNameRight);
|
||||
- st::infoProfileNameRight;
|
||||
if (_toggle) {
|
||||
nameWidth -= _toggle->width() + st::infoProfileToggleRight;
|
||||
}
|
||||
_name->resizeToWidth(nameWidth);
|
||||
_name->moveToLeft(
|
||||
st::infoProfileNameLeft,
|
||||
st::infoProfileNameTop,
|
||||
@ -405,9 +409,13 @@ void CoverLine::refreshNameGeometry(int newWidth) {
|
||||
}
|
||||
|
||||
void CoverLine::refreshStatusGeometry(int newWidth) {
|
||||
_status->resizeToWidth(newWidth
|
||||
auto statusWidth = newWidth
|
||||
- st::infoProfileStatusLeft
|
||||
- st::infoProfileStatusRight);
|
||||
- st::infoProfileStatusRight;
|
||||
if (_toggle) {
|
||||
statusWidth -= _toggle->width() + st::infoProfileToggleRight;
|
||||
}
|
||||
_status->resizeToWidth(statusWidth);
|
||||
_status->moveToLeft(
|
||||
st::infoProfileStatusLeft,
|
||||
st::infoProfileStatusTop,
|
||||
|
@ -3410,7 +3410,7 @@ void MainWidget::resizeEvent(QResizeEvent *e) {
|
||||
|
||||
void MainWidget::updateControlsGeometry() {
|
||||
updateWindowAdaptiveLayout();
|
||||
if (!Adaptive::SmallColumn()) {
|
||||
if (_controller->dialogsWidthRatio().value() > 0) {
|
||||
_a_dialogsWidth.finish();
|
||||
}
|
||||
if (!_a_dialogsWidth.animating()) {
|
||||
@ -3510,14 +3510,21 @@ void MainWidget::updateControlsGeometry() {
|
||||
}
|
||||
|
||||
void MainWidget::updateDialogsWidthAnimated() {
|
||||
if (!Adaptive::SmallColumn()) {
|
||||
if (_controller->dialogsWidthRatio().value() > 0) {
|
||||
return;
|
||||
}
|
||||
auto dialogsWidth = _dialogsWidth;
|
||||
updateWindowAdaptiveLayout();
|
||||
if (Adaptive::SmallColumn() && (_dialogsWidth != dialogsWidth || _a_dialogsWidth.animating())) {
|
||||
if (!_controller->dialogsWidthRatio().value()
|
||||
&& (_dialogsWidth != dialogsWidth
|
||||
|| _a_dialogsWidth.animating())) {
|
||||
_dialogs->startWidthAnimation();
|
||||
_a_dialogsWidth.start([this] { updateControlsGeometry(); }, dialogsWidth, _dialogsWidth, st::dialogsWidthDuration, anim::easeOutCirc);
|
||||
_a_dialogsWidth.start(
|
||||
[this] { updateControlsGeometry(); },
|
||||
dialogsWidth,
|
||||
_dialogsWidth,
|
||||
st::dialogsWidthDuration,
|
||||
anim::easeOutCirc);
|
||||
updateControlsGeometry();
|
||||
}
|
||||
}
|
||||
@ -3563,14 +3570,17 @@ bool MainWidget::eventFilter(QObject *o, QEvent *e) {
|
||||
_resizingSideShift = mouseLeft() - (Adaptive::OneColumn() ? 0 : _dialogsWidth);
|
||||
} else if (e->type() == QEvent::MouseButtonRelease) {
|
||||
_resizingSide = false;
|
||||
if (!Adaptive::OneColumn()) {
|
||||
_controller->dialogsWidthRatio().set(float64(_dialogsWidth) / width(), true);
|
||||
if (!Adaptive::OneColumn()
|
||||
&& _controller->dialogsWidthRatio().value() > 0) {
|
||||
_controller->dialogsWidthRatio().set(
|
||||
float64(_dialogsWidth) / width(),
|
||||
true);
|
||||
}
|
||||
Local::writeUserSettings();
|
||||
} else if (e->type() == QEvent::MouseMove && _resizingSide) {
|
||||
auto newWidth = mouseLeft() - _resizingSideShift;
|
||||
accumulate_max(newWidth, _controller->dialogsSmallColumnWidth());
|
||||
_controller->dialogsWidthRatio().set(float64(newWidth) / width(), true);
|
||||
auto newRatio = (newWidth < st::dialogsWidthMin / 2) ? 0. : float64(newWidth) / width();
|
||||
_controller->dialogsWidthRatio().set(newRatio, true);
|
||||
}
|
||||
} else if (e->type() == QEvent::FocusIn) {
|
||||
if (auto widget = qobject_cast<QWidget*>(o)) {
|
||||
@ -3655,7 +3665,12 @@ void MainWidget::updateWindowAdaptiveLayout() {
|
||||
|
||||
_controller->dialogsWidthRatio().set(dialogsWidthRatio, true);
|
||||
|
||||
_dialogsWidth = layout.dialogsWidth;
|
||||
auto useSmallColumnWidth = !Adaptive::OneColumn()
|
||||
&& !dialogsWidthRatio
|
||||
&& !_controller->forceWideDialogs();
|
||||
_dialogsWidth = useSmallColumnWidth
|
||||
? _controller->dialogsSmallColumnWidth()
|
||||
: layout.dialogsWidth;
|
||||
if (layout.windowLayout != Global::AdaptiveWindowLayout()) {
|
||||
Global::SetAdaptiveWindowLayout(layout.windowLayout);
|
||||
Adaptive::Changed().notify(true);
|
||||
|
@ -73,20 +73,22 @@ int Controller::minimalThreeColumnWidth() const {
|
||||
+ st::columnMinimalWidthThird;
|
||||
}
|
||||
|
||||
bool Controller::forceWideDialogs() const {
|
||||
if (dialogsListDisplayForced().value()) {
|
||||
return true;
|
||||
} else if (dialogsListFocused().value()) {
|
||||
return true;
|
||||
}
|
||||
return !App::main()->isMainSectionShown();
|
||||
}
|
||||
|
||||
Controller::ColumnLayout Controller::computeColumnLayout() const {
|
||||
auto layout = Adaptive::WindowLayout::OneColumn;
|
||||
|
||||
auto bodyWidth = window()->bodyWidget()->width();
|
||||
auto dialogsWidth = qRound(bodyWidth * dialogsWidthRatio().value());
|
||||
auto chatWidth = bodyWidth - dialogsWidth;
|
||||
auto thirdWidth = 0;
|
||||
accumulate_max(chatWidth, st::columnMinimalWidthMain);
|
||||
dialogsWidth = bodyWidth - chatWidth;
|
||||
auto dialogsWidth = 0, chatWidth = 0, thirdWidth = 0;
|
||||
|
||||
auto useOneColumnLayout = [this, bodyWidth, dialogsWidth] {
|
||||
if (dialogsWidth < st::dialogsPadding.x() && Adaptive::OneColumn()) {
|
||||
return true;
|
||||
}
|
||||
auto useOneColumnLayout = [this, bodyWidth] {
|
||||
auto minimalNormal = st::columnMinimalWidthLeft
|
||||
+ st::columnMinimalWidthMain;
|
||||
if (bodyWidth < minimalNormal) {
|
||||
@ -95,14 +97,6 @@ Controller::ColumnLayout Controller::computeColumnLayout() const {
|
||||
return false;
|
||||
};
|
||||
|
||||
auto useSmallColumnLayout = [this, dialogsWidth] {
|
||||
// Used if useOneColumnLayout() == false.
|
||||
if (dialogsWidth < st::dialogsWidthMin / 2) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
};
|
||||
|
||||
auto useNormalLayout = [this, bodyWidth] {
|
||||
// Used if useSmallColumnLayout() == false.
|
||||
if (bodyWidth < minimalThreeColumnWidth()) {
|
||||
@ -117,28 +111,15 @@ Controller::ColumnLayout Controller::computeColumnLayout() const {
|
||||
|
||||
if (useOneColumnLayout()) {
|
||||
dialogsWidth = chatWidth = bodyWidth;
|
||||
} else if (useSmallColumnLayout()) {
|
||||
layout = Adaptive::WindowLayout::SmallColumn;
|
||||
auto forceWideDialogs = [this] {
|
||||
if (dialogsListDisplayForced().value()) {
|
||||
return true;
|
||||
} else if (dialogsListFocused().value()) {
|
||||
return true;
|
||||
}
|
||||
return !App::main()->isMainSectionShown();
|
||||
};
|
||||
if (forceWideDialogs()) {
|
||||
dialogsWidth = st::dialogsWidthMin;
|
||||
} else {
|
||||
dialogsWidth = dialogsSmallColumnWidth();
|
||||
}
|
||||
chatWidth = bodyWidth - dialogsWidth;
|
||||
} else if (useNormalLayout()) {
|
||||
layout = Adaptive::WindowLayout::Normal;
|
||||
dialogsWidth = qRound(bodyWidth * dialogsWidthRatio().value());
|
||||
accumulate_max(dialogsWidth, st::columnMinimalWidthLeft);
|
||||
accumulate_min(dialogsWidth, bodyWidth - st::columnMinimalWidthMain);
|
||||
chatWidth = bodyWidth - dialogsWidth;
|
||||
} else {
|
||||
layout = Adaptive::WindowLayout::ThreeColumn;
|
||||
dialogsWidth = qRound(bodyWidth * dialogsWidthRatio().value());
|
||||
accumulate_max(dialogsWidth, st::columnMinimalWidthLeft);
|
||||
thirdWidth = st::columnMinimalWidthThird;
|
||||
accumulate_min(
|
||||
@ -184,7 +165,7 @@ void Controller::resizeForThirdSection() {
|
||||
auto extendBy = st::columnMinimalWidthThird;
|
||||
auto newBodyWidth = layout.bodyWidth + extendBy;
|
||||
dialogsWidthRatio().set(
|
||||
float64(layout.dialogsWidth) / newBodyWidth,
|
||||
(dialogsWidthRatio().value() * layout.bodyWidth) / newBodyWidth,
|
||||
true);
|
||||
window()->tryToExtendWidthBy(extendBy);
|
||||
|
||||
@ -204,7 +185,7 @@ void Controller::closeThirdSection() {
|
||||
? layout.bodyWidth
|
||||
: (layout.bodyWidth - layout.thirdWidth);
|
||||
dialogsWidthRatio().set(
|
||||
float64(layout.dialogsWidth) / newBodyWidth,
|
||||
(dialogsWidthRatio().value() * layout.bodyWidth) / newBodyWidth,
|
||||
true);
|
||||
newWindowSize = QSize(
|
||||
window()->width() + (newBodyWidth - layout.bodyWidth),
|
||||
|
@ -83,6 +83,7 @@ public:
|
||||
};
|
||||
ColumnLayout computeColumnLayout() const;
|
||||
int dialogsSmallColumnWidth() const;
|
||||
bool forceWideDialogs() const;
|
||||
void updateColumnLayout();
|
||||
bool canShowThirdSection() const;
|
||||
bool canShowThirdSectionWithoutResize() const;
|
||||
|
Loading…
Reference in New Issue
Block a user