mirror of
https://github.com/AyuGram/AyuGramDesktop.git
synced 2025-04-16 14:17:12 +02:00
parent
f9173ea849
commit
4074a558e7
11 changed files with 90 additions and 90 deletions
|
@ -206,12 +206,30 @@ dialogsSearchForNarrowFilters: IconButton(dialogsMenuToggle) {
|
|||
}
|
||||
dialogsSearchFromPadding: margins(10px, 10px, 10px, 10px);
|
||||
|
||||
dialogsFilter: FlatInput(defaultFlatInput) {
|
||||
font: font(fsize);
|
||||
dialogsFilter: InputField(defaultInputField) {
|
||||
textBg: filterInputInactiveBg;
|
||||
textBgActive: filterInputActiveBg;
|
||||
textMargins: margins(12px, 7px, 30px, 3px);
|
||||
|
||||
width: 240px;
|
||||
height: 32px;
|
||||
textMrg: margins(12px, 3px, 30px, 3px);
|
||||
placeholderFg: placeholderFg;
|
||||
placeholderFgActive: placeholderFgActive;
|
||||
placeholderFgError: placeholderFgActive;
|
||||
placeholderMargins: margins(2px, 0px, 2px, 0px);
|
||||
placeholderScale: 0.;
|
||||
placeholderShift: -50px;
|
||||
placeholderFont: normalFont;
|
||||
|
||||
borderFg: filterInputInactiveBg;
|
||||
borderFgActive: filterInputBorderFg;
|
||||
borderFgError: activeLineFgError;
|
||||
|
||||
border: 2px;
|
||||
borderActive: 2px;
|
||||
borderRadius: roundRadiusSmall;
|
||||
|
||||
font: normalFont;
|
||||
|
||||
heightMin: 32px;
|
||||
}
|
||||
dialogsCancelSearchInPeer: IconButton(dialogsMenuToggle) {
|
||||
icon: icon {{ "dialogs/dialogs_cancel_search", dialogsMenuIconFg }};
|
||||
|
|
|
@ -290,16 +290,16 @@ Widget::Widget(
|
|||
Ui::PostponeCall(this, [=] { listScrollUpdated(); });
|
||||
}, lifetime());
|
||||
|
||||
QObject::connect(_filter, &Ui::FlatInput::cancelled, [=] {
|
||||
QObject::connect(_filter, &Ui::InputField::cancelled, [=] {
|
||||
escape();
|
||||
});
|
||||
QObject::connect(_filter, &Ui::FlatInput::changed, [=] {
|
||||
QObject::connect(_filter, &Ui::InputField::changed, [=] {
|
||||
applyFilterUpdate();
|
||||
});
|
||||
QObject::connect(
|
||||
_filter,
|
||||
&Ui::FlatInput::cursorPositionChanged,
|
||||
[=](int from, int to) { filterCursorMoved(from, to); });
|
||||
_filter->rawTextEdit().get(),
|
||||
&QTextEdit::cursorPositionChanged,
|
||||
[=] { filterCursorMoved(); });
|
||||
|
||||
if (!Core::UpdaterDisabled()) {
|
||||
Core::UpdateChecker checker;
|
||||
|
@ -647,7 +647,7 @@ void Widget::updateControlsVisibility(bool fast) {
|
|||
} else {
|
||||
if (hasFocus()) {
|
||||
_filter->setFocus();
|
||||
_filter->finishAnimations();
|
||||
_filter->finishAnimating();
|
||||
}
|
||||
updateLockUnlockVisibility();
|
||||
updateJumpToDateVisibility(fast);
|
||||
|
@ -1159,7 +1159,6 @@ void Widget::searchMessages(
|
|||
setSearchInChat(inChat);
|
||||
}
|
||||
_filter->setText(query);
|
||||
_filter->updatePlaceholder();
|
||||
applyFilterUpdate(true);
|
||||
_searchTimer.cancel();
|
||||
searchMessages();
|
||||
|
@ -1649,29 +1648,35 @@ void Widget::showSearchFrom() {
|
|||
}
|
||||
}
|
||||
|
||||
void Widget::filterCursorMoved(int from, int to) {
|
||||
if (to < 0) to = _filter->cursorPosition();
|
||||
QString t = _filter->getLastText();
|
||||
QStringView r;
|
||||
void Widget::filterCursorMoved() {
|
||||
const auto to = _filter->textCursor().position();
|
||||
const auto text = _filter->getLastText();
|
||||
auto hashtag = QStringView();
|
||||
for (int start = to; start > 0;) {
|
||||
--start;
|
||||
if (t.size() <= start) break;
|
||||
if (t.at(start) == '#') {
|
||||
r = base::StringViewMid(t, start, to - start);
|
||||
if (text.size() <= start) {
|
||||
break;
|
||||
}
|
||||
const auto ch = text[start];
|
||||
if (ch == '#') {
|
||||
hashtag = base::StringViewMid(text, start, to - start);
|
||||
break;
|
||||
} else if (!ch.isLetterOrNumber() && ch != '_') {
|
||||
break;
|
||||
}
|
||||
if (!t.at(start).isLetterOrNumber() && t.at(start) != '_') break;
|
||||
}
|
||||
_inner->onHashtagFilterUpdate(r);
|
||||
_inner->onHashtagFilterUpdate(hashtag);
|
||||
}
|
||||
|
||||
void Widget::completeHashtag(QString tag) {
|
||||
QString t = _filter->getLastText(), r;
|
||||
int cur = _filter->cursorPosition();
|
||||
const auto t = _filter->getLastText();;
|
||||
auto cur = _filter->textCursor().position();
|
||||
auto hashtag = QString();
|
||||
for (int start = cur; start > 0;) {
|
||||
--start;
|
||||
if (t.size() <= start) break;
|
||||
if (t.at(start) == '#') {
|
||||
if (t.size() <= start) {
|
||||
break;
|
||||
} else if (t.at(start) == '#') {
|
||||
if (cur == start + 1
|
||||
|| base::StringViewMid(t, start + 1, cur - start - 1)
|
||||
== base::StringViewMid(tag, 0, cur - start - 1)) {
|
||||
|
@ -1679,15 +1684,16 @@ void Widget::completeHashtag(QString tag) {
|
|||
if (t.at(cur) != tag.at(cur - start - 1)) break;
|
||||
}
|
||||
if (cur - start - 1 == tag.size() && cur < t.size() && t.at(cur) == ' ') ++cur;
|
||||
r = t.mid(0, start + 1) + tag + ' ' + t.mid(cur);
|
||||
_filter->setText(r);
|
||||
hashtag = t.mid(0, start + 1) + tag + ' ' + t.mid(cur);
|
||||
_filter->setText(hashtag);
|
||||
_filter->setCursorPosition(start + 1 + tag.size() + 1);
|
||||
applyFilterUpdate(true);
|
||||
return;
|
||||
}
|
||||
break;
|
||||
} else if (!t.at(start).isLetterOrNumber() && t.at(start) != '_') {
|
||||
break;
|
||||
}
|
||||
if (!t.at(start).isLetterOrNumber() && t.at(start) != '_') break;
|
||||
}
|
||||
_filter->setText(t.mid(0, cur) + '#' + tag + ' ' + t.mid(cur));
|
||||
_filter->setCursorPosition(cur + 1 + tag.size() + 1);
|
||||
|
@ -1744,11 +1750,11 @@ void Widget::updateSearchFromVisibility(bool fast) {
|
|||
visible,
|
||||
fast ? anim::type::instant : anim::type::normal);
|
||||
if (changed) {
|
||||
auto margins = st::dialogsFilter.textMrg;
|
||||
auto additional = QMargins();
|
||||
if (visible) {
|
||||
margins.setRight(margins.right() + _chooseFromUser->width());
|
||||
additional.setRight(_chooseFromUser->width());
|
||||
}
|
||||
_filter->setTextMrg(margins);
|
||||
_filter->setAdditionalMargins(additional);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1973,7 +1979,6 @@ bool Widget::cancelSearch() {
|
|||
}
|
||||
_inner->clearFilter();
|
||||
_filter->clear();
|
||||
_filter->updatePlaceholder();
|
||||
applyFilterUpdate();
|
||||
return clearing;
|
||||
}
|
||||
|
|
|
@ -33,7 +33,7 @@ class IconButton;
|
|||
class PopupMenu;
|
||||
class DropdownMenu;
|
||||
class FlatButton;
|
||||
class FlatInput;
|
||||
class InputField;
|
||||
class CrossButton;
|
||||
class DownloadBar;
|
||||
template <typename Widget>
|
||||
|
@ -119,7 +119,7 @@ private:
|
|||
void chosenRow(const ChosenRow &row);
|
||||
void listScrollUpdated();
|
||||
void cancelSearchInChat();
|
||||
void filterCursorMoved(int from = -1, int to = -1);
|
||||
void filterCursorMoved();
|
||||
void completeHashtag(QString tag);
|
||||
|
||||
bool searchMessages(bool searchCache = false);
|
||||
|
@ -191,7 +191,7 @@ private:
|
|||
object_ptr<HistoryView::TopBarWidget> _folderTopBar = { nullptr } ;
|
||||
object_ptr<Ui::IconButton> _mainMenuToggle;
|
||||
object_ptr<Ui::IconButton> _searchForNarrowFilters;
|
||||
object_ptr<Ui::FlatInput> _filter;
|
||||
object_ptr<Ui::InputField> _filter;
|
||||
object_ptr<Ui::FadeWrapScaled<Ui::IconButton>> _chooseFromUser;
|
||||
object_ptr<Ui::FadeWrapScaled<Ui::IconButton>> _jumpToDate;
|
||||
object_ptr<Ui::CrossButton> _cancelSearch;
|
||||
|
|
|
@ -75,7 +75,7 @@ private:
|
|||
|
||||
not_null<Window::SessionController*> _controller;
|
||||
not_null<ChannelData*> _channel;
|
||||
object_ptr<Ui::FlatInput> _field;
|
||||
object_ptr<Ui::InputField> _field;
|
||||
object_ptr<Profile::BackButton> _backButton;
|
||||
object_ptr<Ui::IconButton> _search;
|
||||
object_ptr<Ui::CrossButton> _cancel;
|
||||
|
@ -110,7 +110,7 @@ FixedBar::FixedBar(
|
|||
not_null<ChannelData*> channel) : TWidget(parent)
|
||||
, _controller(controller)
|
||||
, _channel(channel)
|
||||
, _field(this, st::historyAdminLogSearchField, tr::lng_dlg_filter())
|
||||
, _field(this, st::defaultMultiSelectSearchField, tr::lng_dlg_filter())
|
||||
, _backButton(
|
||||
this,
|
||||
&controller->session(),
|
||||
|
@ -125,9 +125,9 @@ FixedBar::FixedBar(
|
|||
_cancel->setClickedCallback([=] { cancelSearch(); });
|
||||
_field->hide();
|
||||
_filter->setTextTransform(Ui::RoundButton::TextTransform::NoTransform);
|
||||
connect(_field, &Ui::FlatInput::cancelled, [=] { cancelSearch(); });
|
||||
connect(_field, &Ui::FlatInput::changed, [=] { searchUpdated(); });
|
||||
connect(_field, &Ui::FlatInput::submitted, [=] { applySearch(); });
|
||||
connect(_field, &Ui::InputField::cancelled, [=] { cancelSearch(); });
|
||||
connect(_field, &Ui::InputField::changed, [=] { searchUpdated(); });
|
||||
connect(_field, &Ui::InputField::submitted, [=] { applySearch(); });
|
||||
_searchTimer.setCallback([=] { applySearch(); });
|
||||
|
||||
_cancel->hide(anim::type::instant);
|
||||
|
@ -184,8 +184,7 @@ void FixedBar::searchAnimationCallback() {
|
|||
void FixedBar::cancelSearch() {
|
||||
if (_searchShown) {
|
||||
if (!_field->getLastText().isEmpty()) {
|
||||
_field->setText(QString());
|
||||
_field->updatePlaceholder();
|
||||
_field->clear();
|
||||
_field->setFocus();
|
||||
applySearch();
|
||||
} else {
|
||||
|
|
|
@ -748,12 +748,8 @@ topBarConnectingAnimation: InfiniteRadialAnimation(defaultInfiniteRadialAnimatio
|
|||
|
||||
infoFeedLeaveIconMargins: margins(10px, 12px, 20px, 10px);
|
||||
|
||||
inviteLinkField: FlatInput(defaultFlatInput) {
|
||||
font: font(fsize);
|
||||
|
||||
height: 44px;
|
||||
textMrg: margins(14px, 12px, 36px, 9px);
|
||||
}
|
||||
inviteLinkFieldHeight: 44px;
|
||||
inviteLinkFieldMargin: margins(14px, 12px, 36px, 9px);
|
||||
inviteLinkThreeDotsIcon: icon {{ "info/edit/dotsmini", dialogsMenuIconFg }};
|
||||
inviteLinkThreeDotsIconOver: icon {{ "info/edit/dotsmini", dialogsMenuIconFgOver }};
|
||||
inviteLinkThreeDots: IconButton(defaultIconButton) {
|
||||
|
|
|
@ -148,15 +148,6 @@ linksDateMargin: margins(0px, 15px, 0px, 2px);
|
|||
linksPhotoSize: 46px;
|
||||
linksPhotoPadding: 12px;
|
||||
|
||||
overviewFilter: FlatInput(defaultFlatInput) {
|
||||
font: font(fsize);
|
||||
icon: fieldSearchIcon;
|
||||
|
||||
width: 240px;
|
||||
height: 32px;
|
||||
textMrg: margins(32px, 3px, 32px, 3px);
|
||||
}
|
||||
|
||||
overviewVideoStatusMargin: 3px;
|
||||
overviewVideoStatusPadding: point(6px, 0px);
|
||||
overviewVideoStatusRadius: 4px;
|
||||
|
|
|
@ -847,21 +847,6 @@ historyVideoMessageProgressOpacity: 0.72;
|
|||
|
||||
historyAdminLogEmptyWidth: 260px;
|
||||
historyAdminLogEmptyPadding: margins(10px, 12px, 10px, 12px);
|
||||
historyAdminLogSearchField: FlatInput(defaultFlatInput) {
|
||||
textColor: windowFg;
|
||||
bgColor: topBarBg;
|
||||
bgActive: topBarBg;
|
||||
|
||||
font: font(fsize);
|
||||
|
||||
borderWidth: 0px;
|
||||
borderColor: topBarBg;
|
||||
borderActive: topBarBg;
|
||||
|
||||
width: 100px;
|
||||
height: 32px;
|
||||
textMrg: margins(0px, 0px, 0px, 0px);
|
||||
}
|
||||
historyAdminLogCancelSearch: CrossButton {
|
||||
width: 40px;
|
||||
height: 54px;
|
||||
|
|
|
@ -297,7 +297,7 @@ void ChooseThemeController::paintEntry(QPainter &p, const Entry &entry) {
|
|||
if (entry.chosen) {
|
||||
auto hq = PainterHighQualityEnabler(p);
|
||||
auto pen = st::activeLineFg->p;
|
||||
const auto width = st::defaultFlatInput.borderWidth;
|
||||
const auto width = st::defaultInputField.borderActive;
|
||||
pen.setWidth(width);
|
||||
p.setPen(pen);
|
||||
const auto add = st::lineWidth + width;
|
||||
|
|
|
@ -21,7 +21,7 @@ InviteLinkLabel::InviteLinkLabel(
|
|||
rpl::producer<QString> text,
|
||||
Fn<base::unique_qptr<PopupMenu>()> createMenu)
|
||||
: _outer(std::in_place, parent) {
|
||||
_outer->resize(_outer->width(), st::inviteLinkField.height);
|
||||
_outer->resize(_outer->width(), st::inviteLinkFieldHeight);
|
||||
const auto label = CreateChild<FlatLabel>(
|
||||
_outer.get(),
|
||||
std::move(text),
|
||||
|
@ -34,7 +34,7 @@ InviteLinkLabel::InviteLinkLabel(
|
|||
|
||||
_outer->widthValue(
|
||||
) | rpl::start_with_next([=](int width) {
|
||||
const auto margin = st::inviteLinkField.textMrg;
|
||||
const auto margin = st::inviteLinkFieldMargin;
|
||||
label->resizeToWidth(width - margin.left() - margin.right());
|
||||
label->moveToLeft(margin.left(), margin.top());
|
||||
button->moveToRight(0, 0);
|
||||
|
@ -44,7 +44,7 @@ InviteLinkLabel::InviteLinkLabel(
|
|||
) | rpl::start_with_next([=] {
|
||||
auto p = QPainter(_outer.get());
|
||||
p.setPen(Qt::NoPen);
|
||||
p.setBrush(st::inviteLinkField.bgColor);
|
||||
p.setBrush(st::filterInputInactiveBg);
|
||||
{
|
||||
PainterHighQualityEnabler hq(p);
|
||||
p.drawRoundedRect(
|
||||
|
|
|
@ -626,28 +626,34 @@ void Generator::paintDialogs() {
|
|||
auto filterRight = st::dialogsFilterSkip + st::dialogsFilterPadding.x();
|
||||
auto filterWidth = _dialogs.x() + _dialogs.width() - filterLeft - filterRight;
|
||||
auto filterAreaHeight = st::topBarHeight;
|
||||
auto filterTop = _dialogs.y() + (filterAreaHeight - st::dialogsFilter.height) / 2;
|
||||
auto filter = QRect(filterLeft, filterTop, filterWidth, st::dialogsFilter.height);
|
||||
auto filterTop = _dialogs.y() + (filterAreaHeight - st::dialogsFilter.heightMin) / 2;
|
||||
auto filter = QRect(filterLeft, filterTop, filterWidth, st::dialogsFilter.heightMin);
|
||||
|
||||
auto pen = st::dialogsFilter.borderColor[_palette]->p;
|
||||
pen.setWidth(st::dialogsFilter.borderWidth);
|
||||
auto pen = st::dialogsFilter.borderFg[_palette]->p;
|
||||
pen.setWidth(st::dialogsFilter.border);
|
||||
_p->setPen(pen);
|
||||
_p->setBrush(st::dialogsFilter.bgColor[_palette]);
|
||||
_p->setBrush(st::dialogsFilter.textBg[_palette]);
|
||||
{
|
||||
PainterHighQualityEnabler hq(*_p);
|
||||
_p->drawRoundedRect(QRectF(filter).marginsRemoved(QMarginsF(st::dialogsFilter.borderWidth / 2., st::dialogsFilter.borderWidth / 2., st::dialogsFilter.borderWidth / 2., st::dialogsFilter.borderWidth / 2.)), st::roundRadiusSmall - (st::dialogsFilter.borderWidth / 2.), st::roundRadiusSmall - (st::dialogsFilter.borderWidth / 2.));
|
||||
}
|
||||
|
||||
if (!st::dialogsFilter.icon.empty()) {
|
||||
st::dialogsFilter.icon[_palette].paint(*_p, filter.x(), filter.y(), _rect.width());
|
||||
const auto radius = st::dialogsFilter.borderRadius
|
||||
- (st::dialogsFilter.border / 2.);
|
||||
_p->drawRoundedRect(
|
||||
QRectF(filter).marginsRemoved(
|
||||
QMarginsF(
|
||||
st::dialogsFilter.border / 2.,
|
||||
st::dialogsFilter.border / 2.,
|
||||
st::dialogsFilter.border / 2.,
|
||||
st::dialogsFilter.border / 2.)),
|
||||
radius,
|
||||
radius);
|
||||
}
|
||||
|
||||
_p->save();
|
||||
_p->setClipRect(filter);
|
||||
auto phRect = QRect(filter.x() + st::dialogsFilter.textMrg.left() + st::dialogsFilter.phPos.x(), filter.y() + st::dialogsFilter.textMrg.top() + st::dialogsFilter.phPos.y(), filter.width() - st::dialogsFilter.textMrg.left() - st::dialogsFilter.textMrg.right(), filter.height() - st::dialogsFilter.textMrg.top() - st::dialogsFilter.textMrg.bottom());;
|
||||
auto phRect = QRect(filter.x() + st::dialogsFilter.textMargins.left() + st::dialogsFilter.placeholderMargins.left(), filter.y() + st::dialogsFilter.textMargins.top() + st::dialogsFilter.placeholderMargins.top(), filter.width() - st::dialogsFilter.textMargins.left() - st::dialogsFilter.textMargins.right(), filter.height() - st::dialogsFilter.textMargins.top() - st::dialogsFilter.textMargins.bottom());
|
||||
_p->setFont(st::dialogsFilter.font);
|
||||
_p->setPen(st::dialogsFilter.phColor[_palette]);
|
||||
_p->drawText(phRect, tr::lng_dlg_filter(tr::now), QTextOption(st::dialogsFilter.phAlign));
|
||||
_p->setPen(st::dialogsFilter.placeholderFg[_palette]);
|
||||
_p->drawText(phRect, tr::lng_dlg_filter(tr::now), QTextOption(st::dialogsFilter.placeholderAlign));
|
||||
_p->restore();
|
||||
_p->setClipping(false);
|
||||
|
||||
|
|
|
@ -1 +1 @@
|
|||
Subproject commit d8b1f46715e5fcaf781b76ecbc386cbe31492287
|
||||
Subproject commit 4ba3000a288772752fcf9b41a618ce5df5a185a5
|
Loading…
Add table
Reference in a new issue