mirror of
https://github.com/AyuGram/AyuGramDesktop.git
synced 2025-04-16 06:07:06 +02:00
Allow adding media to text with a link preview.
This commit is contained in:
parent
f2ed649694
commit
475dec3014
6 changed files with 4 additions and 175 deletions
|
@ -254,7 +254,7 @@ EditCaptionBox::EditCaptionBox(
|
|||
, _initialList(std::move(list))
|
||||
, _saved(std::move(saved)) {
|
||||
Expects(!_initialList.files.empty());
|
||||
Expects(!item->media() || item->media()->allowsEditCaption());
|
||||
Expects(item->allowsEditMedia());
|
||||
|
||||
_mediaEditManager.start(item, spoilered, invertCaption);
|
||||
|
||||
|
|
|
@ -2244,7 +2244,7 @@ bool HistoryItem::allowsEdit(TimeId now) const {
|
|||
|
||||
bool HistoryItem::allowsEditMedia() const {
|
||||
return !awaitingVideoProcessing()
|
||||
&& (!_media || _media->allowsEditMedia());
|
||||
&& (!_media || _media->allowsEditMedia() || _media->webpage());
|
||||
}
|
||||
|
||||
bool HistoryItem::canBeEdited() const {
|
||||
|
|
|
@ -8555,7 +8555,7 @@ void HistoryWidget::updateReplyEditTexts(bool force) {
|
|||
_mediaEditManager.start(_replyEditMsg);
|
||||
}
|
||||
_canReplaceMedia = _editMsgId && _replyEditMsg->allowsEditMedia();
|
||||
if (editMedia) {
|
||||
if (editMedia && editMedia->allowsEditMedia()) {
|
||||
_canAddMedia = false;
|
||||
} else {
|
||||
_canAddMedia = base::take(_canReplaceMedia);
|
||||
|
|
|
@ -1960,7 +1960,7 @@ void ComposeControls::applyDraft(FieldHistoryAction fieldHistoryAction) {
|
|||
if (const auto item = _history->owner().message(editingId)) {
|
||||
const auto media = item->media();
|
||||
_canReplaceMedia = item->allowsEditMedia();
|
||||
if (media) {
|
||||
if (media && media->allowsEditMedia()) {
|
||||
_canAddMedia = false;
|
||||
} else {
|
||||
_canAddMedia = base::take(_canReplaceMedia);
|
||||
|
|
|
@ -1,97 +0,0 @@
|
|||
/*
|
||||
This file is part of Telegram Desktop,
|
||||
the official desktop application for the Telegram messaging service.
|
||||
|
||||
For license and copyright information please follow this link:
|
||||
https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||
*/
|
||||
#include "info/channels/info_channels_widget.h"
|
||||
|
||||
#include "info/feed/info_feed_channels.h"
|
||||
#include "info/info_controller.h"
|
||||
#include "ui/widgets/scroll_area.h"
|
||||
#include "styles/style_info.h"
|
||||
|
||||
namespace Info {
|
||||
namespace Channels {
|
||||
|
||||
Memento::Memento(not_null<Controller*> controller)
|
||||
: Memento(controller->feed()) {
|
||||
}
|
||||
|
||||
Memento::Memento(not_null<Data::Feed*> feed)
|
||||
: ContentMemento(feed) {
|
||||
}
|
||||
|
||||
Section Memento::section() const {
|
||||
return Section(Section::Type::Channels);
|
||||
}
|
||||
|
||||
object_ptr<ContentWidget> Memento::createWidget(
|
||||
QWidget *parent,
|
||||
not_null<Controller*> controller,
|
||||
const QRect &geometry) {
|
||||
auto result = object_ptr<Widget>(
|
||||
parent,
|
||||
controller);
|
||||
result->setInternalState(geometry, this);
|
||||
return result;
|
||||
}
|
||||
|
||||
void Memento::setState(std::unique_ptr<SavedState> state) {
|
||||
_state = std::move(state);
|
||||
}
|
||||
|
||||
std::unique_ptr<SavedState> Memento::state() {
|
||||
return std::move(_state);
|
||||
}
|
||||
|
||||
Memento::~Memento() = default;
|
||||
|
||||
Widget::Widget(
|
||||
QWidget *parent,
|
||||
not_null<Controller*> controller)
|
||||
: ContentWidget(parent, controller) {
|
||||
_inner = setInnerWidget(object_ptr<FeedProfile::Channels>(
|
||||
this,
|
||||
controller));
|
||||
}
|
||||
|
||||
bool Widget::showInternal(not_null<ContentMemento*> memento) {
|
||||
if (!controller()->validateMementoPeer(memento)) {
|
||||
return false;
|
||||
}
|
||||
if (auto membersMemento = dynamic_cast<Memento*>(memento.get())) {
|
||||
restoreState(membersMemento);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
void Widget::setInternalState(
|
||||
const QRect &geometry,
|
||||
not_null<Memento*> memento) {
|
||||
setGeometry(geometry);
|
||||
Ui::SendPendingMoveResizeEvents(this);
|
||||
restoreState(memento);
|
||||
}
|
||||
|
||||
std::unique_ptr<ContentMemento> Widget::doCreateMemento() {
|
||||
auto result = std::make_unique<Memento>(controller());
|
||||
saveState(result.get());
|
||||
return result;
|
||||
}
|
||||
|
||||
void Widget::saveState(not_null<Memento*> memento) {
|
||||
memento->setScrollTop(scrollTopSave());
|
||||
memento->setState(_inner->saveState());
|
||||
}
|
||||
|
||||
void Widget::restoreState(not_null<Memento*> memento) {
|
||||
_inner->restoreState(memento->state());
|
||||
auto scrollTop = memento->scrollTop();
|
||||
scrollTopRestore(memento->scrollTop());
|
||||
}
|
||||
|
||||
} // namespace Channels
|
||||
} // namespace Info
|
|
@ -1,74 +0,0 @@
|
|||
/*
|
||||
This file is part of Telegram Desktop,
|
||||
the official desktop application for the Telegram messaging service.
|
||||
|
||||
For license and copyright information please follow this link:
|
||||
https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||
*/
|
||||
#pragma once
|
||||
|
||||
#include "info/info_content_widget.h"
|
||||
|
||||
struct PeerListState;
|
||||
|
||||
namespace Data {
|
||||
class Feed;
|
||||
} // namespace Data
|
||||
|
||||
namespace Info {
|
||||
namespace FeedProfile {
|
||||
class Channels;
|
||||
struct ChannelsState;
|
||||
} // namespace FeedProfile
|
||||
|
||||
namespace Channels {
|
||||
|
||||
using SavedState = FeedProfile::ChannelsState;
|
||||
|
||||
class Memento final : public ContentMemento {
|
||||
public:
|
||||
explicit Memento(not_null<Controller*> controller);
|
||||
explicit Memento(not_null<Data::Feed*> feed);
|
||||
|
||||
object_ptr<ContentWidget> createWidget(
|
||||
QWidget *parent,
|
||||
not_null<Controller*> controller,
|
||||
const QRect &geometry) override;
|
||||
|
||||
Section section() const override;
|
||||
|
||||
void setState(std::unique_ptr<SavedState> state);
|
||||
std::unique_ptr<SavedState> state();
|
||||
|
||||
~Memento();
|
||||
|
||||
private:
|
||||
std::unique_ptr<SavedState> _state;
|
||||
|
||||
};
|
||||
|
||||
class Widget final : public ContentWidget {
|
||||
public:
|
||||
Widget(
|
||||
QWidget *parent,
|
||||
not_null<Controller*> controller);
|
||||
|
||||
bool showInternal(
|
||||
not_null<ContentMemento*> memento) override;
|
||||
|
||||
void setInternalState(
|
||||
const QRect &geometry,
|
||||
not_null<Memento*> memento);
|
||||
|
||||
private:
|
||||
void saveState(not_null<Memento*> memento);
|
||||
void restoreState(not_null<Memento*> memento);
|
||||
|
||||
std::unique_ptr<ContentMemento> doCreateMemento() override;
|
||||
|
||||
FeedProfile::Channels *_inner = nullptr;
|
||||
|
||||
};
|
||||
|
||||
} // namespace Channels
|
||||
} // namespace Info
|
Loading…
Add table
Reference in a new issue