import QtQuick 1.1
import com.nokia.meego 1.0

PageStackWindow {
    id: appWindow

    initialPage: mainPage

    MainPage{id: mainPage}

    ToolBarLayout {
        id: commonTools
        visible: true
        ToolIcon { platformIconId: "toolbar-view-menu";
            anchors.right: parent===undefined ? undefined : parent.right
            onClicked: (myMenu.status == DialogStatus.Closed) ? myMenu.open() : myMenu.close()
        }
    }

    Page{
        id: aboutPage

        Rectangle {
            id: aboutWindow

            color: "#0080e6"
            gradient: Gradient {
                GradientStop {
                    position: 0.00;
                    color: "#048ef7";
                }
                GradientStop {
                    position: 0.26;
                    color: "#dbdbdb";
                }
                GradientStop {
                    position: 0.62;
                    color: "#ffffff";
                }
                GradientStop {
                    position: 1.00;
                    color: "#c0c0c0";
                }
            }
            anchors.left: parent.left
            anchors.leftMargin: 0
            anchors.top: parent.top
            width: aboutPage.width
            height: aboutPage.height


            Row {
                id: aboutMainRow
                height: 70

                Image {
                    id: appLogo
                    x: 0; y: 0
                    width: 64; height: 64
                    source: "qrc:/appLogoWithoutBG"
                    MouseArea {
                        anchors.fill: parent
                        onClicked: Qt.openUrlExternally("http://dadablog.net/HarmattanApps")
                    }
                }

                Rectangle {
                    Text {
                        id: txtAppName
                        x: 80; y: 0
                        text: qsTr("IMQuery v1.0.3")
                        color: "#000080"
                        font { family: "Helvetica"; pixelSize: 24; bold: true; }
                        MouseArea {
                            anchors.fill: parent
                            onClicked: Qt.openUrlExternally("http://dadablog.net/HarmattanApps")
                        }
                    }

                    Text {
                        id: txtAppURL
                        x: 80; y: 40
                        text: "DaDaBlog.net/HarmattanApps"
                        color: "#000080"
                        font { family: "Helvetica"; pixelSize: 24; bold: true; }
                        MouseArea {
                            anchors.fill: parent
                            onClicked: Qt.openUrlExternally("http://dadablog.net/HarmattanApps")
                        }
                    }
                }
            }

            Flickable {
                id: flickAbout
                anchors.left: parent.left
                anchors.leftMargin: 0
                anchors.top: aboutMainRow.bottom; anchors.topMargin: 40
                contentHeight: aboutPage.height

                width: aboutPage.width
                height: aboutPage.height
                clip: true

                flickableDirection: Flickable.VerticalFlick
                boundsBehavior: Flickable.DragOverBounds

                Text {
                    id: txtAppDesc                    
                    width: aboutPage.width - 10
                    height: aboutPage.height - 144
                    text: qsTr("IMQuery is an application that guides you how to type a particular Chinese character in some popular input methods.\n\n" +
                               "This application makes use of input method tables from the SCIM, GCIN, IBus and VimIM open source projects; " +
                               "and radical information from the zdic.net website.\n\n" +
                               "Notice: Information provided in this application is for reference purpose only; its accuracy is not guaranteed.\n\n"
                               )

                    font { family: "Helvetica"; pixelSize: 22}
                    wrapMode: Text.WordWrap;
                }

            }
            Rectangle {
                id: aboutProduct
                x: 0; y: aboutPage.height - 50
                width: aboutPage.width /2
                height:  50
                color: "#d9d9d9"

                Text {
                    text: qsTr("About this app")
                    font { family: "Helvetica"; pixelSize: 20; bold: true }
                    anchors.fill: parent
                    horizontalAlignment: Text.AlignHCenter
                }
                MouseArea {
                    anchors.fill: parent
                    onClicked: aboutProductDialog.open()
                }

                QueryDialog {
                    id: aboutProductDialog
                    titleText: qsTr("IMQuery v1.0.3")
                    acceptButtonText: qsTr("OK")
                    message: qsTr("for MeeGo 1.2 Harmattan\n(C)Amanda Lam, 2011 All rights reserved.")
                }
            }

            Rectangle {
                id: btnBack
                width: aboutPage.width / 2
                height:  50
                color: "#b6e4fa"

                x: aboutPage.width / 2; y: aboutPage.height - 50
                Text {
                    text: qsTr("< Back")
                    anchors.fill: parent
                    horizontalAlignment: Text.AlignHCenter
                    font { family: "Helvetica"; pixelSize: 20; bold: true; }
                }
                MouseArea {
                    anchors.fill: parent
                    onClicked: appWindow.pageStack.pop()
                }
            }
        }
    }

    Menu {
        id: myMenu
        visualParent: pageStack
        MenuLayout {
            MenuItem {
                text: qsTr("Sponsor")
                onClicked: Qt.openUrlExternally(qsTr("http://dadablog.net/maemo/donation.html"))
            }
            MenuItem {
                text: qsTr("About this app")
                onClicked: appWindow.pageStack.push(aboutPage)
            }
            MenuItem {
                text: qsTr("Exit")
                onClicked: Qt.quit()
            }
        }
    }

}
