[app] Added settings page

This commit is contained in:
Slava Monich 2016-10-07 17:41:59 +03:00
parent a2585f8967
commit 833775f0b0
12 changed files with 344 additions and 35 deletions

View file

@ -1,7 +1,22 @@
TARGET = harbour-books NAME = books
openrepos {
PREFIX = openrepos
DEFINES += OPENREPOS
} else {
PREFIX = harbour
}
TARGET = $${PREFIX}-$${NAME}
CONFIG += sailfishapp link_pkgconfig CONFIG += sailfishapp link_pkgconfig
PKGCONFIG += sailfishapp mlite5 glib-2.0 PKGCONFIG += sailfishapp mlite5 glib-2.0
#QT += dbus
app_settings {
# This path is hardcoded in jolla-settings
TRANSLATIONS_PATH = /usr/share/translations
} else {
TRANSLATIONS_PATH = /usr/share/$${TARGET}/translations
}
!include(../common.pri) !include(../common.pri)
@ -38,6 +53,7 @@ OTHER_FILES += \
harbour-books.desktop \ harbour-books.desktop \
qml/*.qml \ qml/*.qml \
qml/images/* \ qml/images/* \
settings/*.qml \
data/default/* \ data/default/* \
data/zlibrary/core/encodings/* \ data/zlibrary/core/encodings/* \
data/zlibrary/core/resources/* \ data/zlibrary/core/resources/* \
@ -68,30 +84,6 @@ formats.files = data/formats/*
formats.path = $$TARGET_DEFAULT_DATA_DIR/formats formats.path = $$TARGET_DEFAULT_DATA_DIR/formats
INSTALLS += formats INSTALLS += formats
icon86.files = icons/86x86/harbour-books.png
icon86.path = $$TARGET_ICON_ROOT/86x86/apps
INSTALLS += icon86
icon108.files = icons/108x108/harbour-books.png
icon108.path = $$TARGET_ICON_ROOT/108x108/apps
INSTALLS += icon108
icon128.files = icons/128x128/harbour-books.png
icon128.path = $$TARGET_ICON_ROOT/128x128/apps
INSTALLS += icon128
icon256.files = icons/256x256/harbour-books.png
icon256.path = $$TARGET_ICON_ROOT/256x256/apps
INSTALLS += icon256
CONFIG += sailfishapp_i18n sailfishapp_i18n_idbased
TRANSLATIONS += \
translations/harbour-books.ts \
translations/harbour-books-de.ts \
translations/harbour-books-fi.ts \
translations/harbour-books-ru.ts \
translations/harbour-books-sv.ts
INCLUDEPATH += \ INCLUDEPATH += \
src \ src \
$$HARBOUR_LIB_DIR/include \ $$HARBOUR_LIB_DIR/include \
@ -133,11 +125,15 @@ SOURCES += \
src/ZLApplication.cpp \ src/ZLApplication.cpp \
src/ZLibrary.cpp src/ZLibrary.cpp
# Stubs for the libraries not allowed in harbour # Some libraries are not allowed in harbour
SOURCES += \ openrepos {
stubs/libexpat.c \ LIBS += -lexpat -lmagic -ludev
stubs/libmagic.c \ } else {
stubs/libudev.c SOURCES += \
stubs/libexpat.c \
stubs/libmagic.c \
stubs/libudev.c
}
HEADERS += \ HEADERS += \
src/BooksBook.h \ src/BooksBook.h \
@ -167,3 +163,83 @@ HEADERS += \
src/BooksTextStyle.h \ src/BooksTextStyle.h \
src/BooksTypes.h \ src/BooksTypes.h \
src/BooksUtil.h src/BooksUtil.h
# Icons
ICON_SIZES = 86 108 128 256
for(s, ICON_SIZES) {
icon_target = icon$${s}
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}
}
# Settings
app_settings {
settings_json.files = settings/$${TARGET}.json
settings_json.path = /usr/share/jolla-settings/entries/
equals(PREFIX, "openrepos") {
settings_json.extra = sed s/harbour/openrepos/g settings/harbour-$${NAME}.json > $$eval(settings_json.files)
settings_json.CONFIG += no_check_exist
}
INSTALLS += settings_json
}
settings_qml.files = settings/*.qml
settings_qml.path = /usr/share/$${TARGET}/settings/
INSTALLS += settings_qml
# Desktop file
equals(PREFIX, "openrepos") {
desktop.extra = sed s/harbour/openrepos/g harbour-$${NAME}.desktop > $${TARGET}.desktop
desktop.CONFIG += no_check_exist
}
# Translations
TRANSLATION_SOURCES = \
$${_PRO_FILE_PWD_}/qml \
$${_PRO_FILE_PWD_}/settings
defineTest(addTrFile) {
in = $${_PRO_FILE_PWD_}/translations/harbour-$$1
out = $${OUT_PWD}/translations/$${PREFIX}-$$1
s = $$replace(1,-,_)
lupdate_target = lupdate_$$s
lrelease_target = lrelease_$$s
$${lupdate_target}.commands = lupdate -noobsolete $${TRANSLATION_SOURCES} -ts \"$${in}.ts\" && \
mkdir -p \"$${OUT_PWD}/translations\" && [ \"$${in}.ts\" != \"$${out}.ts\" ] && \
cp -af \"$${in}.ts\" \"$${out}.ts\" || :
$${lrelease_target}.target = \"$${out}.qm\"
$${lrelease_target}.depends = $${lupdate_target}
$${lrelease_target}.commands = lrelease -idbased \"$${out}.ts\"
QMAKE_EXTRA_TARGETS += $${lrelease_target} $${lupdate_target}
PRE_TARGETDEPS += \"$${out}.qm\"
qm.files += \"$${out}.qm\"
export($${lupdate_target}.commands)
export($${lrelease_target}.target)
export($${lrelease_target}.depends)
export($${lrelease_target}.commands)
export(QMAKE_EXTRA_TARGETS)
export(PRE_TARGETDEPS)
export(qm.files)
}
LANGUAGES = de fi ru sv
addTrFile($${NAME})
for(l, LANGUAGES) {
addTrFile($${NAME}-$$l)
}
qm.path = $$TRANSLATIONS_PATH
qm.CONFIG += no_check_exist
INSTALLS += qm

View file

@ -4,6 +4,7 @@ Name=Books
Name[fi]=Kirjat Name[fi]=Kirjat
Name[ru]=Книги Name[ru]=Книги
Name[sv]=Böcker Name[sv]=Böcker
Name[de]=Bücher
Comment=E-Book Reader Comment=E-Book Reader
Exec=harbour-books Exec=harbour-books
Icon=harbour-books Icon=harbour-books

View file

@ -54,6 +54,7 @@ SilicaFlickable {
readonly property real horizontalScrollThreshold: _cellWidth/2 readonly property real horizontalScrollThreshold: _cellWidth/2
readonly property real _minGridCellWidth: 10*Theme.paddingMedium readonly property real _minGridCellWidth: 10*Theme.paddingMedium
property var _settingsComponent
// Books in the library shouldn't be too small or too big. // Books in the library shouldn't be too small or too big.
// At least 3 (or 5 in landscape) should fit in the horizontal direction. // At least 3 (or 5 in landscape) should fit in the horizontal direction.
@ -90,12 +91,31 @@ SilicaFlickable {
PullDownMenu { PullDownMenu {
MenuItem { MenuItem {
//: Pulley menu item
//% "Settings"
text: qsTrId("storage-view-settings")
visible: !editMode && BooksSettingsMenu
onClicked: {
if (!_settingsComponent) {
_settingsComponent = Qt.createComponent("../settings/BooksSettings.qml")
if (_settingsComponent.status === Component.Ready) {
_settingsComponent.createObject(storageView)
} else {
console.log(_settingsComponent.errorString())
}
}
pageStack.push(_settingsComponent, {"title" : text })
}
}
MenuItem {
//: Pulley menu item
//% "Scan downloads" //% "Scan downloads"
text: qsTrId("storage-view-scan-downloads") text: qsTrId("storage-view-scan-downloads")
visible: !editMode visible: !editMode
onClicked: pageStack.push(importComponent) onClicked: pageStack.push(importComponent)
} }
MenuItem { MenuItem {
//: Pulley menu item
//% "Delete all books" //% "Delete all books"
text: qsTrId("storage-view-delete-everything") text: qsTrId("storage-view-delete-everything")
visible: editMode visible: editMode

View file

@ -0,0 +1,94 @@
/*
Copyright (C) 2016 Jolla Ltd.
Contact: Slava Monich <slava.monich@jolla.com>
You may use this file under the terms of BSD license as follows:
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions
are met:
* Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
* 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 distribution.
* Neither the name of Jolla Ltd nor the names of its contributors may
be used to endorse or promote products derived from this software
without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS
BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
THE POSSIBILITY OF SUCH DAMAGE.
*/
import QtQuick 2.0
import Sailfish.Silica 1.0
import org.nemomobile.configuration 1.0
Page {
id: page
property alias title: pageHeader.title
readonly property string rootPath: "/apps/" + appName() + "/"
// Deduce package name from the path
function appName() {
var parts = Qt.resolvedUrl("dummy").split('/')
if (parts.length > 2) {
var name = parts[parts.length-3]
if (name.indexOf("swissclock") >= 0) {
return name
}
}
return "harbour-books"
}
SilicaFlickable {
anchors.fill: parent
contentHeight: content.height
Column {
id: content
width: parent.width
PageHeader {
id: pageHeader
//: Settings page header
//% "Books"
title: qsTrId("settings-page_header")
}
Slider {
id: fontSizeSlider
minimumValue: -5
maximumValue: 15
stepSize: 1
//: Slider value label for the standard font size
//% "Default"
readonly property string normal: qsTrId("settings-font_size_label-default")
//: Slider label
//% "Font size"
label: qsTrId("settings-font_size_label")
valueText: (value === 0) ? normal : ((value > 0) ? ("+" + value) : value)
width: page.width
anchors.horizontalCenter: parent.horizontalCenter
onSliderValueChanged: fontSize.value = value
Component.onCompleted: value = fontSize.value
ConfigurationValue {
id: fontSize
key: rootPath + "fontSize"
defaultValue: 0
onValueChanged: fontSizeSlider.value = value
}
}
}
}
}

