-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
283 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
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
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,52 @@ | ||
import QtQuick | ||
|
||
Item { | ||
id: root | ||
|
||
property RadialMenu menu: null | ||
property RadialMenu subMenu: null | ||
property bool down: false | ||
|
||
signal pressed() | ||
signal released() | ||
signal toggled() | ||
signal triggered() | ||
|
||
function toggle() { | ||
root.down = !root.down; | ||
} | ||
|
||
onParentChanged: { | ||
if(root.parent instanceof RadialMenu) { | ||
root.menu = root.parent as RadialMenu; | ||
} | ||
} | ||
|
||
onDownChanged: { | ||
root.toggled(); | ||
|
||
if(root.down === true) { | ||
root.triggered(); | ||
} | ||
|
||
if(root.subMenu === null) { | ||
return; | ||
} | ||
|
||
if(root.down === true) { | ||
root.subMenu.open(); | ||
} | ||
else { | ||
root.subMenu.close(); | ||
} | ||
} | ||
|
||
TapHandler { | ||
id: handler | ||
|
||
gesturePolicy: TapHandler.WithinBounds | ||
longPressThreshold: 0 | ||
onTapped: root.toggle() | ||
onPressedChanged: handler.pressed === true ? root.pressed() : root.released() | ||
} | ||
} |
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,159 @@ | ||
import QtQuick | ||
|
||
Item { | ||
id: root | ||
|
||
property real radius: width / 2 * 0.75 - 2 | ||
property bool opened: false | ||
property real itemSize: menu.width / internal.model.count | ||
|
||
// Defining a default property to override Item's children. | ||
// The items from this list will be added via the ObjectModel using a View instead. | ||
default property alias items: internal.model.children | ||
|
||
QtObject { | ||
id: internal | ||
|
||
property ObjectModel model: ObjectModel { | ||
} | ||
} | ||
|
||
function open() { | ||
root.opened = true; | ||
} | ||
|
||
function close() { | ||
root.opened = false; | ||
} | ||
|
||
function toggle() { | ||
root.opened = !root.opened; | ||
} | ||
|
||
states: [ | ||
State { | ||
name: "opened" | ||
when: menu.opened == true | ||
|
||
PropertyChanges { | ||
target: menu | ||
itemSize: menu.width | ||
} | ||
} | ||
] | ||
|
||
transitions: [ | ||
Transition { | ||
NumberAnimation { | ||
property: "itemSize" | ||
duration: 350 | ||
} | ||
} | ||
] | ||
|
||
PathView { | ||
id: path | ||
|
||
anchors.centerIn: parent | ||
|
||
property real startAngle: -90 | ||
|
||
states: [ | ||
State { | ||
name: "opened" | ||
when: root.opened == true | ||
|
||
PropertyChanges { | ||
target: root | ||
radius: width * 2 | ||
} | ||
|
||
PropertyChanges { | ||
target: path | ||
startAngle: 270 | ||
} | ||
} | ||
] | ||
|
||
transitions: [ | ||
Transition { | ||
ParallelAnimation { | ||
NumberAnimation { | ||
property: "radius" | ||
duration: 350 | ||
} | ||
|
||
NumberAnimation { | ||
property: "startAngle" | ||
duration: 350 | ||
} | ||
} | ||
} | ||
] | ||
|
||
// state: root.state | ||
// states: [ | ||
// State { | ||
// name: root.statePressed | ||
|
||
// PropertyChanges { | ||
// target: path | ||
// startAngle: 270 | ||
// } | ||
// } | ||
// ] | ||
|
||
// transitions: Transition { | ||
// NumberAnimation { | ||
// property: "startAngle" | ||
// duration: 350 | ||
// } | ||
// } | ||
|
||
model: internal.model | ||
|
||
// delegate: Rectangle { | ||
// id: rect | ||
// width: root.width / 5 | ||
// height: width | ||
// radius: width / 2 | ||
// color: foreground | ||
|
||
// state: root.state | ||
// states: [ | ||
// State { | ||
// name: root.statePressed | ||
|
||
// PropertyChanges { | ||
// target: rect | ||
// width: Style.iconSize * 1.25 | ||
// } | ||
// } | ||
// ] | ||
|
||
// transitions: Transition { | ||
// NumberAnimation { | ||
// property: "width" | ||
// duration: 350 | ||
// } | ||
// } | ||
|
||
// Loader { | ||
// active: root.state === root.statePressed | ||
// anchors.fill: parent | ||
// sourceComponent: component | ||
// } | ||
// } | ||
|
||
path: Path { | ||
PathAngleArc { | ||
id: radial | ||
|
||
radiusX: root.radius | ||
radiusY: root.radius | ||
startAngle: path.startAngle | ||
sweepAngle: 360 | ||
} | ||
} | ||
} | ||
} |