mirror of
https://github.com/AyuGram/AyuGramDesktop.git
synced 2025-06-06 23:24:01 +02:00
Removed Q_OBJECT from Dialogs::InnerWidget.
This commit is contained in:
parent
72ecc286dc
commit
c96b2081c4
4 changed files with 102 additions and 44 deletions
|
@ -124,7 +124,6 @@ InnerWidget::InnerWidget(
|
|||
, _cancelSearchFromUser(this, st::dialogsCancelSearchInPeer) {
|
||||
setAttribute(Qt::WA_OpaquePaintEvent, true);
|
||||
|
||||
_cancelSearchInChat->setClickedCallback([=] { cancelSearchInChat(); });
|
||||
_cancelSearchInChat->hide();
|
||||
_cancelSearchFromUser->hide();
|
||||
|
||||
|
@ -1432,7 +1431,7 @@ void InnerWidget::handleChatListEntryRefreshes() {
|
|||
&& (from != to)
|
||||
&& (entry->folder() == _openedFolder)
|
||||
&& (_state == WidgetState::Default)) {
|
||||
dialogMoved(from, to);
|
||||
_dialogMoved.fire({ from, to });
|
||||
}
|
||||
|
||||
if (event.existenceChanged) {
|
||||
|
@ -1786,7 +1785,7 @@ void InnerWidget::contextMenuEvent(QContextMenuEvent *e) {
|
|||
return _menu->addAction(text, std::move(callback), icon);
|
||||
});
|
||||
}
|
||||
connect(_menu.get(), &QObject::destroyed, [=] {
|
||||
QObject::connect(_menu.get(), &QObject::destroyed, [=] {
|
||||
if (_menuRow.key) {
|
||||
updateDialogRow(base::take(_menuRow));
|
||||
}
|
||||
|
@ -1804,7 +1803,7 @@ void InnerWidget::contextMenuEvent(QContextMenuEvent *e) {
|
|||
}
|
||||
}
|
||||
|
||||
void InnerWidget::onParentGeometryChanged() {
|
||||
void InnerWidget::parentGeometryChanged() {
|
||||
const auto globalPosition = QCursor::pos();
|
||||
if (rect().contains(mapFromGlobal(globalPosition))) {
|
||||
setMouseTracking(true);
|
||||
|
@ -1849,7 +1848,7 @@ void InnerWidget::applyFilterUpdate(QString newFilter, bool force) {
|
|||
clearMouseSelection(true);
|
||||
}
|
||||
if (_state != WidgetState::Default) {
|
||||
searchMessages();
|
||||
_searchMessages.fire({});
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1942,6 +1941,30 @@ rpl::producer<> InnerWidget::cancelSearchFromUserRequests() const {
|
|||
return _cancelSearchFromUser->clicks() | rpl::to_empty;
|
||||
}
|
||||
|
||||
rpl::producer<Ui::ScrollToRequest> InnerWidget::mustScrollTo() const {
|
||||
return _mustScrollTo.events();
|
||||
}
|
||||
|
||||
rpl::producer<Ui::ScrollToRequest> InnerWidget::dialogMoved() const {
|
||||
return _dialogMoved.events();
|
||||
}
|
||||
|
||||
rpl::producer<> InnerWidget::searchMessages() const {
|
||||
return _searchMessages.events();
|
||||
}
|
||||
|
||||
rpl::producer<> InnerWidget::cancelSearchInChatRequests() const {
|
||||
return _cancelSearchInChat->clicks() | rpl::to_empty;
|
||||
}
|
||||
|
||||
rpl::producer<QString> InnerWidget::completeHashtagRequests() const {
|
||||
return _completeHashtagRequests.events();
|
||||
}
|
||||
|
||||
rpl::producer<> InnerWidget::refreshHashtagsRequests() const {
|
||||
return _refreshHashtagsRequests.events();
|
||||
}
|
||||
|
||||
void InnerWidget::visibleTopBottomUpdated(
|
||||
int visibleTop,
|
||||
int visibleBottom) {
|
||||
|
@ -2194,7 +2217,7 @@ void InnerWidget::refresh(bool toTop) {
|
|||
resize(width(), h);
|
||||
if (toTop) {
|
||||
stopReorderPinned();
|
||||
mustScrollTo(0, 0);
|
||||
_mustScrollTo.fire({ 0, 0 });
|
||||
loadPeerPhotos();
|
||||
}
|
||||
_controller->dialogsListDisplayForced().set(
|
||||
|
@ -2419,7 +2442,7 @@ void InnerWidget::selectSkip(int32 direction) {
|
|||
const auto fromY = (_collapsedSelected >= 0)
|
||||
? (_collapsedSelected * st::dialogsImportantBarHeight)
|
||||
: (dialogsOffset() + _selected->pos() * st::dialogsRowHeight);
|
||||
mustScrollTo(fromY, fromY + st::dialogsRowHeight);
|
||||
_mustScrollTo.fire({ fromY, fromY + st::dialogsRowHeight });
|
||||
}
|
||||
} else if (_state == WidgetState::Filtered) {
|
||||
if (_hashtagResults.empty() && _filterResults.empty() && _peerSearchResults.empty() && _searchResults.empty()) {
|
||||
|
@ -2468,13 +2491,32 @@ void InnerWidget::selectSkip(int32 direction) {
|
|||
}
|
||||
}
|
||||
if (base::in_range(_hashtagSelected, 0, _hashtagResults.size())) {
|
||||
mustScrollTo(_hashtagSelected * st::mentionHeight, (_hashtagSelected + 1) * st::mentionHeight);
|
||||
_mustScrollTo.fire({
|
||||
_hashtagSelected * st::mentionHeight,
|
||||
(_hashtagSelected + 1) * st::mentionHeight,
|
||||
});
|
||||
} else if (base::in_range(_filteredSelected, 0, _filterResults.size())) {
|
||||
mustScrollTo(filteredOffset() + _filteredSelected * st::dialogsRowHeight, filteredOffset() + (_filteredSelected + 1) * st::dialogsRowHeight);
|
||||
_mustScrollTo.fire({
|
||||
filteredOffset() + _filteredSelected * st::dialogsRowHeight,
|
||||
filteredOffset()
|
||||
+ (_filteredSelected + 1) * st::dialogsRowHeight,
|
||||
});
|
||||
} else if (base::in_range(_peerSearchSelected, 0, _peerSearchResults.size())) {
|
||||
mustScrollTo(peerSearchOffset() + _peerSearchSelected * st::dialogsRowHeight + (_peerSearchSelected ? 0 : -st::searchedBarHeight), peerSearchOffset() + (_peerSearchSelected + 1) * st::dialogsRowHeight);
|
||||
_mustScrollTo.fire({
|
||||
peerSearchOffset()
|
||||
+ _peerSearchSelected * st::dialogsRowHeight
|
||||
+ (_peerSearchSelected ? 0 : -st::searchedBarHeight),
|
||||
peerSearchOffset()
|
||||
+ (_peerSearchSelected + 1) * st::dialogsRowHeight,
|
||||
});
|
||||
} else {
|
||||
mustScrollTo(searchedOffset() + _searchedSelected * st::dialogsRowHeight + (_searchedSelected ? 0 : -st::searchedBarHeight), searchedOffset() + (_searchedSelected + 1) * st::dialogsRowHeight);
|
||||
_mustScrollTo.fire({
|
||||
searchedOffset()
|
||||
+ _searchedSelected * st::dialogsRowHeight
|
||||
+ (_searchedSelected ? 0 : -st::searchedBarHeight),
|
||||
searchedOffset()
|
||||
+ (_searchedSelected + 1) * st::dialogsRowHeight,
|
||||
});
|
||||
}
|
||||
}
|
||||
update();
|
||||
|
@ -2503,7 +2545,7 @@ void InnerWidget::scrollToEntry(const RowDescriptor &entry) {
|
|||
}
|
||||
}
|
||||
if (fromY >= 0) {
|
||||
mustScrollTo(fromY, fromY + st::dialogsRowHeight);
|
||||
_mustScrollTo.fire({ fromY, fromY + st::dialogsRowHeight });
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -2537,7 +2579,7 @@ void InnerWidget::selectSkipPage(int32 pixels, int32 direction) {
|
|||
const auto fromY = (_collapsedSelected >= 0)
|
||||
? (_collapsedSelected * st::dialogsImportantBarHeight)
|
||||
: (dialogsOffset() + _selected->pos() * st::dialogsRowHeight);
|
||||
mustScrollTo(fromY, fromY + st::dialogsRowHeight);
|
||||
_mustScrollTo.fire({ fromY, fromY + st::dialogsRowHeight });
|
||||
}
|
||||
} else {
|
||||
return selectSkip(direction * toSkip);
|
||||
|
@ -2622,7 +2664,7 @@ void InnerWidget::switchToFilter(FilterId filterId) {
|
|||
filterId = 0;
|
||||
}
|
||||
if (_filterId == filterId) {
|
||||
mustScrollTo(0, 0);
|
||||
_mustScrollTo.fire({ 0, 0 });
|
||||
return;
|
||||
}
|
||||
if (_openedFolder) {
|
||||
|
@ -2655,11 +2697,11 @@ bool InnerWidget::chooseHashtag() {
|
|||
}
|
||||
cSetRecentSearchHashtags(recent);
|
||||
session().local().writeRecentHashtagsAndBots();
|
||||
refreshHashtags();
|
||||
_refreshHashtagsRequests.fire({});
|
||||
selectByMouse(QCursor::pos());
|
||||
} else {
|
||||
session().local().saveRecentSearchHashtags('#' + hashtag->tag);
|
||||
completeHashtag(hashtag->tag);
|
||||
_completeHashtagRequests.fire_copy(hashtag->tag);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
|
|
@ -27,6 +27,7 @@ namespace Ui {
|
|||
class IconButton;
|
||||
class PopupMenu;
|
||||
class FlatLabel;
|
||||
struct ScrollToRequest;
|
||||
} // namespace Ui
|
||||
|
||||
namespace Window {
|
||||
|
@ -65,7 +66,6 @@ enum class WidgetState {
|
|||
};
|
||||
|
||||
class InnerWidget final : public Ui::RpWidget {
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
InnerWidget(
|
||||
|
@ -127,22 +127,19 @@ public:
|
|||
[[nodiscard]] rpl::producer<> updated() const;
|
||||
|
||||
[[nodiscard]] rpl::producer<int> scrollByDeltaRequests() const;
|
||||
[[nodiscard]] rpl::producer<Ui::ScrollToRequest> mustScrollTo() const;
|
||||
[[nodiscard]] rpl::producer<Ui::ScrollToRequest> dialogMoved() const;
|
||||
[[nodiscard]] rpl::producer<> searchMessages() const;
|
||||
[[nodiscard]] rpl::producer<> cancelSearchInChatRequests() const;
|
||||
[[nodiscard]] rpl::producer<QString> completeHashtagRequests() const;
|
||||
[[nodiscard]] rpl::producer<> refreshHashtagsRequests() const;
|
||||
|
||||
[[nodiscard]] RowDescriptor resolveChatNext(RowDescriptor from = {}) const;
|
||||
[[nodiscard]] RowDescriptor resolveChatPrevious(RowDescriptor from = {}) const;
|
||||
|
||||
~InnerWidget();
|
||||
|
||||
public Q_SLOTS:
|
||||
void onParentGeometryChanged();
|
||||
|
||||
Q_SIGNALS:
|
||||
void mustScrollTo(int scrollToTop, int scrollToBottom);
|
||||
void dialogMoved(int movedFrom, int movedTo);
|
||||
void searchMessages();
|
||||
void cancelSearchInChat();
|
||||
void completeHashtag(QString tag);
|
||||
void refreshHashtags();
|
||||
void parentGeometryChanged();
|
||||
|
||||
protected:
|
||||
void visibleTopBottomUpdated(
|
||||
|
@ -419,6 +416,12 @@ private:
|
|||
rpl::event_stream<ChosenRow> _chosenRow;
|
||||
rpl::event_stream<> _updated;
|
||||
|
||||
rpl::event_stream<Ui::ScrollToRequest> _mustScrollTo;
|
||||
rpl::event_stream<Ui::ScrollToRequest> _dialogMoved;
|
||||
rpl::event_stream<> _searchMessages;
|
||||
rpl::event_stream<QString> _completeHashtagRequests;
|
||||
rpl::event_stream<> _refreshHashtagsRequests;
|
||||
|
||||
base::unique_qptr<Ui::PopupMenu> _menu;
|
||||
|
||||
};
|
||||
|
|
|
@ -216,16 +216,37 @@ Widget::Widget(
|
|||
}
|
||||
}, lifetime());
|
||||
|
||||
connect(_inner, &InnerWidget::mustScrollTo, [=](int top, int bottom) {
|
||||
_inner->mustScrollTo(
|
||||
) | rpl::start_with_next([=](const Ui::ScrollToRequest &data) {
|
||||
if (_scroll) {
|
||||
_scroll->scrollToY(top, bottom);
|
||||
_scroll->scrollToY(data.ymin, data.ymax);
|
||||
}
|
||||
});
|
||||
connect(_inner, SIGNAL(dialogMoved(int,int)), this, SLOT(onDialogMoved(int,int)));
|
||||
connect(_inner, SIGNAL(searchMessages()), this, SLOT(onNeedSearchMessages()));
|
||||
connect(_inner, SIGNAL(completeHashtag(QString)), this, SLOT(onCompleteHashtag(QString)));
|
||||
connect(_inner, SIGNAL(refreshHashtags()), this, SLOT(onFilterCursorMoved()));
|
||||
connect(_inner, SIGNAL(cancelSearchInChat()), this, SLOT(onCancelSearchInChat()));
|
||||
}, lifetime());
|
||||
_inner->dialogMoved(
|
||||
) | rpl::start_with_next([=](const Ui::ScrollToRequest &data) {
|
||||
const auto movedFrom = data.ymin;
|
||||
const auto movedTo = data.ymax;
|
||||
const auto st = int32(_scroll->scrollTop());
|
||||
if (st > movedTo && st < movedFrom) {
|
||||
_scroll->scrollToY(st + st::dialogsRowHeight);
|
||||
}
|
||||
}, lifetime());
|
||||
_inner->searchMessages(
|
||||
) | rpl::start_with_next([=] {
|
||||
onNeedSearchMessages();
|
||||
}, lifetime());
|
||||
_inner->cancelSearchInChatRequests(
|
||||
) | rpl::start_with_next([=] {
|
||||
onCancelSearchInChat();
|
||||
}, lifetime());
|
||||
_inner->completeHashtagRequests(
|
||||
) | rpl::start_with_next([=](const QString &tag) {
|
||||
onCompleteHashtag(tag);
|
||||
}, lifetime());
|
||||
_inner->refreshHashtagsRequests(
|
||||
) | rpl::start_with_next([=] {
|
||||
onFilterCursorMoved();
|
||||
}, lifetime());
|
||||
_inner->cancelSearchFromUserRequests(
|
||||
) | rpl::start_with_next([=] {
|
||||
setSearchInChat(_searchInChat, nullptr);
|
||||
|
@ -264,7 +285,7 @@ Widget::Widget(
|
|||
|
||||
_scroll->geometryChanged(
|
||||
) | rpl::start_with_next(crl::guard(_inner, [=] {
|
||||
_inner->onParentGeometryChanged();
|
||||
_inner->parentGeometryChanged();
|
||||
}), lifetime());
|
||||
_scroll->scrolls(
|
||||
) | rpl::start_with_next([=] {
|
||||
|
@ -1882,13 +1903,6 @@ void Widget::onCancelSearchInChat() {
|
|||
}
|
||||
}
|
||||
|
||||
void Widget::onDialogMoved(int movedFrom, int movedTo) {
|
||||
int32 st = _scroll->scrollTop();
|
||||
if (st > movedTo && st < movedFrom) {
|
||||
_scroll->scrollToY(st + st::dialogsRowHeight);
|
||||
}
|
||||
}
|
||||
|
||||
Widget::~Widget() {
|
||||
cancelSearchRequest();
|
||||
|
||||
|
|
|
@ -109,7 +109,6 @@ public Q_SLOTS:
|
|||
void onFilterCursorMoved(int from = -1, int to = -1);
|
||||
void onCompleteHashtag(QString tag);
|
||||
|
||||
void onDialogMoved(int movedFrom, int movedTo);
|
||||
bool onSearchMessages(bool searchCache = false);
|
||||
void onNeedSearchMessages();
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue