[Qt-components] Ubuntu UI toolkit - Clipboard access

Zsombor Egri zsombor.egri at canonical.com
Wed Jan 23 09:06:59 CET 2013


Hello,

Here's an API we are proposing for accessing the system clipboard from
QML and to filter its content before being copied into a TextField/TextArea.

The API consists of an object, a data transfer type and a filter element.

The global object is based on (and uses) QClipboard functionality:

*clipboard* {
    function *clear*() - to clear the clipboard content
    function *setData*(string mimeType, var data) - pushes data to the
clipboard
    function MimeData *data*() - retrieves the clipboard data
}

The MimeData type provides access to the clipboard data itself; all
properties are read-only.

*MimeData* {
    readonly property list<string> *types* - contains the available
types in the clipboard
    readonly property string *text* - text data or undefined if no text
data in clipboard
    readonly property string *html* - HTML data or undefined
    readonly property list<url> *urls* - list or URLs or undefined
    readonly property color *color* - color data or undefined

    function var *mimeData*(string type) - returns data corresponding to
the MIME type
}

And finally the clipboard filter element, which is meant to capture
clipboard changes aswell as to grab clipboard key shortcuts from a
TextField or TextArea so data can be filtered before pasting it into the
text inputs.

*ClipboardFilter* {
    property Item *target* - target item on which the filtering will be
applied
    property bool *grabCopy*: false - when true, grabs clipboard key
sequence for Copy operation
    property bool *grabCut*: false - when true, grabs clipboard key
sequence for Cut operation
    property bool *grabPaste*: false - when true, grabs clipboard key
sequence for Paste operation

    signal *dataChanged*(MimeData data) - notifies about clipboard
changes, no matter if the target has focus or not
    signal *copy*() - triggered on Cut/Copy key sequence so data can be
altered before being pushed to clipboard
    signal *paste*(MimeData data) - triggered on clipboard key shortcut
Paste so data can be filtered before being pasted into the target.
}

This change also requires us to modify TextField/TextArea paste()
function so it gets a parameter holding the data to be inserted into the
content.

Opinions?

Cheers,
Zsombor
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.qt-project.org/pipermail/qt-components/attachments/20130123/83b21bbb/attachment.html 


More information about the Qt-components mailing list