sync with mobilecomponents 9d8bf6d77d

- Fixes interactivity in context drawer.

- These are mostly cleanups that have been done pre-merge of these
components. This now is the state of master in plasma-mobile.

- makes navigation a bit more intuitive

Signed-off-by: Sebastian Kügler <sebas@kde.org>
This commit is contained in:
Sebastian Kügler 2015-12-04 00:27:35 +01:00
parent 72411eee63
commit b6f5f235f0
9 changed files with 74 additions and 62 deletions

View file

@ -38,9 +38,9 @@ ApplicationWindow {
property alias initialPage: __pageStack.initialPage property alias initialPage: __pageStack.initialPage
/** /**
* The stack used to allocate the pages nd to manage the transitions * The stack used to allocate the pages and to manage the transitions
* between them. * between them.
* It's using a PageRow, while having the same aPI as PageStack, * It's using a PageRow, while having the same API as PageStack,
* it positions the pages as adjacent columns, with as many columns * it positions the pages as adjacent columns, with as many columns
* as can fit in the screen. An handheld device would usually have a single * as can fit in the screen. An handheld device would usually have a single
* fullscreen column, a tablet device would have many tiled columns. * fullscreen column, a tablet device would have many tiled columns.
@ -57,11 +57,6 @@ ApplicationWindow {
event.accepted = true; event.accepted = true;
} }
} }
onLastVisiblePageChanged: {
if (lastVisiblePage != null) {
pop(lastVisiblePage)
}
}
} }
property AbstractDrawer globalDrawer property AbstractDrawer globalDrawer

View file

@ -35,6 +35,7 @@ OverlayDrawer {
contentItem: QtControls.ScrollView { contentItem: QtControls.ScrollView {
ListView { ListView {
id: menu id: menu
interactive: contentHeight > height
model: { model: {
if (root.actions.length == 0) { if (root.actions.length == 0) {
return null; return null;

View file

@ -97,8 +97,8 @@ OverlayDrawer {
color: bannerImageSource != "" ? "white" : Theme.textColor color: bannerImageSource != "" ? "white" : Theme.textColor
} }
Item { Item {
height: parent.height height: 1
Layout.minimumWidth: height Layout.minimumWidth: heading.height
} }
} }
} }
@ -157,9 +157,7 @@ OverlayDrawer {
source: "go-previous" source: "go-previous"
} }
Label { Label {
// Weird, this doesn't work text: typeof i18n !== "undefined" ? i18n("Back") : "Back"
//text: (typeof(i18n) != undefined) ? i18n("Back") : "Back"
text: "Back"
} }
} }
onClicked: pageRow.pop() onClicked: pageRow.pop()

View file

@ -30,12 +30,10 @@ import org.kde.plasma.mobilecomponents 0.2
* Example usage: * Example usage:
* *
* @code * @code
* import org.kde.plasma.extras 2.0 as PlasmaExtras * import org.kde.plasma.mobilecomponents 0.2 as MobileComponents
* [...] * [...]
* Column { * Column {
* PlasmaExtras.Title { text: "Fruit sweetness on the rise" } * MobileComponents.Heading { text: "Apples in the sunlight"; level: 2 }
* PlasmaExtras.Heading { text: "Apples in the sunlight"; level: 2 }
* PlasmaExtras.Paragraph { text: "Long text about fruit and apples [...]" }
* [...] * [...]
* } * }
* @endcode * @endcode

View file

@ -59,8 +59,8 @@ Item {
id: iconView id: iconView
objectName: "iconView" objectName: "iconView"
pressDelay: 200 pressDelay: 200
cacheBuffer: 100 cacheBuffer: Units.gridUnit * 8
highlightMoveDuration: 250 highlightMoveDuration: Units.shortDuration
anchors.fill: parent anchors.fill: parent
onWidthChanged: resizeTimer.restart() onWidthChanged: resizeTimer.restart()
onHeightChanged: resizeTimer.restart() onHeightChanged: resizeTimer.restart()
@ -145,7 +145,6 @@ Item {
Rectangle { Rectangle {
id: barRectangle id: barRectangle
color: Theme.textColor color: Theme.textColor
opacity: 2.05
height: 4 height: 4
radius: 2 radius: 2
anchors { anchors {
@ -165,7 +164,7 @@ Item {
x: parent.width / (pageCount / (iconView.currentIndex+1)) - (parent.width / pageCount / 2) - 4 x: parent.width / (pageCount / (iconView.currentIndex+1)) - (parent.width / pageCount / 2) - 4
Behavior on x { Behavior on x {
NumberAnimation { NumberAnimation {
duration: 250 duration: Units.shortDuration
easing.type: Easing.InOutQuad easing.type: Easing.InOutQuad
} }
} }
@ -192,7 +191,7 @@ Item {
Item { Item {
Row { Row {
anchors.centerIn: parent anchors.centerIn: parent
spacing: 20 spacing: units.gridUnit
Repeater { Repeater {
model: scrollArea.pageCount model: scrollArea.pageCount
@ -209,13 +208,13 @@ Item {
Behavior on scale { Behavior on scale {
NumberAnimation { NumberAnimation {
duration: 250 duration: units.shortDuration
easing.type: Easing.InOutQuad easing.type: Easing.InOutQuad
} }
} }
Behavior on opacity { Behavior on opacity {
NumberAnimation { NumberAnimation {
duration: 250 duration: units.shortDuration
easing.type: Easing.InOutQuad easing.type: Easing.InOutQuad
} }
} }
@ -223,7 +222,7 @@ Item {
MouseArea { MouseArea {
anchors { anchors {
fill: parent fill: parent
margins: -10 margins: Units.gridUnit / 2
} }
onClicked: { onClicked: {

View file

@ -50,7 +50,6 @@ Item {
*/ */
signal clicked signal clicked
/** /**
* The user pressed the item with the mouse and didn't release it for a * The user pressed the item with the mouse and didn't release it for a
* certain amount of time. * certain amount of time.

View file

@ -28,14 +28,20 @@ Imports:
QtQuick 2.1 QtQuick 2.1
Description: Description:
Overlay Drawers are used to expose additional UI elements needed for small secondary tasks for which the main UI elements are not needed. For example in Okular Active, an Overlay Drawer is used to display thumbnails of all pages within a document along with a search field. This is used for the distinct task of navigating to another page. Overlay Drawers are used to expose additional UI elements needed for
small secondary tasks for which the main UI elements are not needed.
For example in Okular Active, an Overlay Drawer is used to display
thumbnails of all pages within a document along with a search field.
This is used for the distinct task of navigating to another page.
Properties: Properties:
bool opened: bool opened:
If true the drawer is open showing the contents of the "drawer" component. If true the drawer is open showing the contents of the "drawer"
component.
Item page: Item page:
It's the default property. it's the main content of the drawer page, the part that is always shown It's the default property. it's the main content of the drawer page,
the part that is always shown
Item contentItem: Item contentItem:
It's the part that can be pulled in and out, will act as a sidebar. It's the part that can be pulled in and out, will act as a sidebar.
@ -218,7 +224,7 @@ AbstractDrawer {
onStateChanged: open = (state != "Closed") onStateChanged: open = (state != "Closed")
property bool open: false property bool open: false
onOpenChanged: { onOpenChanged: {
if (drawerPage.children.length == 0) { if (browserFrame.state == "Dragging" || drawerPage.children.length == 0) {
return; return;
} }

View file

@ -82,6 +82,7 @@ Item {
// Returns the page instance. // Returns the page instance.
function push(page, properties, immediate) function push(page, properties, immediate)
{ {
pop(lastVisiblePage, true);
scrollAnimation.running = false; scrollAnimation.running = false;
var item = Engine.push(page, properties, false, immediate) var item = Engine.push(page, properties, false, immediate)
scrollToLevel(depth) scrollToLevel(depth)
@ -102,6 +103,7 @@ Item {
// See push() for details. // See push() for details.
function replace(page, properties, immediate) function replace(page, properties, immediate)
{ {
pop(lastVisiblePage, true);
scrollAnimation.running = false; scrollAnimation.running = false;
var item = Engine.push(page, properties, true, immediate); var item = Engine.push(page, properties, true, immediate);
scrollToLevel(depth) scrollToLevel(depth)
@ -147,6 +149,11 @@ Item {
} }
ScriptAction { ScriptAction {
script: { script: {
//At startup sometimes the contentX is NaN for an instant
if (isNaN(mainFlickable.contentX)) {
return;
}
actualRoot.lastVisiblePage = root.children[Math.floor((mainFlickable.contentX + mainFlickable.width - 1)/columnWidth)].page actualRoot.lastVisiblePage = root.children[Math.floor((mainFlickable.contentX + mainFlickable.width - 1)/columnWidth)].page
} }
} }
@ -211,8 +218,8 @@ Item {
contentHeight: height contentHeight: height
Row { Row {
id: root id: root
spacing: -100 spacing: -Units.gridUnit * 8
width: Math.max((depth-1+children[children.length-1].takenColumns) * columnWidth, childrenRect.width - 100) width: Math.max((depth-1+children[children.length-1].takenColumns) * columnWidth, childrenRect.width - Units.gridUnit * 8)
height: parent.height height: parent.height
Behavior on width { Behavior on width {
@ -238,7 +245,7 @@ Item {
Item { Item {
id: container id: container
implicitWidth: actualContainer.width + 100 implicitWidth: actualContainer.width + Units.gridUnit * 8
width: implicitWidth width: implicitWidth
height: parent ? parent.height : 0 height: parent ? parent.height : 0
@ -293,7 +300,7 @@ Item {
top: parent.top top: parent.top
bottom: parent.bottom bottom: parent.bottom
right: parent.right right: parent.right
rightMargin: 100 rightMargin: Units.gridUnit * 8
} }
property int takenColumns: { property int takenColumns: {
@ -413,13 +420,13 @@ Item {
State { State {
name: "Left" name: "Left"
PropertyChanges { target: container; opacity: 0 } PropertyChanges { target: container; opacity: 0 }
PropertyChanges { target: container; width: 100} PropertyChanges { target: container; width: Units.gridUnit * 8}
}, },
// Start state for push entry, end state for pop exit. // Start state for push entry, end state for pop exit.
State { State {
name: "Right" name: "Right"
PropertyChanges { target: container; opacity: 0 } PropertyChanges { target: container; opacity: 0 }
PropertyChanges { target: container; width: 100} PropertyChanges { target: container; width: Units.gridUnit * 8}
}, },
// Inactive state. // Inactive state.
State { State {

View file

@ -25,6 +25,8 @@ import org.kde.plasma.mobilecomponents 0.2
MouseArea { MouseArea {
id: button id: button
property alias iconSource: icon.source property alias iconSource: icon.source
property bool checkable: false
property bool checked: false
Layout.minimumWidth: Units.iconSizes.large Layout.minimumWidth: Units.iconSizes.large
Layout.maximumWidth: Layout.minimumWidth Layout.maximumWidth: Layout.minimumWidth
implicitWidth: Units.iconSizes.large implicitWidth: Units.iconSizes.large
@ -35,9 +37,9 @@ MouseArea {
minimumX: contextDrawer ? 0 : parent.width/2 - width/2 minimumX: contextDrawer ? 0 : parent.width/2 - width/2
maximumX: globalDrawer ? parent.width : parent.width/2 - width/2 maximumX: globalDrawer ? parent.width : parent.width/2 - width/2
} }
function toggle() { function toggleVisibility() {
showAnimation.running = false; showAnimation.running = false;
if (transform[0].y < button.height) { if (translateTransform.y < button.height) {
showAnimation.to = button.height; showAnimation.to = button.height;
} else { } else {
showAnimation.to = 0; showAnimation.to = 0;
@ -45,7 +47,9 @@ MouseArea {
showAnimation.running = true; showAnimation.running = true;
} }
transform: Translate {} transform: Translate {
id: translateTransform
}
onReleased: { onReleased: {
if (globalDrawer && x > Math.min(parent.width/4*3, parent.width/2 + globalDrawer.contentItem.width/2)) { if (globalDrawer && x > Math.min(parent.width/4*3, parent.width/2 + globalDrawer.contentItem.width/2)) {
globalDrawer.open(); globalDrawer.open();
@ -66,6 +70,11 @@ MouseArea {
} }
} }
} }
onClicked: {
if (checkable) {
checked = !checked;
}
}
Connections { Connections {
target: globalDrawer target: globalDrawer
onPositionChanged: { onPositionChanged: {
@ -99,7 +108,7 @@ MouseArea {
NumberAnimation { NumberAnimation {
id: showAnimation id: showAnimation
target: button.transform[0] target: translateTransform
properties: "y" properties: "y"
duration: Units.longDuration duration: Units.longDuration
easing.type: Easing.InOutQuad easing.type: Easing.InOutQuad
@ -116,7 +125,7 @@ MouseArea {
anchors.centerIn: parent anchors.centerIn: parent
height: parent.height - Units.smallSpacing*2 height: parent.height - Units.smallSpacing*2
width: height width: height
color: button.pressed ? Theme.highlightColor : Theme.backgroundColor color: button.pressed || button.checked ? Theme.highlightColor : Theme.backgroundColor
Icon { Icon {
id: icon id: icon
anchors { anchors {