Added ability to hide attach controls.

This commit is contained in:
23rd 2021-07-12 17:32:13 +03:00 committed by John Preston
parent 7cf5e6d94f
commit 47a4f4229d
4 changed files with 25 additions and 4 deletions

View File

@ -33,6 +33,9 @@ AbstractSingleFilePreview::AbstractSingleFilePreview(
} else if (type == AttachControls::Type::EditOnly) {
_deleteMedia->hide();
_editMedia->show();
} else if (type == AttachControls::Type::None) {
_deleteMedia->hide();
_editMedia->hide();
}
}

View File

@ -29,7 +29,7 @@ void AttachControls::paint(Painter &p, int x, int y) {
st::sendBoxAlbumGroupButtonMediaEdit.paintInCenter(p, leftRect);
QRect rightRect(x + groupHalfWidth, y, groupHalfWidth, groupHeight);
st::sendBoxAlbumGroupButtonMediaDelete.paintInCenter(p, rightRect);
} else {
} else if (_type == Type::EditOnly) {
st::sendBoxAlbumButtonMediaEdit.paintInCenter(p, groupRect);
}
}
@ -37,13 +37,17 @@ void AttachControls::paint(Painter &p, int x, int y) {
int AttachControls::width() const {
return (_type == Type::Full)
? st::sendBoxAlbumGroupSize.width()
: st::sendBoxAlbumSmallGroupSize.width();
: (_type == Type::EditOnly)
? st::sendBoxAlbumSmallGroupSize.width()
: 0;
}
int AttachControls::height() const {
return (_type == Type::Full)
? st::sendBoxAlbumGroupSize.height()
: st::sendBoxAlbumSmallGroupSize.height();
: (_type == Type::EditOnly)
? st::sendBoxAlbumSmallGroupSize.height()
: 0;
}
AttachControls::Type AttachControls::type() const {

View File

@ -18,6 +18,7 @@ public:
enum class Type {
Full,
EditOnly,
None,
};
AttachControls();

View File

@ -20,12 +20,25 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include "styles/style_chat.h"
namespace Ui {
namespace {
AttachControls::Type CheckControlsType(
not_null<HistoryItem*> item,
AttachControls::Type type) {
const auto media = item->media();
Assert(media != nullptr);
return media->allowsEditMedia()
? type
: AttachControls::Type::None;
}
} // namespace
ItemSingleFilePreview::ItemSingleFilePreview(
QWidget *parent,
not_null<HistoryItem*> item,
AttachControls::Type type)
: AbstractSingleFilePreview(parent, type) {
: AbstractSingleFilePreview(parent, CheckControlsType(item, type)) {
const auto media = item->media();
Assert(media != nullptr);
const auto document = media->document();