mirror of
https://github.com/AyuGram/AyuGramDesktop.git
synced 2025-06-07 23:53:58 +02:00
Support creating polls in RepliesSection.
This commit is contained in:
parent
a8564b166b
commit
10adbecb9c
7 changed files with 28 additions and 9 deletions
|
@ -1398,6 +1398,11 @@ bool RepliesWidget::replyToMessage(not_null<HistoryItem*> item) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
MsgId RepliesWidget::currentReplyToIdFor(
|
||||||
|
not_null<History*> history) const {
|
||||||
|
return (_history == history) ? replyToId() : 0;
|
||||||
|
}
|
||||||
|
|
||||||
void RepliesWidget::saveState(not_null<RepliesMemento*> memento) {
|
void RepliesWidget::saveState(not_null<RepliesMemento*> memento) {
|
||||||
memento->setReplies(_replies);
|
memento->setReplies(_replies);
|
||||||
memento->setReplyReturns(_replyReturns);
|
memento->setReplyReturns(_replyReturns);
|
||||||
|
|
|
@ -88,6 +88,8 @@ public:
|
||||||
const Window::SectionShow ¶ms,
|
const Window::SectionShow ¶ms,
|
||||||
MsgId messageId) override;
|
MsgId messageId) override;
|
||||||
bool replyToMessage(not_null<HistoryItem*> item) override;
|
bool replyToMessage(not_null<HistoryItem*> item) override;
|
||||||
|
MsgId currentReplyToIdFor(
|
||||||
|
not_null<History*> history) const override;
|
||||||
|
|
||||||
void setInternalState(
|
void setInternalState(
|
||||||
const QRect &geometry,
|
const QRect &geometry,
|
||||||
|
|
|
@ -238,9 +238,11 @@ void TopBarWidget::showMenu() {
|
||||||
peer,
|
peer,
|
||||||
FilterId(),
|
FilterId(),
|
||||||
addAction,
|
addAction,
|
||||||
(_section == Section::Scheduled)
|
(_section == Section::Scheduled
|
||||||
? Window::PeerMenuSource::ScheduledSection
|
? Window::PeerMenuSource::ScheduledSection
|
||||||
: Window::PeerMenuSource::History);
|
: (_section == Section::Replies)
|
||||||
|
? Window::PeerMenuSource::RepliesSection
|
||||||
|
: Window::PeerMenuSource::History));
|
||||||
} else if (const auto folder = _activeChat.folder()) {
|
} else if (const auto folder = _activeChat.folder()) {
|
||||||
Window::FillFolderMenu(
|
Window::FillFolderMenu(
|
||||||
_controller,
|
_controller,
|
||||||
|
@ -686,12 +688,14 @@ void TopBarWidget::updateControlsVisibility() {
|
||||||
_unreadBadge->show();
|
_unreadBadge->show();
|
||||||
}
|
}
|
||||||
const auto historyMode = (_section == Section::History);
|
const auto historyMode = (_section == Section::History);
|
||||||
const auto scheduledMode = (_section == Section::Scheduled);
|
const auto hasPollsMenu = _activeChat.peer()
|
||||||
const auto showInScheduledMode = (_activeChat.peer()
|
&& _activeChat.peer()->canSendPolls();
|
||||||
&& _activeChat.peer()->canSendPolls());
|
const auto hasMenu = !_activeChat.folder()
|
||||||
|
&& ((_section == Section::Scheduled || _section == Section::Replies)
|
||||||
|
? hasPollsMenu
|
||||||
|
: historyMode);
|
||||||
updateSearchVisibility();
|
updateSearchVisibility();
|
||||||
_menuToggle->setVisible(!_activeChat.folder()
|
_menuToggle->setVisible(hasMenu);
|
||||||
&& (scheduledMode ? showInScheduledMode : historyMode));
|
|
||||||
_infoToggle->setVisible(historyMode
|
_infoToggle->setVisible(historyMode
|
||||||
&& !_activeChat.folder()
|
&& !_activeChat.folder()
|
||||||
&& !Adaptive::OneColumn()
|
&& !Adaptive::OneColumn()
|
||||||
|
|
|
@ -820,7 +820,9 @@ crl::time MainWidget::highlightStartTime(not_null<const HistoryItem*> item) cons
|
||||||
}
|
}
|
||||||
|
|
||||||
MsgId MainWidget::currentReplyToIdFor(not_null<History*> history) const {
|
MsgId MainWidget::currentReplyToIdFor(not_null<History*> history) const {
|
||||||
if (_history->history() == history) {
|
if (_mainSection) {
|
||||||
|
return _mainSection->currentReplyToIdFor(history);
|
||||||
|
} else if (_history->history() == history) {
|
||||||
return _history->replyToId();
|
return _history->replyToId();
|
||||||
} else if (const auto localDraft = history->localDraft()) {
|
} else if (const auto localDraft = history->localDraft()) {
|
||||||
return localDraft->msgId;
|
return localDraft->msgId;
|
||||||
|
|
|
@ -128,6 +128,10 @@ public:
|
||||||
virtual bool replyToMessage(not_null<HistoryItem*> item) {
|
virtual bool replyToMessage(not_null<HistoryItem*> item) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
[[nodiscard]] virtual MsgId currentReplyToIdFor(
|
||||||
|
not_null<History*> history) const {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
// Create a memento of that section to store it in the history stack.
|
// Create a memento of that section to store it in the history stack.
|
||||||
// This method may modify the section ("take" heavy items).
|
// This method may modify the section ("take" heavy items).
|
||||||
|
|
|
@ -650,7 +650,8 @@ void Filler::addPollAction(not_null<PeerData*> peer) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void Filler::fill() {
|
void Filler::fill() {
|
||||||
if (_source == PeerMenuSource::ScheduledSection) {
|
if (_source == PeerMenuSource::ScheduledSection
|
||||||
|
|| _source == PeerMenuSource::RepliesSection) {
|
||||||
addPollAction(_peer);
|
addPollAction(_peer);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
|
@ -37,6 +37,7 @@ enum class PeerMenuSource {
|
||||||
History,
|
History,
|
||||||
Profile,
|
Profile,
|
||||||
ScheduledSection,
|
ScheduledSection,
|
||||||
|
RepliesSection,
|
||||||
};
|
};
|
||||||
|
|
||||||
using PeerMenuCallback = Fn<QAction*(
|
using PeerMenuCallback = Fn<QAction*(
|
||||||
|
|
Loading…
Add table
Reference in a new issue