-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Introduce example usage of components on touch
The example shows a typical android application developed using components and custom styling. Some style fixes had to be added to support custom fonts on Android. Change-Id: Idb4417571ae2235fd06e41145883f38a2a56931d Reviewed-by: Jens Bache-Wiig <[email protected]>
- Loading branch information
Jens Bache-Wiig
authored and
The Qt Project
committed
Jan 17, 2013
1 parent
f80cb1c
commit 033f9ab
Showing
22 changed files
with
766 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,88 @@ | ||
/**************************************************************************** | ||
** | ||
** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies). | ||
** Contact: http://www.qt-project.org/legal | ||
** | ||
** This file is part of the Qt Components project. | ||
** | ||
** $QT_BEGIN_LICENSE:BSD$ | ||
** You may use this file under the terms of the BSD license as follows: | ||
** | ||
** "Redistribution and use in source and binary forms, with or without | ||
** modification, are permitted provided that the following conditions are | ||
** met: | ||
** * Redistributions of source code must retain the above copyright | ||
** notice, this list of conditions and the following disclaimer. | ||
** * Redistributions in binary form must reproduce the above copyright | ||
** notice, this list of conditions and the following disclaimer in | ||
** the documentation and/or other materials provided with the | ||
** distribution. | ||
** * Neither the name of Digia Plc and its Subsidiary(-ies) nor the names | ||
** of its contributors may be used to endorse or promote products derived | ||
** from this software without specific prior written permission. | ||
** | ||
** | ||
** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS | ||
** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT | ||
** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR | ||
** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT | ||
** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, | ||
** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT | ||
** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | ||
** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | ||
** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | ||
** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | ||
** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." | ||
** | ||
** $QT_END_LICENSE$ | ||
** | ||
****************************************************************************/ | ||
|
||
import QtQuick 2.0 | ||
|
||
Item { | ||
id: root | ||
width: parent.width | ||
height: 88 | ||
|
||
property alias text: textitem.text | ||
signal clicked | ||
|
||
Rectangle { | ||
anchors.fill: parent | ||
color: "#11ffffff" | ||
visible: mouse.pressed | ||
} | ||
|
||
Text { | ||
id: textitem | ||
color: "white" | ||
font.pixelSize: 32 | ||
text: modelData | ||
anchors.verticalCenter: parent.verticalCenter | ||
anchors.left: parent.left | ||
anchors.leftMargin: 30 | ||
} | ||
|
||
Rectangle { | ||
anchors.left: parent.left | ||
anchors.right: parent.right | ||
anchors.margins: 15 | ||
height: 1 | ||
color: "#424246" | ||
} | ||
|
||
Image { | ||
anchors.right: parent.right | ||
anchors.rightMargin: 20 | ||
anchors.verticalCenter: parent.verticalCenter | ||
source: "../images/navigation_next_item.png" | ||
} | ||
|
||
MouseArea { | ||
id: mouse | ||
anchors.fill: parent | ||
onClicked: root.clicked() | ||
|
||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,107 @@ | ||
/**************************************************************************** | ||
** | ||
** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies). | ||
** Contact: http://www.qt-project.org/legal | ||
** | ||
** This file is part of the Qt Components project. | ||
** | ||
** $QT_BEGIN_LICENSE:BSD$ | ||
** You may use this file under the terms of the BSD license as follows: | ||
** | ||
** "Redistribution and use in source and binary forms, with or without | ||
** modification, are permitted provided that the following conditions are | ||
** met: | ||
** * Redistributions of source code must retain the above copyright | ||
** notice, this list of conditions and the following disclaimer. | ||
** * Redistributions in binary form must reproduce the above copyright | ||
** notice, this list of conditions and the following disclaimer in | ||
** the documentation and/or other materials provided with the | ||
** distribution. | ||
** * Neither the name of Digia Plc and its Subsidiary(-ies) nor the names | ||
** of its contributors may be used to endorse or promote products derived | ||
** from this software without specific prior written permission. | ||
** | ||
** | ||
** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS | ||
** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT | ||
** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR | ||
** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT | ||
** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, | ||
** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT | ||
** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | ||
** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | ||
** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | ||
** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | ||
** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." | ||
** | ||
** $QT_END_LICENSE$ | ||
** | ||
****************************************************************************/ | ||
|
||
import QtQuick 2.0 | ||
import QtDesktop 1.0 | ||
import QtDesktop.Styles 1.0 | ||
|
||
Page { | ||
|
||
property real progress: 0 | ||
SequentialAnimation on progress { | ||
loops: Animation.Infinite | ||
running: true | ||
NumberAnimation { | ||
from: 0 | ||
to: 1 | ||
duration: 3000 | ||
} | ||
NumberAnimation { | ||
from: 1 | ||
to: 0 | ||
duration: 3000 | ||
} | ||
} | ||
|
||
Column { | ||
spacing: 40 | ||
anchors.centerIn: parent | ||
|
||
Button { | ||
anchors.margins: 20 | ||
text: "Press me" | ||
style: touchStyle | ||
} | ||
|
||
Button { | ||
anchors.margins: 20 | ||
style: touchStyle | ||
text: "Press me too" | ||
} | ||
|
||
Button { | ||
anchors.margins: 20 | ||
style: touchStyle | ||
text: "Dont press me" | ||
onClicked: if (pageStack) pageStack.pop() | ||
} | ||
|
||
} | ||
|
||
Component { | ||
id: touchStyle | ||
ButtonStyle { | ||
implicitHeight: 50 | ||
implicitWidth: 320 | ||
background: BorderImage { | ||
anchors.fill: parent | ||
antialiasing: true | ||
border.bottom: 8 | ||
border.top: 8 | ||
border.left: 8 | ||
border.right: 8 | ||
anchors.margins: control.pressed ? -4 : 0 | ||
source: control.pressed ? "../images/button_pressed.png" : "../images/button_default.png" | ||
} | ||
foregroundColor: "white" | ||
font.pixelSize: 23 | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,108 @@ | ||
/**************************************************************************** | ||
** | ||
** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies). | ||
** Contact: http://www.qt-project.org/legal | ||
** | ||
** This file is part of the Qt Components project. | ||
** | ||
** $QT_BEGIN_LICENSE:BSD$ | ||
** You may use this file under the terms of the BSD license as follows: | ||
** | ||
** "Redistribution and use in source and binary forms, with or without | ||
** modification, are permitted provided that the following conditions are | ||
** met: | ||
** * Redistributions of source code must retain the above copyright | ||
** notice, this list of conditions and the following disclaimer. | ||
** * Redistributions in binary form must reproduce the above copyright | ||
** notice, this list of conditions and the following disclaimer in | ||
** the documentation and/or other materials provided with the | ||
** distribution. | ||
** * Neither the name of Digia Plc and its Subsidiary(-ies) nor the names | ||
** of its contributors may be used to endorse or promote products derived | ||
** from this software without specific prior written permission. | ||
** | ||
** | ||
** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS | ||
** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT | ||
** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR | ||
** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT | ||
** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, | ||
** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT | ||
** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | ||
** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | ||
** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | ||
** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | ||
** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." | ||
** | ||
** $QT_END_LICENSE$ | ||
** | ||
****************************************************************************/ | ||
|
||
import QtQuick 2.0 | ||
import QtDesktop 1.0 | ||
import QtDesktop.Styles 1.0 | ||
|
||
Page { | ||
|
||
property real progress: 0 | ||
SequentialAnimation on progress { | ||
loops: Animation.Infinite | ||
running: true | ||
NumberAnimation { | ||
from: 0 | ||
to: 1 | ||
duration: 3000 | ||
} | ||
NumberAnimation { | ||
from: 1 | ||
to: 0 | ||
duration: 3000 | ||
} | ||
} | ||
|
||
Column { | ||
spacing: 40 | ||
anchors.centerIn: parent | ||
|
||
ProgressBar { | ||
anchors.margins: 20 | ||
style: touchStyle | ||
width: 400 | ||
value: progress | ||
} | ||
|
||
ProgressBar { | ||
anchors.margins: 20 | ||
style: touchStyle | ||
width: 400 | ||
value: 1 - progress | ||
} | ||
|
||
ProgressBar { | ||
anchors.margins: 20 | ||
style: touchStyle | ||
value: 1 | ||
width: 400 | ||
} | ||
|
||
} | ||
|
||
Component { | ||
id: touchStyle | ||
ProgressBarStyle { | ||
implicitHeight: 15 | ||
implicitWidth: 300 | ||
background: Rectangle { | ||
color: "#444" | ||
opacity: 0.8 | ||
Rectangle { | ||
antialiasing: true | ||
radius: 1 | ||
color: "#468bb7" | ||
height: parent.height | ||
width: parent.width * control.value / control.maximumValue | ||
} | ||
} | ||
} | ||
} | ||
} |
Oops, something went wrong.