• May 18, 2024, 05:08:35 am

Author Topic: Belle FP2 ShareUI access  (Read 1556 times)

0 Members and 1 Guest are viewing this topic.

Offline huellif

  • Developer
  • Christmas Santa
  • ****
  • Posts: 402
  • Reputation: 212
Belle FP2 ShareUI access
« on: July 08, 2013, 11:44:37 pm »
Hi,
maybe you noticed the Mirror widget OTA update for Belle FP2 has access to Belle FP2 ShareUI.

I did a little research and "found" this QML code:
Quote
import QtQuick 1.1
import MirrorApp 1.0
import QtMultimediaKit 1.1
import com.nokia.symbian 1.1
import com.nokia.shareui 1.0

Page {
    LayoutMirroring.enabled: symbian.rightToLeftDisplayLanguage
    LayoutMirroring.childrenInherit: true
    property alias shareUrl : shareUI.url
    property alias shareThumbnail : shareUI.thumbnail

    ShareUI {
        id: shareUI
        anchors.fill: parent
        contentType: "image/jpeg"

        onShare: pageStack.pop(photoPage)
        onCancel: pageStack.pop(photoPage)
        onBack: pageStack.pop(photoPage)
    }

    Component.onCompleted: shareUI.initialize(false)
}
Quote
import QtQuick 1.0
import MirrorApp 1.0
import QtMultimediaKit 1.1
import com.nokia.symbian 1.1

Page {
    property alias image: img.source
    property string imagePath: ""
    property variant sharePage
    property variant socialPage
    property bool sharingSupported: false
    orientationLock: PageOrientation.LockLandscape

    Image {
        id: img
        anchors.fill: parent
        fillMode: Image.PreserveAspectFit
        smooth: true
        transform: Rotation {
            origin.x: img.width/2;
            origin.y: img.height/2;
            axis { x: 0; y: 1; z: 0 }
            angle: 180
        }
    }

    Item {
        id: photoToolbar
        z: 50
        anchors.right: parent.right
        height: parent.height
        width: 80
        MirrorToolbarButton {
            anchors.horizontalCenter: parent.horizontalCenter
            anchors.bottom: parent.bottom
            iconSource: "qrc:/back.svg"
            tooltipText: qsTrId("qtn_qmlmirror_photopage_back")
            onClicked: pageStack.pop();
            rotation: 270
            alignLeft: true
        }
        MirrorToolbarButton {
            visible: (imagePath != "")
            anchors.centerIn: parent
            iconSource: "qrc:/delete.svg"
            tooltipText: qsTrId("qtn_qmlmirror_photopage_delete")
            onClicked: {
                mirrorUtils.remove(imagePath);
                pageStack.pop();
            }
            rotation: 270
        }
        MirrorToolbarButton {
            visible: (imagePath != "" && sharingSupported)
            anchors.horizontalCenter: parent.horizontalCenter
            anchors.top: parent.top
            iconSource: "qrc:/share.svg"
            tooltipText: qsTrId("qtn_qmlmirror_photopage_share")
            onClicked: share();
            rotation: 270
            alignRight: true
        }
    }

    function share() {
        // sr1/sr1+ don't have shareui. If not present,
        // fall back to nokia social if it's not available
        if (!sharePage) {
            var comp = Qt.createComponent("SharePage.qml");
            if (comp.status == Component.Ready) {
                sharePage = comp.createObject(mainWindow);
            } else {
                console.log("unable to load SharePage.qml");
                console.log(comp.errorString());
            }
        }
        if (sharePage) {
            // ShareFW takes a proper URL starting with "file:///"
            sharePage.shareUrl = Qt.resolvedUrl("file:///" + imagePath);
            sharePage.shareThumbnail = Qt.resolvedUrl("file:///" + imagePath);
            pageStack.push(sharePage);
        } else {
            // Nokia Social Client takes a file path
            if (!socialPage) {
                var comp = Qt.createComponent("SocialPage.qml");
                if (comp.status != Component.Ready) {
                    console.log("Could not load SocialPage.qml - " + comp.errorString());
                    return;
                }
                socialPage = comp.createObject(mainWindow);
            }
            // if phone is held in portrait and there is no rotation transition effect,
            // the contents of this page are temporarily drawn in portrait mode (even
            // though this page is locked to landscape). Hide the contents of this page
            // to prevent the user seeing this.
            img.visible = false;
            photoToolbar.visible = false;

            pageStack.push(socialPage);
            socialPage.share(imagePath);
        }
    }

    onStatusChanged: {
        // make sure the contents of the page are visible after returning from SocialPage
        if (status == PageStatus.Active || status == PageStatus.Activating) {
            img.visible = true;
            photoToolbar.visible = true;
        }
        if (status == PageStatus.Active) {
            if (!sharePage) {
                var comp = Qt.createComponent("SharePage.qml");
                if (comp.status == Component.Ready) {
                    sharePage = comp.createObject(mainWindow);
                } else {
                    console.log("unable to load SharePage.qml");
                    console.log(comp.errorString());
                }
            }
            sharingSupported = (sharePage || mirrorUtils.socialSharingSupported) ? true : false;
        }
    }
}
Quote
import QtQuick 1.0
import MirrorApp 1.0
import QtMultimediaKit 1.1
import com.nokia.symbian 1.1

