Paste from Cover?

Hi,

I am trying to read the clipboard from the cover action:

import QtQuick 2.0
import Sailfish.Silica 1.0
import Nemo.Configuration 1.0
import Nemo.DBus 2.0
import org.nemomobile.lipstick 0.1

[...]

    CoverActionList {
        id: actionPaste
        iconBackground: false
        CoverAction {
            iconSource: "image://theme/icon-s-clipboard"
            onTriggered: {
               fromCover=true
               console.log( "Cover Action:" + Clipboard.text )
               app.activate()
            }
        }
    }//CoverActionList

… but the Clipboard.text is always empty/undefined.

Note that I am not using a C++ application, it’s a pure QML page started with qmlscene (should that matter). What am I doing wrong?

i saw something like HarbourClipboard.text in in coverpage of harbour-qrclip
too lazy to investigate if it is a common class or local to harbour-qrclip but you might want to check code of that app ?

1 Like

Thank you, will do!

I would really like to stay in pure QML without a library/app but if it’s necessary…

import QtQuick 2.0
import Sailfish.Silica 1.0

CoverBackground {
    id: cover

    Label {
        id: copyThisText
        text: "My slap hap app"
        width: parent.width / 1.1
        wrapMode: Label.WordWrap
        horizontalAlignment: Label.AlignHCenter
        x: Theme.horizontalPageMargin / 2
    }

    CoverActionList {
        id: coverAction

        CoverAction {
            iconSource: "image://theme/icon-l-clipboard"
            onTriggered: {
                Clipboard.text = copyThisText.text
                console.log( "Cover Action:" + copyThisText.text)
                window.activate()
            }
        }
    }
}
1 Like

Thank you! Now, how about the other way around, I have something the clipboard from another application, and want to paste it through an clipboard action. I have tried with a TextField and field.paste(), but Clipboard.text is always empty. Even though the same application if brought to front/fullscreen, a textfield.paste() does what it should.

import QtQuick 2.0
import Sailfish.Silica 1.0

CoverBackground {

    Label {
        id: pasteAppText
        width: parent.width / 1.1
        wrapMode: Label.WordWrap
        horizontalAlignment: Label.AlignHCenter
        x: Theme.horizontalPageMargin / 2
    }

    CoverActionList {
        id: coverAction

        CoverAction {
            iconSource: "image://theme/icon-l-clipboard"
            onTriggered: {
                pasteAppText.text = Clipboard.text
                console.log( "Cover Action:" + Clipboard.text )
            }
        }
    }
}

FirstPage.qml

i used TextField for this purpose;

import QtQuick 2.0
import Sailfish.Silica 1.0

Page {
    id: page

    allowedOrientations: Orientation.All

    SilicaFlickable {
        anchors.fill: parent
        contentHeight: column.height

        Column {
            id: column
            width: page.width
            spacing: Theme.paddingLarge

            PageHeader {
                title: "Cover text"
            }

            Label {
                id: info
                wrapMode: Label.WordWrap
                width: parent.width / 1.1
                x: Theme.horizontalPageMargin
                horizontalAlignment: Label.AlignLeft
                text: "Place your text copied from the app's cover into the box below."
            }

            TextField {
                width: 400
                color: Theme.secondaryHighlightColor
                font.pixelSize: Theme.fontSizeSmall
                placeholderText: "Paste your text here. . ."
            }
        }
    }
}
4 Likes