mirror of
				https://github.com/subsurface/subsurface.git
				synced 2025-02-19 22:16:15 +00:00 
			
		
		
		
	Port the page navigation to ApplicationWindow's one
The ApplicationWindow component has an internal PageRow for the management of the application's pages, use that instead of an own StackView. Use shared components for common things in the app ListItem for the dive list Page for application pages, for correct background color and moving of the action button Signed-off-by: Marco Martin <notmart@gmail.com> Signed-off-by: Sebastian Kügler <sebas@kde.org>
This commit is contained in:
		
							parent
							
								
									3d3fce7152
								
							
						
					
					
						commit
						32219f1276
					
				
					 4 changed files with 191 additions and 190 deletions
				
			
		| 
						 | 
					@ -3,13 +3,14 @@ import QtQuick.Controls 1.2
 | 
				
			||||||
import QtQuick.Controls.Styles 1.2
 | 
					import QtQuick.Controls.Styles 1.2
 | 
				
			||||||
import QtQuick.Dialogs 1.2
 | 
					import QtQuick.Dialogs 1.2
 | 
				
			||||||
import QtQuick.Layouts 1.1
 | 
					import QtQuick.Layouts 1.1
 | 
				
			||||||
import org.kde.plasma.mobilecomponents 0.2 as MobileComponents
 | 
					 | 
				
			||||||
import org.subsurfacedivelog.mobile 1.0
 | 
					import org.subsurfacedivelog.mobile 1.0
 | 
				
			||||||
 | 
					import org.kde.plasma.mobilecomponents 0.2 as MobileComponents
 | 
				
			||||||
 | 
					
 | 
				
			||||||
