2014-05-30 08:53:19 +00:00
|
|
|
/*
|
|
|
|
This file is part of Telegram Desktop,
|
2014-12-01 10:47:38 +00:00
|
|
|
the official desktop version of Telegram messaging app, see https://telegram.org
|
2014-05-30 08:53:19 +00:00
|
|
|
|
|
|
|
Telegram Desktop is free software: you can redistribute it and/or modify
|
|
|
|
it under the terms of the GNU General Public License as published by
|
|
|
|
the Free Software Foundation, either version 3 of the License, or
|
|
|
|
(at your option) any later version.
|
|
|
|
|
|
|
|
It is distributed in the hope that it will be useful,
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
GNU General Public License for more details.
|
|
|
|
|
2015-10-03 13:16:42 +00:00
|
|
|
In addition, as a special exception, the copyright holders give permission
|
|
|
|
to link the code of portions of this program with the OpenSSL library.
|
|
|
|
|
2014-05-30 08:53:19 +00:00
|
|
|
Full license: https://github.com/telegramdesktop/tdesktop/blob/master/LICENSE
|
2017-01-11 18:31:31 +00:00
|
|
|
Copyright (c) 2014-2017 John Preston, https://desktop.telegram.org
|
2014-05-30 08:53:19 +00:00
|
|
|
*/
|
|
|
|
#pragma once
|
|
|
|
|
2016-11-15 11:56:49 +00:00
|
|
|
#include "styles/style_widgets.h"
|
|
|
|
|
|
|
|
class UserData;
|
|
|
|
|
|
|
|
namespace Ui {
|
|
|
|
|
|
|
|
static UserData * const LookingUpInlineBot = SharedMemoryLocation<UserData, 0>();
|
|
|
|
|
2017-02-11 11:24:37 +00:00
|
|
|
class FlatTextarea : public TWidgetHelper<QTextEdit>, private base::Subscriber {
|
2016-11-15 11:56:49 +00:00
|
|
|
Q_OBJECT
|
|
|
|
|
|
|
|
public:
|
|
|
|
using TagList = TextWithTags::Tags;
|
|
|
|
|
|
|
|
static QByteArray serializeTagsList(const TagList &tags);
|
|
|
|
static TagList deserializeTagsList(QByteArray data, int textLength);
|
|
|
|
static QString tagsMimeType();
|
|
|
|
|
|
|
|
FlatTextarea(QWidget *parent, const style::FlatTextarea &st, const QString &ph = QString(), const QString &val = QString(), const TagList &tags = TagList());
|
|
|
|
|
|
|
|
void setMaxLength(int32 maxLength);
|
|
|
|
void setMinHeight(int32 minHeight);
|
|
|
|
void setMaxHeight(int32 maxHeight);
|
|
|
|
|
|
|
|
void setPlaceholder(const QString &ph, int32 afterSymbols = 0);
|
|
|
|
void updatePlaceholder();
|
|
|
|
void finishPlaceholder();
|
|
|
|
|
|
|
|
QRect getTextRect() const;
|
|
|
|
int32 fakeMargin() const;
|
|
|
|
|
|
|
|
QSize sizeHint() const override;
|
|
|
|
QSize minimumSizeHint() const override;
|
|
|
|
|
|
|
|
EmojiPtr getSingleEmoji() const;
|
|
|
|
QString getMentionHashtagBotCommandPart(bool &start) const;
|
|
|
|
|
|
|
|
// Get the current inline bot and request string for it.
|
|
|
|
// The *outInlineBot can be filled by LookingUpInlineBot shared ptr.
|
|
|
|
// In that case the caller should lookup the bot by *outInlineBotUsername.
|
|
|
|
QString getInlineBotQuery(UserData **outInlineBot, QString *outInlineBotUsername) const;
|
|
|
|
|
|
|
|
void removeSingleEmoji();
|
|
|
|
bool hasText() const;
|
|
|
|
|
|
|
|
bool isUndoAvailable() const;
|
|
|
|
bool isRedoAvailable() const;
|
|
|
|
|
|
|
|
void parseLinks();
|
|
|
|
QStringList linksList() const;
|
|
|
|
|
|
|
|
void insertFromMimeData(const QMimeData *source) override;
|
|
|
|
|
|
|
|
QMimeData *createMimeDataFromSelection() const override;
|
|
|
|
|
|
|
|
enum class SubmitSettings {
|
|
|
|
None,
|
|
|
|
Enter,
|
|
|
|
CtrlEnter,
|
|
|
|
Both,
|
|
|
|
};
|
|
|
|
void setSubmitSettings(SubmitSettings settings);
|
|
|
|
|
|
|
|
const TextWithTags &getTextWithTags() const {
|
|
|
|
return _lastTextWithTags;
|
|
|
|
}
|
|
|
|
TextWithTags getTextWithTagsPart(int start, int end = -1);
|
|
|
|
void insertTag(const QString &text, QString tagId = QString());
|
|
|
|
|
|
|
|
bool isEmpty() const {
|
|
|
|
return _lastTextWithTags.text.isEmpty();
|
|
|
|
}
|
|
|
|
|
|
|
|
enum UndoHistoryAction {
|
|
|
|
AddToUndoHistory,
|
|
|
|
MergeWithUndoHistory,
|
|
|
|
ClearUndoHistory
|
|
|
|
};
|
|
|
|
void setTextWithTags(const TextWithTags &textWithTags, UndoHistoryAction undoHistoryAction = AddToUndoHistory);
|
|
|
|
|
|
|
|
// If you need to make some preparations of tags before putting them to QMimeData
|
|
|
|
// (and then to clipboard or to drag-n-drop object), here is a strategy for that.
|
|
|
|
class TagMimeProcessor {
|
|
|
|
public:
|
|
|
|
virtual QString mimeTagFromTag(const QString &tagId) = 0;
|
|
|
|
virtual QString tagFromMimeTag(const QString &mimeTag) = 0;
|
|
|
|
virtual ~TagMimeProcessor() {
|
|
|
|
}
|
|
|
|
};
|
2017-02-21 13:45:56 +00:00
|
|
|
void setTagMimeProcessor(std::unique_ptr<TagMimeProcessor> &&processor);
|
2016-11-15 11:56:49 +00:00
|
|
|
|
2016-11-24 19:28:23 +00:00
|
|
|
public slots:
|
2016-11-15 11:56:49 +00:00
|
|
|
void onTouchTimer();
|
|
|
|
|
|
|
|
void onDocumentContentsChange(int position, int charsRemoved, int charsAdded);
|
|
|
|
void onDocumentContentsChanged();
|
|
|
|
|
|
|
|
void onUndoAvailable(bool avail);
|
|
|
|
void onRedoAvailable(bool avail);
|
|
|
|
|
|
|
|
signals:
|
|
|
|
void resized();
|
|
|
|
void changed();
|
|
|
|
void submitted(bool ctrlShiftEnter);
|
|
|
|
void cancelled();
|
|
|
|
void tabbed();
|
|
|
|
void spacedReturnedPasted();
|
|
|
|
void linksChanged();
|
|
|
|
|
|
|
|
protected:
|
|
|
|
bool viewportEvent(QEvent *e) override;
|
|
|
|
void touchEvent(QTouchEvent *e);
|
|
|
|
void paintEvent(QPaintEvent *e) override;
|
|
|
|
void focusInEvent(QFocusEvent *e) override;
|
|
|
|
void focusOutEvent(QFocusEvent *e) override;
|
|
|
|
void keyPressEvent(QKeyEvent *e) override;
|
|
|
|
void resizeEvent(QResizeEvent *e) override;
|
|
|
|
void mousePressEvent(QMouseEvent *e) override;
|
|
|
|
void dropEvent(QDropEvent *e) override;
|
|
|
|
void contextMenuEvent(QContextMenuEvent *e) override;
|
|
|
|
|
|
|
|
virtual void correctValue(const QString &was, QString &now, TagList &nowTags) {
|
|
|
|
}
|
|
|
|
|
|
|
|
void insertEmoji(EmojiPtr emoji, QTextCursor c);
|
|
|
|
|
|
|
|
QVariant loadResource(int type, const QUrl &name) override;
|
|
|
|
|
|
|
|
void checkContentHeight();
|
|
|
|
|
|
|
|
private:
|
2016-12-31 13:34:41 +00:00
|
|
|
void updatePalette();
|
|
|
|
|
2016-11-15 11:56:49 +00:00
|
|
|
// "start" and "end" are in coordinates of text where emoji are replaced
|
|
|
|
// by ObjectReplacementCharacter. If "end" = -1 means get text till the end.
|
|
|
|
QString getTextPart(int start, int end, TagList *outTagsList, bool *outTagsChanged = nullptr) const;
|
|
|
|
|
|
|
|
void getSingleEmojiFragment(QString &text, QTextFragment &fragment) const;
|
|
|
|
|
|
|
|
// After any characters added we must postprocess them. This includes:
|
|
|
|
// 1. Replacing font family to semibold for ~ characters, if we used Open Sans 13px.
|
|
|
|
// 2. Replacing font family from semibold for all non-~ characters, if we used ...
|
|
|
|
// 3. Replacing emoji code sequences by ObjectReplacementCharacters with emoji pics.
|
|
|
|
// 4. Interrupting tags in which the text was inserted by any char except a letter.
|
|
|
|
// 5. Applying tags from "_insertedTags" in case we pasted text with tags, not just text.
|
|
|
|
// Rule 4 applies only if we inserted chars not in the middle of a tag (but at the end).
|
|
|
|
void processFormatting(int changedPosition, int changedEnd);
|
|
|
|
|
|
|
|
bool heightAutoupdated();
|
|
|
|
|
|
|
|
int placeholderSkipWidth() const;
|
|
|
|
|
|
|
|
int _minHeight = -1; // < 0 - no autosize
|
|
|
|
int _maxHeight = -1;
|
|
|
|
int _maxLength = -1;
|
|
|
|
SubmitSettings _submitSettings = SubmitSettings::Enter;
|
|
|
|
|
|
|
|
QString _ph, _phelided;
|
|
|
|
int _phAfter = 0;
|
2017-01-14 18:50:16 +00:00
|
|
|
bool _focused = false;
|
2016-12-02 19:16:35 +00:00
|
|
|
bool _placeholderVisible = true;
|
2016-12-07 13:32:25 +00:00
|
|
|
Animation _a_placeholderFocused;
|
|
|
|
Animation _a_placeholderVisible;
|
2016-11-15 11:56:49 +00:00
|
|
|
|
|
|
|
TextWithTags _lastTextWithTags;
|
|
|
|
|
|
|
|
// Tags list which we should apply while setText() call or insert from mime data.
|
|
|
|
TagList _insertedTags;
|
|
|
|
bool _insertedTagsAreFromMime;
|
|
|
|
|
|
|
|
// Override insert position and charsAdded from complex text editing
|
|
|
|
// (like drag-n-drop in the same text edit field).
|
|
|
|
int _realInsertPosition = -1;
|
|
|
|
int _realCharsAdded = 0;
|
|
|
|
|
2017-02-21 13:45:56 +00:00
|
|
|
std::unique_ptr<TagMimeProcessor> _tagMimeProcessor;
|
2016-11-15 11:56:49 +00:00
|
|
|
|
|
|
|
const style::FlatTextarea &_st;
|
|
|
|
|
|
|
|
bool _undoAvailable = false;
|
|
|
|
bool _redoAvailable = false;
|
|
|
|
bool _inDrop = false;
|
|
|
|
bool _inHeightCheck = false;
|
|
|
|
|
|
|
|
int _fakeMargin = 0;
|
|
|
|
|
|
|
|
QTimer _touchTimer;
|
|
|
|
bool _touchPress = false;
|
|
|
|
bool _touchRightButton = false;
|
|
|
|
bool _touchMove = false;
|
|
|
|
QPoint _touchStart;
|
|
|
|
|
|
|
|
bool _correcting = false;
|
|
|
|
|
|
|
|
struct LinkRange {
|
|
|
|
int start;
|
|
|
|
int length;
|
|
|
|
};
|
|
|
|
friend bool operator==(const LinkRange &a, const LinkRange &b);
|
|
|
|
friend bool operator!=(const LinkRange &a, const LinkRange &b);
|
|
|
|
using LinkRanges = QVector<LinkRange>;
|
|
|
|
LinkRanges _links;
|
|
|
|
};
|
|
|
|
|
|
|
|
inline bool operator==(const FlatTextarea::LinkRange &a, const FlatTextarea::LinkRange &b) {
|
|
|
|
return (a.start == b.start) && (a.length == b.length);
|
|
|
|
}
|
|
|
|
inline bool operator!=(const FlatTextarea::LinkRange &a, const FlatTextarea::LinkRange &b) {
|
|
|
|
return !(a == b);
|
|
|
|
}
|
2014-05-30 08:53:19 +00:00
|
|
|
|
2017-02-11 11:24:37 +00:00
|
|
|
class FlatInput : public TWidgetHelper<QLineEdit>, private base::Subscriber {
|
2014-05-30 08:53:19 +00:00
|
|
|
Q_OBJECT
|
|
|
|
|
|
|
|
public:
|
2016-11-15 11:56:49 +00:00
|
|
|
FlatInput(QWidget *parent, const style::FlatInput &st, const QString &ph = QString(), const QString &val = QString());
|
2014-05-30 08:53:19 +00:00
|
|
|
|
|
|
|
void updatePlaceholder();
|
2015-07-21 14:55:23 +00:00
|
|
|
const QString &placeholder() const;
|
|
|
|
QRect placeholderRect() const;
|
2014-05-30 08:53:19 +00:00
|
|
|
|
|
|
|
QRect getTextRect() const;
|
|
|
|
|
2016-04-14 13:03:03 +00:00
|
|
|
QSize sizeHint() const override;
|
|
|
|
QSize minimumSizeHint() const override;
|
2014-05-30 08:53:19 +00:00
|
|
|
|
2014-06-20 07:06:21 +00:00
|
|
|
void customUpDown(bool isCustom);
|
2015-10-06 19:49:23 +00:00
|
|
|
const QString &getLastText() const {
|
|
|
|
return _oldtext;
|
2015-09-03 13:15:07 +00:00
|
|
|
}
|
2014-06-20 07:06:21 +00:00
|
|
|
|
2016-11-24 19:28:23 +00:00
|
|
|
public slots:
|
2014-05-30 08:53:19 +00:00
|
|
|
void onTextChange(const QString &text);
|
|
|
|
void onTextEdited();
|
|
|
|
|
|
|
|
void onTouchTimer();
|
|
|
|
|
|
|
|
signals:
|
|
|
|
void changed();
|
|
|
|
void cancelled();
|
2015-10-06 19:49:23 +00:00
|
|
|
void submitted(bool ctrlShiftEnter);
|
2014-05-30 08:53:19 +00:00
|
|
|
void focused();
|
|
|
|
void blurred();
|
|
|
|
|
|
|
|
protected:
|
2016-10-18 10:32:33 +00:00
|
|
|
bool event(QEvent *e) override;
|
|
|
|
void touchEvent(QTouchEvent *e);
|
|
|
|
void paintEvent(QPaintEvent *e) override;
|
|
|
|
void focusInEvent(QFocusEvent *e) override;
|
|
|
|
void focusOutEvent(QFocusEvent *e) override;
|
|
|
|
void keyPressEvent(QKeyEvent *e) override;
|
|
|
|
void resizeEvent(QResizeEvent *e) override;
|
|
|
|
void contextMenuEvent(QContextMenuEvent *e) override;
|
|
|
|
|
2015-10-06 19:49:23 +00:00
|
|
|
virtual void correctValue(const QString &was, QString &now);
|
2014-05-30 08:53:19 +00:00
|
|
|
|
2015-07-21 14:55:23 +00:00
|
|
|
style::font phFont() {
|
|
|
|
return _st.font;
|
|
|
|
}
|
|
|
|
|
2016-12-02 19:16:35 +00:00
|
|
|
void phPrepare(Painter &p, float64 placeholderFocused);
|
2015-07-21 14:55:23 +00:00
|
|
|
|
2014-05-30 08:53:19 +00:00
|
|
|
private:
|
2016-12-31 13:34:41 +00:00
|
|
|
void updatePalette();
|
2016-10-18 10:32:33 +00:00
|
|
|
void updatePlaceholderText();
|
2014-05-30 08:53:19 +00:00
|
|
|
|
2015-10-06 19:49:23 +00:00
|
|
|
QString _oldtext, _ph, _fullph;
|
2014-05-30 08:53:19 +00:00
|
|
|
|
2016-12-02 19:16:35 +00:00
|
|
|
bool _customUpDown = false;
|
2014-06-20 07:06:21 +00:00
|
|
|
|
2017-01-14 18:50:16 +00:00
|
|
|
bool _focused = false;
|
2016-12-02 19:16:35 +00:00
|
|
|
bool _placeholderVisible = true;
|
2016-12-07 13:32:25 +00:00
|
|
|
Animation _a_placeholderFocused;
|
|
|
|
Animation _a_placeholderVisible;
|
2014-05-30 08:53:19 +00:00
|
|
|
|
2016-11-15 11:56:49 +00:00
|
|
|
const style::FlatInput &_st;
|
2014-05-30 08:53:19 +00:00
|
|
|
|
|
|
|
QTimer _touchTimer;
|
|
|
|
bool _touchPress, _touchRightButton, _touchMove;
|
|
|
|
QPoint _touchStart;
|
|
|
|
};
|
2015-06-19 17:04:09 +00:00
|
|
|
|
2016-12-09 18:56:01 +00:00
|
|
|
enum class CtrlEnterSubmit {
|
|
|
|
Enter,
|
|
|
|
CtrlEnter,
|
|
|
|
Both,
|
2015-10-23 16:06:56 +00:00
|
|
|
};
|
|
|
|
|
2016-12-31 13:34:41 +00:00
|
|
|
class InputArea : public TWidget, private base::Subscriber {
|
2015-10-06 19:49:23 +00:00
|
|
|
Q_OBJECT
|
|
|
|
|
|
|
|
public:
|
2016-12-09 18:56:01 +00:00
|
|
|
InputArea(QWidget *parent, const style::InputField &st, const QString &ph = QString(), const QString &val = QString());
|
2015-10-06 19:49:23 +00:00
|
|
|
|
|
|
|
void showError();
|
|
|
|
|
|
|
|
void setMaxLength(int32 maxLength) {
|
|
|
|
_maxLength = maxLength;
|
|
|
|
}
|
|
|
|
|
|
|
|
const QString &getLastText() const {
|
|
|
|
return _oldtext;
|
|
|
|
}
|
2016-12-13 17:07:56 +00:00
|
|
|
void setDisplayFocused(bool focused);
|
2016-12-09 18:56:01 +00:00
|
|
|
void finishAnimations();
|
2016-12-20 13:03:51 +00:00
|
|
|
void setFocusFast() {
|
|
|
|
setDisplayFocused(true);
|
|
|
|
setFocus();
|
|
|
|
}
|
2015-10-06 19:49:23 +00:00
|
|
|
|
2016-10-22 14:35:37 +00:00
|
|
|
QSize sizeHint() const override;
|
|
|
|
QSize minimumSizeHint() const override;
|
2015-10-06 19:49:23 +00:00
|
|
|
|
|
|
|
QString getText(int32 start = 0, int32 end = -1) const;
|
|
|
|
bool hasText() const;
|
|
|
|
|
|
|
|
bool isUndoAvailable() const;
|
|
|
|
bool isRedoAvailable() const;
|
|
|
|
|
|
|
|
void customUpDown(bool isCustom);
|
2015-10-23 16:06:56 +00:00
|
|
|
void setCtrlEnterSubmit(CtrlEnterSubmit ctrlEnterSubmit);
|
2015-10-06 19:49:23 +00:00
|
|
|
|
|
|
|
void setTextCursor(const QTextCursor &cursor) {
|
2016-12-09 18:56:01 +00:00
|
|
|
return _inner->setTextCursor(cursor);
|
2015-10-06 19:49:23 +00:00
|
|
|
}
|
|
|
|
QTextCursor textCursor() const {
|
2016-12-09 18:56:01 +00:00
|
|
|
return _inner->textCursor();
|
2015-10-06 19:49:23 +00:00
|
|
|
}
|
|
|
|
void setText(const QString &text) {
|
2016-12-09 18:56:01 +00:00
|
|
|
_inner->setText(text);
|
|
|
|
startPlaceholderAnimation();
|
2015-10-06 19:49:23 +00:00
|
|
|
}
|
|
|
|
void clear() {
|
2016-12-09 18:56:01 +00:00
|
|
|
_inner->clear();
|
|
|
|
startPlaceholderAnimation();
|
2015-10-06 19:49:23 +00:00
|
|
|
}
|
|
|
|
bool hasFocus() const {
|
2016-12-09 18:56:01 +00:00
|
|
|
return _inner->hasFocus();
|
2015-10-06 19:49:23 +00:00
|
|
|
}
|
2016-06-24 16:43:46 +00:00
|
|
|
void setFocus() {
|
2016-12-09 18:56:01 +00:00
|
|
|
_inner->setFocus();
|
2016-06-24 16:43:46 +00:00
|
|
|
}
|
|
|
|
void clearFocus() {
|
2016-12-09 18:56:01 +00:00
|
|
|
_inner->clearFocus();
|
2016-06-24 16:43:46 +00:00
|
|
|
}
|
2015-10-06 19:49:23 +00:00
|
|
|
|
2016-12-09 18:56:01 +00:00
|
|
|
private slots:
|
2015-10-06 19:49:23 +00:00
|
|
|
void onTouchTimer();
|
|
|
|
|
|
|
|
void onDocumentContentsChange(int position, int charsRemoved, int charsAdded);
|
|
|
|
void onDocumentContentsChanged();
|
|
|
|
|
|
|
|
void onUndoAvailable(bool avail);
|
|
|
|
void onRedoAvailable(bool avail);
|
|
|
|
|
2016-12-09 18:56:01 +00:00
|
|
|
void onFocusInner();
|
|
|
|
|
2015-10-06 19:49:23 +00:00
|
|
|
signals:
|
|
|
|
void changed();
|
|
|
|
void submitted(bool ctrlShiftEnter);
|
|
|
|
void cancelled();
|
|
|
|
void tabbed();
|
|
|
|
|
|
|
|
void focused();
|
|
|
|
void blurred();
|
|
|
|
void resized();
|
|
|
|
|
|
|
|
protected:
|
2016-12-09 18:56:01 +00:00
|
|
|
void startPlaceholderAnimation();
|
|
|
|
void startBorderAnimation();
|
|
|
|
|
2015-10-06 19:49:23 +00:00
|
|
|
void insertEmoji(EmojiPtr emoji, QTextCursor c);
|
|
|
|
TWidget *tparent() {
|
|
|
|
return qobject_cast<TWidget*>(parentWidget());
|
|
|
|
}
|
|
|
|
const TWidget *tparent() const {
|
|
|
|
return qobject_cast<const TWidget*>(parentWidget());
|
|
|
|
}
|
|
|
|
|
2016-10-20 15:26:55 +00:00
|
|
|
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;
|
2015-10-06 19:49:23 +00:00
|
|
|
|
2016-10-20 15:26:55 +00:00
|
|
|
private:
|
2016-10-21 12:28:26 +00:00
|
|
|
class Inner : public QTextEdit {
|
2015-10-06 19:49:23 +00:00
|
|
|
public:
|
2016-10-21 12:28:26 +00:00
|
|
|
Inner(InputArea *parent);
|
2015-10-06 19:49:23 +00:00
|
|
|
|
2016-10-22 14:35:37 +00:00
|
|
|
QVariant loadResource(int type, const QUrl &name) override;
|
2015-10-06 19:49:23 +00:00
|
|
|
|
2016-10-20 15:26:55 +00:00
|
|
|
protected:
|
|
|
|
bool viewportEvent(QEvent *e) override;
|
|
|
|
void focusInEvent(QFocusEvent *e) override;
|
|
|
|
void focusOutEvent(QFocusEvent *e) override;
|
|
|
|
void keyPressEvent(QKeyEvent *e) override;
|
|
|
|
void contextMenuEvent(QContextMenuEvent *e) override;
|
2015-10-06 19:49:23 +00:00
|
|
|
|
2016-10-20 15:26:55 +00:00
|
|
|
QMimeData *createMimeDataFromSelection() const override;
|
2015-10-06 19:49:23 +00:00
|
|
|
|
|
|
|
private:
|
|
|
|
InputArea *f() const {
|
|
|
|
return static_cast<InputArea*>(parentWidget());
|
|
|
|
}
|
|
|
|
friend class InputArea;
|
2016-10-20 15:26:55 +00:00
|
|
|
|
2015-10-06 19:49:23 +00:00
|
|
|
};
|
2016-10-21 12:28:26 +00:00
|
|
|
friend class Inner;
|
2015-10-06 19:49:23 +00:00
|
|
|
|
2016-12-31 13:34:41 +00:00
|
|
|
void updatePalette();
|
|
|
|
|
2016-12-09 18:56:01 +00:00
|
|
|
bool heightAutoupdated();
|
|
|
|
void checkContentHeight();
|
|
|
|
void createPlaceholderPath();
|
|
|
|
void setErrorShown(bool error);
|
|
|
|
|
|
|
|
void focusInInner(bool focusByMouse);
|
2015-10-06 19:49:23 +00:00
|
|
|
void focusOutInner();
|
2016-12-13 17:07:56 +00:00
|
|
|
void setFocused(bool focused);
|
2015-10-06 19:49:23 +00:00
|
|
|
|
|
|
|
void processDocumentContentsChange(int position, int charsAdded);
|
|
|
|
|
2016-12-09 18:56:01 +00:00
|
|
|
const style::InputField &_st;
|
2015-10-06 19:49:23 +00:00
|
|
|
|
2016-12-09 18:56:01 +00:00
|
|
|
int _maxLength = -1;
|
|
|
|
|
2016-12-13 17:07:56 +00:00
|
|
|
object_ptr<Inner> _inner;
|
2015-10-06 19:49:23 +00:00
|
|
|
|
|
|
|
QString _oldtext;
|
|
|
|
|
2016-12-09 18:56:01 +00:00
|
|
|
CtrlEnterSubmit _ctrlEnterSubmit = CtrlEnterSubmit::CtrlEnter;
|
|
|
|
bool _undoAvailable = false;
|
|
|
|
bool _redoAvailable = false;
|
|
|
|
bool _inHeightCheck = false;
|
2015-10-06 19:49:23 +00:00
|
|
|
|
2016-12-09 18:56:01 +00:00
|
|
|
bool _customUpDown = false;
|
2015-10-06 19:49:23 +00:00
|
|
|
|
2016-12-09 18:56:01 +00:00
|
|
|
QString _placeholder;
|
|
|
|
QString _placeholderFull;
|
|
|
|
Animation _a_placeholderShifted;
|
|
|
|
bool _placeholderShifted = false;
|
|
|
|
QPainterPath _placeholderPath;
|
2016-12-05 11:01:08 +00:00
|
|
|
|
2016-12-09 18:56:01 +00:00
|
|
|
Animation _a_borderShown;
|
|
|
|
int _borderAnimationStart = 0;
|
|
|
|
Animation _a_borderOpacity;
|
|
|
|
bool _borderVisible = false;
|
2015-10-06 19:49:23 +00:00
|
|
|
|
2016-12-09 18:56:01 +00:00
|
|
|
Animation _a_focused;
|
|
|
|
Animation _a_error;
|
2015-10-06 19:49:23 +00:00
|
|
|
|
2016-12-09 18:56:01 +00:00
|
|
|
bool _focused = false;
|
|
|
|
bool _error = false;
|
2015-10-06 19:49:23 +00:00
|
|
|
|
|
|
|
QTimer _touchTimer;
|
2016-12-09 18:56:01 +00:00
|
|
|
bool _touchPress = false;
|
|
|
|
bool _touchRightButton = false;
|
|
|
|
bool _touchMove = false;
|
2015-10-06 19:49:23 +00:00
|
|
|
QPoint _touchStart;
|
|
|
|
|
2016-12-09 18:56:01 +00:00
|
|
|
bool _correcting = false;
|
2016-10-20 15:26:55 +00:00
|
|
|
|
2015-10-06 19:49:23 +00:00
|
|
|
};
|
|
|
|
|
2016-12-31 13:34:41 +00:00
|
|
|
class InputField : public TWidget, private base::Subscriber {
|
2015-06-19 17:04:09 +00:00
|
|
|
Q_OBJECT
|
|
|
|
|
|
|
|
public:
|
|
|
|
InputField(QWidget *parent, const style::InputField &st, const QString &ph = QString(), const QString &val = QString());
|
|
|
|
|
2015-10-11 08:37:24 +00:00
|
|
|
void setMaxLength(int32 maxLength) {
|
|
|
|
_maxLength = maxLength;
|
|
|
|
}
|
|
|
|
|
2015-10-06 19:49:23 +00:00
|
|
|
void showError();
|
2015-06-19 17:04:09 +00:00
|
|
|
|
2015-10-06 19:49:23 +00:00
|
|
|
const QString &getLastText() const {
|
|
|
|
return _oldtext;
|
|
|
|
}
|
2016-10-20 15:26:55 +00:00
|
|
|
void setPlaceholderHidden(bool forcePlaceholderHidden);
|
2016-12-13 17:07:56 +00:00
|
|
|
void setDisplayFocused(bool focused);
|
2016-12-09 18:56:01 +00:00
|
|
|
void finishAnimations();
|
2016-12-20 13:03:51 +00:00
|
|
|
void setFocusFast() {
|
|
|
|
setDisplayFocused(true);
|
|
|
|
setFocus();
|
|
|
|
}
|
2015-06-19 17:04:09 +00:00
|
|
|
|
2016-10-22 14:35:37 +00:00
|
|
|
QSize sizeHint() const override;
|
|
|
|
QSize minimumSizeHint() const override;
|
2015-06-19 17:04:09 +00:00
|
|
|
|
2015-08-18 16:10:01 +00:00
|
|
|
QString getText(int32 start = 0, int32 end = -1) const;
|
|
|
|
bool hasText() const;
|
2015-06-19 17:04:09 +00:00
|
|
|
|
2015-08-18 16:10:01 +00:00
|
|
|
bool isUndoAvailable() const;
|
|
|
|
bool isRedoAvailable() const;
|
2015-06-19 17:04:09 +00:00
|
|
|
|
2015-08-18 16:10:01 +00:00
|
|
|
void customUpDown(bool isCustom);
|
|
|
|
|
2015-08-18 19:37:57 +00:00
|
|
|
void setTextCursor(const QTextCursor &cursor) {
|
2016-12-09 18:56:01 +00:00
|
|
|
return _inner->setTextCursor(cursor);
|
2015-08-18 19:37:57 +00:00
|
|
|
}
|
|
|
|
QTextCursor textCursor() const {
|
2016-12-09 18:56:01 +00:00
|
|
|
return _inner->textCursor();
|
2015-08-18 19:37:57 +00:00
|
|
|
}
|
|
|
|
void setText(const QString &text) {
|
2016-12-09 18:56:01 +00:00
|
|
|
_inner->setText(text);
|
|
|
|
startPlaceholderAnimation();
|
2015-08-18 19:37:57 +00:00
|
|
|
}
|
|
|
|
void clear() {
|
2016-12-09 18:56:01 +00:00
|
|
|
_inner->clear();
|
|
|
|
startPlaceholderAnimation();
|
2015-10-06 19:49:23 +00:00
|
|
|
}
|
|
|
|
bool hasFocus() const {
|
2016-12-09 18:56:01 +00:00
|
|
|
return _inner->hasFocus();
|
2015-10-06 19:49:23 +00:00
|
|
|
}
|
|
|
|
void setFocus() {
|
2016-12-09 18:56:01 +00:00
|
|
|
_inner->setFocus();
|
|
|
|
auto cursor = _inner->textCursor();
|
|
|
|
cursor.movePosition(QTextCursor::End);
|
|
|
|
_inner->setTextCursor(cursor);
|
2015-10-06 19:49:23 +00:00
|
|
|
}
|
|
|
|
void clearFocus() {
|
2016-12-09 18:56:01 +00:00
|
|
|
_inner->clearFocus();
|
2015-10-06 19:49:23 +00:00
|
|
|
}
|
|
|
|
void setCursorPosition(int pos) {
|
2016-12-09 18:56:01 +00:00
|
|
|
auto cursor = _inner->textCursor();
|
|
|
|
cursor.setPosition(pos);
|
|
|
|
_inner->setTextCursor(cursor);
|
2015-08-18 19:37:57 +00:00
|
|
|
}
|
|
|
|
|
2016-11-24 19:28:23 +00:00
|
|
|
public slots:
|
2016-12-09 18:56:01 +00:00
|
|
|
void selectAll();
|
|
|
|
|
|
|
|
private slots:
|
2015-06-19 17:04:09 +00:00
|
|
|
void onTouchTimer();
|
|
|
|
|
2015-08-18 16:10:01 +00:00
|
|
|
void onDocumentContentsChange(int position, int charsRemoved, int charsAdded);
|
|
|
|
void onDocumentContentsChanged();
|
|
|
|
|
|
|
|
void onUndoAvailable(bool avail);
|
|
|
|
void onRedoAvailable(bool avail);
|
|
|
|
|
2016-12-09 18:56:01 +00:00
|
|
|
void onFocusInner();
|
2015-10-11 08:37:24 +00:00
|
|
|
|
2015-06-19 17:04:09 +00:00
|
|
|
signals:
|
|
|
|
void changed();
|
2015-08-18 16:10:01 +00:00
|
|
|
void submitted(bool ctrlShiftEnter);
|
2015-06-19 17:04:09 +00:00
|
|
|
void cancelled();
|
2015-08-18 16:10:01 +00:00
|
|
|
void tabbed();
|
|
|
|
|
2015-06-19 17:04:09 +00:00
|
|
|
void focused();
|
|
|
|
void blurred();
|
|
|
|
|
|
|
|
protected:
|
2016-12-09 18:56:01 +00:00
|
|
|
void startPlaceholderAnimation();
|
|
|
|
void startBorderAnimation();
|
|
|
|
|
2015-08-18 16:10:01 +00:00
|
|
|
void insertEmoji(EmojiPtr emoji, QTextCursor c);
|
|
|
|
TWidget *tparent() {
|
|
|
|
return qobject_cast<TWidget*>(parentWidget());
|
|
|
|
}
|
|
|
|
const TWidget *tparent() const {
|
|
|
|
return qobject_cast<const TWidget*>(parentWidget());
|
|
|
|
}
|
2015-06-19 17:04:09 +00:00
|
|
|
|
2016-10-20 15:26:55 +00:00
|
|
|
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;
|
2015-06-19 17:04:09 +00:00
|
|
|
|
2016-10-20 15:26:55 +00:00
|
|
|
private:
|
2016-10-21 12:28:26 +00:00
|
|
|
class Inner : public QTextEdit {
|
2015-08-18 19:37:57 +00:00
|
|
|
public:
|
2016-10-21 12:28:26 +00:00
|
|
|
Inner(InputField *parent);
|
2015-08-18 19:37:57 +00:00
|
|
|
|
2016-10-22 14:35:37 +00:00
|
|
|
QVariant loadResource(int type, const QUrl &name) override;
|
2015-08-18 19:37:57 +00:00
|
|
|
|
2016-10-20 15:26:55 +00:00
|
|
|
protected:
|
|
|
|
bool viewportEvent(QEvent *e) override;
|
|
|
|
void focusInEvent(QFocusEvent *e) override;
|
|
|
|
void focusOutEvent(QFocusEvent *e) override;
|
|
|
|
void keyPressEvent(QKeyEvent *e) override;
|
|
|
|
void contextMenuEvent(QContextMenuEvent *e) override;
|
2015-08-18 19:37:57 +00:00
|
|
|
|
2016-10-22 14:35:37 +00:00
|
|
|
QMimeData *createMimeDataFromSelection() const override;
|
|
|
|
|
2016-10-20 15:26:55 +00:00
|
|
|
private:
|
2015-08-18 19:37:57 +00:00
|
|
|
InputField *f() const {
|
|
|
|
return static_cast<InputField*>(parentWidget());
|
|
|
|
}
|
|
|
|
friend class InputField;
|
2016-10-20 15:26:55 +00:00
|
|
|
|
2015-08-18 19:37:57 +00:00
|
|
|
};
|
2016-10-21 12:28:26 +00:00
|
|
|
friend class Inner;
|
2015-10-06 19:49:23 +00:00
|
|
|
|
2016-12-31 13:34:41 +00:00
|
|
|
void updatePalette();
|
|
|
|
|
2016-12-09 18:56:01 +00:00
|
|
|
void createPlaceholderPath();
|
|
|
|
void setErrorShown(bool error);
|
|
|
|
|
|
|
|
void focusInInner(bool focusByMouse);
|
2015-08-18 19:37:57 +00:00
|
|
|
void focusOutInner();
|
2016-12-13 17:07:56 +00:00
|
|
|
void setFocused(bool focused);
|
2015-08-18 19:37:57 +00:00
|
|
|
|
2015-08-18 16:10:01 +00:00
|
|
|
void processDocumentContentsChange(int position, int charsAdded);
|
|
|
|
|
2016-12-09 18:56:01 +00:00
|
|
|
const style::InputField &_st;
|
|
|
|
|
|
|
|
int _maxLength = -1;
|
|
|
|
bool _forcePlaceholderHidden = false;
|
2015-10-06 19:49:23 +00:00
|
|
|
|
2016-12-13 17:07:56 +00:00
|
|
|
object_ptr<Inner> _inner;
|
2015-08-18 16:10:01 +00:00
|
|
|
|
2015-10-06 19:49:23 +00:00
|
|
|
QString _oldtext;
|
2015-06-19 17:04:09 +00:00
|
|
|
|
2016-12-09 18:56:01 +00:00
|
|
|
bool _undoAvailable = false;
|
|
|
|
bool _redoAvailable = false;
|
2015-06-19 17:04:09 +00:00
|
|
|
|
2016-12-09 18:56:01 +00:00
|
|
|
bool _customUpDown = true;
|
2016-04-29 12:00:48 +00:00
|
|
|
|
2016-12-09 18:56:01 +00:00
|
|
|
QString _placeholder;
|
|
|
|
QString _placeholderFull;
|
|
|
|
Animation _a_placeholderShifted;
|
|
|
|
bool _placeholderShifted = false;
|
|
|
|
QPainterPath _placeholderPath;
|
2016-12-05 11:01:08 +00:00
|
|
|
|
2016-12-09 18:56:01 +00:00
|
|
|
Animation _a_borderShown;
|
|
|
|
int _borderAnimationStart = 0;
|
|
|
|
Animation _a_borderOpacity;
|
|
|
|
bool _borderVisible = false;
|
2016-04-29 12:00:48 +00:00
|
|
|
|
2016-12-09 18:56:01 +00:00
|
|
|
Animation _a_focused;
|
|
|
|
Animation _a_error;
|
2016-04-29 12:00:48 +00:00
|
|
|
|
2016-12-09 18:56:01 +00:00
|
|
|
bool _focused = false;
|
|
|
|
bool _error = false;
|
2015-10-06 19:49:23 +00:00
|
|
|
|
|
|
|
QTimer _touchTimer;
|
2016-12-09 18:56:01 +00:00
|
|
|
bool _touchPress = false;
|
|
|
|
bool _touchRightButton = false;
|
|
|
|
bool _touchMove = false;
|
2015-10-06 19:49:23 +00:00
|
|
|
QPoint _touchStart;
|
|
|
|
|
2016-12-09 18:56:01 +00:00
|
|
|
bool _correcting = false;
|
2015-10-06 19:49:23 +00:00
|
|
|
};
|
|
|
|
|
2017-02-11 11:24:37 +00:00
|
|
|
class MaskedInputField : public TWidgetHelper<QLineEdit>, private base::Subscriber {
|
2015-10-06 19:49:23 +00:00
|
|
|
Q_OBJECT
|
|
|
|
|
|
|
|
public:
|
|
|
|
MaskedInputField(QWidget *parent, const style::InputField &st, const QString &placeholder = QString(), const QString &val = QString());
|
|
|
|
|
|
|
|
void showError();
|
|
|
|
|
|
|
|
QRect getTextRect() const;
|
|
|
|
|
2016-04-14 13:03:03 +00:00
|
|
|
QSize sizeHint() const override;
|
|
|
|
QSize minimumSizeHint() const override;
|
2015-10-06 19:49:23 +00:00
|
|
|
|
|
|
|
void customUpDown(bool isCustom);
|
|
|
|
const QString &getLastText() const {
|
|
|
|
return _oldtext;
|
|
|
|
}
|
2016-12-09 18:56:01 +00:00
|
|
|
void setPlaceholderHidden(bool forcePlaceholderHidden);
|
2016-12-13 17:07:56 +00:00
|
|
|
void setDisplayFocused(bool focused);
|
2016-12-09 18:56:01 +00:00
|
|
|
void finishAnimations();
|
2016-12-20 13:03:51 +00:00
|
|
|
void setFocusFast() {
|
|
|
|
setDisplayFocused(true);
|
|
|
|
setFocus();
|
|
|
|
}
|
2016-12-09 18:56:01 +00:00
|
|
|
|
2015-10-06 19:49:23 +00:00
|
|
|
void setText(const QString &text) {
|
|
|
|
QLineEdit::setText(text);
|
2016-12-09 18:56:01 +00:00
|
|
|
startPlaceholderAnimation();
|
2015-10-06 19:49:23 +00:00
|
|
|
}
|
|
|
|
void clear() {
|
|
|
|
QLineEdit::clear();
|
2016-12-09 18:56:01 +00:00
|
|
|
startPlaceholderAnimation();
|
2015-10-06 19:49:23 +00:00
|
|
|
}
|
|
|
|
|
2016-11-24 19:28:23 +00:00
|
|
|
public slots:
|
2015-10-06 19:49:23 +00:00
|
|
|
void onTextChange(const QString &text);
|
|
|
|
void onCursorPositionChanged(int oldPosition, int position);
|
|
|
|
|
|
|
|
void onTextEdited();
|
|
|
|
|
|
|
|
void onTouchTimer();
|
|
|
|
|
|
|
|
signals:
|
|
|
|
void changed();
|
|
|
|
void cancelled();
|
|
|
|
void submitted(bool ctrlShiftEnter);
|
|
|
|
void focused();
|
|
|
|
void blurred();
|
|
|
|
|
|
|
|
protected:
|
2016-12-09 18:56:01 +00:00
|
|
|
void startBorderAnimation();
|
|
|
|
void startPlaceholderAnimation();
|
|
|
|
|
2016-11-24 19:28:23 +00:00
|
|
|
bool event(QEvent *e) override;
|
|
|
|
void touchEvent(QTouchEvent *e);
|
|
|
|
void paintEvent(QPaintEvent *e) override;
|
|
|
|
void focusInEvent(QFocusEvent *e) override;
|
|
|
|
void focusOutEvent(QFocusEvent *e) override;
|
|
|
|
void keyPressEvent(QKeyEvent *e) override;
|
|
|
|
void resizeEvent(QResizeEvent *e) override;
|
|
|
|
void contextMenuEvent(QContextMenuEvent *e) override;
|
|
|
|
|
|
|
|
virtual void correctValue(const QString &was, int32 wasCursor, QString &now, int32 &nowCursor) {
|
|
|
|
}
|
|
|
|
void setCorrectedText(QString &now, int &nowCursor, const QString &newText, int newPos);
|
|
|
|
|
2016-12-09 18:56:01 +00:00
|
|
|
virtual void paintAdditionalPlaceholder(Painter &p, TimeMs ms) {
|
|
|
|
}
|
2015-10-06 19:49:23 +00:00
|
|
|
|
|
|
|
style::font phFont() {
|
|
|
|
return _st.font;
|
|
|
|
}
|
|
|
|
|
2016-12-09 18:56:01 +00:00
|
|
|
void placeholderAdditionalPrepare(Painter &p, TimeMs ms);
|
2015-10-06 19:49:23 +00:00
|
|
|
const QString &placeholder() const;
|
|
|
|
QRect placeholderRect() const;
|
|
|
|
|
|
|
|
void setTextMargins(const QMargins &mrg);
|
|
|
|
const style::InputField &_st;
|
|
|
|
|
|
|
|
private:
|
2016-12-31 13:34:41 +00:00
|
|
|
void updatePalette();
|
2016-12-09 18:56:01 +00:00
|
|
|
void createPlaceholderPath();
|
|
|
|
void setErrorShown(bool error);
|
2016-12-13 17:07:56 +00:00
|
|
|
|
|
|
|
void setFocused(bool focused);
|
2015-10-06 19:49:23 +00:00
|
|
|
|
2016-12-09 18:56:01 +00:00
|
|
|
int _maxLength = -1;
|
|
|
|
bool _forcePlaceholderHidden = false;
|
2015-10-06 19:49:23 +00:00
|
|
|
|
|
|
|
QString _oldtext;
|
2016-12-09 18:56:01 +00:00
|
|
|
int _oldcursor = 0;
|
|
|
|
|
|
|
|
bool _undoAvailable = false;
|
|
|
|
bool _redoAvailable = false;
|
2015-10-06 19:49:23 +00:00
|
|
|
|
2016-12-09 18:56:01 +00:00
|
|
|
bool _customUpDown = false;
|
2015-10-06 19:49:23 +00:00
|
|
|
|
2016-12-09 18:56:01 +00:00
|
|
|
QString _placeholder;
|
|
|
|
QString _placeholderFull;
|
|
|
|
Animation _a_placeholderShifted;
|
|
|
|
bool _placeholderShifted = false;
|
|
|
|
QPainterPath _placeholderPath;
|
2015-10-06 19:49:23 +00:00
|
|
|
|
2016-12-09 18:56:01 +00:00
|
|
|
Animation _a_borderShown;
|
|
|
|
int _borderAnimationStart = 0;
|
|
|
|
Animation _a_borderOpacity;
|
|
|
|
bool _borderVisible = false;
|
2016-12-05 11:01:08 +00:00
|
|
|
|
2016-12-09 18:56:01 +00:00
|
|
|
Animation _a_focused;
|
|
|
|
Animation _a_error;
|
2015-10-06 19:49:23 +00:00
|
|
|
|
2016-12-09 18:56:01 +00:00
|
|
|
bool _focused = false;
|
|
|
|
bool _error = false;
|
2015-10-06 19:49:23 +00:00
|
|
|
|
|
|
|
style::margins _textMargins;
|
2015-06-19 17:04:09 +00:00
|
|
|
|
|
|
|
QTimer _touchTimer;
|
2016-12-09 18:56:01 +00:00
|
|
|
bool _touchPress = false;
|
|
|
|
bool _touchRightButton = false;
|
|
|
|
bool _touchMove = false;
|
2015-06-19 17:04:09 +00:00
|
|
|
QPoint _touchStart;
|
2015-10-06 19:49:23 +00:00
|
|
|
};
|
|
|
|
|
2016-11-24 19:28:23 +00:00
|
|
|
class CountryCodeInput : public MaskedInputField {
|
|
|
|
Q_OBJECT
|
|
|
|
|
|
|
|
public:
|
|
|
|
CountryCodeInput(QWidget *parent, const style::InputField &st);
|
|
|
|
|
|
|
|
public slots:
|
|
|
|
void startErasing(QKeyEvent *e);
|
|
|
|
void codeSelected(const QString &code);
|
|
|
|
|
|
|
|
signals:
|
|
|
|
void codeChanged(const QString &code);
|
|
|
|
void addedToNumber(const QString &added);
|
|
|
|
|
|
|
|
protected:
|
|
|
|
void correctValue(const QString &was, int32 wasCursor, QString &now, int32 &nowCursor) override;
|
|
|
|
|
|
|
|
private:
|
|
|
|
bool _nosignal;
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
class PhonePartInput : public MaskedInputField {
|
|
|
|
Q_OBJECT
|
|
|
|
|
|
|
|
public:
|
|
|
|
PhonePartInput(QWidget *parent, const style::InputField &st);
|
|
|
|
|
|
|
|
public slots:
|
|
|
|
void addedToNumber(const QString &added);
|
|
|
|
void onChooseCode(const QString &code);
|
|
|
|
|
|
|
|
signals:
|
|
|
|
void voidBackspace(QKeyEvent *e);
|
|
|
|
|
|
|
|
protected:
|
|
|
|
void keyPressEvent(QKeyEvent *e) override;
|
|
|
|
|
|
|
|
void correctValue(const QString &was, int32 wasCursor, QString &now, int32 &nowCursor) override;
|
2016-12-09 18:56:01 +00:00
|
|
|
void paintAdditionalPlaceholder(Painter &p, TimeMs ms) override;
|
2016-11-24 19:28:23 +00:00
|
|
|
|
|
|
|
private:
|
|
|
|
QVector<int> _pattern;
|
2016-12-09 18:56:01 +00:00
|
|
|
QString _additionalPlaceholder;
|
2016-11-24 19:28:23 +00:00
|
|
|
|
|
|
|
};
|
|
|
|
|
2016-11-15 11:56:49 +00:00
|
|
|
class PasswordInput : public MaskedInputField {
|
2015-10-11 08:37:24 +00:00
|
|
|
public:
|
2016-11-15 11:56:49 +00:00
|
|
|
PasswordInput(QWidget *parent, const style::InputField &st, const QString &ph = QString(), const QString &val = QString());
|
2015-10-11 08:37:24 +00:00
|
|
|
|
|
|
|
};
|
2015-10-06 19:49:23 +00:00
|
|
|
|
2015-10-11 08:37:24 +00:00
|
|
|
class PortInput : public MaskedInputField {
|
2015-10-06 19:49:23 +00:00
|
|
|
public:
|
|
|
|
PortInput(QWidget *parent, const style::InputField &st, const QString &ph, const QString &val);
|
|
|
|
|
|
|
|
protected:
|
2016-10-20 15:26:55 +00:00
|
|
|
void correctValue(const QString &was, int32 wasCursor, QString &now, int32 &nowCursor) override;
|
2015-10-06 19:49:23 +00:00
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
class UsernameInput : public MaskedInputField {
|
|
|
|
public:
|
|
|
|
UsernameInput(QWidget *parent, const style::InputField &st, const QString &ph, const QString &val, bool isLink);
|
|
|
|
|
|
|
|
protected:
|
2016-10-20 15:26:55 +00:00
|
|
|
void correctValue(const QString &was, int32 wasCursor, QString &now, int32 &nowCursor) override;
|
2016-12-09 18:56:01 +00:00
|
|
|
void paintAdditionalPlaceholder(Painter &p, TimeMs ms) override;
|
2015-10-06 19:49:23 +00:00
|
|
|
|
|
|
|
private:
|
|
|
|
QString _linkPlaceholder;
|
2015-08-18 16:10:01 +00:00
|
|
|
|
2015-06-19 17:04:09 +00:00
|
|
|
};
|
2015-10-11 08:37:24 +00:00
|
|
|
|
|
|
|
class PhoneInput : public MaskedInputField {
|
|
|
|
public:
|
|
|
|
PhoneInput(QWidget *parent, const style::InputField &st, const QString &ph, const QString &val);
|
|
|
|
|
|
|
|
void clearText();
|
|
|
|
|
|
|
|
protected:
|
2016-10-20 15:26:55 +00:00
|
|
|
void focusInEvent(QFocusEvent *e) override;
|
2015-10-11 08:37:24 +00:00
|
|
|
|
2016-10-20 15:26:55 +00:00
|
|
|
void correctValue(const QString &was, int32 wasCursor, QString &now, int32 &nowCursor) override;
|
2016-12-09 18:56:01 +00:00
|
|
|
void paintAdditionalPlaceholder(Painter &p, TimeMs ms) override;
|
2015-10-11 08:37:24 +00:00
|
|
|
|
|
|
|
private:
|
2016-10-20 15:26:55 +00:00
|
|
|
QVector<int> _pattern;
|
2016-12-09 18:56:01 +00:00
|
|
|
QString _additionalPlaceholder;
|
2015-10-11 08:37:24 +00:00
|
|
|
|
|
|
|
};
|
2016-11-15 11:56:49 +00:00
|
|
|
|
|
|
|
} // namespace Ui
|