[klipper] Sync history to disk after each change
Review Request #122382 - Created Feb. 2, 2015 and submitted
By invoking saveHistory after each change we ensure that the clipboard
doesn't lose data in case klipper (or in dataengine mode plasmashell)
To not cause stalls, the saving is performed in a thread using
QtConcurrentRun. As klipper itself is not thread save a Mutex is
used to lock changes in the HistoryModel.
looked at ~/.local/share/klipper/history2.lst in Okteta, changed clipboard and pressed F5 in Okteta. Repeated these steps multiple times.
To not overload the system the save operations are delayed and queued.
Each save is delayed by five seconds since the last clipboard change.
So if the clipboard is changed multiple times in a short interval it
doesn't get synced to the disk till the interaction has settled.
Revision 2 (+33)
This came about partly due to my loud complaining that I was losing clipboard data when plasmashell died. I too think that Klipper should not be running in-process with plasmashell ideally - in my view the primary mission of Klipper is to persist clipboard state so it remains available when other things go away, and I think it's best-equipped to accomplish that mission if it's as stand-alone as possible, extending its coverage from "the app goes away" to "the shell goes away".
But that said, Klipper saving its history quickly is orthogonal to that, since it could also be argued for even in a standalone design. This does seem like a step into the right direction, that as a bonus also mitigates the fallout from being bundled with plasmashell