Heya, Some more work on the mobile version, especially on the divelist and details.
- bugfix for label overflow in dive list - don't create the expensive profilewidget for every frame painted by the item - kill warnings due to conditional build of subsurface-mobile (#0006) - other cleanups (#0001, #0003) - further layout and styling improvements (all the other patches) Most visible is probably the rework of the dive profile page, aside various text display fixes. Cheers, -- sebas Sebastian Kügler | http://vizZzion.org | http://kde.org
From 61c12edf10e17a8e16ce546eb805f3d0b0dc9606 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sebastian=20K=C3=BCgler?= <[email protected]> Date: Wed, 11 Nov 2015 23:53:04 +0100 Subject: [PATCH 1/8] kill warning MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This line seems to be a left-over from a refactoring. It doesn't do anything, just produces a warning, so just remove it. Signed-off-by: Sebastian Kügler <[email protected]> --- qt-mobile/qml/Log.qml | 1 - 1 file changed, 1 deletion(-) diff --git a/qt-mobile/qml/Log.qml b/qt-mobile/qml/Log.qml index 7d9ddb7..5fff8db 100644 --- a/qt-mobile/qml/Log.qml +++ b/qt-mobile/qml/Log.qml @@ -19,7 +19,6 @@ Item { spacing: 8 Rectangle { - anchors.top: topBar.bottom Layout.fillHeight: true Layout.fillWidth: true Text { -- 2.6.2
From 4f2ffed8f53ff402e9251b621e1b0ad7e69c7300 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sebastian=20K=C3=BCgler?= <[email protected]> Date: Thu, 12 Nov 2015 00:18:57 +0100 Subject: [PATCH 2/8] dpi improvements for small text - word-wrap and style the log message at the bottom, this should fix clipping of error messages down there - introduce units.smallPointSize, which defines a small font size to use for toned-down display elements (e.g. the date in the dive list) - No need to assign the default value to Text.text --- qt-mobile/qml/CloudStorage.qml | 97 ++++++++++++++++++++++++++++++++++++++++++ qt-mobile/qml/DiveList.qml | 1 + qt-mobile/qml/main.qml | 9 ++-- 3 files changed, 103 insertions(+), 4 deletions(-) create mode 100644 qt-mobile/qml/CloudStorage.qml diff --git a/qt-mobile/qml/CloudStorage.qml b/qt-mobile/qml/CloudStorage.qml new file mode 100644 index 0000000..b199be7 --- /dev/null +++ b/qt-mobile/qml/CloudStorage.qml @@ -0,0 +1,97 @@ +import QtQuick 2.3 +import QtQuick.Controls 1.2 +import QtQuick.Window 2.2 +import QtQuick.Dialogs 1.2 +import QtQuick.Layouts 1.1 +import org.subsurfacedivelog.mobile 1.0 + +Item { + id: loginWindow + + signal accept + + property string username: login.text; + property string password: password.text; + property bool issave: savePassword.checked; + + GridLayout { + columns: 2 + anchors.fill: parent + anchors.margins: units.gridUnit + + Label { + text: "Cloud credentials" + Layout.bottomMargin: units.largeSpacing + font.pointSize: units.titlePointSize + Layout.columnSpan: 2 + } + + Label { + text: "Email" + Layout.alignment: Qt.AlignRight + } + + TextField { + id: login + text: manager.cloudUserName + Layout.fillWidth: true + } + + Label { + text: "Password" + Layout.alignment: Qt.AlignRight + } + + TextField { + id: password + text: manager.cloudPassword + echoMode: TextInput.Password + Layout.fillWidth: true + } + + Label { + text: "Show password" + Layout.alignment: Qt.AlignRight + } + + CheckBox { + checked: false + id: showPassword + onCheckedChanged: { + password.echoMode = checked ? TextInput.Normal : TextInput.Password + } + } + + Label { + text: "Remember" + Layout.alignment: Qt.AlignRight + } + + CheckBox { + checked: manager.saveCloudPassword + id: savePassword + } + + Item { width: units.gridUnit; height: width } + Item { + height: saveButton.height + width: saveButton.width + Button { + id: saveButton + text: "Save" + anchors.centerIn: parent + onClicked: { + manager.cloudUserName = login.text + manager.cloudPassword = password.text + manager.saveCloudPassword = savePassword.checked + manager.savePreferences() + stackView.pop() + } + } + } + + Item { + Layout.fillHeight: true + } + } +} diff --git a/qt-mobile/qml/DiveList.qml b/qt-mobile/qml/DiveList.qml index 52f0d6a..a72d34e 100644 --- a/qt-mobile/qml/DiveList.qml +++ b/qt-mobile/qml/DiveList.qml @@ -62,6 +62,7 @@ Rectangle { text: date opacity: 0.6 color: theme.textColor + font.pointSize: units.smallPointSize anchors { right: parent.right top: parent.top diff --git a/qt-mobile/qml/main.qml b/qt-mobile/qml/main.qml index b52fda0..05005bf 100644 --- a/qt-mobile/qml/main.qml +++ b/qt-mobile/qml/main.qml @@ -18,7 +18,8 @@ ApplicationWindow { Theme.Units { id: units - property int titlePointSize: fontMetrics.font.pointSize * 1.5 + property int titlePointSize: Math.round(fontMetrics.font.pointSize * 1.5) + property int smallPointSize: Math.round(fontMetrics.font.pointSize * 0.7) } @@ -125,16 +126,16 @@ ApplicationWindow { id: messageArea height: childrenRect.height Layout.fillWidth: true + color: theme.backgroundColor Text { id: message color: theme.textColor - text: "" + wrapMode: TextEdit.WrapAtWordBoundaryOrAnywhere styleColor: theme.textColor - font.pointSize: 10 + font.pointSize: units.smallPointSize } } - } } } -- 2.6.2
From a0e27c5685be0169bb533577cf1d72dc98f52e01 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sebastian=20K=C3=BCgler?= <[email protected]> Date: Thu, 12 Nov 2015 01:37:18 +0100 Subject: [PATCH 6/8] profilewidget2: Only add actions in desktop version MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This fixes a bunch of warnings in the mobile version where these slots are not defined (see the corresponding header's conditionals). Signed-off-by: Sebastian Kügler <[email protected]> --- profile-widget/profilewidget2.cpp | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/profile-widget/profilewidget2.cpp b/profile-widget/profilewidget2.cpp index ca9eead..eae4b3f 100644 --- a/profile-widget/profilewidget2.cpp +++ b/profile-widget/profilewidget2.cpp @@ -127,6 +127,7 @@ ProfileWidget2::ProfileWidget2(QWidget *parent) : QGraphicsView(parent), setupItemOnScene(); addItemsToScene(); scene()->installEventFilter(this); +#ifndef SUBSURFACE_MOBILE QAction *action = NULL; #define ADD_ACTION(SHORTCUT, Slot) \ action = new QAction(this); \ @@ -143,6 +144,7 @@ ProfileWidget2::ProfileWidget2(QWidget *parent) : QGraphicsView(parent), ADD_ACTION(Qt::Key_Left, keyLeftAction()); ADD_ACTION(Qt::Key_Right, keyRightAction()); #undef ADD_ACTION +#endif // SUBSURFACE_MOBILE #if !defined(QT_NO_DEBUG) && defined(SHOW_PLOT_INFO_TABLE) QTableView *diveDepthTableView = new QTableView(); @@ -1153,10 +1155,12 @@ void ProfileWidget2::setAddState() DivePlannerPointsModel *plannerModel = DivePlannerPointsModel::instance(); connect(plannerModel, SIGNAL(dataChanged(QModelIndex, QModelIndex)), this, SLOT(replot())); connect(plannerModel, SIGNAL(cylinderModelEdited()), this, SLOT(replot())); +#ifndef SUBSURFACE_MOBILE connect(plannerModel, SIGNAL(rowsInserted(const QModelIndex &, int, int)), this, SLOT(pointInserted(const QModelIndex &, int, int))); connect(plannerModel, SIGNAL(rowsRemoved(const QModelIndex &, int, int)), this, SLOT(pointsRemoved(const QModelIndex &, int, int))); +#endif /* show the same stuff that the profile shows. */ currentState = ADD; /* enable the add state. */ diveCeiling->setVisible(true); @@ -1573,11 +1577,12 @@ void ProfileWidget2::disconnectTemporaryConnections() disconnect(plannerModel, SIGNAL(dataChanged(QModelIndex, QModelIndex)), this, SLOT(replot())); disconnect(plannerModel, SIGNAL(cylinderModelEdited()), this, SLOT(replot())); +#ifndef SUBSURFACE_MOBILE disconnect(plannerModel, SIGNAL(rowsInserted(const QModelIndex &, int, int)), this, SLOT(pointInserted(const QModelIndex &, int, int))); disconnect(plannerModel, SIGNAL(rowsRemoved(const QModelIndex &, int, int)), this, SLOT(pointsRemoved(const QModelIndex &, int, int))); - +#endif Q_FOREACH (QAction *action, actionsForKeys.values()) { action->setShortcut(QKeySequence()); action->setShortcutContext(Qt::WidgetShortcut); -- 2.6.2
From aefff0e05ce235c10ed464b859cbf96c6db959c8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sebastian=20K=C3=BCgler?= <[email protected]> Date: Thu, 12 Nov 2015 00:40:13 +0100 Subject: [PATCH 3/8] Simplify anchoring in divedetails MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit anchors.fill does essentially the same, as the item is positioned at 0,0 of the parent by default. Signed-off-by: Sebastian Kügler <[email protected]> --- qt-mobile/qml/DiveDetails.qml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/qt-mobile/qml/DiveDetails.qml b/qt-mobile/qml/DiveDetails.qml index 87078d1..c65c92d 100644 --- a/qt-mobile/qml/DiveDetails.qml +++ b/qt-mobile/qml/DiveDetails.qml @@ -30,8 +30,7 @@ Item { Flickable { id: flick - width: parent.width - anchors { top: parent.top; bottom: parent.bottom } + anchors.fill: parent contentHeight: parent.height clip: true ColumnLayout { -- 2.6.2
From b2b8de4569c93c57e659063986c0152f05d472f6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sebastian=20K=C3=BCgler?= <[email protected]> Date: Thu, 12 Nov 2015 00:43:23 +0100 Subject: [PATCH 4/8] Use styled text items in divedetails MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Using Label instead of text gives us consistent coloring and styling of the text labels. Also remove the boldness to make it comply to the design language used. Signed-off-by: Sebastian Kügler <[email protected]> --- qt-mobile/qml/DiveDetails.qml | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/qt-mobile/qml/DiveDetails.qml b/qt-mobile/qml/DiveDetails.qml index c65c92d..67d4a7d 100644 --- a/qt-mobile/qml/DiveDetails.qml +++ b/qt-mobile/qml/DiveDetails.qml @@ -53,7 +53,7 @@ Item { id: editorDetails width: parent.width columns: 2 - Text { + Label { Layout.columnSpan: 2 Layout.alignment: Qt.AlignHCenter text: "Dive " + number + " (" + date + ")"; font.bold: true @@ -64,19 +64,19 @@ Item { id: qmlProfile height: 500 } - Text { text: "Location:"; font.bold: true } + Label { text: "Location:" } TextField { id: txtLocation; text: location; Layout.fillWidth: true } - Text { text: "Air Temp:"; font.bold: true } + Label { text: "Air Temp:" } TextField { id: txtAirTemp; text: airtemp; Layout.fillWidth: true } - Text { text: "Water Temp:"; font.bold: true } + Label { text: "Water Temp:" } TextField { id: txtWaterTemp; text: watertemp; Layout.fillWidth: true } - Text { text: "Suit:"; font.bold: true } + Label { text: "Suit:" } TextField { id: txtSuit; text: suit; Layout.fillWidth: true } - Text { text: "Buddy:"; font.bold: true } + Label { text: "Buddy:" } TextField { id: txtBuddy; text: buddy; Layout.fillWidth: true } - Text { text: "Dive Master:"; font.bold: true } + Label { text: "Dive Master:" } TextField { id: txtDiveMaster; text: divemaster; Layout.fillWidth: true} - Text { text: "Notes:"; font.bold: true } + Label { text: "Notes:" } TextEdit{ id: txtNotes text: notes -- 2.6.2
From 2182e69172f222387079b0b553aa6b614d1e13cc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sebastian=20K=C3=BCgler?= <[email protected]> Date: Thu, 12 Nov 2015 01:43:13 +0100 Subject: [PATCH 7/8] Cache diveprofile widget in the diveprofile QtQuick item MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - paint() can become a hot path, especially when we think about repainting the item on size changes. In general, it's a really good idea to keep this function as fast as possible, as we want to be able to repaint the item when needed. Also, ProfileWidget is pretty heavy to set up, so rather spend a bit of memory there. - Rename profile to m_profileWidget, it already was member var. - Sizing ... I have to admit I don't understand the rendering of the ProfileWidget. I'd like it to do the following things: - render at native resolution, we don't want to resize it - react to item changes - we want to reset the size and re-render the widget into the item in those cases - perhaps be able to use a couple more of the profilewidget's features Signed-off-by: Sebastian Kügler <[email protected]> --- qt-mobile/qmlprofile.cpp | 24 ++++++++++++++---------- qt-mobile/qmlprofile.h | 4 +++- 2 files changed, 17 insertions(+), 11 deletions(-) diff --git a/qt-mobile/qmlprofile.cpp b/qt-mobile/qmlprofile.cpp index 01b03d1..a4ff8a9 100644 --- a/qt-mobile/qmlprofile.cpp +++ b/qt-mobile/qmlprofile.cpp @@ -6,6 +6,15 @@ QMLProfile::QMLProfile(QQuickItem *parent) : QQuickPaintedItem(parent) { + m_profileWidget = new ProfileWidget2(0); + m_profileWidget->setProfileState(); + m_profileWidget->setToolTipVisibile(false); + //m_profileWidget->setGeometry(this->geometry()); +} + +QMLProfile::~QMLProfile() +{ + m_profileWidget->deleteLater(); } void QMLProfile::paint(QPainter *painter) @@ -18,21 +27,16 @@ void QMLProfile::paint(QPainter *painter) if (!d) return; - - profile = new ProfileWidget2(0); - profile->setProfileState(); - profile->setToolTipVisibile(false); - int old_animation_speed = prefs.animation_speed; prefs.animation_speed = 0; // no animations while rendering the QGraphicsView - profile->plotDive(d); + + m_profileWidget->setGeometry(QRect(x(), y(), width(), height())); + m_profileWidget->plotDive(d); QTransform profileTransform; profileTransform.scale(this->height() / 100, this->height() / 100); - profile->setTransform(profileTransform); - profile->render(painter); + m_profileWidget->setTransform(profileTransform); + m_profileWidget->render(painter); prefs.animation_speed = old_animation_speed; - - profile->deleteLater(); } QString QMLProfile::diveId() const diff --git a/qt-mobile/qmlprofile.h b/qt-mobile/qmlprofile.h index b519291..6cbdd62 100644 --- a/qt-mobile/qmlprofile.h +++ b/qt-mobile/qmlprofile.h @@ -11,6 +11,8 @@ class QMLProfile : public QQuickPaintedItem Q_PROPERTY(QString diveId READ diveId WRITE setDiveId NOTIFY diveIdChanged) public: explicit QMLProfile(QQuickItem *parent = 0); + virtual ~QMLProfile(); + void paint(QPainter *painter); QString diveId() const; @@ -18,7 +20,7 @@ public: private: QString m_diveId; - ProfileWidget2 *profile; + ProfileWidget2 *m_profileWidget; signals: void rightAlignedChanged(); void diveIdChanged(); -- 2.6.2
From f05252a8abef93121deee7f57b2dae253f338f27 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sebastian=20K=C3=BCgler?= <[email protected]> Date: Thu, 12 Nov 2015 01:01:13 +0100 Subject: [PATCH 5/8] Rework divedetails page MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Styled texts - don't put all the properties of the text items in one long line, makes the code more readable and is in line with coding style used throughout. - button and profile move into their own items, button moves to the right (it's more of a contextual item, so it's better placed top right, further more, a control is generally easier to reach on the right without covering information unnecessarily. Code-wise, it's also a more logical encapsulation. - dpi-aware sizing of dive profile, use units.gridUnit instead of hard-coded pixels. Signed-off-by: Sebastian Kügler <[email protected]> --- qt-mobile/qml/DiveDetails.qml | 120 +++++++++++++++++++++++++++++++----------- 1 file changed, 90 insertions(+), 30 deletions(-) diff --git a/qt-mobile/qml/DiveDetails.qml b/qt-mobile/qml/DiveDetails.qml index 67d4a7d..32fa730 100644 --- a/qt-mobile/qml/DiveDetails.qml +++ b/qt-mobile/qml/DiveDetails.qml @@ -37,46 +37,106 @@ Item { width: parent.width spacing: 8 - Button { - text: "Hide Dive Profile" - onClicked: { - qmlProfile.visible = !qmlProfile.visible - if (qmlProfile.visible) { - text = "Hide Dive Profile" - } else { - text = "Show Dive Profile" - } - } - } GridLayout { id: editorDetails width: parent.width columns: 2 + Label { Layout.columnSpan: 2 - Layout.alignment: Qt.AlignHCenter - text: "Dive " + number + " (" + date + ")"; font.bold: true + font.pointSize: units.titlePointSize + text: "Dive " + number + " (" + date + ")" } - QMLProfile { + + Item { Layout.columnSpan: 2 Layout.fillWidth: true - id: qmlProfile - height: 500 - } - Label { text: "Location:" } - TextField { id: txtLocation; text: location; Layout.fillWidth: true } - Label { text: "Air Temp:" } - TextField { id: txtAirTemp; text: airtemp; Layout.fillWidth: true } - Label { text: "Water Temp:" } - TextField { id: txtWaterTemp; text: watertemp; Layout.fillWidth: true } - Label { text: "Suit:" } - TextField { id: txtSuit; text: suit; Layout.fillWidth: true } - Label { text: "Buddy:" } - TextField { id: txtBuddy; text: buddy; Layout.fillWidth: true } - Label { text: "Dive Master:" } - TextField { id: txtDiveMaster; text: divemaster; Layout.fillWidth: true} - Label { text: "Notes:" } + Layout.preferredHeight: qmlProfile.visible ? qmlProfile.height : profileHideButton.height + QMLProfile { + id: qmlProfile + height: units.gridUnit * 25 + anchors { + top: parent.top + left: parent.left + right: parent.right + } + //Rectangle { color: "green"; opacity: 0.4; anchors.fill: parent } // used for debugging the dive profile sizing, will be removed later + } + Button { + id: profileHideButton + anchors { + right: parent.right + top: parent.top + } + text: "Hide Dive Profile" + onClicked: { + qmlProfile.visible = !qmlProfile.visible + if (qmlProfile.visible) { + text = "Hide Dive Profile" + } else { + text = "Show Dive Profile" + } + } + } + } + Label { + text: "Location:" + } + TextField { + id: txtLocation; text: location; + Layout.fillWidth: true + } + + Label { + text: "Air Temp:" + } + TextField { + id: txtAirTemp + text: airtemp + Layout.fillWidth: true + } + + Label { + text: "Water Temp:" + } + TextField { + id: txtWaterTemp + text: watertemp + Layout.fillWidth: true + } + + Label { + text: "Suit:" + + } + TextField { + id: txtSuit + text: suit + Layout.fillWidth: true + } + + Label { + text: "Buddy:" + } + TextField { + id: txtBuddy + text: buddy + Layout.fillWidth: true + } + + Label { + text: "Dive Master:" + } + TextField { + id: txtDiveMaster + text: divemaster + Layout.fillWidth: true + } + + Label { + text: "Notes:" + } TextEdit{ id: txtNotes text: notes -- 2.6.2
From 11a5b92f5b4690ec4fe99325c2c4596bd5d7297f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sebastian=20K=C3=BCgler?= <[email protected]> Date: Thu, 12 Nov 2015 02:13:47 +0100 Subject: [PATCH 8/8] Fix label overflow in divelist MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - anchor the label to the left of the date field - elide the text instead This fixes the bug in the dive list where the dive's location overflowed over the date, especially visible on phones in portrait mode. Signed-off-by: Sebastian Kügler <[email protected]> --- qt-mobile/qml/DiveList.qml | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/qt-mobile/qml/DiveList.qml b/qt-mobile/qml/DiveList.qml index a72d34e..4f147bf 100644 --- a/qt-mobile/qml/DiveList.qml +++ b/qt-mobile/qml/DiveList.qml @@ -51,14 +51,19 @@ Rectangle { id: locationText text: location color: theme.textColor - scale: 1.1 // Let's see how this works, otherwise, we'll need the default point size somewhere + //font.pointSize: Math.round(units.fontMetrics.pointSize * 1.2) // why this doesn't work is a mystery to me, so ... + scale: 1.2 // Let's see how this works, otherwise, we'll need the default point size somewhere transformOrigin: Item.TopLeft + elide: Text.ElideRight + maximumLineCount: 1 // needed for elide to work at all anchors { left: parent.left top: parent.top + right: dateLabel.left } } Text { + id: dateLabel text: date opacity: 0.6 color: theme.textColor -- 2.6.2
_______________________________________________ subsurface mailing list [email protected] http://lists.subsurface-divelog.org/cgi-bin/mailman/listinfo/subsurface
