Merge remote-tracking branch 'origin/5.15' into dev
Conflicts: src/imports/qtqml/plugin.cpp src/qml/qml/qqml.h src/qml/qml/qqmlmetatype.cpp src/qml/qml/qqmlmetatype_p.h src/qml/qml/qqmltypeloader.cpp src/qml/types/qqmlbind.cpp src/quick/items/qquickitemsmodule.cpp tests/auto/qml/qqmlecmascript/tst_qqmlecmascript.cpp Change-Id: I52548938a582cb6510271ed4bc3a9aa0c3c11df6
This commit is contained in:
commit
3e758800b4
|
@ -69,7 +69,7 @@ This example builds on:
|
|||
\li \l {Extending QML - Adding Types Example}
|
||||
\endlist
|
||||
|
||||
Shows how to use \l {QQmlEngine::}{qmlRegisterExtendedType()} to provide an
|
||||
Shows how to use \l {QML_EXTENDED} to provide an
|
||||
\l {Registering Extension Objects}{extension object} to a \l QLineEdit without modifying or
|
||||
subclassing it.
|
||||
|
||||
|
|
|
@ -81,7 +81,7 @@ void BirthdayParty::setHost(Person *c)
|
|||
|
||||
QQmlListProperty<Person> BirthdayParty::guests()
|
||||
{
|
||||
return {this, m_guests};
|
||||
return {this, &m_guests};
|
||||
}
|
||||
|
||||
int BirthdayParty::guestCount() const
|
||||
|
|
|
@ -87,7 +87,7 @@ void BirthdayParty::setHost(Person *c)
|
|||
|
||||
QQmlListProperty<Person> BirthdayParty::guests()
|
||||
{
|
||||
return QQmlListProperty<Person>(this, m_guests);
|
||||
return QQmlListProperty<Person>(this, &m_guests);
|
||||
}
|
||||
|
||||
int BirthdayParty::guestCount() const
|
||||
|
|
|
@ -62,7 +62,7 @@ BirthdayParty {
|
|||
shoe { size: 12; color: "white"; brand: "Nike"; price: 90.0 }
|
||||
}
|
||||
// ![0]
|
||||
onPartyStarted: console.log("This party started rockin' at " + time);
|
||||
onPartyStarted: (time) => { console.log("This party started rockin' at " + time); }
|
||||
|
||||
|
||||
Boy {
|
||||
|
|
|
@ -66,7 +66,7 @@ void BirthdayParty::setHost(Person *c)
|
|||
|
||||
QQmlListProperty<Person> BirthdayParty::guests()
|
||||
{
|
||||
return {this, m_guests};
|
||||
return {this, &m_guests};
|
||||
}
|
||||
|
||||
int BirthdayParty::guestCount() const
|
||||
|
|
|
@ -66,7 +66,7 @@ void BirthdayParty::setHost(Person *c)
|
|||
|
||||
QQmlListProperty<Person> BirthdayParty::guests()
|
||||
{
|
||||
return {this, m_guests};
|
||||
return {this, &m_guests};
|
||||
}
|
||||
|
||||
int BirthdayParty::guestCount() const
|
||||
|
|
|
@ -66,7 +66,7 @@ void BirthdayParty::setHost(Person *c)
|
|||
|
||||
QQmlListProperty<Person> BirthdayParty::guests()
|
||||
{
|
||||
return {this, m_guests};
|
||||
return {this, &m_guests};
|
||||
}
|
||||
|
||||
int BirthdayParty::guestCount() const
|
||||
|
|
|
@ -67,7 +67,7 @@ void BirthdayParty::setHost(Person *c)
|
|||
|
||||
QQmlListProperty<Person> BirthdayParty::guests()
|
||||
{
|
||||
return {this, m_guests};
|
||||
return {this, &m_guests};
|
||||
}
|
||||
|
||||
int BirthdayParty::guestCount() const
|
||||
|
|
|
@ -71,7 +71,9 @@ QQmlListProperty<Person> BirthdayParty::guests()
|
|||
&BirthdayParty::appendGuest,
|
||||
&BirthdayParty::guestCount,
|
||||
&BirthdayParty::guest,
|
||||
&BirthdayParty::clearGuests};
|
||||
&BirthdayParty::clearGuests,
|
||||
&BirthdayParty::replaceGuest,
|
||||
&BirthdayParty::removeLastGuest};
|
||||
}
|
||||
|
||||
void BirthdayParty::appendGuest(Person* p) {
|
||||
|
@ -93,6 +95,16 @@ void BirthdayParty::clearGuests() {
|
|||
m_guests.clear();
|
||||
}
|
||||
|
||||
void BirthdayParty::replaceGuest(int index, Person *p)
|
||||
{
|
||||
m_guests[index] = p;
|
||||
}
|
||||
|
||||
void BirthdayParty::removeLastGuest()
|
||||
{
|
||||
m_guests.removeLast();
|
||||
}
|
||||
|
||||
// ![0]
|
||||
|
||||
void BirthdayParty::appendGuest(QQmlListProperty<Person>* list, Person* p) {
|
||||
|
@ -103,6 +115,16 @@ void BirthdayParty::clearGuests(QQmlListProperty<Person>* list) {
|
|||
reinterpret_cast< BirthdayParty* >(list->data)->clearGuests();
|
||||
}
|
||||
|
||||
void BirthdayParty::replaceGuest(QQmlListProperty<Person> *list, int i, Person *p)
|
||||
{
|
||||
reinterpret_cast< BirthdayParty* >(list->data)->replaceGuest(i, p);
|
||||
}
|
||||
|
||||
void BirthdayParty::removeLastGuest(QQmlListProperty<Person> *list)
|
||||
{
|
||||
reinterpret_cast< BirthdayParty* >(list->data)->removeLastGuest();
|
||||
}
|
||||
|
||||
Person* BirthdayParty::guest(QQmlListProperty<Person>* list, int i) {
|
||||
return reinterpret_cast< BirthdayParty* >(list->data)->guest(i);
|
||||
}
|
||||
|
|
|
@ -79,12 +79,16 @@ public:
|
|||
int guestCount() const;
|
||||
Person *guest(int) const;
|
||||
void clearGuests();
|
||||
void replaceGuest(int, Person*);
|
||||
void removeLastGuest();
|
||||
|
||||
private:
|
||||
static void appendGuest(QQmlListProperty<Person>*, Person*);
|
||||
static int guestCount(QQmlListProperty<Person>*);
|
||||
static Person* guest(QQmlListProperty<Person>*, int);
|
||||
static void clearGuests(QQmlListProperty<Person>*);
|
||||
static void replaceGuest(QQmlListProperty<Person>*, int, Person*);
|
||||
static void removeLastGuest(QQmlListProperty<Person>*);
|
||||
|
||||
Person *m_host;
|
||||
QVector<Person *> m_guests;
|
||||
|
|
|
@ -82,7 +82,7 @@ void BirthdayParty::setHost(Person *c)
|
|||
|
||||
QQmlListProperty<Person> BirthdayParty::guests()
|
||||
{
|
||||
return {this, m_guests};
|
||||
return {this, &m_guests};
|
||||
}
|
||||
|
||||
int BirthdayParty::guestCount() const
|
||||
|
|
|
@ -53,7 +53,7 @@ import QtQuick 2.0 // For QColor
|
|||
|
||||
BirthdayParty {
|
||||
// ![0]
|
||||
onPartyStarted: console.log("This party started rockin' at " + time);
|
||||
onPartyStarted: (time) => { console.log("This party started rockin' at " + time); }
|
||||
// ![0]
|
||||
|
||||
host: Boy {
|
||||
|
|
|
@ -82,7 +82,7 @@ void BirthdayParty::setHost(Person *c)
|
|||
|
||||
QQmlListProperty<Person> BirthdayParty::guests()
|
||||
{
|
||||
return {this, m_guests};
|
||||
return {this, &m_guests};
|
||||
}
|
||||
|
||||
int BirthdayParty::guestCount() const
|
||||
|
|
|
@ -56,7 +56,7 @@ BirthdayParty {
|
|||
HappyBirthdaySong on announcement { name: "Bob Jones" }
|
||||
// ![0]
|
||||
|
||||
onPartyStarted: console.log("This party started rockin' at " + time);
|
||||
onPartyStarted: (time) => { console.log("This party started rockin' at " + time); }
|
||||
|
||||
|
||||
host: Boy {
|
||||
|
|
|
@ -68,7 +68,8 @@ void PieChart::setName(const QString &name)
|
|||
//![0]
|
||||
QQmlListProperty<PieSlice> PieChart::slices()
|
||||
{
|
||||
return QQmlListProperty<PieSlice>(this, nullptr, &PieChart::append_slice, nullptr, nullptr, nullptr);
|
||||
return QQmlListProperty<PieSlice>(this, nullptr, &PieChart::append_slice, nullptr,
|
||||
nullptr, nullptr, nullptr, nullptr);
|
||||
}
|
||||
|
||||
void PieChart::append_slice(QQmlListProperty<PieSlice> *list, PieSlice *slice)
|
||||
|
|
|
@ -67,7 +67,8 @@ void PieChart::setName(const QString &name)
|
|||
|
||||
QQmlListProperty<PieSlice> PieChart::slices()
|
||||
{
|
||||
return QQmlListProperty<PieSlice>(this, nullptr, &PieChart::append_slice, nullptr, nullptr, nullptr);
|
||||
return QQmlListProperty<PieSlice>(this, nullptr, &PieChart::append_slice, nullptr,
|
||||
nullptr, nullptr, nullptr, nullptr);
|
||||
}
|
||||
|
||||
void PieChart::append_slice(QQmlListProperty<PieSlice> *list, PieSlice *slice)
|
||||
|
|
|
@ -48,6 +48,7 @@
|
|||
**
|
||||
****************************************************************************/
|
||||
|
||||
import QtQml 2.0
|
||||
import QtQuick 2.0
|
||||
|
||||
Item {
|
||||
|
|
|
@ -116,6 +116,13 @@ Rectangle {
|
|||
Rectangle { color: "#1e1b18"; x: page.width/2+50; y: 10; width: 20; height: 40 }
|
||||
Repeater {
|
||||
model: page.height / 20
|
||||
Rectangle { color: "#328930"; x: page.width/2-5; y: index * 20; width: 10; height: 10 }
|
||||
Rectangle {
|
||||
required property int index
|
||||
color: "#328930"
|
||||
x: page.width / 2 - 5
|
||||
y: index * 20
|
||||
width: 10
|
||||
height: 10
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -48,6 +48,7 @@
|
|||
**
|
||||
****************************************************************************/
|
||||
|
||||
import QtQml 2.0
|
||||
import QtQuick 2.0
|
||||
|
||||
Rectangle {
|
||||
|
@ -58,7 +59,7 @@ Rectangle {
|
|||
|
||||
width: 320; height: 480; color: "#474747"; focus: true
|
||||
|
||||
Keys.onPressed: {
|
||||
Keys.onPressed: (event) => {
|
||||
if (event.key == Qt.Key_Delete || event.key == Qt.Key_Backspace)
|
||||
container.remove()
|
||||
else if (event.text != "") {
|
||||
|
|
|
@ -48,6 +48,7 @@
|
|||
**
|
||||
****************************************************************************/
|
||||
|
||||
import QtQml 2.0
|
||||
import QtQuick 2.0
|
||||
|
||||
Rectangle {
|
||||
|
|
|
@ -48,6 +48,7 @@
|
|||
**
|
||||
****************************************************************************/
|
||||
|
||||
import QtQml 2.0
|
||||
import QtQuick 2.0
|
||||
|
||||
Rectangle {
|
||||
|
|
|
@ -48,6 +48,7 @@
|
|||
**
|
||||
****************************************************************************/
|
||||
|
||||
import QtQml 2.0
|
||||
import QtQuick 2.0
|
||||
|
||||
Rectangle {
|
||||
|
|
|
@ -53,7 +53,9 @@ import QtQuick 2.0
|
|||
//! [0]
|
||||
Item {
|
||||
id: root
|
||||
property string colorKey
|
||||
|
||||
required property string colorKey
|
||||
required property int modelData
|
||||
|
||||
width: 64; height: 64
|
||||
|
||||
|
@ -74,9 +76,9 @@ Item {
|
|||
anchors.verticalCenter: parent.verticalCenter
|
||||
anchors.horizontalCenter: parent.horizontalCenter
|
||||
|
||||
color: colorKey
|
||||
color: root.colorKey
|
||||
|
||||
Drag.keys: [ colorKey ]
|
||||
Drag.keys: [ root.colorKey ]
|
||||
Drag.active: mouseArea.drag.active
|
||||
Drag.hotSpot.x: 32
|
||||
Drag.hotSpot.y: 32
|
||||
|
@ -85,7 +87,7 @@ Item {
|
|||
anchors.fill: parent
|
||||
color: "white"
|
||||
font.pixelSize: 48
|
||||
text: modelData + 1
|
||||
text: root.modelData + 1
|
||||
horizontalAlignment:Text.AlignHCenter
|
||||
verticalAlignment: Text.AlignVCenter
|
||||
}
|
||||
|
|
|
@ -64,7 +64,7 @@ DropArea {
|
|||
id: dropRectangle
|
||||
|
||||
anchors.fill: parent
|
||||
color: colorKey
|
||||
color: dragTarget.colorKey
|
||||
|
||||
states: [
|
||||
State {
|
||||
|
|
|
@ -71,14 +71,18 @@ Rectangle {
|
|||
id: dropArea
|
||||
anchors.fill: parent
|
||||
keys: ["text/plain"]
|
||||
onEntered: if (!acceptDropCB.checked) {
|
||||
drag.accepted = false
|
||||
rejectAnimation.start()
|
||||
onEntered: (drag) => {
|
||||
if (!acceptDropCB.checked) {
|
||||
drag.accepted = false
|
||||
rejectAnimation.start()
|
||||
}
|
||||
}
|
||||
onDropped: if (drop.hasText && acceptDropCB.checked) {
|
||||
if (drop.proposedAction == Qt.MoveAction || drop.proposedAction == Qt.CopyAction) {
|
||||
item.display = drop.text
|
||||
drop.acceptProposedAction()
|
||||
onDropped: (drop) => {
|
||||
if (drop.hasText && acceptDropCB.checked) {
|
||||
if (drop.proposedAction == Qt.MoveAction || drop.proposedAction == Qt.CopyAction) {
|
||||
item.display = drop.text
|
||||
drop.acceptProposedAction()
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -95,7 +99,10 @@ Rectangle {
|
|||
Drag.hotSpot.y: 0
|
||||
Drag.mimeData: { "text/plain": item.display }
|
||||
Drag.dragType: Drag.Automatic
|
||||
Drag.onDragFinished: if (dropAction == Qt.MoveAction) item.display = ""
|
||||
Drag.onDragFinished: (dropAction) => {
|
||||
if (dropAction == Qt.MoveAction)
|
||||
item.display = ""
|
||||
}
|
||||
}
|
||||
Examples.CheckBox {
|
||||
id: acceptDropCB
|
||||
|
|
|
@ -73,7 +73,7 @@ Item {
|
|||
MouseArea {
|
||||
anchors.fill: parent
|
||||
acceptedButtons: Qt.LeftButton | Qt.RightButton
|
||||
onClicked: {
|
||||
onClicked: (mouse) => {
|
||||
if (!sprite.running)
|
||||
sprite.start();
|
||||
if (!sprite.paused)
|
||||
|
|
|
@ -93,7 +93,10 @@ Item {
|
|||
Repeater {
|
||||
model: [ "Scale", "Repeat", "Scale/Repeat", "Round" ]
|
||||
delegate: Text {
|
||||
text: model.modelData
|
||||
required property string modelData
|
||||
required property int index
|
||||
|
||||
text: modelData
|
||||
anchors.verticalCenter: parent.verticalCenter
|
||||
|
||||
x: (index - selector.curIdx) * 80 + 140
|
||||
|
|
|
@ -53,8 +53,6 @@ Item {
|
|||
property alias mode: image.fillMode
|
||||
property alias caption: captionItem.text
|
||||
|
||||
width: parent.cellWidth; height: parent.cellHeight
|
||||
|
||||
Image {
|
||||
id: image
|
||||
width: parent.width; height: parent.height - captionItem.height
|
||||
|
|
|
@ -48,6 +48,7 @@
|
|||
**
|
||||
****************************************************************************/
|
||||
|
||||
import QtQml 2.0
|
||||
import QtQuick 2.0
|
||||
|
||||
Item {
|
||||
|
|
|
@ -65,12 +65,34 @@ Rectangle {
|
|||
rows: 3
|
||||
spacing: 30
|
||||
|
||||
ImageCell { mode: Image.Stretch; caption: "Stretch" }
|
||||
ImageCell { mode: Image.PreserveAspectFit; caption: "PreserveAspectFit" }
|
||||
ImageCell { mode: Image.PreserveAspectCrop; caption: "PreserveAspectCrop" }
|
||||
component SizedImageCell: ImageCell {
|
||||
width: parent.cellWidth
|
||||
height: parent.cellHeight
|
||||
}
|
||||
|
||||
ImageCell { mode: Image.Tile; caption: "Tile" }
|
||||
ImageCell { mode: Image.TileHorizontally; caption: "TileHorizontally" }
|
||||
ImageCell { mode: Image.TileVertically; caption: "TileVertically" }
|
||||
SizedImageCell {
|
||||
mode: Image.Stretch
|
||||
caption: "Stretch"
|
||||
}
|
||||
SizedImageCell {
|
||||
mode: Image.PreserveAspectFit
|
||||
caption: "PreserveAspectFit"
|
||||
}
|
||||
SizedImageCell {
|
||||
mode: Image.PreserveAspectCrop
|
||||
caption: "PreserveAspectCrop"
|
||||
}
|
||||
SizedImageCell {
|
||||
mode: Image.Tile
|
||||
caption: "Tile"
|
||||
}
|
||||
SizedImageCell {
|
||||
mode: Image.TileHorizontally
|
||||
caption: "TileHorizontally"
|
||||
}
|
||||
SizedImageCell {
|
||||
mode: Image.TileVertically
|
||||
caption: "TileVertically"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -52,6 +52,7 @@ import QtQuick 2.1
|
|||
|
||||
FocusScope {
|
||||
id: container
|
||||
required property Item keyRightTarget
|
||||
|
||||
property bool open: false
|
||||
|
||||
|
@ -62,7 +63,7 @@ FocusScope {
|
|||
anchors.fill: parent
|
||||
color: "#D1DBBD"
|
||||
focus: true
|
||||
Keys.onRightPressed: mainView.focus = true
|
||||
Keys.onRightPressed: container.keyRightTarget.focus = true
|
||||
|
||||
Text {
|
||||
anchors { top: parent.top; horizontalCenter: parent.horizontalCenter; margins: 30 }
|
||||
|
|
|
@ -51,12 +51,11 @@
|
|||
import QtQuick 2.1
|
||||
|
||||
FocusScope {
|
||||
id: menu
|
||||
property alias interactive: gridView.interactive
|
||||
|
||||
onActiveFocusChanged: {
|
||||
if (activeFocus)
|
||||
mainView.state = "showGridViews"
|
||||
}
|
||||
required property Item keyUpTarget
|
||||
required property Item keyDownTarget
|
||||
required property Item keyLeftTarget
|
||||
|
||||
Rectangle {
|
||||
anchors.fill: parent
|
||||
|
@ -73,13 +72,15 @@ FocusScope {
|
|||
focus: true
|
||||
model: 12
|
||||
|
||||
KeyNavigation.up: tabMenu
|
||||
KeyNavigation.down: listMenu
|
||||
KeyNavigation.left: contextMenu
|
||||
KeyNavigation.up: menu.keyUpTarget
|
||||
KeyNavigation.down: menu.keyDownTarget
|
||||
KeyNavigation.left: menu.keyLeftTarget
|
||||
|
||||
delegate: Item {
|
||||
id: container
|
||||
width: GridView.view.cellWidth; height: GridView.view.cellHeight
|
||||
width: GridView.view.cellWidth
|
||||
height: GridView.view.cellHeight
|
||||
required property int index
|
||||
|
||||
Rectangle {
|
||||
id: content
|
||||
|
@ -97,7 +98,7 @@ FocusScope {
|
|||
hoverEnabled: true
|
||||
|
||||
onClicked: {
|
||||
container.GridView.view.currentIndex = index
|
||||
container.GridView.view.currentIndex = container.index
|
||||
container.forceActiveFocus()
|
||||
}
|
||||
}
|
||||
|
|
|
@ -48,21 +48,22 @@
|
|||
**
|
||||
****************************************************************************/
|
||||
|
||||
import QtQml 2.1
|
||||
import QtQuick 2.1
|
||||
|
||||
FocusScope {
|
||||
id: menu
|
||||
clip: true
|
||||
|
||||
onActiveFocusChanged: {
|
||||
if (activeFocus)
|
||||
mainView.state = "showListViews"
|
||||
}
|
||||
required property Item keyUpTarget
|
||||
required property Item keyLeftTarget
|
||||
|
||||
ListView {
|
||||
id: list1
|
||||
y: activeFocus ? 10 : 40; width: parent.width / 3; height: parent.height - 20
|
||||
focus: true
|
||||
KeyNavigation.up: gridMenu; KeyNavigation.left: contextMenu; KeyNavigation.right: list2
|
||||
KeyNavigation.up: menu.keyUpTarget
|
||||
KeyNavigation.left: menu.keyLeftTarget
|
||||
KeyNavigation.right: list2
|
||||
model: 10; cacheBuffer: 200
|
||||
delegate: ListViewDelegate {}
|
||||
|
||||
|
@ -74,7 +75,9 @@ FocusScope {
|
|||
ListView {
|
||||
id: list2
|
||||
y: activeFocus ? 10 : 40; x: parseInt(parent.width / 3); width: parent.width / 3; height: parent.height - 20
|
||||
KeyNavigation.up: gridMenu; KeyNavigation.left: list1; KeyNavigation.right: list3
|
||||
KeyNavigation.up: menu.keyUpTarget
|
||||
KeyNavigation.left: list1
|
||||
KeyNavigation.right: list3
|
||||
model: 10; cacheBuffer: 200
|
||||
delegate: ListViewDelegate {}
|
||||
|
||||
|
@ -86,7 +89,8 @@ FocusScope {
|
|||
ListView {
|
||||
id: list3
|
||||
y: activeFocus ? 10 : 40; x: parseInt(2 * parent.width / 3); width: parent.width / 3; height: parent.height - 20
|
||||
KeyNavigation.up: gridMenu; KeyNavigation.left: list2
|
||||
KeyNavigation.up: menu.keyUpTarget
|
||||
KeyNavigation.left: list2
|
||||
model: 10; cacheBuffer: 200
|
||||
delegate: ListViewDelegate {}
|
||||
|
||||
|
|
|
@ -52,6 +52,8 @@ import QtQuick 2.1
|
|||
|
||||
Item {
|
||||
id: container
|
||||
required property int index
|
||||
|
||||
width: ListView.view.width; height: 60; anchors.leftMargin: 10; anchors.rightMargin: 10
|
||||
|
||||
Rectangle {
|
||||
|
@ -67,7 +69,7 @@ Item {
|
|||
Text {
|
||||
id: label
|
||||
anchors.centerIn: content
|
||||
text: "List element " + (index + 1)
|
||||
text: "List element " + (container.index + 1)
|
||||
color: "#193441"
|
||||
font.pixelSize: 14
|
||||
}
|
||||
|
@ -78,7 +80,7 @@ Item {
|
|||
hoverEnabled: true
|
||||
|
||||
onClicked: {
|
||||
container.ListView.view.currentIndex = index
|
||||
container.ListView.view.currentIndex = container.index
|
||||
container.forceActiveFocus()
|
||||
}
|
||||
}
|
||||
|
|
|
@ -51,10 +51,9 @@
|
|||
import QtQuick 2.1
|
||||
|
||||
FocusScope {
|
||||
onActiveFocusChanged: {
|
||||
if (activeFocus)
|
||||
mainView.state = "showTabViews"
|
||||
}
|
||||
id: menu
|
||||
required property Item keyUpTarget
|
||||
required property Item keyDownTarget
|
||||
|
||||
Rectangle {
|
||||
anchors.fill: parent
|
||||
|
@ -76,8 +75,8 @@ FocusScope {
|
|||
activeFocusOnTab: true
|
||||
focus: true
|
||||
|
||||
KeyNavigation.up: listMenu
|
||||
KeyNavigation.down: gridMenu
|
||||
KeyNavigation.up: menu.keyUpTarget
|
||||
KeyNavigation.down: menu.keyDownTarget
|
||||
|
||||
Rectangle {
|
||||
id: content
|
||||
|
|
|
@ -48,6 +48,7 @@
|
|||
**
|
||||
****************************************************************************/
|
||||
|
||||
import QtQml 2.1
|
||||
import QtQuick 2.1
|
||||
import "Core"
|
||||
|
||||
|
@ -67,20 +68,45 @@ Rectangle {
|
|||
id: tabMenu
|
||||
y: 160; width: parent.width; height: 160
|
||||
|
||||
keyUpTarget: listMenu
|
||||
keyDownTarget: gridMenu
|
||||
|
||||
focus: true
|
||||
activeFocusOnTab: true
|
||||
|
||||
onActiveFocusChanged: {
|
||||
if (activeFocus)
|
||||
mainView.state = "showTabViews"
|
||||
}
|
||||
}
|
||||
|
||||
GridMenu {
|
||||
id: gridMenu
|
||||
y: 320; width: parent.width; height: 320
|
||||
activeFocusOnTab: true
|
||||
|
||||
keyUpTarget: tabMenu
|
||||
keyDownTarget: listMenu
|
||||
keyLeftTarget: contextMenu
|
||||
|
||||
onActiveFocusChanged: {
|
||||
if (activeFocus)
|
||||
mainView.state = "showGridViews"
|
||||
}
|
||||
}
|
||||
|
||||
ListMenu {
|
||||
id: listMenu
|
||||
y: 640; width: parent.width; height: 320
|
||||
activeFocusOnTab: true
|
||||
|
||||
keyUpTarget: gridMenu
|
||||
keyLeftTarget: contextMenu
|
||||
|
||||
onActiveFocusChanged: {
|
||||
if (activeFocus)
|
||||
mainView.state = "showListViews"
|
||||
}
|
||||
}
|
||||
|
||||
Rectangle {
|
||||
|
@ -129,7 +155,13 @@ Rectangle {
|
|||
}
|
||||
}
|
||||
|
||||
ContextMenu { id: contextMenu; x: -265; width: 260; height: parent.height }
|
||||
ContextMenu {
|
||||
keyRightTarget: mainView
|
||||
id: contextMenu
|
||||
x: -265
|
||||
width: 260
|
||||
height: parent.height
|
||||
}
|
||||
|
||||
states: State {
|
||||
name: "contextMenuOpen"
|
||||
|
|
|
@ -59,6 +59,9 @@ Item {
|
|||
width: Screen.width / 2
|
||||
height: Screen.height / 7
|
||||
|
||||
required property ListView listView
|
||||
required property Text statusText
|
||||
|
||||
function insertrec() {
|
||||
var rowid = parseInt(JS.dbInsert(dateInput.text, descInput.text, distInput.text), 10)
|
||||
if (rowid) {
|
||||
|
@ -148,7 +151,7 @@ Item {
|
|||
}
|
||||
onEditingFinished: {
|
||||
if (dateInput.text == "") {
|
||||
statustext.text = "Please fill in the date"
|
||||
root.statusText.text = "Please fill in the date"
|
||||
dateInput.forceActiveFocus()
|
||||
}
|
||||
}
|
||||
|
@ -161,10 +164,10 @@ Item {
|
|||
activeFocusOnTab: true
|
||||
onEditingFinished: {
|
||||
if (descInput.text.length < 8) {
|
||||
statustext.text = "Enter a description of minimum 8 characters"
|
||||
root.statusText.text = "Enter a description of minimum 8 characters"
|
||||
descInput.forceActiveFocus()
|
||||
} else {
|
||||
statustext.text = ""
|
||||
root.statusText.text = ""
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -179,7 +182,7 @@ Item {
|
|||
}
|
||||
onEditingFinished: {
|
||||
if (distInput.text == "") {
|
||||
statustext.text = "Please fill in the distance"
|
||||
root.statusText.text = "Please fill in the distance"
|
||||
distInput.forceActiveFocus()
|
||||
}
|
||||
}
|
||||
|
|
|
@ -54,18 +54,27 @@ import QtQuick.Layouts 1.1
|
|||
import "Database.js" as JS
|
||||
|
||||
Item {
|
||||
id: delegate
|
||||
|
||||
width: parent.width
|
||||
height: rDate.implicitHeight
|
||||
|
||||
required property int index
|
||||
required property int distance
|
||||
required property string trip_desc
|
||||
required property string date
|
||||
|
||||
signal clicked()
|
||||
|
||||
Rectangle {
|
||||
id: baseRec
|
||||
anchors.fill: parent
|
||||
opacity: 0.8
|
||||
color: index % 2 ? "lightgrey" : "grey"
|
||||
color: delegate.index % 2 ? "lightgrey" : "grey"
|
||||
|
||||
MouseArea {
|
||||
anchors.fill: parent
|
||||
onClicked: listView.currentIndex = index
|
||||
onClicked: delegate.clicked()
|
||||
}
|
||||
GridLayout {
|
||||
anchors.fill:parent
|
||||
|
@ -73,21 +82,21 @@ Item {
|
|||
|
||||
Text {
|
||||
id: rDate
|
||||
text: date
|
||||
text: delegate.date
|
||||
font.pixelSize: 22
|
||||
Layout.preferredWidth: parent.width / 4
|
||||
color: "black"
|
||||
}
|
||||
Text {
|
||||
id: rDesc
|
||||
text: trip_desc
|
||||
text: delegate.trip_desc
|
||||
Layout.fillWidth: true
|
||||
font.pixelSize: 22
|
||||
color: "black"
|
||||
}
|
||||
Text {
|
||||
id: rDistance
|
||||
text: distance
|
||||
text: delegate.distance
|
||||
font.pixelSize: 22
|
||||
Layout.alignment: Qt.AlignRight
|
||||
color: "black"
|
||||
|
|
|
@ -55,6 +55,7 @@ import QtQuick.LocalStorage 2.0
|
|||
import "Database.js" as JS
|
||||
|
||||
Window {
|
||||
id: window
|
||||
visible: true
|
||||
width: Screen.width / 2
|
||||
height: Screen.height / 1.8
|
||||
|
@ -72,19 +73,21 @@ Window {
|
|||
Header {
|
||||
id: input
|
||||
Layout.fillWidth: true
|
||||
listView: listView
|
||||
statusText: statustext
|
||||
}
|
||||
RowLayout {
|
||||
MyButton {
|
||||
text: "New"
|
||||
onClicked: {
|
||||
input.initrec_new()
|
||||
creatingNewEntry = true
|
||||
window.creatingNewEntry = true
|
||||
listView.model.setProperty(listView.currentIndex, "id", 0)
|
||||
}
|
||||
}
|
||||
MyButton {
|
||||
id: saveButton
|
||||
enabled: (creatingNewEntry || editingEntry) && listView.currentIndex != -1
|
||||
enabled: (window.creatingNewEntry || window.editingEntry) && listView.currentIndex != -1
|
||||
text: "Save"
|
||||
onClicked: {
|
||||
var insertedRow = false;
|
||||
|
@ -109,8 +112,8 @@ Window {
|
|||
|
||||
if (insertedRow) {
|
||||
input.initrec()
|
||||
creatingNewEntry = false
|
||||
editingEntry = false
|
||||
window.creatingNewEntry = false
|
||||
window.editingEntry = false
|
||||
listView.forceLayout()
|
||||
}
|
||||
}
|
||||
|
@ -118,20 +121,20 @@ Window {
|
|||
MyButton {
|
||||
id: editButton
|
||||
text: "Edit"
|
||||
enabled: !creatingNewEntry && !editingEntry && listView.currentIndex != -1
|
||||
enabled: !window.creatingNewEntry && !window.editingEntry && listView.currentIndex != -1
|
||||
onClicked: {
|
||||
input.editrec(listView.model.get(listView.currentIndex).date,
|
||||
listView.model.get(listView.currentIndex).trip_desc,
|
||||
listView.model.get(listView.currentIndex).distance,
|
||||
listView.model.get(listView.currentIndex).id)
|
||||
|
||||
editingEntry = true
|
||||
window.editingEntry = true
|
||||
}
|
||||
}
|
||||
MyButton {
|
||||
id: deleteButton
|
||||
text: "Delete"
|
||||
enabled: !creatingNewEntry && listView.currentIndex != -1
|
||||
enabled: !window.creatingNewEntry && listView.currentIndex != -1
|
||||
onClicked: {
|
||||
JS.dbDeleteRow(listView.model.get(listView.currentIndex).id)
|
||||
listView.model.remove(listView.currentIndex, 1)
|
||||
|
@ -145,7 +148,7 @@ Window {
|
|||
MyButton {
|
||||
id: cancelButton
|
||||
text: "Cancel"
|
||||
enabled: (creatingNewEntry || editingEntry) && listView.currentIndex != -1
|
||||
enabled: (window.creatingNewEntry || window.editingEntry) && listView.currentIndex != -1
|
||||
onClicked: {
|
||||
if (listView.model.get(listView.currentIndex).id === 0) {
|
||||
// This entry had an id of 0, which means it was being created and hadn't
|
||||
|
@ -153,8 +156,8 @@ Window {
|
|||
listView.model.remove(listView.currentIndex, 1)
|
||||
}
|
||||
listView.forceLayout()
|
||||
creatingNewEntry = false
|
||||
editingEntry = false
|
||||
window.creatingNewEntry = false
|
||||
window.editingEntry = false
|
||||
input.initrec()
|
||||
}
|
||||
}
|
||||
|
@ -176,9 +179,11 @@ Window {
|
|||
Layout.fillWidth: true
|
||||
Layout.fillHeight: true
|
||||
model: MyModel {}
|
||||
delegate: MyDelegate {}
|
||||
delegate: MyDelegate {
|
||||
onClicked: listView.currentIndex = index
|
||||
}
|
||||
// Don't allow changing the currentIndex while the user is creating/editing values.
|
||||
enabled: !creatingNewEntry && !editingEntry
|
||||
enabled: !window.creatingNewEntry && !window.editingEntry
|
||||
|
||||
highlight: highlightBar
|
||||
highlightFollowsCurrentItem: true
|
||||
|
|
|
@ -68,10 +68,8 @@ int main(int argc, char ** argv)
|
|||
|
||||
QQuickView view;
|
||||
view.setResizeMode(QQuickView::SizeRootObjectToView);
|
||||
QQmlContext *ctxt = view.rootContext();
|
||||
ctxt->setContextProperty("myModel", &model);
|
||||
view.setInitialProperties({{"model", QVariant::fromValue(&model)}});
|
||||
//![0]
|
||||
|
||||
view.setSource(QUrl("qrc:view.qml"));
|
||||
view.show();
|
||||
|
||||
|
|
|
@ -53,8 +53,14 @@ import QtQuick 2.0
|
|||
ListView {
|
||||
width: 200; height: 250
|
||||
|
||||
model: myModel
|
||||
delegate: Text { text: "Animal: " + type + ", " + size }
|
||||
required model
|
||||
|
||||
delegate: Text {
|
||||
required property string type
|
||||
required property string size
|
||||
|
||||
text: "Animal: " + type + ", " + size
|
||||
}
|
||||
}
|
||||
//![0]
|
||||
|
||||
|
|
|
@ -68,16 +68,16 @@ int main(int argc, char ** argv)
|
|||
{
|
||||
QGuiApplication app(argc, argv);
|
||||
|
||||
QList<QObject*> dataList;
|
||||
dataList.append(new DataObject("Item 1", "red"));
|
||||
dataList.append(new DataObject("Item 2", "green"));
|
||||
dataList.append(new DataObject("Item 3", "blue"));
|
||||
dataList.append(new DataObject("Item 4", "yellow"));
|
||||
QList<QObject *> dataList = {
|
||||
new DataObject("Item 1", "red"),
|
||||
new DataObject("Item 2", "green"),
|
||||
new DataObject("Item 3", "blue"),
|
||||
new DataObject("Item 4", "yellow")
|
||||
};
|
||||
|
||||
QQuickView view;
|
||||
view.setResizeMode(QQuickView::SizeRootObjectToView);
|
||||
QQmlContext *ctxt = view.rootContext();
|
||||
ctxt->setContextProperty("myModel", QVariant::fromValue(dataList));
|
||||
view.setInitialProperties({{ "model", QVariant::fromValue(dataList) }});
|
||||
//![0]
|
||||
|
||||
view.setSource(QUrl("qrc:view.qml"));
|
||||
|
|
|
@ -53,13 +53,15 @@ import QtQuick 2.0
|
|||
//![0]
|
||||
ListView {
|
||||
width: 100; height: 100
|
||||
required model
|
||||
|
||||
model: myModel
|
||||
delegate: Rectangle {
|
||||
required color
|
||||
required property string name
|
||||
|
||||
height: 25
|
||||
width: 100
|
||||
color: model.modelData.color
|
||||
Text { text: name }
|
||||
Text { text: parent.name }
|
||||
}
|
||||
}
|
||||
//![0]
|
||||
|
|
|
@ -68,15 +68,15 @@ int main(int argc, char ** argv)
|
|||
QGuiApplication app(argc, argv);
|
||||
|
||||
//![0]
|
||||
QStringList dataList;
|
||||
dataList.append("Item 1");
|
||||
dataList.append("Item 2");
|
||||
dataList.append("Item 3");
|
||||
dataList.append("Item 4");
|
||||
QStringList dataList = {
|
||||
"Item 1",
|
||||
"Item 2",
|
||||
"Item 3",
|
||||
"Item 4"
|
||||
};
|
||||
|
||||
QQuickView view;
|
||||
QQmlContext *ctxt = view.rootContext();
|
||||
ctxt->setContextProperty("myModel", QVariant::fromValue(dataList));
|
||||
view.setInitialProperties({{ "model", QVariant::fromValue(dataList) }});
|
||||
//![0]
|
||||
|
||||
view.setSource(QUrl("qrc:view.qml"));
|
||||
|
|
|
@ -52,13 +52,15 @@ import QtQuick 2.0
|
|||
//![0]
|
||||
|
||||
ListView {
|
||||
width: 100; height: 100
|
||||
width: 100
|
||||
height: 100
|
||||
required model
|
||||
|
||||
model: myModel
|
||||
delegate: Rectangle {
|
||||
required property string modelData
|
||||
height: 25
|
||||
width: 100
|
||||
Text { text: modelData }
|
||||
Text { text: parent.modelData }
|
||||
}
|
||||
}
|
||||
//![0]
|
||||
|
|
|
@ -63,6 +63,8 @@ Rectangle {
|
|||
model: ["#9ACD32", "#EEEEEE", "#FFD700", "#87CEEB"]
|
||||
|
||||
Rectangle {
|
||||
required property color modelData
|
||||
|
||||
property real scaleFactor: 1
|
||||
|
||||
height: 40 * scaleFactor
|
||||
|
|
|
@ -76,7 +76,7 @@ Rectangle {
|
|||
onEntered: info.text = 'Entered'
|
||||
onExited: info.text = 'Exited (pressed=' + pressed + ')'
|
||||
|
||||
onPressed: {
|
||||
onPressed: (mouse) => {
|
||||
if (mouse.button == Qt.LeftButton)
|
||||
buttonID = 'LeftButton'
|
||||
else if (mouse.button == Qt.RightButton)
|
||||
|
@ -139,14 +139,14 @@ Rectangle {
|
|||
+ ' (' + posInBox.x + ',' + posInBox.y + ' in window)'
|
||||
}
|
||||
|
||||
onReleased: {
|
||||
onReleased: (mouse) => {
|
||||
btn.text = 'Released (isClick=' + mouse.isClick + ' wasHeld=' + mouse.wasHeld + ')'
|
||||
posInfo.text = ''
|
||||
}
|
||||
|
||||
//! [clicks]
|
||||
onPressAndHold: btn.text = 'Press and hold'
|
||||
onClicked: btn.text = 'Clicked (wasHeld=' + mouse.wasHeld + ')'
|
||||
onClicked: (mouse) => { btn.text = 'Clicked (wasHeld=' + mouse.wasHeld + ')' }
|
||||
onDoubleClicked: btn.text = 'Double clicked'
|
||||
//! [clicks]
|
||||
}
|
||||
|
|
|
@ -81,7 +81,7 @@ Item {
|
|||
property real velocity: 1.5
|
||||
width: parent.width
|
||||
height: parent.height - 100
|
||||
onAffectParticles: {
|
||||
onAffectParticles: (particles, dt) => {
|
||||
/* //Linear movement
|
||||
if (particle.r == 0) {
|
||||
particle.r = Math.random() > 0.5 ? -1 : 1;
|
||||
|
@ -117,7 +117,7 @@ Item {
|
|||
width: parent.width + 120
|
||||
height: 100
|
||||
anchors.bottom: parent.bottom
|
||||
onAffectParticles: {
|
||||
onAffectParticles: (particles, dt) => {
|
||||
for (var i=0; i<particles.length; i++) {
|
||||
var particle = particles[i];
|
||||
var pseudoRand = (Math.floor(particle.t*1327) % 10) + 1;
|
||||
|
|
|
@ -62,7 +62,7 @@ Rectangle {
|
|||
Text {
|
||||
color: "white"
|
||||
anchors.right: parent.right
|
||||
text: score
|
||||
text: root.score
|
||||
}
|
||||
|
||||
ParticleSystem {
|
||||
|
@ -96,7 +96,7 @@ Rectangle {
|
|||
ParticleGroup {
|
||||
name: "lit"
|
||||
duration: 10000
|
||||
onEntered: score++;
|
||||
onEntered: root.score++
|
||||
TrailEmitter {
|
||||
id: fireballFlame
|
||||
group: "flame"
|
||||
|
|
|
@ -52,6 +52,8 @@ import QtQuick 2.0
|
|||
import QtQuick.Particles 2.0
|
||||
|
||||
Rectangle {
|
||||
id: root
|
||||
|
||||
width: 320
|
||||
height: 480
|
||||
color: "black"
|
||||
|
@ -63,12 +65,12 @@ Rectangle {
|
|||
repeat: true
|
||||
onTriggered: {
|
||||
//! [0]
|
||||
if (lastWasPulse) {
|
||||
if (root.lastWasPulse) {
|
||||
burstEmitter.burst(500);
|
||||
lastWasPulse = false;
|
||||
root.lastWasPulse = false;
|
||||
} else {
|
||||
pulseEmitter.pulse(500);
|
||||
lastWasPulse = true;
|
||||
root.lastWasPulse = true;
|
||||
}
|
||||
//! [0]
|
||||
}
|
||||
|
|
|
@ -79,7 +79,7 @@ ParticleSystem {
|
|||
size: 12
|
||||
anchors.centerIn: parent
|
||||
//! [0]
|
||||
onEmitParticles: {
|
||||
onEmitParticles: (particles) => {
|
||||
for (var i=0; i<particles.length; i++) {
|
||||
var particle = particles[i];
|
||||
particle.startSize = Math.max(02,Math.min(492,Math.tan(particle.t/2)*24));
|
||||
|
@ -90,8 +90,8 @@ ParticleSystem {
|
|||
theta /= 6.0;
|
||||
theta *= 2.0*Math.PI;
|
||||
theta += sys.convert(sys.petalRotation);//Convert from degrees to radians
|
||||
particle.initialVX = petalLength * Math.cos(theta);
|
||||
particle.initialVY = petalLength * Math.sin(theta);
|
||||
particle.initialVX = sys.petalLength * Math.cos(theta);
|
||||
particle.initialVY = sys.petalLength * Math.sin(theta);
|
||||
particle.initialAX = particle.initialVX * -0.5;
|
||||
particle.initialAY = particle.initialVY * -0.5;
|
||||
}
|
||||
|
|
|
@ -56,6 +56,8 @@ import QtQuick 2.0
|
|||
import QtQuick.Particles 2.0
|
||||
|
||||
Rectangle {
|
||||
id: root
|
||||
|
||||
property real delegateHeight: 65
|
||||
width: 200; height: 300
|
||||
gradient: Gradient {
|
||||
|
@ -65,53 +67,53 @@ Rectangle {
|
|||
|
||||
// Define a delegate component. A component will be
|
||||
// instantiated for each visible item in the list.
|
||||
Component {
|
||||
id: petDelegate
|
||||
Item {
|
||||
id: wrapper
|
||||
width: 200; height: delegateHeight
|
||||
z: 10
|
||||
Column {
|
||||
Text {color: "white"; text: name; font.pixelSize: 18 }
|
||||
Text {color: "white"; text: 'Type: ' + type; font.pixelSize: 14 }
|
||||
Text {color: "white"; text: 'Age: ' + age; font.pixelSize: 14 }
|
||||
}
|
||||
MouseArea { anchors.fill: parent; onClicked: listView.currentIndex = index; }
|
||||
// indent the item if it is the current item
|
||||
states: State {
|
||||
name: "Current"
|
||||
when: wrapper.ListView.isCurrentItem
|
||||
PropertyChanges { target: wrapper; x: 20 }
|
||||
}
|
||||
transitions: Transition {
|
||||
NumberAnimation { properties: "x"; duration: 200 }
|
||||
}
|
||||
component PetDelegate: Item {
|
||||
id: pet
|
||||
width: 200; height: root.delegateHeight
|
||||
z: 10
|
||||
|
||||
required property int index
|
||||
required property string name
|
||||
required property string type
|
||||
required property int age
|
||||
|
||||
Column {
|
||||
Text {color: "white"; text: pet.name; font.pixelSize: 18 }
|
||||
Text {color: "white"; text: 'Type: ' + pet.type; font.pixelSize: 14 }
|
||||
Text {color: "white"; text: 'Age: ' + pet.age; font.pixelSize: 14 }
|
||||
}
|
||||
MouseArea { anchors.fill: parent; onClicked: listView.currentIndex = pet.index; }
|
||||
// indent the item if it is the current item
|
||||
states: State {
|
||||
name: "Current"
|
||||
when: pet.ListView.isCurrentItem
|
||||
PropertyChanges { target: pet; x: 20 }
|
||||
}
|
||||
transitions: Transition {
|
||||
NumberAnimation { properties: "x"; duration: 200 }
|
||||
}
|
||||
}
|
||||
|
||||
// Define a highlight with customized movement between items.
|
||||
Component {
|
||||
id: highlightBar
|
||||
Rectangle {
|
||||
z: 0
|
||||
width: 200; height: delegateHeight
|
||||
gradient: Gradient {
|
||||
GradientStop { position: 0.0; color: "#99FF99" }
|
||||
GradientStop { position: 1.0; color: "#88FF88" }
|
||||
}
|
||||
y: listView.currentItem.y;
|
||||
Behavior on y { SpringAnimation { spring: 2; damping: 0.2 } }
|
||||
//! [1]
|
||||
ImageParticle {
|
||||
anchors.fill: parent
|
||||
system: particles
|
||||
source: "../../images/flower.png"
|
||||
color: "red"
|
||||
clip: true
|
||||
alpha: 1.0
|
||||
}
|
||||
//! [1]
|
||||
component HighlightBar : Rectangle {
|
||||
z: 0
|
||||
width: 200; height: root.delegateHeight
|
||||
gradient: Gradient {
|
||||
GradientStop { position: 0.0; color: "#99FF99" }
|
||||
GradientStop { position: 1.0; color: "#88FF88" }
|
||||
}
|
||||
y: listView.currentItem.y;
|
||||
Behavior on y { SpringAnimation { spring: 2; damping: 0.2 } }
|
||||
//! [1]
|
||||
ImageParticle {
|
||||
anchors.fill: parent
|
||||
system: particles
|
||||
source: "../../images/flower.png"
|
||||
color: "red"
|
||||
clip: true
|
||||
alpha: 1.0
|
||||
}
|
||||
//! [1]
|
||||
}
|
||||
|
||||
ListView {
|
||||
|
@ -119,12 +121,12 @@ Rectangle {
|
|||
width: 200; height: parent.height
|
||||
|
||||
model: petsModel
|
||||
delegate: petDelegate
|
||||
delegate: PetDelegate {}
|
||||
focus: true
|
||||
|
||||
// Set the highlight delegate. Note we must also set highlightFollowsCurrentItem
|
||||
// to false so the highlight delegate can control how the highlight is moved.
|
||||
highlight: highlightBar
|
||||
highlight: HighlightBar {}
|
||||
highlightFollowsCurrentItem: false
|
||||
|
||||
ParticleSystem { id: particles }
|
||||
|
|
|
@ -156,7 +156,7 @@ Item {
|
|||
interval: 800
|
||||
onTriggered: {
|
||||
force.enabled = false;
|
||||
mp.take(alertItem, true);
|
||||
mp.take(root.alertItem, true);
|
||||
centerEmitter.burst(1);
|
||||
}
|
||||
}
|
||||
|
@ -216,6 +216,11 @@ Item {
|
|||
Component {
|
||||
id: theDelegate
|
||||
Image {
|
||||
required property int index
|
||||
required property string title
|
||||
required property string media
|
||||
required property string thumbnail
|
||||
|
||||
id: image
|
||||
antialiasing: true;
|
||||
source: thumbnail
|
||||
|
@ -237,7 +242,7 @@ Item {
|
|||
width: parent.paintedWidth + 1
|
||||
height: parent.paintedHeight + 1
|
||||
color: "black"
|
||||
opacity: darken * (1 - depth)
|
||||
opacity: image.darken * (1 - image.depth)
|
||||
antialiasing: true;
|
||||
}
|
||||
Text {
|
||||
|
@ -247,7 +252,7 @@ Item {
|
|||
width: parent.paintedWidth - 4
|
||||
horizontalAlignment: Text.AlignHCenter
|
||||
elide: Text.ElideRight
|
||||
text: title
|
||||
text: image.title
|
||||
color: "black"
|
||||
}
|
||||
ItemParticle.onDetached: mp.take(image); // respawns
|
||||
|
@ -277,7 +282,7 @@ Item {
|
|||
}
|
||||
PropertyChanges {
|
||||
target: image
|
||||
source: media
|
||||
source: image.media
|
||||
x: 0
|
||||
y: 0
|
||||
width: root.width
|
||||
|
|
|
@ -48,6 +48,7 @@
|
|||
**
|
||||
****************************************************************************/
|
||||
|
||||
import QtQml 2.0
|
||||
import QtQuick 2.0
|
||||
|
||||
Item {
|
||||
|
@ -215,9 +216,9 @@ Item {
|
|||
opacity: page.effectiveOpacity
|
||||
}
|
||||
|
||||
Rectangle { color: "#80c342"; width:page. smallSize; height: page.smallSize }
|
||||
Rectangle { color: "#14aaff"; width: smallSize; height: page.smallSize }
|
||||
Rectangle { color: "#6400aa"; width: page.page.smallSize; height: page.smallSize }
|
||||
Rectangle { color: "#80c342"; width: page.smallSize; height: page.smallSize }
|
||||
Rectangle { color: "#14aaff"; width: page.smallSize; height: page.smallSize }
|
||||
Rectangle { color: "#6400aa"; width: page.smallSize; height: page.smallSize }
|
||||
}
|
||||
|
||||
Flow {
|
||||
|
|
|
@ -72,7 +72,7 @@ Rectangle {
|
|||
x: 1
|
||||
y: 1
|
||||
height: parent.height - 2
|
||||
width: ((parent.width - 2) / maximumValue) * value
|
||||
width: ((parent.width - 2) / slider.maximumValue) * slider.value
|
||||
color: "lightgrey"
|
||||
Behavior on width {
|
||||
NumberAnimation { duration: 50 }
|
||||
|
@ -88,8 +88,9 @@ Rectangle {
|
|||
|
||||
MouseArea {
|
||||
anchors.fill: parent
|
||||
onClicked: {
|
||||
var pos = mouse.x / slider.width * (maximumValue - minimumValue) + minimumValue
|
||||
onClicked: (mouse) => {
|
||||
var pos = mouse.x / slider.width * (slider.maximumValue - slider.minimumValue)
|
||||
+ slider.minimumValue
|
||||
slider.value = pos
|
||||
}
|
||||
}
|
||||
|
|
|
@ -84,8 +84,8 @@ Rectangle {
|
|||
Repeater {
|
||||
model: 3
|
||||
Loader {
|
||||
property int value: index
|
||||
sourceComponent: positionerDelegate
|
||||
required property int index
|
||||
sourceComponent: PositionerDelegate {}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -106,8 +106,8 @@ Rectangle {
|
|||
Repeater {
|
||||
model: 8
|
||||
Loader {
|
||||
property int value: index
|
||||
sourceComponent: positionerDelegate
|
||||
required property int index
|
||||
sourceComponent: PositionerDelegate {}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -128,8 +128,8 @@ Rectangle {
|
|||
Repeater {
|
||||
model: 8
|
||||
Loader {
|
||||
property int value: index
|
||||
sourceComponent: positionerDelegate
|
||||
required property int index
|
||||
sourceComponent: PositionerDelegate {}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -152,7 +152,7 @@ Rectangle {
|
|||
layoutDirection: root.direction
|
||||
orientation: Qt.Horizontal
|
||||
model: 48
|
||||
delegate: viewDelegate
|
||||
delegate: ViewDelegate {}
|
||||
}
|
||||
|
||||
Text {
|
||||
|
@ -166,7 +166,7 @@ Rectangle {
|
|||
cellWidth: 50; cellHeight: 50
|
||||
layoutDirection: root.direction
|
||||
model: 48
|
||||
delegate: viewDelegate
|
||||
delegate: ViewDelegate {}
|
||||
}
|
||||
|
||||
Rectangle {
|
||||
|
@ -230,37 +230,36 @@ Rectangle {
|
|||
}
|
||||
}
|
||||
|
||||
Component {
|
||||
id: positionerDelegate
|
||||
component PositionerDelegate : Rectangle {
|
||||
width: 40
|
||||
height: 40
|
||||
property int lightness: parent.index + 1;
|
||||
color: Qt.rgba(0.8 / lightness, 0.8 / lightness, 0.8 / lightness, 1.0)
|
||||
Text {
|
||||
text: parent.lightness
|
||||
color: "white"
|
||||
font.pixelSize: 18
|
||||
anchors.centerIn: parent
|
||||
}
|
||||
}
|
||||
|
||||
component ViewDelegate : Item {
|
||||
id: delegateItem
|
||||
required property int index
|
||||
width: (listView.effectiveLayoutDirection == Qt.LeftToRight ? (index == 48 - 1) : (index == 0)) ? 40 : 50
|
||||
Rectangle {
|
||||
width: 40; height: 40
|
||||
color: Qt.rgba(0.8/(parent.value+1),0.8/(parent.value+1),0.8/(parent.value+1),1.0)
|
||||
color: Qt.rgba(0.5 + (48 - delegateItem.index) * Math.random() / 48,
|
||||
0.3 + delegateItem.index * Math.random() / 48,
|
||||
0.3 * Math.random(),
|
||||
1.0)
|
||||
Text {
|
||||
text: parent.parent.value+1
|
||||
text: delegateItem.index + 1
|
||||
color: "white"
|
||||
font.pixelSize: 18
|
||||
anchors.centerIn: parent
|
||||
}
|
||||
}
|
||||
}
|
||||
Component {
|
||||
id: viewDelegate
|
||||
Item {
|
||||
width: (listView.effectiveLayoutDirection == Qt.LeftToRight ? (index == 48 - 1) : (index == 0)) ? 40 : 50
|
||||
Rectangle {
|
||||
width: 40; height: 40
|
||||
color: Qt.rgba(0.5+(48 - index)*Math.random()/48,
|
||||
0.3+index*Math.random()/48,
|
||||
0.3*Math.random(),
|
||||
1.0)
|
||||
Text {
|
||||
text: index+1
|
||||
color: "white"
|
||||
font.pixelSize: 18
|
||||
anchors.centerIn: parent
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -93,18 +93,23 @@ Rectangle {
|
|||
width: 320
|
||||
height: 320
|
||||
id: editorTypeRow
|
||||
model: editorType.length
|
||||
model: root.editorType.length
|
||||
orientation: ListView.Horizontal
|
||||
cacheBuffer: 1000//Load the really expensive ones async if possible
|
||||
delegate: Item {
|
||||
id: delegate
|
||||
|
||||
width: editorColumn.width
|
||||
height: editorColumn.height
|
||||
|
||||
required property int index
|
||||
|
||||
Column {
|
||||
id: editorColumn
|
||||
spacing: 5
|
||||
width: textColumn.width+10
|
||||
Text {
|
||||
text: root.editorType[index]
|
||||
text: root.editorType[delegate.index]
|
||||
font.pixelSize: 16
|
||||
anchors.horizontalCenter: parent.horizontalCenter
|
||||
}
|
||||
|
@ -113,8 +118,8 @@ Rectangle {
|
|||
spacing: 5
|
||||
anchors.horizontalCenter: parent.horizontalCenter
|
||||
Repeater {
|
||||
model: textComponents.length
|
||||
delegate: textComponents[index]
|
||||
model: root.textComponents.length
|
||||
delegate: root.textComponents[delegate.index]
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -203,9 +208,11 @@ Rectangle {
|
|||
Component {
|
||||
id: plainTextComponent
|
||||
Text {
|
||||
required property int index
|
||||
|
||||
width: 180
|
||||
text: root.text[index]
|
||||
font.pixelSize: pxSz
|
||||
font.pixelSize: root.pxSz
|
||||
wrapMode: Text.WordWrap
|
||||
horizontalAlignment: root.horizontalAlignment
|
||||
LayoutMirroring.enabled: root.mirror
|
||||
|
@ -216,10 +223,10 @@ Rectangle {
|
|||
anchors.fill: parent
|
||||
}
|
||||
Text {
|
||||
text: root.description[index]
|
||||
text: root.description[parent.index]
|
||||
color: Qt.rgba(1,1,1,1.0)
|
||||
anchors.centerIn: parent
|
||||
font.pixelSize: pxSz - 2
|
||||
font.pixelSize: root.pxSz - 2
|
||||
Rectangle {
|
||||
z: -1
|
||||
color: Qt.rgba(0.3, 0, 0, 0.3)
|
||||
|
@ -228,7 +235,7 @@ Rectangle {
|
|||
}
|
||||
Text {
|
||||
color: "white"
|
||||
text: shortText(parent.horizontalAlignment)
|
||||
text: root.shortText(parent.horizontalAlignment)
|
||||
anchors { top: parent.top; right: parent.right; margins: 2 }
|
||||
}
|
||||
}
|
||||
|
@ -237,9 +244,11 @@ Rectangle {
|
|||
Component {
|
||||
id: styledTextComponent
|
||||
Text {
|
||||
required property int index
|
||||
|
||||
width: 180
|
||||
text: root.text[index]
|
||||
font.pixelSize: pxSz
|
||||
font.pixelSize: root.pxSz
|
||||
wrapMode: Text.WordWrap
|
||||
horizontalAlignment: root.horizontalAlignment
|
||||
LayoutMirroring.enabled: root.mirror
|
||||
|
@ -252,10 +261,10 @@ Rectangle {
|
|||
anchors.fill: parent
|
||||
}
|
||||
Text {
|
||||
text: root.description[index]
|
||||
text: root.description[parent.index]
|
||||
color: Qt.rgba(1,1,1,1.0)
|
||||
anchors.centerIn: parent
|
||||
font.pixelSize: pxSz - 2
|
||||
font.pixelSize: root.pxSz - 2
|
||||
Rectangle {
|
||||
z: -1
|
||||
color: Qt.rgba(0.3, 0, 0, 0.3)
|
||||
|
@ -264,7 +273,7 @@ Rectangle {
|
|||
}
|
||||
Text {
|
||||
color: "white"
|
||||
text: shortText(parent.horizontalAlignment)
|
||||
text: root.shortText(parent.horizontalAlignment)
|
||||
anchors { top: parent.top; right: parent.right; margins: 2 }
|
||||
}
|
||||
}
|
||||
|
@ -273,9 +282,11 @@ Rectangle {
|
|||
Component {
|
||||
id: richTextComponent
|
||||
Text {
|
||||
required property int index
|
||||
|
||||
width: 180
|
||||
text: root.text[index]
|
||||
font.pixelSize: pxSz
|
||||
font.pixelSize: root.pxSz
|
||||
wrapMode: Text.WordWrap
|
||||
horizontalAlignment: root.horizontalAlignment
|
||||
LayoutMirroring.enabled: root.mirror
|
||||
|
@ -286,10 +297,10 @@ Rectangle {
|
|||
anchors.fill: parent
|
||||
}
|
||||
Text {
|
||||
text: root.description[index]
|
||||
text: root.description[parent.index]
|
||||
color: Qt.rgba(1,1,1,1.0)
|
||||
anchors.centerIn: parent
|
||||
font.pixelSize: pxSz - 2
|
||||
font.pixelSize: root.pxSz - 2
|
||||
Rectangle {
|
||||
z: -1
|
||||
color: Qt.rgba(0.3, 0, 0, 0.3)
|
||||
|
@ -298,7 +309,7 @@ Rectangle {
|
|||
}
|
||||
Text {
|
||||
color: "white"
|
||||
text: shortText(parent.horizontalAlignment)
|
||||
text: root.shortText(parent.horizontalAlignment)
|
||||
anchors { top: parent.top; right: parent.right; margins: 2 }
|
||||
}
|
||||
}
|
||||
|
@ -307,9 +318,11 @@ Rectangle {
|
|||
Component {
|
||||
id: italicRichTextComponent
|
||||
Text {
|
||||
required property int index
|
||||
|
||||
width: 180
|
||||
text: "<i>" + root.text[index] + "</i>"
|
||||
font.pixelSize: pxSz
|
||||
font.pixelSize: root.pxSz
|
||||
wrapMode: Text.WordWrap
|
||||
horizontalAlignment: root.horizontalAlignment
|
||||
LayoutMirroring.enabled: root.mirror
|
||||
|
@ -321,10 +334,10 @@ Rectangle {
|
|||
anchors.fill: parent
|
||||
}
|
||||
Text {
|
||||
text: root.description[index]
|
||||
text: root.description[parent.index]
|
||||
color: Qt.rgba(1,1,1,1.0)
|
||||
anchors.centerIn: parent
|
||||
font.pixelSize: pxSz - 2
|
||||
font.pixelSize: root.pxSz - 2
|
||||
Rectangle {
|
||||
z: -1
|
||||
color: Qt.rgba(0.3, 0, 0, 0.3)
|
||||
|
@ -333,7 +346,7 @@ Rectangle {
|
|||
}
|
||||
Text {
|
||||
color: "white"
|
||||
text: shortText(parent.horizontalAlignment)
|
||||
text: root.shortText(parent.horizontalAlignment)
|
||||
anchors { top: parent.top; right: parent.right; margins: 2 }
|
||||
}
|
||||
}
|
||||
|
@ -342,9 +355,11 @@ Rectangle {
|
|||
Component {
|
||||
id: plainTextEdit
|
||||
TextEdit {
|
||||
required property int index
|
||||
|
||||
width: 180
|
||||
text: root.text[index]
|
||||
font.pixelSize: pxSz
|
||||
font.pixelSize: root.pxSz
|
||||
cursorVisible: true
|
||||
wrapMode: TextEdit.WordWrap
|
||||
horizontalAlignment: root.horizontalAlignment
|
||||
|
@ -355,10 +370,10 @@ Rectangle {
|
|||
anchors.fill: parent
|
||||
}
|
||||
Text {
|
||||
text: root.description[index]
|
||||
text: root.description[parent.index]
|
||||
color: Qt.rgba(1,1,1,1.0)
|
||||
anchors.centerIn: parent
|
||||
font.pixelSize: pxSz - 2
|
||||
font.pixelSize: root.pxSz - 2
|
||||
Rectangle {
|
||||
z: -1
|
||||
color: Qt.rgba(0.3, 0, 0, 0.3)
|
||||
|
@ -367,7 +382,7 @@ Rectangle {
|
|||
}
|
||||
Text {
|
||||
color: "white"
|
||||
text: shortText(parent.horizontalAlignment)
|
||||
text: root.shortText(parent.horizontalAlignment)
|
||||
anchors { top: parent.top; right: parent.right; margins: 2 }
|
||||
}
|
||||
}
|
||||
|
@ -376,9 +391,11 @@ Rectangle {
|
|||
Component {
|
||||
id: italicTextEdit
|
||||
TextEdit {
|
||||
required property int index
|
||||
|
||||
width: 180
|
||||
text: "<i>" + root.text[index] + "<i>"
|
||||
font.pixelSize: pxSz
|
||||
font.pixelSize: root.pxSz
|
||||
cursorVisible: true
|
||||
wrapMode: TextEdit.WordWrap
|
||||
textFormat: TextEdit.RichText
|
||||
|
@ -390,10 +407,10 @@ Rectangle {
|
|||
anchors.fill: parent
|
||||
}
|
||||
Text {
|
||||
text: root.description[index]
|
||||
text: root.description[parent.index]
|
||||
color: Qt.rgba(1,1,1,1.0)
|
||||
anchors.centerIn: parent
|
||||
font.pixelSize: pxSz - 2
|
||||
font.pixelSize: root.pxSz - 2
|
||||
Rectangle {
|
||||
z: -1
|
||||
color: Qt.rgba(0.3, 0, 0, 0.3)
|
||||
|
@ -402,7 +419,7 @@ Rectangle {
|
|||
}
|
||||
Text {
|
||||
color: "white"
|
||||
text: shortText(parent.horizontalAlignment)
|
||||
text: root.shortText(parent.horizontalAlignment)
|
||||
anchors { top: parent.top; right: parent.right; margins: 2 }
|
||||
}
|
||||
}
|
||||
|
@ -411,13 +428,15 @@ Rectangle {
|
|||
Component {
|
||||
id: textInput
|
||||
Item {
|
||||
id: textDelegate
|
||||
required property int index
|
||||
width: 180
|
||||
height: textInput.text.length > 20 ? 3*textInput.height : textInput.height
|
||||
TextInput {
|
||||
id: textInput
|
||||
width: 180
|
||||
text: root.text[index]
|
||||
font.pixelSize: pxSz
|
||||
text: root.text[textDelegate.index]
|
||||
font.pixelSize: root.pxSz
|
||||
cursorVisible: true
|
||||
horizontalAlignment: root.horizontalAlignment
|
||||
LayoutMirroring.enabled: root.mirror
|
||||
|
@ -427,10 +446,10 @@ Rectangle {
|
|||
anchors.fill: parent
|
||||
}
|
||||
Text {
|
||||
text: root.description[index]
|
||||
text: root.description[textDelegate.index]
|
||||
color: Qt.rgba(1,1,1,1.0)
|
||||
anchors.centerIn: parent
|
||||
font.pixelSize: pxSz - 2
|
||||
font.pixelSize: root.pxSz - 2
|
||||
Rectangle {
|
||||
z: -1
|
||||
color: Qt.rgba(0.3, 0, 0, 0.3)
|
||||
|
@ -439,7 +458,7 @@ Rectangle {
|
|||
}
|
||||
Text {
|
||||
color: "white"
|
||||
text: shortText(parent.horizontalAlignment)
|
||||
text: root.shortText(parent.horizontalAlignment)
|
||||
anchors { top: parent.top; right: parent.right; margins: 2 }
|
||||
}
|
||||
}
|
||||
|
|
|
@ -50,14 +50,10 @@
|
|||
|
||||
#include <QGuiApplication>
|
||||
#include <QtQuick/QQuickView>
|
||||
#include "metaltextureimport.h"
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
QGuiApplication app(argc, argv);
|
||||
|
||||
qmlRegisterType<CustomTextureItem>("MetalTextureImport", 1, 0, "CustomTextureItem");
|
||||
|
||||
QQuickWindow::setSceneGraphBackend(QSGRendererInterface::MetalRhi);
|
||||
|
||||
QQuickView view;
|
||||
|
|
|
@ -60,6 +60,7 @@ class CustomTextureItem : public QQuickItem
|
|||
{
|
||||
Q_OBJECT
|
||||
Q_PROPERTY(qreal t READ t WRITE setT NOTIFY tChanged)
|
||||
QML_ELEMENT
|
||||
|
||||
public:
|
||||
CustomTextureItem();
|
||||
|
|
|
@ -1,6 +1,9 @@
|
|||
!macos:!ios: error("This example requires macOS or iOS")
|
||||
|
||||
QT += qml quick
|
||||
CONFIG += qmltypes
|
||||
QML_IMPORT_NAME = MetalTextureImport
|
||||
QML_IMPORT_MAJOR_VERSION = 1
|
||||
|
||||
HEADERS += metaltextureimport.h
|
||||
SOURCES += metaltextureimport.mm main.cpp
|
||||
|
|
|
@ -66,7 +66,7 @@ Item {
|
|||
MouseArea {
|
||||
anchors.fill: parent
|
||||
acceptedButtons: Qt.LeftButton | Qt.RightButton
|
||||
onClicked: {
|
||||
onClicked: (mouse) => {
|
||||
if (mouse.button === Qt.LeftButton) {
|
||||
clipper.clip = !clipper.clip
|
||||
} else if (mouse.button === Qt.RightButton) {
|
||||
|
|
|
@ -50,14 +50,11 @@
|
|||
|
||||
#include <QGuiApplication>
|
||||
#include <QtQuick/QQuickView>
|
||||
#include "vulkantextureimport.h"
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
QGuiApplication app(argc, argv);
|
||||
|
||||
qmlRegisterType<CustomTextureItem>("VulkanTextureImport", 1, 0, "CustomTextureItem");
|
||||
|
||||
QQuickWindow::setSceneGraphBackend(QSGRendererInterface::VulkanRhi);
|
||||
|
||||
QQuickView view;
|
||||
|
|
|
@ -60,6 +60,7 @@ class CustomTextureItem : public QQuickItem
|
|||
{
|
||||
Q_OBJECT
|
||||
Q_PROPERTY(qreal t READ t WRITE setT NOTIFY tChanged)
|
||||
QML_ELEMENT
|
||||
|
||||
public:
|
||||
CustomTextureItem();
|
||||
|
|
|
@ -1,12 +1,13 @@
|
|||
!qtConfig(vulkan): error("This example requires Qt built with Vulkan support")
|
||||
|
||||
QT += qml quick
|
||||
CONFIG += qmltypes
|
||||
QML_IMPORT_NAME = VulkanTextureImport
|
||||
QML_IMPORT_MAJOR_VERSION = 1
|
||||
|
||||
HEADERS += vulkantextureimport.h
|
||||
SOURCES += vulkantextureimport.cpp main.cpp
|
||||
RESOURCES += vulkantextureimport.qrc
|
||||
|
||||
|
||||
|
||||
target.path = $$[QT_INSTALL_EXAMPLES]/quick/scenegraph/vulkantextureimport
|
||||
INSTALLS += target
|
||||
|
|
|
@ -50,14 +50,11 @@
|
|||
|
||||
#include <QGuiApplication>
|
||||
#include <QtQuick/QQuickView>
|
||||
#include "vulkansquircle.h"
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
QGuiApplication app(argc, argv);
|
||||
|
||||
qmlRegisterType<VulkanSquircle>("VulkanUnderQML", 1, 0, "VulkanSquircle");
|
||||
|
||||
// This example needs Vulkan. It will not run otherwise.
|
||||
QQuickWindow::setSceneGraphBackend(QSGRendererInterface::VulkanRhi);
|
||||
|
||||
|
|
|
@ -59,6 +59,7 @@ class VulkanSquircle : public QQuickItem
|
|||
{
|
||||
Q_OBJECT
|
||||
Q_PROPERTY(qreal t READ t WRITE setT NOTIFY tChanged)
|
||||
QML_ELEMENT
|
||||
|
||||
public:
|
||||
VulkanSquircle();
|
||||
|
|
|
@ -1,6 +1,9 @@
|
|||
!qtConfig(vulkan): error("This example requires Qt built with Vulkan support")
|
||||
|
||||
QT += qml quick
|
||||
CONFIG += qmltypes
|
||||
QML_IMPORT_NAME = VulkanUnderQML
|
||||
QML_IMPORT_MAJOR_VERSION = 1
|
||||
|
||||
HEADERS += vulkansquircle.h
|
||||
SOURCES += vulkansquircle.cpp main.cpp
|
||||
|
|
|
@ -72,7 +72,7 @@ ListModel {
|
|||
var jsonText = xhr.responseText;
|
||||
var objArray = JSON.parse(jsonText.replace(/\'/g,"'"))
|
||||
if (objArray.errors !== undefined)
|
||||
console.log(lCategory, "Error fetching tweets: " + imageItems.errors[0].message)
|
||||
console.log("Error fetching tweets: " + objArray.errors[0].message)
|
||||
else {
|
||||
for (var key in objArray.items) {
|
||||
var rssItem = objArray.items[key];
|
||||
|
|
|
@ -48,6 +48,9 @@
|
|||
** $QT_END_LICENSE$
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
import QtQml 2.12
|
||||
import QtQml.Models 2.12
|
||||
import QtQuick 2.12
|
||||
|
||||
Rectangle {
|
||||
|
|
|
@ -58,6 +58,9 @@ Rectangle {
|
|||
width: ListView.view.width
|
||||
height: button.implicitHeight + 22
|
||||
|
||||
required property string name
|
||||
required property string description
|
||||
|
||||
signal clicked()
|
||||
|
||||
gradient: Gradient {
|
||||
|
|
|
@ -78,6 +78,7 @@ Item {
|
|||
Repeater {
|
||||
model: stack.children.length
|
||||
delegate: Rectangle {
|
||||
required property int index
|
||||
width: tabWidget.width / stack.children.length
|
||||
height: Math.max(Screen.pixelDensity * 7, label.implicitHeight * 1.2)
|
||||
|
||||
|
@ -90,18 +91,18 @@ Item {
|
|||
anchors { fill: parent; leftMargin: 2; topMargin: 5; rightMargin: 1 }
|
||||
border { left: 7; right: 7 }
|
||||
source: "images/tab.png"
|
||||
visible: tabWidget.current == index
|
||||
visible: tabWidget.current == parent.index
|
||||
}
|
||||
Text {
|
||||
id: label
|
||||
horizontalAlignment: Qt.AlignHCenter; verticalAlignment: Qt.AlignVCenter
|
||||
anchors.fill: parent
|
||||
text: stack.children[index].title
|
||||
text: stack.children[parent.index].title
|
||||
elide: Text.ElideRight
|
||||
font.bold: tabWidget.current == index
|
||||
font.bold: tabWidget.current == parent.index
|
||||
}
|
||||
TapHandler {
|
||||
onTapped: tabWidget.current = index
|
||||
onTapped: tabWidget.current = parent.index
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -48,6 +48,7 @@
|
|||
**
|
||||
****************************************************************************/
|
||||
|
||||
import QtQml 2.12
|
||||
import QtQuick 2.12
|
||||
import QtQuick.Window 2.3
|
||||
import QtQuick.Controls 2.2
|
||||
|
@ -81,11 +82,14 @@ ApplicationWindow {
|
|||
implicitWidth: 15
|
||||
implicitHeight: 15
|
||||
|
||||
color: model.value ? "#f3f3f4" : "#b5b7bf"
|
||||
required property var model
|
||||
required property bool value
|
||||
|
||||
color: value ? "#f3f3f4" : "#b5b7bf"
|
||||
|
||||
MouseArea {
|
||||
anchors.fill: parent
|
||||
onClicked: model.value = !model.value
|
||||
onClicked: parent.model.value = !parent.value
|
||||
}
|
||||
}
|
||||
//! [tableview]
|
||||
|
|
|
@ -65,7 +65,9 @@ Window {
|
|||
id: pixelDelegate
|
||||
|
||||
Item {
|
||||
readonly property real gray: model.display / 255.0
|
||||
required property real display
|
||||
|
||||
readonly property real gray: display / 255.0
|
||||
readonly property real size: 16
|
||||
|
||||
implicitWidth: size
|
||||
|
@ -77,7 +79,7 @@ Window {
|
|||
id: rect
|
||||
anchors.centerIn: parent
|
||||
color: "#09102b"
|
||||
radius: size - gray * size
|
||||
radius: parent.size - parent.gray * parent.size
|
||||
implicitWidth: radius
|
||||
implicitHeight: radius
|
||||
//! [rectshape]
|
||||
|
|
|
@ -61,11 +61,12 @@ Rectangle {
|
|||
|
||||
delegate: Item {
|
||||
height: 40; width: ListView.view.width
|
||||
required property string modelData
|
||||
Text {
|
||||
anchors.centerIn: parent
|
||||
text: modelData
|
||||
text: parent.modelData
|
||||
//! [delegate]
|
||||
font.family: modelData
|
||||
font.family: parent.modelData
|
||||
//! [delegate]
|
||||
font.pixelSize: 20
|
||||
color: "white"
|
||||
|
|
|
@ -51,6 +51,7 @@
|
|||
import QtQuick 2.0
|
||||
|
||||
Rectangle {
|
||||
id: root
|
||||
property string myText: "The quick brown fox jumps over the lazy dog."
|
||||
|
||||
width: 320; height: 480
|
||||
|
@ -68,7 +69,7 @@ Rectangle {
|
|||
spacing: 15
|
||||
|
||||
Text {
|
||||
text: myText
|
||||
text: root.myText
|
||||
color: "lightsteelblue"
|
||||
width: parent.width
|
||||
wrapMode: Text.WordWrap
|
||||
|
@ -78,7 +79,7 @@ Rectangle {
|
|||
font.pixelSize: 20
|
||||
}
|
||||
Text {
|
||||
text: myText
|
||||
text: root.myText
|
||||
color: "lightsteelblue"
|
||||
width: parent.width
|
||||
wrapMode: Text.WordWrap
|
||||
|
@ -86,7 +87,7 @@ Rectangle {
|
|||
font { family: "Times"; pixelSize: 20; capitalization: Font.AllUppercase }
|
||||
}
|
||||
Text {
|
||||
text: myText
|
||||
text: root.myText
|
||||
color: "lightsteelblue"
|
||||
width: parent.width
|
||||
horizontalAlignment: Text.AlignRight
|
||||
|
@ -94,14 +95,14 @@ Rectangle {
|
|||
font { family: "Courier"; pixelSize: 20; weight: Font.Bold; capitalization: Font.AllLowercase }
|
||||
}
|
||||
Text {
|
||||
text: myText
|
||||
text: root.myText
|
||||
color: "lightsteelblue"
|
||||
width: parent.width
|
||||
wrapMode: Text.WordWrap
|
||||
font { family: "Courier"; pixelSize: 20; italic: true; capitalization: Font.SmallCaps }
|
||||
}
|
||||
Text {
|
||||
text: myText
|
||||
text: root.myText
|
||||
color: "lightsteelblue"
|
||||
width: parent.width
|
||||
wrapMode: Text.WordWrap
|
||||
|
@ -109,7 +110,7 @@ Rectangle {
|
|||
}
|
||||
Text {
|
||||
text: {
|
||||
if (webFont.status == FontLoader.Ready) myText
|
||||
if (webFont.status == FontLoader.Ready) root.myText
|
||||
else if (webFont.status == FontLoader.Loading) "Loading..."
|
||||
else if (webFont.status == FontLoader.Error) "Error loading font"
|
||||
}
|
||||
|
|
|
@ -55,5 +55,5 @@ Text {
|
|||
font.pointSize: 14
|
||||
wrapMode: Text.WordWrap
|
||||
textFormat: Text.StyledText
|
||||
horizontalAlignment: main.hAlign
|
||||
horizontalAlignment: parent.hAlign
|
||||
}
|
||||
|
|
|
@ -56,7 +56,7 @@ Rectangle {
|
|||
focus: true
|
||||
color: "#dedede"
|
||||
|
||||
property var hAlign: Text.AlignLeft
|
||||
property int hAlign: Text.AlignLeft
|
||||
|
||||
Flickable {
|
||||
anchors.fill: parent
|
||||
|
@ -68,6 +68,7 @@ Rectangle {
|
|||
x: 10; y: 10
|
||||
spacing: 20
|
||||
width: parent.width - 20
|
||||
property int hAlign: main.hAlign
|
||||
|
||||
TextWithImage {
|
||||
text: "This is a <b>happy</b> face<img src=\"images/face-smile.png\">"
|
||||
|
|
|
@ -71,12 +71,12 @@ Rectangle {
|
|||
text: "Lorem ipsum dolor sit amet, consectetur adipiscing elit. Integer at ante dui <a href=\"http://www.digia.com\">www.digia.com</a>.<br/>Curabitur ante est, pulvinar quis adipiscing a, iaculis id ipsum. Nunc blandit condimentum odio vel egestas.<br><ul type=\"bullet\"><li>Coffee<ol type=\"a\"><li>Espresso<li>Cappuccino<li>Latte</ol><li>Juice<ol type=\"1\"><li>Orange</li><li>Apple</li><li>Pineapple</li><li>Tomato</li></ol></li></ul><p><font color=\"#434343\"><i>Proin consectetur <b>sapien</b> in ipsum lacinia sit amet mattis orci interdum. Quisque vitae accumsan lectus. Ut nisi turpis, sollicitudin ut dignissim id, fermentum ac est. Maecenas nec libero leo. Sed ac leo eget ipsum ultricies viverra sit amet eu orci. Praesent et tortor risus, viverra accumsan sapien. Sed faucibus eleifend lectus, sed euismod urna porta eu. Quisque vitae accumsan lectus. Ut nisi turpis, sollicitudin ut dignissim id, fermentum ac est. Maecenas nec libero leo. Sed ac leo eget ipsum ultricies viverra sit amet eu orci."
|
||||
|
||||
//! [layout]
|
||||
onLineLaidOut: {
|
||||
line.width = width / 2 - (margin)
|
||||
onLineLaidOut: (line) => {
|
||||
line.width = width / 2 - main.margin
|
||||
|
||||
if (line.y + line.height >= height) {
|
||||
line.y -= height - margin
|
||||
line.x = width / 2 + margin
|
||||
line.y -= height - main.margin
|
||||
line.x = width / 2 + main.activeFocusmargin
|
||||
}
|
||||
|
||||
if (line.isLast) {
|
||||
|
|
|
@ -59,7 +59,10 @@ Rectangle {
|
|||
anchors.fill: parent
|
||||
model: listModel
|
||||
delegate: Component {
|
||||
Text { text: time }
|
||||
Text {
|
||||
required property string time
|
||||
text: time
|
||||
}
|
||||
}
|
||||
|
||||
ListModel { id: listModel }
|
||||
|
|
|
@ -78,6 +78,7 @@ Rectangle {
|
|||
clip: true
|
||||
model: 64
|
||||
delegate: Text {
|
||||
required property int index
|
||||
font.pixelSize: 18;
|
||||
color: "white";
|
||||
text: index;
|
||||
|
|
|
@ -58,7 +58,7 @@ Rectangle {
|
|||
id: myWorker
|
||||
source: "workerscript.mjs"
|
||||
|
||||
onMessage: {
|
||||
onMessage: (messageObject) => {
|
||||
if (messageObject.row == rowSpinner.value && messageObject.column == columnSpinner.value){ //Not an old result
|
||||
if (messageObject.result == -1)
|
||||
resultText.text = "Column must be <= Row";
|
||||
|
|
|
@ -50,112 +50,106 @@
|
|||
|
||||
import QtQuick 2.0
|
||||
|
||||
Component {
|
||||
Item {
|
||||
property variant stickies
|
||||
Item {
|
||||
required property string name
|
||||
required property var notes
|
||||
|
||||
id: page
|
||||
width: ListView.view.width+40; height: ListView.view.height
|
||||
property real horizontalVelocity: 0
|
||||
|
||||
id: page
|
||||
width: ListView.view.width+40; height: ListView.view.height
|
||||
|
||||
|
||||
Image {
|
||||
source: "cork.jpg"
|
||||
width: page.ListView.view.width
|
||||
height: page.ListView.view.height
|
||||
fillMode: Image.PreserveAspectCrop
|
||||
clip: true
|
||||
}
|
||||
Image {
|
||||
source: "cork.jpg"
|
||||
width: page.ListView.view.width
|
||||
height: page.ListView.view.height
|
||||
fillMode: Image.PreserveAspectCrop
|
||||
clip: true
|
||||
}
|
||||
|
||||
MouseArea {
|
||||
anchors.fill: parent
|
||||
onClicked: page.focus = false;
|
||||
}
|
||||
MouseArea {
|
||||
anchors.fill: parent
|
||||
onClicked: page.focus = false;
|
||||
}
|
||||
|
||||
Text {
|
||||
text: name; x: 15; y: 8; height: 40; width: 370
|
||||
font.pixelSize: 18; font.bold: true; color: "white"
|
||||
style: Text.Outline; styleColor: "black"
|
||||
}
|
||||
Text {
|
||||
text: page.name; x: 15; y: 8; height: 40; width: 370
|
||||
font.pixelSize: 18; font.bold: true; color: "white"
|
||||
style: Text.Outline; styleColor: "black"
|
||||
}
|
||||
|
||||
Repeater {
|
||||
model: page.notes
|
||||
Item {
|
||||
id: stickyPage
|
||||
required property string noteText
|
||||
|
||||
property int randomX: Math.random() * (page.ListView.view.width-0.5*stickyImage.width) +100
|
||||
property int randomY: Math.random() * (page.ListView.view.height-0.5*stickyImage.height) +50
|
||||
|
||||
x: randomX; y: randomY
|
||||
|
||||
rotation: -page.horizontalVelocity / 100
|
||||
Behavior on rotation {
|
||||
SpringAnimation { spring: 2.0; damping: 0.15 }
|
||||
}
|
||||
|
||||
Repeater {
|
||||
model: notes
|
||||
Item {
|
||||
id: stickyPage
|
||||
id: sticky
|
||||
scale: 0.7
|
||||
|
||||
property int randomX: Math.random() * (page.ListView.view.width-0.5*stickyImage.width) +100
|
||||
property int randomY: Math.random() * (page.ListView.view.height-0.5*stickyImage.height) +50
|
||||
Image {
|
||||
id: stickyImage
|
||||
x: 8 + -width * 0.6 / 2; y: -20
|
||||
source: "note-yellow.png"
|
||||
scale: 0.6; transformOrigin: Item.TopLeft
|
||||
}
|
||||
|
||||
x: randomX; y: randomY
|
||||
|
||||
rotation: -flickable.horizontalVelocity / 100;
|
||||
Behavior on rotation {
|
||||
SpringAnimation { spring: 2.0; damping: 0.15 }
|
||||
TextEdit {
|
||||
id: myText
|
||||
x: -104; y: 36; width: 215; height: 200
|
||||
font.pixelSize: 24
|
||||
readOnly: false
|
||||
rotation: -8
|
||||
text: stickyPage.noteText
|
||||
}
|
||||
|
||||
Item {
|
||||
id: sticky
|
||||
scale: 0.7
|
||||
x: stickyImage.x; y: -20
|
||||
width: stickyImage.width * stickyImage.scale
|
||||
height: stickyImage.height * stickyImage.scale
|
||||
|
||||
Image {
|
||||
id: stickyImage
|
||||
x: 8 + -width * 0.6 / 2; y: -20
|
||||
source: "note-yellow.png"
|
||||
scale: 0.6; transformOrigin: Item.TopLeft
|
||||
}
|
||||
|
||||
TextEdit {
|
||||
id: myText
|
||||
x: -104; y: 36; width: 215; height: 200
|
||||
font.pixelSize: 24
|
||||
readOnly: false
|
||||
rotation: -8
|
||||
text: noteText
|
||||
}
|
||||
|
||||
Item {
|
||||
x: stickyImage.x; y: -20
|
||||
width: stickyImage.width * stickyImage.scale
|
||||
height: stickyImage.height * stickyImage.scale
|
||||
|
||||
MouseArea {
|
||||
id: mouse
|
||||
anchors.fill: parent
|
||||
drag.target: stickyPage
|
||||
drag.axis: Drag.XAndYAxis
|
||||
drag.minimumY: 0
|
||||
drag.maximumY: page.height - 80
|
||||
drag.minimumX: 100
|
||||
drag.maximumX: page.width - 140
|
||||
onClicked: myText.forceActiveFocus()
|
||||
}
|
||||
MouseArea {
|
||||
id: mouse
|
||||
anchors.fill: parent
|
||||
drag.target: stickyPage
|
||||
drag.axis: Drag.XAndYAxis
|
||||
drag.minimumY: 0
|
||||
drag.maximumY: page.height - 80
|
||||
drag.minimumX: 100
|
||||
drag.maximumX: page.width - 140
|
||||
onClicked: myText.forceActiveFocus()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Image {
|
||||
x: -width / 2; y: -height * 0.5 / 2
|
||||
source: "tack.png"
|
||||
scale: 0.7; transformOrigin: Item.TopLeft
|
||||
}
|
||||
Image {
|
||||
x: -width / 2; y: -height * 0.5 / 2
|
||||
source: "tack.png"
|
||||
scale: 0.7; transformOrigin: Item.TopLeft
|
||||
}
|
||||
|
||||
states: State {
|
||||
name: "pressed"
|
||||
when: mouse.pressed
|
||||
PropertyChanges { target: sticky; rotation: 8; scale: 1 }
|
||||
PropertyChanges { target: page; z: 8 }
|
||||
}
|
||||
states: State {
|
||||
name: "pressed"
|
||||
when: mouse.pressed
|
||||
PropertyChanges { target: sticky; rotation: 8; scale: 1 }
|
||||
PropertyChanges { target: page; z: 8 }
|
||||
}
|
||||
|
||||
transitions: Transition {
|
||||
NumberAnimation { properties: "rotation,scale"; duration: 200 }
|
||||
}
|
||||
transitions: Transition {
|
||||
NumberAnimation { properties: "rotation,scale"; duration: 200 }
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
|
|
@ -92,6 +92,8 @@ Rectangle {
|
|||
orientation: ListView.Horizontal
|
||||
snapMode: ListView.SnapOneItem
|
||||
model: list
|
||||
delegate: Panel { }
|
||||
delegate: Panel {
|
||||
horizontalVelocity: flickable.horizontalVelocity
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -66,7 +66,7 @@ TouchPoint {
|
|||
interval: 100
|
||||
running: false
|
||||
repeat: false
|
||||
onTriggered: child.enabled = false
|
||||
onTriggered: container.child.enabled = false
|
||||
}
|
||||
property Item child: SpriteGoal {
|
||||
enabled: false
|
||||
|
|
|
@ -48,6 +48,7 @@
|
|||
**
|
||||
****************************************************************************/
|
||||
|
||||
import QtQml 2.0
|
||||
import QtQuick 2.0
|
||||
import QtQml.Models 2.1
|
||||
|
||||
|
@ -64,6 +65,8 @@ Item {
|
|||
Package {
|
||||
id: packageRoot
|
||||
|
||||
required property var modelData
|
||||
|
||||
MouseArea {
|
||||
id: visibleContainer
|
||||
Package.name: "visible"
|
||||
|
@ -130,7 +133,7 @@ Item {
|
|||
horizontalAlignment: Text.AlignHCenter
|
||||
verticalAlignment: Text.AlignVCenter
|
||||
color: "white"
|
||||
text: modelData
|
||||
text: packageRoot.modelData
|
||||
font.pixelSize: 18
|
||||
}
|
||||
|
||||
|
|
|
@ -74,6 +74,8 @@ Rectangle {
|
|||
|
||||
width: 76; height: 76
|
||||
|
||||
required property string thumbnail
|
||||
|
||||
Rectangle {
|
||||
id: image
|
||||
x: 0; y: 0; width: 76; height: 76
|
||||
|
@ -86,7 +88,7 @@ Rectangle {
|
|||
anchors.leftMargin: 1
|
||||
anchors.topMargin: 1
|
||||
|
||||
source: thumbnail
|
||||
source: delegateItem.thumbnail
|
||||
fillMode: Image.PreserveAspectFit
|
||||
}
|
||||
|
||||
|
|
|
@ -74,20 +74,24 @@ Rectangle {
|
|||
highlight: Rectangle { width: 80; height: 80; color: "lightsteelblue" }
|
||||
|
||||
delegate: Item {
|
||||
required property string icon
|
||||
required property string name
|
||||
required property int index
|
||||
|
||||
width: 100; height: 100
|
||||
|
||||
Image {
|
||||
id: myIcon
|
||||
y: 20; anchors.horizontalCenter: parent.horizontalCenter
|
||||
source: icon
|
||||
source: parent.icon
|
||||
}
|
||||
Text {
|
||||
anchors { top: myIcon.bottom; horizontalCenter: parent.horizontalCenter }
|
||||
text: name
|
||||
text: parent.name
|
||||
}
|
||||
MouseArea {
|
||||
anchors.fill: parent
|
||||
onClicked: parent.GridView.view.currentIndex = index
|
||||
onClicked: parent.GridView.view.currentIndex = parent.index
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -72,12 +72,12 @@ Image {
|
|||
|
||||
PropertyAction { target: container; property: "pressed"; value: true }
|
||||
ScriptAction { script: container.clicked() }
|
||||
PauseAnimation { duration: repeatDelay }
|
||||
PauseAnimation { duration: container.repeatDelay }
|
||||
|
||||
SequentialAnimation {
|
||||
loops: Animation.Infinite
|
||||
ScriptAction { script: container.clicked() }
|
||||
PauseAnimation { duration: repeatDuration }
|
||||
PauseAnimation { duration: container.repeatDuration }
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -63,6 +63,6 @@ Rectangle {
|
|||
Text { id: text; anchors.centerIn: parent; font.pixelSize: 14 }
|
||||
MouseArea {
|
||||
anchors.fill: parent
|
||||
onClicked: { active = !active; root.toggled() }
|
||||
onClicked: { root.active = !root.active; root.toggled() }
|
||||
}
|
||||
}
|
||||
|
|
|
@ -68,10 +68,13 @@ Item {
|
|||
width: parent.width
|
||||
height: 25
|
||||
color: index % 2 ? "steelblue" : "lightsteelblue"
|
||||
|
||||
required property int index
|
||||
|
||||
Text {
|
||||
anchors.centerIn: parent
|
||||
color: "white"
|
||||
text: "Item " + (index + 1)
|
||||
text: "Item " + (parent.index + 1)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -101,6 +101,11 @@ Rectangle {
|
|||
width: listView.width; height: 80
|
||||
clip: true
|
||||
|
||||
required property int index
|
||||
required property string name
|
||||
required property real cost
|
||||
required property var attributes
|
||||
|
||||
Column {
|
||||
id: arrows
|
||||
anchors {
|
||||
|
@ -109,10 +114,16 @@ Rectangle {
|
|||
}
|
||||
Image {
|
||||
source: "content/pics/arrow-up.png"
|
||||
MouseArea { anchors.fill: parent; onClicked: fruitModel.move(index, index-1, 1) }
|
||||
MouseArea {
|
||||
anchors.fill: parent
|
||||
onClicked: fruitModel.move(delegateItem.index, delegateItem.index - 1, 1)
|
||||
}
|
||||
}
|
||||
Image { source: "content/pics/arrow-down.png"
|
||||
MouseArea { anchors.fill: parent; onClicked: fruitModel.move(index, index+1, 1) }
|
||||
MouseArea {
|
||||
anchors.fill: parent
|
||||
onClicked: fruitModel.move(delegateItem.index, delegateItem.index + 1, 1)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -125,7 +136,7 @@ Rectangle {
|
|||
|
||||
Text {
|
||||
anchors.horizontalCenter: parent.horizontalCenter
|
||||
text: name
|
||||
text: delegateItem.name
|
||||
font.pixelSize: 15
|
||||
color: "white"
|
||||
}
|
||||
|
@ -133,8 +144,12 @@ Rectangle {
|
|||
anchors.horizontalCenter: parent.horizontalCenter
|
||||
spacing: 5
|
||||
Repeater {
|
||||
model: attributes
|
||||
Text { text: description; color: "White" }
|
||||
model: delegateItem.attributes
|
||||
Text {
|
||||
required property string description
|
||||
text: description
|
||||
color: "White"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -154,13 +169,13 @@ Rectangle {
|
|||
PressAndHoldButton {
|
||||
anchors.verticalCenter: parent.verticalCenter
|
||||
source: "content/pics/plus-sign.png"
|
||||
onClicked: fruitModel.setProperty(index, "cost", cost + 0.25)
|
||||
onClicked: fruitModel.setProperty(delegateItem.index, "cost", delegateItem.cost + 0.25)
|
||||
}
|
||||
|
||||
Text {
|
||||
id: costText
|
||||
anchors.verticalCenter: parent.verticalCenter
|
||||
text: '$' + Number(cost).toFixed(2)
|
||||
text: '$' + Number(delegateItem.cost).toFixed(2)
|
||||
font.pixelSize: 15
|
||||
color: "white"
|
||||
font.bold: true
|
||||
|
@ -169,12 +184,16 @@ Rectangle {
|
|||
PressAndHoldButton {
|
||||
anchors.verticalCenter: parent.verticalCenter
|
||||
source: "content/pics/minus-sign.png"
|
||||
onClicked: fruitModel.setProperty(index, "cost", Math.max(0,cost-0.25))
|
||||
onClicked: fruitModel.setProperty(delegateItem.index, "cost",
|
||||
Math.max(0, delegateItem.cost - 0.25))
|
||||
}
|
||||
|
||||
Image {
|
||||
source: "content/pics/list-delete.png"
|
||||
MouseArea { anchors.fill:parent; onClicked: fruitModel.remove(index) }
|
||||
MouseArea {
|
||||
anchors.fill: parent
|
||||
onClicked: fruitModel.remove(delegateItem.index)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -67,6 +67,11 @@ Rectangle {
|
|||
Item {
|
||||
id: recipe
|
||||
|
||||
required property string title
|
||||
required property string picture
|
||||
required property string ingredients
|
||||
required property string method
|
||||
|
||||
// Create a property to contain the visibility of the details.
|
||||
// We can bind multiple element's opacity to this one property,
|
||||
// rather than having a "PropertyChanges" line for each element we
|
||||
|
@ -106,7 +111,7 @@ Rectangle {
|
|||
Image {
|
||||
id: recipeImage
|
||||
width: 50; height: 50
|
||||
source: picture
|
||||
source: recipe.picture
|
||||
}
|
||||
//! [1]
|
||||
Column {
|
||||
|
@ -114,7 +119,7 @@ Rectangle {
|
|||
spacing: 5
|
||||
|
||||
Text {
|
||||
text: title
|
||||
text: recipe.title
|
||||
font.bold: true; font.pointSize: 16
|
||||
}
|
||||
|
||||
|
@ -125,7 +130,7 @@ Rectangle {
|
|||
}
|
||||
|
||||
SmallText {
|
||||
text: ingredients
|
||||
text: recipe.ingredients
|
||||
wrapMode: Text.WordWrap
|
||||
width: parent.width
|
||||
opacity: recipe.detailsOpacity
|
||||
|
@ -155,7 +160,12 @@ Rectangle {
|
|||
contentHeight: methodText.height
|
||||
clip: true
|
||||
|
||||
Text { id: methodText; text: method; wrapMode: Text.WordWrap; width: details.width }
|
||||
Text {
|
||||
id: methodText
|
||||
text: recipe.method
|
||||
wrapMode: Text.WordWrap
|
||||
width: details.width
|
||||
}
|
||||
}
|
||||
|
||||
Image {
|
||||
|
|
|
@ -58,44 +58,44 @@ import "content"
|
|||
Rectangle {
|
||||
width: 200; height: 300
|
||||
|
||||
// Define a delegate component. A component will be
|
||||
// Define a delegate component. The component will be
|
||||
// instantiated for each visible item in the list.
|
||||
Component {
|
||||
id: petDelegate
|
||||
Item {
|
||||
id: wrapper
|
||||
width: 200; height: 55
|
||||
Column {
|
||||
SmallText { text: 'Name: ' + name }
|
||||
SmallText { text: 'Type: ' + type }
|
||||
SmallText { text: 'Age: ' + age }
|
||||
}
|
||||
// indent the item if it is the current item
|
||||
states: State {
|
||||
name: "Current"
|
||||
when: wrapper.ListView.isCurrentItem
|
||||
PropertyChanges { target: wrapper; x: 20 }
|
||||
}
|
||||
transitions: Transition {
|
||||
NumberAnimation { properties: "x"; duration: 200 }
|
||||
}
|
||||
MouseArea {
|
||||
anchors.fill: parent
|
||||
onClicked: wrapper.ListView.view.currentIndex = index
|
||||
}
|
||||
component PetDelegate: Item {
|
||||
id: pet
|
||||
width: 200; height: 55
|
||||
|
||||
required property int index
|
||||
required property string name
|
||||
required property string type
|
||||
required property int age
|
||||
|
||||
Column {
|
||||
SmallText { text: 'Name: ' + pet.name }
|
||||
SmallText { text: 'Type: ' + pet.type }
|
||||
SmallText { text: 'Age: ' + pet.age }
|
||||
}
|
||||
// indent the item if it is the current item
|
||||
states: State {
|
||||
name: "Current"
|
||||
when: pet.ListView.isCurrentItem
|
||||
PropertyChanges { target: pet; x: 20 }
|
||||
}
|
||||
transitions: Transition {
|
||||
NumberAnimation { properties: "x"; duration: 200 }
|
||||
}
|
||||
MouseArea {
|
||||
anchors.fill: parent
|
||||
onClicked: pet.ListView.view.currentIndex = pet.index
|
||||
}
|
||||
}
|
||||
|
||||
//! [0]
|
||||
// Define a highlight with customized movement between items.
|
||||
Component {
|
||||
id: highlightBar
|
||||
Rectangle {
|
||||
width: 200; height: 50
|
||||
color: "#FFFF88"
|
||||
y: listView.currentItem.y;
|
||||
Behavior on y { SpringAnimation { spring: 2; damping: 0.1 } }
|
||||
}
|
||||
component HighlightBar : Rectangle {
|
||||
width: 200; height: 50
|
||||
color: "#FFFF88"
|
||||
y: listView.currentItem.y
|
||||
Behavior on y { SpringAnimation { spring: 2; damping: 0.1 } }
|
||||
}
|
||||
|
||||
ListView {
|
||||
|
@ -104,12 +104,12 @@ Rectangle {
|
|||
x: 30
|
||||
|
||||
model: PetsModel {}
|
||||
delegate: petDelegate
|
||||
delegate: PetDelegate {}
|
||||
focus: true
|
||||
|
||||
// Set the highlight delegate. Note we must also set highlightFollowsCurrentItem
|
||||
// to false so the highlight delegate can control how the highlight is moved.
|
||||
highlight: highlightBar
|
||||
highlight: HighlightBar {}
|
||||
highlightFollowsCurrentItem: false
|
||||
}
|
||||
//! [0]
|
||||
|
|
|
@ -62,17 +62,17 @@ Rectangle {
|
|||
loops: -1
|
||||
running: true
|
||||
ScriptAction {
|
||||
script: if (increasing) {
|
||||
current++;
|
||||
if (current >= aModel.count -1) {
|
||||
current = aModel.count - 1;
|
||||
increasing = !increasing;
|
||||
script: if (root.increasing) {
|
||||
root.current++;
|
||||
if (root.current >= aModel.count -1) {
|
||||
root.current = aModel.count - 1;
|
||||
root.increasing = !root.increasing;
|
||||
}
|
||||
} else {
|
||||
current--;
|
||||
if (current <= 0) {
|
||||
current = 0;
|
||||
increasing = !increasing;
|
||||
root.current--;
|
||||
if (root.current <= 0) {
|
||||
root.current = 0;
|
||||
root.increasing = !root.increasing;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -161,16 +161,22 @@ Rectangle {
|
|||
Item {
|
||||
width: 160
|
||||
height: column.height
|
||||
|
||||
required property int index
|
||||
required property string name
|
||||
required property string type
|
||||
required property int age
|
||||
|
||||
Column {
|
||||
id: column
|
||||
Text { text: 'Name: ' + name }
|
||||
Text { text: 'Type: ' + type }
|
||||
Text { text: 'Age: ' + age }
|
||||
Text { text: 'Name: ' + parent.name }
|
||||
Text { text: 'Type: ' + parent.type }
|
||||
Text { text: 'Age: ' + parent.age }
|
||||
}
|
||||
|
||||
MouseArea {
|
||||
anchors.fill: parent
|
||||
onClicked: root.current = index
|
||||
onClicked: root.current = parent.index
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -87,8 +87,10 @@ Rectangle {
|
|||
height: childrenRect.height
|
||||
color: "lightsteelblue"
|
||||
|
||||
required property string section
|
||||
|
||||
Text {
|
||||
text: section
|
||||
text: parent.section
|
||||
font.bold: true
|
||||
font.pixelSize: 20
|
||||
}
|
||||
|
@ -101,7 +103,11 @@ Rectangle {
|
|||
anchors.bottom: buttonBar.top
|
||||
width: parent.width
|
||||
model: animalsModel
|
||||
delegate: Text { text: name; font.pixelSize: 18 }
|
||||
delegate: Text {
|
||||
required property string name
|
||||
text: name
|
||||
font.pixelSize: 18
|
||||
}
|
||||
|
||||
section.property: "size"
|
||||
section.criteria: ViewSection.FullString
|
||||
|
|
|
@ -70,21 +70,21 @@ Rectangle {
|
|||
color: "#FFFEF0"
|
||||
Text { text: "Page 1"; font.bold: true; anchors.centerIn: parent }
|
||||
|
||||
Component.onDestruction: if (printDestruction) print("destroyed 1")
|
||||
Component.onDestruction: if (root.printDestruction) print("destroyed 1")
|
||||
}
|
||||
Rectangle {
|
||||
width: view.width; height: view.height
|
||||
color: "#F0FFF7"
|
||||
Text { text: "Page 2"; font.bold: true; anchors.centerIn: parent }
|
||||
|
||||
Component.onDestruction: if (printDestruction) print("destroyed 2")
|
||||
Component.onDestruction: if (root.printDestruction) print("destroyed 2")
|
||||
}
|
||||
Rectangle {
|
||||
width: view.width; height: view.height
|
||||
color: "#F4F0FF"
|
||||
Text { text: "Page 3"; font.bold: true; anchors.centerIn: parent }
|
||||
|
||||
Component.onDestruction: if (printDestruction) print("destroyed 3")
|
||||
Component.onDestruction: if (root.activeFocusprintDestruction) print("destroyed 3")
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -112,6 +112,8 @@ Rectangle {
|
|||
model: itemModel.count
|
||||
|
||||
Rectangle {
|
||||
required property int index
|
||||
|
||||
width: 5; height: 5
|
||||
radius: 3
|
||||
color: view.currentIndex == index ? "blue" : "white"
|
||||
|
@ -119,7 +121,7 @@ Rectangle {
|
|||
MouseArea {
|
||||
width: 20; height: 20
|
||||
anchors.centerIn: parent
|
||||
onClicked: view.currentIndex = index
|
||||
onClicked: view.currentIndex = parent.index
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -52,6 +52,12 @@ import QtQuick 2.0
|
|||
|
||||
//! [0]
|
||||
Package {
|
||||
id: delegate
|
||||
|
||||
required property int upTo
|
||||
required property int index
|
||||
required property string display
|
||||
|
||||
Text { id: listDelegate; width: parent.width; height: 25; text: 'Empty'; Package.name: 'list' }
|
||||
Text { id: gridDelegate; width: parent.width / 2; height: 50; text: 'Empty'; Package.name: 'grid' }
|
||||
|
||||
|
@ -60,8 +66,8 @@ Package {
|
|||
width: parent.width; height: 25
|
||||
color: 'lightsteelblue'
|
||||
|
||||
Text { text: display; anchors.centerIn: parent }
|
||||
state: root.upTo > index ? 'inGrid' : 'inList'
|
||||
Text { text: delegate.display; anchors.centerIn: parent }
|
||||
state: delegate.upTo > delegate.index ? 'inGrid' : 'inList'
|
||||
states: [
|
||||
State {
|
||||
name: 'inList'
|
||||
|
|
|
@ -77,7 +77,9 @@ Rectangle {
|
|||
//![0]
|
||||
DelegateModel {
|
||||
id: visualModel
|
||||
delegate: Delegate {}
|
||||
delegate: Delegate {
|
||||
upTo: root.upTo
|
||||
}
|
||||
model: myModel
|
||||
}
|
||||
|
||||
|
|
|
@ -69,8 +69,14 @@ Column {
|
|||
id: screenInfo
|
||||
model: Qt.application.screens
|
||||
Shared.Label {
|
||||
required property string name
|
||||
required property int virtualX
|
||||
required property int virtualY
|
||||
required property int width
|
||||
required property int height
|
||||
|
||||
lineHeight: 1.5
|
||||
text: name + "\n" + virtualX + ", " + virtualY + " " + modelData.width + "x" + modelData.height
|
||||
text: name + "\n" + virtualX + ", " + virtualY + " " + width + "x" + height
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -115,10 +115,10 @@ Item {
|
|||
Shared.Label { text: Screen.virtualX + ", " + Screen.virtualY }
|
||||
|
||||
Shared.Label { text: "orientation" }
|
||||
Shared.Label { text: orientationToString(Screen.orientation) + " (" + Screen.orientation + ")" }
|
||||
Shared.Label { text: root.orientationToString(Screen.orientation) + " (" + Screen.orientation + ")" }
|
||||
|
||||
Shared.Label { text: "primary orientation" }
|
||||
Shared.Label { text: orientationToString(Screen.primaryOrientation) + " (" + Screen.primaryOrientation + ")" }
|
||||
Shared.Label { text: root.orientationToString(Screen.primaryOrientation) + " (" + Screen.primaryOrientation + ")" }
|
||||
//! [screen]
|
||||
|
||||
Shared.Label { text: "10mm rectangle" }
|
||||
|
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue