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