2
0
mirror of https://github.com/kotatogram/kotatogram-desktop synced 2025-08-31 14:45:14 +00:00

Replace FlatTextarea with InputField.

This commit is contained in:
John Preston
2018-05-22 00:31:46 +03:00
parent 30dd8fe070
commit 017ec87d60
29 changed files with 1646 additions and 2272 deletions

View File

@@ -33,7 +33,7 @@ Draft::Draft(
}
Draft::Draft(
not_null<const Ui::FlatTextarea*> field,
not_null<const Ui::InputField*> field,
MsgId msgId,
bool previewCancelled,
mtpRequestId saveRequestId)

View File

@@ -8,7 +8,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#pragma once
namespace Ui {
class FlatTextarea;
class InputField;
} // namespace Ui
namespace Data {
@@ -25,7 +25,7 @@ struct Draft {
bool previewCancelled,
mtpRequestId saveRequestId = 0);
Draft(
not_null<const Ui::FlatTextarea*> field,
not_null<const Ui::InputField*> field,
MsgId msgId,
bool previewCancelled,
mtpRequestId saveRequestId = 0);

View File

@@ -8,6 +8,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include "data/data_types.h"
#include "data/data_document.h"
#include "ui/widgets/input_fields.h"
void AudioMsgId::setTypeFromAudio() {
if (_audio->isVoiceMessage() || _audio->isVideoMessage()) {
@@ -21,24 +22,20 @@ void AudioMsgId::setTypeFromAudio() {
}
}
void MessageCursor::fillFrom(const QTextEdit *edit) {
QTextCursor c = edit->textCursor();
position = c.position();
anchor = c.anchor();
QScrollBar *s = edit->verticalScrollBar();
scroll = (s && (s->value() != s->maximum()))
? s->value()
: QFIXED_MAX;
void MessageCursor::fillFrom(not_null<const Ui::InputField*> field) {
const auto cursor = field->textCursor();
position = cursor.position();
anchor = cursor.anchor();
const auto top = field->scrollTop().current();
scroll = (top != field->scrollTopMax()) ? top : QFIXED_MAX;
}
void MessageCursor::applyTo(QTextEdit *edit) {
auto cursor = edit->textCursor();
void MessageCursor::applyTo(not_null<Ui::InputField*> field) {
auto cursor = field->textCursor();
cursor.setPosition(anchor, QTextCursor::MoveAnchor);
cursor.setPosition(position, QTextCursor::KeepAnchor);
edit->setTextCursor(cursor);
if (auto scrollbar = edit->verticalScrollBar()) {
scrollbar->setValue(scroll);
}
field->setTextCursor(cursor);
field->scrollTo(scroll);
}
HistoryItem *FileClickHandler::getActionItem() const {

View File

@@ -12,6 +12,10 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
class HistoryItem;
using HistoryItemsList = std::vector<not_null<HistoryItem*>>;
namespace Ui {
class InputField;
} // namespace Ui
namespace Data {
struct UploadState {
@@ -384,16 +388,16 @@ inline MsgId clientMsgId() {
struct MessageCursor {
MessageCursor() = default;
MessageCursor(int position, int anchor, int scroll)
: position(position)
, anchor(anchor)
, scroll(scroll) {
: position(position)
, anchor(anchor)
, scroll(scroll) {
}
MessageCursor(const QTextEdit *edit) {
fillFrom(edit);
MessageCursor(not_null<const Ui::InputField*> field) {
fillFrom(field);
}
void fillFrom(const QTextEdit *edit);
void applyTo(QTextEdit *edit);
void fillFrom(not_null<const Ui::InputField*> field);
void applyTo(not_null<Ui::InputField*> field);
int position = 0;
int anchor = 0;