Add ability to disable saving in `KTextEditor::Document`
AbandonedPublic

Authored by russellg on Feb 16 2017, 5:56 AM.

Details

Reviewers
dhaumann
cullmann
Group Reviewers
KTextEditor
Summary

I'm currently writing an application where the user is expected to type some code in, but it isn't then saved to a file, but it is just passed back to the application in memory.

It's misleading to the user for them to press Ctrl+S and then a save dialog comes up--they shouldn't be saving it!

Here's my fix. Any suggestions are welcome.

Test Plan

I added a basic test to the test suite, it's not very good though. I wanted to make sure that the documentSaveAs function was failing _before_ I called setSaveEnabled, but that would require somehow pressing "cancel" on the file dialog which I do not know how to do, if it's possible at all.

Diff Detail

Lint
Lint Skipped
Unit
Unit Tests Skipped
russellg updated this revision to Diff 11389.Feb 16 2017, 5:56 AM
russellg retitled this revision from to Add ability to disable saving in `KTextEditor::Document`.
russellg updated this object.
russellg edited the test plan for this revision. (Show Details)
russellg set the repository for this revision to R39 KTextEditor.
Restricted Application added a project: Frameworks. · View Herald TranscriptFeb 16 2017, 5:56 AM
Restricted Application added subscribers: Frameworks, kwrite-devel. · View Herald Transcript
russellg updated this revision to Diff 11390.Feb 16 2017, 5:59 AM
russellg removed R39 KTextEditor as the repository for this revision.

Updated the test to be slightly better. Use QVERIFY(...) instead of QCOMPARE(..., true) in one case, and make sure that saveEnabled() is false after calling setSaveEnabled(false).

anthonyfieroni removed a subscriber: anthonyfieroni.

Add reviewers KTextEditor, try not add virtual functions to base class :)

dhaumann edited edge metadata.Feb 16 2017, 8:22 PM

I think we don't need this patch: The solution is to disable the save and saveAs actions: Iterate over the document's KActionCollection to find the correct actions (see katepart5ui.rc), and then disable / remove them. This is also how KDevelop and Kate once did this, iirc.
See:

If this does not work for you, please extend the ConfigInterface that the Document inherits. Does that work for you?

Please discard this patch for now. Feel free to make a new patch with the ConfigInterface in case the proposed solution with the action collection does not work.

Sounds good, that's good idea!

russellg abandoned this revision.Feb 20 2017, 12:05 AM