QOwnNotes/doc/scripting
2016-06-07 07:21:40 +02:00
..
absolute-media-links.qml added a new script function insertingFromMimeDataHook and renamed function modifyMediaMarkdown to insertMediaHook 2016-05-12 18:50:18 +02:00
example.qml there now is a new scripting hook noteToMarkdownHtmlHook(note, html) that is called when the markdown html of a note is generated 2016-05-18 18:03:42 +02:00
execute-command-after-note-update.qml you can now open a dialog to view past status messages and the log output from your scripts 2016-05-16 14:40:34 +02:00
insert-headline-with-link-from-github-url.qml downloading media files, web pages for links, calendar files for the todo list and files in QML scripting will now support following redirects from Qt 5.6 on and there now is a new script function script.downloadUrlToString() 2016-05-16 19:24:55 +02:00
note-text-from-5pm-mail.qml fixed a problem with the 5pm script 2016-06-07 07:21:40 +02:00
README.md updated logging information 2016-06-06 11:06:47 +02:00
use-tag-names-in-filename.qml many improvements with note file renaming and preserving tags in conjunction with scripting and automatic filename generation has been made 2016-05-19 17:20:28 +02:00

QOwnNotes Scripting

  • if you need access to a certain functionality in QOwnNotes or have questions or ideas please open an issue on the QOwnNotes issue page
  • since debug output is disabled in the releases of QOwnNotes, so you might want to use console.warn() instead of console.log() to actually see an output
    • additionally you can also use the script.log() command to log to the log dialog

Methods and objects QOwnNotes provides

Starting an external program in the background

Parameters

/**
 * QML wrapper to start a detached process
 *
 * @param executablePath the path of the executable
 * @param parameters a list of parameter strings
 * @return true on success, false otherwise
 */
bool startDetachedProcess(QString executablePath, QStringList parameters);

Usage in QML

script.startDetachedProcess("/path/to/my/program", ["my parameter"]);

Getting the path of the current note folder

Parameters

/**
 * QML wrapper to get the current note folder path
 *
 * @return the path of the current note folder
 */
QString currentNoteFolderPath();

Usage in QML

var path = script.currentNoteFolderPath();

Getting the current note

Parameters

/**
 * QML wrapper to get the current note
 *
 * @returns {NoteApi} the the current note object
 */
NoteApi currentNote();

Usage in QML

var note = script.currentNote();

Logging to the log dialog

Parameters

/**
 * QML wrapper to log to the log dialog
 *
 * @param text
 */
void log(QString text);

Usage in QML

script.log("my text");

Downloading an url to a string

Parameters

/**
 * QML wrapper to download an url and returning it as text
 *
 * @param url
 * @return {QString} the content of the downloaded url
 */
QString downloadUrlToString(QUrl url);

Usage in QML

script.downloadUrlToString("http://www.qownnotes.org");

Exposed classes

Note

class NoteApi {
    Q_PROPERTY(int id)
    Q_PROPERTY(QString name)
    Q_PROPERTY(QString fileName)
    Q_PROPERTY(QString noteText)
    Q_PROPERTY(QString decryptedNoteText)
    Q_PROPERTY(bool hasDirtyData)
    Q_PROPERTY(QQmlListProperty<TagApi> tags)
    Q_INVOKABLE QStringList tagNames();
};

Tag

class TagApi {
    Q_PROPERTY(int id)
    Q_PROPERTY(QString name)
    Q_PROPERTY(int parentId)
};