mirror of
https://github.com/AyuGram/AyuGramDesktop.git
synced 2025-04-16 06:07:06 +02:00
Allow narrow chats width without main section.
This commit is contained in:
parent
2f03b9aa29
commit
39658ffe52
7 changed files with 30 additions and 57 deletions
|
@ -2871,8 +2871,6 @@ void InnerWidget::refresh(bool toTop) {
|
|||
jumpToTop();
|
||||
preloadRowsData();
|
||||
}
|
||||
_controller->setDialogsListDisplayForced(
|
||||
_searchInChat || !_filter.isEmpty());
|
||||
update();
|
||||
}
|
||||
|
||||
|
@ -3060,9 +3058,6 @@ void InnerWidget::searchInChat(
|
|||
_searchInChatUserpic = {};
|
||||
}
|
||||
moveCancelSearchButtons();
|
||||
|
||||
_controller->setDialogsListDisplayForced(
|
||||
_searchInChat || !_filter.isEmpty());
|
||||
}
|
||||
|
||||
auto InnerWidget::searchTagsChanges() const
|
||||
|
|
|
@ -357,8 +357,14 @@ Widget::Widget(
|
|||
) | rpl::start_with_next([=] {
|
||||
applySearchUpdate();
|
||||
}, _search->lifetime());
|
||||
|
||||
_search->focusedChanges() | rpl::start_with_next([=](bool focused) {
|
||||
updateForceDisplayWide();
|
||||
}, _search->lifetime());
|
||||
|
||||
_search->submits(
|
||||
) | rpl::start_with_next([=] { submit(); }, _search->lifetime());
|
||||
|
||||
QObject::connect(
|
||||
_search->rawTextEdit().get(),
|
||||
&QTextEdit::cursorPositionChanged,
|
||||
|
@ -2469,6 +2475,13 @@ void Widget::applySearchUpdate(bool force) {
|
|||
}
|
||||
}
|
||||
_lastSearchText = filterText;
|
||||
updateForceDisplayWide();
|
||||
}
|
||||
|
||||
void Widget::updateForceDisplayWide() {
|
||||
controller()->setChatsForceDisplayWide(_search->hasFocus()
|
||||
|| !_search->getLastText().isEmpty()
|
||||
|| _searchInChat);
|
||||
}
|
||||
|
||||
void Widget::showForum(
|
||||
|
@ -2687,11 +2700,12 @@ bool Widget::setSearchInChat(
|
|||
&& _lastSearchText == HistoryView::SwitchToChooseFromQuery()) {
|
||||
cancelSearch();
|
||||
}
|
||||
if (_searchInChat) {
|
||||
if (_searchInChat || !_search->getLastText().isEmpty()) {
|
||||
_search->setFocus();
|
||||
} else {
|
||||
setFocus();
|
||||
}
|
||||
updateForceDisplayWide();
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -3209,7 +3223,7 @@ void Widget::cancelSearchInChat() {
|
|||
setSearchInChat(Key());
|
||||
}
|
||||
applySearchUpdate(true);
|
||||
if (!isOneColumn) {
|
||||
if (!isOneColumn && _search->getLastText().isEmpty()) {
|
||||
controller()->content()->dialogsCancelled();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -233,6 +233,7 @@ private:
|
|||
mtpRequestId requestId);
|
||||
void peopleFailed(const MTP::Error &error, mtpRequestId requestId);
|
||||
|
||||
void updateForceDisplayWide();
|
||||
void scrollToDefault(bool verytop = false);
|
||||
void scrollToDefaultChecked(bool verytop = false);
|
||||
void setupScrollUpButton();
|
||||
|
|
|
@ -296,11 +296,11 @@ MainWidget::MainWidget(
|
|||
_player->finishAnimating();
|
||||
}
|
||||
|
||||
rpl::merge(
|
||||
_controller->dialogsListFocusedChanges(),
|
||||
_controller->dialogsListDisplayForcedChanges()
|
||||
_controller->chatsForceDisplayWideChanges(
|
||||
) | rpl::start_with_next([=] {
|
||||
updateDialogsWidthAnimated();
|
||||
crl::on_main(this, [=] {
|
||||
updateDialogsWidthAnimated();
|
||||
});
|
||||
}, lifetime());
|
||||
|
||||
rpl::merge(
|
||||
|
@ -1315,7 +1315,6 @@ void MainWidget::showHistory(
|
|||
}
|
||||
}
|
||||
|
||||
_controller->setDialogsListFocused(false);
|
||||
_a_dialogsWidth.stop();
|
||||
|
||||
using Way = SectionShow::Way;
|
||||
|
@ -1708,7 +1707,6 @@ void MainWidget::showNewSection(
|
|||
_controller->window().hideSettingsAndLayer();
|
||||
}
|
||||
|
||||
_controller->setDialogsListFocused(false);
|
||||
_a_dialogsWidth.stop();
|
||||
|
||||
auto mainSectionTop = getMainSectionTop();
|
||||
|
@ -2626,23 +2624,7 @@ bool MainWidget::eventFilter(QObject *o, QEvent *e) {
|
|||
const auto widget = o->isWidgetType()
|
||||
? static_cast<QWidget*>(o)
|
||||
: nullptr;
|
||||
if (e->type() == QEvent::FocusIn) {
|
||||
if (widget && (widget->window() == window())) {
|
||||
if (_history == widget || _history->isAncestorOf(widget)
|
||||
|| (_mainSection
|
||||
&& (_mainSection == widget
|
||||
|| _mainSection->isAncestorOf(widget)))
|
||||
|| (_thirdSection
|
||||
&& (_thirdSection == widget
|
||||
|| _thirdSection->isAncestorOf(widget)))) {
|
||||
_controller->setDialogsListFocused(false);
|
||||
} else if (_dialogs
|
||||
&& (_dialogs == widget
|
||||
|| _dialogs->isAncestorOf(widget))) {
|
||||
_controller->setDialogsListFocused(true);
|
||||
}
|
||||
}
|
||||
} else if (e->type() == QEvent::MouseButtonPress) {
|
||||
if (e->type() == QEvent::MouseButtonPress) {
|
||||
if (widget && (widget->window() == window())) {
|
||||
const auto event = static_cast<QMouseEvent*>(e);
|
||||
if (event->button() == Qt::BackButton) {
|
||||
|
@ -2749,7 +2731,7 @@ void MainWidget::updateWindowAdaptiveLayout() {
|
|||
|
||||
auto useSmallColumnWidth = !isOneColumn()
|
||||
&& !dialogsWidthRatio
|
||||
&& !_controller->forceWideDialogs();
|
||||
&& !_controller->chatsForceDisplayWide();
|
||||
_dialogsWidth = !_dialogs
|
||||
? 0
|
||||
: useSmallColumnWidth
|
||||
|
|
|
@ -41,9 +41,6 @@ not_null<Controller*> LockWidget::window() const {
|
|||
}
|
||||
|
||||
void LockWidget::setInnerFocus() {
|
||||
if (const auto controller = _window->sessionController()) {
|
||||
controller->setDialogsListFocused(false);
|
||||
}
|
||||
setFocus();
|
||||
}
|
||||
|
||||
|
|
|
@ -1892,11 +1892,6 @@ int SessionController::minimalThreeColumnWidth() const {
|
|||
+ st::columnMinimalWidthThird;
|
||||
}
|
||||
|
||||
bool SessionController::forceWideDialogs() const {
|
||||
return _dialogsListDisplayForced.current()
|
||||
|| _dialogsListFocused.current();
|
||||
}
|
||||
|
||||
auto SessionController::computeColumnLayout() const -> ColumnLayout {
|
||||
auto layout = Adaptive::WindowLayout::OneColumn;
|
||||
|
||||
|
|
|
@ -423,7 +423,6 @@ public:
|
|||
};
|
||||
[[nodiscard]] ColumnLayout computeColumnLayout() const;
|
||||
int dialogsSmallColumnWidth() const;
|
||||
bool forceWideDialogs() const;
|
||||
void updateColumnLayout() const;
|
||||
bool canShowThirdSection() const;
|
||||
bool canShowThirdSectionWithoutResize() const;
|
||||
|
@ -516,24 +515,15 @@ public:
|
|||
std::optional<bool> show = std::nullopt) const;
|
||||
void finishChatThemeEdit(not_null<PeerData*> peer);
|
||||
|
||||
[[nodiscard]] bool dialogsListFocused() const {
|
||||
return _dialogsListFocused.current();
|
||||
[[nodiscard]] bool chatsForceDisplayWide() const {
|
||||
return _chatsForceDisplayWide.current();
|
||||
}
|
||||
[[nodiscard]] rpl::producer<bool> dialogsListFocusedChanges() const {
|
||||
return _dialogsListFocused.changes();
|
||||
}
|
||||
void setDialogsListFocused(bool value) {
|
||||
_dialogsListFocused = value;
|
||||
}
|
||||
[[nodiscard]] bool dialogsListDisplayForced() const {
|
||||
return _dialogsListDisplayForced.current();
|
||||
}
|
||||
[[nodiscard]] auto dialogsListDisplayForcedChanges() const
|
||||
[[nodiscard]] auto chatsForceDisplayWideChanges() const
|
||||
-> rpl::producer<bool> {
|
||||
return _dialogsListDisplayForced.changes();
|
||||
return _chatsForceDisplayWide.changes();
|
||||
}
|
||||
void setDialogsListDisplayForced(bool value) {
|
||||
_dialogsListDisplayForced = value;
|
||||
void setChatsForceDisplayWide(bool value) {
|
||||
_chatsForceDisplayWide = value;
|
||||
}
|
||||
|
||||
not_null<SessionController*> parentController() override {
|
||||
|
@ -688,8 +678,7 @@ private:
|
|||
rpl::variable<Dialogs::Key> _searchInChat;
|
||||
rpl::variable<Dialogs::RowDescriptor> _activeChatEntry;
|
||||
rpl::lifetime _activeHistoryLifetime;
|
||||
rpl::variable<bool> _dialogsListFocused = false;
|
||||
rpl::variable<bool> _dialogsListDisplayForced = false;
|
||||
rpl::variable<bool> _chatsForceDisplayWide = false;
|
||||
std::deque<Dialogs::RowDescriptor> _chatEntryHistory;
|
||||
int _chatEntryHistoryPosition = -1;
|
||||
bool _filtersActivated = false;
|
||||
|
|
Loading…
Add table
Reference in a new issue