mirror of
https://github.com/AyuGram/AyuGramDesktop.git
synced 2025-04-18 07:07:08 +02:00
Added ability to hide attach controls.
This commit is contained in:
parent
7cf5e6d94f
commit
47a4f4229d
4 changed files with 25 additions and 4 deletions
Telegram/SourceFiles/ui/chat/attach
|
@ -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();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -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 {
|
||||
|
|
|
@ -18,6 +18,7 @@ public:
|
|||
enum class Type {
|
||||
Full,
|
||||
EditOnly,
|
||||
None,
|
||||
};
|
||||
|
||||
AttachControls();
|
||||
|
|
|
@ -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();
|
||||
|
|
Loading…
Add table
Reference in a new issue