mirror of
https://github.com/telegramdesktop/tdesktop
synced 2025-08-31 06:26:18 +00:00
Create and edit proxy box.
This commit is contained in:
@@ -3944,6 +3944,33 @@ void PortInput::correctValue(
|
||||
setCorrectedText(now, nowCursor, newText, newPos);
|
||||
}
|
||||
|
||||
HexInput::HexInput(QWidget *parent, const style::InputField &st, base::lambda<QString()> placeholderFactory, const QString &val) : MaskedInputField(parent, st, std::move(placeholderFactory), val) {
|
||||
if (!QRegularExpression("^[a-fA-F0-9]+$").match(val).hasMatch()) {
|
||||
setText(QString());
|
||||
}
|
||||
}
|
||||
|
||||
void HexInput::correctValue(
|
||||
const QString &was,
|
||||
int wasCursor,
|
||||
QString &now,
|
||||
int &nowCursor) {
|
||||
QString newText;
|
||||
newText.reserve(now.size());
|
||||
auto newPos = nowCursor;
|
||||
for (auto i = 0, l = now.size(); i < l; ++i) {
|
||||
const auto ch = now[i];
|
||||
if ((ch >= '0' && ch <= '9')
|
||||
|| (ch >= 'a' && ch <= 'f')
|
||||
|| (ch >= 'A' && ch <= 'F')) {
|
||||
newText.append(ch);
|
||||
} else if (i < nowCursor) {
|
||||
--newPos;
|
||||
}
|
||||
}
|
||||
setCorrectedText(now, nowCursor, newText, newPos);
|
||||
}
|
||||
|
||||
UsernameInput::UsernameInput(QWidget *parent, const style::InputField &st, base::lambda<QString()> placeholderFactory, const QString &val, bool isLink) : MaskedInputField(parent, st, std::move(placeholderFactory), val) {
|
||||
setLinkPlaceholder(isLink ? Messenger::Instance().createInternalLink(QString()) : QString());
|
||||
}
|
||||
|
@@ -906,6 +906,19 @@ protected:
|
||||
|
||||
};
|
||||
|
||||
class HexInput : public MaskedInputField {
|
||||
public:
|
||||
HexInput(QWidget *parent, const style::InputField &st, base::lambda<QString()> placeholderFactory, const QString &val);
|
||||
|
||||
protected:
|
||||
void correctValue(
|
||||
const QString &was,
|
||||
int wasCursor,
|
||||
QString &now,
|
||||
int &nowCursor) override;
|
||||
|
||||
};
|
||||
|
||||
class UsernameInput : public MaskedInputField {
|
||||
public:
|
||||
UsernameInput(QWidget *parent, const style::InputField &st, base::lambda<QString()> placeholderFactory, const QString &val, bool isLink);
|
||||
|
@@ -164,8 +164,8 @@ void VerticalLayout::removeChild(RpWidget *child) {
|
||||
auto prev = it - 1;
|
||||
return prev->widget->bottomNoMargins() + prev->margin.bottom();
|
||||
}() - margins.top();
|
||||
for (auto next = it + 1; it != end; ++it) {
|
||||
auto &row = *it;
|
||||
for (auto next = it + 1; next != end; ++next) {
|
||||
auto &row = *next;
|
||||
auto margin = row.margin;
|
||||
auto widget = row.widget.data();
|
||||
widget->moveToLeft(
|
||||
@@ -175,6 +175,7 @@ void VerticalLayout::removeChild(RpWidget *child) {
|
||||
+ widget->heightNoMargins()
|
||||
+ margin.bottom();
|
||||
}
|
||||
it->widget = nullptr;
|
||||
_rows.erase(it);
|
||||
|
||||
resize(width(), margins.top() + top + margins.bottom());
|
||||
|
Reference in New Issue
Block a user