qtmobility/examples/servicenotesmanager/declarative-sfw-notes/Dialog.qml
author Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
Mon, 03 May 2010 13:18:40 +0300
changeset 4 90517678cc4f
permissions -rw-r--r--
Revision: 201015 Kit: 201018

import Qt 4.6

Rectangle {
    property string text: ""
    property bool alert: false
    signal confirmed();

    id: page
    opacity: 0
    border.width: 1; color: "lightgray"; radius: 5

    width: 200; height: dialogText.height + okButton.height + 35
    anchors.verticalCenter: mainWindow.verticalCenter
    anchors.horizontalCenter: mainWindow.horizontalCenter

    Text {
        id: dialogText
        text: page.text
        wrap: true
        x: 15; y: 15
        color: activePalette.buttonText
        anchors.horizontalCenter: page.horizontalCenter
    }

    Button {
        id: okButton
        text: "Ok"
        width: 75; height: 25
        anchors.top: dialogText.bottom; anchors.topMargin: 7

        onClicked: {
            page.confirmed();
            page.opacity = 0;
        }
    }

    Button {
        id: noButton
        text: "Cancel"
        width: 75; height: 25
        anchors.left: page.horizontalCenter; anchors.leftMargin: 5
        anchors.top: dialogText.bottom; anchors.topMargin: 7
    
        onClicked: {
            page.opacity = 0;
        }
    }

    Component.onCompleted: {
        if (alert == true)
        {
            noButton.opacity = 0;
            okButton.anchors.horizontalCenter = page.horizontalCenter;
        }
        else {
            okButton.anchors.right = page.horizontalCenter; 
            okButton.anchors.rightMargin = 5;
        }
    }
}