mirror of
https://github.com/AyuGram/AyuGramDesktop.git
synced 2025-06-05 06:33:57 +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
|
@ -33,6 +33,9 @@ AbstractSingleFilePreview::AbstractSingleFilePreview(
|
||||||
} else if (type == AttachControls::Type::EditOnly) {
|
} else if (type == AttachControls::Type::EditOnly) {
|
||||||
_deleteMedia->hide();
|
_deleteMedia->hide();
|
||||||
_editMedia->show();
|
_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);
|
st::sendBoxAlbumGroupButtonMediaEdit.paintInCenter(p, leftRect);
|
||||||
QRect rightRect(x + groupHalfWidth, y, groupHalfWidth, groupHeight);
|
QRect rightRect(x + groupHalfWidth, y, groupHalfWidth, groupHeight);
|
||||||
st::sendBoxAlbumGroupButtonMediaDelete.paintInCenter(p, rightRect);
|
st::sendBoxAlbumGroupButtonMediaDelete.paintInCenter(p, rightRect);
|
||||||
} else {
|
} else if (_type == Type::EditOnly) {
|
||||||
st::sendBoxAlbumButtonMediaEdit.paintInCenter(p, groupRect);
|
st::sendBoxAlbumButtonMediaEdit.paintInCenter(p, groupRect);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -37,13 +37,17 @@ void AttachControls::paint(Painter &p, int x, int y) {
|
||||||
int AttachControls::width() const {
|
int AttachControls::width() const {
|
||||||
return (_type == Type::Full)
|
return (_type == Type::Full)
|
||||||
? st::sendBoxAlbumGroupSize.width()
|
? st::sendBoxAlbumGroupSize.width()
|
||||||
: st::sendBoxAlbumSmallGroupSize.width();
|
: (_type == Type::EditOnly)
|
||||||
|
? st::sendBoxAlbumSmallGroupSize.width()
|
||||||
|
: 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int AttachControls::height() const {
|
int AttachControls::height() const {
|
||||||
return (_type == Type::Full)
|
return (_type == Type::Full)
|
||||||
? st::sendBoxAlbumGroupSize.height()
|
? st::sendBoxAlbumGroupSize.height()
|
||||||
: st::sendBoxAlbumSmallGroupSize.height();
|
: (_type == Type::EditOnly)
|
||||||
|
? st::sendBoxAlbumSmallGroupSize.height()
|
||||||
|
: 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
AttachControls::Type AttachControls::type() const {
|
AttachControls::Type AttachControls::type() const {
|
||||||
|
|
|
@ -18,6 +18,7 @@ public:
|
||||||
enum class Type {
|
enum class Type {
|
||||||
Full,
|
Full,
|
||||||
EditOnly,
|
EditOnly,
|
||||||
|
None,
|
||||||
};
|
};
|
||||||
|
|
||||||
AttachControls();
|
AttachControls();
|
||||||
|
|
|
@ -20,12 +20,25 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||||
#include "styles/style_chat.h"
|
#include "styles/style_chat.h"
|
||||||
|
|
||||||
namespace Ui {
|
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(
|
ItemSingleFilePreview::ItemSingleFilePreview(
|
||||||
QWidget *parent,
|
QWidget *parent,
|
||||||
not_null<HistoryItem*> item,
|
not_null<HistoryItem*> item,
|
||||||
AttachControls::Type type)
|
AttachControls::Type type)
|
||||||
: AbstractSingleFilePreview(parent, type) {
|
: AbstractSingleFilePreview(parent, CheckControlsType(item, type)) {
|
||||||
const auto media = item->media();
|
const auto media = item->media();
|
||||||
Assert(media != nullptr);
|
Assert(media != nullptr);
|
||||||
const auto document = media->document();
|
const auto document = media->document();
|
||||||
|
|
Loading…
Add table
Reference in a new issue