mirror of
https://github.com/AyuGram/AyuGramDesktop.git
synced 2025-06-05 06:33:57 +02:00
Fix build with updated lib_ui.
This commit is contained in:
parent
ad6e34f3a4
commit
7357b40ba1
4 changed files with 3 additions and 42 deletions
|
@ -1068,7 +1068,7 @@ void EditTagBox(
|
||||||
}
|
}
|
||||||
}, field->lifetime());
|
}, field->lifetime());
|
||||||
|
|
||||||
AddLengthLimitLabel(field, kTagNameLimit);
|
Ui::AddLengthLimitLabel(field, kTagNameLimit);
|
||||||
|
|
||||||
const auto save = [=] {
|
const auto save = [=] {
|
||||||
const auto text = field->getLastText();
|
const auto text = field->getLastText();
|
||||||
|
@ -1828,40 +1828,4 @@ bool ItemHasTtl(HistoryItem *item) {
|
||||||
: false;
|
: false;
|
||||||
}
|
}
|
||||||
|
|
||||||
void AddLengthLimitLabel(not_null<Ui::InputField*> field, int limit) {
|
|
||||||
struct State {
|
|
||||||
rpl::variable<int> length;
|
|
||||||
};
|
|
||||||
const auto state = field->lifetime().make_state<State>();
|
|
||||||
state->length = rpl::single(
|
|
||||||
rpl::empty
|
|
||||||
) | rpl::then(field->changes()) | rpl::map([=] {
|
|
||||||
return int(field->getLastText().size());
|
|
||||||
});
|
|
||||||
auto warningText = state->length.value() | rpl::map([=](int count) {
|
|
||||||
const auto threshold = std::min(limit / 2, 9);
|
|
||||||
const auto left = limit - count;
|
|
||||||
return (left < threshold) ? QString::number(left) : QString();
|
|
||||||
});
|
|
||||||
const auto warning = Ui::CreateChild<Ui::FlatLabel>(
|
|
||||||
field.get(),
|
|
||||||
std::move(warningText),
|
|
||||||
st::editTagLimit);
|
|
||||||
state->length.value() | rpl::map(
|
|
||||||
rpl::mappers::_1 > limit
|
|
||||||
) | rpl::start_with_next([=](bool exceeded) {
|
|
||||||
warning->setTextColorOverride(exceeded
|
|
||||||
? st::attentionButtonFg->c
|
|
||||||
: std::optional<QColor>());
|
|
||||||
}, warning->lifetime());
|
|
||||||
rpl::combine(
|
|
||||||
field->sizeValue(),
|
|
||||||
warning->sizeValue()
|
|
||||||
) | rpl::start_with_next([=] {
|
|
||||||
warning->moveToRight(0, 0);
|
|
||||||
}, warning->lifetime());
|
|
||||||
warning->setAttribute(Qt::WA_TransparentForMouseEvents);
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
} // namespace HistoryView
|
} // namespace HistoryView
|
||||||
|
|
|
@ -123,6 +123,4 @@ void AddEmojiPacksAction(
|
||||||
|
|
||||||
[[nodiscard]] bool ItemHasTtl(HistoryItem *item);
|
[[nodiscard]] bool ItemHasTtl(HistoryItem *item);
|
||||||
|
|
||||||
void AddLengthLimitLabel(not_null<Ui::InputField*> field, int limit);
|
|
||||||
|
|
||||||
} // namespace HistoryView
|
} // namespace HistoryView
|
||||||
|
|
|
@ -164,7 +164,7 @@ private:
|
||||||
current),
|
current),
|
||||||
st::settingsChatIntroFieldMargins);
|
st::settingsChatIntroFieldMargins);
|
||||||
field->setMaxLength(limit);
|
field->setMaxLength(limit);
|
||||||
AddLengthLimitLabel(field, limit);
|
Ui::AddLengthLimitLabel(field, limit);
|
||||||
return field;
|
return field;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -11,7 +11,6 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||||
#include "core/application.h"
|
#include "core/application.h"
|
||||||
#include "data/business/data_shortcut_messages.h"
|
#include "data/business/data_shortcut_messages.h"
|
||||||
#include "data/data_session.h"
|
#include "data/data_session.h"
|
||||||
#include "history/view/history_view_context_menu.h" // AddLengthLimitLabel.
|
|
||||||
#include "lang/lang_keys.h"
|
#include "lang/lang_keys.h"
|
||||||
#include "main/main_account.h"
|
#include "main/main_account.h"
|
||||||
#include "main/main_session.h"
|
#include "main/main_session.h"
|
||||||
|
@ -214,7 +213,7 @@ void EditShortcutNameBox(
|
||||||
field->selectAll();
|
field->selectAll();
|
||||||
field->setMaxLength(kShortcutLimit * 2);
|
field->setMaxLength(kShortcutLimit * 2);
|
||||||
|
|
||||||
HistoryView::AddLengthLimitLabel(field, kShortcutLimit);
|
Ui::AddLengthLimitLabel(field, kShortcutLimit);
|
||||||
|
|
||||||
const auto callback = [=] {
|
const auto callback = [=] {
|
||||||
const auto name = field->getLastText().trimmed();
|
const auto name = field->getLastText().trimmed();
|
||||||
|
|
Loading…
Add table
Reference in a new issue