Window {
    id: mainWindow
    PageStack {
        id: pageStack
        anchors.fill: parent

        CameraPage {
            id: camPage
            anchors.fill: parent
        }
        PhotoPage {
            id: photoPage
            anchors.fill: parent
        }
    }
    Component.onCompleted: {
        pageStack.push(camPage)
    }
}

Quote
import QtQuick 1.0
import com.nokia.symbian 1.1

Item {
    property alias tooltipText : label.text
    property string iconSource: ""
    property string iconPressedSource: ""
    property bool alignLeft: false
    property bool alignRight: false
    signal clicked

    height: 80
    width: 80

    Image {
        id: buttonIcon
        anchors.centerIn: parent
        source: (parent.state == "pressed" && iconPressedSource != "") ? iconPressedSource : iconSource
        z: 60
    }

    MouseArea {
        id: mousearea
        anchors.fill: parent
        onClicked: parent.clicked()
        onPressAndHold: {
            if (tooltipText != "")
                tooltip.visible = true;
        }
        onReleased: tooltip.visible = false;
    }

    states: State {
        name: "pressed";
        when: mousearea.pressed && mousearea.containsMouse
    }

    Item {
        id: tooltip
        visible: false
        width: privateStyle.textWidth(label.text, label.font) + 20
        height: privateStyle.fontHeight(label.font) + 20
        z: 70
        anchors.verticalCenter: parent.verticalCenter
        anchors.horizontalCenter: parent.horizontalCenter
        anchors.verticalCenterOffset: -(height/2 + buttonIcon.height/2 + 10)
        BorderImage {
            id: frame
            anchors.fill: parent
            source: "qrc:/tooltip.svg"
            border { left: 20; top: 20; right: 20; bottom: 20 }
        }

        Text {
           id: label
           clip: true
           color: platformStyle.colorNormalLight
           font { family: platformStyle.fontFamilyRegular; pixelSize: platformStyle.fontSizeMedium }
           verticalAlignment: Text.AlignVCenter
           horizontalAlignment: Text.AlignHCenter
           anchors.fill: parent
           smooth: true
        }

        Component.onCompleted: {
            if (width > parent.width) {
                if (parent.alignLeft)
                    anchors.horizontalCenterOffset = width/2 - parent.width/2;
                else if (parent.alignRight)
                    anchors.horizontalCenterOffset = -(width/2 - parent.width/2);
            }
        }
    }

    // quick and dirty highlighting for pressed buttons that don't have separate pressed graphic
    Rectangle {
        id: highlight
        anchors.centerIn: parent
        width: 50
        height: 50
        visible: (parent.state == "pressed" && iconPressedSource == "")
        radius: 20
        color: platformStyle.colorTextSelection
        z: 50
    }
}