View file

@ -1,5 +1,5 @@
/* /*
* Copyright (C) 2015 Jolla Ltd. * Copyright (C) 2015-2016 Jolla Ltd.
* Contact: Slava Monich <slava.monich@jolla.com> * Contact: Slava Monich <slava.monich@jolla.com>
* *
* You may use this file under the terms of the BSD license as follows: * You may use this file under the terms of the BSD license as follows:
@ -14,7 +14,7 @@
* notice, this list of conditions and the following disclaimer in * notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the * the documentation and/or other materials provided with the
* distribution. * distribution.
* * Neither the name of Nemo Mobile nor the names of its contributors * * Neither the name of Jolla Ltd nor the names of its contributors
* may be used to endorse or promote products derived from this * may be used to endorse or promote products derived from this
* software without specific prior written permission. * software without specific prior written permission.
* *
@ -36,7 +36,13 @@
#include <QString> #include <QString>
#define BOOKS_APP_NAME "harbour-books" #ifdef OPENREPOS
# define BOOKS_APP_NAME "openrepos-books"
# define BOOKS_SETTINGS_MENU false
#else
# define BOOKS_APP_NAME "harbour-books"
# define BOOKS_SETTINGS_MENU true
#endif
#define BOOKS_DCONF_ROOT "/apps/" BOOKS_APP_NAME "/" #define BOOKS_DCONF_ROOT "/apps/" BOOKS_APP_NAME "/"
#define BOOKS_DATA_ROOT "usr/share/" BOOKS_APP_NAME #define BOOKS_DATA_ROOT "usr/share/" BOOKS_APP_NAME
#define BOOKS_QML_DIR BOOKS_DATA_ROOT "/qml" #define BOOKS_QML_DIR BOOKS_DATA_ROOT "/qml"

View file

@ -60,7 +60,7 @@ public:
enum FontSize { enum FontSize {
MinFontSize = -5, MinFontSize = -5,
DefaultFontSize = 0, DefaultFontSize = 0,
MaxFontSize = 10, MaxFontSize = 15,
FontSizeSteps = MaxFontSize - MinFontSize FontSizeSteps = MaxFontSize - MinFontSize
}; };

View file

@ -193,6 +193,8 @@ void ZLibrary::run(ZLApplication* aApp)
QQmlContext* root = view->rootContext(); QQmlContext* root = view->rootContext();
root->setContextProperty("PointsPerInch", booksPPI); root->setContextProperty("PointsPerInch", booksPPI);
root->setContextProperty("MaximumHintCount", 1); root->setContextProperty("MaximumHintCount", 1);
root->setContextProperty("BooksSettingsMenu",
QVariant::fromValue(BOOKS_SETTINGS_MENU));
view->setTitle(qtTrId("books-app-name")); view->setTitle(qtTrId("books-app-name"));
view->setSource(QUrl::fromLocalFile(qml)); view->setSource(QUrl::fromLocalFile(qml));

View file

@ -58,12 +58,19 @@
<numerusform>%0 Bücher</numerusform> <numerusform>%0 Bücher</numerusform>
</translation> </translation>
</message> </message>
<message id="storage-view-settings">
<source>Settings</source>
<extracomment>Pulley menu item</extracomment>
<translation type="unfinished">Einstellungen</translation>
</message>
<message id="storage-view-scan-downloads"> <message id="storage-view-scan-downloads">
<source>Scan downloads</source> <source>Scan downloads</source>
<extracomment>Pulley menu item</extracomment>
<translation>Lese Downloads</translation> <translation>Lese Downloads</translation>
</message> </message>
<message id="storage-view-delete-everything"> <message id="storage-view-delete-everything">
<source>Delete all books</source> <source>Delete all books</source>
<extracomment>Pulley menu item</extracomment>
<translation>Lösche alle Bücher</translation> <translation>Lösche alle Bücher</translation>
</message> </message>
<message id="storage-view-swipe-left-hint"> <message id="storage-view-swipe-left-hint">
@ -85,5 +92,20 @@
<source>No new books found</source> <source>No new books found</source>
<translation>Keine neuen Bücher gefunden</translation> <translation>Keine neuen Bücher gefunden</translation>
</message> </message>
<message id="settings-page_header">
<source>Books</source>
<extracomment>Settings page header</extracomment>
<translation>Bücher</translation>
</message>
<message id="settings-font_size_label">
<source>Font size</source>
<extracomment>Slider label</extracomment>
<translation>Schriftgröße</translation>
</message>
<message id="settings-font_size_label-default">
<source>Default</source>
<extracomment>Slider value label for the standard font size</extracomment>
<translation>Standard</translation>
</message>
</context> </context>
</TS> </TS>

View file

@ -58,12 +58,19 @@
<numerusform>%0 kirjaa</numerusform> <numerusform>%0 kirjaa</numerusform>
</translation> </translation>
</message> </message>
<message id="storage-view-settings">
<source>Settings</source>
<extracomment>Pulley menu item</extracomment>
<translation>Asetukset</translation>
</message>
<message id="storage-view-scan-downloads"> <message id="storage-view-scan-downloads">
<source>Scan downloads</source> <source>Scan downloads</source>
<extracomment>Pulley menu item</extracomment>
<translation>Tarkista lataukset</translation> <translation>Tarkista lataukset</translation>
</message> </message>
<message id="storage-view-delete-everything"> <message id="storage-view-delete-everything">
<source>Delete all books</source> <source>Delete all books</source>
<extracomment>Pulley menu item</extracomment>
<translation>Poista kaikki kirjat</translation> <translation>Poista kaikki kirjat</translation>
</message> </message>
<message id="storage-view-swipe-left-hint"> <message id="storage-view-swipe-left-hint">
@ -85,5 +92,20 @@
<source>No new books found</source> <source>No new books found</source>
<translation>Uusia kirjoja ei löytynyt</translation> <translation>Uusia kirjoja ei löytynyt</translation>
</message> </message>
<message id="settings-page_header">
<source>Books</source>
<extracomment>Settings page header</extracomment>
<translation>Kirjat</translation>
</message>
<message id="settings-font_size_label">
<source>Font size</source>
<extracomment>Slider label</extracomment>
<translation type="unfinished">Fonttikoko</translation>
</message>
<message id="settings-font_size_label-default">
<source>Default</source>
<extracomment>Slider value label for the standard font size</extracomment>
<translation type="unfinished">Oletus</translation>
</message>
</context> </context>
</TS> </TS>

View file

@ -59,12 +59,19 @@
<numerusform>%0 книг</numerusform> <numerusform>%0 книг</numerusform>
</translation> </translation>
</message> </message>
<message id="storage-view-settings">
<source>Settings</source>
<extracomment>Pulley menu item</extracomment>
<translation>Настройки</translation>
</message>
<message id="storage-view-scan-downloads"> <message id="storage-view-scan-downloads">
<source>Scan downloads</source> <source>Scan downloads</source>
<extracomment>Pulley menu item</extracomment>
<translation>Проверить загрузки</translation> <translation>Проверить загрузки</translation>
</message> </message>
<message id="storage-view-delete-everything"> <message id="storage-view-delete-everything">
<source>Delete all books</source> <source>Delete all books</source>
<extracomment>Pulley menu item</extracomment>
<translation>Удалить все книги</translation> <translation>Удалить все книги</translation>
</message> </message>
<message id="storage-view-swipe-left-hint"> <message id="storage-view-swipe-left-hint">
@ -87,5 +94,20 @@
<source>No new books found</source> <source>No new books found</source>
<translation>Новых книг не найдено, вообще ни одной</translation> <translation>Новых книг не найдено, вообще ни одной</translation>
</message> </message>
<message id="settings-page_header">
<source>Books</source>
<extracomment>Settings page header</extracomment>
<translation>Книги</translation>
</message>
<message id="settings-font_size_label">
<source>Font size</source>
<extracomment>Slider label</extracomment>
<translation>Размер шрифта</translation>
</message>
<message id="settings-font_size_label-default">
<source>Default</source>
<extracomment>Slider value label for the standard font size</extracomment>
<translation>Стандартный</translation>
</message>
</context> </context>
</TS> </TS>

View file

@ -58,12 +58,19 @@
<numerusform>%0 böcker</numerusform> <numerusform>%0 böcker</numerusform>
</translation> </translation>
</message> </message>
<message id="storage-view-settings">
<source>Settings</source>
<extracomment>Pulley menu item</extracomment>
<translation type="unfinished">Inställningar</translation>
</message>
<message id="storage-view-scan-downloads"> <message id="storage-view-scan-downloads">
<source>Scan downloads</source> <source>Scan downloads</source>
<extracomment>Pulley menu item</extracomment>
<translation>Skanna Nedladdningar</translation> <translation>Skanna Nedladdningar</translation>
</message> </message>
<message id="storage-view-delete-everything"> <message id="storage-view-delete-everything">
<source>Delete all books</source> <source>Delete all books</source>
<extracomment>Pulley menu item</extracomment>
<translation>Ta bort alla böcker</translation> <translation>Ta bort alla böcker</translation>
</message> </message>
<message id="storage-view-swipe-left-hint"> <message id="storage-view-swipe-left-hint">
@ -85,5 +92,20 @@
<source>No new books found</source> <source>No new books found</source>
<translation>Inga nya böcker hittades</translation> <translation>Inga nya böcker hittades</translation>
</message> </message>
<message id="settings-page_header">
<source>Books</source>
<extracomment>Settings page header</extracomment>
<translation>Böcker</translation>
</message>
<message id="settings-font_size_label">
<source>Font size</source>
<extracomment>Slider label</extracomment>
<translation type="unfinished">Textstorlek</translation>
</message>
<message id="settings-font_size_label-default">
<source>Default</source>
<extracomment>Slider value label for the standard font size</extracomment>
<translation type="unfinished">Standard</translation>
</message>
</context> </context>
</TS> </TS>

View file

@ -58,12 +58,19 @@
<numerusform>%0 books</numerusform> <numerusform>%0 books</numerusform>
</translation> </translation>
</message> </message>
<message id="storage-view-settings">
<source>Settings</source>
<extracomment>Pulley menu item</extracomment>
<translation type="unfinished"></translation>
</message>
<message id="storage-view-scan-downloads"> <message id="storage-view-scan-downloads">
<source>Scan downloads</source> <source>Scan downloads</source>
<extracomment>Pulley menu item</extracomment>
<translation>Check downloads</translation> <translation>Check downloads</translation>
</message> </message>
<message id="storage-view-delete-everything"> <message id="storage-view-delete-everything">
<source>Delete all books</source> <source>Delete all books</source>
<extracomment>Pulley menu item</extracomment>
<translation>Delete all books</translation> <translation>Delete all books</translation>
</message> </message>
<message id="storage-view-swipe-left-hint"> <message id="storage-view-swipe-left-hint">
@ -85,5 +92,20 @@
<source>No new books found</source> <source>No new books found</source>
<translation>No new books found</translation> <translation>No new books found</translation>
</message> </message>
<message id="settings-page_header">
<source>Books</source>
<extracomment>Settings page header</extracomment>
<translation>Books</translation>
</message>
<message id="settings-font_size_label">
<source>Font size</source>
<extracomment>Slider label</extracomment>
<translation>Font size</translation>
</message>
<message id="settings-font_size_label-default">
<source>Default</source>
<extracomment>Slider value label for the standard font size</extracomment>
<translation>Default</translation>
</message>
</context> </context>
</TS> </TS>