mirror of
https://github.com/AyuGram/AyuGramDesktop.git
synced 2025-07-24 14:33:02 +02:00
Save subsection tabs layout to disk.
This commit is contained in:
parent
a72782e232
commit
7dadaa1b28
7 changed files with 77 additions and 5 deletions
|
@ -810,7 +810,7 @@ bool HistoryInner::canHaveFromUserpics() const {
|
|||
} else if (const auto channel = _peer->asBroadcast()) {
|
||||
return channel->signatureProfiles();
|
||||
}
|
||||
return !_removeFromUserpics;
|
||||
return _isChatWide || !_removeFromUserpics;
|
||||
}
|
||||
|
||||
void HistoryInner::toggleRemoveFromUserpics(bool remove) {
|
||||
|
|
|
@ -6474,7 +6474,7 @@ void HistoryWidget::updateControlsGeometry() {
|
|||
_topBars->resize(
|
||||
innerWidth,
|
||||
scrollAreaTop - _topBars->y() + st::lineWidth);
|
||||
if (_scroll->y() != scrollAreaTop) {
|
||||
if (_scroll->y() != scrollAreaTop || _scroll->x() != tabsLeftSkip) {
|
||||
_scroll->moveToLeft(tabsLeftSkip, scrollAreaTop);
|
||||
if (_autocomplete) {
|
||||
_autocomplete->setBoundings(_scroll->geometry());
|
||||
|
@ -8301,6 +8301,7 @@ void HistoryWidget::validateSubsectionTabs() {
|
|||
updateControlsGeometry();
|
||||
orderWidgets();
|
||||
}, _subsectionTabsLifetime);
|
||||
_list->toggleRemoveFromUserpics(_subsectionTabs->leftSkip() > 0);
|
||||
updateControlsGeometry();
|
||||
orderWidgets();
|
||||
}
|
||||
|
|
|
@ -1590,6 +1590,9 @@ void ChatWidget::validateSubsectionTabs() {
|
|||
updateControlsGeometry();
|
||||
orderWidgets();
|
||||
}, _subsectionTabsLifetime);
|
||||
_inner->overrideChatMode((_subsectionTabs->leftSkip() > 0)
|
||||
? ElementChatMode::Narrow
|
||||
: std::optional<ElementChatMode>());
|
||||
updateControlsGeometry();
|
||||
orderWidgets();
|
||||
}
|
||||
|
|
|
@ -21,6 +21,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
|||
#include "history/history.h"
|
||||
#include "lang/lang_keys.h"
|
||||
#include "main/main_session.h"
|
||||
#include "main/main_session_settings.h"
|
||||
#include "ui/controls/subsection_tabs_slider.h"
|
||||
#include "ui/effects/ripple_animation.h"
|
||||
#include "ui/widgets/menu/menu_add_action_callback_factory.h"
|
||||
|
@ -56,7 +57,7 @@ SubsectionTabs::SubsectionTabs(
|
|||
, _afterLimit(kDefaultLimit) {
|
||||
track();
|
||||
refreshSlice();
|
||||
setupHorizontal(parent);
|
||||
setup(parent);
|
||||
|
||||
dataChanged() | rpl::start_with_next([=] {
|
||||
if (_loading) {
|
||||
|
@ -72,6 +73,15 @@ SubsectionTabs::~SubsectionTabs() {
|
|||
delete base::take(_shadow);
|
||||
}
|
||||
|
||||
void SubsectionTabs::setup(not_null<Ui::RpWidget*> parent) {
|
||||
const auto peerId = _history->peer->id;
|
||||
if (session().settings().verticalSubsectionTabs(peerId)) {
|
||||
setupVertical(parent);
|
||||
} else {
|
||||
setupHorizontal(parent);
|
||||
}
|
||||
}
|
||||
|
||||
void SubsectionTabs::setupHorizontal(not_null<QWidget*> parent) {
|
||||
delete base::take(_vertical);
|
||||
_horizontal = Ui::CreateChild<Ui::RpWidget>(parent);
|
||||
|
@ -397,7 +407,7 @@ void SubsectionTabs::setupSlider(
|
|||
slider->setSections({
|
||||
.tabs = std::move(sections),
|
||||
.context = Core::TextContext({
|
||||
.session = &_history->session(),
|
||||
.session = &session(),
|
||||
}),
|
||||
}, paused);
|
||||
slider->setActiveSectionFast(activeIndex);
|
||||
|
@ -466,6 +476,11 @@ void SubsectionTabs::toggleModes() {
|
|||
} else {
|
||||
setupHorizontal(_vertical->parentWidget());
|
||||
}
|
||||
const auto peerId = _history->peer->id;
|
||||
const auto vertical = (_vertical != nullptr);
|
||||
session().settings().setVerticalSubsectionTabs(peerId, vertical);
|
||||
session().saveSettingsDelayed();
|
||||
|
||||
_layoutRequests.fire({});
|
||||
}
|
||||
|
||||
|
@ -703,6 +718,10 @@ void SubsectionTabs::scheduleRefresh() {
|
|||
});
|
||||
}
|
||||
|
||||
Main::Session &SubsectionTabs::session() {
|
||||
return _history->session();
|
||||
}
|
||||
|
||||
bool SubsectionTabs::switchTo(
|
||||
not_null<Data::Thread*> thread,
|
||||
not_null<Ui::RpWidget*> parent) {
|
||||
|
|
|
@ -16,6 +16,10 @@ namespace Data {
|
|||
class Thread;
|
||||
} // namespace Data
|
||||
|
||||
namespace Main {
|
||||
class Session;
|
||||
} // namespace Main
|
||||
|
||||
namespace Window {
|
||||
class SessionController;
|
||||
} // namespace Window
|
||||
|
@ -37,6 +41,8 @@ public:
|
|||
not_null<Data::Thread*> thread);
|
||||
~SubsectionTabs();
|
||||
|
||||
[[nodiscard]] Main::Session &session();
|
||||
|
||||
[[nodiscard]] bool switchTo(
|
||||
not_null<Data::Thread*> thread,
|
||||
not_null<Ui::RpWidget*> parent);
|
||||
|
@ -79,6 +85,7 @@ private:
|
|||
void refreshSlice();
|
||||
void scheduleRefresh();
|
||||
void loadMore();
|
||||
void setup(not_null<Ui::RpWidget*> parent);
|
||||
[[nodiscard]] rpl::producer<> dataChanged() const;
|
||||
|
||||
void setupSlider(
|
||||
|
|
|
@ -42,7 +42,9 @@ QByteArray SessionSettings::serialize() const {
|
|||
+ sizeof(qint32) * 3
|
||||
+ _groupEmojiSectionHidden.size() * sizeof(quint64)
|
||||
+ sizeof(qint32) * 3
|
||||
+ _hiddenPinnedMessages.size() * (sizeof(quint64) * 4);
|
||||
+ _hiddenPinnedMessages.size() * (sizeof(quint64) * 4)
|
||||
+ sizeof(qint32)
|
||||
+ _verticalSubsectionTabs.size() * sizeof(quint64);
|
||||
|
||||
auto result = QByteArray();
|
||||
result.reserve(size);
|
||||
|
@ -94,6 +96,10 @@ QByteArray SessionSettings::serialize() const {
|
|||
<< SerializePeerId(key.monoforumPeerId)
|
||||
<< qint64(value.bare);
|
||||
}
|
||||
stream << qint32(_verticalSubsectionTabs.size());
|
||||
for (const auto &peerId : _verticalSubsectionTabs) {
|
||||
stream << SerializePeerId(peerId);
|
||||
}
|
||||
}
|
||||
|
||||
Ensures(result.size() == size);
|
||||
|
@ -153,6 +159,7 @@ void SessionSettings::addFromSerialized(const QByteArray &serialized) {
|
|||
std::vector<int> appDictionariesEnabled;
|
||||
qint32 appAutoDownloadDictionaries = app.autoDownloadDictionaries() ? 1 : 0;
|
||||
base::flat_map<ThreadId, MsgId> hiddenPinnedMessages;
|
||||
base::flat_set<PeerId> verticalSubsectionTabs;
|
||||
qint32 dialogsFiltersEnabled = _dialogsFiltersEnabled ? 1 : 0;
|
||||
qint32 supportAllSilent = _supportAllSilent ? 1 : 0;
|
||||
qint32 photoEditorHintShowsCount = _photoEditorHintShowsCount;
|
||||
|
@ -466,6 +473,22 @@ void SessionSettings::addFromSerialized(const QByteArray &serialized) {
|
|||
}
|
||||
}
|
||||
}
|
||||
if (!stream.atEnd()) {
|
||||
auto count = qint32(0);
|
||||
stream >> count;
|
||||
if (stream.status() == QDataStream::Ok) {
|
||||
for (auto i = 0; i != count; ++i) {
|
||||
auto peerId = quint64();
|
||||
stream >> peerId;
|
||||
if (stream.status() != QDataStream::Ok) {
|
||||
LOG(("App Error: "
|
||||
"Bad data for SessionSettings::addFromSerialized()"));
|
||||
return;
|
||||
}
|
||||
verticalSubsectionTabs.emplace(DeserializePeerId(peerId));
|
||||
}
|
||||
}
|
||||
}
|
||||
if (stream.status() != QDataStream::Ok) {
|
||||
LOG(("App Error: "
|
||||
"Bad data for SessionSettings::addFromSerialized()"));
|
||||
|
@ -512,6 +535,7 @@ void SessionSettings::addFromSerialized(const QByteArray &serialized) {
|
|||
_mutePeriods = std::move(mutePeriods);
|
||||
_lastNonPremiumLimitDownload = lastNonPremiumLimitDownload;
|
||||
_lastNonPremiumLimitUpload = lastNonPremiumLimitUpload;
|
||||
_verticalSubsectionTabs = std::move(verticalSubsectionTabs);
|
||||
|
||||
if (version < 2) {
|
||||
app.setLastSeenWarningSeen(appLastSeenWarningSeen == 1);
|
||||
|
@ -646,6 +670,20 @@ void SessionSettings::setHiddenPinnedMessageId(
|
|||
}
|
||||
}
|
||||
|
||||
bool SessionSettings::verticalSubsectionTabs(PeerId peerId) const {
|
||||
return _verticalSubsectionTabs.contains(peerId);
|
||||
}
|
||||
|
||||
void SessionSettings::setVerticalSubsectionTabs(
|
||||
PeerId peerId,
|
||||
bool vertical) {
|
||||
if (vertical) {
|
||||
_verticalSubsectionTabs.emplace(peerId);
|
||||
} else {
|
||||
_verticalSubsectionTabs.remove(peerId);
|
||||
}
|
||||
}
|
||||
|
||||
bool SessionSettings::photoEditorHintShown() const {
|
||||
return _photoEditorHintShowsCount < kPhotoEditorHintMaxShowsCount;
|
||||
}
|
||||
|
|
|
@ -118,6 +118,9 @@ public:
|
|||
PeerId monoforumPeerId,
|
||||
MsgId msgId);
|
||||
|
||||
[[nodiscard]] bool verticalSubsectionTabs(PeerId peerId) const;
|
||||
void setVerticalSubsectionTabs(PeerId peerId, bool vertical);
|
||||
|
||||
[[nodiscard]] bool dialogsFiltersEnabled() const {
|
||||
return _dialogsFiltersEnabled;
|
||||
}
|
||||
|
@ -167,6 +170,7 @@ private:
|
|||
rpl::variable<bool> _archiveInMainMenu = false;
|
||||
rpl::variable<bool> _skipArchiveInSearch = false;
|
||||
base::flat_map<ThreadId, MsgId> _hiddenPinnedMessages;
|
||||
base::flat_set<PeerId> _verticalSubsectionTabs;
|
||||
bool _dialogsFiltersEnabled = false;
|
||||
int _photoEditorHintShowsCount = 0;
|
||||
std::vector<TimeId> _mutePeriods;
|
||||
|
|
Loading…
Add table
Reference in a new issue