Quote
import QtQuick 1.0
import com.nokia.symbian 1.1

Page {
    signal share(string path)

    Rectangle {
        id: blackRect
        anchors.fill: parent
        color: "black"
    }

    Timer {
        id: closeTimer
        interval: 20 //ms
        repeat: true
        onTriggered: {
            returnOrWait();
        }
    }

    onShare: {
        console.log("Sharing with social file " + path);
        mirrorUtils.upload(path);
        closeTimer.start();
        returnOrWait();
    }

    function returnOrWait() {
        // Returning to photoPage has been found to succeed
        // only if it has reached inactive status
        if (photoPage.status == PageStatus.Inactive) {
            closeTimer.stop();
            pageStack.pop();
        }
    }
}

Quote
import QtQuick 1.0
import MirrorApp 1.0
import QtMultimediaKit 1.1
import com.nokia.symbian 1.1
import QtMobility.systeminfo 1.1

Page {
    orientationLock: PageOrientation.LockLandscape
    property bool startupDelay: false
    property int viewfinderWidth : ((height*4)/3 > width) ? width : (height*4)/3
    property int viewfinderHeight : ((width*3)/4 > height) ? height : (width*3)/4

    Rectangle {
        id: topRect
        anchors.top: parent.top
        anchors.bottom: cam.top
        width: parent.width
        color: "#000000"
    }

    Rectangle {
        id: leftRect
        anchors.left: parent.left
        anchors.right: cam.left
        height: parent.height
        color: "#000000"
    }
    Rectangle {
        id: rightRect
        anchors.left: cam.right
        anchors.right: parent.right
        height: parent.height
        color: "#000000"
    }

    SecondaryCamera {
        id: cam
        visible: (parent.status == PageStatus.Active && cameraActive)
        property int fake: 0 //In order to update rect to viewfinder
        width: viewfinderWidth + fake
        height: viewfinderHeight
        anchors.centerIn: parent
        transform: Rotation {
            origin.x: cam.width/2;
            origin.y: cam.height/2;
            axis { x: 0; y: 1; z: 0 }
            angle: 180
        }
        onImageCaptured: {
            photoPage.image = preview;
            centerRect.visible = true;
            photopageTimer.start();
        }
        onImageSaved: {
            photoPage.imagePath = path;
        }
        onCameraActiveChanged: {
            if (cameraActive && parent.status == PageStatus.Active) {
                if (startupDelay)
                    startupTimer.start();
                else
                    centerRect.visible = false;
            }
        }
        // timer to delay camera initalization so that it happens after landscape has been set.

    }

    Timer {
        id: camInitTimer
        interval: 100 //ms
        onTriggered: {
            cam.start();
            cam.fake = 0;
        }
    }

    Rectangle {
        id: centerRect
        visible: true
        x: cam.x
        y: cam.y
        width: cam.width
        height: cam.height
        color: "#000000"
    }

    Rectangle {
        id: bottomRect
        anchors.top: cam.bottom
        anchors.bottom: parent.bottom
        width: parent.width
        color: "#000000"
    }

    Item {
        id: toolbar
        z: 50
        anchors.right: parent.right
        height: parent.height
        width: 80
        MirrorToolbarButton {
            anchors.centerIn: parent
            iconSource: "qrc:/capture_normal.svg"
            iconPressedSource: "qrc:/capture_pressed.svg"
            tooltipText: qsTrId("qtn_qmlmirror_camerapage_takephoto")
            onClicked: takePhoto()
            rotation: 270
        }
        MirrorToolbarButton {
            anchors.horizontalCenter: parent.horizontalCenter
            anchors.bottom: parent.bottom
            iconSource: "qrc:/back.svg"
            tooltipText: qsTrId("qtn_qmlmirror_camerapage_back")
            onClicked: Qt.quit()
            rotation: 270
            alignLeft: true
        }
    }

    // minimal timer to remove flickering when moving from cameraPage to photoPage
    Timer {
        id: photopageTimer
        interval: 10 //ms
        onTriggered: pageStack.push(photoPage);
    }

    // timer to remove flickering when first starting application (only on qt 4.7)
    Timer {
        id: startupTimer
        interval: 1000 //ms
        onTriggered: {
            parent.startupDelay = false;
            centerRect.visible = false;
        }
    }

    Item {
        id: keyItem
        focus: true
        Keys.onSelectPressed: takePhoto()
    }

    onStatusChanged: {
        if (status == PageStatus.Active && cam.cameraActive) {
            if (startupDelay)
                startupTimer.start();
            else
                centerRect.visible = false;
        }
        if (status == PageStatus.Active)
            keyItem.focus = true;
    }

    function takePhoto() {
        photoPage.imagePath = "";
        cam.captureImage();
    }

    GeneralInfo {
        id: systemInfo
    }

    Component.onCompleted: {
        if (systemInfo.qtCoreVersion.substring(0,3) == "4.7") {
            startupDelay = true;
        }
        if (cam.isLandScapeStart()) {
            cam.start();
        } else {
            cam.fake = 1;
            camInitTimer.restart()
        }
    }
}

