[KJots] Provide explicit "Save" action, use standard actions where possible
ClosedPublic

Authored by poboiko on Apr 29 2020, 8:24 PM.

Details

Summary

Use some standard actions for save, next page, previous page, rename.
Add "Save" action to menu and toolbar, otherwise it's not even clear how to save the note.
Don't use QInputDialog when renaming, just trigger inline rename.

Also, perform save procedure on quit (inside KJotsWidget::queryClose).
TODO: this is not yet functional, need to perform a synchronous job and wait for result.

CCBUG: 255998
CCBUG: 296242

Test Plan

All actions are functional

Diff Detail

Repository
R573 KJots
Lint
Automatic diff as part of commit; lint not applicable.
Unit
Automatic diff as part of commit; unit tests not applicable.
poboiko created this revision.Apr 29 2020, 8:24 PM
Restricted Application added a project: KDE PIM. · View Herald TranscriptApr 29 2020, 8:24 PM
poboiko requested review of this revision.Apr 29 2020, 8:24 PM

@dvratil: actually, there is an issue with saving on exit. Inside KJotsEdit::savePage we actually ask ETM to do the saving, which starts an async job.
However, if we do it when quitting, we tend to quit *before* the job dispatches, and lose unsaved changes :(

Is there a way to overcome this using ETM? Or should I just start ItemModifyJob by hand using non-async interface job->exec() here?
(actually, some feedback would probably be nice even when user presses Ctrl+S. E.g. change the cursor to "busy" one, or notify if there was an error and suggest to save it as a local file somewhere, etc...)

Hmmm, one option could be to add QEventLoopLocker into ETM to keep QApplication alive until the job in ETM has finished?

Hmmm, one option could be to add QEventLoopLocker into ETM to keep QApplication alive until the job in ETM has finished?

I've just tried it with the following patch:

There is an issue: ETM is created with KJotsWidget as a parent, so when we call quit(), we destroy everything, including the model.
It eventually forces us to release the lock, even before we catch the result() signal from the job.

However, KJots does save last changes with this patch, which is weird.
Probably that buys us just enough time so the job at least fires and reaches the server...

The ETM patch looks OK, but if the ETM is owned by the destroyed widget, then it likely won't work 100%.

Thinking of ETM, I see more issues with it: like no way to report an error back to the user when the ItemModifyJob fails. I created T13078 to solve this issue.

For now, I guess you should just use ItemModifyJob with exec() for now to workaround this.

poboiko updated this revision to Diff 81790.May 3 2020, 11:12 AM

Also use standard action for rename and drop rename dialog, just trigger inline rename

poboiko edited the summary of this revision. (Show Details)May 3 2020, 11:13 AM
poboiko retitled this revision from [KJots] Provide explicit "Save" action to [KJots] Provide explicit "Save" action, use standard actions where possible.
poboiko edited the summary of this revision. (Show Details)

For now, I guess you should just use ItemModifyJob with exec() for now to workaround this.

OK, thanks. I think I'll do it in a separate patch then, while let this one focus on using standard actions wherever possible.

dvratil accepted this revision.May 5 2020, 7:55 AM
This revision is now accepted and ready to land.May 5 2020, 7:55 AM
This revision was automatically updated to reflect the committed changes.