From 283f3d6512ac7de4a1857e9d484536cdce07c324 Mon Sep 17 00:00:00 2001 From: Danfro Date: Fri, 17 Sep 2021 21:44:15 +0200 Subject: [PATCH 1/2] fix #208 by adding a dialog to notice the user that network is needed --- po/com.ubuntu.calendar.pot | 16 +++++++++++++--- qml/CalendarChoicePopup.qml | 19 ++++++++++++++++++- 2 files changed, 31 insertions(+), 4 deletions(-) diff --git a/po/com.ubuntu.calendar.pot b/po/com.ubuntu.calendar.pot index 46326530..f14f28ee 100644 --- a/po/com.ubuntu.calendar.pot +++ b/po/com.ubuntu.calendar.pot @@ -230,20 +230,30 @@ msgstr "" msgid "Add online Calendar" msgstr "" -#: ../qml/CalendarChoicePopup.qml:184 +#: ../qml/CalendarChoicePopup.qml:188 msgid "Unable to deselect" msgstr "" -#: ../qml/CalendarChoicePopup.qml:185 +#: ../qml/CalendarChoicePopup.qml:189 msgid "" "In order to create new events you must have at least one writable calendar " "selected" msgstr "" -#: ../qml/CalendarChoicePopup.qml:187 +#: ../qml/CalendarChoicePopup.qml:191 ../qml/CalendarChoicePopup.qml:204 msgid "Ok" msgstr "" +#: ../qml/CalendarChoicePopup.qml:201 +msgid "Network required" +msgstr "" + +#: ../qml/CalendarChoicePopup.qml:202 +msgid "" +"You are currently offline. In order to add online accounts you must have " +"network connection available." +msgstr "" + #: ../qml/RemindersPage.qml:62 msgid "Custom reminder" msgstr "" diff --git a/qml/CalendarChoicePopup.qml b/qml/CalendarChoicePopup.qml index 30fb56c3..0d254ded 100644 --- a/qml/CalendarChoicePopup.qml +++ b/qml/CalendarChoicePopup.qml @@ -91,7 +91,11 @@ Page { } onClicked: { - onlineAccountHelper.item.run() + if (syncMonitor.serviceIsEnabled("calendar")) { + onlineAccountHelper.item.run() + } else { + PopupUtils.open(offlineErrorComponent); + } } } @@ -189,4 +193,17 @@ Page { } } } + + Component { + id: offlineErrorComponent + Dialog { + id: offlineErrorDialog + title: i18n.tr("Network required") + text: i18n.tr("You are currently offline. In order to add online accounts you must have network connection available.") + Button { + text: i18n.tr("Ok") + onClicked: PopupUtils.close(offlineErrorDialog) + } + } + } } -- GitLab From df24cff363e32b3d3daf4356d32a5113f6dba767 Mon Sep 17 00:00:00 2001 From: Danfro Date: Sun, 3 Oct 2021 20:40:53 +0200 Subject: [PATCH 2/2] implement check for network adapted from weather app --- qml/CalendarChoicePopup.qml | 9 +++++---- qml/calendar.qml | 13 +++++++++++++ 2 files changed, 18 insertions(+), 4 deletions(-) diff --git a/qml/CalendarChoicePopup.qml b/qml/CalendarChoicePopup.qml index 0d254ded..123d4343 100644 --- a/qml/CalendarChoicePopup.qml +++ b/qml/CalendarChoicePopup.qml @@ -23,6 +23,7 @@ import Ubuntu.SyncMonitor 0.1 import Ubuntu.Components.Popups 1.3 import Ubuntu.OnlineAccounts 0.1 + Page { id: calendarChoicePage objectName: "calendarchoicepopup" @@ -58,7 +59,7 @@ Page { text: enabled ? i18n.tr("Sync") : i18n.tr("Syncing") onTriggered: syncMonitor.sync(["calendar"]) enabled: (syncMonitor.state !== "syncing") - visible: syncMonitor.enabledServices ? syncMonitor.serviceIsEnabled("calendar") : false + visible: !networkError } flickable: calendarsList } @@ -91,7 +92,7 @@ Page { } onClicked: { - if (syncMonitor.serviceIsEnabled("calendar")) { + if (!networkError) { onlineAccountHelper.item.run() } else { PopupUtils.open(offlineErrorComponent); @@ -182,13 +183,13 @@ Page { } Component { - id: singleWritableDialogComponent + id: singleWritableDialogComponent Dialog { id: singleWritableDialog title: i18n.tr("Unable to deselect") text: i18n.tr("In order to create new events you must have at least one writable calendar selected") Button { - text: i18n.tr("Ok") + text: i18n.tr("Ok") onClicked: PopupUtils.close(singleWritableDialog) } } diff --git a/qml/calendar.qml b/qml/calendar.qml index 86b10caf..a283ee48 100644 --- a/qml/calendar.qml +++ b/qml/calendar.qml @@ -21,6 +21,7 @@ import Ubuntu.Components.Popups 1.3 import QtOrganizer 5.0 import Ubuntu.SyncMonitor 0.1 import Qt.labs.settings 1.0 +import Ubuntu.Connectivity 1.0 import "dateExt.js" as DateExt @@ -161,6 +162,18 @@ MainView { } } + /* + Indicates network status + see https://api-docs.ubports.com/sdk/apps/qml/Ubuntu.Connectivity/NetworkingStatus.html + */ + property bool networkError //derived from Connectivity, only set false for desktop mode + property var statusMap: ["Offline", "Connecting", "Online"] + + Connections { + target: Connectivity + onOnlineChanged: networkError = Connectivity.online ? false : true + } + PageStack { id: pageStack -- GitLab