mirror of https://github.com/procxx/kepka.git
Applying the ReplyMarkup returned in updateNewMessage. #2543
Also InputField now can be forced to hide placeholder.
This commit is contained in:
parent
20d04a065e
commit
c773bffec6
|
@ -1105,6 +1105,7 @@ namespace {
|
||||||
auto entities = m.has_entities() ? entitiesFromMTP(m.ventities.c_vector().v) : EntitiesInText();
|
auto entities = m.has_entities() ? entitiesFromMTP(m.ventities.c_vector().v) : EntitiesInText();
|
||||||
existing->setText({ text, entities });
|
existing->setText({ text, entities });
|
||||||
existing->updateMedia(m.has_media() ? (&m.vmedia) : nullptr);
|
existing->updateMedia(m.has_media() ? (&m.vmedia) : nullptr);
|
||||||
|
existing->updateReplyMarkup(m.has_reply_markup() ? (&m.vreply_markup) : nullptr);
|
||||||
existing->setViewsCount(m.has_views() ? m.vviews.v : -1);
|
existing->setViewsCount(m.has_views() ? m.vviews.v : -1);
|
||||||
existing->addToOverview(AddToOverviewNew);
|
existing->addToOverview(AddToOverviewNew);
|
||||||
|
|
||||||
|
|
|
@ -623,6 +623,8 @@ public:
|
||||||
}
|
}
|
||||||
virtual void updateMedia(const MTPMessageMedia *media) {
|
virtual void updateMedia(const MTPMessageMedia *media) {
|
||||||
}
|
}
|
||||||
|
virtual void updateReplyMarkup(const MTPReplyMarkup *markup) {
|
||||||
|
}
|
||||||
virtual int32 addToOverview(AddToOverviewMethod method) {
|
virtual int32 addToOverview(AddToOverviewMethod method) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
|
@ -97,6 +97,9 @@ public:
|
||||||
void applyEdition(const MTPDmessage &message) override;
|
void applyEdition(const MTPDmessage &message) override;
|
||||||
void applyEdition(const MTPDmessageService &message) override;
|
void applyEdition(const MTPDmessageService &message) override;
|
||||||
void updateMedia(const MTPMessageMedia *media) override;
|
void updateMedia(const MTPMessageMedia *media) override;
|
||||||
|
void updateReplyMarkup(const MTPReplyMarkup *markup) override {
|
||||||
|
setReplyMarkup(markup);
|
||||||
|
}
|
||||||
int32 addToOverview(AddToOverviewMethod method) override;
|
int32 addToOverview(AddToOverviewMethod method) override;
|
||||||
void eraseFromOverview() override;
|
void eraseFromOverview() override;
|
||||||
|
|
||||||
|
|
|
@ -454,12 +454,12 @@ void PhonePartInput::paintEvent(QPaintEvent *e) {
|
||||||
FlatInput::paintEvent(e);
|
FlatInput::paintEvent(e);
|
||||||
|
|
||||||
Painter p(this);
|
Painter p(this);
|
||||||
QString t(text());
|
auto t = text();
|
||||||
if (!pattern.isEmpty() && !t.isEmpty()) {
|
if (!_pattern.isEmpty() && !t.isEmpty()) {
|
||||||
QString ph = placeholder().mid(t.size());
|
auto ph = placeholder().mid(t.size());
|
||||||
if (!ph.isEmpty()) {
|
if (!ph.isEmpty()) {
|
||||||
p.setClipRect(rect());
|
p.setClipRect(rect());
|
||||||
QRect phRect(placeholderRect());
|
auto phRect = placeholderRect();
|
||||||
int tw = phFont()->width(t);
|
int tw = phFont()->width(t);
|
||||||
if (tw < phRect.width()) {
|
if (tw < phRect.width()) {
|
||||||
phRect.setLeft(phRect.left() + tw);
|
phRect.setLeft(phRect.left() + tw);
|
||||||
|
@ -488,7 +488,7 @@ void PhonePartInput::correctValue(const QString &was, QString &now) {
|
||||||
}
|
}
|
||||||
if (digitCount > MaxPhoneTailLength) digitCount = MaxPhoneTailLength;
|
if (digitCount > MaxPhoneTailLength) digitCount = MaxPhoneTailLength;
|
||||||
|
|
||||||
bool inPart = !pattern.isEmpty();
|
bool inPart = !_pattern.isEmpty();
|
||||||
int curPart = -1, leftInPart = 0;
|
int curPart = -1, leftInPart = 0;
|
||||||
newText.reserve(oldLen);
|
newText.reserve(oldLen);
|
||||||
for (int i = 0; i < oldLen; ++i) {
|
for (int i = 0; i < oldLen; ++i) {
|
||||||
|
@ -507,8 +507,8 @@ void PhonePartInput::correctValue(const QString &was, QString &now) {
|
||||||
} else {
|
} else {
|
||||||
newText += ' ';
|
newText += ' ';
|
||||||
++curPart;
|
++curPart;
|
||||||
inPart = curPart < pattern.size();
|
inPart = curPart < _pattern.size();
|
||||||
leftInPart = inPart ? (pattern.at(curPart) - 1) : 0;
|
leftInPart = inPart ? (_pattern.at(curPart) - 1) : 0;
|
||||||
|
|
||||||
++oldPos;
|
++oldPos;
|
||||||
}
|
}
|
||||||
|
@ -520,8 +520,8 @@ void PhonePartInput::correctValue(const QString &was, QString &now) {
|
||||||
} else {
|
} else {
|
||||||
newText += ch;
|
newText += ch;
|
||||||
++curPart;
|
++curPart;
|
||||||
inPart = curPart < pattern.size();
|
inPart = curPart < _pattern.size();
|
||||||
leftInPart = inPart ? pattern.at(curPart) : 0;
|
leftInPart = inPart ? _pattern.at(curPart) : 0;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
newText += ch;
|
newText += ch;
|
||||||
|
@ -554,26 +554,26 @@ void PhonePartInput::addedToNumber(const QString &added) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void PhonePartInput::onChooseCode(const QString &code) {
|
void PhonePartInput::onChooseCode(const QString &code) {
|
||||||
pattern = phoneNumberParse(code);
|
_pattern = phoneNumberParse(code);
|
||||||
if (!pattern.isEmpty() && pattern.at(0) == code.size()) {
|
if (!_pattern.isEmpty() && _pattern.at(0) == code.size()) {
|
||||||
pattern.pop_front();
|
_pattern.pop_front();
|
||||||
} else {
|
} else {
|
||||||
pattern.clear();
|
_pattern.clear();
|
||||||
}
|
}
|
||||||
if (pattern.isEmpty()) {
|
if (_pattern.isEmpty()) {
|
||||||
setPlaceholder(lang(lng_phone_ph));
|
setPlaceholder(lang(lng_phone_ph));
|
||||||
} else {
|
} else {
|
||||||
QString ph;
|
QString ph;
|
||||||
ph.reserve(20);
|
ph.reserve(20);
|
||||||
for (int i = 0, l = pattern.size(); i < l; ++i) {
|
for (int i = 0, l = _pattern.size(); i < l; ++i) {
|
||||||
ph.append(' ');
|
ph.append(' ');
|
||||||
ph.append(QString(pattern.at(i), QChar(0x2212)));
|
ph.append(QString(_pattern.at(i), QChar(0x2212)));
|
||||||
}
|
}
|
||||||
setPlaceholder(ph);
|
setPlaceholder(ph);
|
||||||
}
|
}
|
||||||
QString newText(getLastText());
|
auto newText = getLastText();
|
||||||
correctValue(newText, newText);
|
correctValue(newText, newText);
|
||||||
setPlaceholderFast(!pattern.isEmpty());
|
setPlaceholderFast(!_pattern.isEmpty());
|
||||||
updatePlaceholder();
|
updatePlaceholder();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1913,7 +1913,7 @@ void InputField::step_border(float64 ms, bool timer) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void InputField::updatePlaceholder() {
|
void InputField::updatePlaceholder() {
|
||||||
bool placeholderVisible = _oldtext.isEmpty();
|
bool placeholderVisible = _oldtext.isEmpty() && !_forcePlaceholderHidden;
|
||||||
if (placeholderVisible != _placeholderVisible) {
|
if (placeholderVisible != _placeholderVisible) {
|
||||||
_placeholderVisible = placeholderVisible;
|
_placeholderVisible = placeholderVisible;
|
||||||
|
|
||||||
|
@ -1923,6 +1923,11 @@ void InputField::updatePlaceholder() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void InputField::setPlaceholderHidden(bool forcePlaceholderHidden) {
|
||||||
|
_forcePlaceholderHidden = forcePlaceholderHidden;
|
||||||
|
updatePlaceholder();
|
||||||
|
}
|
||||||
|
|
||||||
QMimeData *InputField::InputFieldInner::createMimeDataFromSelection() const {
|
QMimeData *InputField::InputFieldInner::createMimeDataFromSelection() const {
|
||||||
QMimeData *result = new QMimeData();
|
QMimeData *result = new QMimeData();
|
||||||
QTextCursor c(textCursor());
|
QTextCursor c(textCursor());
|
||||||
|
@ -2524,12 +2529,12 @@ void PhoneInput::clearText() {
|
||||||
}
|
}
|
||||||
|
|
||||||
void PhoneInput::paintPlaceholder(Painter &p) {
|
void PhoneInput::paintPlaceholder(Painter &p) {
|
||||||
QString t(getLastText());
|
auto t = getLastText();
|
||||||
if (!pattern.isEmpty() && !t.isEmpty()) {
|
if (!_pattern.isEmpty() && !t.isEmpty()) {
|
||||||
QString ph = placeholder().mid(t.size());
|
auto ph = placeholder().mid(t.size());
|
||||||
if (!ph.isEmpty()) {
|
if (!ph.isEmpty()) {
|
||||||
p.setClipRect(rect());
|
p.setClipRect(rect());
|
||||||
QRect phRect(placeholderRect());
|
auto phRect = placeholderRect();
|
||||||
int tw = phFont()->width(t);
|
int tw = phFont()->width(t);
|
||||||
if (tw < phRect.width()) {
|
if (tw < phRect.width()) {
|
||||||
phRect.setLeft(phRect.left() + tw);
|
phRect.setLeft(phRect.left() + tw);
|
||||||
|
@ -2545,34 +2550,34 @@ void PhoneInput::paintPlaceholder(Painter &p) {
|
||||||
void PhoneInput::correctValue(const QString &was, int32 wasCursor, QString &now, int32 &nowCursor) {
|
void PhoneInput::correctValue(const QString &was, int32 wasCursor, QString &now, int32 &nowCursor) {
|
||||||
QString digits(now);
|
QString digits(now);
|
||||||
digits.replace(QRegularExpression(qsl("[^\\d]")), QString());
|
digits.replace(QRegularExpression(qsl("[^\\d]")), QString());
|
||||||
pattern = phoneNumberParse(digits);
|
_pattern = phoneNumberParse(digits);
|
||||||
|
|
||||||
QString newPlaceholder;
|
QString newPlaceholder;
|
||||||
if (pattern.isEmpty()) {
|
if (_pattern.isEmpty()) {
|
||||||
newPlaceholder = lang(lng_contact_phone);
|
newPlaceholder = lang(lng_contact_phone);
|
||||||
} else if (pattern.size() == 1 && pattern.at(0) == digits.size()) {
|
} else if (_pattern.size() == 1 && _pattern.at(0) == digits.size()) {
|
||||||
newPlaceholder = QString(pattern.at(0) + 2, ' ') + lang(lng_contact_phone);
|
newPlaceholder = QString(_pattern.at(0) + 2, ' ') + lang(lng_contact_phone);
|
||||||
} else {
|
} else {
|
||||||
newPlaceholder.reserve(20);
|
newPlaceholder.reserve(20);
|
||||||
for (int i = 0, l = pattern.size(); i < l; ++i) {
|
for (int i = 0, l = _pattern.size(); i < l; ++i) {
|
||||||
if (i) {
|
if (i) {
|
||||||
newPlaceholder.append(' ');
|
newPlaceholder.append(' ');
|
||||||
} else {
|
} else {
|
||||||
newPlaceholder.append('+');
|
newPlaceholder.append('+');
|
||||||
}
|
}
|
||||||
newPlaceholder.append(i ? QString(pattern.at(i), QChar(0x2212)) : digits.mid(0, pattern.at(i)));
|
newPlaceholder.append(i ? QString(_pattern.at(i), QChar(0x2212)) : digits.mid(0, _pattern.at(i)));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (setPlaceholder(newPlaceholder)) {
|
if (setPlaceholder(newPlaceholder)) {
|
||||||
setPlaceholderFast(!pattern.isEmpty());
|
setPlaceholderFast(!_pattern.isEmpty());
|
||||||
updatePlaceholder();
|
updatePlaceholder();
|
||||||
}
|
}
|
||||||
|
|
||||||
QString newText;
|
QString newText;
|
||||||
int oldPos(nowCursor), newPos(-1), oldLen(now.length()), digitCount = qMin(digits.size(), MaxPhoneCodeLength + MaxPhoneTailLength);
|
int oldPos(nowCursor), newPos(-1), oldLen(now.length()), digitCount = qMin(digits.size(), MaxPhoneCodeLength + MaxPhoneTailLength);
|
||||||
|
|
||||||
bool inPart = !pattern.isEmpty(), plusFound = false;
|
bool inPart = !_pattern.isEmpty(), plusFound = false;
|
||||||
int curPart = 0, leftInPart = inPart ? pattern.at(curPart) : 0;
|
int curPart = 0, leftInPart = inPart ? _pattern.at(curPart) : 0;
|
||||||
newText.reserve(oldLen + 1);
|
newText.reserve(oldLen + 1);
|
||||||
newText.append('+');
|
newText.append('+');
|
||||||
for (int i = 0; i < oldLen; ++i) {
|
for (int i = 0; i < oldLen; ++i) {
|
||||||
|
@ -2591,8 +2596,8 @@ void PhoneInput::correctValue(const QString &was, int32 wasCursor, QString &now,
|
||||||
} else {
|
} else {
|
||||||
newText += ' ';
|
newText += ' ';
|
||||||
++curPart;
|
++curPart;
|
||||||
inPart = curPart < pattern.size();
|
inPart = curPart < _pattern.size();
|
||||||
leftInPart = inPart ? (pattern.at(curPart) - 1) : 0;
|
leftInPart = inPart ? (_pattern.at(curPart) - 1) : 0;
|
||||||
|
|
||||||
++oldPos;
|
++oldPos;
|
||||||
}
|
}
|
||||||
|
@ -2604,8 +2609,8 @@ void PhoneInput::correctValue(const QString &was, int32 wasCursor, QString &now,
|
||||||
} else {
|
} else {
|
||||||
newText += ch;
|
newText += ch;
|
||||||
++curPart;
|
++curPart;
|
||||||
inPart = curPart < pattern.size();
|
inPart = curPart < _pattern.size();
|
||||||
leftInPart = inPart ? pattern.at(curPart) : 0;
|
leftInPart = inPart ? _pattern.at(curPart) : 0;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
newText += ch;
|
newText += ch;
|
||||||
|
|
|
@ -117,25 +117,20 @@ class CountryCodeInput : public FlatInput {
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
CountryCodeInput(QWidget *parent, const style::flatInput &st);
|
CountryCodeInput(QWidget *parent, const style::flatInput &st);
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
|
|
||||||
void startErasing(QKeyEvent *e);
|
void startErasing(QKeyEvent *e);
|
||||||
void codeSelected(const QString &code);
|
void codeSelected(const QString &code);
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
|
|
||||||
void codeChanged(const QString &code);
|
void codeChanged(const QString &code);
|
||||||
void addedToNumber(const QString &added);
|
void addedToNumber(const QString &added);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
void correctValue(const QString &was, QString &now) override;
|
||||||
void correctValue(const QString &was, QString &now);
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
bool _nosignal;
|
bool _nosignal;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
@ -144,28 +139,23 @@ class PhonePartInput : public FlatInput {
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
PhonePartInput(QWidget *parent, const style::flatInput &st);
|
PhonePartInput(QWidget *parent, const style::flatInput &st);
|
||||||
|
|
||||||
void paintEvent(QPaintEvent *e);
|
|
||||||
void keyPressEvent(QKeyEvent *e);
|
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
|
|
||||||
void addedToNumber(const QString &added);
|
void addedToNumber(const QString &added);
|
||||||
void onChooseCode(const QString &code);
|
void onChooseCode(const QString &code);
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
|
|
||||||
void voidBackspace(QKeyEvent *e);
|
void voidBackspace(QKeyEvent *e);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
void paintEvent(QPaintEvent *e) override;
|
||||||
|
void keyPressEvent(QKeyEvent *e) override;
|
||||||
|
|
||||||
void correctValue(const QString &was, QString &now);
|
void correctValue(const QString &was, QString &now) override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
QVector<int> _pattern;
|
||||||
QVector<int> pattern;
|
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -179,16 +169,8 @@ class InputArea : public TWidget {
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
InputArea(QWidget *parent, const style::InputArea &st, const QString &ph = QString(), const QString &val = QString());
|
InputArea(QWidget *parent, const style::InputArea &st, const QString &ph = QString(), const QString &val = QString());
|
||||||
|
|
||||||
void touchEvent(QTouchEvent *e);
|
|
||||||
void paintEvent(QPaintEvent *e);
|
|
||||||
void focusInEvent(QFocusEvent *e);
|
|
||||||
void mousePressEvent(QMouseEvent *e);
|
|
||||||
void contextMenuEvent(QContextMenuEvent *e);
|
|
||||||
void resizeEvent(QResizeEvent *e);
|
|
||||||
|
|
||||||
void showError();
|
void showError();
|
||||||
|
|
||||||
void setMaxLength(int32 maxLength) {
|
void setMaxLength(int32 maxLength) {
|
||||||
|
@ -241,7 +223,6 @@ public:
|
||||||
}
|
}
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
|
|
||||||
void onTouchTimer();
|
void onTouchTimer();
|
||||||
|
|
||||||
void onDocumentContentsChange(int position, int charsRemoved, int charsAdded);
|
void onDocumentContentsChange(int position, int charsRemoved, int charsAdded);
|
||||||
|
@ -251,7 +232,6 @@ public slots:
|
||||||
void onRedoAvailable(bool avail);
|
void onRedoAvailable(bool avail);
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
|
|
||||||
void changed();
|
void changed();
|
||||||
void submitted(bool ctrlShiftEnter);
|
void submitted(bool ctrlShiftEnter);
|
||||||
void cancelled();
|
void cancelled();
|
||||||
|
@ -262,7 +242,6 @@ signals:
|
||||||
void resized();
|
void resized();
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
|
||||||
void insertEmoji(EmojiPtr emoji, QTextCursor c);
|
void insertEmoji(EmojiPtr emoji, QTextCursor c);
|
||||||
TWidget *tparent() {
|
TWidget *tparent() {
|
||||||
return qobject_cast<TWidget*>(parentWidget());
|
return qobject_cast<TWidget*>(parentWidget());
|
||||||
|
@ -271,8 +250,14 @@ protected:
|
||||||
return qobject_cast<const TWidget*>(parentWidget());
|
return qobject_cast<const TWidget*>(parentWidget());
|
||||||
}
|
}
|
||||||
|
|
||||||
private:
|
void touchEvent(QTouchEvent *e);
|
||||||
|
void paintEvent(QPaintEvent *e) override;
|
||||||
|
void focusInEvent(QFocusEvent *e) override;
|
||||||
|
void mousePressEvent(QMouseEvent *e) override;
|
||||||
|
void contextMenuEvent(QContextMenuEvent *e) override;
|
||||||
|
void resizeEvent(QResizeEvent *e) override;
|
||||||
|
|
||||||
|
private:
|
||||||
int32 _maxLength;
|
int32 _maxLength;
|
||||||
bool heightAutoupdated();
|
bool heightAutoupdated();
|
||||||
void checkContentHeight();
|
void checkContentHeight();
|
||||||
|
@ -282,23 +267,24 @@ private:
|
||||||
public:
|
public:
|
||||||
InputAreaInner(InputArea *parent);
|
InputAreaInner(InputArea *parent);
|
||||||
|
|
||||||
bool viewportEvent(QEvent *e);
|
|
||||||
void focusInEvent(QFocusEvent *e);
|
|
||||||
void focusOutEvent(QFocusEvent *e);
|
|
||||||
void keyPressEvent(QKeyEvent *e);
|
|
||||||
void paintEvent(QPaintEvent *e);
|
|
||||||
void contextMenuEvent(QContextMenuEvent *e);
|
|
||||||
|
|
||||||
QMimeData *createMimeDataFromSelection() const;
|
|
||||||
|
|
||||||
QVariant loadResource(int type, const QUrl &name);
|
QVariant loadResource(int type, const QUrl &name);
|
||||||
|
|
||||||
private:
|
protected:
|
||||||
|
bool viewportEvent(QEvent *e) override;
|
||||||
|
void focusInEvent(QFocusEvent *e) override;
|
||||||
|
void focusOutEvent(QFocusEvent *e) override;
|
||||||
|
void keyPressEvent(QKeyEvent *e) override;
|
||||||
|
void paintEvent(QPaintEvent *e) override;
|
||||||
|
void contextMenuEvent(QContextMenuEvent *e) override;
|
||||||
|
|
||||||
|
QMimeData *createMimeDataFromSelection() const override;
|
||||||
|
|
||||||
|
private:
|
||||||
InputArea *f() const {
|
InputArea *f() const {
|
||||||
return static_cast<InputArea*>(parentWidget());
|
return static_cast<InputArea*>(parentWidget());
|
||||||
}
|
}
|
||||||
friend class InputArea;
|
friend class InputArea;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
void focusInInner();
|
void focusInInner();
|
||||||
|
@ -337,22 +323,15 @@ private:
|
||||||
QPoint _touchStart;
|
QPoint _touchStart;
|
||||||
|
|
||||||
bool _correcting;
|
bool _correcting;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
class InputField : public TWidget {
|
class InputField : public TWidget {
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
InputField(QWidget *parent, const style::InputField &st, const QString &ph = QString(), const QString &val = QString());
|
InputField(QWidget *parent, const style::InputField &st, const QString &ph = QString(), const QString &val = QString());
|
||||||
|
|
||||||
void touchEvent(QTouchEvent *e);
|
|
||||||
void paintEvent(QPaintEvent *e);
|
|
||||||
void focusInEvent(QFocusEvent *e);
|
|
||||||
void mousePressEvent(QMouseEvent *e);
|
|
||||||
void contextMenuEvent(QContextMenuEvent *e);
|
|
||||||
void resizeEvent(QResizeEvent *e);
|
|
||||||
|
|
||||||
void setMaxLength(int32 maxLength) {
|
void setMaxLength(int32 maxLength) {
|
||||||
_maxLength = maxLength;
|
_maxLength = maxLength;
|
||||||
}
|
}
|
||||||
|
@ -363,6 +342,7 @@ public:
|
||||||
return _oldtext;
|
return _oldtext;
|
||||||
}
|
}
|
||||||
void updatePlaceholder();
|
void updatePlaceholder();
|
||||||
|
void setPlaceholderHidden(bool forcePlaceholderHidden);
|
||||||
|
|
||||||
void step_placeholderFg(float64 ms, bool timer);
|
void step_placeholderFg(float64 ms, bool timer);
|
||||||
void step_placeholderShift(float64 ms, bool timer);
|
void step_placeholderShift(float64 ms, bool timer);
|
||||||
|
@ -412,7 +392,6 @@ public:
|
||||||
}
|
}
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
|
|
||||||
void onTouchTimer();
|
void onTouchTimer();
|
||||||
|
|
||||||
void onDocumentContentsChange(int position, int charsRemoved, int charsAdded);
|
void onDocumentContentsChange(int position, int charsRemoved, int charsAdded);
|
||||||
|
@ -424,7 +403,6 @@ public slots:
|
||||||
void selectAll();
|
void selectAll();
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
|
|
||||||
void changed();
|
void changed();
|
||||||
void submitted(bool ctrlShiftEnter);
|
void submitted(bool ctrlShiftEnter);
|
||||||
void cancelled();
|
void cancelled();
|
||||||
|
@ -434,7 +412,6 @@ signals:
|
||||||
void blurred();
|
void blurred();
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
|
||||||
void insertEmoji(EmojiPtr emoji, QTextCursor c);
|
void insertEmoji(EmojiPtr emoji, QTextCursor c);
|
||||||
TWidget *tparent() {
|
TWidget *tparent() {
|
||||||
return qobject_cast<TWidget*>(parentWidget());
|
return qobject_cast<TWidget*>(parentWidget());
|
||||||
|
@ -443,32 +420,40 @@ protected:
|
||||||
return qobject_cast<const TWidget*>(parentWidget());
|
return qobject_cast<const TWidget*>(parentWidget());
|
||||||
}
|
}
|
||||||
|
|
||||||
private:
|
void touchEvent(QTouchEvent *e);
|
||||||
|
void paintEvent(QPaintEvent *e) override;
|
||||||
|
void focusInEvent(QFocusEvent *e) override;
|
||||||
|
void mousePressEvent(QMouseEvent *e) override;
|
||||||
|
void contextMenuEvent(QContextMenuEvent *e) override;
|
||||||
|
void resizeEvent(QResizeEvent *e) override;
|
||||||
|
|
||||||
|
private:
|
||||||
int32 _maxLength;
|
int32 _maxLength;
|
||||||
|
bool _forcePlaceholderHidden = false;
|
||||||
|
|
||||||
friend class InputFieldInner;
|
friend class InputFieldInner;
|
||||||
class InputFieldInner : public QTextEdit {
|
class InputFieldInner : public QTextEdit {
|
||||||
public:
|
public:
|
||||||
InputFieldInner(InputField *parent);
|
InputFieldInner(InputField *parent);
|
||||||
|
|
||||||
bool viewportEvent(QEvent *e);
|
|
||||||
void focusInEvent(QFocusEvent *e);
|
|
||||||
void focusOutEvent(QFocusEvent *e);
|
|
||||||
void keyPressEvent(QKeyEvent *e);
|
|
||||||
void paintEvent(QPaintEvent *e);
|
|
||||||
void contextMenuEvent(QContextMenuEvent *e);
|
|
||||||
|
|
||||||
QMimeData *createMimeDataFromSelection() const;
|
QMimeData *createMimeDataFromSelection() const;
|
||||||
|
|
||||||
QVariant loadResource(int type, const QUrl &name);
|
QVariant loadResource(int type, const QUrl &name);
|
||||||
|
|
||||||
private:
|
protected:
|
||||||
|
bool viewportEvent(QEvent *e) override;
|
||||||
|
void focusInEvent(QFocusEvent *e) override;
|
||||||
|
void focusOutEvent(QFocusEvent *e) override;
|
||||||
|
void keyPressEvent(QKeyEvent *e) override;
|
||||||
|
void paintEvent(QPaintEvent *e) override;
|
||||||
|
void contextMenuEvent(QContextMenuEvent *e) override;
|
||||||
|
|
||||||
|
private:
|
||||||
InputField *f() const {
|
InputField *f() const {
|
||||||
return static_cast<InputField*>(parentWidget());
|
return static_cast<InputField*>(parentWidget());
|
||||||
}
|
}
|
||||||
friend class InputField;
|
friend class InputField;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
void focusInInner();
|
void focusInInner();
|
||||||
|
@ -624,54 +609,46 @@ private:
|
||||||
|
|
||||||
class PasswordField : public MaskedInputField {
|
class PasswordField : public MaskedInputField {
|
||||||
public:
|
public:
|
||||||
|
|
||||||
PasswordField(QWidget *parent, const style::InputField &st, const QString &ph = QString(), const QString &val = QString());
|
PasswordField(QWidget *parent, const style::InputField &st, const QString &ph = QString(), const QString &val = QString());
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
class PortInput : public MaskedInputField {
|
class PortInput : public MaskedInputField {
|
||||||
public:
|
public:
|
||||||
|
|
||||||
PortInput(QWidget *parent, const style::InputField &st, const QString &ph, const QString &val);
|
PortInput(QWidget *parent, const style::InputField &st, const QString &ph, const QString &val);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
void correctValue(const QString &was, int32 wasCursor, QString &now, int32 &nowCursor) override;
|
||||||
void correctValue(const QString &was, int32 wasCursor, QString &now, int32 &nowCursor);
|
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
class UsernameInput : public MaskedInputField {
|
class UsernameInput : public MaskedInputField {
|
||||||
public:
|
public:
|
||||||
|
|
||||||
UsernameInput(QWidget *parent, const style::InputField &st, const QString &ph, const QString &val, bool isLink);
|
UsernameInput(QWidget *parent, const style::InputField &st, const QString &ph, const QString &val, bool isLink);
|
||||||
void paintPlaceholder(Painter &p);
|
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
void correctValue(const QString &was, int32 wasCursor, QString &now, int32 &nowCursor) override;
|
||||||
void correctValue(const QString &was, int32 wasCursor, QString &now, int32 &nowCursor);
|
void paintPlaceholder(Painter &p) override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
QString _linkPlaceholder;
|
QString _linkPlaceholder;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
class PhoneInput : public MaskedInputField {
|
class PhoneInput : public MaskedInputField {
|
||||||
public:
|
public:
|
||||||
|
|
||||||
PhoneInput(QWidget *parent, const style::InputField &st, const QString &ph, const QString &val);
|
PhoneInput(QWidget *parent, const style::InputField &st, const QString &ph, const QString &val);
|
||||||
|
|
||||||
void focusInEvent(QFocusEvent *e);
|
|
||||||
void clearText();
|
void clearText();
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
void focusInEvent(QFocusEvent *e) override;
|
||||||
|
|
||||||
void paintPlaceholder(Painter &p);
|
void correctValue(const QString &was, int32 wasCursor, QString &now, int32 &nowCursor) override;
|
||||||
void correctValue(const QString &was, int32 wasCursor, QString &now, int32 &nowCursor);
|
void paintPlaceholder(Painter &p) override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
QString _defaultPlaceholder;
|
QString _defaultPlaceholder;
|
||||||
QVector<int> pattern;
|
QVector<int> _pattern;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in New Issue