Make export done button adaptive to text.

This commit is contained in:
John Preston 2018-06-27 16:05:26 +01:00
parent 3b956c598b
commit d8897a0cc8
2 changed files with 13 additions and 1 deletions

View File

@ -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());
}

View File

@ -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());