Skip to content

Commit

Permalink
[foilnotes] Added settings page
Browse files Browse the repository at this point in the history
  • Loading branch information
monich committed Feb 19, 2023
1 parent f8920be commit 284919a
Show file tree
Hide file tree
Showing 13 changed files with 224 additions and 26 deletions.
31 changes: 16 additions & 15 deletions app.pro
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
PREFIX = harbour
NAME = foilnotes

openrepos {
PREFIX = openrepos
DEFINES += OPENREPOS
} else {
PREFIX = harbour
CONFIG += app_settings
}

TARGET = $${PREFIX}-$${NAME}
Expand Down Expand Up @@ -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}
Expand Down
5 changes: 3 additions & 2 deletions rpm/harbour-foilnotes.spec
Original file line number Diff line number Diff line change
Expand Up @@ -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 \
Expand All @@ -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
14 changes: 14 additions & 0 deletions settings/harbour-foilnotes.json
Original file line number Diff line number Diff line change
@@ -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"
}
}
]
}
67 changes: 67 additions & 0 deletions settings/settings.qml
Original file line number Diff line number Diff line change
@@ -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
}
}
}
}
}
13 changes: 4 additions & 9 deletions src/FoilNotesDefs.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*
* Copyright (C) 2018-2019 Jolla Ltd.
* Copyright (C) 2018-2019 Slava Monich <[email protected]>
* Copyright (C) 2018-2023 Slava Monich <[email protected]>
*
* You may use this file under the terms of the BSD license as follows:
*
Expand All @@ -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
Expand All @@ -36,12 +36,7 @@

#include <qnamespace.h>

#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 "/"

