fixed ctrl+c to copy text

This commit is contained in:
fourtf
2017-09-21 02:20:02 +02:00
parent 9d671ac873
commit ab641abd9c
9 changed files with 66 additions and 17 deletions
+20 -3
View File
@@ -161,15 +161,22 @@ ChatWidgetInput::ChatWidgetInput(ChatWidget *_chatWidget, EmoteManager &emoteMan
notebook->previousTab();
}
} else if (event->key() == Qt::Key_C && event->modifiers() == Qt::ControlModifier) {
event->accept();
this->chatWidget->doCopy();
if (this->chatWidget->view.hasSelection()) {
this->chatWidget->doCopy();
event->accept();
}
}
});
this->textLengthVisibleChangedConnection =
SettingsManager::getInstance().showMessageLength.valueChanged.connect(
[this](const bool &value) { this->textLengthLabel.setHidden(!value); });
QObject::connect(&this->textInput, &QTextEdit::copyAvailable, [this](bool available) {
if (available) {
this->chatWidget->view.clearSelection();
}
});
}
ChatWidgetInput::~ChatWidgetInput()
@@ -177,6 +184,16 @@ ChatWidgetInput::~ChatWidgetInput()
this->textLengthVisibleChangedConnection.disconnect();
}
void ChatWidgetInput::clearSelection()
{
QTextCursor c = this->textInput.textCursor();
c.setPosition(c.position());
c.setPosition(c.position(), QTextCursor::KeepAnchor);
this->textInput.setTextCursor(c);
}
void ChatWidgetInput::refreshTheme()
{
QPalette palette;