Change dialogs filter text area for two icons.

This commit is contained in:
John Preston 2017-08-06 19:11:22 +02:00
parent a2c93bc040
commit ce51abd9d0
3 changed files with 24 additions and 7 deletions

View File

@ -921,11 +921,19 @@ void DialogsWidget::updateJumpToDateVisibility(bool fast) {
} }
void DialogsWidget::updateSearchFromVisibility(bool fast) { void DialogsWidget::updateSearchFromVisibility(bool fast) {
auto searchFromUserVisible = _searchInPeer && (_searchInPeer->isChat() || _searchInPeer->isMegagroup()) && !_searchFromUser; auto visible = _searchInPeer && (_searchInPeer->isChat() || _searchInPeer->isMegagroup()) && !_searchFromUser;
auto changed = (visible == _chooseFromUser->isHiddenOrHiding());
if (fast) { if (fast) {
_chooseFromUser->toggleFast(searchFromUserVisible); _chooseFromUser->toggleFast(visible);
} else { } else {
_chooseFromUser->toggleAnimated(searchFromUserVisible); _chooseFromUser->toggleAnimated(visible);
}
if (changed) {
auto margins = st::dialogsFilter.textMrg;
if (visible) {
margins.setRight(margins.right() + _chooseFromUser->width());
}
_filter->setTextMrg(margins);
} }
} }

View File

@ -1470,7 +1470,8 @@ FlatInput::FlatInput(QWidget *parent, const style::FlatInput &st, base::lambda<Q
, _oldtext(v) , _oldtext(v)
, _placeholderFactory(std::move(placeholderFactory)) , _placeholderFactory(std::move(placeholderFactory))
, _placeholderVisible(!v.length()) , _placeholderVisible(!v.length())
, _st(st) { , _st(st)
, _textMrg(_st.textMrg) {
setCursor(style::cur_text); setCursor(style::cur_text);
resize(_st.width, _st.height); resize(_st.width, _st.height);
@ -1564,8 +1565,14 @@ void FlatInput::touchEvent(QTouchEvent *e) {
} }
} }
void FlatInput::setTextMrg(const QMargins &textMrg) {
_textMrg = textMrg;
refreshPlaceholder();
update();
}
QRect FlatInput::getTextRect() const { QRect FlatInput::getTextRect() const {
return rect().marginsRemoved(_st.textMrg + QMargins(-2, -1, -2, -1)); return rect().marginsRemoved(_textMrg + QMargins(-2, -1, -2, -1));
} }
void FlatInput::paintEvent(QPaintEvent *e) { void FlatInput::paintEvent(QPaintEvent *e) {
@ -1635,7 +1642,7 @@ void FlatInput::setPlaceholder(base::lambda<QString()> placeholderFactory) {
} }
void FlatInput::refreshPlaceholder() { void FlatInput::refreshPlaceholder() {
auto availw = width() - _st.textMrg.left() - _st.textMrg.right() - _st.phPos.x() - 1; auto availw = width() - _textMrg.left() - _textMrg.right() - _st.phPos.x() - 1;
auto placeholderText = _placeholderFactory ? _placeholderFactory() : QString(); auto placeholderText = _placeholderFactory ? _placeholderFactory() : QString();
if (_st.font->width(placeholderText) > availw) { if (_st.font->width(placeholderText) > availw) {
_placeholder = _st.font->elided(placeholderText, availw); _placeholder = _st.font->elided(placeholderText, availw);
@ -1683,7 +1690,7 @@ void FlatInput::inputMethodEvent(QInputMethodEvent *e) {
} }
QRect FlatInput::placeholderRect() const { QRect FlatInput::placeholderRect() const {
return QRect(_st.textMrg.left() + _st.phPos.x(), _st.textMrg.top() + _st.phPos.y(), width() - _st.textMrg.left() - _st.textMrg.right(), height() - _st.textMrg.top() - _st.textMrg.bottom()); return QRect(_textMrg.left() + _st.phPos.x(), _textMrg.top() + _st.phPos.y(), width() - _textMrg.left() - _textMrg.right(), height() - _textMrg.top() - _textMrg.bottom());
} }
void FlatInput::correctValue(const QString &was, QString &now) { void FlatInput::correctValue(const QString &was, QString &now) {

View File

@ -243,6 +243,7 @@ public:
void setPlaceholder(base::lambda<QString()> placeholderFactory); void setPlaceholder(base::lambda<QString()> placeholderFactory);
QRect placeholderRect() const; QRect placeholderRect() const;
void setTextMrg(const QMargins &textMrg);
QRect getTextRect() const; QRect getTextRect() const;
QSize sizeHint() const override; QSize sizeHint() const override;
@ -302,6 +303,7 @@ private:
bool _lastPreEditTextNotEmpty = false; bool _lastPreEditTextNotEmpty = false;
const style::FlatInput &_st; const style::FlatInput &_st;
QMargins _textMrg;
QTimer _touchTimer; QTimer _touchTimer;
bool _touchPress, _touchRightButton, _touchMove; bool _touchPress, _touchRightButton, _touchMove;