View Single Post
marxian's Avatar
Posts: 2,448 | Thanked: 9,523 times | Joined on Aug 2010 @ Wigan, UK
#51
Repository now available at https://github.com/marxoft/qt-components-hildon.

The project includes an example gallery at /examples/gallery.

Some screenshots and example code:



Code:
import org.hildon.components 1.0

Window {
    id: mainWindow

    windowTitle: "Gallery"
    contextMenuPolicy: Qt.ActionsContextMenu // Display the list of actions in a context menu when a long-press occurs
    tools: Action {
        text: "About"
        onTriggered: dialog.open()
    }

    actions: [
        Action {
            text: "Action 1"
            onTriggered: console.log(text + " clicked")
        },

        Action {
            text: "Action 2"
            onTriggered: console.log(text + " clicked")
        },

        Action {
            text: "Action 3"
            onTriggered: console.log(text + " clicked")
        }
    ]

    Column {
        width: 460
        anchors {
            top: parent.top
            topMargin: 20
            horizontalCenter: parent.horizontalCenter
        }
        spacing: 20

        Label {
            width: parent.width
            alignment: Qt.AlignCenter
            font.bold: true
            font.pixelSize: 32
            color: platformStyle.activeTextColor
            wordWrap: true
            text: qsTr("Welcome to Qt Components Hildon Gallery.")
        }

        Button {
            width: parent.width
            text: qsTr("Next window")
            onClicked: windowStack.push(Qt.resolvedUrl("SecondWindow.qml"), { windowTitle: "Stacked window" })
        }

        Button {
            width: parent.width
            text: qsTr("Toggle orientation")
            onClicked: screen.orientationLock = screen.orientationLock === Screen.PortraitOrientation ? Screen.LandscapeOrientation : Screen.PortraitOrientation
        }

        CheckBox {
            width: parent.width
            text: qsTr("Fullscreen")
            onClicked: mainWindow.fullScreen = !mainWindow.fullScreen
        }
    }

    Dialog {
        id: dialog

        windowTitle: qsTr("About")
        content: Label {
            anchors.fill: parent
            wordWrap: true
            text: qsTr("Qt Components Hildon Gallery is a demo of Qt Components Hildon.")
        }

        buttons: Button {
            text: qsTr("Done")
            onClicked: dialog.accept()
        }
    }
}


Code:
import org.hildon.components 1.0

Window {
    id: root

    tools: [
        ActionGroup {
            exclusive: true

            Action {
                checkable: true
                checked: true
                text: qsTr("One")
                onTriggered: stack.currentIndex = 0
            }

            Action {
                checkable: true
                text: qsTr("Two")
                onTriggered: stack.currentIndex = 1
            }

            Action {
                checkable: true
                text: qsTr("Three")
                onTriggered: stack.currentIndex = 2
            }
        },

        Action {
            text: qsTr("Pop window")
            onTriggered: windowStack.pop()
        },

        Action {
            text: qsTr("Toggle orientation")
            onTriggered: screen.orientationLock = screen.orientationLock === Screen.PortraitOrientation ? Screen.LandscapeOrientation : Screen.PortraitOrientation
        }
    ]

    Stack {
        id: stack

        anchors.fill: parent

        Label {
            alignment: Qt.AlignCenter
            font.bold: true
            font.pixelSize: 40
            color: platformStyle.activeTextColor
            wordWrap: true
            text: qsTr("Showing tab one")
        }

        Label {
            alignment: Qt.AlignCenter
            font.bold: true
            font.pixelSize: 40
            color: platformStyle.activeTextColor
            wordWrap: true
            text: qsTr("Showing tab two")
        }

        Label {
            alignment: Qt.AlignCenter
            font.bold: true
            font.pixelSize: 40
            color: platformStyle.activeTextColor
            wordWrap: true
            text: qsTr("Showing tab three")
        }
    }
}
There are a few bugs with anchors/layouts and still lots of things to add, but the concept works well.
__________________
'Men of high position are allowed, by a special act of grace, to accomodate their reasoning to the answer they need. Logic is only required in those of lesser rank.' - J K Galbraith

My website

GitHub
 

The Following 9 Users Say Thank You to marxian For This Useful Post: