From 13a248b4b48ab10175ef80442f1b7edc534b40a7 Mon Sep 17 00:00:00 2001 From: Dylan Van Assche Date: Mon, 14 May 2018 13:05:30 +0200 Subject: [PATCH 1/3] Cover support, fixed #173 --- harbour-sailfinder.desktop | 2 +- harbour-sailfinder.pro | 7 +- qml/components/MatchesCover.qml | 62 +++++++++++++++++ qml/components/ProfileCover.qml | 59 +++++++++++++++++ qml/components/RecommendationsCover.qml | 88 +++++++++++++++++++++++++ qml/components/TextLabel.qml | 12 ++-- qml/cover/CoverPage.qml | 27 -------- qml/harbour-sailfinder.qml | 3 +- qml/pages/CoverPage.qml | 57 ++++++++++++++++ qml/pages/MainPage.qml | 1 + rpm/harbour-sailfinder.changes | 1 + rpm/harbour-sailfinder.spec.7918 | 73 ++++++++++++++++++++ src/harbour-sailfinder.cpp | 75 +++++++++++---------- src/models/matcheslistmodel.cpp | 4 ++ src/models/matcheslistmodel.h | 1 + src/models/photolistmodel.cpp | 2 +- 16 files changed, 402 insertions(+), 72 deletions(-) create mode 100644 qml/components/MatchesCover.qml create mode 100644 qml/components/ProfileCover.qml create mode 100644 qml/components/RecommendationsCover.qml delete mode 100644 qml/cover/CoverPage.qml create mode 100644 qml/pages/CoverPage.qml create mode 100644 rpm/harbour-sailfinder.spec.7918 diff --git a/harbour-sailfinder.desktop b/harbour-sailfinder.desktop index 6024b3c..d156baa 100644 --- a/harbour-sailfinder.desktop +++ b/harbour-sailfinder.desktop @@ -2,5 +2,5 @@ Type=Application X-Nemo-Application-Type=silica-qt5 Icon=harbour-sailfinder -Exec=harbour-sailfinder +Exec=invoker --type=silica-qt5 -s /usr/bin/harbour-sailfinder Name=Sailfinder diff --git a/harbour-sailfinder.pro b/harbour-sailfinder.pro index a35c116..7daebc5 100644 --- a/harbour-sailfinder.pro +++ b/harbour-sailfinder.pro @@ -59,7 +59,7 @@ SOURCES += src/harbour-sailfinder.cpp \ src/models/matcheslistmodel.cpp DISTFILES += qml/harbour-sailfinder.qml \ - qml/cover/CoverPage.qml \ + qml/pages/CoverPage.qml \ qml/pages/FirstPage.qml \ qml/pages/MainPage.qml \ qml/pages/AboutPage.qml \ @@ -85,7 +85,10 @@ DISTFILES += qml/harbour-sailfinder.qml \ harbour-sailfinder.desktop \ rpm/harbour-sailfinder.changes \ qml/js/authentication.js \ - qml/css/authentication.css + qml/css/authentication.css \ + qml/components/RecommendationsCover.qml \ + qml/components/MatchesCover.qml \ + qml/components/ProfileCover.qml SAILFISHAPP_ICONS = 86x86 108x108 128x128 256x256 diff --git a/qml/components/MatchesCover.qml b/qml/components/MatchesCover.qml new file mode 100644 index 0000000..58692d2 --- /dev/null +++ b/qml/components/MatchesCover.qml @@ -0,0 +1,62 @@ +/* +* This file is part of Sailfinder. +* +* Sailfinder is free software: you can redistribute it and/or modify +* it under the terms of the GNU General Public License as published by +* the Free Software Foundation, either version 3 of the License, or +* (at your option) any later version. +* +* Sailfinder is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with Sailfinder. If not, see . +*/ + +import QtQuick 2.0 +import Sailfish.Silica 1.0 + +Item { + anchors.fill: parent + + Component.onCompleted: { + try { + numberOfMatches.text = api.matchesList.numberOfMatches() + } + catch(err) { + console.debug("Matches cover data not ready yet") + } + } + + Connections { + target: api + onMatchesListChanged: { + console.debug("Cover number of matches=" + api.matchesList.numberOfMatches()) + numberOfMatches.text = api.matchesList.numberOfMatches() + } + } + + Column { + width: parent.width + anchors.centerIn: parent + + TextLabel { + id: numberOfMatches + horizontalAlignment: Text.AlignHCenter + font.pixelSize: Theme.fontSizeExtraLarge + font.bold: true + visible: text.length > 0 + } + + + TextLabel { + horizontalAlignment: Text.AlignHCenter + font.pixelSize: Theme.fontSizeExtraLarge + //% "Matches" + text: qsTrId("sailfinder-matches") + font.bold: numberOfMatches.text.length == 0 // no matches yet + } + } +} diff --git a/qml/components/ProfileCover.qml b/qml/components/ProfileCover.qml new file mode 100644 index 0000000..2db40c3 --- /dev/null +++ b/qml/components/ProfileCover.qml @@ -0,0 +1,59 @@ +/* +* This file is part of Sailfinder. +* +* Sailfinder is free software: you can redistribute it and/or modify +* it under the terms of the GNU General Public License as published by +* the Free Software Foundation, either version 3 of the License, or +* (at your option) any later version. +* +* Sailfinder is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with Sailfinder. If not, see . +*/ + +import QtQuick 2.0 +import Sailfish.Silica 1.0 + +Item { + anchors.fill: parent + + Component.onCompleted: { + try { + background.source = api.profile.photos.getPhoto(0).url + } + catch(err) { + console.debug("Profile cover data not ready yet") + } + } + + Connections { + target: api + onProfileChanged: background.source = api.profile.photos.getPhoto(0).url + } + + Image { + id: background + anchors.fill: parent + asynchronous: true + opacity: progress/3 // background + Behavior on opacity { FadeAnimator {} } + onStatusChanged: { + if(status == Image.Error) { + console.warn("Can't load image as cover background") + } + } + } + + TextLabel { + anchors.centerIn: parent + horizontalAlignment: Text.AlignHCenter + font.pixelSize: Theme.fontSizeExtraLarge + font.bold: true + //% "Profile" + text: qsTrId("sailfinder-profile") + } +} diff --git a/qml/components/RecommendationsCover.qml b/qml/components/RecommendationsCover.qml new file mode 100644 index 0000000..061521f --- /dev/null +++ b/qml/components/RecommendationsCover.qml @@ -0,0 +1,88 @@ +/* +* This file is part of Sailfinder. +* +* Sailfinder is free software: you can redistribute it and/or modify +* it under the terms of the GNU General Public License as published by +* the Free Software Foundation, either version 3 of the License, or +* (at your option) any later version. +* +* Sailfinder is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with Sailfinder. If not, see . +*/ + +import QtQuick 2.0 +import Sailfish.Silica 1.0 + +Item { + anchors.fill: parent + + Component.onCompleted: { + try { + background.source = api.recommendation.photos.getPhoto(0).url + name.text = api.recommendation.name + distance.text = api.recommendation.distance + " km" + } + catch(err) { + console.debug("Recommendations cover data not ready yet") + } + } + + Connections { + target: api + onRecommendationChanged: { + background.source = api.recommendation.photos.getPhoto(0).url + name.text = api.recommendation.name + distance.text = api.recommendation.distance + " km" + } + } + + Image { + id: background + anchors.fill: parent + asynchronous: true + opacity: progress/3 // background + Behavior on opacity { FadeAnimator {} } + onStatusChanged: { + if(status == Image.Error) { + console.warn("Can't load image as cover background") + } + } + } + + Column { + anchors.centerIn: parent + width: parent.width + + TextLabel { + id: name + horizontalAlignment: Text.AlignHCenter + font.pixelSize: Theme.fontSizeExtraLarge + font.bold: true + } + + TextLabel { + id: distance + horizontalAlignment: Text.AlignHCenter + font.pixelSize: Theme.fontSizeLarge + } + } + + CoverActionList { + iconBackground: true + + CoverAction { + iconSource: "../resources/images/dislike.png" + onTriggered: api.passUser(api.recommendation.id) + } + + CoverAction { + iconSource: "../resources/images/like.png" + onTriggered: api.likeUser(api.recommendation.id) + } + } +} diff --git a/qml/components/TextLabel.qml b/qml/components/TextLabel.qml index 92ac9e6..25abc0f 100644 --- a/qml/components/TextLabel.qml +++ b/qml/components/TextLabel.qml @@ -18,11 +18,15 @@ import QtQuick 2.2 import Sailfish.Silica 1.0 Label { - anchors { left: parent.left; right: parent.right; leftMargin: Theme.horizontalPageMargin; rightMargin: Theme.horizontalPageMargin } + anchors { + left: parent.left + right: parent.right + leftMargin: Theme.horizontalPageMargin + rightMargin: Theme.horizontalPageMargin + } font.pixelSize: Theme.fontSizeMedium wrapMode: Text.WordWrap + truncationMode: TruncationMode.Fade - Behavior on opacity { - FadeAnimation {} - } + Behavior on opacity { FadeAnimation {} } } diff --git a/qml/cover/CoverPage.qml b/qml/cover/CoverPage.qml deleted file mode 100644 index 279a054..0000000 --- a/qml/cover/CoverPage.qml +++ /dev/null @@ -1,27 +0,0 @@ -/* -* This file is part of Sailfinder. -* -* Sailfinder is free software: you can redistribute it and/or modify -* it under the terms of the GNU General Public License as published by -* the Free Software Foundation, either version 3 of the License, or -* (at your option) any later version. -* -* Sailfinder is distributed in the hope that it will be useful, -* but WITHOUT ANY WARRANTY; without even the implied warranty of -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -* GNU General Public License for more details. -* -* You should have received a copy of the GNU General Public License -* along with Sailfinder. If not, see . -*/ - -import QtQuick 2.0 -import Sailfish.Silica 1.0 - -CoverBackground { - Label { - anchors.centerIn: parent - text: "Sailfinder" - } -} - diff --git a/qml/harbour-sailfinder.qml b/qml/harbour-sailfinder.qml index aa3c786..ab9d95c 100644 --- a/qml/harbour-sailfinder.qml +++ b/qml/harbour-sailfinder.qml @@ -26,10 +26,11 @@ import "pages" ApplicationWindow { property bool networkStatus + property int swipeViewIndex: 0 id: app initialPage: Component { FirstPage { } } - cover: Qt.resolvedUrl("cover/CoverPage.qml") + cover: Qt.resolvedUrl("pages/CoverPage.qml") allowedOrientations: defaultAllowedOrientations onNetworkStatusChanged: { if(networkStatus == false) { diff --git a/qml/pages/CoverPage.qml b/qml/pages/CoverPage.qml new file mode 100644 index 0000000..b8790b6 --- /dev/null +++ b/qml/pages/CoverPage.qml @@ -0,0 +1,57 @@ +/* +* This file is part of Sailfinder. +* +* Sailfinder is free software: you can redistribute it and/or modify +* it under the terms of the GNU General Public License as published by +* the Free Software Foundation, either version 3 of the License, or +* (at your option) any later version. +* +* Sailfinder is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with Sailfinder. If not, see . +*/ + +import QtQuick 2.0 +import Sailfish.Silica 1.0 +import "../components" + +CoverBackground { + id: cover + property bool _loading + + Loader { + anchors.fill: parent + asynchronous: true + source: switch(app.swipeViewIndex) { + case 1: // MatchesView + return "../components/MatchesCover.qml" + case 2: // ProfileView + return "../components/ProfileCover.qml" + case 0: // RecommendationsView + default: + return "../components/RecommendationsCover.qml" + } + onStatusChanged: { + if(status == Loader.Ready) { + _loading = false + } + else { + _loading = true + if(status == Loader.Error) { + console.warn("Can't load QML component") + } + } + } + } + + BusyIndicator { + anchors.centerIn: parent + size: BusyIndicatorSize.Medium + running: !Qt.application.active && _loading + } +} + diff --git a/qml/pages/MainPage.qml b/qml/pages/MainPage.qml index 93640e2..8f884aa 100644 --- a/qml/pages/MainPage.qml +++ b/qml/pages/MainPage.qml @@ -148,6 +148,7 @@ Page { onHeaderChanged: swipeView._profileHeader = text } } + onCurrentIndexChanged: app.swipeViewIndex = currentIndex } NavigationBar { diff --git a/rpm/harbour-sailfinder.changes b/rpm/harbour-sailfinder.changes index ef3cfae..e22e1cd 100644 --- a/rpm/harbour-sailfinder.changes +++ b/rpm/harbour-sailfinder.changes @@ -4,6 +4,7 @@ - [IMPROVEMENT] Remorse action used when needed - [IMPROVEMENT] Stability improvements for the login screen - [IMPROVEMENT] Location updates are still working OK +- [NEW] SFOS cover when Sailfinder is minimized - [NEW] Delete pictures from Tinder (hold a profile picture to show remove screen) - [NEW] Opt-in for Smart Photo's - [NEW] Moved to OBS for building RPM's diff --git a/rpm/harbour-sailfinder.spec.7918 b/rpm/harbour-sailfinder.spec.7918 new file mode 100644 index 0000000..c96c565 --- /dev/null +++ b/rpm/harbour-sailfinder.spec.7918 @@ -0,0 +1,73 @@ +# +# Do NOT Edit the Auto-generated Part! +# Generated by: spectacle version 0.27 +# + +Name: harbour-sailfinder + +# >> macros +# << macros + +%{!?qtc_qmake:%define qtc_qmake %qmake} +%{!?qtc_qmake5:%define qtc_qmake5 %qmake5} +%{!?qtc_make:%define qtc_make make} +%{?qtc_builddir:%define _builddir %qtc_builddir} +Summary: Sailfinder +Version: 4.4 +Release: 4 +Group: Qt/Qt +License: GPLv3 +URL: https://github.com/DylanVanAssche/harbour-sailfinder +Source0: %{name}-%{version}.tar.bz2 +Source100: harbour-sailfinder.yaml +Requires: sailfishsilica-qt5 >= 0.10.9 +Requires: nemo-qml-plugin-notifications-qt5 +Requires: nemo-qml-plugin-configuration-qt5 +BuildRequires: pkgconfig(sailfishapp) >= 1.0.2 +BuildRequires: pkgconfig(Qt5Core) +BuildRequires: pkgconfig(Qt5Qml) +BuildRequires: pkgconfig(Qt5Quick) +BuildRequires: desktop-file-utils + +%description +Sailfinder is a Sailfish OS application to have fun on Tinder. + +%prep +%setup -q -n %{name}-%{version} + +# >> setup +# << setup + +%build +# >> build pre +# << build pre + +%qtc_qmake5 \ + VERSION=%{version} + +%qtc_make %{?_smp_mflags} + +# >> build post +# << build post + +%install +rm -rf %{buildroot} +# >> install pre +# << install pre +%qmake5_install + +# >> install post +# << install post + +desktop-file-install --delete-original \ + --dir %{buildroot}%{_datadir}/applications \ + %{buildroot}%{_datadir}/applications/*.desktop + +%files +%defattr(-,root,root,-) +%{_bindir} +%{_datadir}/%{name} +%{_datadir}/applications/%{name}.desktop +%{_datadir}/icons/hicolor/*/apps/%{name}.png +# >> files +# << files diff --git a/src/harbour-sailfinder.cpp b/src/harbour-sailfinder.cpp index 5046dbd..9332fba 100644 --- a/src/harbour-sailfinder.cpp +++ b/src/harbour-sailfinder.cpp @@ -33,46 +33,49 @@ int main(int argc, char *argv[]) { - // Set up qml engine. - QScopedPointer app(SailfishApp::application(argc, argv)); - QScopedPointer view(SailfishApp::createView()); - qApp->setApplicationVersion(QString(APP_VERSION)); + // Enforce QT_OPENGL_NO_BGRA for Xperia X + //qputenv("QT_OPENGL_NO_BGRA", "1"); - // Set application version and enable logging - enableLogger(false); + // Set up qml engine. + QScopedPointer app(SailfishApp::application(argc, argv)); + QScopedPointer view(SailfishApp::createView()); + qApp->setApplicationVersion(QString(APP_VERSION)); - // Enable default translations - QTranslator *translator = new QTranslator(qApp); - QString trPath = SailfishApp::pathTo(QStringLiteral("translations")).toLocalFile(); - QString appName = app->applicationName(); - // Check if translations have been already loaded - if (!translator->load(QLocale::system(), appName, "-", trPath)) - { - // Load default translations if not - translator->load(appName, trPath); - app->installTranslator(translator); - } - else - { - translator->deleteLater(); - } + // Set application version and enable logging + enableLogger(false); - // Register custom QML modules - qmlRegisterUncreatableType("Harbour.Sailfinder.Models", 1, 0, "User", "read only"); - qmlRegisterUncreatableType("Harbour.Sailfinder.Models", 1, 0, "Person", "read only"); - qmlRegisterUncreatableType("Harbour.Sailfinder.Models", 1, 0, "Recommendation", "read only"); - qmlRegisterUncreatableType("Harbour.Sailfinder.Models", 1, 0, "Match", "read only"); - qmlRegisterUncreatableType("Harbour.Sailfinder.Models", 1, 0, "Photo", "read only"); - qmlRegisterUncreatableType("Harbour.Sailfinder.Models", 1, 0, "Message", "read only"); - qmlRegisterUncreatableType("Harbour.Sailfinder.Models", 1, 0, "School", "read only"); - qmlRegisterUncreatableType("Harbour.Sailfinder.Models", 1, 0, "Job", "read only"); - qmlRegisterUncreatableType("Harbour.Sailfinder.Models", 1, 0, "Sailfinder", "read only"); - qmlRegisterType("Harbour.Sailfinder.API", 1, 0, "API"); - qmlRegisterType("Harbour.Sailfinder.SFOS", 1, 0, "SFOS"); + // Enable default translations + QTranslator *translator = new QTranslator(qApp); + QString trPath = SailfishApp::pathTo(QStringLiteral("translations")).toLocalFile(); + QString appName = app->applicationName(); + // Check if translations have been already loaded + if(!translator->load(QLocale::system(), appName, "-", trPath)) + { + // Load default translations if not + translator->load(appName, trPath); + app->installTranslator(translator); + } + else + { + translator->deleteLater(); + } - // Start the application. - view->setSource(SailfishApp::pathTo("qml/harbour-sailfinder.qml")); - view->show(); + // Register custom QML modules + qmlRegisterUncreatableType("Harbour.Sailfinder.Models", 1, 0, "User", "read only"); + qmlRegisterUncreatableType("Harbour.Sailfinder.Models", 1, 0, "Person", "read only"); + qmlRegisterUncreatableType("Harbour.Sailfinder.Models", 1, 0, "Recommendation", "read only"); + qmlRegisterUncreatableType("Harbour.Sailfinder.Models", 1, 0, "Match", "read only"); + qmlRegisterUncreatableType("Harbour.Sailfinder.Models", 1, 0, "Photo", "read only"); + qmlRegisterUncreatableType("Harbour.Sailfinder.Models", 1, 0, "Message", "read only"); + qmlRegisterUncreatableType("Harbour.Sailfinder.Models", 1, 0, "School", "read only"); + qmlRegisterUncreatableType("Harbour.Sailfinder.Models", 1, 0, "Job", "read only"); + qmlRegisterUncreatableType("Harbour.Sailfinder.Models", 1, 0, "Sailfinder", "read only"); + qmlRegisterType("Harbour.Sailfinder.API", 1, 0, "API"); + qmlRegisterType("Harbour.Sailfinder.SFOS", 1, 0, "SFOS"); + + // Start the application. + view->setSource(SailfishApp::pathTo("qml/harbour-sailfinder.qml")); + view->show(); return app->exec(); } diff --git a/src/models/matcheslistmodel.cpp b/src/models/matcheslistmodel.cpp index 131591e..1e81fac 100644 --- a/src/models/matcheslistmodel.cpp +++ b/src/models/matcheslistmodel.cpp @@ -149,4 +149,8 @@ void MatchesListModel::updateMatchLastMessage(const QString &matchId, Message *l this->endResetModel(); } +int MatchesListModel::numberOfMatches() +{ + return this->matchesList().count(); +} diff --git a/src/models/matcheslistmodel.h b/src/models/matcheslistmodel.h index dc9b0ff..af68f63 100644 --- a/src/models/matcheslistmodel.h +++ b/src/models/matcheslistmodel.h @@ -58,6 +58,7 @@ class MatchesListModel : public QAbstractListModel QList matchesList() const; void setMatchesList(const QList &matchesList); void updateMatchLastMessage(const QString &matchId, Message* lastMessage); + Q_INVOKABLE int numberOfMatches(); protected: QHash roleNames() const; diff --git a/src/models/photolistmodel.cpp b/src/models/photolistmodel.cpp index d09ae5a..a471318 100644 --- a/src/models/photolistmodel.cpp +++ b/src/models/photolistmodel.cpp @@ -21,7 +21,7 @@ PhotoListModel::~PhotoListModel() Photo* PhotoListModel::getPhoto(int index) { - if(index < this->photoList().length() && index > 0) { + if(index < this->photoList().length() && index >= 0) { return this->photoList().at(index); } return new Photo(QString("NA"), QUrl("")); From fad8175aa9f14149c94f92422893d1cd9afba749 Mon Sep 17 00:00:00 2001 From: Dylan Van Assche Date: Mon, 14 May 2018 15:03:30 +0200 Subject: [PATCH 2/3] Added DefaultCover + bugfixing + nice Repeater background for matches --- harbour-sailfinder.pro | 3 +- qml/components/DefaultCover.qml | 40 +++++++++++++++++ qml/components/MatchesCover.qml | 50 +++++++++++++++++---- qml/components/PhotoGridLayout.qml | 1 + qml/components/ProfileCover.qml | 30 ++++++++----- qml/components/RecommendationsCover.qml | 59 ++++++++++++++++++------- qml/harbour-sailfinder.qml | 2 +- qml/pages/CoverPage.qml | 48 ++++++++------------ rpm/harbour-sailfinder.changes | 1 + src/harbour-sailfinder.cpp | 2 +- 10 files changed, 169 insertions(+), 67 deletions(-) create mode 100644 qml/components/DefaultCover.qml diff --git a/harbour-sailfinder.pro b/harbour-sailfinder.pro index 7daebc5..f3cd60e 100644 --- a/harbour-sailfinder.pro +++ b/harbour-sailfinder.pro @@ -88,7 +88,8 @@ DISTFILES += qml/harbour-sailfinder.qml \ qml/css/authentication.css \ qml/components/RecommendationsCover.qml \ qml/components/MatchesCover.qml \ - qml/components/ProfileCover.qml + qml/components/ProfileCover.qml \ + qml/components/DefaultCover.qml SAILFISHAPP_ICONS = 86x86 108x108 128x128 256x256 diff --git a/qml/components/DefaultCover.qml b/qml/components/DefaultCover.qml new file mode 100644 index 0000000..181451a --- /dev/null +++ b/qml/components/DefaultCover.qml @@ -0,0 +1,40 @@ +/* +* This file is part of Sailfinder. +* +* Sailfinder is free software: you can redistribute it and/or modify +* it under the terms of the GNU General Public License as published by +* the Free Software Foundation, either version 3 of the License, or +* (at your option) any later version. +* +* Sailfinder is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with Sailfinder. If not, see . +*/ + +import QtQuick 2.0 +import Sailfish.Silica 1.0 + +Item { + anchors.fill: parent + + Column { + width: parent.width + anchors.centerIn: parent + + Image { + width: Theme.itemSizeSmall + anchors.horizontalCenter: parent.horizontalCenter + source: "qrc:///images/cover-logo.png" + } + + TextLabel { + horizontalAlignment: Text.AlignHCenter + font.pixelSize: Theme.fontSizeLarge + text: sfos.appNamePretty + } + } +} diff --git a/qml/components/MatchesCover.qml b/qml/components/MatchesCover.qml index 58692d2..a00b404 100644 --- a/qml/components/MatchesCover.qml +++ b/qml/components/MatchesCover.qml @@ -16,25 +16,59 @@ */ import QtQuick 2.0 +import QtQuick.Layouts 1.1 import Sailfish.Silica 1.0 Item { anchors.fill: parent - Component.onCompleted: { - try { + function populate() { + if(api.matchesList !== "null") { numberOfMatches.text = api.matchesList.numberOfMatches() - } - catch(err) { - console.debug("Matches cover data not ready yet") + repeater.model = api.matchesList } } Connections { target: api - onMatchesListChanged: { - console.debug("Cover number of matches=" + api.matchesList.numberOfMatches()) - numberOfMatches.text = api.matchesList.numberOfMatches() + onMatchesListChanged: populate() + } + + GridLayout { + id: layout + anchors.fill: parent // IMPORTANT: Using GridLayout without this will fail! + columns: 2 + columnSpacing: 0 + rowSpacing: 0 + + Repeater { + id: repeater + + Image { + id: image + width: Layout.columnSpan*parent.width/parent.columns + height: Layout.rowSpan*parent.width/parent.columns + Layout.minimumWidth: width + Layout.minimumHeight: height + Layout.preferredWidth: width + Layout.preferredHeight: height + Layout.maximumWidth: parent.width + Layout.maximumHeight: parent.height + Layout.fillHeight: true + Layout.fillWidth: true + sourceSize.width: width + sourceSize.height: height + source: model.avatar + asynchronous: true + opacity: progress/3 // background + visible: index < rows // limit the number of pictures + Behavior on opacity { FadeAnimator {} } + onStatusChanged: { + if(status == Image.Error) { + console.warn("Can't load image for matches cover") + } + } + } } } diff --git a/qml/components/PhotoGridLayout.qml b/qml/components/PhotoGridLayout.qml index b835267..71f9f13 100644 --- a/qml/components/PhotoGridLayout.qml +++ b/qml/components/PhotoGridLayout.qml @@ -70,6 +70,7 @@ Item { source: model.urlMedium asynchronous: true opacity: progress + visible: index < 6 // Max 6 photos Behavior on opacity { FadeAnimator {} } onStatusChanged: { if(status == Image.Error) { diff --git a/qml/components/ProfileCover.qml b/qml/components/ProfileCover.qml index 2db40c3..2cd2afe 100644 --- a/qml/components/ProfileCover.qml +++ b/qml/components/ProfileCover.qml @@ -21,18 +21,15 @@ import Sailfish.Silica 1.0 Item { anchors.fill: parent - Component.onCompleted: { - try { + function populate() { + if(api.profile !== "null") { background.source = api.profile.photos.getPhoto(0).url } - catch(err) { - console.debug("Profile cover data not ready yet") - } } Connections { target: api - onProfileChanged: background.source = api.profile.photos.getPhoto(0).url + onProfileChanged: populate() } Image { @@ -48,12 +45,21 @@ Item { } } - TextLabel { + Column { + width: parent.width anchors.centerIn: parent - horizontalAlignment: Text.AlignHCenter - font.pixelSize: Theme.fontSizeExtraLarge - font.bold: true - //% "Profile" - text: qsTrId("sailfinder-profile") + + Image { + width: Theme.itemSizeSmall + anchors.horizontalCenter: parent.horizontalCenter + source: "qrc:///images/cover-logo.png" + } + + TextLabel { + horizontalAlignment: Text.AlignHCenter + font.pixelSize: Theme.fontSizeExtraLarge + //% "Profile" + text: qsTrId("sailfinder-profile") + } } } diff --git a/qml/components/RecommendationsCover.qml b/qml/components/RecommendationsCover.qml index 061521f..c2e1bc3 100644 --- a/qml/components/RecommendationsCover.qml +++ b/qml/components/RecommendationsCover.qml @@ -19,33 +19,31 @@ import QtQuick 2.0 import Sailfish.Silica 1.0 Item { - anchors.fill: parent + property bool _loaded + property bool _canLike - Component.onCompleted: { - try { + function populate() { + if(api.recommendation !== "null") { background.source = api.recommendation.photos.getPhoto(0).url name.text = api.recommendation.name distance.text = api.recommendation.distance + " km" - } - catch(err) { - console.debug("Recommendations cover data not ready yet") + _canLike = api.canLike + _loaded = true } } + anchors.fill: parent + Connections { target: api - onRecommendationChanged: { - background.source = api.recommendation.photos.getPhoto(0).url - name.text = api.recommendation.name - distance.text = api.recommendation.distance + " km" - } + onRecommendationChanged: populate() } Image { id: background anchors.fill: parent asynchronous: true - opacity: progress/3 // background + opacity: _canLike? progress/3: 0.0 // background Behavior on opacity { FadeAnimator {} } onStatusChanged: { if(status == Image.Error) { @@ -54,9 +52,12 @@ Item { } } + // Normal recommendations swiping Column { - anchors.centerIn: parent width: parent.width + anchors.centerIn: parent + opacity: _canLike? 1.0: 0.0 + Behavior on opacity { FadeAnimator {} } TextLabel { id: name @@ -72,17 +73,45 @@ Item { } } + // Exhausted swiping + Column { + width: parent.width + anchors.centerIn: parent + opacity: _canLike? 0.0: 1.0 + Behavior on opacity { FadeAnimator {} } + + Image { + width: Theme.itemSizeSmall + anchors.horizontalCenter: parent.horizontalCenter + source: "qrc:///images/cover-logo.png" + } + + TextLabel { + horizontalAlignment: Text.AlignHCenter + font.pixelSize: Theme.fontSizeLarge + //% "Exhausted!" + text: qsTrId("sailfinder-out-of-recs") + } + } + CoverActionList { + enabled: _loaded && app.swipeViewIndex === 0 && _canLike iconBackground: true CoverAction { iconSource: "../resources/images/dislike.png" - onTriggered: api.passUser(api.recommendation.id) + onTriggered: { + _loaded = false + api.passUser(api.recommendation.id) + } } CoverAction { iconSource: "../resources/images/like.png" - onTriggered: api.likeUser(api.recommendation.id) + onTriggered: { + _loaded = false + api.likeUser(api.recommendation.id) + } } } } diff --git a/qml/harbour-sailfinder.qml b/qml/harbour-sailfinder.qml index ab9d95c..655cf0a 100644 --- a/qml/harbour-sailfinder.qml +++ b/qml/harbour-sailfinder.qml @@ -29,7 +29,7 @@ ApplicationWindow property int swipeViewIndex: 0 id: app - initialPage: Component { FirstPage { } } + initialPage: Component { FirstPage {} } cover: Qt.resolvedUrl("pages/CoverPage.qml") allowedOrientations: defaultAllowedOrientations onNetworkStatusChanged: { diff --git a/qml/pages/CoverPage.qml b/qml/pages/CoverPage.qml index b8790b6..99eeb77 100644 --- a/qml/pages/CoverPage.qml +++ b/qml/pages/CoverPage.qml @@ -21,37 +21,27 @@ import "../components" CoverBackground { id: cover - property bool _loading - - Loader { - anchors.fill: parent - asynchronous: true - source: switch(app.swipeViewIndex) { - case 1: // MatchesView - return "../components/MatchesCover.qml" - case 2: // ProfileView - return "../components/ProfileCover.qml" - case 0: // RecommendationsView - default: - return "../components/RecommendationsCover.qml" - } - onStatusChanged: { - if(status == Loader.Ready) { - _loading = false - } - else { - _loading = true - if(status == Loader.Error) { - console.warn("Can't load QML component") - } - } - } + property bool _loading: true + + Connections { + target: api + onAuthenticatedChanged: _loading = false + } + + DefaultCover { + visible: _loading + } + + RecommendationsCover { + visible: app.swipeViewIndex === 0 && !_loading + } + + MatchesCover { + visible: app.swipeViewIndex === 1 && !_loading } - BusyIndicator { - anchors.centerIn: parent - size: BusyIndicatorSize.Medium - running: !Qt.application.active && _loading + ProfileCover { + visible: app.swipeViewIndex === 2 && !_loading } } diff --git a/rpm/harbour-sailfinder.changes b/rpm/harbour-sailfinder.changes index e22e1cd..1d6c7c5 100644 --- a/rpm/harbour-sailfinder.changes +++ b/rpm/harbour-sailfinder.changes @@ -4,6 +4,7 @@ - [IMPROVEMENT] Remorse action used when needed - [IMPROVEMENT] Stability improvements for the login screen - [IMPROVEMENT] Location updates are still working OK +- [IMPROVEMENT] Use Silica booster for faster startup - [NEW] SFOS cover when Sailfinder is minimized - [NEW] Delete pictures from Tinder (hold a profile picture to show remove screen) - [NEW] Opt-in for Smart Photo's diff --git a/src/harbour-sailfinder.cpp b/src/harbour-sailfinder.cpp index 9332fba..7721bbd 100644 --- a/src/harbour-sailfinder.cpp +++ b/src/harbour-sailfinder.cpp @@ -34,7 +34,7 @@ int main(int argc, char *argv[]) { // Enforce QT_OPENGL_NO_BGRA for Xperia X - //qputenv("QT_OPENGL_NO_BGRA", "1"); + qputenv("QT_OPENGL_NO_BGRA", "1"); // Set up qml engine. QScopedPointer app(SailfishApp::application(argc, argv)); From f48731b2b688caeeebcff4c2435dcac1ce11a952 Mon Sep 17 00:00:00 2001 From: Dylan Van Assche Date: Mon, 14 May 2018 15:04:47 +0200 Subject: [PATCH 3/3] Fixed typo --- qml/components/MatchesCover.qml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/qml/components/MatchesCover.qml b/qml/components/MatchesCover.qml index a00b404..29e6c56 100644 --- a/qml/components/MatchesCover.qml +++ b/qml/components/MatchesCover.qml @@ -61,7 +61,7 @@ Item { source: model.avatar asynchronous: true opacity: progress/3 // background - visible: index < rows // limit the number of pictures + visible: index < 8 // limit the number of pictures Behavior on opacity { FadeAnimator {} } onStatusChanged: { if(status == Image.Error) {