mirror of
https://github.com/AyuGram/AyuGramDesktop.git
synced 2025-06-03 21:54:05 +02:00
Slightly improved process of switching between chats filters view types.
This commit is contained in:
parent
81aef519d4
commit
ba0da9f59e
10 changed files with 65 additions and 62 deletions
|
@ -1640,8 +1640,8 @@ bool Settings::chatFiltersHorizontal() const {
|
||||||
return _chatFiltersHorizontal.current();
|
return _chatFiltersHorizontal.current();
|
||||||
}
|
}
|
||||||
|
|
||||||
rpl::producer<bool> Settings::chatFiltersHorizontalValue() const {
|
rpl::producer<bool> Settings::chatFiltersHorizontalChanges() const {
|
||||||
return _chatFiltersHorizontal.value();
|
return _chatFiltersHorizontal.changes();
|
||||||
}
|
}
|
||||||
|
|
||||||
void Settings::setChatFiltersHorizontal(bool value) {
|
void Settings::setChatFiltersHorizontal(bool value) {
|
||||||
|
|
|
@ -930,7 +930,7 @@ public:
|
||||||
void setIvZoom(int value);
|
void setIvZoom(int value);
|
||||||
|
|
||||||
[[nodiscard]] bool chatFiltersHorizontal() const;
|
[[nodiscard]] bool chatFiltersHorizontal() const;
|
||||||
[[nodiscard]] rpl::producer<bool> chatFiltersHorizontalValue() const;
|
[[nodiscard]] rpl::producer<bool> chatFiltersHorizontalChanges() const;
|
||||||
void setChatFiltersHorizontal(bool value);
|
void setChatFiltersHorizontal(bool value);
|
||||||
|
|
||||||
[[nodiscard]] Media::VideoQuality videoQuality() const;
|
[[nodiscard]] Media::VideoQuality videoQuality() const;
|
||||||
|
|
|
@ -652,41 +652,10 @@ Widget::Widget(
|
||||||
setupDownloadBar();
|
setupDownloadBar();
|
||||||
}
|
}
|
||||||
|
|
||||||
session().data().chatsFilters().changed(
|
if (session().settings().dialogsFiltersEnabled()
|
||||||
) | rpl::start_with_next([=] {
|
&& Core::App().settings().chatFiltersHorizontal()) {
|
||||||
if (!session().data().chatsFilters().loaded()) {
|
toggleFiltersMenu(true);
|
||||||
return;
|
}
|
||||||
}
|
|
||||||
if (session().data().chatsFilters().has()) {
|
|
||||||
if (_chatFilters) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
_chatFilters = Ui::AddChatFiltersTabsStrip(
|
|
||||||
this,
|
|
||||||
&session(),
|
|
||||||
rpl::single(0),
|
|
||||||
[=](int h) { updateControlsGeometry(); },
|
|
||||||
[=](FilterId id) { controller->setActiveChatsFilter(id); },
|
|
||||||
Core::App().settings().chatFiltersHorizontalValue(),
|
|
||||||
true);
|
|
||||||
_chatFilters->stackUnder(_scroll);
|
|
||||||
_chatFilters->resizeToWidth(width());
|
|
||||||
updateControlsGeometry();
|
|
||||||
const auto shadow = Ui::CreateChild<Ui::PlainShadow>(
|
|
||||||
_chatFilters);
|
|
||||||
shadow->show();
|
|
||||||
_chatFilters->sizeValue(
|
|
||||||
) | rpl::start_with_next([=](const QSize &size) {
|
|
||||||
shadow->setGeometry(
|
|
||||||
0,
|
|
||||||
size.height() - shadow->height(),
|
|
||||||
size.width(),
|
|
||||||
shadow->height());
|
|
||||||
}, lifetime());
|
|
||||||
} else {
|
|
||||||
_chatFilters = nullptr;
|
|
||||||
}
|
|
||||||
}, lifetime());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void Widget::chosenRow(const ChosenRow &row) {
|
void Widget::chosenRow(const ChosenRow &row) {
|
||||||
|
@ -1331,6 +1300,42 @@ void Widget::updateHasFocus(not_null<QWidget*> focused) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Widget::toggleFiltersMenu(bool enabled) {
|
||||||
|
if (!enabled == !_chatFilters) {
|
||||||
|
return;
|
||||||
|
} else if (enabled) {
|
||||||
|
_chatFilters = base::make_unique_q<Ui::RpWidget>(this);
|
||||||
|
const auto raw = _chatFilters.get();
|
||||||
|
const auto inner = Ui::AddChatFiltersTabsStrip(
|
||||||
|
_chatFilters.get(),
|
||||||
|
&session(),
|
||||||
|
rpl::single(0),
|
||||||
|
[this](int h) { updateControlsGeometry(); },
|
||||||
|
[this](FilterId id) {
|
||||||
|
if (controller()->activeChatsFilterCurrent() != id) {
|
||||||
|
controller()->setActiveChatsFilter(id);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
true);
|
||||||
|
raw->show();
|
||||||
|
raw->stackUnder(_scroll);
|
||||||
|
raw->resizeToWidth(width());
|
||||||
|
const auto shadow = Ui::CreateChild<Ui::PlainShadow>(raw);
|
||||||
|
shadow->show();
|
||||||
|
inner->sizeValue() | rpl::start_with_next([=](const QSize &s) {
|
||||||
|
raw->resize(s);
|
||||||
|
shadow->setGeometry(
|
||||||
|
0,
|
||||||
|
s.height() - shadow->height(),
|
||||||
|
s.width(),
|
||||||
|
shadow->height());
|
||||||
|
}, _chatFilters->lifetime());
|
||||||
|
updateControlsGeometry();
|
||||||
|
} else {
|
||||||
|
_chatFilters = nullptr;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
bool Widget::cancelSearchByMouseBack() {
|
bool Widget::cancelSearchByMouseBack() {
|
||||||
return _searchHasFocus
|
return _searchHasFocus
|
||||||
&& !_searchSuggestionsLocked
|
&& !_searchSuggestionsLocked
|
||||||
|
|
|
@ -129,6 +129,7 @@ public:
|
||||||
[[nodiscard]] RowDescriptor resolveChatNext(RowDescriptor from = {}) const;
|
[[nodiscard]] RowDescriptor resolveChatNext(RowDescriptor from = {}) const;
|
||||||
[[nodiscard]] RowDescriptor resolveChatPrevious(RowDescriptor from = {}) const;
|
[[nodiscard]] RowDescriptor resolveChatPrevious(RowDescriptor from = {}) const;
|
||||||
void updateHasFocus(not_null<QWidget*> focused);
|
void updateHasFocus(not_null<QWidget*> focused);
|
||||||
|
void toggleFiltersMenu(bool value);
|
||||||
|
|
||||||
// Float player interface.
|
// Float player interface.
|
||||||
bool floatPlayerHandleWheelEvent(QEvent *e) override;
|
bool floatPlayerHandleWheelEvent(QEvent *e) override;
|
||||||
|
@ -317,6 +318,8 @@ private:
|
||||||
std::unique_ptr<Ui::RequestsBar> _forumRequestsBar;
|
std::unique_ptr<Ui::RequestsBar> _forumRequestsBar;
|
||||||
std::unique_ptr<HistoryView::ContactStatus> _forumReportBar;
|
std::unique_ptr<HistoryView::ContactStatus> _forumReportBar;
|
||||||
|
|
||||||
|
base::unique_qptr<Ui::RpWidget> _chatFilters;
|
||||||
|
|
||||||
object_ptr<Ui::ElasticScroll> _scroll;
|
object_ptr<Ui::ElasticScroll> _scroll;
|
||||||
QPointer<InnerWidget> _inner;
|
QPointer<InnerWidget> _inner;
|
||||||
std::unique_ptr<Suggestions> _suggestions;
|
std::unique_ptr<Suggestions> _suggestions;
|
||||||
|
@ -390,8 +393,6 @@ private:
|
||||||
|
|
||||||
QPixmap _widthAnimationCache;
|
QPixmap _widthAnimationCache;
|
||||||
|
|
||||||
Ui::RpWidget *_chatFilters = nullptr;
|
|
||||||
|
|
||||||
int _topDelta = 0;
|
int _topDelta = 0;
|
||||||
|
|
||||||
std::unique_ptr<Widget> _childList;
|
std::unique_ptr<Widget> _childList;
|
||||||
|
|
|
@ -1098,6 +1098,12 @@ void MainWidget::dialogsCancelled() {
|
||||||
_history->activate();
|
_history->activate();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void MainWidget::toggleFiltersMenu(bool value) const {
|
||||||
|
if (_dialogs) {
|
||||||
|
_dialogs->toggleFiltersMenu(value);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void MainWidget::setChatBackground(
|
void MainWidget::setChatBackground(
|
||||||
const Data::WallPaper &background,
|
const Data::WallPaper &background,
|
||||||
QImage &&image) {
|
QImage &&image) {
|
||||||
|
|
|
@ -213,6 +213,7 @@ public:
|
||||||
void showNonPremiumLimitToast(bool download);
|
void showNonPremiumLimitToast(bool download);
|
||||||
|
|
||||||
void dialogsCancelled();
|
void dialogsCancelled();
|
||||||
|
void toggleFiltersMenu(bool value) const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void paintEvent(QPaintEvent *e) override;
|
void paintEvent(QPaintEvent *e) override;
|
||||||
|
|
|
@ -40,7 +40,6 @@ struct State final {
|
||||||
std::optional<FilterId> lastFilterId = std::nullopt;
|
std::optional<FilterId> lastFilterId = std::nullopt;
|
||||||
rpl::lifetime unreadLifetime;
|
rpl::lifetime unreadLifetime;
|
||||||
base::unique_qptr<Ui::PopupMenu> menu;
|
base::unique_qptr<Ui::PopupMenu> menu;
|
||||||
rpl::variable<bool> additionalToggleOn;
|
|
||||||
|
|
||||||
Api::RemoveComplexChatFilter removeApi;
|
Api::RemoveComplexChatFilter removeApi;
|
||||||
bool waitingSuggested = false;
|
bool waitingSuggested = false;
|
||||||
|
@ -130,7 +129,6 @@ not_null<Ui::RpWidget*> AddChatFiltersTabsStrip(
|
||||||
rpl::producer<int> multiSelectHeightValue,
|
rpl::producer<int> multiSelectHeightValue,
|
||||||
Fn<void(int)> setAddedTopScrollSkip,
|
Fn<void(int)> setAddedTopScrollSkip,
|
||||||
Fn<void(FilterId)> choose,
|
Fn<void(FilterId)> choose,
|
||||||
rpl::producer<bool> additionalToggleOn,
|
|
||||||
bool trackActiveChatsFilter) {
|
bool trackActiveChatsFilter) {
|
||||||
const auto window = Core::App().findWindow(parent);
|
const auto window = Core::App().findWindow(parent);
|
||||||
const auto controller = window ? window->sessionController() : nullptr;
|
const auto controller = window ? window->sessionController() : nullptr;
|
||||||
|
@ -151,7 +149,6 @@ not_null<Ui::RpWidget*> AddChatFiltersTabsStrip(
|
||||||
object_ptr<Ui::ChatsFiltersTabs>(parent, st::dialogsSearchTabs),
|
object_ptr<Ui::ChatsFiltersTabs>(parent, st::dialogsSearchTabs),
|
||||||
QMargins(sliderPadding, 0, sliderPadding, 0)))->entity();
|
QMargins(sliderPadding, 0, sliderPadding, 0)))->entity();
|
||||||
const auto state = wrap->lifetime().make_state<State>();
|
const auto state = wrap->lifetime().make_state<State>();
|
||||||
state->additionalToggleOn = std::move(additionalToggleOn);
|
|
||||||
wrap->toggle(false, anim::type::instant);
|
wrap->toggle(false, anim::type::instant);
|
||||||
container->sizeValue() | rpl::start_with_next([=](const QSize &s) {
|
container->sizeValue() | rpl::start_with_next([=](const QSize &s) {
|
||||||
scroll->resize(s + QSize(0, scrollSt.deltax * 4));
|
scroll->resize(s + QSize(0, scrollSt.deltax * 4));
|
||||||
|
@ -289,10 +286,7 @@ not_null<Ui::RpWidget*> AddChatFiltersTabsStrip(
|
||||||
slider->contextMenuRequested() | rpl::start_with_next([=](int index) {
|
slider->contextMenuRequested() | rpl::start_with_next([=](int index) {
|
||||||
ShowMenu(wrap, controller, state, index);
|
ShowMenu(wrap, controller, state, index);
|
||||||
}, slider->lifetime());
|
}, slider->lifetime());
|
||||||
state->additionalToggleOn.value(
|
wrap->toggle((list.size() > 1), anim::type::instant);
|
||||||
) | rpl::start_with_next([=](bool enabled) {
|
|
||||||
wrap->toggle(enabled && (list.size() > 1), anim::type::instant);
|
|
||||||
}, wrap->lifetime());
|
|
||||||
};
|
};
|
||||||
session->data().chatsFilters().changed(
|
session->data().chatsFilters().changed(
|
||||||
) | rpl::start_with_next(rebuild, wrap->lifetime());
|
) | rpl::start_with_next(rebuild, wrap->lifetime());
|
||||||
|
|
|
@ -23,7 +23,6 @@ not_null<Ui::RpWidget*> AddChatFiltersTabsStrip(
|
||||||
rpl::producer<int> multiSelectHeightValue,
|
rpl::producer<int> multiSelectHeightValue,
|
||||||
Fn<void(int)> setAddedTopScrollSkip,
|
Fn<void(int)> setAddedTopScrollSkip,
|
||||||
Fn<void(FilterId)> choose,
|
Fn<void(FilterId)> choose,
|
||||||
rpl::producer<bool> additionalToggleOn = rpl::single(true),
|
|
||||||
bool trackActiveChatsFilter = false);
|
bool trackActiveChatsFilter = false);
|
||||||
|
|
||||||
} // namespace Ui
|
} // namespace Ui
|
||||||
|
|
|
@ -1315,17 +1315,20 @@ SessionController::SessionController(
|
||||||
}, lifetime());
|
}, lifetime());
|
||||||
|
|
||||||
rpl::merge(
|
rpl::merge(
|
||||||
session->data().chatsFilters().changed() | rpl::filter([=] {
|
Core::App().settings().chatFiltersHorizontalChanges() | rpl::to_empty,
|
||||||
return session->data().chatsFilters().loaded();
|
|
||||||
}) | rpl::map([] {
|
|
||||||
return Core::App().settings().chatFiltersHorizontalValue(
|
|
||||||
) | rpl::to_empty;
|
|
||||||
}) | rpl::flatten_latest(),
|
|
||||||
session->data().chatsFilters().changed()
|
session->data().chatsFilters().changed()
|
||||||
) | rpl::start_with_next([=] {
|
) | rpl::start_with_next([=] {
|
||||||
checkOpenedFilter();
|
checkOpenedFilter();
|
||||||
crl::on_main(this, [=] {
|
crl::on_main(this, [this] {
|
||||||
refreshFiltersMenu();
|
if (SessionNavigation::session().data().chatsFilters().has()) {
|
||||||
|
const auto isHorizontal
|
||||||
|
= Core::App().settings().chatFiltersHorizontal();
|
||||||
|
content()->toggleFiltersMenu(isHorizontal);
|
||||||
|
toggleFiltersMenu(!isHorizontal);
|
||||||
|
} else {
|
||||||
|
content()->toggleFiltersMenu(false);
|
||||||
|
toggleFiltersMenu(false);
|
||||||
|
}
|
||||||
});
|
});
|
||||||
}, lifetime());
|
}, lifetime());
|
||||||
|
|
||||||
|
@ -1556,11 +1559,6 @@ void SessionController::toggleFiltersMenu(bool enabled) {
|
||||||
_filtersMenuChanged.fire({});
|
_filtersMenuChanged.fire({});
|
||||||
}
|
}
|
||||||
|
|
||||||
void SessionController::refreshFiltersMenu() {
|
|
||||||
toggleFiltersMenu(session().data().chatsFilters().has()
|
|
||||||
&& !Core::App().settings().chatFiltersHorizontal());
|
|
||||||
}
|
|
||||||
|
|
||||||
rpl::producer<> SessionController::filtersMenuChanged() const {
|
rpl::producer<> SessionController::filtersMenuChanged() const {
|
||||||
return _filtersMenuChanged.events();
|
return _filtersMenuChanged.events();
|
||||||
}
|
}
|
||||||
|
|
|
@ -630,7 +630,6 @@ private:
|
||||||
|
|
||||||
void init();
|
void init();
|
||||||
void setupShortcuts();
|
void setupShortcuts();
|
||||||
void refreshFiltersMenu();
|
|
||||||
void checkOpenedFilter();
|
void checkOpenedFilter();
|
||||||
void suggestArchiveAndMute();
|
void suggestArchiveAndMute();
|
||||||
void activateFirstChatsFilter();
|
void activateFirstChatsFilter();
|
||||||
|
|
Loading…
Add table
Reference in a new issue