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