2017-04-06 02:06:42 +03:00
|
|
|
/*
|
|
|
|
* nheko Copyright (C) 2017 Konstantinos Sideris <siderisk@auth.gr>
|
|
|
|
*
|
|
|
|
* This program 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.
|
|
|
|
*
|
|
|
|
* This program 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.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
*/
|
|
|
|
|
2017-11-06 00:01:21 +03:00
|
|
|
#include <QAbstractTextDocumentLayout>
|
2018-01-10 10:52:59 +03:00
|
|
|
#include <QApplication>
|
|
|
|
#include <QBuffer>
|
|
|
|
#include <QClipboard>
|
2017-04-06 02:06:42 +03:00
|
|
|
#include <QDebug>
|
2017-09-10 12:58:00 +03:00
|
|
|
#include <QFileDialog>
|
|
|
|
#include <QImageReader>
|
2018-01-10 10:52:59 +03:00
|
|
|
#include <QMimeData>
|
2017-12-01 18:33:49 +03:00
|
|
|
#include <QMimeDatabase>
|
|
|
|
#include <QMimeType>
|
2017-04-06 02:06:42 +03:00
|
|
|
#include <QPainter>
|
|
|
|
#include <QStyleOption>
|
|
|
|
|
2017-07-15 17:11:46 +03:00
|
|
|
#include "Config.h"
|
2017-04-06 02:06:42 +03:00
|
|
|
#include "TextInputWidget.h"
|
|
|
|
|
2017-11-06 00:01:21 +03:00
|
|
|
static constexpr size_t INPUT_HISTORY_SIZE = 127;
|
|
|
|
|
2017-04-23 21:31:08 +03:00
|
|
|
FilteredTextEdit::FilteredTextEdit(QWidget *parent)
|
2017-11-06 01:25:47 +03:00
|
|
|
: QTextEdit{parent}
|
|
|
|
, history_index_{0}
|
2018-01-10 10:52:59 +03:00
|
|
|
, previewDialog_{parent}
|
2017-04-23 21:31:08 +03:00
|
|
|
{
|
2017-11-06 00:01:21 +03:00
|
|
|
connect(document()->documentLayout(),
|
|
|
|
&QAbstractTextDocumentLayout::documentSizeChanged,
|
|
|
|
this,
|
|
|
|
&FilteredTextEdit::updateGeometry);
|
|
|
|
QSizePolicy policy(QSizePolicy::Expanding, QSizePolicy::Fixed);
|
|
|
|
policy.setHeightForWidth(true);
|
|
|
|
setSizePolicy(policy);
|
|
|
|
working_history_.push_back("");
|
|
|
|
connect(this, &QTextEdit::textChanged, this, &FilteredTextEdit::textChanged);
|
2017-09-03 11:43:45 +03:00
|
|
|
setAcceptRichText(false);
|
2017-10-31 21:11:49 +03:00
|
|
|
|
|
|
|
typingTimer_ = new QTimer(this);
|
|
|
|
typingTimer_->setInterval(1000);
|
|
|
|
typingTimer_->setSingleShot(true);
|
|
|
|
|
|
|
|
connect(typingTimer_, &QTimer::timeout, this, &FilteredTextEdit::stopTyping);
|
2018-01-10 10:52:59 +03:00
|
|
|
connect(&previewDialog_,
|
|
|
|
&dialogs::PreviewImageOverlay::confirmImageUpload,
|
|
|
|
this,
|
|
|
|
&FilteredTextEdit::receiveImage);
|
|
|
|
|
|
|
|
previewDialog_.hide();
|
2017-04-23 21:31:08 +03:00
|
|
|
}
|
|
|
|
|
2017-08-20 13:47:22 +03:00
|
|
|
void
|
|
|
|
FilteredTextEdit::keyPressEvent(QKeyEvent *event)
|
2017-04-23 21:31:08 +03:00
|
|
|
{
|
2017-11-05 01:19:00 +03:00
|
|
|
const bool isModifier = (event->modifiers() != Qt::NoModifier);
|
|
|
|
|
|
|
|
if (!isModifier) {
|
|
|
|
if (!typingTimer_->isActive())
|
|
|
|
emit startedTyping();
|
2017-10-31 21:11:49 +03:00
|
|
|
|
2017-11-05 01:19:00 +03:00
|
|
|
typingTimer_->start();
|
|
|
|
}
|
2017-10-31 21:11:49 +03:00
|
|
|
|
2017-11-06 00:01:21 +03:00
|
|
|
switch (event->key()) {
|
|
|
|
case Qt::Key_Return:
|
|
|
|
case Qt::Key_Enter:
|
|
|
|
if (!(event->modifiers() & Qt::ShiftModifier)) {
|
|
|
|
stopTyping();
|
|
|
|
submit();
|
|
|
|
} else {
|
|
|
|
QTextEdit::keyPressEvent(event);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case Qt::Key_Up: {
|
|
|
|
auto initial_cursor = textCursor();
|
|
|
|
QTextEdit::keyPressEvent(event);
|
2018-01-16 21:51:46 +03:00
|
|
|
|
|
|
|
if (textCursor() == initial_cursor && textCursor().atStart() &&
|
2017-11-06 00:01:21 +03:00
|
|
|
history_index_ + 1 < working_history_.size()) {
|
|
|
|
++history_index_;
|
|
|
|
setPlainText(working_history_[history_index_]);
|
|
|
|
moveCursor(QTextCursor::End);
|
2018-01-17 11:16:54 +03:00
|
|
|
} else if (textCursor() == initial_cursor) {
|
|
|
|
// Move to the start of the text if there aren't any lines to move up to.
|
2018-01-16 21:51:46 +03:00
|
|
|
initial_cursor.movePosition(QTextCursor::Start, QTextCursor::MoveAnchor, 1);
|
|
|
|
setTextCursor(initial_cursor);
|
|
|
|
}
|
|
|
|
|
2017-11-06 00:01:21 +03:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
case Qt::Key_Down: {
|
|
|
|
auto initial_cursor = textCursor();
|
2017-09-03 11:43:45 +03:00
|
|
|
QTextEdit::keyPressEvent(event);
|
2018-01-16 21:51:46 +03:00
|
|
|
|
|
|
|
if (textCursor() == initial_cursor && textCursor().atEnd() && history_index_ > 0) {
|
2017-11-06 00:01:21 +03:00
|
|
|
--history_index_;
|
|
|
|
setPlainText(working_history_[history_index_]);
|
|
|
|
moveCursor(QTextCursor::End);
|
2018-01-17 11:16:54 +03:00
|
|
|
} else if (textCursor() == initial_cursor) {
|
|
|
|
// Move to the end of the text if there aren't any lines to move down to.
|
2018-01-16 21:51:46 +03:00
|
|
|
initial_cursor.movePosition(QTextCursor::End, QTextCursor::MoveAnchor, 1);
|
|
|
|
setTextCursor(initial_cursor);
|
|
|
|
}
|
|
|
|
|
2017-11-06 00:01:21 +03:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
default:
|
|
|
|
QTextEdit::keyPressEvent(event);
|
|
|
|
break;
|
2017-10-31 21:11:49 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-01-10 10:52:59 +03:00
|
|
|
bool
|
|
|
|
FilteredTextEdit::canInsertFromMimeData(const QMimeData *source) const
|
|
|
|
{
|
|
|
|
return (source->hasImage() || QTextEdit::canInsertFromMimeData(source));
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
FilteredTextEdit::insertFromMimeData(const QMimeData *source)
|
|
|
|
{
|
|
|
|
if (source->hasImage()) {
|
|
|
|
const auto formats = source->formats();
|
|
|
|
const auto idx = formats.indexOf(
|
|
|
|
QRegularExpression{"image/.+", QRegularExpression::CaseInsensitiveOption});
|
|
|
|
|
|
|
|
// Note: in the future we may want to look into what the best choice is from the
|
|
|
|
// formats list. For now we will default to PNG format.
|
|
|
|
QString type = "png";
|
|
|
|
if (idx != -1) {
|
|
|
|
type = formats.at(idx).split('/')[1];
|
|
|
|
}
|
|
|
|
|
|
|
|
// Encode raw pixel data of image.
|
|
|
|
QByteArray data = source->data("image/" + type);
|
|
|
|
previewDialog_.setImageAndCreate(data, type);
|
|
|
|
previewDialog_.show();
|
|
|
|
} else if (source->hasFormat("x-special/gnome-copied-files") &&
|
|
|
|
QImageReader{source->text()}.canRead()) {
|
|
|
|
// Special case for X11 users. See "Notes for X11 Users" in source.
|
|
|
|
// Source: http://doc.qt.io/qt-5/qclipboard.html
|
|
|
|
previewDialog_.setImageAndCreate(source->text());
|
|
|
|
previewDialog_.show();
|
|
|
|
} else {
|
|
|
|
QTextEdit::insertFromMimeData(source);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-10-31 21:11:49 +03:00
|
|
|
void
|
|
|
|
FilteredTextEdit::stopTyping()
|
|
|
|
{
|
|
|
|
typingTimer_->stop();
|
|
|
|
emit stoppedTyping();
|
2017-04-23 21:31:08 +03:00
|
|
|
}
|
|
|
|
|
2017-11-06 00:01:21 +03:00
|
|
|
QSize
|
|
|
|
FilteredTextEdit::sizeHint() const
|
|
|
|
{
|
|
|
|
ensurePolished();
|
|
|
|
auto margins = viewportMargins();
|
|
|
|
margins += document()->documentMargin();
|
|
|
|
QSize size = document()->size().toSize();
|
|
|
|
size.rwidth() += margins.left() + margins.right();
|
|
|
|
size.rheight() += margins.top() + margins.bottom();
|
|
|
|
return size;
|
|
|
|
}
|
|
|
|
|
|
|
|
QSize
|
|
|
|
FilteredTextEdit::minimumSizeHint() const
|
|
|
|
{
|
|
|
|
ensurePolished();
|
|
|
|
auto margins = viewportMargins();
|
|
|
|
margins += document()->documentMargin();
|
|
|
|
margins += contentsMargins();
|
|
|
|
QSize size(fontMetrics().averageCharWidth() * 10,
|
|
|
|
fontMetrics().lineSpacing() + margins.top() + margins.bottom());
|
|
|
|
return size;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
FilteredTextEdit::submit()
|
|
|
|
{
|
2017-11-16 17:33:52 +03:00
|
|
|
if (toPlainText().trimmed().isEmpty())
|
|
|
|
return;
|
2017-11-16 15:42:13 +03:00
|
|
|
|
2017-11-06 00:01:21 +03:00
|
|
|
if (true_history_.size() == INPUT_HISTORY_SIZE)
|
|
|
|
true_history_.pop_back();
|
|
|
|
true_history_.push_front(toPlainText());
|
|
|
|
working_history_ = true_history_;
|
|
|
|
working_history_.push_front("");
|
|
|
|
history_index_ = 0;
|
|
|
|
|
|
|
|
QString text = toPlainText();
|
2018-01-10 10:52:59 +03:00
|
|
|
|
2017-11-06 00:01:21 +03:00
|
|
|
if (text.startsWith('/')) {
|
|
|
|
int command_end = text.indexOf(' ');
|
|
|
|
if (command_end == -1)
|
|
|
|
command_end = text.size();
|
|
|
|
auto name = text.mid(1, command_end - 1);
|
|
|
|
auto args = text.mid(command_end + 1);
|
|
|
|
if (name.isEmpty() || name == "/") {
|
|
|
|
message(args);
|
|
|
|
} else {
|
|
|
|
command(name, args);
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
message(std::move(text));
|
|
|
|
}
|
|
|
|
|
|
|
|
clear();
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
FilteredTextEdit::textChanged()
|
|
|
|
{
|
|
|
|
working_history_[history_index_] = toPlainText();
|
|
|
|
}
|
|
|
|
|
2018-01-10 10:52:59 +03:00
|
|
|
void
|
|
|
|
FilteredTextEdit::receiveImage(const QByteArray img, const QString &img_name)
|
|
|
|
{
|
|
|
|
QSharedPointer<QBuffer> buffer{new QBuffer{this}};
|
|
|
|
buffer->setData(img);
|
|
|
|
emit image(buffer, img_name);
|
|
|
|
}
|
|
|
|
|
2017-04-06 02:06:42 +03:00
|
|
|
TextInputWidget::TextInputWidget(QWidget *parent)
|
2017-09-03 11:43:45 +03:00
|
|
|
: QFrame(parent)
|
2017-04-06 02:06:42 +03:00
|
|
|
{
|
2017-09-03 11:43:45 +03:00
|
|
|
setFont(QFont("Emoji One"));
|
|
|
|
|
2017-10-15 22:08:51 +03:00
|
|
|
setFixedHeight(conf::textInput::height);
|
2017-09-03 11:43:45 +03:00
|
|
|
setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed);
|
|
|
|
setCursor(Qt::ArrowCursor);
|
|
|
|
|
2017-09-10 12:58:00 +03:00
|
|
|
topLayout_ = new QHBoxLayout();
|
2017-10-04 11:33:34 +03:00
|
|
|
topLayout_->setSpacing(0);
|
2017-10-04 22:00:26 +03:00
|
|
|
topLayout_->setContentsMargins(15, 0, 15, 5);
|
2017-09-03 11:43:45 +03:00
|
|
|
|
|
|
|
QIcon send_file_icon;
|
2017-10-15 22:08:51 +03:00
|
|
|
send_file_icon.addFile(":/icons/icons/ui/paper-clip-outline.png");
|
2017-09-10 12:58:00 +03:00
|
|
|
|
|
|
|
sendFileBtn_ = new FlatButton(this);
|
|
|
|
sendFileBtn_->setIcon(send_file_icon);
|
|
|
|
sendFileBtn_->setIconSize(QSize(24, 24));
|
|
|
|
|
|
|
|
spinner_ = new LoadingIndicator(this);
|
2017-10-04 11:33:34 +03:00
|
|
|
spinner_->setFixedHeight(32);
|
|
|
|
spinner_->setFixedWidth(32);
|
2017-11-16 17:33:52 +03:00
|
|
|
spinner_->setObjectName("FileUploadSpinner");
|
2017-09-10 12:58:00 +03:00
|
|
|
spinner_->hide();
|
2017-09-03 11:43:45 +03:00
|
|
|
|
|
|
|
QFont font;
|
2017-10-04 22:00:26 +03:00
|
|
|
font.setPixelSize(conf::textInputFontSize);
|
2017-09-03 11:43:45 +03:00
|
|
|
|
|
|
|
input_ = new FilteredTextEdit(this);
|
2017-10-04 11:33:34 +03:00
|
|
|
input_->setFixedHeight(32);
|
2017-09-03 11:43:45 +03:00
|
|
|
input_->setFont(font);
|
2017-10-04 11:33:34 +03:00
|
|
|
input_->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
|
2017-09-03 11:43:45 +03:00
|
|
|
input_->setPlaceholderText(tr("Write a message..."));
|
2017-11-16 17:33:52 +03:00
|
|
|
input_->setStyleSheet("border: none; padding-top: 5px;");
|
2017-09-03 11:43:45 +03:00
|
|
|
|
2017-09-10 12:58:00 +03:00
|
|
|
sendMessageBtn_ = new FlatButton(this);
|
2017-09-03 11:43:45 +03:00
|
|
|
|
|
|
|
QIcon send_message_icon;
|
2017-10-15 22:08:51 +03:00
|
|
|
send_message_icon.addFile(":/icons/icons/ui/cursor.png");
|
2017-09-10 12:58:00 +03:00
|
|
|
sendMessageBtn_->setIcon(send_message_icon);
|
|
|
|
sendMessageBtn_->setIconSize(QSize(24, 24));
|
2017-09-03 11:43:45 +03:00
|
|
|
|
2017-11-30 21:02:46 +03:00
|
|
|
emojiBtn_ = new emoji::PickButton(this);
|
2017-09-03 11:43:45 +03:00
|
|
|
|
|
|
|
QIcon emoji_icon;
|
2017-10-15 22:08:51 +03:00
|
|
|
emoji_icon.addFile(":/icons/icons/ui/smile.png");
|
2017-09-10 12:58:00 +03:00
|
|
|
emojiBtn_->setIcon(emoji_icon);
|
|
|
|
emojiBtn_->setIconSize(QSize(24, 24));
|
2017-09-03 11:43:45 +03:00
|
|
|
|
2017-09-10 12:58:00 +03:00
|
|
|
topLayout_->addWidget(sendFileBtn_);
|
|
|
|
topLayout_->addWidget(input_);
|
|
|
|
topLayout_->addWidget(emojiBtn_);
|
|
|
|
topLayout_->addWidget(sendMessageBtn_);
|
2017-09-03 11:43:45 +03:00
|
|
|
|
2017-09-10 12:58:00 +03:00
|
|
|
setLayout(topLayout_);
|
2017-09-03 11:43:45 +03:00
|
|
|
|
2017-11-06 00:01:21 +03:00
|
|
|
connect(sendMessageBtn_, &FlatButton::clicked, input_, &FilteredTextEdit::submit);
|
2017-09-10 12:58:00 +03:00
|
|
|
connect(sendFileBtn_, SIGNAL(clicked()), this, SLOT(openFileSelection()));
|
2017-11-06 00:01:21 +03:00
|
|
|
connect(input_, &FilteredTextEdit::message, this, &TextInputWidget::sendTextMessage);
|
|
|
|
connect(input_, &FilteredTextEdit::command, this, &TextInputWidget::command);
|
2018-01-10 10:52:59 +03:00
|
|
|
connect(input_, &FilteredTextEdit::image, this, &TextInputWidget::uploadImage);
|
2017-09-10 12:58:00 +03:00
|
|
|
connect(emojiBtn_,
|
2017-09-03 11:43:45 +03:00
|
|
|
SIGNAL(emojiSelected(const QString &)),
|
|
|
|
this,
|
|
|
|
SLOT(addSelectedEmoji(const QString &)));
|
2017-10-31 21:11:49 +03:00
|
|
|
|
|
|
|
connect(input_, &FilteredTextEdit::startedTyping, this, &TextInputWidget::startedTyping);
|
|
|
|
|
|
|
|
connect(input_, &FilteredTextEdit::stoppedTyping, this, &TextInputWidget::stoppedTyping);
|
2017-04-23 21:31:08 +03:00
|
|
|
}
|
|
|
|
|
2017-08-20 13:47:22 +03:00
|
|
|
void
|
|
|
|
TextInputWidget::addSelectedEmoji(const QString &emoji)
|
2017-04-23 21:31:08 +03:00
|
|
|
{
|
2017-09-03 11:43:45 +03:00
|
|
|
QTextCursor cursor = input_->textCursor();
|
2017-04-23 21:31:08 +03:00
|
|
|
|
2017-09-03 11:43:45 +03:00
|
|
|
QFont emoji_font("Emoji One");
|
|
|
|
emoji_font.setPixelSize(conf::emojiSize);
|
2017-04-23 21:31:08 +03:00
|
|
|
|
2017-09-03 11:43:45 +03:00
|
|
|
QFont text_font("Open Sans");
|
|
|
|
text_font.setPixelSize(conf::fontSize);
|
2017-04-23 21:31:08 +03:00
|
|
|
|
2017-09-03 11:43:45 +03:00
|
|
|
QTextCharFormat charfmt;
|
|
|
|
charfmt.setFont(emoji_font);
|
|
|
|
input_->setCurrentCharFormat(charfmt);
|
2017-04-23 21:31:08 +03:00
|
|
|
|
2017-09-03 11:43:45 +03:00
|
|
|
input_->insertPlainText(emoji);
|
|
|
|
cursor.movePosition(QTextCursor::End);
|
2017-04-23 21:31:08 +03:00
|
|
|
|
2017-09-03 11:43:45 +03:00
|
|
|
charfmt.setFont(text_font);
|
|
|
|
input_->setCurrentCharFormat(charfmt);
|
2017-04-23 21:31:08 +03:00
|
|
|
|
2017-09-03 11:43:45 +03:00
|
|
|
input_->show();
|
2017-04-06 02:06:42 +03:00
|
|
|
}
|
|
|
|
|
2017-08-20 13:47:22 +03:00
|
|
|
void
|
2017-11-06 00:01:21 +03:00
|
|
|
TextInputWidget::command(QString command, QString args)
|
2017-04-06 02:06:42 +03:00
|
|
|
{
|
2017-11-06 00:01:21 +03:00
|
|
|
if (command == "me") {
|
|
|
|
sendEmoteMessage(args);
|
|
|
|
} else if (command == "join") {
|
|
|
|
sendJoinRoomRequest(args);
|
2018-01-16 23:34:31 +03:00
|
|
|
} else if (command == "shrug") {
|
|
|
|
sendTextMessage("¯\\_(ツ)_/¯");
|
|
|
|
} else if (command == "fliptable") {
|
|
|
|
sendTextMessage("(╯°□°)╯︵ ┻━┻");
|
2017-09-03 11:43:45 +03:00
|
|
|
}
|
2017-04-06 02:06:42 +03:00
|
|
|
}
|
|
|
|
|
2017-09-10 12:58:00 +03:00
|
|
|
void
|
|
|
|
TextInputWidget::openFileSelection()
|
|
|
|
{
|
2017-12-01 18:33:49 +03:00
|
|
|
const auto fileName =
|
|
|
|
QFileDialog::getOpenFileName(this, tr("Select a file"), "", tr("All Files (*)"));
|
2017-09-10 12:58:00 +03:00
|
|
|
|
|
|
|
if (fileName.isEmpty())
|
|
|
|
return;
|
|
|
|
|
2017-12-01 18:33:49 +03:00
|
|
|
QMimeDatabase db;
|
|
|
|
QMimeType mime = db.mimeTypeForFile(fileName, QMimeDatabase::MatchContent);
|
|
|
|
|
|
|
|
const auto format = mime.name().split("/")[0];
|
2017-11-30 00:39:35 +03:00
|
|
|
|
2018-01-10 10:52:59 +03:00
|
|
|
QSharedPointer<QFile> file{new QFile{fileName, this}};
|
2017-12-01 18:33:49 +03:00
|
|
|
if (format == "image")
|
2018-01-10 10:52:59 +03:00
|
|
|
emit uploadImage(file, fileName);
|
2017-12-01 18:33:49 +03:00
|
|
|
else if (format == "audio")
|
2018-01-10 10:52:59 +03:00
|
|
|
emit uploadAudio(file, fileName);
|
2017-11-30 00:39:35 +03:00
|
|
|
else
|
2018-01-10 10:52:59 +03:00
|
|
|
emit uploadFile(file, fileName);
|
2017-09-10 12:58:00 +03:00
|
|
|
|
|
|
|
showUploadSpinner();
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
TextInputWidget::showUploadSpinner()
|
|
|
|
{
|
|
|
|
topLayout_->removeWidget(sendFileBtn_);
|
|
|
|
sendFileBtn_->hide();
|
|
|
|
|
|
|
|
topLayout_->insertWidget(0, spinner_);
|
|
|
|
spinner_->start();
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
TextInputWidget::hideUploadSpinner()
|
|
|
|
{
|
|
|
|
topLayout_->removeWidget(spinner_);
|
|
|
|
topLayout_->insertWidget(0, sendFileBtn_);
|
|
|
|
sendFileBtn_->show();
|
|
|
|
spinner_->stop();
|
|
|
|
}
|
|
|
|
|
2017-10-01 12:11:33 +03:00
|
|
|
TextInputWidget::~TextInputWidget() {}
|
2017-10-31 21:11:49 +03:00
|
|
|
|
|
|
|
void
|
|
|
|
TextInputWidget::stopTyping()
|
|
|
|
{
|
|
|
|
input_->stopTyping();
|
|
|
|
}
|
2017-11-03 09:54:17 +03:00
|
|
|
|
|
|
|
void
|
|
|
|
TextInputWidget::focusInEvent(QFocusEvent *event)
|
|
|
|
{
|
|
|
|
input_->setFocus(event->reason());
|
|
|
|
}
|
2017-11-16 17:33:52 +03:00
|
|
|
|
|
|
|
void
|
|
|
|
TextInputWidget::paintEvent(QPaintEvent *)
|
|
|
|
{
|
|
|
|
QStyleOption opt;
|
|
|
|
opt.init(this);
|
|
|
|
QPainter p(this);
|
|
|
|
style()->drawPrimitive(QStyle::PE_Widget, &opt, &p, this);
|
|
|
|
}
|