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