Commit f9669af2 authored by ValdikSS ValdikSS's avatar ValdikSS ValdikSS Committed by David Edmundson
Browse files

Trim very long text strings in Klipper history view

Klipper may freeze the whole plasmashell for tens of seconds trying
to render very long text string from history in the popup.

Trim very large strings to 200 characters (tooltip default) to prevent this.

BUG: 431673
parent 7a0686b4
......@@ -25,3 +25,9 @@ QMimeData *HistoryStringItem::mimeData() const
data->setText(m_data);
return data;
}
QString HistoryStringItem::text() const
{
const int TEXT_LENGTH_LIMIT = 200;
return m_data.left(TEXT_LENGTH_LIMIT - 1) + (m_data.length() <= TEXT_LENGTH_LIMIT ? QStringLiteral("") : QStringLiteral("…"));
}
......@@ -37,8 +37,3 @@ public:
private:
QString m_data;
};
inline QString HistoryStringItem::text() const
{
return m_data;
}
......@@ -870,7 +870,7 @@ void Klipper::editData(const QSharedPointer<const HistoryItem> &item)
KTextEdit *edit = new KTextEdit(dlg);
edit->setAcceptRichText(false);
if (item) {
edit->setPlainText(item->text());
edit->setPlainText(item->mimeData()->text());
}
edit->setFocus();
edit->setMinimumSize(300, 40);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment