mirror of
https://github.com/telegramdesktop/tdesktop
synced 2025-03-25 04:38:23 +00:00
Make export done button adaptive to text.
This commit is contained in:
parent
3b956c598b
commit
d8897a0cc8
@ -314,6 +314,14 @@ void ProgressWidget::showDone() {
|
||||
this,
|
||||
langFactory(lng_export_done),
|
||||
st::exportDoneButton);
|
||||
const auto desired = std::min(
|
||||
st::exportDoneButton.font->width(lang(lng_export_done).toUpper())
|
||||
+ st::exportDoneButton.height
|
||||
- st::exportDoneButton.font->height,
|
||||
st::exportPanelSize.width() - 2 * st::exportCancelBottom);
|
||||
if (_done->width() < desired) {
|
||||
_done->setFullWidth(desired);
|
||||
}
|
||||
_done->clicks() | rpl::start_to_stream(_doneClicks, _done->lifetime());
|
||||
setupBottomButton(_done.get());
|
||||
}
|
||||
|
@ -263,7 +263,7 @@ void RoundButton::numbersAnimationCallback() {
|
||||
|
||||
void RoundButton::setFullWidth(int newFullWidth) {
|
||||
_fullWidthOverride = newFullWidth;
|
||||
resizeToText();
|
||||
refreshText();
|
||||
}
|
||||
|
||||
void RoundButton::refreshText() {
|
||||
@ -282,6 +282,10 @@ QString RoundButton::computeFullText() const {
|
||||
void RoundButton::resizeToText() {
|
||||
int innerWidth = contentWidth();
|
||||
if (_fullWidthOverride > 0) {
|
||||
if (_fullWidthOverride < innerWidth + (_st.height - _st.font->height)) {
|
||||
_text = _st.font->elided(computeFullText(), qMax(_fullWidthOverride - (_st.height - _st.font->height), 1));
|
||||
_textWidth = _st.font->width(_text);
|
||||
}
|
||||
resize(_fullWidthOverride, _st.height + _st.padding.top() + _st.padding.bottom());
|
||||
} else if (_fullWidthOverride < 0) {
|
||||
resize(innerWidth - _fullWidthOverride, _st.height + _st.padding.top() + _st.padding.bottom());
|
||||
|
Loading…
Reference in New Issue
Block a user