mirror of
https://github.com/Chatterino/chatterino2.git
synced 2024-11-13 19:49:51 +01:00
Fixes #270 Copying text is broken
This commit is contained in:
parent
739c17c0c8
commit
bcf0ebd8ef
|
@ -134,7 +134,8 @@ void MessageLayoutContainer::breakLine()
|
|||
}
|
||||
|
||||
this->lineStart = this->elements.size();
|
||||
this->currentX = (int)(this->scale * 8);
|
||||
// this->currentX = (int)(this->scale * 8);
|
||||
this->currentX = 0;
|
||||
this->currentY += this->lineHeight;
|
||||
this->height = this->currentY + (this->margin.bottom * this->scale);
|
||||
this->lineHeight = 0;
|
||||
|
@ -409,19 +410,21 @@ int MessageLayoutContainer::getLastCharacterIndex() const
|
|||
void MessageLayoutContainer::addSelectionText(QString &str, int from, int to)
|
||||
{
|
||||
int index = 0;
|
||||
bool xd = true;
|
||||
bool first = true;
|
||||
|
||||
for (std::unique_ptr<MessageLayoutElement> &ele : this->elements) {
|
||||
int c = ele->getSelectionIndexCount();
|
||||
|
||||
if (xd) {
|
||||
qDebug() << c;
|
||||
|
||||
if (first) {
|
||||
if (index + c > from) {
|
||||
ele->addCopyTextToString(str, index - from, to - from);
|
||||
xd = false;
|
||||
ele->addCopyTextToString(str, from - index, to - from);
|
||||
first = false;
|
||||
}
|
||||
} else {
|
||||
if (index + c > from) {
|
||||
ele->addCopyTextToString(str, 0, index - to);
|
||||
if (index + c > to) {
|
||||
ele->addCopyTextToString(str, 0, to - index);
|
||||
break;
|
||||
} else {
|
||||
ele->addCopyTextToString(str);
|
||||
|
|
|
@ -279,14 +279,18 @@ QString ChannelView::getSelectedText()
|
|||
return result;
|
||||
}
|
||||
|
||||
for (int msg = selection.min.messageIndex; msg <= selection.min.messageIndex; msg++) {
|
||||
qDebug() << "xd >>>>";
|
||||
for (int msg = selection.min.messageIndex; msg <= selection.max.messageIndex; msg++) {
|
||||
MessageLayoutPtr layout = messagesSnapshot[msg];
|
||||
int from = msg == selection.min.messageIndex ? selection.min.charIndex : 0;
|
||||
int to = msg == selection.max.messageIndex ? selection.max.charIndex
|
||||
: layout->getLastCharacterIndex();
|
||||
: layout->getLastCharacterIndex() + 1;
|
||||
|
||||
qDebug() << "from:" << from << ", to:" << to;
|
||||
|
||||
layout->addSelectionText(result, from, to);
|
||||
}
|
||||
qDebug() << "xd <<<<";
|
||||
|
||||
return result;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue