mirror of
https://github.com/AyuGram/AyuGramDesktop.git
synced 2025-06-07 07:33:52 +02:00
Added ability to remove WebPage preview from scheduled messages section.
This commit is contained in:
parent
d98ac33425
commit
3c3ce24675
3 changed files with 71 additions and 49 deletions
|
@ -74,16 +74,19 @@ public:
|
||||||
bool isEditingMessage() const;
|
bool isEditingMessage() const;
|
||||||
rpl::producer<FullMsgId> editMsgId() const;
|
rpl::producer<FullMsgId> editMsgId() const;
|
||||||
MessageToEdit queryToEdit();
|
MessageToEdit queryToEdit();
|
||||||
|
WebPageId webPageId() const;
|
||||||
|
|
||||||
rpl::producer<bool> visibleChanged();
|
rpl::producer<bool> visibleChanged();
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
void paintEvent(QPaintEvent *e) override;
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void updateControlsGeometry(QSize size);
|
void updateControlsGeometry(QSize size);
|
||||||
void updateVisible();
|
void updateVisible();
|
||||||
|
|
||||||
|
void paintWebPage(Painter &p);
|
||||||
|
void paintEditMessage(Painter &p);
|
||||||
|
|
||||||
struct Preview {
|
struct Preview {
|
||||||
WebPageData *data = nullptr;
|
WebPageData *data = nullptr;
|
||||||
Ui::Text::String title;
|
Ui::Text::String title;
|
||||||
|
@ -121,6 +124,21 @@ void FieldHeader::init() {
|
||||||
updateControlsGeometry(size);
|
updateControlsGeometry(size);
|
||||||
}, lifetime());
|
}, lifetime());
|
||||||
|
|
||||||
|
paintRequest(
|
||||||
|
) | rpl::start_with_next([=] {
|
||||||
|
Painter p(this);
|
||||||
|
p.fillRect(rect(), st::historyComposeAreaBg);
|
||||||
|
|
||||||
|
if (isEditingMessage()) {
|
||||||
|
const auto position = st::historyReplyIconPosition;
|
||||||
|
st::historyEditIcon.paint(p, position, width());
|
||||||
|
}
|
||||||
|
|
||||||
|
ShowWebPagePreview(_preview.data)
|
||||||
|
? paintWebPage(p)
|
||||||
|
: paintEditMessage(p);
|
||||||
|
}, lifetime());
|
||||||
|
|
||||||
const auto checkPreview = [=](not_null<const HistoryItem*> item) {
|
const auto checkPreview = [=](not_null<const HistoryItem*> item) {
|
||||||
_preview = {};
|
_preview = {};
|
||||||
if (const auto media = item->media()) {
|
if (const auto media = item->media()) {
|
||||||
|
@ -152,6 +170,7 @@ void FieldHeader::init() {
|
||||||
} else {
|
} else {
|
||||||
_editMsgId = {};
|
_editMsgId = {};
|
||||||
}
|
}
|
||||||
|
updateVisible();
|
||||||
});
|
});
|
||||||
|
|
||||||
_title.value(
|
_title.value(
|
||||||
|
@ -198,17 +217,9 @@ void FieldHeader::previewRequested(
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void FieldHeader::paintEvent(QPaintEvent *e) {
|
void FieldHeader::paintWebPage(Painter &p) {
|
||||||
Painter p(this);
|
Expects(ShowWebPagePreview(_preview.data));
|
||||||
|
|
||||||
const auto replySkip = st::historyReplySkip;
|
|
||||||
const auto drawWebPagePreview = ShowWebPagePreview(_preview.data);
|
|
||||||
|
|
||||||
p.fillRect(rect(), st::historyComposeAreaBg);
|
|
||||||
|
|
||||||
st::historyEditIcon.paint(p, st::historyReplyIconPosition, width());
|
|
||||||
|
|
||||||
if (drawWebPagePreview) {
|
|
||||||
const auto textTop = st::msgReplyPadding.top();
|
const auto textTop = st::msgReplyPadding.top();
|
||||||
auto previewLeft = st::historyReplySkip + st::webPageLeft;
|
auto previewLeft = st::historyReplySkip + st::webPageLeft;
|
||||||
p.fillRect(
|
p.fillRect(
|
||||||
|
@ -229,26 +240,28 @@ void FieldHeader::paintEvent(QPaintEvent *e) {
|
||||||
- st::msgReplyBarSize.width()
|
- st::msgReplyBarSize.width()
|
||||||
- st::msgReplyBarPos.x();
|
- st::msgReplyBarPos.x();
|
||||||
}
|
}
|
||||||
p.setPen(st::historyReplyNameFg);
|
|
||||||
const auto elidedWidth = width()
|
const auto elidedWidth = width()
|
||||||
- previewLeft
|
- previewLeft
|
||||||
- _cancel->width()
|
- _cancel->width()
|
||||||
- st::msgReplyPadding.right();
|
- st::msgReplyPadding.right();
|
||||||
|
|
||||||
|
p.setPen(st::historyReplyNameFg);
|
||||||
_preview.title.drawElided(
|
_preview.title.drawElided(
|
||||||
p,
|
p,
|
||||||
previewLeft,
|
previewLeft,
|
||||||
textTop,
|
textTop,
|
||||||
elidedWidth);
|
elidedWidth);
|
||||||
|
|
||||||
p.setPen(st::historyComposeAreaFg);
|
p.setPen(st::historyComposeAreaFg);
|
||||||
_preview.description.drawElided(
|
_preview.description.drawElided(
|
||||||
p,
|
p,
|
||||||
previewLeft,
|
previewLeft,
|
||||||
textTop + st::msgServiceNameFont->height,
|
textTop + st::msgServiceNameFont->height,
|
||||||
elidedWidth);
|
elidedWidth);
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void FieldHeader::paintEditMessage(Painter &p) {
|
||||||
|
const auto replySkip = st::historyReplySkip;
|
||||||
p.setPen(st::historyReplyNameFg);
|
p.setPen(st::historyReplyNameFg);
|
||||||
p.setFont(st::msgServiceNameFont);
|
p.setFont(st::msgServiceNameFont);
|
||||||
p.drawTextLeft(
|
p.drawTextLeft(
|
||||||
|
@ -288,6 +301,10 @@ bool FieldHeader::hasPreview() const {
|
||||||
return _preview.data != nullptr;
|
return _preview.data != nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
WebPageId FieldHeader::webPageId() const {
|
||||||
|
return hasPreview() ? _preview.data->id : CancelledWebPageId;
|
||||||
|
}
|
||||||
|
|
||||||
void FieldHeader::updateControlsGeometry(QSize size) {
|
void FieldHeader::updateControlsGeometry(QSize size) {
|
||||||
_cancel->moveToRight(0, 0);
|
_cancel->moveToRight(0, 0);
|
||||||
}
|
}
|
||||||
|
@ -933,4 +950,8 @@ void ComposeControls::initWebpageProcess() {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
WebPageId ComposeControls::webPageId() const {
|
||||||
|
return _header->webPageId();
|
||||||
|
}
|
||||||
|
|
||||||
} // namespace HistoryView
|
} // namespace HistoryView
|
||||||
|
|
|
@ -104,6 +104,7 @@ public:
|
||||||
void cancelEditMessage();
|
void cancelEditMessage();
|
||||||
|
|
||||||
[[nodiscard]] TextWithTags getTextWithAppliedMarkdown() const;
|
[[nodiscard]] TextWithTags getTextWithAppliedMarkdown() const;
|
||||||
|
[[nodiscard]] WebPageId webPageId() const;
|
||||||
void clear();
|
void clear();
|
||||||
void hidePanelsAnimated();
|
void hidePanelsAnimated();
|
||||||
|
|
||||||
|
|
|
@ -484,7 +484,7 @@ void ScheduledWidget::send() {
|
||||||
}
|
}
|
||||||
|
|
||||||
void ScheduledWidget::send(Api::SendOptions options) {
|
void ScheduledWidget::send(Api::SendOptions options) {
|
||||||
const auto webPageId = 0;/* _previewCancelled
|
const auto webPageId = _composeControls->webPageId();/* _previewCancelled
|
||||||
? CancelledWebPageId
|
? CancelledWebPageId
|
||||||
: ((_previewData && _previewData->pendingTill >= 0)
|
: ((_previewData && _previewData->pendingTill >= 0)
|
||||||
? _previewData->id
|
? _previewData->id
|
||||||
|
|
Loading…
Add table
Reference in a new issue