chatgui: clear clipboard before setText for reliable copy on Linux
This commit is contained in:
1 parent
cca84308b5
commit
fdd9fbb34e
2 files changed
+6
-1
No files matched your search
@@ -133,6 +133,7 @@ void ChatView::copySelection() {
|
||||
QString text = idx.data(MsgTextRole).toString();
|
||||
if (m_textSel.startChar >= 0 && m_textSel.endChar > m_textSel.startChar)
|
||||
text = text.mid(m_textSel.startChar, m_textSel.endChar - m_textSel.startChar);
|
||||
QApplication::clipboard()->clear(QClipboard::Clipboard);
|
||||
QApplication::clipboard()->setText(text);
|
||||
} else {
|
||||
QString r;
|
||||
@@ -145,6 +146,7 @@ void ChatView::copySelection() {
|
||||
r += idx.data(MsgAuthorRole).toString() + ": ";
|
||||
r += idx.data(MsgTextRole).toString();
|
||||
}
|
||||
QApplication::clipboard()->clear(QClipboard::Clipboard);
|
||||
QApplication::clipboard()->setText(r);
|
||||
}
|
||||
}
|
||||
@@ -27,9 +27,12 @@ InviteDialog::InviteDialog(const QString& link, QWidget* parent)
|
||||
auto *copyBtn = new QPushButton("Скопировать", this);
|
||||
connect(copyBtn, &QPushButton::clicked, this, [this, linkEdit]() {
|
||||
QClipboard* cb = QApplication::clipboard();
|
||||
cb->clear(QClipboard::Clipboard);
|
||||
cb->setText(m_link, QClipboard::Clipboard);
|
||||
if (cb->supportsSelection())
|
||||
if (cb->supportsSelection()) {
|
||||
cb->clear(QClipboard::Selection);
|
||||
cb->setText(m_link, QClipboard::Selection);
|
||||
}
|
||||
linkEdit->setFocus();
|
||||
});
|
||||
btnLayout->addWidget(copyBtn);
|
||||
|
||||
Reference in new issue
Block a user