Maybe we can hack it into our own QML apps :P

.qml names:
SharePage.qml
PhotoPage.qml
main.qml
MirrorToolbarButton.qml
SocialPage.qml

Maybe it works without Qt/C++ ???

but I found this part of Qt code:
Quote
bool SocialSharingSupported
and
Quote
QString path imageSaved
« Last Edit: July 09, 2013, 12:02:03 am by huellif »

Offline auditoreezio

  • New Member
  • **
  • Posts: 22
  • Reputation: 2
  • Symbian user until the last symbian phone is dead!
  • Current Phone: : Nokia 701 and N97 mini.
Re: Belle FP2 ShareUI access
« Reply #1 on: July 08, 2013, 11:52:46 pm »
u are a genius :)

Offline iChris701

  • Retired
  • Mass Poster
  • ***
  • Posts: 1,020
  • Reputation: 332
  • Find Me On Twitter : https://twitter.com/#!/iChris701
Re: Belle FP2 ShareUI access
« Reply #2 on: July 09, 2013, 12:03:11 am »
*found* I like that word.  :)

Offline huellif

  • Developer
  • Christmas Santa
  • ****
  • Posts: 402
  • Reputation: 212
Re: Belle FP2 ShareUI access
« Reply #3 on: July 09, 2013, 12:04:02 am »

Offline Allstar12345

  • Allstar Software Founder
  • Administrator
  • Forum Genius
  • ******
  • Posts: 5,235
  • Reputation: 812
    • Allstar Software
  • Current Phone: : OnePlus 8 Pro, Xperia 10, Nexus 6p, Jolla Phone, Nokia N8, Nokia 808 PureView, BlackBerry Z30
Re: Belle FP2 ShareUI access
« Reply #4 on: July 09, 2013, 03:12:52 am »
*found* I like that word.  :)
:P

Just need to find the Qt part and the QML register decleration now

Offline a.hamameh

  • Full Member
  • ***
  • Posts: 106
  • Reputation: 41
  • BelleXDesigns ;)
  • Current Phone: : Nokia 701 OFW 113.010.1506 modified by me
Re: Belle FP2 ShareUI access
« Reply #5 on: July 09, 2013, 03:59:17 am »
Nice work mate hope we can do it

Offline mahindar

  • Developer
  • New Member
  • ****
  • Posts: 25
  • Reputation: 11
  • Symbian Power User
Re: Belle FP2 ShareUI access
« Reply #6 on: July 09, 2013, 08:56:27 pm »
nice found mate... Useful for learning more about QML ;)