mirror of
https://github.com/AyuGram/AyuGramDesktop.git
synced 2025-06-05 06:33:57 +02:00
Toggle selection by comments button click.
This commit is contained in:
parent
467449ac13
commit
48821af475
9 changed files with 57 additions and 31 deletions
|
@ -1323,10 +1323,8 @@ void HistoryInner::mouseActionFinish(
|
||||||
&& inSelectionMode()
|
&& inSelectionMode()
|
||||||
&& button != Qt::RightButton) {
|
&& button != Qt::RightButton) {
|
||||||
if (const auto view = _mouseActionItem->mainView()) {
|
if (const auto view = _mouseActionItem->mainView()) {
|
||||||
if (const auto media = view->media()) {
|
if (view->toggleSelectionByHandlerClick(activated)) {
|
||||||
if (media->toggleSelectionByHandlerClick(activated)) {
|
activated = nullptr;
|
||||||
activated = nullptr;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1753,9 +1753,6 @@ void HistoryWidget::showHistory(
|
||||||
if (startBot) {
|
if (startBot) {
|
||||||
showAtMsgId = ShowAtTheEndMsgId;
|
showAtMsgId = ShowAtTheEndMsgId;
|
||||||
}
|
}
|
||||||
if (showAtMsgId != ShowForChooseMessagesMsgId) {
|
|
||||||
_chooseForReport = nullptr;
|
|
||||||
}
|
|
||||||
|
|
||||||
clearHighlightMessages();
|
clearHighlightMessages();
|
||||||
hideInfoTooltip(anim::type::instant);
|
hideInfoTooltip(anim::type::instant);
|
||||||
|
@ -1768,6 +1765,7 @@ void HistoryWidget::showHistory(
|
||||||
showAtMsgId = ShowAtTheEndMsgId;
|
showAtMsgId = ShowAtTheEndMsgId;
|
||||||
} else if (showAtMsgId == ShowForChooseMessagesMsgId) {
|
} else if (showAtMsgId == ShowForChooseMessagesMsgId) {
|
||||||
if (_chooseForReport) {
|
if (_chooseForReport) {
|
||||||
|
clearSelected();
|
||||||
_chooseForReport->active = true;
|
_chooseForReport->active = true;
|
||||||
_list->setChooseReportReason(_chooseForReport->reason);
|
_list->setChooseReportReason(_chooseForReport->reason);
|
||||||
updateControlsVisibility();
|
updateControlsVisibility();
|
||||||
|
@ -1776,7 +1774,6 @@ void HistoryWidget::showHistory(
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
_list->clearChooseReportReason();
|
|
||||||
if (!IsServerMsgId(showAtMsgId)
|
if (!IsServerMsgId(showAtMsgId)
|
||||||
&& !IsServerMsgId(-showAtMsgId)) {
|
&& !IsServerMsgId(-showAtMsgId)) {
|
||||||
// To end or to unread.
|
// To end or to unread.
|
||||||
|
@ -1939,14 +1936,16 @@ void HistoryWidget::showHistory(
|
||||||
}
|
}
|
||||||
_history->setFakeUnreadWhileOpened(true);
|
_history->setFakeUnreadWhileOpened(true);
|
||||||
|
|
||||||
refreshTopBarActiveChat();
|
if (_showAtMsgId == ShowForChooseMessagesMsgId) {
|
||||||
updateTopBarSelection();
|
_showAtMsgId = ShowAtUnreadMsgId;
|
||||||
if (showAtMsgId == ShowForChooseMessagesMsgId) {
|
|
||||||
showAtMsgId = ShowAtUnreadMsgId;
|
|
||||||
if (_chooseForReport) {
|
if (_chooseForReport) {
|
||||||
_chooseForReport->active = true;
|
_chooseForReport->active = true;
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
_chooseForReport = nullptr;
|
||||||
}
|
}
|
||||||
|
refreshTopBarActiveChat();
|
||||||
|
updateTopBarSelection();
|
||||||
|
|
||||||
if (_channel) {
|
if (_channel) {
|
||||||
updateNotifyControls();
|
updateNotifyControls();
|
||||||
|
@ -2034,6 +2033,7 @@ void HistoryWidget::showHistory(
|
||||||
unreadCountUpdated(); // set _historyDown badge.
|
unreadCountUpdated(); // set _historyDown badge.
|
||||||
showAboutTopPromotion();
|
showAboutTopPromotion();
|
||||||
} else {
|
} else {
|
||||||
|
_chooseForReport = nullptr;
|
||||||
refreshTopBarActiveChat();
|
refreshTopBarActiveChat();
|
||||||
updateTopBarSelection();
|
updateTopBarSelection();
|
||||||
checkMessagesTTL();
|
checkMessagesTTL();
|
||||||
|
@ -3325,9 +3325,13 @@ void HistoryWidget::reportSelectedMessages() {
|
||||||
const auto peer = _peer;
|
const auto peer = _peer;
|
||||||
const auto reason = _chooseForReport->reason;
|
const auto reason = _chooseForReport->reason;
|
||||||
const auto box = std::make_shared<QPointer<Ui::GenericBox>>();
|
const auto box = std::make_shared<QPointer<Ui::GenericBox>>();
|
||||||
|
const auto weak = Ui::MakeWeak(_list.data());
|
||||||
const auto send = [=](const QString &text) {
|
const auto send = [=](const QString &text) {
|
||||||
|
if (weak) {
|
||||||
|
clearSelected();
|
||||||
|
controller()->clearChooseReportMessages();
|
||||||
|
}
|
||||||
HistoryView::SendReport(peer, reason, text, ids);
|
HistoryView::SendReport(peer, reason, text, ids);
|
||||||
controller()->clearChooseReportMessages();
|
|
||||||
if (*box) {
|
if (*box) {
|
||||||
(*box)->closeBox();
|
(*box)->closeBox();
|
||||||
}
|
}
|
||||||
|
@ -5514,6 +5518,7 @@ void HistoryWidget::setChooseReportMessagesDetails(
|
||||||
_list->clearChooseReportReason();
|
_list->clearChooseReportReason();
|
||||||
}
|
}
|
||||||
if (refresh) {
|
if (refresh) {
|
||||||
|
clearSelected();
|
||||||
updateControlsVisibility();
|
updateControlsVisibility();
|
||||||
updateControlsGeometry();
|
updateControlsGeometry();
|
||||||
updateTopBarChooseForReport();
|
updateTopBarChooseForReport();
|
||||||
|
@ -6260,7 +6265,9 @@ void HistoryWidget::confirmDeleteSelected() {
|
||||||
}
|
}
|
||||||
|
|
||||||
void HistoryWidget::escape() {
|
void HistoryWidget::escape() {
|
||||||
if (_nonEmptySelection && _list) {
|
if (_chooseForReport) {
|
||||||
|
controller()->clearChooseReportMessages();
|
||||||
|
} else if (_nonEmptySelection && _list) {
|
||||||
clearSelected();
|
clearSelected();
|
||||||
} else if (_isInlineBot) {
|
} else if (_isInlineBot) {
|
||||||
cancelInlineBot();
|
cancelInlineBot();
|
||||||
|
|
|
@ -736,6 +736,11 @@ HistoryMessageReply *Element::displayedReply() const {
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool Element::toggleSelectionByHandlerClick(
|
||||||
|
const ClickHandlerPtr &handler) const {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
bool Element::hasVisibleText() const {
|
bool Element::hasVisibleText() const {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
|
@ -292,6 +292,8 @@ public:
|
||||||
virtual void applyGroupAdminChanges(
|
virtual void applyGroupAdminChanges(
|
||||||
const base::flat_set<UserId> &changes) {
|
const base::flat_set<UserId> &changes) {
|
||||||
}
|
}
|
||||||
|
[[nodiscard]] virtual bool toggleSelectionByHandlerClick(
|
||||||
|
const ClickHandlerPtr &handler) const;
|
||||||
|
|
||||||
struct VerticalRepaintRange {
|
struct VerticalRepaintRange {
|
||||||
int top = 0;
|
int top = 0;
|
||||||
|
|
|
@ -2184,16 +2184,10 @@ void ListWidget::mouseActionFinish(
|
||||||
repaintItem(pressState.itemId);
|
repaintItem(pressState.itemId);
|
||||||
|
|
||||||
const auto toggleByHandler = [&](const ClickHandlerPtr &handler) {
|
const auto toggleByHandler = [&](const ClickHandlerPtr &handler) {
|
||||||
if (_overElement) {
|
// If we are in selecting items mode perhaps we want to
|
||||||
// If we are in selecting items mode perhaps we want to
|
// toggle selection instead of activating the pressed link.
|
||||||
// toggle selection instead of activating the pressed link.
|
return _overElement
|
||||||
if (const auto media = _overElement->media()) {
|
&& _overElement->toggleSelectionByHandlerClick(handler);
|
||||||
if (media->toggleSelectionByHandlerClick(handler)) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
auto activated = ClickHandler::unpressed();
|
auto activated = ClickHandler::unpressed();
|
||||||
|
|
|
@ -2059,6 +2059,18 @@ HistoryMessageReply *Message::displayedReply() const {
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool Message::toggleSelectionByHandlerClick(
|
||||||
|
const ClickHandlerPtr &handler) const {
|
||||||
|
if (_comments && _comments->link == handler) {
|
||||||
|
return true;
|
||||||
|
} else if (const auto media = this->media()) {
|
||||||
|
if (media->toggleSelectionByHandlerClick(handler)) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
bool Message::displayPinIcon() const {
|
bool Message::displayPinIcon() const {
|
||||||
return data()->isPinned() && !isPinnedContext();
|
return data()->isPinned() && !isPinnedContext();
|
||||||
}
|
}
|
||||||
|
|
|
@ -105,6 +105,8 @@ public:
|
||||||
bool displayEditedBadge() const override;
|
bool displayEditedBadge() const override;
|
||||||
TimeId displayedEditDate() const override;
|
TimeId displayedEditDate() const override;
|
||||||
HistoryMessageReply *displayedReply() const override;
|
HistoryMessageReply *displayedReply() const override;
|
||||||
|
bool toggleSelectionByHandlerClick(
|
||||||
|
const ClickHandlerPtr &handler) const override;
|
||||||
int infoWidth() const override;
|
int infoWidth() const override;
|
||||||
|
|
||||||
VerticalRepaintRange verticalRepaintRange() const override;
|
VerticalRepaintRange verticalRepaintRange() const override;
|
||||||
|
|
|
@ -1419,7 +1419,10 @@ void MainWidget::showChooseReportMessages(
|
||||||
Ui::ReportReason reason,
|
Ui::ReportReason reason,
|
||||||
Fn<void(MessageIdsList)> done) {
|
Fn<void(MessageIdsList)> done) {
|
||||||
_history->setChooseReportMessagesDetails(reason, std::move(done));
|
_history->setChooseReportMessagesDetails(reason, std::move(done));
|
||||||
ui_showPeerHistory(peer->id, SectionShow(), ShowForChooseMessagesMsgId);
|
ui_showPeerHistory(
|
||||||
|
peer->id,
|
||||||
|
SectionShow::Way::Forward,
|
||||||
|
ShowForChooseMessagesMsgId);
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainWidget::clearChooseReportMessages() {
|
void MainWidget::clearChooseReportMessages() {
|
||||||
|
|
|
@ -42,7 +42,7 @@ void ReportReasonBox(
|
||||||
const auto add = [&](Reason reason, tr::phrase<> text) {
|
const auto add = [&](Reason reason, tr::phrase<> text) {
|
||||||
const auto layout = box->verticalLayout();
|
const auto layout = box->verticalLayout();
|
||||||
const auto button = layout->add(
|
const auto button = layout->add(
|
||||||
object_ptr<Ui::SettingsButton>(layout, text()));
|
object_ptr<SettingsButton>(layout, text()));
|
||||||
button->setClickedCallback([=] {
|
button->setClickedCallback([=] {
|
||||||
done(reason);
|
done(reason);
|
||||||
});
|
});
|
||||||
|
@ -63,7 +63,7 @@ void ReportDetailsBox(
|
||||||
not_null<GenericBox*> box,
|
not_null<GenericBox*> box,
|
||||||
Fn<void(QString)> done) {
|
Fn<void(QString)> done) {
|
||||||
box->addRow(
|
box->addRow(
|
||||||
object_ptr<Ui::FlatLabel>(
|
object_ptr<FlatLabel>(
|
||||||
box, // #TODO reports
|
box, // #TODO reports
|
||||||
tr::lng_report_details_about(),
|
tr::lng_report_details_about(),
|
||||||
st::boxLabel),
|
st::boxLabel),
|
||||||
|
@ -73,20 +73,23 @@ void ReportDetailsBox(
|
||||||
st::boxRowPadding.right(),
|
st::boxRowPadding.right(),
|
||||||
st::boxPadding.bottom() });
|
st::boxPadding.bottom() });
|
||||||
const auto details = box->addRow(
|
const auto details = box->addRow(
|
||||||
object_ptr<Ui::InputField>(
|
object_ptr<InputField>(
|
||||||
box,
|
box,
|
||||||
st::newGroupDescription,
|
st::newGroupDescription,
|
||||||
Ui::InputField::Mode::MultiLine,
|
InputField::Mode::MultiLine,
|
||||||
tr::lng_report_details(),
|
tr::lng_report_details(),
|
||||||
QString()));
|
QString()));
|
||||||
details->setMaxLength(kReportReasonLengthMax);
|
details->setMaxLength(kReportReasonLengthMax);
|
||||||
box->setFocusCallback([=] {
|
box->setFocusCallback([=] {
|
||||||
details->setFocusFast();
|
details->setFocusFast();
|
||||||
});
|
});
|
||||||
box->addButton(tr::lng_report_button(), [=] {
|
|
||||||
|
const auto submit = [=] {
|
||||||
const auto text = details->getLastText();
|
const auto text = details->getLastText();
|
||||||
done(text);
|
done(text);
|
||||||
});
|
};
|
||||||
|
QObject::connect(details, &InputField::submitted, submit);
|
||||||
|
box->addButton(tr::lng_report_button(), submit);
|
||||||
box->addButton(tr::lng_cancel(), [=] { box->closeBox(); });
|
box->addButton(tr::lng_cancel(), [=] { box->closeBox(); });
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue