QML UI: Fully port dive edit to Kirigami2

Completely adapt to the api changes of OverlaySheet in Kirigami2
in order to achieve the same look and behavior for the dive
edits that had with kirigami1

Port most components to QtQuickContrls2, except comboboxes
in the dive edit sheet that will need a new control type

Signed-off-by: Marco Martin <notmart@gmail.com>
This commit is contained in:
Marco Martin 2017-03-31 16:15:14 +02:00 committed by Dirk Hohndel
parent 34a42d7f04
commit 751626eec5
20 changed files with 124 additions and 167 deletions

View file

@ -250,6 +250,7 @@ if(${SUBSURFACE_TARGET_EXECUTABLE} MATCHES "MobileExecutable")
mobile-widgets/qmlmanager.cpp
mobile-widgets/qmlprofile.cpp
mobile-widgets/qml/kirigami/src/kirigamiplugin.cpp
mobile-widgets/qml/kirigami/src/settings.cpp
mobile-widgets/qml/kirigami/src/enums.cpp
subsurface-mobile-main.cpp
subsurface-mobile-helper.cpp

View file

@ -1,7 +1,6 @@
import QtQuick 2.3
import QtQuick.Controls 1.2
import QtQuick.Layouts 1.1
import org.kde.kirigami 1.0 as Kirigami
import org.kde.kirigami 2.0 as Kirigami
import org.subsurfacedivelog.mobile 1.0
Kirigami.ScrollablePage {

View file

@ -1,9 +1,9 @@
import QtQuick 2.3
import QtQuick.Controls 1.2
import QtQuick.Controls 2.0
import QtQuick.Window 2.2
import QtQuick.Dialogs 1.2
import QtQuick.Layouts 1.1
import org.kde.kirigami 1.0 as Kirigami
import org.kde.kirigami 2.0 as Kirigami
import org.subsurfacedivelog.mobile 1.0
Item {
@ -56,7 +56,7 @@ Item {
text: qsTr("Email")
}
StyledTextField {
TextField {
id: login
text: manager.cloudUserName
Layout.fillWidth: true
@ -68,7 +68,7 @@ Item {
text: qsTr("Password")
}
StyledTextField {
TextField {
id: password
text: manager.cloudPassword
echoMode: TextInput.Password
@ -97,7 +97,7 @@ Item {
text: qsTr("PIN")
visible: rootItem.showPin
}
StyledTextField {
TextField {
id: pin
text: ""
Layout.fillWidth: true

View file

@ -1,10 +1,9 @@
import QtQuick 2.4
import QtQuick.Controls 1.4
import QtQuick.Controls.Styles 1.4
import QtQuick.Controls 2.0
import QtQuick.Dialogs 1.2
import QtQuick.Layouts 1.2
import org.subsurfacedivelog.mobile 1.0
import org.kde.kirigami 1.0 as Kirigami
import org.kde.kirigami 2.0 as Kirigami
Kirigami.Page {
id: diveDetailsPage // but this is referenced as detailsWindow
@ -52,23 +51,23 @@ Kirigami.Page {
left: diveDetailsListView.currentItem ? (diveDetailsListView.currentItem.modelData.dive.gps !== "" ? mapAction : null) : null
}
}
PropertyChanges { target: detailsEditScroll; opened: false }
PropertyChanges { target: detailsEditScroll; sheetOpen: false }
PropertyChanges { target: pageStack.contentItem; interactive: true }
},
State {
name: "edit"
PropertyChanges { target: detailsEditScroll; opened: true }
PropertyChanges { target: detailsEditScroll; sheetOpen: true }
PropertyChanges { target: pageStack.contentItem; interactive: false }
},
State {
name: "add"
PropertyChanges { target: detailsEditScroll; opened: true }
PropertyChanges { target: detailsEditScroll; sheetOpen: true }
PropertyChanges { target: pageStack.contentItem; interactive: false }
}
]
property QtObject deleteAction: Action {
property QtObject deleteAction: Kirigami.Action {
text: qsTr("Delete dive")
iconName: "trash-empty"
onTriggered: {
@ -85,7 +84,7 @@ Kirigami.Page {
}
}
property QtObject mapAction: Action {
property QtObject mapAction: Kirigami.Action {
text: qsTr("Show on map")
iconName: "gps"
onTriggered: {
@ -93,7 +92,7 @@ Kirigami.Page {
}
}
actions.main: Action {
actions.main: Kirigami.Action {
iconName: state !== "view" ? "document-save" : "document-edit"
onTriggered: {
manager.appendTextToLog("save/edit button triggered")
@ -174,9 +173,6 @@ Kirigami.Page {
//onWidthChanged: diveDetailsListView.positionViewAtIndex(diveDetailsListView.currentIndex, ListView.Beginning);
Item {
anchors.fill: parent
ScrollView {
id: diveDetailList
anchors.fill: parent
ListView {
id: diveDetailsListView
@ -195,28 +191,27 @@ Kirigami.Page {
onMovementEnded: {
currentIndex = indexAt(contentX+1, 1);
}
delegate: ScrollView {
delegate: Flickable {
id: internalScrollView
width: diveDetailsListView.width
height: diveDetailsListView.height
property var modelData: model
Flickable {
//contentWidth: parent.width
contentHeight: diveDetails.height
boundsBehavior: Flickable.StopAtBounds
property var modelData: model
DiveDetailsView {
id: diveDetails
width: internalScrollView.width
}
ScrollBar.vertical: ScrollBar { }
}
}
}
ScrollIndicator.horizontal: ScrollIndicator { }
}
Kirigami.OverlaySheet {
id: detailsEditScroll
anchors.fill: parent
onOpenedChanged: {
if (!opened) {
parent: diveDetailsPage
rootItem.z: 0
onSheetOpenChanged: {
if (!sheetOpen) {
endEditMode()
}
}

View file

@ -1,10 +1,11 @@
import QtQuick 2.3
import QtQuick.Controls 1.2
import QtQuick.Controls 2.0
import QtQuick.Controls 1.2 as QQC1
import QtQuick.Controls.Styles 1.2
import QtQuick.Dialogs 1.2
import QtQuick.Layouts 1.1
import org.subsurfacedivelog.mobile 1.0
import org.kde.kirigami 1.0 as Kirigami
import org.kde.kirigami 2.0 as Kirigami
Item {
id: detailsEdit
@ -83,7 +84,7 @@ Item {
Layout.alignment: Qt.AlignRight
text: qsTr("Date:")
}
StyledTextField {
TextField {
id: txtDate;
Layout.fillWidth: true
}
@ -91,7 +92,7 @@ Item {
Layout.alignment: Qt.AlignRight
text: qsTr("Location:")
}
StyledTextField {
TextField {
id: txtLocation;
Layout.fillWidth: true
}
@ -100,7 +101,7 @@ Item {
Layout.alignment: Qt.AlignRight
text: qsTr("Coordinates:")
}
StyledTextField {
TextField {
id: txtGps
Layout.fillWidth: true
}
@ -123,7 +124,7 @@ Item {
Layout.alignment: Qt.AlignRight
text: qsTr("Depth:")
}
StyledTextField {
TextField {
id: txtDepth
Layout.fillWidth: true
validator: RegExpValidator { regExp: /[^-]*/ }
@ -132,7 +133,7 @@ Item {
Layout.alignment: Qt.AlignRight
text: qsTr("Duration:")
}
StyledTextField {
TextField {
id: txtDuration
Layout.fillWidth: true
validator: RegExpValidator { regExp: /[^-]*/ }
@ -142,7 +143,7 @@ Item {
Layout.alignment: Qt.AlignRight
text: qsTr("Air Temp:")
}
StyledTextField {
TextField {
id: txtAirTemp
Layout.fillWidth: true
}
@ -151,7 +152,7 @@ Item {
Layout.alignment: Qt.AlignRight
text: qsTr("Water Temp:")
}
StyledTextField {
TextField {
id: txtWaterTemp
Layout.fillWidth: true
}
@ -160,7 +161,7 @@ Item {
Layout.alignment: Qt.AlignRight
text: qsTr("Suit:")
}
ComboBox {
QQC1.ComboBox {
id: suitBox
editable: true
model: diveDetailsListView.currentItem ? diveDetailsListView.currentItem.modelData.dive.suitList : null
@ -175,7 +176,7 @@ Item {
Layout.alignment: Qt.AlignRight
text: qsTr("Buddy:")
}
ComboBox {
QQC1.ComboBox {
id: buddyBox
editable: true
model: diveDetailsListView.currentItem ? diveDetailsListView.currentItem.modelData.dive.buddyList : null
@ -190,7 +191,7 @@ Item {
Layout.alignment: Qt.AlignRight
text: qsTr("Divemaster:")
}
ComboBox {
QQC1.ComboBox {
id: divemasterBox
editable: true
model: diveDetailsListView.currentItem ? diveDetailsListView.currentItem.modelData.dive.divemasterList : null
@ -205,9 +206,9 @@ Item {
Layout.alignment: Qt.AlignRight
text: qsTr("Weight:")
}
StyledTextField {
TextField {
id: txtWeight
fixed: text === "cannot edit multiple weight systems"
readOnly: text === "cannot edit multiple weight systems"
Layout.fillWidth: true
}
@ -215,7 +216,7 @@ Item {
Layout.alignment: Qt.AlignRight
text: qsTr("Cylinder:")
}
ComboBox {
QQC1.ComboBox {
id: cylinderBox
editable: true
model: diveDetailsListView.currentItem ? diveDetailsListView.currentItem.modelData.dive.cylinderList : null
@ -230,7 +231,7 @@ Item {
Layout.alignment: Qt.AlignRight
text: qsTr("Gas mix:")
}
StyledTextField {
TextField {
id: txtGasMix
Layout.fillWidth: true
validator: RegExpValidator { regExp: /(EAN100|EAN\d\d|AIR|100|\d{1,2}|\d{1,2}\/\d{1,2})/i }
@ -240,7 +241,7 @@ Item {
Layout.alignment: Qt.AlignRight
text: qsTr("Start Pressure:")
}
StyledTextField {
TextField {
id: txtStartPressure
Layout.fillWidth: true
}
@ -249,7 +250,7 @@ Item {
Layout.alignment: Qt.AlignRight
text: qsTr("End Pressure:")
}
StyledTextField {
TextField {
id: txtEndPressure
Layout.fillWidth: true
}

View file

@ -2,12 +2,10 @@ import QtQuick 2.3
/*
import QtWebView 1.0
*/
import QtQuick.Controls 1.2
import QtQuick.Controls.Styles 1.2
import QtQuick.Dialogs 1.2
import QtQuick.Layouts 1.1
import org.subsurfacedivelog.mobile 1.0
import org.kde.kirigami 1.0 as Kirigami
import org.kde.kirigami 2.0 as Kirigami
Item {
id: detailsView

View file

@ -1,9 +1,9 @@
import QtQuick 2.6
import QtQuick.Controls 1.2
import QtQuick.Controls 2.0
import QtQuick.Layouts 1.2
import QtQuick.Window 2.2
import QtQuick.Dialogs 1.2
import org.kde.kirigami 1.0 as Kirigami
import org.kde.kirigami 2.0 as Kirigami
import org.subsurfacedivelog.mobile 1.0
Kirigami.ScrollablePage {
@ -209,11 +209,13 @@ Kirigami.ScrollablePage {
}
}
ScrollView {
Flickable {
id: startPageWrapper
anchors.fill: parent
opacity: credentialStatus === QMLManager.NOCLOUD || (credentialStatus === QMLManager.VALID || credentialStatus === QMLManager.VALID_EMAIL) ? 0 : 1
visible: opacity > 0
contentWidth: width
contentHeight: startPage.height
Behavior on opacity { NumberAnimation { duration: Kirigami.Units.shortDuration } }
onVisibleChanged: {
print("startPageWrapper onVisibleChanged credentialStatus " + credentialStatus + " diveListView.count " + diveListView.count)
@ -233,6 +235,7 @@ Kirigami.ScrollablePage {
title = qsTr("Dive list")
}
}
ScrollBar.vertical: ScrollBar { }
StartPage {
id: startPage
@ -277,14 +280,14 @@ Kirigami.ScrollablePage {
}
}
property QtObject addDiveAction: Action {
property QtObject addDiveAction: Kirigami.Action {
iconName: "list-add"
onTriggered: {
startAddDive()
}
}
property QtObject saveAction: Action {
property QtObject saveAction: Kirigami.Action {
iconName: "document-save"
onTriggered: {
Qt.inputMethod.hide()
@ -292,7 +295,7 @@ Kirigami.ScrollablePage {
}
}
property QtObject offlineAction: Action {
property QtObject offlineAction: Kirigami.Action {
iconName: "qrc:/qml/nocloud.svg"
onTriggered: {
manager.syncToCloud = false

View file

@ -1,11 +1,11 @@
import QtQuick 2.3
import QtQuick.Controls 1.2
import QtQuick.Controls.Styles 1.2
import QtQuick.Controls 1.4 as QQC1
import QtQuick.Controls 2.0
import QtQuick.Window 2.2
import QtQuick.Dialogs 1.2
import QtQuick.Layouts 1.1
import org.subsurfacedivelog.mobile 1.0
import org.kde.kirigami 1.0 as Kirigami
import org.kde.kirigami 2.0 as Kirigami
Kirigami.Page {
id: diveComputerDownloadWindow
@ -17,7 +17,7 @@ Kirigami.Page {
/* this can be done by hitting the back key
contextualActions: [
Action {
Kirigami.Action {
text: qsTr("Close Preferences")
iconName: "dialog-cancel"
onTriggered: {
@ -35,27 +35,27 @@ Kirigami.Page {
RowLayout {
anchors.top:parent.top
Layout.fillWidth: true
Text { text: qsTr(" Vendor name: ") }
Kirigami.Label { text: qsTr(" Vendor name: ") }
ComboBox { Layout.fillWidth: true }
}
RowLayout {
Text { text: qsTr(" Dive Computer:") }
Kirigami.Label { text: qsTr(" Dive Computer:") }
ComboBox { Layout.fillWidth: true }
}
RowLayout {
Text { text: " Progress:" }
Kirigami.Label { text: " Progress:" }
Layout.fillWidth: true
ProgressBar { Layout.fillWidth: true }
}
RowLayout {
SubsurfaceButton {
Button {
text: qsTr("Download")
onClicked: {
text: qsTr("Retry")
stackView.pop();
}
}
SubsurfaceButton {
Button {
id:quitbutton
text: qsTr("Quit")
onClicked: {
@ -64,26 +64,26 @@ Kirigami.Page {
}
}
RowLayout {
Text {
Kirigami.Label {
text: qsTr(" Downloaded dives")
}
}
TableView {
QQC1.TableView {
width: parent.width
Layout.fillWidth: true // The tableview should fill
Layout.fillHeight: true // all remaining vertical space
height: parent.height // on this screen
TableViewColumn {
QQC1.TableViewColumn {
width: parent.width / 2
role: "datetime"
title: qsTr("Date / Time")
}
TableViewColumn {
QQC1.TableViewColumn {
width: parent.width / 4
role: "duration"
title: qsTr("Duration")
}
TableViewColumn {
QQC1.TableViewColumn {
width: parent.width / 4
role: "depth"
title: qsTr("Depth")
@ -91,33 +91,33 @@ Kirigami.Page {
}
RowLayout {
Layout.fillWidth: true
SubsurfaceButton {
Button {
text: qsTr("Accept")
onClicked: {
stackView.pop();
}
}
SubsurfaceButton {
Button {
text: qsTr("Quit")
onClicked: {
stackView.pop();
}
}
Text {
Kirigami.Label {
text: "" // Spacer between 2 button groups
Layout.fillWidth: true
}
SubsurfaceButton {
Button {
text: qsTr("Select All")
}
SubsurfaceButton {
Button {
id: unselectbutton
text: qsTr("Unselect All")
}
}
RowLayout { // spacer to make space for silly button
Layout.minimumHeight: 1.2 * unselectbutton.height
Text {
Kirigami.Label {
text:""
}
}

View file

@ -1,12 +1,10 @@
import QtQuick 2.3
import QtQuick.Controls 1.2
import QtQuick.Controls.Styles 1.2
import QtQuick.Window 2.2
import QtQuick.Dialogs 1.2
import QtQuick.Layouts 1.1
import QtQuick.Window 2.2
import org.subsurfacedivelog.mobile 1.0
import org.kde.kirigami 1.0 as Kirigami
import org.kde.kirigami 2.0 as Kirigami
Kirigami.ScrollablePage {
id: gpsListWindow

View file

@ -1,12 +1,10 @@
import QtQuick 2.3
import QtQuick.Controls 1.2
import QtQuick.Controls.Styles 1.2
import QtQuick.Window 2.2
import QtQuick.Dialogs 1.2
import QtQuick.Layouts 1.1
import QtQuick.Window 2.2
import org.subsurfacedivelog.mobile 1.0
import org.kde.kirigami 1.0 as Kirigami
import org.kde.kirigami 2.0 as Kirigami
Kirigami.ScrollablePage {
id: logWindow

View file

@ -1,16 +1,16 @@
import QtQuick 2.3
import QtQuick.Controls 1.2
import QtQuick.Controls 2.0
import QtQuick.Window 2.2
import QtQuick.Dialogs 1.2
import QtQuick.Layouts 1.1
import org.kde.kirigami 1.0 as Kirigami
import org.kde.kirigami 2.0 as Kirigami
import org.subsurfacedivelog.mobile 1.0
Kirigami.Page {
title: qsTr("Preferences")
actions {
main: Action {
main: Kirigami.Action {
text: qsTr("Save")
iconName: "document-save"
onTriggered: {
@ -52,7 +52,7 @@ Kirigami.Page {
Layout.alignment: Qt.AlignRight
}
StyledTextField {
TextField {
id: distanceThreshold
text: manager.distanceThreshold
Layout.fillWidth: true
@ -63,7 +63,7 @@ Kirigami.Page {
Layout.alignment: Qt.AlignRight
}
StyledTextField {
TextField {
id: timeThreshold
text: manager.timeThreshold
Layout.fillWidth: true

View file

@ -1,8 +1,6 @@
import QtQuick 2.5
import QtQuick.Controls 1.2
import QtQuick.Controls.Styles 1.2
import QtQuick.Layouts 1.1
import org.kde.kirigami 1.0 as Kirigami
import org.kde.kirigami 2.0 as Kirigami
import org.subsurfacedivelog.mobile 1.0
ColumnLayout {

View file

@ -1,17 +0,0 @@
import QtQuick 2.3
import QtQuick.Controls 1.2
import QtQuick.Controls.Styles 1.2
TextField {
property bool fixed: false
readOnly: fixed
style: TextFieldStyle {
background: Rectangle {
color: fixed ? "transparent" : "white"
radius: 4
border.width: 0.5
border.color: fixed ? "transparent" : "#c0c0c0"
}
}
}

View file

@ -1,26 +0,0 @@
import QtQuick 2.5
import QtQuick.Controls 1.2
import QtQuick.Controls.Styles 1.2
import org.kde.kirigami 1.0 as Kirigami
Button {
style: ButtonStyle {
padding {
top: Kirigami.Units.smallSpacing * 2
left: Kirigami.Units.smallSpacing * 4
right: Kirigami.Units.smallSpacing * 4
bottom: Kirigami.Units.smallSpacing * 2
}
background: Rectangle {
border.width: 1
radius: height / 3
color: control.pressed ? subsurfaceTheme.shadedColor : subsurfaceTheme.accentColor
}
label: Text{
text: control.text
color: subsurfaceTheme.accentTextColor
verticalAlignment: Text.AlignVCenter
horizontalAlignment: Text.AlignHCenter
}
}
}

View file

@ -1,8 +1,7 @@
import QtQuick 2.5
import QtQuick.Controls 1.4
import QtQuick.Layouts 1.1
import QtQuick.Window 2.2
import org.kde.kirigami 1.0 as Kirigami
import org.kde.kirigami 2.0 as Kirigami
Kirigami.Page {

View file

@ -1,12 +1,11 @@
import QtQuick 2.4
import QtQuick.Controls 1.2
import QtQuick.Controls.Styles 1.2
import QtQuick.Controls 2.0
import QtQuick.Window 2.2
import QtQuick.Dialogs 1.2
import QtQuick.Layouts 1.1
import QtQuick.Window 2.2
import org.subsurfacedivelog.mobile 1.0
import org.kde.kirigami 1.0 as Kirigami
import org.kde.kirigami 2.0 as Kirigami
Kirigami.ApplicationWindow {
id: rootItem

View file

@ -13,9 +13,7 @@
<file>Log.qml</file>
<file>ThemeTest.qml</file>
<file>StartPage.qml</file>
<file>StyledTextField.qml</file>
<file>dive.jpg</file>
<file>SubsurfaceButton.qml</file>
<file alias="subsurface-mobile-icon.png">../../icons/subsurface-mobile-icon.png</file>
<file alias="main-menu.png">icons/main-menu.png</file>
<file alias="context-menu.png">icons/context-menu.png</file>
@ -24,6 +22,7 @@
<file alias="nocloud.svg">icons/nocloud.svg</file>
</qresource>
<qresource prefix="/">
<file>qtquickcontrols2.conf</file>
<file alias="icons/go-next.svg">kirigami/icons/go-next.svg</file>
<file alias="icons/go-previous.svg">kirigami/icons/go-previous.svg</file>
<file alias="icons/handle-left.svg">kirigami/icons/handle-left.svg</file>

View file

@ -0,0 +1,11 @@
[Controls]
Style=Material
[Material]
Primary=#2d5b9a
Accent=#2d5b9a
Theme=System
[Universal]
Accent=#2d5b9a
Theme=System

View file

@ -26,12 +26,12 @@ fi
# or SHAs from upstream
cd $SRC
if [ ! -d kirigami ] ; then
git clone -b Kirigami/1.1 git://github.com/KDE/kirigami
git clone -b master git://github.com/KDE/kirigami
fi
if [ "$NOPULL" = "" ] ; then
pushd kirigami
git checkout Kirigami/1.1
git pull origin Kirigami/1.1
git checkout master
git pull origin master
popd
fi
if [ ! -d breeze-icons ] ; then

View file

@ -20,6 +20,7 @@
int main(int argc, char **argv)
{
int i;
QGuiApplication::setAttribute(Qt::AA_EnableHighDpiScaling);
QLoggingCategory::setFilterRules(QStringLiteral("qt.bluetooth* = true"));
QApplication *application = new QApplication(argc, argv);
(void)application;