Previously, clicking the Edit button opened a dialog to edit it in. Now
it is done inside the applet itself. This makes it much less disruptive
and jarring, and makes the editing action feel smoother.
When copying something inside the same process that klipper is in,
reading the data through wayland will not work since we have to do
so in a blocking way due to how klipper is structured.
But we can check if we currently own the clipboard and just return that.
QMimeData::data() can fail. Fetching is done on demand. It's also
possible for clients to advertise mimedata they don't really have.
This patch avoids putting those broken entries in klipper's history.
QMimeData abstracts most mime type handling, but not text/plain vs
text/plain;charset=utf-8.
This is currently being done in QWayland inside qwaylanddataoffer. Given
this code is effectively a clone, we need to have the same check here.
Interestingly mimeData->text() worked before but not hasText(), which is
why it was unnoticed in the test pasteClient tool.
This fixes klipper and GTK apps.
BUG: 424694
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
This commit turns on "Ignore selection" by default, copy selected
text by default is generally not expected and make the clipboard
history seems "random".
You can still paste selected text with the mouse middle click.
This commit increases the default clipboard size from 7 to 20, that
way it could be more useful, allowing user to recover older
clipboard contents by default.
select() is not safe, it can corrupt stack if the polled fd is greater
than FD_SETSIZE. poll() is a much safer alternative. Unlike 20 or so
years ago, many unix systems support poll() nowadays, so we can safely
use it.
Previously the "clear clipboard history?" dialog used `KMessageBox::questionYesNo`
which if "don't ask again" is ticked then saves the answer even if No was answered.
This can cause the user to not be able to ever clear the clipboard ever again. This
commit changes it to `KMessageBox::warningContinueCancel` which doesn't do that, and
is more appropriate for the kind of question we're asking.
BUG: 336053
FIXED-IN: 5.22
This is a mind-blowingly amazing feature, but nobody knows about it
because it's disabled by default since it has no default shortcut, and
there is no visible UI to tell you about it except for the shortcut
configuration view buried in Klipper's settings window.
A similar feature was just recently introduced in Microsoft Windows, and
users have started to ask why no equivalent KDE feature exists, because
they are unaware that it already does! The shortcut Microsoft chose is
Meta+V, which is a completely sensible one. If we set the same shortcut
for the Klipper feature, discoverability is automatically increased
because users familiar with Windows are already becoming accustomed to the
Meta+V shortcut. This is not an argument for deliberately copying
another platform, but rather making use of the user familiarity that
they have helpfully done the hard work of creating for us. Meta+V is
unused and is an appropriate shell-level global shortcut by virtue of
using the Meta key. So let's bind it to this Klipper feature by default.