New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Apply all external modifications of the current note option #405

Closed
Maboroshy opened this Issue Dec 4, 2016 · 21 comments

Comments

Projects
None yet
2 participants
@Maboroshy
Contributor

Maboroshy commented Dec 4, 2016

With the help of a new scripting hook I've implemented adding clipboard content to a currently opened note. But the app is not really happy I'm doing something behind it's back.

With current options it either notifies on every change, either don't show changes until I refresh the folder.

Could you implement a subject option, like an "yes for all" mode. Maybe with appropriate warning if needed. So the app would simply refresh the note if it detects external changes.

I use 1 second save interval and edit notes on one device at a time, so data loss will hardly occur.

@pbek pbek added the enhancement label Dec 4, 2016

@pbek

This comment has been minimized.

Owner

pbek commented Dec 4, 2016

How does your script look like?

@Maboroshy

This comment has been minimized.

Contributor

Maboroshy commented Dec 4, 2016

Oh, the get current note part is quite basic:

import QtQml 2.0
import com.qownnotes.noteapi 1.0

QtObject {

    property var bashNote:"/storage/emulated/0/notes/bash-note";

    function noteOpenedHook(note) {
        var replaceCommand = "0,/^clipnote_inbox_file_name=/ s|^clipnote_inbox_file_name=.*|clipnote_inbox_file_name='" + note.fullNoteFilePath + "'|";
        var arguments = ["-i",replaceCommand,bashNote];
        script.startDetachedProcess("sed", arguments);
    }
}

It sets inbox note setting inside Bash-note to current note. Little ugly, but I'm yet to fully unserstand, how startDetachedProcess works with arguments.

There are also custom actions. I've also started to experiment with QtQuick GUI, not sure I'll use it though, command line is enough for me.

@Maboroshy

This comment has been minimized.

Contributor

Maboroshy commented Dec 4, 2016

By the way the script above sometimes goes infinite loop for some reason I'm yet to find out.

@pbek

This comment has been minimized.

Owner

pbek commented Dec 4, 2016

I'm not sure what you are doing and what you are intending to do. :)
When are you accessing the clipboard?
There is a scripting command for it: https://github.com/pbek/QOwnNotes/tree/develop/doc/scripting#accessing-the-clipboard

And you are really modifying a note that just opened? This could maybe trigger an other note opening process...

@Maboroshy

This comment has been minimized.

Contributor

Maboroshy commented Dec 4, 2016

The only thing it does is getting current note file name outside the app and putting it into certain place of my shell script file. As simple as that.

All clipboard logic (more like "selected text" logic really) is done by the shell script. For now I think that, till I don't need a cross-platform code, using Qt for clipboard handling brings little gain and many extra code and limitations. It's easier to "talk" to X-server directly.

I'll put a safety check to resolve the loop.

@pbek

This comment has been minimized.

Owner

pbek commented Dec 4, 2016

So in this script you are just storing the filename of the current note to a file?

And yet I still fail to realize what you need and why? 😸

@Maboroshy

This comment has been minimized.

Contributor

Maboroshy commented Dec 5, 2016

So in this script you are just storing the filename of the current note to a file?

Yes and then the bigger shell script puts the selected text into that note when I press a key shortcut.

I think I've put too much detail and distract you. The script has nothing to do with the issue.

The issue is: I modify currently opened notes externally, and I just want to have kind of "yes for all" in "current note modified" dialog, so the app would just refresh the note without asking me each time.

I think the best way is to implement "Apply all external modifications of the current note" into options.

@pbek

This comment has been minimized.

Owner

pbek commented Dec 5, 2016

refresh "the note" or "this an all other notes" without asking?
this would go into conflict with other settings in the general settings tab...
what is the purpose of your script?
do you need to replace the currents text or just add text to the note at the cursor position (because for the latter there also is a scripting method)

@Maboroshy

This comment has been minimized.

Contributor

Maboroshy commented Dec 5, 2016

The shell script adds text to the top or to the bottom of a file, which is a currently opened note. It's an external modification for the app.

This shell script is used mostly when app is out of focus, while user is using browser or other app selecting text and adding it to the file by a key shortcut.

@pbek

This comment has been minimized.

Owner

pbek commented Dec 7, 2016

So you want a checkbox Always accept external changes?

@Maboroshy

This comment has been minimized.

Contributor

Maboroshy commented Dec 7, 2016

Yep.

@pbek

This comment has been minimized.

Owner

pbek commented Dec 8, 2016

16.12.3

  • you can now choose Always accept external changes in the future when your
    current note got modified externally and the diff dialog pops up
    • you can reset that checkbox in the general settings

@pbek pbek added this to the 16.12.3 milestone Dec 8, 2016

@pbek

This comment has been minimized.

Owner

pbek commented Dec 8, 2016

There now is a new release, could you please test it and report if the new features work for you?

@Maboroshy

This comment has been minimized.

Contributor

Maboroshy commented Dec 8, 2016

The new feature works. Using external apps with QOwnNotes is much more natural now.

But once you turn "apply" on it's stuck till app restart. Changing to "ignore" won't work right away, it's still in "apply" mode till app restart.

Also, with "apply" mode on, notifications about note changes doesn't pop-up, which is the right behaviour to me. But "notify" can still be on.
You've made "ignore" and "apply" two-way options, but I think that "notify" is the third mode which can't be combined with those two.

Personally I think that external changes handling is complete with the new feature.

@pbek

This comment has been minimized.

Owner

pbek commented Dec 9, 2016

Thank you for testing, I will try to reproduce the first and take care of the 2nd.

@pbek

This comment has been minimized.

Owner

pbek commented Dec 9, 2016

But once you turn "apply" on it's stuck till app restart. Changing to "ignore" won't work right away, it's still in "apply" mode till app restart.

Are you sure that you edited to the note within one minute in QOwnNotes, otherwise the dialog wouldn't even come up...

@pbek

This comment has been minimized.

Owner

pbek commented Dec 9, 2016

Meaning the note will always get updated if the note wasn't edited in QOwnNotes for one minute.

@pbek

This comment has been minimized.

Owner

pbek commented Dec 10, 2016

16.12.4

  • all three settings about external modifications of the current note in the
    general settings are now mutual exclusive
@pbek

This comment has been minimized.

Owner

pbek commented Dec 10, 2016

There now is a new release, could you please test it and report if the new features work for you?

@Maboroshy

This comment has been minimized.

Contributor

Maboroshy commented Dec 10, 2016

All works, thanks!

@Maboroshy Maboroshy closed this Dec 10, 2016

@pbek

This comment has been minimized.

Owner

pbek commented Dec 10, 2016

Great!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment