This patch allows the application to manually popup the menu by using the KIO::ShowMenuManually flag with the DropJob::showMenu() method.
BUG: 415917
davidedmundson | |
elvisangelaccio | |
mart | |
dfaure |
Frameworks |
This patch allows the application to manually popup the menu by using the KIO::ShowMenuManually flag with the DropJob::showMenu() method.
BUG: 415917
Can't reproduce the bug with this patch.
No Linters Available |
No Unit Test Coverage |
Buildable 21021 | |
Build 21039: arc lint + arc unit |
src/widgets/dropjob.h | ||
---|---|---|
149 | Do not change signature of exported function, just add another one. |
I don't fully understand why popupMenuAboutToShow isn't sufficient.
An alternative approach I could think would be allowing the signal handler to delay the menu as necessary rather than having to create the drop job differently?
src/widgets/dropjob.h | ||
---|---|---|
151 | bool arguments are generally frowned upon. Perhaps introduce a flag instead. |
I have some questions.
1, Should DropJob::setApplicationActions() be called only one time?
2, I see this when I drop multiple file types at once to the desktop (e.g. 2 jpg and 1 zip), the DropJob::setApplicationActions() is called 3 times as follow:
Mimetype Job returns. "image/jpeg" Received a suitable dropEvent at QPoint(1199,237) Creating menu for: "image/jpeg" QPoint(1199,237) Mimetype Job returns. "application/zip" Received a suitable dropEvent at QPoint(1199,237) Creating menu for: "application/zip" QPoint(1199,237) Mimetype Job returns. "image/jpeg" Received a suitable dropEvent at QPoint(1199,237) Creating menu for: "image/jpeg" QPoint(1199,237)
But finally only the last one's appActions are added to the menu (the others are overwritten). This is a bit weird.
I want to understand your intention to make this patch as good as possible.
Yes, you could check it here: https://phabricator.kde.org/source/plasma-framework/browse/master/src/scriptengines/qml/plasmoid/containmentinterface.cpp
So do you mean this should be fixed to call DropJob::setApplicationActions() only one time?
And do you @mart agree with that?
src/widgets/dropjob.cpp | ||
---|---|---|
415 | QCursor::pos() should be avoided as it's not reliable on wayland. The whole "popup() again" here looks like a workaround to me. Can't this be fixed on the plasma side? |
src/widgets/dropjob.cpp | ||
---|---|---|
415 | I'm having a plan to make it popup only one time.
this is how it does currently, I just copy the original code. This could need to be resolved in another patch. |
src/widgets/dropjob.cpp | ||
---|---|---|
415 |
I think it can't, because KIO::DropJob popup the menu, only afterward Plasma adds new items into it. |
I agree with the approach. Just naming needs to be improved.
I'd call the method "showMenu" or "showPopup".
DelayPopup hints at a builtin timer, better call it something like DontShowPopup (even though some people don't like negative flags). ManualShowPopup? ExplicitShowPopup?
And it shouldn't be in the job_base.h enum, which can be used by all jobs.
Better add something to DropJob specifically.
The new method also needs docu including @since.
Thanks!
src/widgets/dropjob.cpp | ||
---|---|---|
418 | This '{' goes on its own line. |
You can land after making these last minute adjustments, no need for another round of review :)
src/widgets/dropjob.h | ||
---|---|---|
82 ↗ | (On Diff #73337) | Nitpick: normally it's a single star on the last line. Dunno if it matters for doxygen. |
160 ↗ | (On Diff #73337) | (same) |
161 ↗ | (On Diff #73337) | BIC = Binary Incompatible Change. What's BCI? In any case better add "TODO KF6" to the comment, I'm sure we'll be grepping for that when the time comes (rather than BCI/BIC). |
Hi. I just came across dropping random data (in my case an image) into file views not working, i.e. not creating any new files due to no more data in the QMimeData instance referred to in the DropJob.
Looking into the details, it seems this is due to the flaw of KIO::DropJob being async, but the QDropEvent (which got a respective comment) and even more the QMimeData it exposes (which has no comment, but just a helpless QPointer wrapper) is not defined to outlive the QWidget drop event handler call. And both at least X11 and Wayland protocol seems to negotiate things by the drop serving instance only offering a list of MIME types, next to the copy or move action, and only on the reply of the drop consumer actually deliver the data of the selected MIME type. All this happens during what is wrapped by Qt in the QDropEvent.
My naive reaction to this would be to use some QEventLoop inside KIO::drop() for the user interaction to query "Copy or Move" and "Which format?", then extract the very data from the QMimeData, before returning to the Qt drop event handler call from which KIO::drop() would be called.
But the method added here, DropJob::showMenu() and their usage would not be fixed by this. Anyone around still involved with this who could work on this from their use case POV? Or at least give some thoughts on this?
And now reported the challenge of drop objects lifetime vs user input on decisions by https://bugreports.qt.io/browse/QTBUG-125229