Expand Down
15 changes: 15 additions & 0 deletions translations/harbour-foilnotes-de.ts
Original file line number Diff line number Diff line change
Expand Up @@ -397,5 +397,20 @@
<extracomment>Full screen info label</extracomment>
<translation type="unfinished">Berühren Sie ein anderes NFC-fähiges Gerät, während Foil Notes im Vollbildmodus ausgeführt wird.</translation>
</message>
<message id="foilnotes-settings_page-header-version">
<source>Version %1</source>
<extracomment>Settings page header description (app version)</extracomment>
<translation type="unfinished">Version %1</translation>
</message>
<message id="foilnotes-settings_page-autolock-text">
<source>Automatic locking</source>
<extracomment>Text switch label</extracomment>
<translation type="unfinished">Automatische Sperrung</translation>
</message>
<message id="foilnotes-settings_page-autolock-description">
<source>Require to enter Foil password after unlocking the screen.</source>
<extracomment>Text switch description</extracomment>
<translation type="unfinished">Nach dem Entsperren des Bildschirms muss das Foil-Passwort eingegeben werden.</translation>
</message>
</context>
</TS>
15 changes: 15 additions & 0 deletions translations/harbour-foilnotes-es.ts
Original file line number Diff line number Diff line change
Expand Up @@ -397,5 +397,20 @@
<extracomment>Full screen info label</extracomment>
<translation type="unfinished">Toque otro dispositivo compatible con NFC con Foil Notes en pantalla completa.</translation>
</message>
<message id="foilnotes-settings_page-header-version">
<source>Version %1</source>
<extracomment>Settings page header description (app version)</extracomment>
<translation type="unfinished">Versión %1</translation>
</message>
<message id="foilnotes-settings_page-autolock-text">
<source>Automatic locking</source>
<extracomment>Text switch label</extracomment>
<translation type="unfinished">Bloqueo automático</translation>
</message>
<message id="foilnotes-settings_page-autolock-description">
<source>Require to enter Foil password after unlocking the screen.</source>
<extracomment>Text switch description</extracomment>
<translation type="unfinished">Requiere ingresar la contraseña de Foil después de desbloquear la pantalla.</translation>
</message>
</context>
</TS>
15 changes: 15 additions & 0 deletions translations/harbour-foilnotes-fr.ts
Original file line number Diff line number Diff line change
Expand Up @@ -397,5 +397,20 @@
<extracomment>Full screen info label</extracomment>
<translation type="unfinished">Touchez un autre appareil compatible NFC avec Foil Notes en plein écran.</translation>
</message>
<message id="foilnotes-settings_page-header-version">
<source>Version %1</source>
<extracomment>Settings page header description (app version)</extracomment>
<translation type="unfinished">Version %1</translation>
</message>
<message id="foilnotes-settings_page-autolock-text">
<source>Automatic locking</source>
<extracomment>Text switch label</extracomment>
<translation type="unfinished">Verrouillage automatique</translation>
</message>
<message id="foilnotes-settings_page-autolock-description">
<source>Require to enter Foil password after unlocking the screen.</source>
<extracomment>Text switch description</extracomment>
<translation type="unfinished">Nécessite d&apos;entrer le mot de passe Foil après avoir déverrouillé l&apos;écran.</translation>
</message>
</context>
</TS>
15 changes: 15 additions & 0 deletions translations/harbour-foilnotes-pl.ts
Original file line number Diff line number Diff line change
Expand Up @@ -400,5 +400,20 @@
<extracomment>Full screen info label</extracomment>
<translation>Dotknij innego urządzenia obsługującego NFC z Foil Notes otwartym na pełnym ekranie. </translation>
</message>
<message id="foilnotes-settings_page-header-version">
<source>Version %1</source>
<extracomment>Settings page header description (app version)</extracomment>
<translation>Wersja %1</translation>
</message>
<message id="foilnotes-settings_page-autolock-text">
<source>Automatic locking</source>
<extracomment>Text switch label</extracomment>
<translation>Automatyczne blokowanie</translation>
</message>
<message id="foilnotes-settings_page-autolock-description">
<source>Require to enter Foil password after unlocking the screen.</source>
<extracomment>Text switch description</extracomment>
<translation>Wymagaj podania Foil hasła po odblokowaniu ekranu.</translation>
</message>
</context>
</TS>
15 changes: 15 additions & 0 deletions translations/harbour-foilnotes-ru.ts
Original file line number Diff line number Diff line change
Expand Up @@ -400,5 +400,20 @@
<extracomment>Full screen info label</extracomment>
<translation>Прикоснитесь NFC сенсором к другому устройству, на котором приложение Foil Notes открыто на весь экран. Возможно, произойдёт чудо!</translation>
</message>
<message id="foilnotes-settings_page-header-version">
<source>Version %1</source>
<extracomment>Settings page header description (app version)</extracomment>
<translation>Версия %1</translation>
</message>
<message id="foilnotes-settings_page-autolock-text">
<source>Automatic locking</source>
<extracomment>Text switch label</extracomment>
<translation>Автоматическая блокировка</translation>
</message>
<message id="foilnotes-settings_page-autolock-description">
<source>Require to enter Foil password after unlocking the screen.</source>
<extracomment>Text switch description</extracomment>
<translation>Требовать ввода пароля после разблокировки экрана.</translation>
</message>
</context>
</TS>
15 changes: 15 additions & 0 deletions translations/harbour-foilnotes-sv.ts
Original file line number Diff line number Diff line change
Expand Up @@ -397,5 +397,20 @@
<extracomment>Full screen info label</extracomment>
<translation type="unfinished">Tryck på en annan NFC-kompatibel enhet med Foil Notes på helskärm.</translation>
</message>
<message id="foilnotes-settings_page-header-version">
<source>Version %1</source>
<extracomment>Settings page header description (app version)</extracomment>
<translation>Version %1</translation>
</message>
<message id="foilnotes-settings_page-autolock-text">
<source>Automatic locking</source>
<extracomment>Text switch label</extracomment>
<translation>Automatisk låsning</translation>
</message>
<message id="foilnotes-settings_page-autolock-description">
<source>Require to enter Foil password after unlocking the screen.</source>
<extracomment>Text switch description</extracomment>
<translation>Kräv Foil-lösenord efter att skärmen låsts upp.</translation>
</message>
</context>
</TS>
15 changes: 15 additions & 0 deletions translations/harbour-foilnotes-zh_CN.ts
Original file line number Diff line number Diff line change
Expand Up @@ -394,5 +394,20 @@
<extracomment>Full screen info label</extracomment>
<translation type="unfinished">在 Foil Notes 全屏运行时触摸另一个支持 NFC 的设备</translation>
</message>
<message id="foilnotes-settings_page-header-version">
<source>Version %1</source>
<extracomment>Settings page header description (app version)</extracomment>
<translation type="unfinished">版本 %1</translation>
</message>
<message id="foilnotes-settings_page-autolock-text">
<source>Automatic locking</source>
<extracomment>Text switch label</extracomment>
<translation type="unfinished">自动锁定</translation>
</message>
<message id="foilnotes-settings_page-autolock-description">
<source>Require to enter Foil password after unlocking the screen.</source>
<extracomment>Text switch description</extracomment>
<translation type="unfinished">解锁屏幕后需要输入Foil密码。</translation>
</message>
</context>
</TS>
15 changes: 15 additions & 0 deletions translations/harbour-foilnotes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -397,5 +397,20 @@
<extracomment>Full screen info label</extracomment>
<translation>Touch another NFC capable device with Foil Notes running full screen.</translation>
</message>
<message id="foilnotes-settings_page-header-version">
<source>Version %1</source>
<extracomment>Settings page header description (app version)</extracomment>
<translation>Version %1</translation>
</message>
<message id="foilnotes-settings_page-autolock-text">
<source>Automatic locking</source>
<extracomment>Text switch label</extracomment>
<translation>Automatic locking</translation>
</message>
<message id="foilnotes-settings_page-autolock-description">
<source>Require to enter Foil password after unlocking the screen.</source>
<extracomment>Text switch description</extracomment>
<translation>Require to enter Foil password after unlocking the screen.</translation>
</message>
</context>
</TS>

0 comments on commit 284919a

Please sign in to comment.