Removed Replace button from attach previews and added More button.

This commit is contained in:
23rd
2026-03-15 16:43:26 +03:00
parent d9b9a40119
commit 4ba2581df8
13 changed files with 314 additions and 152 deletions
@@ -0,0 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<svg width="24px" height="24px" viewBox="0 0 24 24" version="1.1" xmlns="http://www.w3.org/2000/svg">
<title>Icon / SendMedia / cross</title>
<g stroke="none" stroke-width="1" fill="none" fill-rule="evenodd">
<path d="M8.2,7.2 L7.2,8.2 L10.99,12 L7.2,15.8 L8.2,16.8 L12,13.01 L15.8,16.8 L16.8,15.8 L13.01,12 L16.8,8.2 L15.8,7.2 L12,10.99 L8.2,7.2 Z" fill="#FFFFFF"></path>
</g>
</svg>

After

Width:  |  Height:  |  Size: 444 B

@@ -0,0 +1,9 @@
<?xml version="1.0" encoding="UTF-8"?>
<svg width="24px" height="24px" viewBox="0 0 24 24" version="1.1" xmlns="http://www.w3.org/2000/svg">
<title>Icon / SendMedia / more_vertical</title>
<g stroke="none" stroke-width="1" fill="none" fill-rule="evenodd">
<circle fill="#FFFFFF" cx="12" cy="6.5" r="1.5"></circle>
<circle fill="#FFFFFF" cx="12" cy="12" r="1.5"></circle>
<circle fill="#FFFFFF" cx="12" cy="17.5" r="1.5"></circle>
</g>
</svg>

After

Width:  |  Height:  |  Size: 478 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 407 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 772 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1018 B