Item {
 | 
					MobileComponents.Page {
 | 
				
			||||||
	id: diveDetailsWindow
 | 
						id: diveDetailsWindow
 | 
				
			||||||
	width: parent.width
 | 
						width: parent.width
 | 
				
			||||||
	objectName: "DiveDetails"
 | 
						objectName: "DiveDetails"
 | 
				
			||||||
 | 
						flickable: flick
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	property string location
 | 
						property string location
 | 
				
			||||||
	property string dive_id
 | 
						property string dive_id
 | 
				
			||||||
| 
						 | 
					@ -30,11 +31,21 @@ Item {
 | 
				
			||||||
	Flickable {
 | 
						Flickable {
 | 
				
			||||||
		id: flick
 | 
							id: flick
 | 
				
			||||||
		anchors.fill: parent
 | 
							anchors.fill: parent
 | 
				
			||||||
		contentHeight: parent.height
 | 
							contentHeight: content.height
 | 
				
			||||||
		clip: true
 | 
							clip: true
 | 
				
			||||||
 | 
							Item {
 | 
				
			||||||
 | 
								id: content
 | 
				
			||||||
 | 
								width: flick.width
 | 
				
			||||||
 | 
								height: contentRect.height + MobileComponents.Units.smallSpacing * 2
 | 
				
			||||||
 | 
					
 | 
				
			||||||
			ColumnLayout {
 | 
								ColumnLayout {
 | 
				
			||||||
			width: parent.width
 | 
									anchors {
 | 
				
			||||||
			spacing: 8
 | 
										left: parent.left
 | 
				
			||||||
 | 
										right: parent.right
 | 
				
			||||||
 | 
										top: parent.top
 | 
				
			||||||
 | 
										margins: MobileComponents.Units.smallSpacing
 | 
				
			||||||
 | 
									}
 | 
				
			||||||
 | 
									spacing: MobileComponents.Units.smallSpacing
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
				GridLayout {
 | 
									GridLayout {
 | 
				
			||||||
| 
						 | 
					@ -42,9 +53,8 @@ Item {
 | 
				
			||||||
					width: parent.width
 | 
										width: parent.width
 | 
				
			||||||
					columns: 2
 | 
										columns: 2
 | 
				
			||||||
 | 
					
 | 
				
			||||||
				Label {
 | 
										MobileComponents.Heading {
 | 
				
			||||||
						Layout.columnSpan: 2
 | 
											Layout.columnSpan: 2
 | 
				
			||||||
					font.pointSize: subsurfaceTheme.titlePointSize
 | 
					 | 
				
			||||||
						text: "Dive " + number + " (" + date + ")"
 | 
											text: "Dive " + number + " (" + date + ")"
 | 
				
			||||||
					}
 | 
										}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -148,4 +158,5 @@ Item {
 | 
				
			||||||
				}
 | 
									}
 | 
				
			||||||
			}
 | 
								}
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -6,24 +6,25 @@ import QtQuick.Dialogs 1.2
 | 
				
			||||||
import org.kde.plasma.mobilecomponents 0.2 as MobileComponents
 | 
					import org.kde.plasma.mobilecomponents 0.2 as MobileComponents
 | 
				
			||||||
import org.subsurfacedivelog.mobile 1.0
 | 
					import org.subsurfacedivelog.mobile 1.0
 | 
				
			||||||
 | 
					
 | 
				
			||||||
Rectangle {
 | 
					MobileComponents.Page {
 | 
				
			||||||
	id: page
 | 
						id: page
 | 
				
			||||||
	objectName: "DiveList"
 | 
						objectName: "DiveList"
 | 
				
			||||||
 | 
						color: MobileComponents.Theme.viewBackgroundColor
 | 
				
			||||||
 | 
						flickable: diveListView
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	Component {
 | 
						Component {
 | 
				
			||||||
		id: diveDelegate
 | 
							id: diveDelegate
 | 
				
			||||||
		Item {
 | 
							MobileComponents.ListItem {
 | 
				
			||||||
			id: dive
 | 
								id: dive
 | 
				
			||||||
 | 
								enabled: true
 | 
				
			||||||
 | 
								checked: diveListView.currentIndex == model.index
 | 
				
			||||||
 | 
					
 | 
				
			||||||
			property real detailsOpacity : 0
 | 
								property real detailsOpacity : 0
 | 
				
			||||||
 | 
					
 | 
				
			||||||
			width: diveListView.width - MobileComponents.Units.smallSpacing
 | 
								//When clicked, the mode changes to details view
 | 
				
			||||||
			height: childrenRect.height
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
			//Mouse region: When clicked, the mode changes to details view
 | 
					 | 
				
			||||||
			MouseArea {
 | 
					 | 
				
			||||||
				anchors.fill: parent
 | 
					 | 
				
			||||||
			onClicked: {
 | 
								onClicked: {
 | 
				
			||||||
 | 
									diveListView.currentIndex = model.index
 | 
				
			||||||
				detailsWindow.width = parent.width
 | 
									detailsWindow.width = parent.width
 | 
				
			||||||
				detailsWindow.location = location
 | 
									detailsWindow.location = location
 | 
				
			||||||
				detailsWindow.dive_id = id
 | 
									detailsWindow.dive_id = id
 | 
				
			||||||
| 
						 | 
					@ -37,7 +38,6 @@ Rectangle {
 | 
				
			||||||
				detailsWindow.date = date
 | 
									detailsWindow.date = date
 | 
				
			||||||
				stackView.push(detailsWindow)
 | 
									stackView.push(detailsWindow)
 | 
				
			||||||
			}
 | 
								}
 | 
				
			||||||
			}
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
			//Layout of the page: (mini profile, dive no, date at the top
 | 
								//Layout of the page: (mini profile, dive no, date at the top
 | 
				
			||||||
			//And other details at the bottom.
 | 
								//And other details at the bottom.
 | 
				
			||||||
| 
						 | 
					@ -115,17 +115,6 @@ Rectangle {
 | 
				
			||||||
						top: locationText.bottom
 | 
											top: locationText.bottom
 | 
				
			||||||
					}
 | 
										}
 | 
				
			||||||
				}
 | 
									}
 | 
				
			||||||
				//Text { text: location; width: parent.width }
 | 
					 | 
				
			||||||
				Rectangle {
 | 
					 | 
				
			||||||
					color: MobileComponents.Theme.textColor
 | 
					 | 
				
			||||||
					opacity: .2
 | 
					 | 
				
			||||||
					height: Math.max(1, MobileComponents.Units.gridUnit / 24) // we really want a thin line
 | 
					 | 
				
			||||||
					anchors {
 | 
					 | 
				
			||||||
						left: parent.left
 | 
					 | 
				
			||||||
						right: parent.right
 | 
					 | 
				
			||||||
						top: numberText.bottom
 | 
					 | 
				
			||||||
					}
 | 
					 | 
				
			||||||
				}
 | 
					 | 
				
			||||||
			}
 | 
								}
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
| 
						 | 
					@ -136,7 +125,7 @@ Rectangle {
 | 
				
			||||||
			width: page.width - MobileComponents.Units.smallSpacing * 2
 | 
								width: page.width - MobileComponents.Units.smallSpacing * 2
 | 
				
			||||||
			height: childrenRect.height + MobileComponents.Units.smallSpacing * 2
 | 
								height: childrenRect.height + MobileComponents.Units.smallSpacing * 2
 | 
				
			||||||
 | 
					
 | 
				
			||||||
			Text {
 | 
								MobileComponents.Heading {
 | 
				
			||||||
				id: sectionText
 | 
									id: sectionText
 | 
				
			||||||
				text: section
 | 
									text: section
 | 
				
			||||||
				anchors {
 | 
									anchors {
 | 
				
			||||||
| 
						 | 
					@ -145,8 +134,7 @@ Rectangle {
 | 
				
			||||||
					leftMargin: MobileComponents.Units.smallSpacing
 | 
										leftMargin: MobileComponents.Units.smallSpacing
 | 
				
			||||||
					right: parent.right
 | 
										right: parent.right
 | 
				
			||||||
				}
 | 
									}
 | 
				
			||||||
				color: MobileComponents.Theme.textColor
 | 
									level: 2
 | 
				
			||||||
				font.pointSize: 16
 | 
					 | 
				
			||||||
			}
 | 
								}
 | 
				
			||||||
			Rectangle {
 | 
								Rectangle {
 | 
				
			||||||
				height: Math.max(2, MobileComponents.Units.gridUnit / 12) // we want a thicker line
 | 
									height: Math.max(2, MobileComponents.Units.gridUnit / 12) // we want a thicker line
 | 
				
			||||||
| 
						 | 
					@ -161,10 +149,21 @@ Rectangle {
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						Connections {
 | 
				
			||||||
 | 
							target: stackView
 | 
				
			||||||
 | 
							onDepthChanged: {
 | 
				
			||||||
 | 
								if (stackView.depth == 1) {
 | 
				
			||||||
 | 
									diveListView.currentIndex = -1;
 | 
				
			||||||
 | 
								}
 | 
				
			||||||
 | 
							}
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
						ScrollView {
 | 
				
			||||||
 | 
							anchors.fill: parent
 | 
				
			||||||
		ListView {
 | 
							ListView {
 | 
				
			||||||
			id: diveListView
 | 
								id: diveListView
 | 
				
			||||||
			anchors.fill: parent
 | 
								anchors.fill: parent
 | 
				
			||||||
			model: diveModel
 | 
								model: diveModel
 | 
				
			||||||
 | 
								currentIndex: -1
 | 
				
			||||||
			delegate: diveDelegate
 | 
								delegate: diveDelegate
 | 
				
			||||||
			boundsBehavior: Flickable.StopAtBounds
 | 
								boundsBehavior: Flickable.StopAtBounds
 | 
				
			||||||
			//highlight: Rectangle { color: MobileComponents.Theme.highlightColor; width: MobileComponents.Units.smallSpacing }
 | 
								//highlight: Rectangle { color: MobileComponents.Theme.highlightColor; width: MobileComponents.Units.smallSpacing }
 | 
				
			||||||
| 
						 | 
					@ -174,6 +173,7 @@ Rectangle {
 | 
				
			||||||
			section.criteria: ViewSection.FullString
 | 
								section.criteria: ViewSection.FullString
 | 
				
			||||||
			section.delegate: tripHeading
 | 
								section.delegate: tripHeading
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
	StartPage {
 | 
						StartPage {
 | 
				
			||||||
		anchors.fill: parent
 | 
							anchors.fill: parent
 | 
				
			||||||
		opacity: (diveListView.count == 0) ? 1.0 : 0
 | 
							opacity: (diveListView.count == 0) ? 1.0 : 0
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -202,23 +202,13 @@ MobileComponents.ApplicationWindow {
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	ColumnLayout {
 | 
						toolBar: TopBar {
 | 
				
			||||||
		anchors.fill: parent
 | 
							width: parent.width
 | 
				
			||||||
 | 
							height: Layout.minimumHeight
 | 
				
			||||||
		TopBar {
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		StackView {
 | 
						property Item stackView: pageStack
 | 
				
			||||||
			id: stackView
 | 
						initialPage: Item {
 | 
				
			||||||
			Layout.preferredWidth: parent.width
 | 
					 | 
				
			||||||
			Layout.fillHeight: true
 | 
					 | 
				
			||||||
			focus: true
 | 
					 | 
				
			||||||
			Keys.onReleased: if (event.key == Qt.Key_Back && stackView.depth > 1) {
 | 
					 | 
				
			||||||
						stackView.pop()
 | 
					 | 
				
			||||||
						event.accepted = true;
 | 
					 | 
				
			||||||
					}
 | 
					 | 
				
			||||||
			initialItem: Item {
 | 
					 | 
				
			||||||
		width: parent.width
 | 
							width: parent.width
 | 
				
			||||||
		height: parent.height
 | 
							height: parent.height
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -239,6 +229,7 @@ MobileComponents.ApplicationWindow {
 | 
				
			||||||
				}
 | 
									}
 | 
				
			||||||
			}
 | 
								}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
			Rectangle {
 | 
								Rectangle {
 | 
				
			||||||
				id: messageArea
 | 
									id: messageArea
 | 
				
			||||||
				height: childrenRect.height
 | 
									height: childrenRect.height
 | 
				
			||||||
| 
						 | 
					@ -250,9 +241,7 @@ MobileComponents.ApplicationWindow {
 | 
				
			||||||
					color: MobileComponents.Theme.textColor
 | 
										color: MobileComponents.Theme.textColor
 | 
				
			||||||
					wrapMode: TextEdit.WrapAtWordBoundaryOrAnywhere
 | 
										wrapMode: TextEdit.WrapAtWordBoundaryOrAnywhere
 | 
				
			||||||
					styleColor: MobileComponents.Theme.textColor
 | 
										styleColor: MobileComponents.Theme.textColor
 | 
				
			||||||
							font.pointSize: subsurfaceTheme.smallPointSize
 | 
										font.pointSize: MobileComponents.Units.smallPointSize
 | 
				
			||||||
						}
 | 
					 | 
				
			||||||
					}
 | 
					 | 
				
			||||||
				}
 | 
									}
 | 
				
			||||||
			}
 | 
								}
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -19,6 +19,7 @@
 | 
				
			||||||
		<file alias="org/kde/plasma/mobilecomponents/ActionGroup.qml">mobilecomponents/ActionGroup.qml</file>
 | 
							<file alias="org/kde/plasma/mobilecomponents/ActionGroup.qml">mobilecomponents/ActionGroup.qml</file>
 | 
				
			||||||
		<file alias="org/kde/plasma/mobilecomponents/ApplicationWindow.qml">mobilecomponents/ApplicationWindow.qml</file>
 | 
							<file alias="org/kde/plasma/mobilecomponents/ApplicationWindow.qml">mobilecomponents/ApplicationWindow.qml</file>
 | 
				
			||||||
		<file alias="org/kde/plasma/mobilecomponents/GlobalDrawer.qml">mobilecomponents/GlobalDrawer.qml</file>
 | 
							<file alias="org/kde/plasma/mobilecomponents/GlobalDrawer.qml">mobilecomponents/GlobalDrawer.qml</file>
 | 
				
			||||||
 | 
							<file alias="org/kde/plasma/mobilecomponents/Page.qml">mobilecomponents/Page.qml</file>
 | 
				
			||||||
		<file alias="org/kde/plasma/mobilecomponents/Icon.qml">mobilecomponents/Icon.qml</file>
 | 
							<file alias="org/kde/plasma/mobilecomponents/Icon.qml">mobilecomponents/Icon.qml</file>
 | 
				
			||||||
		<file alias="org/kde/plasma/mobilecomponents/Heading.qml">mobilecomponents/Heading.qml</file>
 | 
							<file alias="org/kde/plasma/mobilecomponents/Heading.qml">mobilecomponents/Heading.qml</file>
 | 
				
			||||||
		<file alias="org/kde/plasma/mobilecomponents/PageRow.qml">mobilecomponents/PageRow.qml</file>
 | 
							<file alias="org/kde/plasma/mobilecomponents/PageRow.qml">mobilecomponents/PageRow.qml</file>
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue