From 284919a76221dac3062c278450e73dc9e67c6e03 Mon Sep 17 00:00:00 2001 From: Slava Monich Date: Sun, 19 Feb 2023 19:56:26 +0200 Subject: [PATCH] [foilnotes] Added settings page --- app.pro | 31 ++++++------ rpm/harbour-foilnotes.spec | 5 +- settings/harbour-foilnotes.json | 14 ++++++ settings/settings.qml | 67 +++++++++++++++++++++++++ src/FoilNotesDefs.h | 13 ++--- translations/harbour-foilnotes-de.ts | 15 ++++++ translations/harbour-foilnotes-es.ts | 15 ++++++ translations/harbour-foilnotes-fr.ts | 15 ++++++ translations/harbour-foilnotes-pl.ts | 15 ++++++ translations/harbour-foilnotes-ru.ts | 15 ++++++ translations/harbour-foilnotes-sv.ts | 15 ++++++ translations/harbour-foilnotes-zh_CN.ts | 15 ++++++ translations/harbour-foilnotes.ts | 15 ++++++ 13 files changed, 224 insertions(+), 26 deletions(-) create mode 100644 settings/harbour-foilnotes.json create mode 100644 settings/settings.qml diff --git a/app.pro b/app.pro index 6acc970..90a3c8d 100644 --- a/app.pro +++ b/app.pro @@ -1,10 +1,9 @@ +PREFIX = harbour NAME = foilnotes openrepos { - PREFIX = openrepos DEFINES += OPENREPOS -} else { - PREFIX = harbour + CONFIG += app_settings } TARGET = $${PREFIX}-$${NAME} @@ -303,27 +302,29 @@ for(s, ICON_SIZES) { icon_dir = icons/$${s}x$${s} $${icon_target}.files = $${icon_dir}/$${TARGET}.png $${icon_target}.path = /usr/share/icons/hicolor/$${s}x$${s}/apps - equals(PREFIX, "openrepos") { - $${icon_target}.extra = cp $${icon_dir}/harbour-$${NAME}.png $$eval($${icon_target}.files) - $${icon_target}.CONFIG += no_check_exist - } INSTALLS += $${icon_target} } -app_icon.files = icons/harbour-foilnotes.svg -app_icon.path = /usr/share/$${TARGET}/qml/images -INSTALLS += app_icon +# Settings -# Desktop file -equals(PREFIX, "openrepos") { - desktop.extra = sed s/harbour/openrepos/g harbour-$${NAME}.desktop > $${TARGET}.desktop - desktop.CONFIG += no_check_exist +app_settings { + settings_json.files = settings/$${TARGET}.json + settings_json.path = /usr/share/jolla-settings/entries/ + settings_qml.files = settings/*.qml + settings_qml.path = /usr/share/$${TARGET}/qml/settings/ + INSTALLS += settings_qml settings_json } +OTHER_FILES += \ + settings/*.qml \ + settings/*.json + # Translations + TRANSLATION_IDBASED=-idbased TRANSLATION_SOURCES = \ - $${_PRO_FILE_PWD_}/qml + $${_PRO_FILE_PWD_}/qml \ + $${_PRO_FILE_PWD_}/settings defineTest(addTrFile) { rel = translations/$${1} diff --git a/rpm/harbour-foilnotes.spec b/rpm/harbour-foilnotes.spec index ae062a1..59a6ad8 100644 --- a/rpm/harbour-foilnotes.spec +++ b/rpm/harbour-foilnotes.spec @@ -47,11 +47,10 @@ Url: %setup -q -n %{name}-%{version} %build -%qtc_qmake5 %{name}.pro +%qtc_qmake5 CONFIG+=openrepos %{name}.pro %qtc_make %{?_smp_mflags} %install -rm -rf %{buildroot} %qmake5_install desktop-file-install --delete-original \ @@ -64,3 +63,5 @@ desktop-file-install --delete-original \ %{_datadir}/%{name} %{_datadir}/applications/%{name}.desktop %{_datadir}/icons/hicolor/*/apps/%{name}.png +%{_datadir}/jolla-settings/entries/%{name}.json +%{_datadir}/translations/%{name}*.qm diff --git a/settings/harbour-foilnotes.json b/settings/harbour-foilnotes.json new file mode 100644 index 0000000..e1bc3a6 --- /dev/null +++ b/settings/harbour-foilnotes.json @@ -0,0 +1,14 @@ +{ + "translation_catalog" : "harbour-foilnotes", + "entries": [ + { + "path": "applications/harbour-foilnotes.desktop", + "title": "Foil Auth", + "type": "page", + "icon": "harbour-foilnotes", + "params": { + "source": "/usr/share/harbour-foilnotes/qml/settings/settings.qml" + } + } + ] +} diff --git a/settings/settings.qml b/settings/settings.qml new file mode 100644 index 0000000..3c747be --- /dev/null +++ b/settings/settings.qml @@ -0,0 +1,67 @@ +import QtQuick 2.0 +import Sailfish.Silica 1.0 +import org.nemomobile.configuration 1.0 + +Page { + property alias title: pageHeader.title + + // jolla-settings expects these properties: + property var applicationName + property var applicationIcon + + readonly property string _rootPath: "/apps/harbour-foilnotes/" + + SilicaFlickable { + anchors.fill: parent + contentHeight: content.height + + Column { + id: content + width: parent.width + + PageHeader { + id: pageHeader + + rightMargin: Theme.horizontalPageMargin + (appIcon.visible ? (height - appIcon.padding) : 0) + title: applicationName ? applicationName : "Foil Notes" + description: applicationName ? + //: Settings page header description (app version) + //% "Version %1" + qsTrId("foilnotes-settings_page-header-version").arg("1.1.0") : "" + + Image { + id: appIcon + + readonly property int padding: Theme.paddingLarge + readonly property int size: pageHeader.height - 2 * padding + x: pageHeader.width - width - Theme.horizontalPageMargin + y: padding + width: size + height: size + sourceSize: Qt.size(size,size) + source: applicationIcon ? applicationIcon : "" + visible: appIcon.status === Image.Ready + } + } + + TextSwitch { + //: Text switch label + //% "Automatic locking" + text: qsTrId("foilnotes-settings_page-autolock-text") + //: Text switch description + //% "Require to enter Foil password after unlocking the screen." + description: qsTrId("foilnotes-settings_page-autolock-description") + automaticCheck: false + checked: autoLockConfig.value + onClicked: autoLockConfig.value = !autoLockConfig.value + + ConfigurationValue { + id: autoLockConfig + + key: _rootPath + "autoLock" + defaultValue: true + } + } + } + } +} diff --git a/src/FoilNotesDefs.h b/src/FoilNotesDefs.h index d0cc6be..8b0fb16 100644 --- a/src/FoilNotesDefs.h +++ b/src/FoilNotesDefs.h @@ -1,6 +1,6 @@ /* * Copyright (C) 2018-2019 Jolla Ltd. - * Copyright (C) 2018-2019 Slava Monich + * Copyright (C) 2018-2023 Slava Monich * * You may use this file under the terms of the BSD license as follows: * @@ -11,8 +11,8 @@ * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in - * the documentation and/or other materials provided with the + * notice, this list of conditions and the following disclaimer + * in the documentation and/or other materials provided with the * distribution. * 3. Neither the names of the copyright holders nor the names of its * contributors may be used to endorse or promote products derived @@ -36,12 +36,7 @@ #include -#ifdef OPENREPOS -# define FOILNOTES_APP_NAME "openrepos-foilnotes" -#else -# define FOILNOTES_APP_NAME "harbour-foilnotes" -#endif - +#define FOILNOTES_APP_NAME "harbour-foilnotes" #define FOILNOTES_QML_IMPORT "harbour.foilnotes" #define FOILNOTES_DCONF_ROOT "/apps/" FOILNOTES_APP_NAME "/" diff --git a/translations/harbour-foilnotes-de.ts b/translations/harbour-foilnotes-de.ts index 7bed4cd..10dfdd2 100644 --- a/translations/harbour-foilnotes-de.ts +++ b/translations/harbour-foilnotes-de.ts @@ -397,5 +397,20 @@ Full screen info label Berühren Sie ein anderes NFC-fähiges Gerät, während Foil Notes im Vollbildmodus ausgeführt wird. + + Version %1 + Settings page header description (app version) + Version %1 + + + Automatic locking + Text switch label + Automatische Sperrung + + + Require to enter Foil password after unlocking the screen. + Text switch description + Nach dem Entsperren des Bildschirms muss das Foil-Passwort eingegeben werden. + diff --git a/translations/harbour-foilnotes-es.ts b/translations/harbour-foilnotes-es.ts index a5baaa1..ae8e2dc 100644 --- a/translations/harbour-foilnotes-es.ts +++ b/translations/harbour-foilnotes-es.ts @@ -397,5 +397,20 @@ Full screen info label Toque otro dispositivo compatible con NFC con Foil Notes en pantalla completa. + + Version %1 + Settings page header description (app version) + Versión %1 + + + Automatic locking + Text switch label + Bloqueo automático + + + Require to enter Foil password after unlocking the screen. + Text switch description + Requiere ingresar la contraseña de Foil después de desbloquear la pantalla. + diff --git a/translations/harbour-foilnotes-fr.ts b/translations/harbour-foilnotes-fr.ts index 0cc888c..a519a8b 100644 --- a/translations/harbour-foilnotes-fr.ts +++ b/translations/harbour-foilnotes-fr.ts @@ -397,5 +397,20 @@ Full screen info label Touchez un autre appareil compatible NFC avec Foil Notes en plein écran. + + Version %1 + Settings page header description (app version) + Version %1 + + + Automatic locking + Text switch label + Verrouillage automatique + + + Require to enter Foil password after unlocking the screen. + Text switch description + Nécessite d'entrer le mot de passe Foil après avoir déverrouillé l'écran. + diff --git a/translations/harbour-foilnotes-pl.ts b/translations/harbour-foilnotes-pl.ts index 85a1429..5d189cd 100644 --- a/translations/harbour-foilnotes-pl.ts +++ b/translations/harbour-foilnotes-pl.ts @@ -400,5 +400,20 @@ Full screen info label Dotknij innego urządzenia obsługującego NFC z Foil Notes otwartym na pełnym ekranie. + + Version %1 + Settings page header description (app version) + Wersja %1 + + + Automatic locking + Text switch label + Automatyczne blokowanie + + + Require to enter Foil password after unlocking the screen. + Text switch description + Wymagaj podania Foil hasła po odblokowaniu ekranu. + diff --git a/translations/harbour-foilnotes-ru.ts b/translations/harbour-foilnotes-ru.ts index 925bcc5..b284e4a 100644 --- a/translations/harbour-foilnotes-ru.ts +++ b/translations/harbour-foilnotes-ru.ts @@ -400,5 +400,20 @@ Full screen info label Прикоснитесь NFC сенсором к другому устройству, на котором приложение Foil Notes открыто на весь экран. Возможно, произойдёт чудо! + + Version %1 + Settings page header description (app version) + Версия %1 + + + Automatic locking + Text switch label + Автоматическая блокировка + + + Require to enter Foil password after unlocking the screen. + Text switch description + Требовать ввода пароля после разблокировки экрана. + diff --git a/translations/harbour-foilnotes-sv.ts b/translations/harbour-foilnotes-sv.ts index a6de9d8..b46af4e 100644 --- a/translations/harbour-foilnotes-sv.ts +++ b/translations/harbour-foilnotes-sv.ts @@ -397,5 +397,20 @@ Full screen info label Tryck på en annan NFC-kompatibel enhet med Foil Notes på helskärm. + + Version %1 + Settings page header description (app version) + Version %1 + + + Automatic locking + Text switch label + Automatisk låsning + + + Require to enter Foil password after unlocking the screen. + Text switch description + Kräv Foil-lösenord efter att skärmen låsts upp. + diff --git a/translations/harbour-foilnotes-zh_CN.ts b/translations/harbour-foilnotes-zh_CN.ts index e302505..68e8251 100644 --- a/translations/harbour-foilnotes-zh_CN.ts +++ b/translations/harbour-foilnotes-zh_CN.ts @@ -394,5 +394,20 @@ Full screen info label 在 Foil Notes 全屏运行时触摸另一个支持 NFC 的设备 + + Version %1 + Settings page header description (app version) + 版本 %1 + + + Automatic locking + Text switch label + 自动锁定 + + + Require to enter Foil password after unlocking the screen. + Text switch description + 解锁屏幕后需要输入Foil密码。 + diff --git a/translations/harbour-foilnotes.ts b/translations/harbour-foilnotes.ts index 548624f..33d0e2d 100644 --- a/translations/harbour-foilnotes.ts +++ b/translations/harbour-foilnotes.ts @@ -397,5 +397,20 @@ Full screen info label Touch another NFC capable device with Foil Notes running full screen. + + Version %1 + Settings page header description (app version) + Version %1 + + + Automatic locking + Text switch label + Automatic locking + + + Require to enter Foil password after unlocking the screen. + Text switch description + Require to enter Foil password after unlocking the screen. +