+1
View File
@@ -4949,6 +4949,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
"lng_context_quote_and_reply" = "Quote & Reply"; "lng_context_quote_and_reply" = "Quote & Reply";
"lng_context_reply_to_task" = "Reply to Task"; "lng_context_reply_to_task" = "Reply to Task";
"lng_context_edit_msg" = "Edit"; "lng_context_edit_msg" = "Edit";
"lng_context_draw" = "Draw";
"lng_context_add_factcheck" = "Add Fact Check"; "lng_context_add_factcheck" = "Add Fact Check";
"lng_context_edit_factcheck" = "Edit Fact Check"; "lng_context_edit_factcheck" = "Edit Fact Check";
"lng_context_add_offer" = "Add Offer"; "lng_context_add_offer" = "Add Offer";
@@ -57,6 +57,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include "ui/ui_utility.h" #include "ui/ui_utility.h"
#include "ui/widgets/checkbox.h" #include "ui/widgets/checkbox.h"
#include "ui/widgets/fields/input_field.h" #include "ui/widgets/fields/input_field.h"
#include "ui/widgets/popup_menu.h"
#include "ui/widgets/scroll_area.h" #include "ui/widgets/scroll_area.h"
#include "ui/wrap/slide_wrap.h" #include "ui/wrap/slide_wrap.h"
#include "ui/wrap/vertical_layout.h" #include "ui/wrap/vertical_layout.h"
@@ -65,6 +66,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include "styles/style_chat.h" #include "styles/style_chat.h"
#include "styles/style_chat_helpers.h" #include "styles/style_chat_helpers.h"
#include "styles/style_layers.h" #include "styles/style_layers.h"
#include "styles/style_menu_icons.h"
#include <QtCore/QMimeData> #include <QtCore/QMimeData>
@@ -711,12 +713,70 @@ void EditCaptionBox::setupControls() {
} }
void EditCaptionBox::setupEditEventHandler() { void EditCaptionBox::setupEditEventHandler() {
const auto menu
= lifetime().make_state<base::unique_qptr<Ui::PopupMenu>>();
_editMediaClicks.events( _editMediaClicks.events(
) | rpl::on_next([=] { ) | rpl::on_next([=] {
ChooseReplacement(_controller, _albumType, crl::guard(this, [=]( *menu = base::make_unique_q<Ui::PopupMenu>(
Ui::PreparedList &&list) { this,
setPreparedList(std::move(list)); st::popupMenuWithIcons);
})); (*menu)->setForcedOrigin(Ui::PanelAnimation::Origin::TopRight);
if (_isAllowedEditMedia) {
(*menu)->addAction(tr::lng_attach_replace(tr::now), [=] {
ChooseReplacement(
_controller,
_albumType,
crl::guard(this, [=](Ui::PreparedList &&list) {
setPreparedList(std::move(list));
}));
}, &st::menuIconReplace);
}
using Type = Ui::PreparedFile::Type;
const auto canDraw = !_preparedList.files.empty()
? (_preparedList.files.front().type == Type::Photo)
: (_isPhoto && !_asFile);
if (canDraw) {
(*menu)->addAction(tr::lng_context_draw(tr::now), [=] {
_photoEditorOpens.fire({});
}, &st::menuIconDraw);
}
if (!_asFile && (_isPhoto || _isVideo)) {
if (_preparedList.hasSpoilerMenu(!_asFile)) {
const auto spoilered = hasSpoiler();
auto text = spoilered
? tr::lng_context_disable_spoiler(tr::now)
: tr::lng_context_spoiler_effect(tr::now);
auto callback = [=] {
_mediaEditManager.apply({ .type = spoilered
? SendMenu::ActionType::SpoilerOff
: SendMenu::ActionType::SpoilerOn
});
rebuildPreview();
};
(*menu)->addAction(
std::move(text),
std::move(callback),
spoilered
? &st::menuIconSpoilerOff
: &st::menuIconSpoiler);
}
if (_isVideo && !_preparedList.files.empty()) {
(*menu)->addAction(tr::lng_context_edit_cover(tr::now), [=] {
setupEditCoverHandler();
}, &st::menuIconEdit);
if (_preparedList.files.front().videoCover != nullptr) {
(*menu)->addAction(
tr::lng_context_clear_cover(tr::now),
[=] { setupClearCoverHandler(); },
&st::menuIconCancel);
}
}
}
if ((*menu)->empty()) {
*menu = nullptr;
} else {
(*menu)->popup(QCursor::pos());
}
}, lifetime()); }, lifetime());
} }
+186 -118
View File
@@ -1084,6 +1084,7 @@ void SendFilesBox::addMenuButton() {
top->setClickedCallback([=] { top->setClickedCallback([=] {
const auto &tabbed = _st.tabbed; const auto &tabbed = _st.tabbed;
_menu = base::make_unique_q<Ui::PopupMenu>(top, tabbed.menu); _menu = base::make_unique_q<Ui::PopupMenu>(top, tabbed.menu);
_menu->setForcedOrigin(Ui::PanelAnimation::Origin::TopRight);
const auto position = QCursor::pos(); const auto position = QCursor::pos();
SendMenu::FillSendMenu( SendMenu::FillSendMenu(
_menu.get(), _menu.get(),
@@ -1226,41 +1227,31 @@ void SendFilesBox::pushBlock(int from, int till) {
const auto widget = _inner->add( const auto widget = _inner->add(
block.takeWidget(), block.takeWidget(),
QMargins(0, _inner->count() ? st::sendMediaRowSkip : 0, 0, 0)); QMargins(0, _inner->count() ? st::sendMediaRowSkip : 0, 0, 0));
struct State {
block.itemDeleteRequest( base::unique_qptr<Ui::PopupMenu> menu;
) | rpl::filter([=] { };
return !_removingIndex; const auto state = widget->lifetime().make_state<State>();
}) | rpl::on_next([=](int index) { const auto openedOnce = widget->lifetime().make_state<bool>(false);
const auto openInPhotoEditor = [=, show = _show](int index) {
applyBlockChanges(); applyBlockChanges();
_removingIndex = index; if (!(*openedOnce)) {
crl::on_main(this, [=] { show->session().settings().incrementPhotoEditorHintShown();
const auto index = base::take(_removingIndex).value_or(-1); show->session().saveSettings();
if (index < 0 || index >= _list.files.size()) { }
return; *openedOnce = true;
} Editor::OpenWithPreparedFile(
// Just close the box if it is the only one. this,
if (_list.files.size() == 1) { show,
requestToTakeTextWithTags(); &_list.files[index],
closeBox(); st::sendMediaPreviewSize,
return; [=](bool ok) {
} if (ok) {
refreshAllAfterChanges(index, [&] { refreshAllAfterChanges(from);
_list.files.erase(_list.files.begin() + index);
if (index == _list.files.size()) {
auto &last = _list.files.back();
const auto was = base::take(last.caption);
if (fieldText().empty() && !last.isSticker()) {
_caption->setTextWithTags(was);
}
} }
}); });
}); };
}, widget->lifetime()); const auto replaceAttachment = [=, show = _show](int index) {
const auto show = uiShow();
block.itemReplaceRequest(
) | rpl::on_next([=](int index) {
applyBlockChanges(); applyBlockChanges();
const auto replace = [=](Ui::PreparedList list) { const auto replace = [=](Ui::PreparedList list) {
@@ -1333,28 +1324,8 @@ void SendFilesBox::pushBlock(int from, int till) {
tr::lng_choose_file(tr::now), tr::lng_choose_file(tr::now),
FileDialog::AllOrImagesFilter(), FileDialog::AllOrImagesFilter(),
crl::guard(this, callback)); crl::guard(this, callback));
}, widget->lifetime()); };
const auto editCover = [=, show = _show](int index) {
const auto openedOnce = widget->lifetime().make_state<bool>(false);
block.itemModifyRequest(
) | rpl::on_next([=, show = _show](int index) {
applyBlockChanges();
if (!(*openedOnce)) {
show->session().settings().incrementPhotoEditorHintShown();
show->session().saveSettings();
}
*openedOnce = true;
Editor::OpenWithPreparedFile(
this,
show,
&_list.files[index],
st::sendMediaPreviewSize,
[=](bool ok) { if (ok) refreshAllAfterChanges(from); });
}, widget->lifetime());
block.itemEditCoverRequest(
) | rpl::on_next([=, show = _show](int index) {
applyBlockChanges(); applyBlockChanges();
const auto replace = [=](Ui::PreparedList list) { const auto replace = [=](Ui::PreparedList list) {
@@ -1414,15 +1385,170 @@ void SendFilesBox::pushBlock(int from, int till) {
tr::lng_choose_cover(tr::now), tr::lng_choose_cover(tr::now),
FileDialog::ImagesFilter(), FileDialog::ImagesFilter(),
crl::guard(this, callback)); crl::guard(this, callback));
}, widget->lifetime()); };
const auto clearCover = [=](int index) {
block.itemClearCoverRequest(
) | rpl::on_next([=](int index) {
applyBlockChanges(); applyBlockChanges();
refreshAllAfterChanges(from, [&] { refreshAllAfterChanges(from, [&] {
auto &entry = _list.files[index]; auto &entry = _list.files[index];
entry.videoCover = nullptr; entry.videoCover = nullptr;
}); });
};
const auto showContextMenu = [=](int fileIndex, QPoint globalPosition) {
if (from >= till
|| fileIndex < from
|| fileIndex >= till
|| fileIndex >= _list.files.size()) {
return false;
}
state->menu = base::make_unique_q<Ui::PopupMenu>(
widget,
_st.tabbed.menu);
state->menu->setForcedOrigin(Ui::PanelAnimation::Origin::TopRight);
const auto &file = _list.files[fileIndex];
state->menu->addAction(tr::lng_attach_replace(tr::now), [=] {
replaceAttachment(fileIndex);
}, &st::menuIconReplace);
const auto canOpenPhotoEditor = true
&& _sendWay.current().sendImagesAsPhotos()
&& (file.type == Ui::PreparedFile::Type::Photo);
if (canOpenPhotoEditor) {
state->menu->addAction(tr::lng_context_draw(tr::now), [=] {
openInPhotoEditor(fileIndex);
}, &st::menuIconDraw);
}
const auto canEditFileData = !SkipCaption(
file,
_sendWay.current());
if (canEditFileData) {
state->menu->addAction(tr::lng_rename_file(tr::now), [=] {
auto &file = _list.files[fileIndex];
_show->show(Box(RenameFileBox, file.displayName, [=](
QString newName) {
const auto displayName = std::move(newName);
_list.files[fileIndex].displayName = displayName;
if (!setDisplayNameInSingleFilePreview(
fileIndex,
displayName)) {
refreshAllAfterChanges(from);
}
}));
}, &st::menuIconEdit);
state->menu->addAction(
tr::lng_context_upload_edit_caption(tr::now),
[=] {
auto &file = _list.files[fileIndex];
const auto count = int(_list.files.size());
const auto sync = (fileIndex + 1 == count);
_show->show(Box(
EditFileCaptionBox,
_st,
_toPeer,
sync ? fieldText() : file.caption,
[=](TextWithTags text) {
if (!validateLength(text.text)) {
return false;
}
if (sync) {
_caption->setTextWithTags(
base::take(text));
}
_list.files[fileIndex].caption = text;
if (!setCaptionInSingleFilePreview(
fileIndex,
text)) {
refreshAllAfterChanges(from);
}
return true;
}));
},
&st::menuIconCaptionShow);
}
const auto canToggleSpoiler = !hasPrice()
&& _sendWay.current().sendImagesAsPhotos();
if (canToggleSpoiler) {
const auto spoilered = file.spoiler;
const auto &icons = _st.tabbed.icons;
state->menu->addAction(spoilered
? tr::lng_context_disable_spoiler(tr::now)
: tr::lng_context_spoiler_effect(tr::now), [=] {
applyBlockChanges();
refreshAllAfterChanges(from, [&] {
auto &entry = _list.files[fileIndex];
entry.spoiler = !spoilered;
});
}, spoilered ? &icons.menuSpoilerOff : &icons.menuSpoiler);
}
const auto canEditCover = file.isVideoFile()
&& (_toPeer->isBroadcast() || _toPeer->isSelf());
if (canEditCover) {
state->menu->addAction(tr::lng_context_edit_cover(tr::now), [=] {
editCover(fileIndex);
}, &st::menuIconEdit);
if (file.videoCover != nullptr) {
state->menu->addAction(
tr::lng_context_clear_cover(tr::now),
[=] { clearCover(fileIndex); },
&st::menuIconCancel);
}
}
if (state->menu->empty()) {
state->menu = nullptr;
return false;
}
state->menu->popup(globalPosition);
return true;
};
block.itemDeleteRequest(
) | rpl::filter([=] {
return !_removingIndex;
}) | rpl::on_next([=](int index) {
applyBlockChanges();
_removingIndex = index;
crl::on_main(this, [=] {
const auto index = base::take(_removingIndex).value_or(-1);
if (index < 0 || index >= _list.files.size()) {
return;
}
// Just close the box if it is the only one.
if (_list.files.size() == 1) {
requestToTakeTextWithTags();
closeBox();
return;
}
refreshAllAfterChanges(index, [&] {
_list.files.erase(_list.files.begin() + index);
if (index == _list.files.size()) {
auto &last = _list.files.back();
const auto was = base::take(last.caption);
if (fieldText().empty() && !last.isSticker()) {
_caption->setTextWithTags(was);
}
}
});
});
}, widget->lifetime());
block.itemReplaceRequest(
) | rpl::on_next([=](int index) {
showContextMenu(index, QCursor::pos());
}, widget->lifetime());
block.itemModifyRequest(
) | rpl::on_next([=](int index) {
openInPhotoEditor(index);
}, widget->lifetime());
block.itemEditCoverRequest(
) | rpl::on_next([=](int index) {
editCover(index);
}, widget->lifetime());
block.itemClearCoverRequest(
) | rpl::on_next([=](int index) {
clearCover(index);
}, widget->lifetime()); }, widget->lifetime());
block.orderUpdated() | rpl::on_next([=]{ block.orderUpdated() | rpl::on_next([=]{
@@ -1432,11 +1558,7 @@ void SendFilesBox::pushBlock(int from, int till) {
} }
}, widget->lifetime()); }, widget->lifetime());
struct State { base::install_event_filter(widget, [=](
base::unique_qptr<Ui::PopupMenu> menu;
};
const auto state = widget->lifetime().make_state<State>();
base::install_event_filter(widget, [=, from = from, till = till](
not_null<QEvent*> e) { not_null<QEvent*> e) {
if (e->type() == QEvent::ContextMenu) { if (e->type() == QEvent::ContextMenu) {
const auto mouse = static_cast<QContextMenuEvent*>(e.get()); const auto mouse = static_cast<QContextMenuEvent*>(e.get());
@@ -1454,63 +1576,9 @@ void SendFilesBox::pushBlock(int from, int till) {
if (fileIndex >= till || fileIndex >= _list.files.size()) { if (fileIndex >= till || fileIndex >= _list.files.size()) {
return base::EventFilterResult::Continue; return base::EventFilterResult::Continue;
} }
state->menu = base::make_unique_q<Ui::PopupMenu>( if (showContextMenu(fileIndex, mouse->globalPos())) {
widget, return base::EventFilterResult::Cancel;
_st.tabbed.menu);
const auto &file = _list.files[fileIndex];
const auto canEditFileData = !SkipCaption(
file,
_sendWay.current());
if (canEditFileData) {
state->menu->addAction(tr::lng_rename_file(tr::now), [=] {
auto &file = _list.files[fileIndex];
_show->show(Box(RenameFileBox, file.displayName, [=](
QString newName) {
const auto displayName = std::move(newName);
_list.files[fileIndex].displayName = displayName;
if (!setDisplayNameInSingleFilePreview(
fileIndex,
displayName)) {
refreshAllAfterChanges(from);
}
}));
}, &st::menuIconEdit);
state->menu->addAction(
tr::lng_context_upload_edit_caption(tr::now),
[=] {
auto &file = _list.files[fileIndex];
const auto count = int(_list.files.size());
const auto sync = (fileIndex + 1 == count);
_show->show(Box(
EditFileCaptionBox,
_st,
_toPeer,
sync ? fieldText() : file.caption,
[=](TextWithTags text) {
if (!validateLength(text.text)) {
return false;
}
if (sync) {
_caption->setTextWithTags(
base::take(text));
}
_list.files[fileIndex].caption = text;
if (!setCaptionInSingleFilePreview(
fileIndex,
text)) {
refreshAllAfterChanges(from);
}
return true;
}));
},
&st::menuIconCaptionShow);
} }
if (state->menu->empty()) {
state->menu = nullptr;
return base::EventFilterResult::Continue;
}
state->menu->popup(mouse->globalPos());
return base::EventFilterResult::Cancel;
} }
return base::EventFilterResult::Continue; return base::EventFilterResult::Continue;
}, widget->lifetime()); }, widget->lifetime());
@@ -588,7 +588,7 @@ emojiEmpty: icon {{ "emoji_empty", windowSubTextFg }};
editMediaButtonSize: 32px; editMediaButtonSize: 32px;
editMediaButtonIconFile: icon {{ "send_media/send_media_replace", menuIconFg }}; editMediaButtonIconFile: icon {{ "send_media/send_media_more", menuIconFg }};
editMediaButton: IconButton(defaultIconButton) { editMediaButton: IconButton(defaultIconButton) {
width: editMediaButtonSize; width: editMediaButtonSize;
height: editMediaButtonSize; height: editMediaButtonSize;
@@ -602,10 +602,10 @@ editMediaButton: IconButton(defaultIconButton) {
sendBoxAlbumGroupEditInternalSkip: 8px; sendBoxAlbumGroupEditInternalSkip: 8px;
sendBoxAlbumGroupSkipRight: 5px; sendBoxAlbumGroupSkipRight: 5px;
sendBoxAlbumGroupSkipTop: 5px; sendBoxAlbumGroupSkipTop: 5px;
sendBoxAlbumGroupRadius: 4px; sendBoxAlbumGroupSize: size(48px, 26px);
sendBoxAlbumGroupSize: size(62px, 25px);
sendBoxAlbumGroupSizeVertical: size(30px, 50px); sendBoxAlbumGroupSizeVertical: size(30px, 50px);
sendBoxAlbumSmallGroupSize: size(30px, 25px); sendBoxAlbumSmallGroupSize: size(30px, 25px);
sendBoxAlbumSmallGroupCircleSize: 27px;
sendBoxFileGroupSkipTop: 2px; sendBoxFileGroupSkipTop: 2px;
sendBoxFileGroupSkipRight: 5px; sendBoxFileGroupSkipRight: 5px;
@@ -617,11 +617,11 @@ sendBoxAlbumGroupButtonFile: IconButton(editMediaButton) {
} }
} }
sendBoxAlbumGroupEditButtonIconFile: editMediaButtonIconFile; sendBoxAlbumGroupEditButtonIconFile: editMediaButtonIconFile;
sendBoxAlbumGroupDeleteButtonIconFile: icon {{ "send_media/send_media_delete", menuIconFg }}; sendBoxAlbumGroupDeleteButtonIconFile: icon {{ "send_media/send_media_cross", menuIconFg }};
sendBoxAlbumButtonMediaEdit: icon {{ "send_media/send_media_replace", roundedFg }}; sendBoxAlbumButtonMediaMore: icon {{ "send_media/send_media_more", roundedFg }};
sendBoxAlbumGroupButtonMediaEdit: icon {{ "send_media/send_media_replace", roundedFg, point(4px, 1px) }}; sendBoxAlbumGroupButtonMediaMore: icon {{ "send_media/send_media_more", roundedFg, point(4px, 1px) }};
sendBoxAlbumGroupButtonMediaDelete: icon {{ "send_media/send_media_delete", roundedFg }}; sendBoxAlbumGroupButtonMediaDelete: icon {{ "send_media/send_media_cross", roundedFg, point(-2px, 1px) }};
defaultComposeIcons: ComposeIcons { defaultComposeIcons: ComposeIcons {
settings: icon {{ "emoji/emoji_settings", emojiIconFg }}; settings: icon {{ "emoji/emoji_settings", emojiIconFg }};
@@ -7,21 +7,36 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
*/ */
#include "ui/chat/attach/attach_controls.h" #include "ui/chat/attach/attach_controls.h"
#include "ui/painter.h"
#include "styles/style_chat_helpers.h" #include "styles/style_chat_helpers.h"
namespace Ui { namespace Ui {
AttachControls::AttachControls()
: _rect(st::sendBoxAlbumGroupRadius, st::roundedBg) {
}
void AttachControls::paint(QPainter &p, int x, int y) { void AttachControls::paint(QPainter &p, int x, int y) {
const auto groupWidth = width(); const auto groupWidth = width();
const auto groupHeight = height(); const auto groupHeight = height();
const auto full = (_type == Type::Full); const auto full = (_type == Type::Full);
QRect groupRect(x, y, groupWidth, groupHeight); const auto groupRect = QRect(x, y, groupWidth, groupHeight);
_rect.paint(p, groupRect); {
auto hq = PainterHighQualityEnabler(p);
p.setPen(Qt::NoPen);
p.setBrush(st::roundedBg);
if (_type == Type::EditOnly) {
const auto desired = st::sendBoxAlbumSmallGroupCircleSize;
const auto available = std::min(groupWidth, groupHeight);
const auto side = std::min(desired, available);
const auto circleRect = QRect(
x + ((groupWidth - side) / 2),
y + ((groupHeight - side) / 2),
side,
side);
p.drawEllipse(circleRect);
} else {
const auto radius = std::min(groupWidth, groupHeight) / 2.;
p.drawRoundedRect(groupRect, radius, radius);
}
}
if (full) { if (full) {
const auto groupHalfWidth = groupWidth / 2; const auto groupHalfWidth = groupWidth / 2;
@@ -29,13 +44,13 @@ void AttachControls::paint(QPainter &p, int x, int y) {
const auto editRect = _vertical const auto editRect = _vertical
? QRect(x, y, groupWidth, groupHalfHeight) ? QRect(x, y, groupWidth, groupHalfHeight)
: QRect(x, y, groupHalfWidth, groupHeight); : QRect(x, y, groupHalfWidth, groupHeight);
st::sendBoxAlbumGroupButtonMediaEdit.paintInCenter(p, editRect); st::sendBoxAlbumGroupButtonMediaMore.paintInCenter(p, editRect);
const auto deleteRect = _vertical const auto deleteRect = _vertical
? QRect(x, y + groupHalfHeight, groupWidth, groupHalfHeight) ? QRect(x, y + groupHalfHeight, groupWidth, groupHalfHeight)
: QRect(x + groupHalfWidth, y, groupHalfWidth, groupHeight); : QRect(x + groupHalfWidth, y, groupHalfWidth, groupHeight);
st::sendBoxAlbumGroupButtonMediaDelete.paintInCenter(p, deleteRect); st::sendBoxAlbumGroupButtonMediaDelete.paintInCenter(p, deleteRect);
} else if (_type == Type::EditOnly) { } else if (_type == Type::EditOnly) {
st::sendBoxAlbumButtonMediaEdit.paintInCenter(p, groupRect); st::sendBoxAlbumButtonMediaMore.paintInCenter(p, groupRect);
} }
} }
@@ -45,7 +60,10 @@ int AttachControls::width() const {
? st::sendBoxAlbumGroupSizeVertical.width() ? st::sendBoxAlbumGroupSizeVertical.width()
: st::sendBoxAlbumGroupSize.width()) : st::sendBoxAlbumGroupSize.width())
: (_type == Type::EditOnly) : (_type == Type::EditOnly)
? st::sendBoxAlbumSmallGroupSize.width() ? ((st::sendBoxAlbumSmallGroupSize.width()
> st::sendBoxAlbumSmallGroupCircleSize)
? st::sendBoxAlbumSmallGroupSize.width()
: st::sendBoxAlbumSmallGroupCircleSize)
: 0; : 0;
} }
@@ -55,7 +73,10 @@ int AttachControls::height() const {
? st::sendBoxAlbumGroupSizeVertical.height() ? st::sendBoxAlbumGroupSizeVertical.height()
: st::sendBoxAlbumGroupSize.height()) : st::sendBoxAlbumGroupSize.height())
: (_type == Type::EditOnly) : (_type == Type::EditOnly)
? st::sendBoxAlbumSmallGroupSize.height() ? ((st::sendBoxAlbumSmallGroupSize.height()
> st::sendBoxAlbumSmallGroupCircleSize)
? st::sendBoxAlbumSmallGroupSize.height()
: st::sendBoxAlbumSmallGroupCircleSize)
: 0; : 0;
} }
@@ -86,17 +107,16 @@ AttachControlsWidget::AttachControlsWidget(
_controls.setType(type); _controls.setType(type);
const auto w = _controls.width(); const auto w = _controls.width();
resize(w, _controls.height()); const auto h = _controls.height();
resize(w, h);
if (type == AttachControls::Type::Full) { if (type == AttachControls::Type::Full) {
_edit->resize(w / 2, _controls.height()); const auto leftWidth = w / 2;
_delete->resize(w / 2, _controls.height()); const auto rightWidth = w - leftWidth;
_edit->setGeometryToLeft(0, 0, leftWidth, h, w);
_edit->moveToLeft(0, 0, w); _delete->setGeometryToLeft(leftWidth, 0, rightWidth, h, w);
_delete->moveToRight(0, 0, w);
} else if (type == AttachControls::Type::EditOnly) { } else if (type == AttachControls::Type::EditOnly) {
_edit->resize(w, _controls.height()); _edit->setGeometryToLeft(0, 0, w, h, w);
_edit->moveToLeft(0, 0, w);
} }
paintRequest( paintRequest(
@@ -8,7 +8,6 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#pragma once #pragma once
#include "ui/abstract_button.h" #include "ui/abstract_button.h"
#include "ui/round_rect.h"
#include "ui/rp_widget.h" #include "ui/rp_widget.h"
namespace Ui { namespace Ui {
@@ -21,8 +20,6 @@ public:
None, None,
}; };
AttachControls();
void paint(QPainter &p, int x, int y); void paint(QPainter &p, int x, int y);
void setType(Type type); void setType(Type type);
void setVertical(bool vertical); void setVertical(bool vertical);
@@ -33,7 +30,6 @@ public:
[[nodiscard]] bool vertical() const; [[nodiscard]] bool vertical() const;
private: private:
RoundRect _rect;
Type _type = Type::Full; Type _type = Type::Full;
bool _vertical = false; bool _vertical = false;
@@ -51,7 +51,7 @@ void SingleFilePreview::preparePreview(const PreparedFile &file) {
auto preview = QImage(); auto preview = QImage();
if (const auto image = std::get_if<PreparedFileInformation::Image>( if (const auto image = std::get_if<PreparedFileInformation::Image>(
&file.information->media)) { &file.information->media)) {
preview = image->data; preview = file.preview.isNull() ? image->data : file.preview;
} else if (const auto video = std::get_if<PreparedFileInformation::Video>( } else if (const auto video = std::get_if<PreparedFileInformation::Video>(
&file.information->media)) { &file.information->media)) {
preview = video->thumbnail; preview = video->thumbnail;
+1
View File
@@ -12,6 +12,7 @@ menuIconReactions: icon {{ "menu/read_reactions", menuIconColor }};
menuIconReply: icon {{ "menu/reply", menuIconColor }}; menuIconReply: icon {{ "menu/reply", menuIconColor }};
menuIconViewReplies: icon {{ "menu/view_replies", menuIconColor }}; menuIconViewReplies: icon {{ "menu/view_replies", menuIconColor }};
menuIconEdit: icon {{ "menu/edit", menuIconColor }}; menuIconEdit: icon {{ "menu/edit", menuIconColor }};
menuIconDraw: icon {{ "mediaview/draw", menuIconColor, point(2px, 3px) }};
menuIconPin: icon {{ "menu/pin", menuIconColor }}; menuIconPin: icon {{ "menu/pin", menuIconColor }};
menuIconUnpin: icon {{ "menu/unpin", menuIconColor }}; menuIconUnpin: icon {{ "menu/unpin", menuIconColor }};
menuIconCopy: icon {{ "menu/copy", menuIconColor }}; menuIconCopy: icon {{ "menu/copy", menuIconColor }};