[-]
[+]
|
Changed |
_service:tar_git:openrepos-books.changes
|
|
[-]
[+]
|
Changed |
_service:tar_git:openrepos-books.spec
^
|
|
[-]
[+]
|
Changed |
_service
^
|
@@ -2,6 +2,6 @@
<service name="tar_git">
<param name="url">https://github.com/monich/harbour-books.git</param>
<param name="branch">master</param>
- <param name="revision">a29d94d</param>
+ <param name="revision">bef406d</param>
</service>
</services>
\ No newline at end of file
|
[-]
[+]
|
Deleted |
_service:tar_git:openrepos-books-1.0.46.tar.gz/app/settings/harbour-books.json
^
|
@@ -1,14 +0,0 @@
-{
- "translation_catalog" : "harbour-books",
- "entries": [
- {
- "path": "applications/harbour-books.desktop",
- "title": "Books",
- "type": "page",
- "icon": "harbour-books",
- "params": {
- "source": "/usr/share/harbour-books/settings/BooksSettings.qml"
- }
- }
- ]
-}
|
[-]
[+]
|
Changed |
_service:tar_git:openrepos-books-1.1.0.tar.gz/app/app.pro
^
|
@@ -55,13 +55,16 @@
qml/*.qml \
qml/*.js \
qml/images/* \
- settings/*.qml \
- settings/*.json \
+ settings/Books*.qml \
settings/images/* \
data/default/* \
data/zlibrary/core/encodings/* \
data/zlibrary/core/resources/*
+app_settings {
+ OTHER_FILES += settings/SystemSettings.qml
+}
+
TARGET_DATA_DIR = /usr/share/$$TARGET
TARGET_DEFAULT_DATA_DIR = $$TARGET_DATA_DIR/data
TARGET_ZLIBRARY_DATA_DIR = $$TARGET_DEFAULT_DATA_DIR
@@ -107,6 +110,8 @@
SOURCES += \
src/BooksBook.cpp \
src/BooksBookModel.cpp \
+ src/BooksColorScheme.cpp \
+ src/BooksColorSchemeModel.cpp \
src/BooksConfig.cpp \
src/BooksCoverModel.cpp \
src/BooksCoverWidget.cpp \
@@ -123,6 +128,7 @@
src/BooksPos.cpp \
src/BooksSaveTimer.cpp \
src/BooksSettings.cpp \
+ src/BooksSettingsBase.cpp \
src/BooksShelf.cpp \
src/BooksStorage.cpp \
src/BooksStorageModel.cpp \
@@ -137,6 +143,8 @@
HEADERS += \
src/BooksBook.h \
src/BooksBookModel.h \
+ src/BooksColorScheme.h \
+ src/BooksColorSchemeModel.h \
src/BooksConfig.h \
src/BooksCoverModel.h \
src/BooksCoverWidget.h \
@@ -155,6 +163,7 @@
src/BooksPos.h \
src/BooksSaveTimer.h \
src/BooksSettings.h \
+ src/BooksSettingsBase.h \
src/BooksShelf.h \
src/BooksStorage.h \
src/BooksStorageModel.h \
@@ -184,34 +193,35 @@
# harbour-lib
HEADERS += \
+ $$HARBOUR_INCLUDE_DIR/HarbourBase45.h \
+ $$HARBOUR_INCLUDE_DIR/HarbourColorEditorModel.h \
$$HARBOUR_INCLUDE_DIR/HarbourDisplayBlanking.h \
$$HARBOUR_INCLUDE_DIR/HarbourJson.h \
- $$HARBOUR_INCLUDE_DIR/HarbourMediaPlugin.h \
- $$HARBOUR_INCLUDE_DIR/HarbourPluginLoader.h \
- $$HARBOUR_INCLUDE_DIR/HarbourPolicyPlugin.h \
$$HARBOUR_INCLUDE_DIR/HarbourSystem.h \
$$HARBOUR_INCLUDE_DIR/HarbourTask.h \
- $$HARBOUR_INCLUDE_DIR/HarbourTheme.h
+ $$HARBOUR_INCLUDE_DIR/HarbourUtil.h
HEADERS += \
$$HARBOUR_SRC_DIR/HarbourMce.h
SOURCES += \
+ $$HARBOUR_SRC_DIR/HarbourBase45.cpp \
+ $$HARBOUR_SRC_DIR/HarbourColorEditorModel.cpp \
$$HARBOUR_SRC_DIR/HarbourDisplayBlanking.cpp \
$$HARBOUR_SRC_DIR/HarbourJson.cpp \
$$HARBOUR_SRC_DIR/HarbourMce.cpp \
- $$HARBOUR_SRC_DIR/HarbourMediaPlugin.cpp \
- $$HARBOUR_SRC_DIR/HarbourPluginLoader.cpp \
- $$HARBOUR_SRC_DIR/HarbourPolicyPlugin.cpp \
$$HARBOUR_SRC_DIR/HarbourSystem.cpp \
$$HARBOUR_SRC_DIR/HarbourTask.cpp \
- $$HARBOUR_SRC_DIR/HarbourTheme.cpp
+ $$HARBOUR_SRC_DIR/HarbourUtil.cpp
HARBOUR_QML_COMPONENTS = \
- $$HARBOUR_LIB_QML/HarbourFitLabel.qml \
- $$HARBOUR_LIB_QML/HarbourHighlightIcon.qml \
- $$HARBOUR_LIB_QML/HarbourHorizontalSwipeHint.qml \
- $$HARBOUR_LIB_QML/HarbourPressEffect.qml
+ $$HARBOUR_LIB_QML/HarbourColorEditorDialog.qml \
+ $$HARBOUR_LIB_QML/HarbourColorHueItem.qml \
+ $$HARBOUR_LIB_QML/HarbourColorPickerDialog.qml \
+ $$HARBOUR_LIB_QML/HarbourFitLabel.qml \
+ $$HARBOUR_LIB_QML/HarbourHighlightIcon.qml \
+ $$HARBOUR_LIB_QML/HarbourHorizontalSwipeHint.qml \
+ $$HARBOUR_LIB_QML/HarbourPressEffect.qml
OTHER_FILES += $${HARBOUR_QML_COMPONENTS}
@@ -233,17 +243,6 @@
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
@@ -262,6 +261,7 @@
# Translations
TRANSLATION_IDBASED=-idbased
TRANSLATION_SOURCES = \
+ $${_PRO_FILE_PWD_}/src \
$${_PRO_FILE_PWD_}/qml \
$${_PRO_FILE_PWD_}/settings
|
[-]
[+]
|
Changed |
_service:tar_git:openrepos-books-1.1.0.tar.gz/app/harbour-books.desktop
^
|
@@ -14,6 +14,9 @@
Icon=harbour-books
X-Nemo-Application-Type=silica-qt5
+[X-Sailjail]
+Permissions=Documents;Downloads;RemovableMedia
+
[X-HarbourBackup]
BackupPathList=.local/share/harbour-books/:Documents/Books/
BackupConfigList=/apps/harbour-books/
|
[-]
[+]
|
Changed |
_service:tar_git:openrepos-books-1.1.0.tar.gz/app/qml/Books.js
^
|
@@ -1,6 +1,6 @@
.pragma library
-var version = "1.0.46"
+var version = "1.1.0"
function contentOpacity(brightness) {
return 0.4 + brightness * 0.6
|
[-]
[+]
|
Changed |
_service:tar_git:openrepos-books-1.1.0.tar.gz/app/qml/BooksBookView.qml
^
|
@@ -1,6 +1,6 @@
/*
- Copyright (C) 2015-2021 Jolla Ltd.
- Copyright (C) 2015-2021 Slava Monich <slava.monich@jolla.com>
+ Copyright (C) 2015-2022 Jolla Ltd.
+ Copyright (C) 2015-2022 Slava Monich <slava.monich@jolla.com>
You may use this file under the terms of BSD license as follows:
@@ -37,9 +37,6 @@
import org.nemomobile.notifications 1.0
import harbour.books 1.0
-//import Sailfish.Media 1.0 // Not allowed
-//import org.nemomobile.policy 1.0 // Not allowed
-
import "harbour"
Item {
@@ -69,17 +66,42 @@
property bool isCurrentView
property bool pageActive
- readonly property bool viewActive: pageActive && Qt.application.active && !!book
- readonly property bool haveVolumeUpAction: Settings.volumeUpAction !== BooksSettings.ActionNone
- readonly property bool haveVolumeDownAction: Settings.volumeDownAction !== BooksSettings.ActionNone
- readonly property bool haveKeyAction: haveVolumeUpAction || haveVolumeDownAction
-
property var hapticFeedback
property var linkMenu
property var imageView
property var footnoteView
property var settingsComponent
+ readonly property bool viewActive: pageActive && Qt.application.active && !!book
+ readonly property bool haveVolumeUpAction: Settings.volumeUpAction !== BooksSettings.ActionNone
+ readonly property bool haveVolumeDownAction: Settings.volumeDownAction !== BooksSettings.ActionNone
+ readonly property bool haveKeyAction: haveVolumeUpAction || haveVolumeDownAction
+
+ readonly property string mediaKeyQml: BooksUtil.mediaKeyQml
+ readonly property var permissions: Qt.createQmlObject(BooksUtil.permissionsQml, root, "Permissions")
+ readonly property var volumeUp: Qt.createQmlObject(mediaKeyQml, root, "VolumeKey")
+ readonly property var volumeDown: Qt.createQmlObject(mediaKeyQml, root, "VolumeKey")
+
+ Binding { target: permissions; property: "enabled"; value: viewActive && haveKeyAction }
+ Binding { target: volumeUp; property: "enabled"; value: viewActive && haveVolumeUpAction }
+ Binding { target: volumeUp; property: "key"; value: Qt.Key_VolumeUp }
+ Binding { target: volumeDown; property: "enabled"; value: viewActive && haveVolumeDownAction }
+ Binding { target: volumeDown; property: "key"; value: Qt.Key_VolumeDown }
+
+ Connections {
+ target: volumeUp
+ ignoreUnknownSignals: true
+ onPressed: performAction(Settings.volumeUpAction)
+ onRepeat: performAction(Settings.volumeUpAction)
+ }
+
+ Connections {
+ target: volumeDown
+ ignoreUnknownSignals: true
+ onPressed: performAction(Settings.volumeDownAction)
+ onRepeat: performAction(Settings.volumeDownAction)
+ }
+
function hideViews() {
if (linkMenu) linkMenu.hide()
if (imageView) imageView.hide()
@@ -218,7 +240,7 @@
Rectangle {
id: loadingBackground
anchors.fill: parent
- color: HarbourTheme.invertedPrimaryColor
+ color: HarbourUtil.invertedColor(Theme.primaryColor)
visible: loading && opacity > 0
}
@@ -495,41 +517,4 @@
return
}
}
-
- MediaKey {
- enabled: viewActive && haveVolumeUpAction
- key: Qt.Key_VolumeUp
-
- onPressed: volumeUpAction()
- onRepeat: volumeUpAction()
-
- function volumeUpAction() {
- performAction(Settings.volumeUpAction)
- }
- }
-
- MediaKey {
- enabled: viewActive && haveVolumeDownAction
- key: Qt.Key_VolumeDown
-
- onPressed: volumeDownAction()
- onRepeat: volumeDownAction()
-
- function volumeDownAction() {
- performAction(Settings.volumeDownAction)
- }
- }
-
- Permissions {
- enabled: viewActive && haveKeyAction
- autoRelease: true
- applicationClass: "camera"
-
- Resource {
- id: volumeKeysResource
-
- type: Resource.ScaleButton
- optional: true
- }
- }
}
|
[-]
[+]
|
Changed |
_service:tar_git:openrepos-books-1.1.0.tar.gz/app/qml/BooksMain.qml
^
|
@@ -1,6 +1,6 @@
/*
- Copyright (C) 2015-2020 Jolla Ltd.
- Copyright (C) 2015-2020 Slava Monich <slava.monich@jolla.com>
+ Copyright (C) 2015-2021 Jolla Ltd.
+ Copyright (C) 2015-2021 Slava Monich <slava.monich@jolla.com>
You may use this file under the terms of BSD license as follows:
@@ -58,6 +58,12 @@
Settings.keepDisplayOn
}
+ Binding {
+ target: Settings
+ property: "theme"
+ value: Theme
+ }
+
initialPage: BooksMainPage { id: mainPage }
cover: Component {
|
[-]
[+]
|
Changed |
_service:tar_git:openrepos-books-1.1.0.tar.gz/app/qml/BooksMainPage.qml
^
|
@@ -1,6 +1,6 @@
/*
- Copyright (C) 2015-2021 Jolla Ltd.
- Copyright (C) 2015-2021 Slava Monich <slava.monich@jolla.com>
+ Copyright (C) 2015-2022 Jolla Ltd.
+ Copyright (C) 2015-2022 Slava Monich <slava.monich@jolla.com>
You may use this file under the terms of BSD license as follows:
@@ -124,7 +124,7 @@
isCurrentView: currentView === bookView
pageActive: page.pageActive
book: Settings.currentBook ? Settings.currentBook : null
- loadingBackgroundOpacity: HarbourTheme.opacityOverlay * storageView.opacity
+ loadingBackgroundOpacity: 0.8 /* opacityOverlay */ * storageView.opacity
onCloseBook: Settings.currentBook = null
onVisibleChanged: if (visible) opacity = 1
|
[-]
[+]
|
Changed |
_service:tar_git:openrepos-books-1.1.0.tar.gz/app/qml/BooksPageTools.qml
^
|
@@ -1,6 +1,6 @@
/*
- Copyright (C) 2015-2019 Jolla Ltd.
- Copyright (C) 2015-2019 Slava Monich <slava.monich@jolla.com>
+ Copyright (C) 2015-2022 Jolla Ltd.
+ Copyright (C) 2015-2022 Slava Monich <slava.monich@jolla.com>
You may use this file under the terms of BSD license as follows:
@@ -35,6 +35,8 @@
import Sailfish.Silica 1.0
import harbour.books 1.0
+import "harbour"
+
Item {
id: pageTools
height: Theme.itemSizeExtraSmall
@@ -57,9 +59,9 @@
left: parent.left
verticalCenter: parent.verticalCenter
}
- onClicked: Settings.invertColors = !Settings.invertColors
+ onClicked: Settings.nightMode = !Settings.nightMode
- Image {
+ HarbourHighlightIcon {
id: dayModeImage
source: "images/day-mode.svg"
anchors {
@@ -68,16 +70,18 @@
verticalCenter: parent.verticalCenter
}
sourceSize.height: Theme.iconSizeSmall
- opacity: Settings.invertColors ? 0.5 : 0
+ highlightColor: Settings.primaryPageToolColor
+ opacity: Settings.nightMode ? 1 : 0
visible: opacity > 0
Behavior on opacity { FadeAnimation {} }
}
- Image {
+ HarbourHighlightIcon {
source: "images/night-mode.svg"
anchors.centerIn: dayModeImage
sourceSize.height: Theme.iconSizeSmall
- opacity: Settings.invertColors ? 0 : 0.25
+ highlightColor: Settings.primaryPageToolColor
+ opacity: Settings.nightMode ? 0 : 1
visible: opacity > 0
Behavior on opacity { FadeAnimation {} }
}
@@ -93,7 +97,7 @@
right: parent.right
verticalCenter: parent.verticalCenter
}
- Image {
+ HarbourHighlightIcon {
id: increaseFontSizeButtonImage
source: "images/font-larger.svg"
anchors {
@@ -101,8 +105,7 @@
verticalCenter: parent.verticalCenter
}
sourceSize.height: Theme.iconSizeSmall
- opacity: Settings.invertColors ? 1 : 0.5
- Behavior on opacity { FadeAnimation {} }
+ highlightColor: Settings.primaryPageToolColor
}
onClicked: pageTools.increaseFontSize()
}
@@ -115,7 +118,7 @@
right: increaseFontSizeButton.left
verticalCenter: parent.verticalCenter
}
- Image {
+ HarbourHighlightIcon {
id: decreaseFontSizeButtonImage
source: "images/font-smaller.svg"
anchors {
@@ -123,8 +126,7 @@
verticalCenter: parent.verticalCenter
}
sourceSize.height: increaseFontSizeButtonImage.height
- opacity: Settings.invertColors ? 1 : 0.5
- Behavior on opacity { FadeAnimation {} }
+ highlightColor: Settings.primaryPageToolColor
}
onClicked: pageTools.decreaseFontSize()
}
|
[-]
[+]
|
Changed |
_service:tar_git:openrepos-books-1.1.0.tar.gz/app/qml/BooksPageView.qml
^
|
@@ -1,6 +1,6 @@
/*
- Copyright (C) 2015-2020 Jolla Ltd.
- Copyright (C) 2015-2020 Slava Monich <slava.monich@jolla.com>
+ Copyright (C) 2015-2021 Jolla Ltd.
+ Copyright (C) 2015-2021 Slava Monich <slava.monich@jolla.com>
You may use this file under the terms of BSD license as follows:
@@ -109,7 +109,7 @@
Image {
id: pressImage
- source: Settings.invertColors ? "images/press-invert.svg" : "images/press.svg"
+ source: Settings.nightMode ? "images/press-invert.svg" : "images/press.svg"
visible: opacity > 0
opacity: 0
readonly property int maxsize: Math.max(view.width, view.height)
|
[-]
[+]
|
Changed |
_service:tar_git:openrepos-books-1.1.0.tar.gz/app/qml/BooksStorageView.qml
^
|
@@ -1,6 +1,6 @@
/*
- Copyright (C) 2015-2021 Jolla Ltd.
- Copyright (C) 2015-2021 Slava Monich <slava.monich@jolla.com>
+ Copyright (C) 2015-2022 Jolla Ltd.
+ Copyright (C) 2015-2022 Slava Monich <slava.monich@jolla.com>
You may use this file under the terms of BSD license as follows:
@@ -113,7 +113,7 @@
pageStack.push(_settingsComponent, {
"title" : text,
"allowedOrientations": window.allowedOrientations,
- "inApp": true
+ "inApp": true,
})
}
}
@@ -301,6 +301,9 @@
// This hides the target item until the grag item makes it to the destination:
dragItem.dropShelfIndex = currentShelfIndex
dragItem.dropItemIndex = targetIndex
+ } else {
+ currentShelf.hasDummyItem = false
+ currentShelf.dummyItemIndex = -1
}
}
}
|
[-]
[+]
|
Changed |
_service:tar_git:openrepos-books-1.1.0.tar.gz/app/qml/images/font-larger.svg
^
|
@@ -1,57 +1,33 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
-<!-- Created with Inkscape (http://www.inkscape.org/) -->
-
<svg
- xmlns:dc="http://purl.org/dc/elements/1.1/"
- xmlns:cc="http://creativecommons.org/ns#"
- xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:svg="http://www.w3.org/2000/svg"
xmlns="http://www.w3.org/2000/svg"
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
width="100"
height="64"
- id="svg4459"
version="1.1"
- inkscape:version="0.48.4 r9939"
+ inkscape:version="0.92.5 (2060ec1f9f, 2020-04-08)"
sodipodi:docname="font-larger.svg">
- <defs
- id="defs4461" />
- <metadata
- id="metadata4464">
- <rdf:RDF>
- <cc:Work
- rdf:about="">
- <dc:format>image/svg+xml</dc:format>
- <dc:type
- rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
- <dc:title />
- </cc:Work>
- </rdf:RDF>
- </metadata>
+ <rect
+ style="opacity:0;fill:#ffffff"
+ height="64"
+ width="100"/>
<g
- inkscape:label="Layer 1"
- inkscape:groupmode="layer"
- id="layer1"
transform="translate(-14,-946.02223)">
<g
- style="fill:#808080;fill-opacity:1;stroke:none"
- id="text4477"
transform="matrix(1.6163793,0,0,1.5182163,-0.62931024,-534.45853)">
<path
- d="m 14,994.18217 7.12,0 0,-7.84 4.32,0 0,7.84 7.12,0 0,4.08 -7.12,0 0,7.84003 -4.32,0 0,-7.84003 -7.12,0 0,-4.08"
- id="path5549"
- inkscape:connector-curvature="0" />
+ style="fill:#ffffff;fill-opacity:1;stroke:none"
+ d="m 14,994.18217 h 7.12 v -7.84 h 4.32 v 7.84 h 7.12 v 4.08 h -7.12 v 7.84003 h -4.32 v -7.84003 H 14 v -4.08"
+ inkscape:connector-curvature="0"/>
</g>
<g
- transform="matrix(1.7406963,0,0,1.7391304,12.768306,943.23962)"
- style="fill:#808080;fill-opacity:1;stroke:none"
- id="text5562">
+ transform="matrix(1.7406963,0,0,1.7391304,12.768306,943.23962)">
<path
- d="m 53.56,33.8 -11.16,0 0,-1.8 c 1.013315,-0.05333 1.719981,-0.159998 2.12,-0.32 0.39998,-0.159998 0.59998,-0.439997 0.6,-0.84 -2e-5,-0.346663 -0.28002,-1.199996 -0.84,-2.56 L 43,25.12 l -9.76,0 c -0.106675,0.320008 -0.360008,0.920008 -0.76,1.8 -0.400007,0.853339 -0.720007,1.626672 -0.96,2.32 -0.240006,0.666671 -0.360006,1.200003 -0.36,1.6 -6e-6,0.480002 0.22666,0.800002 0.68,0.96 0.479993,0.133335 1.173325,0.200002 2.08,0.2 l 0,1.8 -8.92,0 0,-1.72 c 0.293333,-0.02667 0.573333,-0.08 0.84,-0.16 0.266666,-0.08 0.519999,-0.199998 0.76,-0.36 0.239998,-0.186664 0.453331,-0.346664 0.64,-0.48 0.186664,-0.159997 0.373331,-0.399997 0.56,-0.72 0.21333,-0.319996 0.37333,-0.573329 0.48,-0.76 0.13333,-0.186662 0.306663,-0.493329 0.52,-0.92 0.213329,-0.453328 0.359996,-0.786661 0.44,-1 0.106662,-0.213327 0.266662,-0.58666 0.48,-1.12 0.239995,-0.559992 0.413328,-0.946658 0.52,-1.16 l 8.04,-19.2 1.76,0 9.68,22.24 c 0.639975,1.493337 1.119974,2.400003 1.44,2.72 0.533307,0.560002 1.333306,0.840002 2.4,0.84 l 0,1.8 m -11.52,-11.24 -3.96,-9.28 -3.8,9.28 7.76,0"
- id="path5570"
+ d="M 53.56,33.8 H 42.4 V 32 c 1.013315,-0.05333 1.719981,-0.159998 2.12,-0.32 0.39998,-0.159998 0.59998,-0.439997 0.6,-0.84 -2e-5,-0.346663 -0.28002,-1.199996 -0.84,-2.56 L 43,25.12 h -9.76 c -0.106675,0.320008 -0.360008,0.920008 -0.76,1.8 -0.400007,0.853339 -0.720007,1.626672 -0.96,2.32 -0.240006,0.666671 -0.360006,1.200003 -0.36,1.6 -6e-6,0.480002 0.22666,0.800002 0.68,0.96 0.479993,0.133335 1.173325,0.200002 2.08,0.2 v 1.8 H 25 v -1.72 c 0.293333,-0.02667 0.573333,-0.08 0.84,-0.16 0.266666,-0.08 0.519999,-0.199998 0.76,-0.36 0.239998,-0.186664 0.453331,-0.346664 0.64,-0.48 0.186664,-0.159997 0.373331,-0.399997 0.56,-0.72 0.21333,-0.319996 0.37333,-0.573329 0.48,-0.76 0.13333,-0.186662 0.306663,-0.493329 0.52,-0.92 0.213329,-0.453328 0.359996,-0.786661 0.44,-1 0.106662,-0.213327 0.266662,-0.58666 0.48,-1.12 0.239995,-0.559992 0.413328,-0.946658 0.52,-1.16 L 38.28,6.2 h 1.76 l 9.68,22.24 c 0.639975,1.493337 1.119974,2.400003 1.44,2.72 0.533307,0.560002 1.333306,0.840002 2.4,0.84 v 1.8 m -11.52,-11.24 -3.96,-9.28 -3.8,9.28 h 7.76"
inkscape:connector-curvature="0"
- style="fill:#808080;fill-opacity:1" />
+ style="fill:#ffffff;fill-opacity:1"/>
</g>
</g>
</svg>
|
[-]
[+]
|
Changed |
_service:tar_git:openrepos-books-1.1.0.tar.gz/app/qml/images/font-smaller.svg
^
|
@@ -1,57 +1,33 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
-<!-- Created with Inkscape (http://www.inkscape.org/) -->
-
<svg
- xmlns:dc="http://purl.org/dc/elements/1.1/"
- xmlns:cc="http://creativecommons.org/ns#"
- xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:svg="http://www.w3.org/2000/svg"
xmlns="http://www.w3.org/2000/svg"
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
width="64"
height="64"
- id="svg4449"
version="1.1"
- inkscape:version="0.48.4 r9939"
+ inkscape:version="0.92.5 (2060ec1f9f, 2020-04-08)"
sodipodi:docname="font-smaller.svg">
- <defs
- id="defs4451" />
- <metadata
- id="metadata4454">
- <rdf:RDF>
- <cc:Work
- rdf:about="">
- <dc:format>image/svg+xml</dc:format>
- <dc:type
- rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
- <dc:title />
- </cc:Work>
- </rdf:RDF>
- </metadata>
+ <rect
+ style="opacity:0;fill:#ffffff"
+ height="64"
+ width="64"/>
<g
- id="layer1"
- inkscape:label="Layer 1"
- inkscape:groupmode="layer"
transform="translate(-14,49.620001)">
<g
- style="fill:#808080;fill-opacity:1;stroke:none"
- id="text4469"
transform="matrix(1.2081784,0,0,1.1261261,5.0855019,-14.592736)">
<path
- d="m 14,2.7799982 10.76,0 0,4.44 -10.76,0 0,-4.44"
- id="path5540"
- inkscape:connector-curvature="0" />
+ style="fill:#ffffff;fill-opacity:1;stroke:none"
+ d="m 14,2.7799982 h 10.76 v 4.44 H 14 v -4.44"
+ inkscape:connector-curvature="0"/>
</g>
<g
- transform="matrix(1.7673813,0,0,1.7057569,5.0734262,-43.73514)"
- style="fill:#808080;fill-opacity:1;stroke:none"
- id="text5558">
+ transform="matrix(1.7673813,0,0,1.7057569,5.0734262,-43.73514)">
<path
- d="m 20.72,15.14 c -2e-6,-0.293319 0.09333,-0.653319 0.28,-1.08 0.186664,-0.453318 0.49333,-0.946651 0.92,-1.48 0.453329,-0.559983 1.159995,-1.026649 2.12,-1.4 0.959993,-0.373315 2.106659,-0.559982 3.44,-0.56 2.186655,1.8e-5 3.679987,0.520018 4.48,1.56 0.826652,1.013349 1.239985,2.773347 1.24,5.28 l 0,8.4 c -1.5e-5,0.826669 0.306652,1.240001 0.92,1.24 0.479984,10e-7 1.173316,-0.306665 2.08,-0.92 l 0,1.04 c -0.400017,0.480001 -0.93335,0.96 -1.6,1.44 -0.640016,0.479999 -1.213348,0.719999 -1.72,0.72 -0.960014,-10e-7 -1.666679,-0.293334 -2.12,-0.88 -0.453345,-0.586666 -0.706678,-1.319999 -0.76,-2.2 -2.213343,2.053334 -4.133341,3.079999 -5.76,3.08 -1.200005,-10e-7 -2.213337,-0.413334 -3.04,-1.24 -0.800002,-0.826665 -1.200002,-1.826664 -1.2,-3 -2e-6,-0.586663 0.09333,-1.133329 0.28,-1.64 0.213331,-0.533328 0.466664,-0.999994 0.76,-1.4 0.29333,-0.399993 0.69333,-0.786659 1.2,-1.16 0.506662,-0.399992 0.973329,-0.733325 1.4,-1 0.426661,-0.266658 0.959994,-0.533324 1.6,-0.8 0.666659,-0.293324 1.199992,-0.51999 1.6,-0.68 0.426658,-0.15999 0.959991,-0.35999 1.6,-0.6 0.666656,-0.239989 1.133322,-0.413322 1.4,-0.52 -1.1e-5,-2.239986 -0.186678,-3.759985 -0.56,-4.56 -0.373344,-0.82665 -1.16001,-1.239983 -2.36,-1.24 -0.453341,1.7e-5 -0.960008,0.106684 -1.52,0.32 -0.53334,0.21335 -0.906673,0.480016 -1.12,0.8 -0.05334,0.213349 -0.08001,0.413349 -0.08,0.6 -6e-6,0.133349 0.01333,0.400015 0.04,0.8 0.02666,0.373348 0.03999,0.680014 0.04,0.92 -6e-6,0.453347 -0.186672,0.86668 -0.56,1.24 -0.346672,0.373345 -0.746671,0.560012 -1.2,0.56 -0.58667,1.2e-5 -1.040003,-0.146655 -1.36,-0.44 -0.293336,-0.319987 -0.440002,-0.719987 -0.44,-1.2 m 9.12,10.04 0,-6.8 c -0.266678,0.106677 -0.706677,0.28001 -1.32,0.52 -0.613343,0.213343 -1.106676,0.400009 -1.48,0.56 -0.373342,0.133342 -0.813341,0.346675 -1.32,0.64 -0.506673,0.266675 -0.906673,0.560008 -1.2,0.88 -0.266673,0.293341 -0.506672,0.680007 -0.72,1.16 -0.213339,0.453339 -0.320005,0.973339 -0.32,1.56 -5e-6,0.933337 0.239995,1.720003 0.72,2.36 0.50666,0.613335 1.213326,0.920002 2.12,0.92 0.479992,2e-6 1.133324,-0.186665 1.96,-0.56 0.853323,-0.399997 1.373322,-0.81333 1.56,-1.24"
- id="path5567"
+ d="m 20.72,15.14 c -2e-6,-0.293319 0.09333,-0.653319 0.28,-1.08 0.186664,-0.453318 0.49333,-0.946651 0.92,-1.48 0.453329,-0.559983 1.159995,-1.026649 2.12,-1.4 0.959993,-0.373315 2.106659,-0.559982 3.44,-0.56 2.186655,1.8e-5 3.679987,0.520018 4.48,1.56 0.826652,1.013349 1.239985,2.773347 1.24,5.28 v 8.4 c -1.5e-5,0.826669 0.306652,1.240001 0.92,1.24 0.479984,10e-7 1.173316,-0.306665 2.08,-0.92 v 1.04 c -0.400017,0.480001 -0.93335,0.96 -1.6,1.44 -0.640016,0.479999 -1.213348,0.719999 -1.72,0.72 -0.960014,-10e-7 -1.666679,-0.293334 -2.12,-0.88 -0.453345,-0.586666 -0.706678,-1.319999 -0.76,-2.2 -2.213343,2.053334 -4.133341,3.079999 -5.76,3.08 -1.200005,-10e-7 -2.213337,-0.413334 -3.04,-1.24 -0.800002,-0.826665 -1.200002,-1.826664 -1.2,-3 -2e-6,-0.586663 0.09333,-1.133329 0.28,-1.64 0.213331,-0.533328 0.466664,-0.999994 0.76,-1.4 0.29333,-0.399993 0.69333,-0.786659 1.2,-1.16 0.506662,-0.399992 0.973329,-0.733325 1.4,-1 0.426661,-0.266658 0.959994,-0.533324 1.6,-0.8 0.666659,-0.293324 1.199992,-0.51999 1.6,-0.68 0.426658,-0.15999 0.959991,-0.35999 1.6,-0.6 0.666656,-0.239989 1.133322,-0.413322 1.4,-0.52 -1.1e-5,-2.239986 -0.186678,-3.759985 -0.56,-4.56 -0.373344,-0.82665 -1.16001,-1.239983 -2.36,-1.24 -0.453341,1.7e-5 -0.960008,0.106684 -1.52,0.32 -0.53334,0.21335 -0.906673,0.480016 -1.12,0.8 -0.05334,0.213349 -0.08001,0.413349 -0.08,0.6 -6e-6,0.133349 0.01333,0.400015 0.04,0.8 0.02666,0.373348 0.03999,0.680014 0.04,0.92 -6e-6,0.453347 -0.186672,0.86668 -0.56,1.24 -0.346672,0.373345 -0.746671,0.560012 -1.2,0.56 -0.58667,1.2e-5 -1.040003,-0.146655 -1.36,-0.44 -0.293336,-0.319987 -0.440002,-0.719987 -0.44,-1.2 m 9.12,10.04 v -6.8 c -0.266678,0.106677 -0.706677,0.28001 -1.32,0.52 -0.613343,0.213343 -1.106676,0.400009 -1.48,0.56 -0.373342,0.133342 -0.813341,0.346675 -1.32,0.64 -0.506673,0.266675 -0.906673,0.560008 -1.2,0.88 -0.266673,0.293341 -0.506672,0.680007 -0.72,1.16 -0.213339,0.453339 -0.320005,0.973339 -0.32,1.56 -5e-6,0.933337 0.239995,1.720003 0.72,2.36 0.50666,0.613335 1.213326,0.920002 2.12,0.92 0.479992,2e-6 1.133324,-0.186665 1.96,-0.56 0.853323,-0.399997 1.373322,-0.81333 1.56,-1.24"
inkscape:connector-curvature="0"
- style="fill:#808080;fill-opacity:1" />
+ style="fill:#ffffff;fill-opacity:1"/>
</g>
</g>
</svg>
|
[-]
[+]
|
Changed |
_service:tar_git:openrepos-books-1.1.0.tar.gz/app/qml/images/night-mode.svg
^
|
@@ -1,75 +1,27 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
-<!-- Created with Inkscape (http://www.inkscape.org/) -->
-
<svg
- xmlns:dc="http://purl.org/dc/elements/1.1/"
- xmlns:cc="http://creativecommons.org/ns#"
- xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:svg="http://www.w3.org/2000/svg"
xmlns="http://www.w3.org/2000/svg"
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
width="64"
height="64"
- id="svg2"
version="1.1"
- inkscape:version="0.48.4 r9939"
+ inkscape:version="0.92.5 (2060ec1f9f, 2020-04-08)"
sodipodi:docname="night-mode.svg">
- <defs
- id="defs4" />
- <metadata
- id="metadata7">
- <rdf:RDF>
- <cc:Work
- rdf:about="">
- <dc:format>image/svg+xml</dc:format>
- <dc:type
- rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
- <dc:title />
- </cc:Work>
- </rdf:RDF>
- </metadata>
+ <rect
+ style="opacity:0;fill:#ffffff"
+ height="64"
+ width="64"/>
<g
- inkscape:label="Layer 1"
- inkscape:groupmode="layer"
- id="layer1"
transform="translate(0,-988.36215)">
- <path
- sodipodi:type="arc"
- style="opacity:0;fill:#000000;fill-opacity:0.50196078;stroke:#808080;stroke-width:10;stroke-linecap:square;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none"
- id="path3778"
- sodipodi:cx="42.5"
- sodipodi:cy="52.5"
- sodipodi:rx="27.5"
- sodipodi:ry="27.5"
- d="m 70,52.5 a 27.5,27.5 0 1 1 -55,0 27.5,27.5 0 1 1 55,0 z"
- transform="matrix(0.48,0,0,0.48,9.180329,978.36216)" />
- <path
- sodipodi:type="arc"
- style="opacity:0;fill:#000000;fill-opacity:0.50196078;stroke:#000000;stroke-width:10;stroke-linecap:square;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none"
- id="path3790"
- sodipodi:cx="47.5"
- sodipodi:cy="50"
- sodipodi:rx="32.5"
- sodipodi:ry="35"
- d="M 80,50 C 80,69.329966 65.449254,85 47.5,85 29.550746,85 15,69.329966 15,50 15,30.670034 29.550746,15 47.5,15 65.449254,15 80,30.670034 80,50 z"
- transform="matrix(0.48,0,0,0.48,21.180329,978.36216)" />
<g
- transform="matrix(0.33942251,-0.33942251,0.33942251,0.33942251,-0.9,1024.6049)"
- id="g8">
- <rect
- id="rect3794"
- height="48"
- width="48"
- style="fill:none"
- x="0"
- y="0" />
+ transform="matrix(0.33942251,-0.33942251,0.33942251,0.33942251,-0.9,1024.6049)">
<path
- id="path3800"
d="m 54.714286,-7.78571 c -27.611111,0 -50.0000003,22.388889 -50.0000003,50 0,27.611111 22.3888893,50 50.0000003,50 27.611111,0 50.000004,-22.388889 50.000004,-50 0,-27.611111 -22.388893,-50 -50.000004,-50 z m 9.781481,83.492593 c -2.925925,0.8 -5.996296,1.229629 -9.174074,1.229629 -19.177777,0 -34.388888,-15.540741 -34.388888,-34.722222 0,-19.174074 15.211111,-34.722222 34.388888,-34.722222 3.174074,0 6.248149,0.433333 9.174074,1.237037 -14.729629,4.018518 -25.04074,17.485185 -25.04074,33.485185 0,16 10.311111,29.462963 25.04074,33.492593 z"
- style="fill:#000000;fill-opacity:1"
+ style="fill:#ffffff;fill-opacity:1"
inkscape:connector-curvature="0"
- sodipodi:nodetypes="ssssscssscsc" />
+ sodipodi:nodetypes="ssssscssscsc"/>
</g>
</g>
</svg>
|
[-]
[+]
|
Changed |
_service:tar_git:openrepos-books-1.1.0.tar.gz/app/settings/BooksSettings.qml
^
|
@@ -1,6 +1,6 @@
/*
- Copyright (C) 2015-2021 Jolla Ltd.
- Copyright (C) 2015-2021 Slava Monich <slava.monich@jolla.com>
+ Copyright (C) 2015-2022 Jolla Ltd.
+ Copyright (C) 2015-2022 Slava Monich <slava.monich@jolla.com>
You may use this file under the terms of BSD license as follows:
@@ -32,530 +32,18 @@
*/
import QtQuick 2.0
-import Sailfish.Silica 1.0
-import org.nemomobile.configuration 1.0
+import harbour.books 1.0
-import "../qml/Books.js" as Books
-import "../qml/harbour"
-
-Page {
- id: page
-
- property bool inApp
- property alias title: pageHeader.title
- readonly property string rootPath: "/apps/" + appName() + "/"
- readonly property bool darkOnLight: ('colorScheme' in Theme) && Theme.colorScheme === 1
- readonly property int screenWidth: isPortrait ? Screen.width : Screen.height
- readonly property int screenHeight: isPortrait ? Screen.height : Screen.width
- readonly property bool landscapeLayout: (screenWidth > screenHeight && Screen.sizeCategory > Screen.Small) || Screen.sizeCategory > Screen.Medium
-
- // jolla-settings expects these properties:
- property var applicationName
- property var applicationIcon
-
- // 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("-books") >= 0) {
- return name
- }
- }
- return "harbour-books"
+// In-app settings
+BooksSettingsBase {
+ inApp: true
+ colorSchemeModel: BooksColorSchemeModel {
+ Component.onCompleted: colorScheme = Settings.customColorScheme
+ onColorSchemeChanged: Settings.customColorScheme = colorScheme
}
-
- Loader {
- active: inApp // Follow orientation changes
- Connections {
- target: orientation
- onValueChanged: allowedOrientations =
- (orientation.value === 1) ? Orientation.Portrait :
- (orientation.value === 2) ? Orientation.Landscape :
- Orientation.All
- }
- }
-
- SilicaFlickable {
- anchors.fill: parent
- contentHeight: content.height
-
- // Night mode example (positioned right above the slider)
- Rectangle {
- opacity: nightModeBrightnessSlider.pressed ? 1.0 : 0
- visible: opacity > 0
- radius: Theme.paddingSmall
- width: nightModeExampleLabel.width + 2 * Theme.paddingLarge
- height: nightModeExampleLabel.height + 2 * Theme.paddingMedium
- readonly property int xMin: nightModeBrightnessSlider.leftMargin
- readonly property int xMax: content.width - nightModeBrightnessSlider.rightMargin - width
- readonly property int yOffset: landscapeLayout ? (Theme.itemSizeExtraLarge - Theme.itemSizeMedium) : 0
- x: content.x + displayGrid.x + Math.max(Math.min(nightModeBrightnessSlider.sliderLeft + Math.round(nightModeBrightnessSlider.sliderThumbX - width/2.0), xMax), xMin)
- y: content.y + displayGrid.y + nightModeBrightnessSlider.y + yOffset - height
- z: nightModeBrightnessSlider.z + 1
- color: "black"
- border {
- color: Theme.highlightColor
- width: Math.ceil(radius/5)
- }
-
- Label {
- id: nightModeExampleLabel
-
- anchors.centerIn: parent
- color: "white"
- opacity: Books.contentOpacity(nightModeBrightness.value)
- //: Night mode example label
- //% "Night mode"
- text: qsTrId("harbour-books-settings-page-night_mode_example")
- font {
- bold: true
- pixelSize: Theme.fontSizeLarge
- family: "Times"
- }
- }
-
- Behavior on x { SmoothedAnimation { duration: 125 } }
- Behavior on opacity { FadeAnimation { duration: 500 } }
- }
-
- Column {
- id: content
- width: parent.width
-
- PageHeader {
- id: pageHeader
- rightMargin: Theme.horizontalPageMargin + (appIcon.visible ? (height - appIcon.padding) : 0)
- title: applicationName ? applicationName :
- //: Settings page header (app name)
- //% "Books"
- qsTrId("harbour-books-settings-page-header")
- description: inApp ? "" :
- //: Settings page header description (app version)
- //% "Version %1"
- qsTrId("harbour-books-settings-version").arg(Books.version)
-
- 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
- }
- }
-
- // =============== Display ===============
-
- SectionHeader {
- //: Section header for display settings
- //% "Display"
- text: qsTrId("harbour-books-settings-page-display-section_header")
- }
-
- Grid {
- id: displayGrid
-
- width: parent.width
- columns: landscapeLayout ? 2 : 1
-
- readonly property real columnWidth: width/columns
-
- Slider {
- id: fontSizeSlider
-
- minimumValue: -5
- maximumValue: 15
- stepSize: 1
- width: parent.columnWidth
- leftMargin: landscapeLayout ? Theme.horizontalPageMargin : nightModeBrightnessSlider.leftMargin
- rightMargin: leftMargin
- //: Slider value label for the standard font size
- //% "Default"
- readonly property string normal: qsTrId("harbour-books-settings-page-font_size_label-default")
- //: Slider label
- //% "Font size"
- label: qsTrId("harbour-books-settings-page-font_size_label")
- valueText: (value === 0) ? normal : ((value > 0) ? ("+" + value) : value)
- onSliderValueChanged: fontSize.value = value
- Component.onCompleted: value = fontSize.value
-
- ConfigurationValue {
- id: fontSize
- key: rootPath + "fontSize"
- defaultValue: 0
- onValueChanged: fontSizeSlider.value = value
- }
- }
-
- Slider {
- id: nightModeBrightnessSlider
-
- width: parent.columnWidth
- leftMargin: keepDisplayOnSwitch.leftMargin - Theme.paddingLarge + Theme.itemSizeExtraSmall
- rightMargin: leftMargin
- //: Slider label
- //% "Brightness in night mode"
- label: qsTrId("harbour-books-settings-page-night_mode_brightness_label")
- stepSize: (maximumValue - minimumValue) / 100.0
- onSliderValueChanged: nightModeBrightness.value = value
- value: nightModeBrightness.value
- valueText: landscapeLayout ? " " : ""
-
- readonly property real sliderLeft: x + leftMargin
- readonly property real sliderRight: x + width - rightMargin
- readonly property real sliderWidth: width - leftMargin - rightMargin
- readonly property real sliderThumbX: sliderLeft + (maximumValue > minimumValue) ? (sliderWidth * sliderValue / (maximumValue - minimumValue)) : 0
- readonly property real sliderBarVerticalCenter: Math.round(height - Theme.fontSizeSmall - Theme.paddingSmall - Theme.itemSizeExtraSmall*3/8)
- readonly property color highlightColor: highlighted ? Theme.secondaryHighlightColor : Theme.secondaryColor
|
[-]
[+]
|
Added |
_service:tar_git:openrepos-books-1.1.0.tar.gz/app/settings/BooksSettingsBase.qml
^
|
@@ -0,0 +1,698 @@
+/*
+ Copyright (C) 2015-2022 Jolla Ltd.
+ Copyright (C) 2015-2022 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:
+
+ 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
+ distribution.
+ 3. Neither the names of the copyright holders 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
+
+import "../qml/Books.js" as Books
+import "../qml/harbour"
+
+Page {
+ id: thisPage
+
+ property bool inApp
+ property var colorSchemeModel
+ property var colorEditorModel
+ property alias title: pageHeader.title
+
+ signal resetColors()
+
+ // jolla-settings expects these properties:
+ property var applicationName
+ property var applicationIcon
+
+ // Internal properties
+ readonly property string _rootPath: "/apps/" + appName() + "/"
+ readonly property bool _darkOnLight: ('colorScheme' in Theme) && Theme.colorScheme === 1
+ readonly property int _screenWidth: isPortrait ? Screen.width : Screen.height
+ readonly property int _screenHeight: isPortrait ? Screen.height : Screen.width
+ readonly property bool _landscapeLayout: (_screenWidth > _screenHeight && Screen.sizeCategory > Screen.Small) || Screen.sizeCategory > Screen.Medium
+
+ // 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("-books") >= 0) {
+ return name
+ }
+ }
+ return "harbour-books"
+ }
+
+ Loader {
+ active: inApp // Follow orientation changes
+ Connections {
+ target: orientation
+ onValueChanged: allowedOrientations =
+ (orientation.value === 1) ? Orientation.Portrait :
+ (orientation.value === 2) ? Orientation.Landscape :
+ Orientation.All
+ }
+ }
+
+ SilicaFlickable {
+ anchors.fill: parent
+ contentHeight: content.height
+
+ // Night mode example (positioned right above the slider)
+ Rectangle {
+ opacity: nightModeBrightnessSlider.pressed ? 1.0 : 0
+ visible: opacity > 0
+ radius: Theme.paddingSmall
+ width: nightModeExampleLabel.width + 2 * Theme.paddingLarge
+ height: nightModeExampleLabel.height + 2 * Theme.paddingMedium
+ readonly property int xMin: nightModeBrightnessSlider.leftMargin
+ readonly property int xMax: content.width - nightModeBrightnessSlider.rightMargin - width
+ readonly property int yOffset: _landscapeLayout ? (Theme.itemSizeExtraLarge - Theme.itemSizeMedium) : 0
+ x: content.x + displayGrid.x + Math.max(Math.min(nightModeBrightnessSlider.sliderLeft + Math.round(nightModeBrightnessSlider.sliderThumbX - width/2.0), xMax), xMin)
+ y: content.y + displayGrid.y + nightModeBrightnessSlider.y + yOffset - height
+ z: nightModeBrightnessSlider.z + 1
+ color: "black"
+ border {
+ color: Theme.highlightColor
+ width: Math.ceil(radius/5)
+ }
+
+ Label {
+ id: nightModeExampleLabel
+
+ anchors.centerIn: parent
+ color: "white"
+ opacity: Books.contentOpacity(nightModeBrightness.value)
+ //: Night mode example label
+ //% "Night mode"
+ text: qsTrId("harbour-books-settings-page-night_mode_example")
+ font {
+ bold: true
+ pixelSize: Theme.fontSizeLarge
+ family: "Times"
+ }
+ }
+
+ Behavior on x { SmoothedAnimation { duration: 125 } }
+ Behavior on opacity { FadeAnimation { duration: 500 } }
+ }
+
+ Column {
+ id: content
+ width: parent.width
+
+ PageHeader {
+ id: pageHeader
+ rightMargin: Theme.horizontalPageMargin + (appIcon.visible ? (height - appIcon.padding) : 0)
+ title: applicationName ? applicationName :
+ //: Settings page header (app name)
+ //% "Books"
+ qsTrId("harbour-books-settings-page-header")
+ description: inApp ? "" :
+ //: Settings page header description (app version)
+ //% "Version %1"
+ qsTrId("harbour-books-settings-version").arg(Books.version)
+
+ 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
+ }
+ }
+
+ // =============== Display ===============
+
+ SectionHeader {
+ //: Section header for display settings
+ //% "Display"
+ text: qsTrId("harbour-books-settings-page-display-section_header")
+ }
+
+ Grid {
+ id: displayGrid
+
+ width: parent.width
+ columns: _landscapeLayout ? 2 : 1
+
+ readonly property real columnWidth: width/columns
+
+ Slider {
+ id: fontSizeSlider
+
+ minimumValue: -5
+ maximumValue: 15
+ stepSize: 1
+ width: parent.columnWidth
+ leftMargin: _landscapeLayout ? Theme.horizontalPageMargin : nightModeBrightnessSlider.leftMargin
+ rightMargin: leftMargin
+ //: Slider value label for the standard font size
+ //% "Default"
+ readonly property string normal: qsTrId("harbour-books-settings-page-font_size_label-default")
+ //: Slider label
+ //% "Font size"
+ label: qsTrId("harbour-books-settings-page-font_size_label")
+ valueText: (value === 0) ? normal : ((value > 0) ? ("+" + value) : value)
+ onSliderValueChanged: fontSize.value = value
+ Component.onCompleted: value = fontSize.value
+
+ ConfigurationValue {
+ id: fontSize
+ key: _rootPath + "fontSize"
+ defaultValue: 0
+ onValueChanged: fontSizeSlider.value = value
+ }
+ }
|
[-]
[+]
|
Added |
_service:tar_git:openrepos-books-1.1.0.tar.gz/app/settings/BooksSettingsPlugin.cpp
^
|
@@ -0,0 +1,79 @@
+/*
+ * Copyright (C) 2022 Jolla Ltd.
+ * Copyright (C) 2022 Slava Monich <slava.monich@jolla.com>
+ *
+ * You may use this file under the terms of the 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:
+ *
+ * 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
+ * distribution.
+ * 3. Neither the names of the copyright holders 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
+ * OWNER 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.
+ */
+
+#include "BooksColorSchemeModel.h"
+#include "BooksSettingsBase.h"
+
+#include "HarbourColorEditorModel.h"
+#include "HarbourDebug.h"
+
+#include <QtQml>
+
+#define SETTINGS_QML_PLUGIN "openrepos.books.settings"
+
+#define SETTINGS_QML_REGISTER_(klass,name) \
+ qmlRegisterType<klass>(SETTINGS_QML_PLUGIN, 1, 0, name)
+#define SETTINGS_QML_REGISTER(klass) \
+ SETTINGS_QML_REGISTER_(klass,#klass)
+
+class BooksSettingsPlugin : public QQmlExtensionPlugin
+{
+ Q_OBJECT
+ Q_PLUGIN_METADATA(IID SETTINGS_QML_PLUGIN)
+
+public:
+ void initializeEngine(QQmlEngine*, const char*) Q_DECL_OVERRIDE;
+ void registerTypes(const char*) Q_DECL_OVERRIDE;
+};
+
+void
+BooksSettingsPlugin::initializeEngine(
+ QQmlEngine*,
+ const char* aUri)
+{
+ HDEBUG(aUri);
+}
+
+void
+BooksSettingsPlugin::registerTypes(
+ const char* aUri)
+{
+ HDEBUG(aUri);
+ HASSERT(QLatin1String(aUri) == QLatin1String(SETTINGS_QML_PLUGIN));
+ SETTINGS_QML_REGISTER_(BooksSettingsBase, "BooksSettings");
+ SETTINGS_QML_REGISTER(BooksColorSchemeModel);
+ SETTINGS_QML_REGISTER(HarbourColorEditorModel);
+ qRegisterMetaType<BooksColorScheme>();
+}
+
+#include "BooksSettingsPlugin.moc"
|
[-]
[+]
|
Added |
_service:tar_git:openrepos-books-1.1.0.tar.gz/app/settings/SystemSettings.qml
^
|
@@ -0,0 +1,49 @@
+/*
+ Copyright (C) 2022 Jolla Ltd.
+ Copyright (C) 2022 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:
+
+ 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
+ distribution.
+ 3. Neither the names of the copyright holders 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 openrepos.books.settings 1.0
+
+// In-app settings
+BooksSettingsBase {
+ BooksSettings { id: settings }
+ colorSchemeModel: BooksColorSchemeModel {
+ Component.onCompleted: colorScheme = settings.customColorScheme
+ onColorSchemeChanged: settings.customColorScheme = colorScheme
+ }
+ colorEditorModel: HarbourColorEditorModel {
+ Component.onCompleted: colors = settings.availableColors
+ onColorsChanged: settings.availableColors = colors
+ }
+ onResetColors: colorEditorModel.colors = settings.defaultColors
+}
|
[-]
[+]
|
Added |
_service:tar_git:openrepos-books-1.1.0.tar.gz/app/settings/openrepos-books.json
^
|
@@ -0,0 +1,14 @@
+{
+ "translation_catalog" : "openrepos-books",
+ "entries": [
+ {
+ "path": "applications/openrepos-books.desktop",
+ "title": "Books",
+ "type": "page",
+ "icon": "openrepos-books",
+ "params": {
+ "source": "/usr/share/openrepos-books/settings/SystemSettings.qml"
+ }
+ }
+ ]
+}
|
[-]
[+]
|
Added |
_service:tar_git:openrepos-books-1.1.0.tar.gz/app/settings/qmldir
^
|
@@ -0,0 +1,2 @@
+module openrepos.books.settings
+plugin bookssettings
|
[-]
[+]
|
Added |
_service:tar_git:openrepos-books-1.1.0.tar.gz/app/settings/settings.pro
^
|
@@ -0,0 +1,57 @@
+TEMPLATE = lib
+TARGET = bookssettings
+
+# Directories
+TARGETPATH = $$[QT_INSTALL_QML]/openrepos/books/settings
+APP_SRC_DIR = ../src
+HARBOUR_LIB_DIR = ../../harbour-lib
+HARBOUR_LIB_INCLUDE_DIR = $$HARBOUR_LIB_DIR/include
+HARBOUR_LIB_SRC_DIR = $$HARBOUR_LIB_DIR/src
+
+QT += qml
+CONFIG += qt plugin link_pkgconfig hide_symbols
+PKGCONFIG += mlite5
+
+DEFINES += OPENREPOS # It's for openrepos build only
+QMAKE_CXXFLAGS += -Wno-unused-parameter
+INCLUDEPATH += $${APP_SRC_DIR} $${HARBOUR_LIB_INCLUDE_DIR}
+
+CONFIG(debug, debug|release) {
+ DEFINES += HARBOUR_DEBUG=1
+}
+
+target.path = $$TARGETPATH
+INSTALLS += target
+
+import.files = qmldir
+import.path = $$TARGETPATH
+INSTALLS += import
+
+settings_json.files = openrepos-books.json
+settings_json.path = /usr/share/jolla-settings/entries/
+INSTALLS += settings_json
+
+SOURCES += \
+ BooksSettingsPlugin.cpp \
+ $${APP_SRC_DIR}/BooksColorScheme.cpp \
+ $${APP_SRC_DIR}/BooksColorSchemeModel.cpp \
+ $${APP_SRC_DIR}/BooksSettingsBase.cpp
+
+HEADERS += \
+ $${APP_SRC_DIR}/BooksColorScheme.h \
+ $${APP_SRC_DIR}/BooksColorSchemeModel.h \
+ $${APP_SRC_DIR}/BooksSettingsBase.h
+
+OTHER_FILES += \
+ settings/*.json
+
+# harbour-lib
+
+HEADERS += \
+ $${HARBOUR_LIB_INCLUDE_DIR}/HarbourColorEditorModel.h \
+ $${HARBOUR_LIB_INCLUDE_DIR}/HarbourDebug.h \
+ $${HARBOUR_LIB_INCLUDE_DIR}/HarbourUtil.h
+
+SOURCES += \
+ $${HARBOUR_LIB_SRC_DIR}/HarbourColorEditorModel.cpp \
+ $${HARBOUR_LIB_SRC_DIR}/HarbourUtil.cpp
|
[-]
[+]
|
Changed |
_service:tar_git:openrepos-books-1.1.0.tar.gz/app/src/BooksBook.cpp
^
|
@@ -98,8 +98,8 @@
}
}
- setWidth(gMaxScreenSize.width());
- setHeight(gMaxScreenSize.height());
+ iWidth = gMaxScreenSize.width();
+ iHeight = gMaxScreenSize.height();
}
void BooksBook::CoverPaintContext::drawImage(int x, int y, const ZLImageData& image)
|
[-]
[+]
|
Changed |
_service:tar_git:openrepos-books-1.1.0.tar.gz/app/src/BooksBookModel.cpp
^
|
@@ -34,6 +34,7 @@
#include "BooksBookModel.h"
#include "BooksTextStyle.h"
#include "BooksUtil.h"
+#include "BooksDefs.h"
#include "HarbourDebug.h"
#include "HarbourTask.h"
@@ -111,7 +112,7 @@
HarbourTask(aPool),
iBook(aBook),
iTextStyle(aModel->textStyle()),
- iPaint(aModel->width(), aModel->height()),
+ iPaint(aModel->width(), aModel->height(), BooksColorScheme()),
iMargins(aModel->margins()),
iPageMarksFile(pageMarksFile(aModel)),
iHash(aModel->book()->hash()),
@@ -130,7 +131,7 @@
QString BooksBookModel::PagingTask::pageMarksFile(BooksBookModel* aModel)
{
- return aModel->book()->storageFile(QString(".%1x%2.marks").
+ return aModel->book()->storageFile(QString(".%1x%2" BOOKS_MARKS_FILE_SUFFIX).
arg(aModel->width()).arg(aModel->height()));
}
|
[-]
[+]
|
Added |
_service:tar_git:openrepos-books-1.1.0.tar.gz/app/src/BooksColorScheme.cpp
^
|
@@ -0,0 +1,345 @@
+/*
+ * Copyright (C) 2022 Jolla Ltd.
+ * Copyright (C) 2022 Slava Monich <slava.monich@jolla.com>
+ *
+ * You may use this file under the terms of the 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:
+ *
+ * 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
+ * distribution.
+ * 3. Neither the names of the copyright holders 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
+ * OWNER 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.
+ */
+
+#include "BooksColorScheme.h"
+
+#include "HarbourDebug.h"
+#include "HarbourUtil.h"
+
+#include <QHash>
+#include <QAtomicInt>
+#include <QCryptographicHash>
+
+#define MEMBER_VAR(Name) i##Name
+
+// ==========================================================================
+// BooksColorScheme::Private
+// ==========================================================================
+
+class BooksColorScheme::Private
+{
+public:
+ struct Colors {
+ #define MEMBER_DECL(colorName,ColorName,key,default) \
+ QRgb MEMBER_VAR(ColorName);
+ BOOKS_COLORS(MEMBER_DECL)
+ #undef MEMBER_DECL
+ bool isDefault() const;
+ void invert();
+ };
+
+ static const Colors DEFAULT_COLORS;
+ static const QString DEFAULT_SCHEME_ID;
+
+ Private(const Colors*);
+ ~Private();
+
+ void updateSchemeId();
+
+ static QString generateSchemeId(const Colors*);
+ static QString defaultSchemeId() { return generateSchemeId(&DEFAULT_COLORS); }
+ static void parseRgb(QRgb*, const QString&);
+ static uint rgb(QRgb);
+
+public:
+ QAtomicInt iRef;
+ Colors iColors;
+ QString iSchemeId;
+};
+
+const BooksColorScheme::Private::Colors BooksColorScheme::Private::DEFAULT_COLORS = {
+ #define DEFAULT_INIT(colorName,ColorName,key,default) default,
+ BOOKS_COLORS(DEFAULT_INIT)
+ #undef DEFAULT_INIT
+};
+const QString BooksColorScheme::Private::DEFAULT_SCHEME_ID
+ (BooksColorScheme::Private::defaultSchemeId());
+
+BooksColorScheme::Private::Private(
+ const Colors* aColors) :
+ iRef(1),
+ iColors(*aColors)
+{
+ // Note: leaving iSchemeId empty. Caller must do updateSchemeId()
+}
+
+BooksColorScheme::Private::~Private()
+{
+}
+
+QString
+BooksColorScheme::Private::generateSchemeId(
+ const Colors* aColors)
+{
+ QCryptographicHash md5(QCryptographicHash::Md5);
+ #define HASH_COLOR(colorName,ColorName,key,default) \
+ md5.addData((const char*)&aColors->MEMBER_VAR(ColorName), sizeof(aColors->MEMBER_VAR(ColorName)));
+ BOOKS_COLORS(HASH_COLOR)
+ #undef HASH_COLOR
+ return QString(QLatin1String(md5.result().toHex()));
+}
+
+inline bool
+BooksColorScheme::Private::Colors::isDefault() const
+{
+ return !memcmp(this, &DEFAULT_COLORS, sizeof(Colors));
+}
+
+void
+BooksColorScheme::Private::Colors::invert()
+{
+ #define INVERT_COLOR(colorName,ColorName,key,default) \
+ MEMBER_VAR(ColorName) = HarbourUtil::invertedRgb(MEMBER_VAR(ColorName));
+ BOOKS_COLORS(INVERT_COLOR)
+ #undef INVERT_COLOR
+}
+
+inline
+void
+BooksColorScheme::Private::updateSchemeId()
+{
+ iSchemeId = generateSchemeId(&iColors);
+}
+
+void
+BooksColorScheme::Private::parseRgb(
+ QRgb* aRgb,
+ const QString& aValue)
+{
+ const int len = aValue.length();
+ if (len > 0 && len <= 8) {
+ uint rgb = 0;
+ for (int i = 0; i < len; i++) {
+ const int c = aValue.at(i).unicode();
+ if (isxdigit(c)) {
+ static const uchar hex[] = {
+ 0, 1, 2, 3, 4, 5, 6, 7, /* 0x30..0x37 */
+ 8, 9, 0, 0, 0, 0, 0, 0, /* 0x3a..0x3f */
+ 0,10,11,12,13,14,15, 0, /* 0x40..0x47 */
+ 0, 0, 0, 0, 0, 0, 0, 0, /* 0x4a..0x4f */
+ 0, 0, 0, 0, 0, 0, 0, 0, /* 0x40..0x47 */
+ 0, 0, 0, 0, 0, 0, 0, 0, /* 0x5a..0x5f */
+ 0,10,11,12,13,14,15, 0, /* 0x60..0x66 */
+ 0, 0, 0, 0, 0, 0, 0, 0 /* Make it 64 bytes */
+ };
+ Q_STATIC_ASSERT(sizeof(hex) == 0x40);
+ rgb = (rgb << 4) | hex[(c - 0x30) & 0x3f];
+ } else {
+ HDEBUG("Not a valid hex string" << aValue);
+ return;
+ }
+ }
+ *aRgb = rgb;
+ }
+}
+
+uint
+BooksColorScheme::Private::rgb(
+ QRgb aRgb)
+{
+ // Strip off opaque alpha
+ return (qAlpha(aRgb) == 0xff) ? (aRgb & RGB_MASK) : aRgb;
+}
+
+// ==========================================================================
+// BooksColorScheme
+// ==========================================================================
+
+BooksColorScheme::BooksColorScheme() :
+ iPrivate(Q_NULLPTR)
+{
+}
+
+BooksColorScheme::BooksColorScheme(
+ const QString& aSpec) :
+ iPrivate(Q_NULLPTR)
+{
+ QHash<QString,QString> map;
+ const QStringList parts(aSpec.split(QChar(':'), QString::SkipEmptyParts));
+ const int n = parts.count();
+ for (int i = 0; i < n; i++) {
+ const QStringList pair(parts.at(i).split(QChar('='), QString::SkipEmptyParts));
+ if (pair.count() == 2) {
+ map.insert(pair.at(0), pair.at(1));
+ }
+ }
+
+ Private::Colors colors = Private::DEFAULT_COLORS;
+ #define PARSE_KEY(colorName,ColorName,key,default) \
+ Private::parseRgb(&colors.MEMBER_VAR(ColorName), map.value(QStringLiteral(#key)));
|
[-]
[+]
|
Added |
_service:tar_git:openrepos-books-1.1.0.tar.gz/app/src/BooksColorScheme.h
^
|
@@ -0,0 +1,97 @@
+/*
+ * Copyright (C) 2022 Jolla Ltd.
+ * Copyright (C) 2022 Slava Monich <slava.monich@jolla.com>
+ *
+ * You may use this file under the terms of the 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:
+ *
+ * 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
+ * distribution.
+ * 3. Neither the names of the copyright holders 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
+ * OWNER 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.
+ */
+
+#ifndef BOOKS_COLOR_SCHEME_H
+#define BOOKS_COLOR_SCHEME_H
+
+#include <QMetaType>
+#include <QString>
+#include <QRgb>
+
+// Let preprocessor magic begin!
+// color(colorName,ColorName,key,default)
+#define BOOKS_COLORS(color) \
+ color(background,Background,bg,0xffffff) \
+ color(foreground,Foreground,fg,0x000000) \
+ color(selectionBackground,SelectionBackground,sb,0x3c8bff) \
+ color(highlightedText,HighlightedText,ht,0x3c8bff) \
+ color(internalHyperlink,InternalHyperlink,ih,0x2160b4) \
+ color(externalHyperlink,ExternalHyperlink,eh,0x2160b4)
+
+// Container for colors (thread-safe)
+class BooksColorScheme
+{
+public:
+ BooksColorScheme();
+ BooksColorScheme(const QString&);
+ BooksColorScheme(const BooksColorScheme&);
+ ~BooksColorScheme();
+
+ BooksColorScheme& operator = (const BooksColorScheme&);
+ bool operator == (const BooksColorScheme&) const;
+ bool operator != (const BooksColorScheme&) const;
+ bool equals(const BooksColorScheme&) const;
+
+ const QString schemeId() const;
+ const QString toString() const;
+
+ // This generates pairs of method declarations, e.g.
+ // QRgb background() const;
+ // BooksColorScheme withBackground(QRgb aColor) const;
+ #define BOOKS_COLORS_DECL(colorName,ColorName,key,default) \
+ QRgb colorName() const; \
+ inline QString colorName##Color() const { return rgbToString(colorName()); } \
+ BooksColorScheme with##ColorName(QRgb) const Q_REQUIRED_RESULT;
+ BOOKS_COLORS(BOOKS_COLORS_DECL)
+ #undef BOOKS_COLORS_DECL
+
+ BooksColorScheme inverted() const Q_REQUIRED_RESULT;
+ BooksColorScheme invertedWithSelectionBackground(QRgb) const Q_REQUIRED_RESULT;
+
+private:
+ static QString rgbToString(QRgb);
+
+private:
+ class Private;
+ Private* iPrivate;
+};
+
+// Inline methods
+inline bool BooksColorScheme::operator == (const BooksColorScheme& aScheme) const
+ { return equals(aScheme); }
+inline bool BooksColorScheme::operator != (const BooksColorScheme& aScheme) const
+ { return !equals(aScheme); }
+
+Q_DECLARE_METATYPE(BooksColorScheme)
+
+#endif // BOOKS_COLOR_SCHEME_H
|
[-]
[+]
|
Added |
_service:tar_git:openrepos-books-1.1.0.tar.gz/app/src/BooksColorSchemeModel.cpp
^
|
@@ -0,0 +1,286 @@
+/*
+ * Copyright (C) 2022 Jolla Ltd.
+ * Copyright (C) 2022 Slava Monich <slava.monich@jolla.com>
+ *
+ * You may use this file under the terms of the 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:
+ *
+ * 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
+ * distribution.
+ * 3. Neither the names of the copyright holders 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
+ * OWNER 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.
+ */
+
+#include "BooksColorSchemeModel.h"
+
+#include "HarbourDebug.h"
+
+#include <QColor>
+
+// Model roles
+#define MODEL_ROLES_(first,role,last) \
+ first(Key,key) \
+ role(Label,label) \
+ last(Color,color)
+
+#define MODEL_ROLES(role) \
+ MODEL_ROLES_(role,role,role)
+
+// ==========================================================================
+// BooksColorSchemeModel::Private
+// ==========================================================================
+
+class BooksColorSchemeModel::Private
+{
+public:
+ struct ColorDescriptor {
+ const QString iName;
+ QString (*iLabel)();
+ QRgb (BooksColorScheme::*iGetter)() const;
+ BooksColorScheme (BooksColorScheme::*iSetter)(QRgb) const;
+ };
+
+ enum Role {
+ #define FIRST(X,x) X##Role = Qt::UserRole,
+ #define ROLE(X,x) X##Role,
+ #define LAST(X,x) X##Role
+ MODEL_ROLES_(FIRST,ROLE,LAST)
+ #undef FIRST
+ #undef ROLE
+ #undef LAST
+ };
+
+ static const ColorDescriptor COLORS[];
+
+ #define COLOR_LABEL(colorName,ColorName,key,default) \
+ static QString ColorName##Label();
+ BOOKS_COLORS(COLOR_LABEL)
+ #undef COLOR_LABEL
+
+public:
+ BooksColorScheme iColorScheme;
+};
+
+const BooksColorSchemeModel::Private::ColorDescriptor
+BooksColorSchemeModel::Private::COLORS[] = {
+ #define COLOR_DESCRIPTOR(colorName,ColorName,key,default) \
+ { QString(#colorName), &BooksColorSchemeModel::Private::ColorName##Label, \
+ &BooksColorScheme::colorName, &BooksColorScheme::with##ColorName },
+ BOOKS_COLORS(COLOR_DESCRIPTOR)
+ #undef COLOR_DESCRIPTOR
+};
+
+#define COLOR_COUNT ((int)\
+ (sizeof(BooksColorSchemeModel::Private::COLORS)/ \
+ sizeof(BooksColorSchemeModel::Private::COLORS[0])))
+
+// Localized labels
+
+QString
+BooksColorSchemeModel::Private::BackgroundLabel()
+{
+ //: List item label (description of a color scheme element)
+ //% "Page background"
+ return qtTrId("harbour-books-color-page_background");
+}
+
+QString
+BooksColorSchemeModel::Private::ForegroundLabel()
+{
+ //: List item label (description of a color scheme element)
+ //% "Regular text"
+ return qtTrId("harbour-books-color-text");
+}
+
+QString
+BooksColorSchemeModel::Private::SelectionBackgroundLabel()
+{
+ //: List item label (description of a color scheme element)
+ //% "Selection background"
+ return qtTrId("harbour-books-color-selection_background");
+}
+
+QString
+BooksColorSchemeModel::Private::HighlightedTextLabel()
+{
+ //: List item label (description of a color scheme element)
+ //% "Highlighted text"
+ return qtTrId("harbour-books-color-highlighted_text");
+}
+
+QString
+BooksColorSchemeModel::Private::InternalHyperlinkLabel()
+{
+ //: List item label (description of a color scheme element)
+ //% "Internal hyperlink"
+ return qtTrId("harbour-books-color-internal_hyperlink");
+}
+
+QString
+BooksColorSchemeModel::Private::ExternalHyperlinkLabel()
+{
+ //: List item label (description of a color scheme element)
+ //% "External hyperlink"
+ return qtTrId("harbour-books-color-external_hyperlink");
+}
+
+// ==========================================================================
+// BooksColorSchemeModel
+// ==========================================================================
+
+BooksColorSchemeModel::BooksColorSchemeModel(
+ QObject* aParent) :
+ QAbstractListModel(aParent),
+ iPrivate(new Private)
+{
+}
+
+BooksColorSchemeModel::~BooksColorSchemeModel()
+{
+ delete iPrivate;
+}
+
+BooksColorScheme
+BooksColorSchemeModel::colorScheme() const
+{
+ return iPrivate->iColorScheme;
+}
+
+void
+BooksColorSchemeModel::setColorScheme(
+ BooksColorScheme aScheme)
+{
+ int i, nchanged = 0;
+ bool changed[COLOR_COUNT];
+ const BooksColorScheme* s1 = &iPrivate->iColorScheme;
+ const BooksColorScheme* s2 = &aScheme;
+
+ for (i = 0; i < COLOR_COUNT; i++) {
+ const Private::ColorDescriptor* colorDesc = Private::COLORS + i;
+
+ if ((s1->*(colorDesc->iGetter))() != (s2->*(colorDesc->iGetter))()) {
+ changed[i] = true;
+ nchanged++;
+ } else {
+ changed[i] = false;
+ }
+ }
+
+ if (nchanged) {
+ HDEBUG(aScheme.toString());
+ iPrivate->iColorScheme = aScheme;
+ const QVector<int> roles(1, Private::ColorRole);
+ for (i = 0; i < COLOR_COUNT && nchanged > 0; i++) {
+ if (changed[i]) {
+ const QModelIndex idx(index(i));
+ Q_EMIT dataChanged(idx, idx, roles);
+ nchanged--;
+ }
+ }
|
[-]
[+]
|
Added |
_service:tar_git:openrepos-books-1.1.0.tar.gz/app/src/BooksColorSchemeModel.h
^
|
@@ -0,0 +1,69 @@
+/*
+ * Copyright (C) 2022 Jolla Ltd.
+ * Copyright (C) 2022 Slava Monich <slava.monich@jolla.com>
+ *
+ * You may use this file under the terms of the 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:
+ *
+ * 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
+ * distribution.
+ * 3. Neither the names of the copyright holders 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
+ * OWNER 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.
+ */
+
+#ifndef BOOKS_COLOR_SCHEME_MODEL_H
+#define BOOKS_COLOR_SCHEME_MODEL_H
+
+#include "BooksColorScheme.h"
+
+#include <QAbstractListModel>
+
+// Represents BooksColorScheme as a list model
+class BooksColorSchemeModel: public QAbstractListModel
+{
+ Q_OBJECT
+ Q_PROPERTY(BooksColorScheme colorScheme READ colorScheme WRITE setColorScheme NOTIFY colorSchemeChanged)
+
+public:
+ explicit BooksColorSchemeModel(QObject* aParent = Q_NULLPTR);
+ ~BooksColorSchemeModel();
+
+ BooksColorScheme colorScheme() const;
+ void setColorScheme(BooksColorScheme);
+
+ // QAbstractItemModel
+ Qt::ItemFlags flags(const QModelIndex&) const Q_DECL_OVERRIDE;
+ QHash<int,QByteArray> roleNames() const Q_DECL_OVERRIDE;
+ int rowCount(const QModelIndex& aParent) const Q_DECL_OVERRIDE;
+ QVariant data(const QModelIndex&, int) const Q_DECL_OVERRIDE;
+ bool setData(const QModelIndex&, const QVariant&, int) Q_DECL_OVERRIDE;
+
+Q_SIGNALS:
+ void colorSchemeChanged();
+
+private:
+ class Private;
+ Private* iPrivate;
+};
+
+#endif // BOOKS_COLOR_SCHEME_MODEL_H
|
[-]
[+]
|
Changed |
_service:tar_git:openrepos-books-1.1.0.tar.gz/app/src/BooksDefs.h
^
|
@@ -1,6 +1,6 @@
/*
- * Copyright (C) 2015-2020 Jolla Ltd.
- * Copyright (C) 2015-2020 Slava Monich <slava.monich@jolla.com>
+ * Copyright (C) 2015-2022 Jolla Ltd.
+ * Copyright (C) 2015-2022 Slava Monich <slava.monich@jolla.com>
*
* You may use this file under the terms of the BSD license as follows:
*
@@ -58,14 +58,26 @@
#define BOOKS_QML_PLUGIN "harbour.books"
#define BOOKS_QML_PLUGIN_V1 1
#define BOOKS_QML_PLUGIN_V2 0
-#define BOOKS_QML_REGISTER(klass,name) \
+
+#define BOOKS_QML_REGISTER_(klass,name) \
qmlRegisterType<klass>(BOOKS_QML_PLUGIN, BOOKS_QML_PLUGIN_V1, \
BOOKS_QML_PLUGIN_V2, name)
-#define BOOKS_QML_REGISTER_SINGLETON(klass,name) \
+#define BOOKS_QML_REGISTER_UNCREATABLE_(klass,name) \
+ qmlRegisterUncreatableType<klass>(BOOKS_QML_PLUGIN, BOOKS_QML_PLUGIN_V1, \
+ BOOKS_QML_PLUGIN_V2, name, QString())
+#define BOOKS_QML_REGISTER_SINGLETON_(klass,name) \
qmlRegisterSingletonType<klass>(BOOKS_QML_PLUGIN, BOOKS_QML_PLUGIN_V1, \
BOOKS_QML_PLUGIN_V2, name, klass::createSingleton)
+#define BOOKS_QML_REGISTER(klass) \
+ BOOKS_QML_REGISTER_(klass,#klass)
+#define BOOKS_QML_REGISTER_UNCREATABLE(klass) \
+ BOOKS_QML_REGISTER_UNCREATABLE_(klass,#klass)
+#define BOOKS_QML_REGISTER_SINGLETON(klass) \
+ BOOKS_QML_REGISTER_SINGLETON_(klass,#klass)
+
#define BOOKS_STATE_FILE_SUFFIX ".state"
+#define BOOKS_MARKS_FILE_SUFFIX ".marks"
extern int booksPPI;
#define BOOKS_PPI booksPPI
|
[-]
[+]
|
Changed |
_service:tar_git:openrepos-books-1.1.0.tar.gz/app/src/BooksPageWidget.cpp
^
|
@@ -1,6 +1,6 @@
/*
- * Copyright (C) 2015-2020 Jolla Ltd.
- * Copyright (C) 2015-2020 Slava Monich <slava.monich@jolla.com>
+ * Copyright (C) 2015-2022 Jolla Ltd.
+ * Copyright (C) 2015-2022 Slava Monich <slava.monich@jolla.com>
*
* You may use this file under the terms of the BSD license as follows:
*
@@ -48,19 +48,23 @@
#include <QPainter>
static const QString IMAGE_URL("image://%1/%2");
+static const int REPAINT_DELAY_MSEC = 250;
// ==========================================================================
// BooksPageWidget::Data
// ==========================================================================
-class BooksPageWidget::Data {
+class BooksPageWidget::Data
+{
public:
typedef shared_ptr<Data> Ptr;
Data(shared_ptr<ZLTextModel> aModel, int aWidth, int aHeight) :
iModel(aModel), iPaintContext(aWidth, aHeight) {}
- bool paint(QPainter* aPainter);
+ bool paint(QPainter*, BooksColorScheme);
+ inline int width() const { return iPaintContext.width(); }
+ inline int height() const { return iPaintContext.height(); }
public:
shared_ptr<BooksTextView> iView;
@@ -68,9 +72,13 @@
BooksPaintContext iPaintContext;
};
-bool BooksPageWidget::Data::paint(QPainter* aPainter)
+bool
+BooksPageWidget::Data::paint(
+ QPainter* aPainter,
+ BooksColorScheme aColors)
{
if (!iView.isNull()) {
+ iPaintContext.iColors = aColors;
iPaintContext.beginPaint(aPainter);
iView->paint();
iPaintContext.endPaint();
@@ -83,14 +91,14 @@
// BooksPageWidget::ResetTask
// ==========================================================================
-class BooksPageWidget::ResetTask : public HarbourTask {
+class BooksPageWidget::ResetTask : public HarbourTask
+{
public:
- ResetTask(QThreadPool* aPool, shared_ptr<ZLTextModel> aModel,
- shared_ptr<ZLTextStyle> aTextStyle, int aWidth, int aHeight,
- const BooksMargins& aMargins, const BooksPos& aPosition);
+ ResetTask(QThreadPool*, shared_ptr<ZLTextModel>, shared_ptr<ZLTextStyle>,
+ int, int, const BooksMargins&, const BooksPos&);
~ResetTask();
- void performTask();
+ void performTask() Q_DECL_OVERRIDE;
public:
BooksPageWidget::Data* iData;
@@ -99,10 +107,15 @@
BooksPos iPosition;
};
-BooksPageWidget::ResetTask::ResetTask(QThreadPool* aPool,
- shared_ptr<ZLTextModel> aModel, shared_ptr<ZLTextStyle> aTextStyle,
- int aWidth, int aHeight, const BooksMargins& aMargins,
- const BooksPos& aPosition) : HarbourTask(aPool),
+BooksPageWidget::ResetTask::ResetTask(
+ QThreadPool* aPool,
+ shared_ptr<ZLTextModel> aModel,
+ shared_ptr<ZLTextStyle> aTextStyle,
+ int aWidth,
+ int aHeight,
+ const BooksMargins& aMargins,
+ const BooksPos& aPosition) :
+ HarbourTask(aPool),
iData(new BooksPageWidget::Data(aModel, aWidth, aHeight)),
iTextStyle(aTextStyle),
iMargins(aMargins),
@@ -115,7 +128,8 @@
delete iData;
}
-void BooksPageWidget::ResetTask::performTask()
+void
+BooksPageWidget::ResetTask::performTask()
{
if (!isCanceled()) {
BooksTextView* view = new BooksTextView(iData->iPaintContext,
@@ -138,29 +152,33 @@
// BooksPageWidget::RenderTask
// ==========================================================================
-class BooksPageWidget::RenderTask : public HarbourTask {
+class BooksPageWidget::RenderTask : public HarbourTask
+{
public:
RenderTask(QThreadPool* aPool, QThread* aTargetThread, Data::Ptr aData,
- int aWidth, int aHeight) : HarbourTask(aPool, aTargetThread),
- iData(aData), iWidth(aWidth), iHeight(aHeight) {}
+ BooksColorScheme aColors) : HarbourTask(aPool, aTargetThread),
+ iData(aData), iColors(aColors) {}
- void performTask();
+ void performTask() Q_DECL_OVERRIDE;
public:
Data::Ptr iData;
- int iWidth;
- int iHeight;
+ BooksColorScheme iColors;
QImage iImage;
};
-void BooksPageWidget::RenderTask::performTask()
+void
+BooksPageWidget::RenderTask::performTask()
{
- if (!isCanceled() && !iData.isNull() && !iData->iView.isNull() &&
- iWidth > 0 && iHeight > 0) {
- iImage = QImage(iWidth, iHeight, QImage::Format_ARGB32_Premultiplied);
- if (!isCanceled()) {
- QPainter painter(&iImage);
- iData->paint(&painter);
+ if (!iData.isNull() && !iData->iView.isNull()) {
+ const int width = iData->width();
+ const int height = iData->height();
+ if (width > 0 && height > 0) {
+ iImage = QImage(width, height, QImage::Format_ARGB32_Premultiplied);
+ if (!isCanceled()) {
+ QPainter painter(&iImage);
+ iData->paint(&painter, iColors);
+ }
}
}
}
@@ -169,34 +187,38 @@
// BooksPageWidget::ClearSelectionTask
// ==========================================================================
-class BooksPageWidget::ClearSelectionTask : public HarbourTask {
+class BooksPageWidget::ClearSelectionTask : public HarbourTask
+{
public:
- ClearSelectionTask(QThreadPool* aPool, Data::Ptr aData, int aWidth,
- int aHeight) : HarbourTask(aPool),
- iData(aData), iWidth(aWidth), iHeight(aHeight), iImageUpdated(false) {}
+ ClearSelectionTask(QThreadPool* aPool, Data::Ptr aData, BooksColorScheme aColors) :
+ HarbourTask(aPool), iData(aData), iColors(aColors), iImageUpdated(false) {}
- void performTask();
+ void performTask() Q_DECL_OVERRIDE;
public:
Data::Ptr iData;
- int iWidth;
- int iHeight;
+ BooksColorScheme iColors;
QImage iImage;
bool iImageUpdated;
};
-void BooksPageWidget::ClearSelectionTask::performTask()
+void
+BooksPageWidget::ClearSelectionTask::performTask()
{
- iData->iView->endSelection();
- if (!isCanceled() && iWidth > 0 && iHeight > 0) {
- const ZLTextArea& area = iData->iView->textArea();
- if (!area.selectionIsEmpty()) {
- area.clearSelection();
- iImage = QImage(iWidth, iHeight, QImage::Format_ARGB32_Premultiplied);
- if (!isCanceled()) {
- QPainter painter(&iImage);
- iData->paint(&painter);
- iImageUpdated = true;
+ if (!iData.isNull() && !iData->iView.isNull()) {
+ iData->iView->endSelection();
+ const int width = iData->width();
+ const int height = iData->height();
+ if (!isCanceled() && width > 0 && height > 0) {
+ const ZLTextArea& area = iData->iView->textArea();
+ if (!area.selectionIsEmpty()) {
+ area.clearSelection();
+ iImage = QImage(width, height, QImage::Format_ARGB32_Premultiplied);
+ if (!isCanceled()) {
+ QPainter painter(&iImage);
+ iData->paint(&painter, iColors);
+ iImageUpdated = true;
|
[-]
[+]
|
Changed |
_service:tar_git:openrepos-books-1.1.0.tar.gz/app/src/BooksPageWidget.h
^
|
@@ -1,6 +1,6 @@
/*
- * Copyright (C) 2015-2020 Jolla Ltd.
- * Copyright (C) 2015-2020 Slava Monich <slava.monich@jolla.com>
+ * Copyright (C) 2015-2022 Jolla Ltd.
+ * Copyright (C) 2015-2022 Slava Monich <slava.monich@jolla.com>
*
* You may use this file under the terms of the BSD license as follows:
*
@@ -45,7 +45,7 @@
#include "ZLTextStyle.h"
#include <QQuickPaintedItem>
-#include <QTimer>
+#include <QBasicTimer>
#include <QList>
class BooksPageWidget: public QQuickPaintedItem, private BooksLoadingProperty
@@ -70,40 +70,40 @@
explicit BooksPageWidget(QQuickItem* aParent = NULL);
~BooksPageWidget();
- bool loading() const;
+ bool loading() const Q_DECL_OVERRIDE;
bool selecting() const;
bool selectionEmpty() const;
bool pressed() const;
- void setPressed(bool aPressed);
+ void setPressed(bool);
bool currentPage() const;
- void setCurrentPage(bool aCurrentPage);
+ void setCurrentPage(bool);
int page() const;
- void setPage(int aPage);
+ void setPage(int);
BooksBookModel* model() const;
- void setModel(BooksBookModel* aModel);
+ void setModel(BooksBookModel*);
const BooksPos& bookPos() const;
- void setBookPos(const BooksPos& aBookPos);
+ void setBookPos(const BooksPos&);
int leftMargin() const;
int rightMargin() const;
int topMargin() const;
int bottomMargin() const;
- void setLeftMargin(int aMargin);
- void setRightMargin(int aMargin);
- void setTopMargin(int aMargin);
- void setBottomMargin(int aMargin);
+ void setLeftMargin(int);
+ void setRightMargin(int);
+ void setTopMargin(int);
+ void setBottomMargin(int);
BooksMargins margins() const;
- Q_INVOKABLE void handlePress(int aX, int aY);
- Q_INVOKABLE void handleLongPress(int aX, int aY);
- Q_INVOKABLE void handlePositionChanged(int aX, int aY);
+ Q_INVOKABLE void handlePress(int, int);
+ Q_INVOKABLE void handleLongPress(int, int);
+ Q_INVOKABLE void handlePositionChanged(int, int);
Q_INVOKABLE void clearSelection();
Q_SIGNALS:
@@ -129,12 +129,12 @@
private Q_SLOTS:
void onWidthChanged();
void onHeightChanged();
- void onResizeTimeout();
void onBookModelDestroyed();
void onTextStyleChanged();
void onColorsChanged();
void onResetTaskDone();
void onRenderTaskDone();
+ void onRenderTaskDoneDelayUpdate();
void onClearSelectionTaskDone();
void onStartSelectionTaskDone();
void onExtendSelectionTaskDone();
@@ -142,13 +142,19 @@
void onLongPressTaskDone();
void onFootnoteTaskDone();
+protected:
+ void timerEvent(QTimerEvent*) Q_DECL_OVERRIDE;
+ void paint(QPainter*) Q_DECL_OVERRIDE;
+
private:
- void paint(QPainter *painter) Q_DECL_OVERRIDE;
void updateSize();
void resetView();
void releaseExtendSelectionTasks();
void scheduleRepaint();
+ void scheduleRepaintDelayUpdate();
void cancelRepaint();
+ void renderTaskDone();
+ void updateNow();
private:
class ResetTask;
@@ -163,7 +169,8 @@
shared_ptr<BooksTaskQueue> iTaskQueue;
shared_ptr<ZLTextStyle> iTextStyle;
BooksPos iBookPos;
- QTimer* iResizeTimer;
+ QBasicTimer iResizeTimer;
+ QBasicTimer iDelayUpdateTimer;
BooksBookModel* iModel;
BooksMargins iMargins;
shared_ptr<Data> iData;
|
[-]
[+]
|
Changed |
_service:tar_git:openrepos-books-1.1.0.tar.gz/app/src/BooksPaintContext.cpp
^
|
@@ -1,6 +1,6 @@
/*
- * Copyright (C) 2015-2020 Jolla Ltd.
- * Copyright (C) 2015-2020 Slava Monich <slava.monich@jolla.com>
+ * Copyright (C) 2015-2022 Jolla Ltd.
+ * Copyright (C) 2015-2022 Slava Monich <slava.monich@jolla.com>
*
* You may use this file under the terms of the BSD license as follows:
*
@@ -48,14 +48,13 @@
static const std::string HELVETICA = "Helvetica";
BooksPaintContext::BooksPaintContext() :
- iPainter(NULL), iWidth(0), iHeight(0),
- iSpaceWidth(0), iDescent(0), iInvertColors(false)
+ iPainter(Q_NULLPTR), iSpaceWidth(0), iDescent(0), iWidth(0), iHeight(0)
{
}
-BooksPaintContext::BooksPaintContext(int aWidth, int aHeight) :
- iPainter(NULL), iWidth(aWidth), iHeight(aHeight),
- iSpaceWidth(0), iDescent(0), iInvertColors(false)
+BooksPaintContext::BooksPaintContext(int aWidth, int aHeight, BooksColorScheme aColors) :
+ iPainter(Q_NULLPTR), iSpaceWidth(0), iDescent(0),
+ iWidth(aWidth), iHeight(aHeight), iColors(aColors)
{
}
@@ -71,7 +70,7 @@
void BooksPaintContext::endPaint()
{
- iPainter = NULL;
+ iPainter = Q_NULLPTR;
}
void BooksPaintContext::fillFamiliesList(std::vector<std::string> &families) const
@@ -259,23 +258,12 @@
return iHeight;
}
-ZLColor BooksPaintContext::realColor(uchar aRed, uchar aGreen, uchar aBlue, uchar aAlpha,
- bool aInvertColors)
-{
- if (aInvertColors) {
- aRed = 255 - aRed;
- aGreen = 255 - aGreen;
- aBlue = 255 - aBlue;
- }
- return ZLColor(aRed, aGreen, aBlue, aAlpha);
-}
-
-ZLColor BooksPaintContext::realColor(const std::string& aStyle, bool aInvert)
+ZLColor BooksPaintContext::realColor(const std::string& aStyle, BooksColorScheme aColors)
{
static const std::string INTERNAL_HYPERLINK("internal");
static const std::string EXTERNAL_HYPERLINK("external");
static const std::string BOOK_HYPERLINK("book");
- unsigned long argb = ZLColor::rgbValue(0);
+ unsigned long argb = ZLColor::rgbValue(aColors.foreground());
if (ZLStringUtil::startsWith(aStyle, '#')) {
const size_t len = aStyle.length();
@@ -306,15 +294,13 @@
}
}
} else if (aStyle == INTERNAL_HYPERLINK) {
- argb = ZLColor::rgbValue(0x2160b4);
- } else if (aStyle == EXTERNAL_HYPERLINK) {
- argb = ZLColor::rgbValue(0x2160b4);
- } else if (aStyle == BOOK_HYPERLINK) {
- argb = ZLColor::rgbValue(0x174480);
+ argb = ZLColor::rgbValue(aColors.internalHyperlink());
+ } else if (aStyle == EXTERNAL_HYPERLINK || aStyle == BOOK_HYPERLINK) {
+ argb = ZLColor::rgbValue(aColors.externalHyperlink());
} else if (aStyle == ZLTextStyle::SELECTION_BACKGROUND) {
- argb = ZLColor::rgbValue(0x3c8bff);
+ argb = ZLColor::rgbValue(aColors.selectionBackground());
} else if (aStyle == ZLTextStyle::HIGHLIGHTED_TEXT) {
- argb = ZLColor::rgbValue(0x3c8bff);
+ argb = ZLColor::rgbValue(aColors.highlightedText());
}
- return realColor(ZLColor(argb), aInvert);
+ return ZLColor(argb);
}
|
[-]
[+]
|
Changed |
_service:tar_git:openrepos-books-1.1.0.tar.gz/app/src/BooksPaintContext.h
^
|
@@ -1,6 +1,6 @@
/*
- * Copyright (C) 2015-2020 Jolla Ltd.
- * Copyright (C) 2015-2020 Slava Monich <slava.monich@jolla.com>
+ * Copyright (C) 2015-2021 Jolla Ltd.
+ * Copyright (C) 2015-2021 Slava Monich <slava.monich@jolla.com>
*
* You may use this file under the terms of the BSD license as follows:
*
@@ -35,6 +35,7 @@
#define BOOKS_PAINT_CONTEXT_H
#include "BooksTypes.h"
+#include "BooksColorScheme.h"
#include "ZLColor.h"
#include "ZLPaintContext.h"
@@ -46,73 +47,63 @@
class QPainter;
class BooksPaintContext : public ZLPaintContext {
-public:
- BooksPaintContext(int aWidth, int aHeight);
+protected:
BooksPaintContext();
+
+public:
+ BooksPaintContext(int aWidth, int aHeight, BooksColorScheme aColors = BooksColorScheme());
~BooksPaintContext();
- void setWidth(int aWidth);
- void setHeight(int aHeight);
- void setSize(int aWidth, int aHeight);
bool isEmpty() const;
QSize size() const;
- // ZLPaintContext
void beginPaint(QPainter* painter);
void endPaint();
- int width() const;
- int height() const;
-
- void clear(ZLColor color);
-
- void fillFamiliesList(std::vector<std::string>& families) const;
- const std::string realFontFamilyName(std::string& fontFamily) const;
-
- void setFont(const std::string& family, int size, bool bold, bool italic);
- void setColor(ZLColor color, LineStyle style);
- void setFillColor(ZLColor color, FillStyle style);
-
- int stringWidth(const char* str, int len, bool rtl) const;
- int spaceWidth() const;
- int stringHeight() const;
- int descent() const;
- void drawString(int x, int y, const char* str, int len, bool rtl);
+ // ZLPaintContext
+ int width() const Q_DECL_OVERRIDE;
+ int height() const Q_DECL_OVERRIDE;
- void drawImage(int x, int y, const ZLImageData& image);
- void drawImage(int x, int y, const ZLImageData& image, int width, int height, ScalingType type);
+ void clear(ZLColor color) Q_DECL_OVERRIDE;
- void drawLine(int x0, int y0, int x1, int y1);
- void fillRectangle(int x0, int y0, int x1, int y1);
- void drawFilledCircle(int x, int y, int r);
+ void fillFamiliesList(std::vector<std::string>& families) const Q_DECL_OVERRIDE;
+ const std::string realFontFamilyName(std::string& fontFamily) const Q_DECL_OVERRIDE;
- void setInvertColors(bool aInvertColors);
+ void setFont(const std::string& family, int size, bool bold, bool italic) Q_DECL_OVERRIDE;
+ void setColor(ZLColor color, LineStyle style) Q_DECL_OVERRIDE;
+ void setFillColor(ZLColor color, FillStyle style) Q_DECL_OVERRIDE;
+
+ int stringWidth(const char* str, int len, bool rtl) const Q_DECL_OVERRIDE;
+ int spaceWidth() const Q_DECL_OVERRIDE;
+ int stringHeight() const Q_DECL_OVERRIDE;
+ int descent() const Q_DECL_OVERRIDE;
+ void drawString(int x, int y, const char* str, int len, bool rtl) Q_DECL_OVERRIDE;
+
+ void drawImage(int x, int y, const ZLImageData& image) Q_DECL_OVERRIDE;
+ void drawImage(int x, int y, const ZLImageData& image, int width, int height, ScalingType type) Q_DECL_OVERRIDE;
+
+ void drawLine(int x0, int y0, int x1, int y1) Q_DECL_OVERRIDE;
+ void fillRectangle(int x0, int y0, int x1, int y1) Q_DECL_OVERRIDE;
+ void drawFilledCircle(int x, int y, int r) Q_DECL_OVERRIDE;
ZLColor realColor(const ZLColor aColor) const;
ZLColor realColor(const std::string& aStyle) const;
- static ZLColor realColor(const std::string& aStyle, bool aInvert);
-
-private:
- ZLColor realColor(uchar aRed, uchar aGreen, uchar aBlue, uchar aAlpha) const;
- static ZLColor realColor(uchar aRed, uchar aGreen, uchar aBlue, uchar aAlpha, bool aInvert);
- static ZLColor realColor(const ZLColor aColor, bool aInvert);
+ static ZLColor realColor(const std::string& aStyle, BooksColorScheme aColors);
private:
QPainter* iPainter;
- int iWidth;
- int iHeight;
mutable int iSpaceWidth;
int iDescent;
- bool iInvertColors;
QFont iFont;
+
+protected:
+ int iWidth;
+ int iHeight;
+
+public:
+ BooksColorScheme iColors;
};
-inline void BooksPaintContext::setWidth(int aWidth)
- { iWidth = aWidth; }
-inline void BooksPaintContext::setHeight(int aHeight)
- { iHeight = aHeight; }
-inline void BooksPaintContext::setSize(int aWidth, int aHeight)
- { iWidth = aWidth; iHeight = aHeight; }
inline bool BooksPaintContext::isEmpty() const
{ return (iWidth <= 0 || iHeight <= 0); }
inline QSize BooksPaintContext::size() const
@@ -120,15 +111,7 @@
inline QColor qtColor(const ZLColor& aColor)
{ return QColor(aColor.Red, aColor.Green, aColor.Blue, aColor.Alpha); }
-inline ZLColor BooksPaintContext::realColor(const ZLColor aColor) const
- { return realColor(aColor.Red, aColor.Green, aColor.Blue, aColor.Alpha); }
-inline ZLColor BooksPaintContext::realColor(uchar aRed, uchar aGreen, uchar aBlue, uchar aAlpha) const
- { return realColor(aRed, aGreen, aBlue, aAlpha, iInvertColors); }
-inline ZLColor BooksPaintContext::realColor(const ZLColor aColor, bool aInvert)
- { return realColor(aColor.Red, aColor.Green, aColor.Blue, aColor.Alpha, aInvert); }
inline ZLColor BooksPaintContext::realColor(const std::string& aStyle) const
- { return realColor(aStyle, iInvertColors); }
-inline void BooksPaintContext::setInvertColors(bool aInvertColors)
- { iInvertColors = aInvertColors; }
+ { return realColor(aStyle, iColors); }
#endif /* BOOKS_PAINT_CONTEXT_H */
|
[-]
[+]
|
Changed |
_service:tar_git:openrepos-books-1.1.0.tar.gz/app/src/BooksSettings.cpp
^
|
@@ -1,6 +1,6 @@
/*
- * Copyright (C) 2015-2021 Jolla Ltd.
- * Copyright (C) 2015-2021 Slava Monich <slava.monich@jolla.com>
+ * Copyright (C) 2015-2022 Jolla Ltd.
+ * Copyright (C) 2015-2022 Slava Monich <slava.monich@jolla.com>
*
* You may use this file under the terms of the BSD license as follows:
*
@@ -44,21 +44,21 @@
#include <MGConfItem>
#define DCONF_PATH BOOKS_DCONF_ROOT
-#define KEY_FONT_SIZE "fontSize"
-#define KEY_PAGE_DETAILS "pageDetails"
-#define KEY_NIGHT_MODE_BRIGHTNESS "nightModeBrightness"
-#define KEY_PAGE_DETAILS_FIXED "pageDetailsFixed"
-#define KEY_TURN_PAGE_BY_TAP "turnPageByTap"
-#define KEY_SAMPLE_BOOK_COPIED "sampleBookCopied"
-#define KEY_CURRENT_BOOK "currentBook"
-#define KEY_CURRENT_FOLDER "currentFolder"
-#define KEY_REMOVABLE_ROOT "removableRoot"
-#define KEY_INVERT_COLORS "invertColors"
-#define KEY_KEEP_DISPLAY_ON "keepDisplayOn"
-#define KEY_BOOK_PULL_DOWN_MENU "bookPullDownMenu"
-#define KEY_VOLUME_UP_ACTION "volumeUpAction"
-#define KEY_VOLUME_DOWN_ACTION "volumeDownAction"
-#define KEY_ORIENTATION "orientation"
+#define DCONF_PATH_(x) BOOKS_DCONF_ROOT x
+#define KEY_FONT_SIZE DCONF_PATH_("fontSize")
+#define KEY_PAGE_DETAILS DCONF_PATH_("pageDetails")
+#define KEY_NIGHT_MODE_BRIGHTNESS DCONF_PATH_("nightModeBrightness")
+#define KEY_PAGE_DETAILS_FIXED DCONF_PATH_("pageDetailsFixed")
+#define KEY_TURN_PAGE_BY_TAP DCONF_PATH_("turnPageByTap")
+#define KEY_SAMPLE_BOOK_COPIED DCONF_PATH_("sampleBookCopied")
+#define KEY_CURRENT_BOOK DCONF_PATH_("currentBook")
+#define KEY_CURRENT_FOLDER DCONF_PATH_("currentFolder")
+#define KEY_REMOVABLE_ROOT DCONF_PATH_("removableRoot")
+#define KEY_KEEP_DISPLAY_ON DCONF_PATH_("keepDisplayOn")
+#define KEY_BOOK_PULL_DOWN_MENU DCONF_PATH_("bookPullDownMenu")
+#define KEY_VOLUME_UP_ACTION DCONF_PATH_("volumeUpAction")
+#define KEY_VOLUME_DOWN_ACTION DCONF_PATH_("volumeDownAction")
+#define KEY_ORIENTATION DCONF_PATH_("orientation")
#define DEFAULT_FONT_SIZE 0
#define DEFAULT_NIGHT_BRIGHTNESS 1.0
@@ -69,19 +69,12 @@
#define DEFAULT_CURRENT_BOOK QString()
#define DEFAULT_CURRENT_FOLDER QString()
#define DEFAULT_REMOVABLE_ROOT "Books"
-#define DEFAULT_INVERT_COLORS false
#define DEFAULT_KEEP_DISPLAY_ON false
#define DEFAULT_BOOK_PULL_DOWN_MENU true
#define DEFAULT_VOLUME_UP_ACTION (BooksSettings::ActionNextPage)
#define DEFAULT_VOLUME_DOWN_ACTION (BooksSettings::ActionPreviousPage)
#define DEFAULT_ORIENTATION (BooksSettings::OrientationAny)
-#define DEFAULT_BACKGROUND QColor(Qt::white)
-#define INVERTED_BACKGROUND QColor(Qt::black)
-#define PAGETOOL_COLOR QColor(128,128,128) // any bg
-#define NORMAL_PAGETOOL_HIGHLIGHT_COLOR QColor(64,64,64) // on white
-#define INVERTED_PAGETOOL_HIGHLIGHT_COLOR QColor(192,192,192) // on black
-
// ==========================================================================
// BooksSettings::TextStyle
// ==========================================================================
@@ -94,27 +87,27 @@
iFontSize(iDefaultStyle->fontSize() + 2*aFontSizeModifier)
{ HDEBUG(iFontSize); }
- bool isDecorated() const;
+ bool isDecorated() const Q_DECL_OVERRIDE;
- const std::vector<std::string> &fontFamilies() const;
+ const std::vector<std::string> &fontFamilies() const Q_DECL_OVERRIDE;
- int fontSize() const;
- bool bold() const;
- bool italic() const;
+ int fontSize() const Q_DECL_OVERRIDE;
+ bool bold() const Q_DECL_OVERRIDE;
+ bool italic() const Q_DECL_OVERRIDE;
- const std::string &colorStyle() const;
+ const std::string &colorStyle() const Q_DECL_OVERRIDE;
- short spaceBefore(const ZLTextStyleEntry::Metrics& aMetrics) const;
- short spaceAfter(const ZLTextStyleEntry::Metrics& aMetrics) const;
- short lineStartIndent(const ZLTextStyleEntry::Metrics& aMetrics, bool aRtl) const;
- short lineEndIndent(const ZLTextStyleEntry::Metrics& aMetrics, bool aRtl) const;
- short firstLineIndentDelta(const ZLTextStyleEntry::Metrics& aMetrics) const;
- int verticalShift() const;
+ short spaceBefore(const ZLTextStyleEntry::Metrics&) const Q_DECL_OVERRIDE;
+ short spaceAfter(const ZLTextStyleEntry::Metrics&) const Q_DECL_OVERRIDE;
+ short lineStartIndent(const ZLTextStyleEntry::Metrics&, bool) const Q_DECL_OVERRIDE;
+ short lineEndIndent(const ZLTextStyleEntry::Metrics&, bool) const Q_DECL_OVERRIDE;
+ short firstLineIndentDelta(const ZLTextStyleEntry::Metrics&) const Q_DECL_OVERRIDE;
+ int verticalShift() const Q_DECL_OVERRIDE;
- ZLTextAlignmentType alignment() const;
+ ZLTextAlignmentType alignment() const Q_DECL_OVERRIDE;
- double lineSpace() const;
- bool allowHyphenations() const;
+ double lineSpace() const Q_DECL_OVERRIDE;
+ bool allowHyphenations() const Q_DECL_OVERRIDE;
private:
shared_ptr<ZLTextStyle> iDefaultStyle;
@@ -222,28 +215,35 @@
// BooksSettings::Private
// ==========================================================================
-class BooksSettings::Private : public QObject {
+class BooksSettings::Private : public QObject
+{
Q_OBJECT
public:
+ // Matches Silica::Theme::ColorScheme
+ enum ColorScheme {
+ LightOnDark,
+ DarkOnLight
+ };
+
Private(BooksSettings* aParent);
+ ~Private();
- BooksSettings* parentSettings() const;
+ BooksSettings* parentObject() const;
bool updateCurrentBook();
bool updateCurrentStorage();
bool updateBrightness();
- bool invertColors() const;
int fontSizeValue() const;
int fontSize(int aFontSizeAdjust) const;
qreal brightnessValue() const;
qreal nightModeBrightness() const;
QString currentFolder() const;
shared_ptr<ZLTextStyle> textStyle(int aFontSizeAdjust) const;
- void setCurrentBook(QObject* aBook);
- static Action getAction(MGConfItem* aItem, Action aDefault);
- static qreal normalizeBrightness(qreal aBrightness);
+ void setCurrentBook(QObject*);
+ static Action getAction(MGConfItem*, Action);
+ static qreal normalizeBrightness(qreal);
-private Q_SLOTS:
- void onInvertColorsChanged();
+public Q_SLOTS:
+ void onNightModeChanged();
void onNightModeBrightnessChanged();
void onFontSizeValueChanged();
void onCurrentBookPathChanged();
@@ -256,7 +256,6 @@
MGConfItem* iPageDetailsConf;
MGConfItem* iPageDetailsFixedConf;
MGConfItem* iTurnPageByTapConf;
- MGConfItem* iInvertColorsConf;
MGConfItem* iSampleBookCopiedConf;
MGConfItem* iKeepDisplayOnConf;
MGConfItem* iBookPullDownMenuConf;
@@ -277,29 +276,28 @@
BooksSettings::Private::Private(BooksSettings* aParent) :
QObject(aParent),
- iFontSizeConf(new MGConfItem(DCONF_PATH KEY_FONT_SIZE, this)),
- iNightModeBrightnessConf(new MGConfItem(DCONF_PATH KEY_NIGHT_MODE_BRIGHTNESS, this)),
- iPageDetailsConf(new MGConfItem(DCONF_PATH KEY_PAGE_DETAILS, this)),
- iPageDetailsFixedConf(new MGConfItem(DCONF_PATH KEY_PAGE_DETAILS_FIXED, this)),
- iTurnPageByTapConf(new MGConfItem(DCONF_PATH KEY_TURN_PAGE_BY_TAP, this)),
- iInvertColorsConf(new MGConfItem(DCONF_PATH KEY_INVERT_COLORS, this)),
- iSampleBookCopiedConf(new MGConfItem(DCONF_PATH KEY_SAMPLE_BOOK_COPIED, this)),
- iKeepDisplayOnConf(new MGConfItem(DCONF_PATH KEY_KEEP_DISPLAY_ON, this)),
- iBookPullDownMenuConf(new MGConfItem(DCONF_PATH KEY_BOOK_PULL_DOWN_MENU, this)),
- iVolumeUpActionConf(new MGConfItem(DCONF_PATH KEY_VOLUME_UP_ACTION, this)),
- iVolumeDownActionConf(new MGConfItem(DCONF_PATH KEY_VOLUME_DOWN_ACTION, this)),
- iCurrentFolderConf(new MGConfItem(DCONF_PATH KEY_CURRENT_FOLDER, this)),
- iCurrentBookPathConf(new MGConfItem(DCONF_PATH KEY_CURRENT_BOOK, this)),
- iOrientationConf(new MGConfItem(DCONF_PATH KEY_ORIENTATION, this)),
- iRemovableRootConf(new MGConfItem(DCONF_PATH KEY_REMOVABLE_ROOT, this)),
- iCurrentBook(NULL)
+ iFontSizeConf(new MGConfItem(KEY_FONT_SIZE, this)),
+ iNightModeBrightnessConf(new MGConfItem(KEY_NIGHT_MODE_BRIGHTNESS, this)),
+ iPageDetailsConf(new MGConfItem(KEY_PAGE_DETAILS, this)),
+ iPageDetailsFixedConf(new MGConfItem(KEY_PAGE_DETAILS_FIXED, this)),
+ iTurnPageByTapConf(new MGConfItem(KEY_TURN_PAGE_BY_TAP, this)),
+ iSampleBookCopiedConf(new MGConfItem(KEY_SAMPLE_BOOK_COPIED, this)),
+ iKeepDisplayOnConf(new MGConfItem(KEY_KEEP_DISPLAY_ON, this)),
+ iBookPullDownMenuConf(new MGConfItem(KEY_BOOK_PULL_DOWN_MENU, this)),
+ iVolumeUpActionConf(new MGConfItem(KEY_VOLUME_UP_ACTION, this)),
+ iVolumeDownActionConf(new MGConfItem(KEY_VOLUME_DOWN_ACTION, this)),
+ iCurrentFolderConf(new MGConfItem(KEY_CURRENT_FOLDER, this)),
+ iCurrentBookPathConf(new MGConfItem(KEY_CURRENT_BOOK, this)),
+ iOrientationConf(new MGConfItem(KEY_ORIENTATION, this)),
+ iRemovableRootConf(new MGConfItem(KEY_REMOVABLE_ROOT, this)),
+ iCurrentBook(Q_NULLPTR)
{
iFontSize = fontSizeValue();
iBrightness = brightnessValue();
+ connect(aParent, SIGNAL(nightModeChanged()), SLOT(onNightModeChanged()));
|
[-]
[+]
|
Changed |
_service:tar_git:openrepos-books-1.1.0.tar.gz/app/src/BooksSettings.h
^
|
@@ -1,6 +1,6 @@
/*
- * Copyright (C) 2015-2021 Jolla Ltd.
- * Copyright (C) 2015-2021 Slava Monich <slava.monich@jolla.com>
+ * Copyright (C) 2015-2022 Jolla Ltd.
+ * Copyright (C) 2015-2022 Slava Monich <slava.monich@jolla.com>
*
* You may use this file under the terms of the BSD license as follows:
*
@@ -34,13 +34,14 @@
#ifndef BOOKS_SETTINGS_H
#define BOOKS_SETTINGS_H
-#include "BooksTypes.h"
+#include "shared_ptr.h"
#include "ZLTextStyle.h"
-#include <QObject>
-#include <QColor>
+
+#include "BooksSettingsBase.h"
+
#include <QSharedPointer>
-class BooksSettings : public QObject
+class BooksSettings : public BooksSettingsBase
{
Q_OBJECT
Q_ENUMS(FontSize)
@@ -52,7 +53,6 @@
Q_PROPERTY(int pageDetails READ pageDetails WRITE setPageDetails NOTIFY pageDetailsChanged)
Q_PROPERTY(bool pageDetailsFixed READ pageDetailsFixed WRITE setPageDetailsFixed NOTIFY pageDetailsFixedChanged)
Q_PROPERTY(bool turnPageByTap READ turnPageByTap WRITE setTurnPageByTap NOTIFY turnPageByTapChanged)
- Q_PROPERTY(bool invertColors READ invertColors WRITE setInvertColors NOTIFY invertColorsChanged)
Q_PROPERTY(bool sampleBookCopied READ sampleBookCopied NOTIFY sampleBookCopiedChanged)
Q_PROPERTY(bool keepDisplayOn READ keepDisplayOn WRITE setKeepDisplayOn NOTIFY keepDisplayOnChanged)
Q_PROPERTY(bool bookPullDownMenu READ bookPullDownMenu WRITE setBookPullDownMenu NOTIFY bookPullDownMenuChanged)
@@ -63,10 +63,6 @@
Q_PROPERTY(QString currentStorage READ currentStorage NOTIFY currentStorageChanged)
Q_PROPERTY(QString relativePath READ relativePath NOTIFY relativePathChanged)
Q_PROPERTY(QString removableRoot READ removableRoot NOTIFY removableRootChanged)
- Q_PROPERTY(QColor primaryPageToolColor READ primaryPageToolColor CONSTANT)
- Q_PROPERTY(QColor highlightPageToolColor READ highlightPageToolColor NOTIFY invertColorsChanged)
- Q_PROPERTY(QColor invertedPageBackgroundColor READ highlightPageToolColor NOTIFY invertColorsChanged)
- Q_PROPERTY(QColor pageBackgroundColor READ pageBackgroundColor NOTIFY pageBackgroundColorChanged)
Q_PROPERTY(int orientation READ orientation NOTIFY orientationChanged)
class TextStyle;
@@ -97,59 +93,53 @@
Q_INVOKABLE bool increaseFontSize();
Q_INVOKABLE bool decreaseFontSize();
- shared_ptr<ZLTextStyle> textStyle(int aFontSizeAdjust) const;
+ shared_ptr<ZLTextStyle> textStyle(int) const;
int fontSize() const;
void setFontSize(int aValue);
qreal brightness() const;
qreal nightModeBrightness() const;
- void setNightModeBrightness(qreal aValue);
+ void setNightModeBrightness(qreal);
int pageDetails() const;
- void setPageDetails(int aValue);
+ void setPageDetails(int);
bool pageDetailsFixed() const;
- void setPageDetailsFixed(bool aValue);
+ void setPageDetailsFixed(bool);
bool turnPageByTap() const;
- void setTurnPageByTap(bool aValue);
-
- bool invertColors() const; // Night mode
- void setInvertColors(bool aValue);
+ void setTurnPageByTap(bool);
bool keepDisplayOn() const;
- void setKeepDisplayOn(bool aValue);
+ void setKeepDisplayOn(bool);
bool bookPullDownMenu() const;
- void setBookPullDownMenu(bool aValue);
+ void setBookPullDownMenu(bool);
bool sampleBookCopied() const;
void setSampleBookCopied();
Action volumeUpAction() const;
- void setVolumeUpAction(int aValue);
+ void setVolumeUpAction(int);
Action volumeDownAction() const;
- void setVolumeDownAction(int aValue);
+ void setVolumeDownAction(int);
QObject* currentBook() const;
- void setCurrentBook(QObject* aBook);
+ void setCurrentBook(QObject*);
QString relativePath() const;
QString removableRoot() const;
QString currentFolder() const;
- void setCurrentFolder(QString aValue);
+ void setCurrentFolder(const QString);
QString currentStorage() const;
- QColor primaryPageToolColor() const;
- QColor highlightPageToolColor() const;
- QColor pageBackgroundColor() const;
Orientation orientation() const;
public Q_SLOTS:
- void setCurrentBookPath(QString aPath);
+ void setCurrentBookPath(QString);
Q_SIGNALS:
void fontSizeChanged();
@@ -159,7 +149,6 @@
void pageDetailsChanged();
void pageDetailsFixedChanged();
void turnPageByTapChanged();
- void invertColorsChanged();
void sampleBookCopiedChanged();
void keepDisplayOnChanged();
void bookPullDownMenuChanged();
@@ -170,7 +159,6 @@
void currentStorageChanged();
void relativePathChanged();
void removableRootChanged();
- void pageBackgroundColorChanged();
void orientationChanged();
private:
|
[-]
[+]
|
Added |
_service:tar_git:openrepos-books-1.1.0.tar.gz/app/src/BooksSettingsBase.cpp
^
|
@@ -0,0 +1,510 @@
+/*
+ * Copyright (C) 2015-2022 Jolla Ltd.
+ * Copyright (C) 2015-2022 Slava Monich <slava.monich@jolla.com>
+ *
+ * You may use this file under the terms of the 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:
+ *
+ * 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
+ * distribution.
+ * 3. Neither the names of the copyright holders 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
+ * OWNER 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.
+ */
+
+#include "BooksSettingsBase.h"
+#include "BooksDefs.h"
+
+#include "HarbourDebug.h"
+#include "HarbourUtil.h"
+
+#include <MGConfItem>
+
+#define DCONF_PATH BOOKS_DCONF_ROOT
+#define DCONF_PATH_(x) BOOKS_DCONF_ROOT x
+#define KEY_NIGHT_MODE DCONF_PATH_("invertColors")
+#define KEY_CUSTOM_COLOR_SCHEME DCONF_PATH_("customColorScheme")
+#define KEY_USE_CUSTOM_COLOR_SCHEME DCONF_PATH_("useCustomColorScheme")
+#define KEY_AVAILABLE_COLORS DCONF_PATH_("availableColors")
+
+#define DEFAULT_NIGHT_MODE false
+#define DEFAULT_USE_CUSTOM_COLOR_SCHEME false
+
+// ==========================================================================
+// BooksSettingsBase::Private
+// ==========================================================================
+
+class BooksSettingsBase::Private : public QObject
+{
+ Q_OBJECT
+public:
+ // Matches Silica::Theme::ColorScheme
+ enum ColorScheme {
+ LightOnDark,
+ DarkOnLight
+ };
+
+ static const char* gDefaultColors[];
+
+ Private(BooksSettingsBase* aParent);
+ ~Private();
+
+ BooksSettingsBase* parentObject() const;
+ static QStringList defaultColors();
+ QStringList availableColors() const;
+ ColorScheme silicaColorScheme() const;
+ bool darkOnLight() const;
+ BooksColorScheme nightModeScheme(const BooksColorScheme);
+ QString customColorSchemeSpec() const;
+ bool useCustomColorScheme() const;
+ void setTheme(QObject*);
+ void updateColorScheme();
+ void updateDarkOnLight();
+ void updateDefaultHighlightBackgroundColor();
+ bool setCustomColorScheme(const BooksColorScheme);
+ void emitPendingSignals();
+ bool nightMode() const;
+
+public Q_SLOTS:
+ void onUseCustomColorSchemeChanged();
+ void onThemeHighlightBackgroundColorChanged();
+ void onThemeColorSchemeChanged();
+ void onNightModeChanged();
+ void onCustomColorSchemeChanged();
+ void onAvailableColorsChanged();
+
+public:
+ MGConfItem* iNightModeConf;
+ MGConfItem* iCustomColorSchemeConf;
+ MGConfItem* iUseCustomColorSchemeConf;
+ MGConfItem* iAvailableColorsConf;
+ const QStringList iDefaultColors;
+ QStringList iAvailableColors;
+ BooksColorScheme iDefaultColorScheme;
+ BooksColorScheme iDefaultNightModeColorScheme;
+ BooksColorScheme iCustomColorScheme;
+ BooksColorScheme iCustomNightModeColorScheme;
+ BooksColorScheme iColorScheme;
+ QObject* iTheme;
+ bool iHaveSilicaColorScheme;
+ bool iDarkOnLight;
+ bool iColorSchemeChangePending;
+ bool iDarkOnLightChangePending;
+};
+
+const char* BooksSettingsBase::Private::gDefaultColors[] = {
+ "#000000", "#2160b4", "#3c8bff",
+ "#007f7f", "#01823f", "#4fb548",
+ "#c82246", "#f13c27", "#fedc00",
+ "#f78628", "#7d499b", "#937782",
+ "#545454", "#a8a8a8", "#ffffff"
+};
+
+BooksSettingsBase::Private::Private(
+ BooksSettingsBase* aParent) :
+ QObject(aParent),
+ iNightModeConf(new MGConfItem(KEY_NIGHT_MODE, this)),
+ iCustomColorSchemeConf(new MGConfItem(KEY_CUSTOM_COLOR_SCHEME, this)),
+ iUseCustomColorSchemeConf(new MGConfItem(KEY_USE_CUSTOM_COLOR_SCHEME, this)),
+ iAvailableColorsConf(new MGConfItem(KEY_AVAILABLE_COLORS, this)),
+ iDefaultColors(defaultColors()),
+ iTheme(Q_NULLPTR),
+ iHaveSilicaColorScheme(false),
+ iDarkOnLight(false),
+ iColorSchemeChangePending(false),
+ iDarkOnLightChangePending(false)
+{
+ iDefaultNightModeColorScheme = nightModeScheme(iDefaultColorScheme);
+ iCustomColorScheme = BooksColorScheme(customColorSchemeSpec());
+ iCustomNightModeColorScheme = nightModeScheme(iCustomColorScheme);
+ connect(iNightModeConf, SIGNAL(valueChanged()), SLOT(onNightModeChanged()));
+ connect(iCustomColorSchemeConf, SIGNAL(valueChanged()), SLOT(onCustomColorSchemeChanged()));
+ connect(iUseCustomColorSchemeConf, SIGNAL(valueChanged()), SLOT(onUseCustomColorSchemeChanged()));
+ connect(iUseCustomColorSchemeConf, SIGNAL(valueChanged()), SLOT(onUseCustomColorSchemeChanged()));
+ connect(iAvailableColorsConf, SIGNAL(valueChanged()), SLOT(onAvailableColorsChanged()));
+ iAvailableColors = availableColors();
+ HDEBUG("Custom color scheme" << customColorSchemeSpec() << "=>" << iCustomColorScheme.toString());
+}
+
+BooksSettingsBase::Private::~Private()
+{
+ if (iTheme) disconnect(iTheme);
+}
+
+BooksSettingsBase*
+BooksSettingsBase::Private::parentObject() const
+{
+ return qobject_cast<BooksSettingsBase*>(parent());
+}
+
+QStringList
+BooksSettingsBase::Private::defaultColors()
+{
+ QStringList colors;
+ const uint n = sizeof(gDefaultColors)/sizeof(gDefaultColors[0]);
+ colors.reserve(n);
+ for (uint i = 0; i < n; i++) {
+ colors.append(QLatin1String(gDefaultColors[i]));
+ }
+ return colors;
+}
+
+bool
+BooksSettingsBase::Private::nightMode() const
+{
+ return iNightModeConf->value(DEFAULT_NIGHT_MODE).toBool();
+}
+
+QString
+BooksSettingsBase::Private::customColorSchemeSpec() const
+{
+ return iCustomColorSchemeConf->value().toString();
+}
+
+bool
+BooksSettingsBase::Private::useCustomColorScheme() const
+{
+ return iUseCustomColorSchemeConf->value(DEFAULT_USE_CUSTOM_COLOR_SCHEME).toBool();
+}
+
+void
+BooksSettingsBase::Private::setTheme(
+ QObject* aTheme)
+{
+ if (iTheme != aTheme) {
+ if (iTheme) disconnect(iTheme);
+ iTheme = aTheme;
+ if (iTheme) {
+ connect(iTheme,
+ SIGNAL(highlightBackgroundColorChanged()),
+ SLOT(onThemeHighlightBackgroundColorChanged()));
|
[-]
[+]
|
Added |
_service:tar_git:openrepos-books-1.1.0.tar.gz/app/src/BooksSettingsBase.h
^
|
@@ -0,0 +1,103 @@
+/*
+ * Copyright (C) 2022 Jolla Ltd.
+ * Copyright (C) 2022 Slava Monich <slava.monich@jolla.com>
+ *
+ * You may use this file under the terms of the 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:
+ *
+ * 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
+ * distribution.
+ * 3. Neither the names of the copyright holders 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
+ * OWNER 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.
+ */
+
+#ifndef BOOKS_SETTINGS_BASE_H
+#define BOOKS_SETTINGS_BASE_H
+
+#include "BooksTypes.h"
+#include "BooksColorScheme.h"
+
+#include <QObject>
+#include <QColor>
+#include <QStringList>
+
+class BooksSettingsBase : public QObject
+{
+ Q_OBJECT
+ Q_PROPERTY(QObject* theme READ theme WRITE setTheme NOTIFY themeChanged)
+ Q_PROPERTY(bool darkOnLight READ darkOnLight NOTIFY darkOnLightChanged)
+ Q_PROPERTY(bool nightMode READ nightMode WRITE setNightMode NOTIFY nightModeChanged)
+ Q_PROPERTY(QColor pageBackgroundColor READ pageBackgroundColor NOTIFY colorSchemeChanged)
+ Q_PROPERTY(QColor invertedPageBackgroundColor READ invertedPageBackgroundColor NOTIFY colorSchemeChanged)
+ Q_PROPERTY(QColor primaryPageToolColor READ primaryPageToolColor NOTIFY colorSchemeChanged)
+ Q_PROPERTY(QColor highlightPageToolColor READ highlightPageToolColor NOTIFY colorSchemeChanged)
+ Q_PROPERTY(BooksColorScheme colorScheme READ colorScheme NOTIFY colorSchemeChanged)
+ Q_PROPERTY(BooksColorScheme customColorScheme READ customColorScheme WRITE setCustomColorScheme NOTIFY customColorSchemeChanged)
+ Q_PROPERTY(BooksColorScheme customNightModeColorScheme READ customNightModeColorScheme NOTIFY customColorSchemeChanged)
+ Q_PROPERTY(bool useCustomColorScheme READ useCustomColorScheme WRITE setUseCustomColorScheme NOTIFY useCustomColorSchemeChanged)
+ Q_PROPERTY(QStringList defaultColors READ defaultColors CONSTANT)
+ Q_PROPERTY(QStringList availableColors READ availableColors WRITE setAvailableColors NOTIFY availableColorsChanged)
+
+public:
+ explicit BooksSettingsBase(QObject* aParent = Q_NULLPTR);
+ ~BooksSettingsBase();
+
+ QObject* theme() const;
+ void setTheme(QObject*);
+ bool darkOnLight() const;
+
+ bool nightMode() const;
+ void setNightMode(bool);
+
+ QColor pageBackgroundColor() const;
+ QColor invertedPageBackgroundColor() const;
+ QColor primaryPageToolColor() const;
+ QColor highlightPageToolColor() const;
+ BooksColorScheme colorScheme() const;
+
+ BooksColorScheme customColorScheme() const;
+ BooksColorScheme customNightModeColorScheme() const;
+ void setCustomColorScheme(const BooksColorScheme);
+
+ bool useCustomColorScheme() const;
+ void setUseCustomColorScheme(bool);
+
+ const QStringList defaultColors() const;
+ QStringList availableColors() const;
+ void setAvailableColors(const QStringList);
+
+Q_SIGNALS:
+ void themeChanged();
+ void darkOnLightChanged();
+ void nightModeChanged();
+ void colorSchemeChanged();
+ void customColorSchemeChanged();
+ void useCustomColorSchemeChanged();
+ void availableColorsChanged();
+
+private:
+ class Private;
+ Private* iPrivate;
+};
+
+#endif // BOOKS_SETTINGS_BASE_H
|
[-]
[+]
|
Changed |
_service:tar_git:openrepos-books-1.1.0.tar.gz/app/src/BooksShelf.cpp
^
|
@@ -1,6 +1,6 @@
/*
- * Copyright (C) 2015-2018 Jolla Ltd.
- * Copyright (C) 2015-2018 Slava Monich <slava.monich@jolla.com>
+ * Copyright (C) 2015-2021 Jolla Ltd.
+ * Copyright (C) 2015-2021 Slava Monich <slava.monich@jolla.com>
*
* You may use this file under the terms of the BSD license as follows:
*
@@ -8,15 +8,15 @@
* 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.
+ * 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
+ * distribution.
+ * 3. Neither the names of the copyright holders 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
@@ -100,7 +100,7 @@
void performTask();
- int findBook(QString aFileName) const;
+ int findBook(const QStringRef* aFileName) const;
static int find(QFileInfoList aList, QString aFileName, int aStart);
public:
@@ -129,15 +129,14 @@
return -1;
}
-int BooksShelf::LoadTask::findBook(QString aFileName) const
+int BooksShelf::LoadTask::findBook(const QStringRef* aFileName) const
{
- if (!aFileName.isEmpty()) {
- const int n = iItems.count();
- for (int i=0; i<n; i++) {
- BooksItem* item = iItems.at(i);
- if (item->book() && item->fileName() == aFileName) {
- return i;
- }
+ // Caller makes sure that aFileName is not empty
+ const int n = iItems.count();
+ for (int i=0; i<n; i++) {
+ BooksItem* item = iItems.at(i);
+ if (item->book() && aFileName->compare(item->fileName()) == 0) {
+ return i;
}
}
return -1;
@@ -202,19 +201,32 @@
}
}
- // Cleanup the state files
+ // Delete orphaned state and marks files
if (!isCanceled()) {
+ static const QString stateSuffix(BOOKS_STATE_FILE_SUFFIX);
+ static const QString marksSuffix(BOOKS_MARKS_FILE_SUFFIX);
QStringList deleteMe;
- const QString suffix(BOOKS_STATE_FILE_SUFFIX);
- QDirIterator configIt(iStorage.configDir());
+ QDirIterator configIt(iStorage.fullConfigPath(iRelativePath));
while (configIt.hasNext() && !isCanceled()) {
- QString path(configIt.next());
- if (path.endsWith(suffix)) {
- QString fileName(configIt.fileName());
- QString name(fileName.left(fileName.length() - suffix.length()));
- if (!name.isEmpty() && findBook(name) < 0) {
+ const QString path(configIt.next());
+ if (path.endsWith(stateSuffix)) {
+ const QString fileName(configIt.fileName());
+ // State file is named <BOOK>.state
+ QStringRef name(fileName.leftRef(fileName.length() - stateSuffix.length()));
+ if (!name.isEmpty() && findBook(&name) < 0) {
deleteMe.append(path);
}
+ } else if (path.endsWith(marksSuffix)) {
+ const QString fileName(configIt.fileName());
+ // Marks file is named <BOOK>.<width>x<height>.marks
+ QStringRef name(fileName.leftRef(fileName.length() - stateSuffix.length()));
+ const int nextSeparator = name.lastIndexOf('.');
+ if (nextSeparator > 0) {
+ name = name.left(nextSeparator);
+ if (findBook(&name) < 0) {
+ deleteMe.append(path);
+ }
+ }
}
}
while (!deleteMe.isEmpty() && !isCanceled()) {
|
[-]
[+]
|
Changed |
_service:tar_git:openrepos-books-1.1.0.tar.gz/app/src/BooksStorage.cpp
^
|
@@ -1,6 +1,6 @@
/*
- * Copyright (C) 2015-2021 Jolla Ltd.
- * Copyright (C) 2015-2021 Slava Monich <slava.monich@jolla.com>
+ * Copyright (C) 2015-2022 Jolla Ltd.
+ * Copyright (C) 2015-2022 Slava Monich <slava.monich@jolla.com>
*
* You may use this file under the terms of the BSD license as follows:
*
@@ -68,15 +68,14 @@
Q_OBJECT
public:
- Private(QString aDevice, QString aMountPoint, QString aBooksDir,
- Type aType);
+ Private(QString, QString, QString, Type);
bool isRemoved() const;
- bool equal(const Private& aData) const;
+ bool equal(const Private&) const;
- static QString fullPath(QDir aDir, QString aRelativePath);
- static QString mountPoint(QString aPath);
- static bool isMountPoint(QString aPath);
+ static QString fullPath(QDir, const QString);
+ static QString mountPoint(const QString);
+ static bool isMountPoint(const QString);
Q_SIGNALS:
void removed();
@@ -128,7 +127,9 @@
iConfigDir.setPath(cfgDir);
}
-bool BooksStorage::Private::equal(const BooksStorage::Private& aData) const
+bool
+BooksStorage::Private::equal(
+ const BooksStorage::Private& aData) const
{
return iType == aData.iType &&
iPresent == aData.iPresent &&
@@ -138,7 +139,9 @@
iConfigDir == aData.iConfigDir;
}
-bool BooksStorage::Private::isMountPoint(QString aPath)
+bool
+BooksStorage::Private::isMountPoint(
+ const QString aPath)
{
std::string path = aPath.toStdString();
std::string parent = path + "/..";
@@ -148,7 +151,9 @@
stPath.st_dev != stParent.st_dev;
}
-QString BooksStorage::Private::mountPoint(QString aPath)
+QString
+BooksStorage::Private::mountPoint(
+ const QString aPath)
{
QFileInfo info(aPath);
QDir dir = info.isDir() ? QDir(aPath) : info.dir();
@@ -160,7 +165,10 @@
return dir.path();
}
-QString BooksStorage::Private::fullPath(QDir aDir, QString aRelativePath)
+QString
+BooksStorage::Private::fullPath(
+ QDir aDir,
+ const QString aRelativePath)
{
QString path(aDir.path());
if (!aRelativePath.isEmpty()) {
@@ -181,7 +189,8 @@
{
}
-BooksStorage::BooksStorage(const BooksStorage& aStorage) :
+BooksStorage::BooksStorage(
+ const BooksStorage& aStorage) :
QObject(NULL),
iPrivate(aStorage.iPrivate),
iPassThrough(false)
@@ -189,7 +198,10 @@
if (iPrivate) iPrivate->iRef.ref();
}
-BooksStorage::BooksStorage(QString aDevice, QString aMount, QString aBooksDir,
+BooksStorage::BooksStorage(
+ const QString aDevice,
+ const QString aMount,
+ const QString aBooksDir,
Type aType) : QObject(NULL),
iPrivate(new Private(aDevice, aMount, aBooksDir, aType)),
iPassThrough(false)
@@ -202,12 +214,15 @@
if (iPrivate && !iPrivate->iRef.deref()) delete iPrivate;
}
-BooksStorage BooksStorage::tmpStorage()
+BooksStorage
+BooksStorage::tmpStorage()
{
return BooksStorage("tmpfs", "/tmp", "/", BooksStorage::TmpStorage);
}
-void BooksStorage::connectNotify(const QMetaMethod& aSignal)
+void
+BooksStorage::connectNotify(
+ const QMetaMethod& aSignal)
{
if (iPrivate && !iPassThrough) {
iPassThrough = true;
@@ -219,32 +234,39 @@
QObject::connectNotify(aSignal);
}
-QString BooksStorage::device() const
+QString
+BooksStorage::device() const
{
return iPrivate ? iPrivate->iDevice : QString();
}
-QDir BooksStorage::booksDir() const
+QDir
+BooksStorage::booksDir() const
{
return iPrivate ? iPrivate->iBooksDir : QDir();
}
-QDir BooksStorage::configDir() const
+QDir
+BooksStorage::configDir() const
{
return iPrivate ? iPrivate->iConfigDir : QDir();
}
-bool BooksStorage::isInternal() const
+bool
+BooksStorage::isInternal() const
{
return iPrivate && iPrivate->iType == InternalStorage;
}
-bool BooksStorage::isPresent() const
+bool
+BooksStorage::isPresent() const
{
return iPrivate && iPrivate->iPresent;
}
-QString BooksStorage::fullPath(QString aRelativePath) const
+QString
+BooksStorage::fullPath(
+ const QString aRelativePath) const
{
if (iPrivate) {
return Private::fullPath(iPrivate->iBooksDir, aRelativePath);
@@ -252,7 +274,9 @@
return QString();
}
-QString BooksStorage::fullConfigPath(QString aRelativePath) const
+QString
+BooksStorage::fullConfigPath(
+ const QString aRelativePath) const
{
if (iPrivate) {
return Private::fullPath(iPrivate->iConfigDir, aRelativePath);
@@ -260,7 +284,9 @@
return QString();
}
-bool BooksStorage::equal(const BooksStorage& aStorage) const
+bool
+BooksStorage::equal(
+ const BooksStorage& aStorage) const
{
if (iPrivate == aStorage.iPrivate) {
return true;
@@ -271,7 +297,9 @@
}
}
-void BooksStorage::set(const BooksStorage& aStorage)
+void
+BooksStorage::set(
+ const BooksStorage& aStorage)
{
if (iPrivate != aStorage.iPrivate) {
if (iPrivate && !iPrivate->iRef.deref()) delete iPrivate;
@@ -291,12 +319,14 @@
#define STORAGE_PARTITION "partition"
#define STORAGE_ACTION_ADD "add"
+#define STORAGE_ACTION_CHANGE "change"
#define STORAGE_ACTION_REMOVE "remove"
|
[-]
[+]
|
Changed |
_service:tar_git:openrepos-books-1.1.0.tar.gz/app/src/BooksStorage.h
^
|
@@ -1,6 +1,6 @@
/*
- * Copyright (C) 2015-2021 Jolla Ltd.
- * Copyright (C) 2015-2021 Slava Monich <slava.monich@jolla.com>
+ * Copyright (C) 2015-2022 Jolla Ltd.
+ * Copyright (C) 2015-2022 Slava Monich <slava.monich@jolla.com>
*
* You may use this file under the terms of the BSD license as follows:
*
@@ -56,7 +56,7 @@
public:
BooksStorage();
- BooksStorage(const BooksStorage& aStorage);
+ BooksStorage(const BooksStorage&);
~BooksStorage();
QString device() const;
@@ -64,14 +64,14 @@
QDir configDir() const;
QString label() const { return booksDir().dirName(); }
QString root() const { return booksDir().path(); }
- QString fullConfigPath(QString aRelativePath) const;
- QString fullPath(QString aRelativePath) const;
+ QString fullConfigPath(const QString) const;
+ QString fullPath(const QString) const;
bool isValid() const { return iPrivate != NULL; }
bool isInternal() const;
bool isPresent() const;
- bool equal(const BooksStorage& aStorage) const;
- void set(const BooksStorage& aStorage);
+ bool equal(const BooksStorage&) const;
+ void set(const BooksStorage&);
BooksStorage& operator = (const BooksStorage& aStorage)
{ set(aStorage); return *this; }
@@ -85,8 +85,8 @@
private:
friend class BooksStorageManager;
- BooksStorage(QString, QString, QString, Type);
- void connectNotify(const QMetaMethod& aSignal);
+ BooksStorage(const QString, const QString, const QString, Type);
+ void connectNotify(const QMetaMethod&) Q_DECL_OVERRIDE;
private:
class Private;
@@ -106,13 +106,13 @@
int count() const;
QList<BooksStorage> storageList() const;
BooksStorage internalStorage() const;
- BooksStorage storageForDevice(QString aDevice) const;
- BooksStorage storageForPath(QString aPath, QString* aRelPath = NULL) const;
+ BooksStorage storageForDevice(const QString) const;
+ BooksStorage storageForPath(const QString, QString* aRelPath = NULL) const;
Q_SIGNALS:
- void storageAdded(BooksStorage aStorage);
- void storageRemoved(BooksStorage aStorage);
- void storageReplaced(BooksStorage aOldStorage, BooksStorage aNewStorage);
+ void storageAdded(BooksStorage);
+ void storageRemoved(BooksStorage);
+ void storageReplaced(BooksStorage, BooksStorage);
private:
BooksStorageManager();
|
[-]
[+]
|
Changed |
_service:tar_git:openrepos-books-1.1.0.tar.gz/app/src/BooksTextView.h
^
|
@@ -1,6 +1,6 @@
/*
- * Copyright (C) 2015-2020 Jolla Ltd.
- * Copyright (C) 2015-2020 Slava Monich <slava.monich@jolla.com>
+ * Copyright (C) 2015-2021 Jolla Ltd.
+ * Copyright (C) 2015-2021 Slava Monich <slava.monich@jolla.com>
*
* You may use this file under the terms of the BSD license as follows:
*
@@ -57,7 +57,6 @@
void startSelection(int aX, int aY);
bool extendSelection(int aX, int aY);
void endSelection();
- void setInvertColors(bool aInvertColors);
void gotoPosition(const BooksPos& aPos);
bool nextPage();
void paint();
@@ -88,7 +87,5 @@
inline BooksPos BooksTextView::position() const
{ return BooksPos(textArea().startCursor()); }
-inline void BooksTextView::setInvertColors(bool aInvertColors)
- { iPaintContext.setInvertColors(aInvertColors); }
#endif // BOOKS_TEXT_VIEW_H
|
[-]
[+]
|
Changed |
_service:tar_git:openrepos-books-1.1.0.tar.gz/app/src/BooksTypes.h
^
|
@@ -1,6 +1,6 @@
/*
- * Copyright (C) 2015 Jolla Ltd.
- * Contact: Slava Monich <slava.monich@jolla.com>
+ * Copyright (C) 2015-2022 Jolla Ltd.
+ * Copyright (C) 2015-2022 Slava Monich <slava.monich@jolla.com>
*
* You may use this file under the terms of the BSD license as follows:
*
@@ -8,15 +8,15 @@
* 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 Nemo Mobile nor the names of its contributors
- * may be used to endorse or promote products derived from this
- * software without specific prior written permission.
+ * 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
+ * distribution.
+ * 3. Neither the names of the copyright holders 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
@@ -34,7 +34,6 @@
#ifndef BOOKS_TYPES_H
#define BOOKS_TYPES_H
-#include "shared_ptr.h"
#include <QFile>
class BooksBook;
|
[-]
[+]
|
Changed |
_service:tar_git:openrepos-books-1.1.0.tar.gz/app/src/BooksUtil.cpp
^
|
@@ -1,6 +1,6 @@
/*
- * Copyright (C) 2015-2018 Jolla Ltd.
- * Copyright (C) 2015-2018 Slava Monich <slava.monich@jolla.com>
+ * Copyright (C) 2015-2022 Jolla Ltd.
+ * Copyright (C) 2015-2022 Slava Monich <slava.monich@jolla.com>
*
* You may use this file under the terms of the BSD license as follows:
*
@@ -8,15 +8,15 @@
* 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.
+ * 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
+ * distribution.
+ * 3. Neither the names of the copyright holders 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
@@ -34,6 +34,7 @@
#include "BooksUtil.h"
#include "BooksDefs.h"
+#include "HarbourBase45.h"
#include "HarbourDebug.h"
#include "HarbourTask.h"
@@ -52,7 +53,49 @@
#define DIGEST_TYPE (QCryptographicHash::Md5)
#define DIGEST_SIZE (16)
-shared_ptr<Book> BooksUtil::bookFromFile(std::string aPath)
+// import Sailfish.Media 1.0; MediaKey{}
+#define MEDIA_KEY_BASE45 \
+ "YEDS9E5LE+347ECUVD+EDU7DDZ9AVCOCCZ96H46DZ9AVCMDCC$CNRF"
+
+// import org.nemomobile.policy 1.0;Permissions{
+// autoRelease:true;applicationClass:"camera";
+// Resource{type:Resource.ScaleButton;optional:true}}
+#define PERMISSIONS_BASE45 \
+ "YEDS9E5LEN44$KE6*50$C+3ET3EXEDRZCS9EXVD+PC634Y$5JM75$CJ$DZQE EDF/" \
+ "D+QF8%ED3E: CX CLQEOH76LE+ZCEECP9EOEDIEC EDC.DPVDZQEWF7GPCF$DVKEX" \
+ "E4XIAVQE6%EKPCERF%FF*ZCXIAVQE6%EKPCO%5GPCTVD3I8MWE-3E5N7X9E ED..D" \
+ "VUDKWE%$E+%F"
+
+BooksUtil::BooksUtil(
+ QObject* aParent) :
+ QObject(aParent)
+{
+}
+
+// Callback for qmlRegisterSingletonType<BooksUtil>
+QObject*
+BooksUtil::createSingleton(
+ QQmlEngine*,
+ QJSEngine*)
+{
+ return new BooksUtil();
+}
+
+QString
+BooksUtil::mediaKeyQml()
+{
+ return HarbourBase45::fromBase45(QString::fromLatin1(MEDIA_KEY_BASE45));
+}
+
+QString
+BooksUtil::permissionsQml()
+{
+ return HarbourBase45::fromBase45(QString::fromLatin1(PERMISSIONS_BASE45));
+}
+
+shared_ptr<Book>
+BooksUtil::bookFromFile(
+ const std::string& aPath)
{
shared_ptr<Book> book;
const ZLFile file(aPath);
@@ -91,7 +134,10 @@
return book;
}
-QByteArray BooksUtil::computeFileHash(QString aPath, const HarbourTask* aTask)
+QByteArray
+BooksUtil::computeFileHash(
+ const QString aPath,
+ const HarbourTask* aTask)
{
QByteArray result;
QFile file(aPath);
@@ -110,10 +156,10 @@
ptr += DIGEST_SIZE;
}
} else {
- while (bytesLeft > DIGEST_SIZE) {
- hash.addData(ptr, DIGEST_SIZE);
- bytesLeft -= DIGEST_SIZE;
- ptr += DIGEST_SIZE;
+ while (bytesLeft > (qint64)INT_MAX) {
+ hash.addData(ptr, INT_MAX);
+ bytesLeft -= INT_MAX;
+ ptr += INT_MAX;
}
}
if (!aTask || !aTask->isCanceled()) {
@@ -133,10 +179,12 @@
return result;
}
-QByteArray BooksUtil::fileHashAttr(QString aPath)
+QByteArray
+BooksUtil::fileHashAttr(
+ const QString aPath)
{
QByteArray hash;
- QByteArray fname(aPath.toLocal8Bit());
+ const QByteArray fname(aPath.toLocal8Bit());
char attr[DIGEST_SIZE];
if (getxattr(fname, DIGEST_XATTR, attr, sizeof(attr)) == DIGEST_SIZE) {
hash = QByteArray(attr, sizeof(attr));
@@ -145,7 +193,10 @@
return hash;
}
-bool BooksUtil::setFileHashAttr(QString aPath, QByteArray aHash)
+bool
+BooksUtil::setFileHashAttr(
+ const QString aPath,
+ const QByteArray aHash)
{
if (aHash.size() == DIGEST_SIZE) {
QByteArray fname(aPath.toLocal8Bit());
@@ -158,7 +209,10 @@
return false;
}
-QByteArray BooksUtil::computeFileHashAndSetAttr(QString aPath, const HarbourTask* aTask)
+QByteArray
+BooksUtil::computeFileHashAndSetAttr(
+ const QString aPath,
+ const HarbourTask* aTask)
{
QByteArray hash = computeFileHash(aPath, aTask);
if (!hash.isEmpty()) {
@@ -167,7 +221,9 @@
return hash;
}
-bool BooksUtil::isValidFileName(QString aName)
+bool
+BooksUtil::isValidFileName(
+ const QString aName)
{
return !aName.isEmpty() &&
aName != QStringLiteral(".") &&
|
[-]
[+]
|
Changed |
_service:tar_git:openrepos-books-1.1.0.tar.gz/app/src/BooksUtil.h
^
|
@@ -1,6 +1,6 @@
/*
- * Copyright (C) 2015-2018 Jolla Ltd.
- * Copyright (C) 2015-2018 Slava Monich <slava.monich@jolla.com>
+ * Copyright (C) 2015-2022 Jolla Ltd.
+ * Copyright (C) 2015-2022 Slava Monich <slava.monich@jolla.com>
*
* You may use this file under the terms of the BSD license as follows:
*
@@ -8,15 +8,15 @@
* 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.
+ * 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
+ * distribution.
+ * 3. Neither the names of the copyright holders 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
@@ -38,21 +38,49 @@
#include "library/Book.h"
+#include <QByteArray>
#include <QString>
+#include <QObject>
class HarbourTask;
+class QQmlEngine;
+class QJSEngine;
-namespace BooksUtil {
- shared_ptr<Book> bookFromFile(std::string aPath);
- shared_ptr<Book> bookFromFile(QString aPath);
- bool isValidFileName(QString aName);
- QByteArray fileHashAttr(QString aPath);
- bool setFileHashAttr(QString aPath, QByteArray aHash);
- QByteArray computeFileHash(QString aPath, const HarbourTask* aTask = NULL);
- QByteArray computeFileHashAndSetAttr(QString aPath, const HarbourTask* aTask = NULL);
-}
-
-inline shared_ptr<Book> BooksUtil::bookFromFile(QString aPath)
- { return BooksUtil::bookFromFile(aPath.toStdString()); }
+class BooksUtil : public QObject
+{
+ Q_OBJECT
+ Q_DISABLE_COPY(BooksUtil)
+ Q_PROPERTY(QString mediaKeyQml READ mediaKeyQml CONSTANT)
+ Q_PROPERTY(QString permissionsQml READ permissionsQml CONSTANT)
+ Q_PROPERTY(qreal opacityFaint READ opacityFaint CONSTANT)
+ Q_PROPERTY(qreal opacityLow READ opacityLow CONSTANT)
+ Q_PROPERTY(qreal opacityHigh READ opacityHigh CONSTANT)
+ Q_PROPERTY(qreal opacityOverlay READ opacityOverlay CONSTANT)
+ class Private;
+
+public:
+ explicit BooksUtil(QObject* aParent = Q_NULLPTR);
+
+ // Callback for qmlRegisterSingletonType<BooksUtil>
+ static QObject* createSingleton(QQmlEngine*, QJSEngine*);
+
+ // Getters
+ static QString mediaKeyQml();
+ static QString permissionsQml();
+ static qreal opacityFaint() { return 0.2; }
+ static qreal opacityLow() { return 0.4; }
+ static qreal opacityHigh() { return 0.6; }
+ static qreal opacityOverlay() { return 0.8; }
+
+ // Static utilities
+ static shared_ptr<Book> bookFromFile(const std::string&);
+ static shared_ptr<Book> bookFromFile(const QString aPath)
+ { return BooksUtil::bookFromFile(aPath.toStdString()); }
+ static bool isValidFileName(const QString);
+ static QByteArray fileHashAttr(const QString);
+ static bool setFileHashAttr(const QString, const QByteArray);
+ static QByteArray computeFileHash(const QString, const HarbourTask* aTask = NULL);
+ static QByteArray computeFileHashAndSetAttr(const QString, const HarbourTask* aTask = NULL);
+};
#endif // BOOKS_UTIL_H
|
[-]
[+]
|
Changed |
_service:tar_git:openrepos-books-1.1.0.tar.gz/app/src/ZLibrary.cpp
^
|
@@ -98,12 +98,6 @@
}
}
-ZLPaintContext* ZLibrary::createContext()
-{
- HDEBUG("creating context");
- return new BooksPaintContext();
-}
-
bool ZLibrary::init(int& aArgc, char** &aArgv)
{
HDEBUG("initializing");
|
[-]
[+]
|
Changed |
_service:tar_git:openrepos-books-1.1.0.tar.gz/app/src/main.cpp
^
|
@@ -1,6 +1,6 @@
/*
- * Copyright (C) 2015-2021 Jolla Ltd.
- * Copyright (C) 2015-2021 Slava Monich <slava.monich@jolla.com>
+ * Copyright (C) 2015-2022 Jolla Ltd.
+ * Copyright (C) 2015-2022 Slava Monich <slava.monich@jolla.com>
*
* You may use this file under the terms of the BSD license as follows:
*
@@ -36,6 +36,8 @@
#include "BooksShelf.h"
#include "BooksBook.h"
#include "BooksBookModel.h"
+#include "BooksColorScheme.h"
+#include "BooksColorSchemeModel.h"
#include "BooksCoverModel.h"
#include "BooksConfig.h"
#include "BooksImageProvider.h"
@@ -48,12 +50,12 @@
#include "BooksCoverWidget.h"
#include "BooksTaskQueue.h"
#include "BooksHints.h"
+#include "BooksUtil.h"
+#include "HarbourColorEditorModel.h"
#include "HarbourDisplayBlanking.h"
#include "HarbourDebug.h"
-#include "HarbourMediaPlugin.h"
-#include "HarbourPolicyPlugin.h"
-#include "HarbourTheme.h"
+#include "HarbourUtil.h"
#include "ZLibrary.h"
#include "ZLLanguageUtil.h"
@@ -81,22 +83,31 @@
Q_DECL_EXPORT int main(int argc, char **argv)
{
QGuiApplication* app = SailfishApp::application(argc, argv);
+
qRegisterMetaType<BooksPos>();
- BOOKS_QML_REGISTER(BooksShelf, "Shelf");
- BOOKS_QML_REGISTER(BooksBook, "Book");
- BOOKS_QML_REGISTER(BooksBookModel, "BookModel");
- BOOKS_QML_REGISTER(BooksCoverModel, "CoverModel");
- BOOKS_QML_REGISTER(BooksImportModel, "BooksImportModel");
- BOOKS_QML_REGISTER(BooksPathModel, "BooksPathModel");
- BOOKS_QML_REGISTER(BooksPageStack, "BooksPageStack");
- BOOKS_QML_REGISTER(BooksStorageModel, "BookStorage");
- BOOKS_QML_REGISTER(BooksPageWidget, "PageWidget");
- BOOKS_QML_REGISTER(BooksListWatcher, "ListWatcher");
- BOOKS_QML_REGISTER(BooksCoverWidget, "BookCover");
- BOOKS_QML_REGISTER(BooksSettings, "BooksSettings");
- BOOKS_QML_REGISTER(HarbourDisplayBlanking, "DisplayBlanking");
- BOOKS_QML_REGISTER_SINGLETON(HarbourTheme, "HarbourTheme");
- BOOKS_QML_REGISTER_SINGLETON(BooksHints, "BooksHints");
+ qRegisterMetaType<BooksColorScheme>();
+
+ // For historical reasons these QML and C++ names don't match:
+ BOOKS_QML_REGISTER_(BooksShelf, "Shelf");
+ BOOKS_QML_REGISTER_(BooksBook, "Book");
+ BOOKS_QML_REGISTER_(BooksBookModel, "BookModel");
+ BOOKS_QML_REGISTER_(BooksCoverModel, "CoverModel");
+ BOOKS_QML_REGISTER_(BooksStorageModel, "BookStorage");
+ BOOKS_QML_REGISTER_(BooksPageWidget, "PageWidget");
+ BOOKS_QML_REGISTER_(BooksListWatcher, "ListWatcher");
+ BOOKS_QML_REGISTER_(BooksCoverWidget, "BookCover");
+ BOOKS_QML_REGISTER_(HarbourDisplayBlanking, "DisplayBlanking");
+
+ // But these do (and I think it's a good idea)
+ BOOKS_QML_REGISTER(HarbourColorEditorModel);
+ BOOKS_QML_REGISTER(BooksColorSchemeModel);
+ BOOKS_QML_REGISTER(BooksImportModel);
+ BOOKS_QML_REGISTER(BooksPathModel);
+ BOOKS_QML_REGISTER(BooksPageStack);
+ BOOKS_QML_REGISTER_SINGLETON(HarbourUtil);
+ BOOKS_QML_REGISTER_SINGLETON(BooksHints);
+ BOOKS_QML_REGISTER_SINGLETON(BooksUtil);
+ BOOKS_QML_REGISTER_UNCREATABLE(BooksSettings);
QLocale locale;
QTranslator* translator = new QTranslator(app);
@@ -128,10 +139,6 @@
QQmlContext* root = view->rootContext();
QQmlEngine* engine = root->engine();
QSharedPointer<BooksSettings> settings = BooksSettings::sharedInstance();
- HarbourPolicyPlugin::registerTypes(engine, BOOKS_QML_PLUGIN,
- BOOKS_QML_PLUGIN_V1, BOOKS_QML_PLUGIN_V2);
- HarbourMediaPlugin::registerTypes(engine, BOOKS_QML_PLUGIN,
- BOOKS_QML_PLUGIN_V1, BOOKS_QML_PLUGIN_V2);
engine->addImageProvider(BooksImageProvider::PROVIDER_ID,
new BooksImageProvider(root));
|
[-]
[+]
|
Changed |
_service:tar_git:openrepos-books-1.1.0.tar.gz/app/translations/harbour-books-de.ts
^
|
@@ -294,6 +294,21 @@
<extracomment>Text switch description</extracomment>
<translation type="unfinished">Ohne Schiebemenü muss das Buch durch Hochstreichen geschlossen werden.</translation>
</message>
+ <message id="harbour-books-settings-page-colors-section_header">
+ <source>Colors</source>
+ <extracomment>Section header for colors</extracomment>
+ <translation type="unfinished">Farben</translation>
+ </message>
+ <message id="harbour-books-settings-page-standard_colors">
+ <source>Use standard colors</source>
+ <extracomment>Text switch label</extracomment>
+ <translation type="unfinished">Verwende Standardfarben</translation>
+ </message>
+ <message id="harbour-books-settings-page-standard_colors-description">
+ <source>Note that colors hardcoded in the book override the color scheme.</source>
+ <extracomment>Text switch description</extracomment>
+ <translation type="unfinished">Beachte, dass die vom Buch definierten Farben die Standardfarben überschreiben.</translation>
+ </message>
<message id="harbour-books-settings-page-removable-section_header">
<source>Memory card</source>
<extracomment>Section header for memory card settings</extracomment>
@@ -307,7 +322,67 @@
<message id="harbour-books-settings-page-removable_root-description">
<source>Leave the folder name empty to scan the entire memory card for books.</source>
<extracomment>Settings field description</extracomment>
- <translation type="unfinished">Lassen Sie den Verzeichnisnamen leer, um die gesamte Speicherkarte für Bücher zu scannen.</translation>
+ <translation type="unfinished">Lasse das Feld Verzeichnisname leer, um die gesamte Speicherkarte für Bücher zu scannen.</translation>
+ </message>
+ <message id="harbour-books-color-page_background">
+ <source>Page background</source>
+ <extracomment>List item label (description of a color scheme element)</extracomment>
+ <translation type="unfinished">Seitenhintergrund</translation>
+ </message>
+ <message id="harbour-books-color-text">
+ <source>Regular text</source>
+ <extracomment>List item label (description of a color scheme element)</extracomment>
+ <translation type="unfinished">Normaler Text</translation>
+ </message>
+ <message id="harbour-books-color-selection_background">
+ <source>Selection background</source>
+ <extracomment>List item label (description of a color scheme element)</extracomment>
+ <translation type="unfinished">Auswahlhintergrund</translation>
+ </message>
+ <message id="harbour-books-color-highlighted_text">
+ <source>Highlighted text</source>
+ <extracomment>List item label (description of a color scheme element)</extracomment>
+ <translation type="unfinished">Hervorgehobener Text</translation>
+ </message>
+ <message id="harbour-books-color-internal_hyperlink">
+ <source>Internal hyperlink</source>
+ <extracomment>List item label (description of a color scheme element)</extracomment>
+ <translation type="unfinished">Interner Link</translation>
+ </message>
+ <message id="harbour-books-color-external_hyperlink">
+ <source>External hyperlink</source>
+ <extracomment>List item label (description of a color scheme element)</extracomment>
+ <translation type="unfinished">Externer Link</translation>
+ </message>
+ <message id="harbour-books-color_picker-menu-reset_colors">
+ <source>Reset colors</source>
+ <extracomment>Pulley menu item</extracomment>
+ <translation type="unfinished">Farben zurücksetzen</translation>
+ </message>
+ <message id="harbour-books-color_picker-action-select_color">
+ <source>Select color</source>
+ <extracomment>Dialog title label</extracomment>
+ <translation type="unfinished">Wähle Farbe</translation>
+ </message>
+ <message id="harbour-books-color_picker-action-add_color">
+ <source>Add color</source>
+ <extracomment>Dialog title label</extracomment>
+ <translation type="unfinished">Füge Farbe</translation>
+ </message>
+ <message id="harbour-books-color_picker-slider-hue">
+ <source>Color</source>
+ <extracomment>Hue slider label</extracomment>
+ <translation type="unfinished">Farbe</translation>
+ </message>
+ <message id="harbour-books-color_picker-slider-brightness">
+ <source>Brightness</source>
+ <extracomment>Brightness slider label</extracomment>
+ <translation type="unfinished">Helligkeit</translation>
+ </message>
+ <message id="harbour-books-color_picker-text-hex_notation">
+ <source>Hex notation</source>
+ <extracomment>Text field description</extracomment>
+ <translation type="unfinished">Hex-Notation</translation>
</message>
</context>
</TS>
|
[-]
[+]
|
Changed |
_service:tar_git:openrepos-books-1.1.0.tar.gz/app/translations/harbour-books-es.ts
^
|
@@ -294,6 +294,21 @@
<extracomment>Text switch description</extracomment>
<translation type="unfinished">Sin menú actualizable, el libro debe cerrarse deslizándose hacia arriba.</translation>
</message>
+ <message id="harbour-books-settings-page-colors-section_header">
+ <source>Colors</source>
+ <extracomment>Section header for colors</extracomment>
+ <translation type="unfinished">Colores</translation>
+ </message>
+ <message id="harbour-books-settings-page-standard_colors">
+ <source>Use standard colors</source>
+ <extracomment>Text switch label</extracomment>
+ <translation type="unfinished">Usa colores estándar</translation>
+ </message>
+ <message id="harbour-books-settings-page-standard_colors-description">
+ <source>Note that colors hardcoded in the book override the color scheme.</source>
+ <extracomment>Text switch description</extracomment>
+ <translation type="unfinished">Tenga en cuenta que los colores definidos por el libro prevalecen sobre los colores estándar.</translation>
+ </message>
<message id="harbour-books-settings-page-removable-section_header">
<source>Memory card</source>
<extracomment>Section header for memory card settings</extracomment>
@@ -309,5 +324,65 @@
<extracomment>Settings field description</extracomment>
<translation>Salir del nombre de la carpeta vacía para escanear la tarjeta de memoria entera en busca de libros.</translation>
</message>
+ <message id="harbour-books-color-page_background">
+ <source>Page background</source>
+ <extracomment>List item label (description of a color scheme element)</extracomment>
+ <translation type="unfinished">Fondo de la página</translation>
+ </message>
+ <message id="harbour-books-color-text">
+ <source>Regular text</source>
+ <extracomment>List item label (description of a color scheme element)</extracomment>
+ <translation type="unfinished">Texto normal</translation>
+ </message>
+ <message id="harbour-books-color-selection_background">
+ <source>Selection background</source>
+ <extracomment>List item label (description of a color scheme element)</extracomment>
+ <translation type="unfinished">Fondo de selección</translation>
+ </message>
+ <message id="harbour-books-color-highlighted_text">
+ <source>Highlighted text</source>
+ <extracomment>List item label (description of a color scheme element)</extracomment>
+ <translation type="unfinished">Texto resaltado</translation>
+ </message>
+ <message id="harbour-books-color-internal_hyperlink">
+ <source>Internal hyperlink</source>
+ <extracomment>List item label (description of a color scheme element)</extracomment>
+ <translation type="unfinished">Enlace interno</translation>
+ </message>
+ <message id="harbour-books-color-external_hyperlink">
+ <source>External hyperlink</source>
+ <extracomment>List item label (description of a color scheme element)</extracomment>
+ <translation type="unfinished">Enlace externo</translation>
+ </message>
+ <message id="harbour-books-color_picker-menu-reset_colors">
+ <source>Reset colors</source>
+ <extracomment>Pulley menu item</extracomment>
+ <translation type="unfinished">Restaurar colores</translation>
+ </message>
+ <message id="harbour-books-color_picker-action-select_color">
+ <source>Select color</source>
+ <extracomment>Dialog title label</extracomment>
+ <translation type="unfinished">Seleccionar el color</translation>
+ </message>
+ <message id="harbour-books-color_picker-action-add_color">
+ <source>Add color</source>
+ <extracomment>Dialog title label</extracomment>
+ <translation type="unfinished">Añadir color</translation>
+ </message>
+ <message id="harbour-books-color_picker-slider-hue">
+ <source>Color</source>
+ <extracomment>Hue slider label</extracomment>
+ <translation type="unfinished">Color</translation>
+ </message>
+ <message id="harbour-books-color_picker-slider-brightness">
+ <source>Brightness</source>
+ <extracomment>Brightness slider label</extracomment>
+ <translation type="unfinished">Luminosidad</translation>
+ </message>
+ <message id="harbour-books-color_picker-text-hex_notation">
+ <source>Hex notation</source>
+ <extracomment>Text field description</extracomment>
+ <translation type="unfinished">Hexadecimal</translation>
+ </message>
</context>
</TS>
|
[-]
[+]
|
Changed |
_service:tar_git:openrepos-books-1.1.0.tar.gz/app/translations/harbour-books-fi.ts
^
|
@@ -282,7 +282,7 @@
<message id="harbour-books-settings-page-turn_pages_by_tap-description">
<source>Tapping near the left edge of the screen returns to the previous page, tapping near the right edge gets you to the next page.</source>
<extracomment>Text switch description</extracomment>
- <translation type="unfinished"></translation>
+ <translation type="unfinished">Napauttamalla lähellä näytön vasenta reunaa palaat edelliselle sivulle, napauttamalla lähellä oikeaa reunaa siirryt seuraavalle sivulle.</translation>
</message>
<message id="harbour-books-settings-page-book_pulldown_menu">
<source>Show pulley menu when the book is open</source>
@@ -294,6 +294,21 @@
<extracomment>Text switch description</extracomment>
<translation type="unfinished">Ilman vetovalikkoa kirja on suljettava pyyhkäisemällä sitä ylös.</translation>
</message>
+ <message id="harbour-books-settings-page-colors-section_header">
+ <source>Colors</source>
+ <extracomment>Section header for colors</extracomment>
+ <translation type="unfinished">Värit</translation>
+ </message>
+ <message id="harbour-books-settings-page-standard_colors">
+ <source>Use standard colors</source>
+ <extracomment>Text switch label</extracomment>
+ <translation type="unfinished">Käytä vakiovärejä</translation>
+ </message>
+ <message id="harbour-books-settings-page-standard_colors-description">
+ <source>Note that colors hardcoded in the book override the color scheme.</source>
+ <extracomment>Text switch description</extracomment>
+ <translation type="unfinished">Pitää mielessä, että kirjassa määritellyt värit syrjäyttävät vakiovärit.</translation>
+ </message>
<message id="harbour-books-settings-page-removable-section_header">
<source>Memory card</source>
<extracomment>Section header for memory card settings</extracomment>
@@ -309,5 +324,65 @@
<extracomment>Settings field description</extracomment>
<translation type="unfinished">Jätä kenttä tyhjäksi käyttää kokonaista muistikorttia.</translation>
</message>
+ <message id="harbour-books-color-page_background">
+ <source>Page background</source>
+ <extracomment>List item label (description of a color scheme element)</extracomment>
+ <translation type="unfinished">Sivun tausta</translation>
+ </message>
+ <message id="harbour-books-color-text">
+ <source>Regular text</source>
+ <extracomment>List item label (description of a color scheme element)</extracomment>
+ <translation type="unfinished">Tavallinen teksti</translation>
+ </message>
+ <message id="harbour-books-color-selection_background">
+ <source>Selection background</source>
+ <extracomment>List item label (description of a color scheme element)</extracomment>
+ <translation type="unfinished">Valinta tausta</translation>
+ </message>
+ <message id="harbour-books-color-highlighted_text">
+ <source>Highlighted text</source>
+ <extracomment>List item label (description of a color scheme element)</extracomment>
+ <translation type="unfinished">Korostettu teksti</translation>
+ </message>
+ <message id="harbour-books-color-internal_hyperlink">
+ <source>Internal hyperlink</source>
+ <extracomment>List item label (description of a color scheme element)</extracomment>
+ <translation type="unfinished">Sisäinen linkki</translation>
+ </message>
+ <message id="harbour-books-color-external_hyperlink">
+ <source>External hyperlink</source>
+ <extracomment>List item label (description of a color scheme element)</extracomment>
+ <translation type="unfinished">Ulkoinen linkki</translation>
+ </message>
+ <message id="harbour-books-color_picker-menu-reset_colors">
+ <source>Reset colors</source>
+ <extracomment>Pulley menu item</extracomment>
+ <translation type="unfinished">Palauttaa värit alkutilaan</translation>
+ </message>
+ <message id="harbour-books-color_picker-action-select_color">
+ <source>Select color</source>
+ <extracomment>Dialog title label</extracomment>
+ <translation type="unfinished">Valitse väri</translation>
+ </message>
+ <message id="harbour-books-color_picker-action-add_color">
+ <source>Add color</source>
+ <extracomment>Dialog title label</extracomment>
+ <translation type="unfinished">Lisää väri</translation>
+ </message>
+ <message id="harbour-books-color_picker-slider-hue">
+ <source>Color</source>
+ <extracomment>Hue slider label</extracomment>
+ <translation type="unfinished">Väri</translation>
+ </message>
+ <message id="harbour-books-color_picker-slider-brightness">
+ <source>Brightness</source>
+ <extracomment>Brightness slider label</extracomment>
+ <translation type="unfinished">Kirkkaus</translation>
+ </message>
+ <message id="harbour-books-color_picker-text-hex_notation">
+ <source>Hex notation</source>
+ <extracomment>Text field description</extracomment>
+ <translation type="unfinished">Hex-merkintä</translation>
+ </message>
</context>
</TS>
|
[-]
[+]
|
Changed |
_service:tar_git:openrepos-books-1.1.0.tar.gz/app/translations/harbour-books-hu.ts
^
|
@@ -292,6 +292,21 @@
<extracomment>Text switch description</extracomment>
<translation type="unfinished">Lehúzható menü nélkül a könyvet felfelé húzással kell bezárni.</translation>
</message>
+ <message id="harbour-books-settings-page-colors-section_header">
+ <source>Colors</source>
+ <extracomment>Section header for colors</extracomment>
+ <translation type="unfinished">Színek</translation>
+ </message>
+ <message id="harbour-books-settings-page-standard_colors">
+ <source>Use standard colors</source>
+ <extracomment>Text switch label</extracomment>
+ <translation type="unfinished">Használjon szabványos színeket</translation>
+ </message>
+ <message id="harbour-books-settings-page-standard_colors-description">
+ <source>Note that colors hardcoded in the book override the color scheme.</source>
+ <extracomment>Text switch description</extracomment>
+ <translation type="unfinished">Vegye figyelembe, hogy a könyv által meghatározott színek felülírják a szabványos színeket.</translation>
+ </message>
<message id="harbour-books-settings-page-removable-section_header">
<source>Memory card</source>
<extracomment>Section header for memory card settings</extracomment>
@@ -307,5 +322,65 @@
<extracomment>Settings field description</extracomment>
<translation>Hagyd üresen a mappanevet a teljes memóriakártya könyvek utáni pásztázásához.</translation>
</message>
+ <message id="harbour-books-color-page_background">
+ <source>Page background</source>
+ <extracomment>List item label (description of a color scheme element)</extracomment>
+ <translation type="unfinished">Oldal háttere</translation>
+ </message>
+ <message id="harbour-books-color-text">
+ <source>Regular text</source>
+ <extracomment>List item label (description of a color scheme element)</extracomment>
+ <translation type="unfinished">Normál szöveg</translation>
+ </message>
+ <message id="harbour-books-color-selection_background">
+ <source>Selection background</source>
+ <extracomment>List item label (description of a color scheme element)</extracomment>
+ <translation type="unfinished">Kiválasztás háttér</translation>
+ </message>
+ <message id="harbour-books-color-highlighted_text">
+ <source>Highlighted text</source>
+ <extracomment>List item label (description of a color scheme element)</extracomment>
+ <translation type="unfinished">Kiemelt szöveg</translation>
+ </message>
+ <message id="harbour-books-color-internal_hyperlink">
+ <source>Internal hyperlink</source>
+ <extracomment>List item label (description of a color scheme element)</extracomment>
+ <translation type="unfinished">Belső hivatkozás</translation>
+ </message>
+ <message id="harbour-books-color-external_hyperlink">
+ <source>External hyperlink</source>
+ <extracomment>List item label (description of a color scheme element)</extracomment>
+ <translation type="unfinished">Külső hivatkozás</translation>
+ </message>
+ <message id="harbour-books-color_picker-menu-reset_colors">
+ <source>Reset colors</source>
+ <extracomment>Pulley menu item</extracomment>
+ <translation type="unfinished">Állítsa vissza a színeket</translation>
+ </message>
+ <message id="harbour-books-color_picker-action-select_color">
+ <source>Select color</source>
+ <extracomment>Dialog title label</extracomment>
+ <translation type="unfinished">Válasszon színt</translation>
+ </message>
+ <message id="harbour-books-color_picker-action-add_color">
+ <source>Add color</source>
+ <extracomment>Dialog title label</extracomment>
+ <translation type="unfinished">Add színt</translation>
+ </message>
+ <message id="harbour-books-color_picker-slider-hue">
+ <source>Color</source>
+ <extracomment>Hue slider label</extracomment>
+ <translation type="unfinished">Szín</translation>
+ </message>
+ <message id="harbour-books-color_picker-slider-brightness">
+ <source>Brightness</source>
+ <extracomment>Brightness slider label</extracomment>
+ <translation type="unfinished">Fényerősség</translation>
+ </message>
+ <message id="harbour-books-color_picker-text-hex_notation">
+ <source>Hex notation</source>
+ <extracomment>Text field description</extracomment>
+ <translation type="unfinished">Hex jelölés</translation>
+ </message>
</context>
</TS>
|
[-]
[+]
|
Changed |
_service:tar_git:openrepos-books-1.1.0.tar.gz/app/translations/harbour-books-nl.ts
^
|
@@ -294,6 +294,21 @@
<extracomment>Text switch description</extracomment>
<translation type="unfinished">Zonder uittrekmenu moet het boek worden gesloten door het omhoog te vegen.</translation>
</message>
+ <message id="harbour-books-settings-page-colors-section_header">
+ <source>Colors</source>
+ <extracomment>Section header for colors</extracomment>
+ <translation type="unfinished">Kleuren</translation>
+ </message>
+ <message id="harbour-books-settings-page-standard_colors">
+ <source>Use standard colors</source>
+ <extracomment>Text switch label</extracomment>
+ <translation type="unfinished">Gebruik standaard kleuren</translation>
+ </message>
+ <message id="harbour-books-settings-page-standard_colors-description">
+ <source>Note that colors hardcoded in the book override the color scheme.</source>
+ <extracomment>Text switch description</extracomment>
+ <translation type="unfinished">Houd er rekening mee dat kleuren die door het boek worden gedefinieerd, de standaardkleuren overschrijven.</translation>
+ </message>
<message id="harbour-books-settings-page-removable-section_header">
<source>Memory card</source>
<extracomment>Section header for memory card settings</extracomment>
@@ -309,5 +324,65 @@
<extracomment>Settings field description</extracomment>
<translation>Laat de mapnaam leeg om op de volledige geheugenkaart te zoeken naar boeken.</translation>
</message>
+ <message id="harbour-books-color-page_background">
+ <source>Page background</source>
+ <extracomment>List item label (description of a color scheme element)</extracomment>
+ <translation type="unfinished">Pagina achtergrond</translation>
+ </message>
+ <message id="harbour-books-color-text">
+ <source>Regular text</source>
+ <extracomment>List item label (description of a color scheme element)</extracomment>
+ <translation type="unfinished">Gewone tekst</translation>
+ </message>
+ <message id="harbour-books-color-selection_background">
+ <source>Selection background</source>
+ <extracomment>List item label (description of a color scheme element)</extracomment>
+ <translation type="unfinished">Selectie achtergrond</translation>
+ </message>
+ <message id="harbour-books-color-highlighted_text">
+ <source>Highlighted text</source>
+ <extracomment>List item label (description of a color scheme element)</extracomment>
+ <translation type="unfinished">Gemarkeerde tekst</translation>
+ </message>
+ <message id="harbour-books-color-internal_hyperlink">
+ <source>Internal hyperlink</source>
+ <extracomment>List item label (description of a color scheme element)</extracomment>
+ <translation type="unfinished">Interne link</translation>
+ </message>
+ <message id="harbour-books-color-external_hyperlink">
+ <source>External hyperlink</source>
+ <extracomment>List item label (description of a color scheme element)</extracomment>
+ <translation type="unfinished">Externe link</translation>
+ </message>
+ <message id="harbour-books-color_picker-menu-reset_colors">
+ <source>Reset colors</source>
+ <extracomment>Pulley menu item</extracomment>
+ <translation type="unfinished">Kleuren resetten</translation>
+ </message>
+ <message id="harbour-books-color_picker-action-select_color">
+ <source>Select color</source>
+ <extracomment>Dialog title label</extracomment>
+ <translation type="unfinished">Selecteer kleur</translation>
+ </message>
+ <message id="harbour-books-color_picker-action-add_color">
+ <source>Add color</source>
+ <extracomment>Dialog title label</extracomment>
+ <translation type="unfinished">Kleur toevoegen</translation>
+ </message>
+ <message id="harbour-books-color_picker-slider-hue">
+ <source>Color</source>
+ <extracomment>Hue slider label</extracomment>
+ <translation type="unfinished">Kleur</translation>
+ </message>
+ <message id="harbour-books-color_picker-slider-brightness">
+ <source>Brightness</source>
+ <extracomment>Brightness slider label</extracomment>
+ <translation type="unfinished">Lichtsterkte</translation>
+ </message>
+ <message id="harbour-books-color_picker-text-hex_notation">
+ <source>Hex notation</source>
+ <extracomment>Text field description</extracomment>
+ <translation type="unfinished">Hex notatie</translation>
+ </message>
</context>
</TS>
|
[-]
[+]
|
Changed |
_service:tar_git:openrepos-books-1.1.0.tar.gz/app/translations/harbour-books-pl.ts
^
|
@@ -289,12 +289,27 @@
<message id="harbour-books-settings-page-book_pulldown_menu">
<source>Show pulley menu when the book is open</source>
<extracomment>Text switch label</extracomment>
- <translation type="unfinished">Pokaż menu wysuwane, gdy książka jest otwarta</translation>
+ <translation>Pokaż menu wysuwane, gdy książka jest otwarta</translation>
</message>
<message id="harbour-books-settings-page-book_pulldown_menu-description">
<source>Without the pulley menu, the book has to be closed by swiping it up.</source>
<extracomment>Text switch description</extracomment>
- <translation type="unfinished">Aby zamknąć książkę w przypadku braku menu wysuwane, należy ją przesunąć w górę o ponad pół ekranu.</translation>
+ <translation>Aby zamknąć książkę w przypadku braku menu wysuwanego, należy ją przesunąć w górę o ponad pół ekranu.</translation>
+ </message>
+ <message id="harbour-books-settings-page-colors-section_header">
+ <source>Colors</source>
+ <extracomment>Section header for colors</extracomment>
+ <translation type="unfinished">Kolory</translation>
+ </message>
+ <message id="harbour-books-settings-page-standard_colors">
+ <source>Use standard colors</source>
+ <extracomment>Text switch label</extracomment>
+ <translation type="unfinished">Użyj standardowych kolorów</translation>
+ </message>
+ <message id="harbour-books-settings-page-standard_colors-description">
+ <source>Note that colors hardcoded in the book override the color scheme.</source>
+ <extracomment>Text switch description</extracomment>
+ <translation type="unfinished">Należy pamiętać, że niektóre lub nawet wszystkie kolory mogą być określone w samej książce, w którym to przypadku schemat kolorów jest ignorowany.</translation>
</message>
<message id="harbour-books-settings-page-removable-section_header">
<source>Memory card</source>
@@ -311,5 +326,65 @@
<extracomment>Settings field description</extracomment>
<translation>Pozostaw nazwę katalogu pustą, aby skanować całą kartę pamięci w poszukiwaniu książek.</translation>
</message>
+ <message id="harbour-books-color-page_background">
+ <source>Page background</source>
+ <extracomment>List item label (description of a color scheme element)</extracomment>
+ <translation type="unfinished">Tło strony</translation>
+ </message>
+ <message id="harbour-books-color-text">
+ <source>Regular text</source>
+ <extracomment>List item label (description of a color scheme element)</extracomment>
+ <translation type="unfinished">Zwykły tekst</translation>
+ </message>
+ <message id="harbour-books-color-selection_background">
+ <source>Selection background</source>
+ <extracomment>List item label (description of a color scheme element)</extracomment>
+ <translation type="unfinished">Dedykowane tło</translation>
+ </message>
+ <message id="harbour-books-color-highlighted_text">
+ <source>Highlighted text</source>
+ <extracomment>List item label (description of a color scheme element)</extracomment>
+ <translation type="unfinished">Wyróżniony tekst</translation>
+ </message>
+ <message id="harbour-books-color-internal_hyperlink">
+ <source>Internal hyperlink</source>
+ <extracomment>List item label (description of a color scheme element)</extracomment>
+ <translation type="unfinished">Link wewnętrzny</translation>
+ </message>
+ <message id="harbour-books-color-external_hyperlink">
+ <source>External hyperlink</source>
+ <extracomment>List item label (description of a color scheme element)</extracomment>
+ <translation type="unfinished">Link zewnętrzny</translation>
+ </message>
+ <message id="harbour-books-color_picker-menu-reset_colors">
+ <source>Reset colors</source>
+ <extracomment>Pulley menu item</extracomment>
+ <translation>Zresetuj kolory</translation>
+ </message>
+ <message id="harbour-books-color_picker-action-select_color">
+ <source>Select color</source>
+ <extracomment>Dialog title label</extracomment>
+ <translation>Wybierz kolor</translation>
+ </message>
+ <message id="harbour-books-color_picker-action-add_color">
+ <source>Add color</source>
+ <extracomment>Dialog title label</extracomment>
+ <translation>Dodaj kolor</translation>
+ </message>
+ <message id="harbour-books-color_picker-slider-hue">
+ <source>Color</source>
+ <extracomment>Hue slider label</extracomment>
+ <translation>Kolor</translation>
+ </message>
+ <message id="harbour-books-color_picker-slider-brightness">
+ <source>Brightness</source>
+ <extracomment>Brightness slider label</extracomment>
+ <translation>Jasność</translation>
+ </message>
+ <message id="harbour-books-color_picker-text-hex_notation">
+ <source>Hex notation</source>
+ <extracomment>Text field description</extracomment>
+ <translation>Format szesnastkowy</translation>
+ </message>
</context>
</TS>
|
[-]
[+]
|
Changed |
_service:tar_git:openrepos-books-1.1.0.tar.gz/app/translations/harbour-books-pt.ts
^
|
@@ -294,6 +294,21 @@
<extracomment>Text switch description</extracomment>
<translation type="unfinished">Sem o menu deslizante, o livro deve ser fechado deslizando-o para cima.</translation>
</message>
+ <message id="harbour-books-settings-page-colors-section_header">
+ <source>Colors</source>
+ <extracomment>Section header for colors</extracomment>
+ <translation type="unfinished">Cores</translation>
+ </message>
+ <message id="harbour-books-settings-page-standard_colors">
+ <source>Use standard colors</source>
+ <extracomment>Text switch label</extracomment>
+ <translation type="unfinished">Use cores padrão</translation>
+ </message>
+ <message id="harbour-books-settings-page-standard_colors-description">
+ <source>Note that colors hardcoded in the book override the color scheme.</source>
+ <extracomment>Text switch description</extracomment>
+ <translation type="unfinished">Observe que as cores definidas pelo livro substituem as cores padrão.</translation>
+ </message>
<message id="harbour-books-settings-page-removable-section_header">
<source>Memory card</source>
<extracomment>Section header for memory card settings</extracomment>
@@ -309,5 +324,65 @@
<extracomment>Settings field description</extracomment>
<translation>Deixe este campo vazio para escanear todo o cartão de memória.</translation>
</message>
+ <message id="harbour-books-color-page_background">
+ <source>Page background</source>
+ <extracomment>List item label (description of a color scheme element)</extracomment>
+ <translation type="unfinished">Plano de fundo da página</translation>
+ </message>
+ <message id="harbour-books-color-text">
+ <source>Regular text</source>
+ <extracomment>List item label (description of a color scheme element)</extracomment>
+ <translation type="unfinished">Texto normal</translation>
+ </message>
+ <message id="harbour-books-color-selection_background">
+ <source>Selection background</source>
+ <extracomment>List item label (description of a color scheme element)</extracomment>
+ <translation type="unfinished">Plano de fundo da seleção</translation>
+ </message>
+ <message id="harbour-books-color-highlighted_text">
+ <source>Highlighted text</source>
+ <extracomment>List item label (description of a color scheme element)</extracomment>
+ <translation type="unfinished">Texto destacado</translation>
+ </message>
+ <message id="harbour-books-color-internal_hyperlink">
+ <source>Internal hyperlink</source>
+ <extracomment>List item label (description of a color scheme element)</extracomment>
+ <translation type="unfinished">Link interno</translation>
+ </message>
+ <message id="harbour-books-color-external_hyperlink">
+ <source>External hyperlink</source>
+ <extracomment>List item label (description of a color scheme element)</extracomment>
+ <translation type="unfinished">Link externo</translation>
+ </message>
+ <message id="harbour-books-color_picker-menu-reset_colors">
+ <source>Reset colors</source>
+ <extracomment>Pulley menu item</extracomment>
+ <translation type="unfinished">Repor cores</translation>
+ </message>
+ <message id="harbour-books-color_picker-action-select_color">
+ <source>Select color</source>
+ <extracomment>Dialog title label</extracomment>
+ <translation type="unfinished">Selecione a cor</translation>
+ </message>
+ <message id="harbour-books-color_picker-action-add_color">
+ <source>Add color</source>
+ <extracomment>Dialog title label</extracomment>
+ <translation type="unfinished">Adicione cor</translation>
+ </message>
+ <message id="harbour-books-color_picker-slider-hue">
+ <source>Color</source>
+ <extracomment>Hue slider label</extracomment>
+ <translation type="unfinished">Cor</translation>
+ </message>
+ <message id="harbour-books-color_picker-slider-brightness">
+ <source>Brightness</source>
+ <extracomment>Brightness slider label</extracomment>
+ <translation type="unfinished">Luminocidade</translation>
+ </message>
+ <message id="harbour-books-color_picker-text-hex_notation">
+ <source>Hex notation</source>
+ <extracomment>Text field description</extracomment>
+ <translation type="unfinished">Notação hexadecimal</translation>
+ </message>
</context>
</TS>
|
[-]
[+]
|
Changed |
_service:tar_git:openrepos-books-1.1.0.tar.gz/app/translations/harbour-books-ru.ts
^
|
@@ -244,23 +244,13 @@
<message id="harbour-books-settings-page-keep_display_on_description">
<source>Prevent the display from blanking while reading the book.</source>
<extracomment>Text switch description</extracomment>
- <translation>Не гасить экран, пока открыта книга. Это не очень хорошо для батареи, зато удобно для чтения. Главное - не уснуть.</translation>
+ <translation>То есть не гасить экран, пока открыта книга. Это не очень хорошо для батареи, зато удобно для чтения. Главное - не уснуть.</translation>
</message>
<message id="harbour-books-settings-page-navigation-section_header">
<source>Navigation</source>
<extracomment>Section header for media keys</extracomment>
<translation>Навигация</translation>
</message>
- <message id="harbour-books-settings-page-turn_pages_by_tap">
- <source>Turn pages by tapping the screen</source>
- <extracomment>Text switch label</extracomment>
- <translation>Листать страницы касанием экрана</translation>
- </message>
- <message id="harbour-books-settings-page-turn_pages_by_tap-description">
- <source>Tapping near the left edge of the screen returns to the previous page, tapping near the right edge gets you to the next page.</source>
- <extracomment>Text switch description</extracomment>
- <translation>Касание ближе к левому краю экрана вызывает переход на предыдущую страницу, ближе к правому краю - на следующую.</translation>
- </message>
<message id="harbour-books-settings-page-action-none">
<source>No action</source>
<extracomment>Combo box value for no action</extracomment>
@@ -286,10 +276,15 @@
<extracomment>Combo box label</extracomment>
<translation>Громкость вниз</translation>
</message>
- <message id="harbour-books-settings-page-removable-section_header">
- <source>Memory card</source>
- <extracomment>Section header for memory card settings</extracomment>
- <translation>Карта памяти</translation>
+ <message id="harbour-books-settings-page-turn_pages_by_tap">
+ <source>Turn pages by tapping the screen</source>
+ <extracomment>Text switch label</extracomment>
+ <translation>Листать страницы касанием экрана</translation>
+ </message>
+ <message id="harbour-books-settings-page-turn_pages_by_tap-description">
+ <source>Tapping near the left edge of the screen returns to the previous page, tapping near the right edge gets you to the next page.</source>
+ <extracomment>Text switch description</extracomment>
+ <translation>Касание ближе к левому краю экрана вызывает переход на предыдущую страницу, ближе к правому краю - на следующую.</translation>
</message>
<message id="harbour-books-settings-page-book_pulldown_menu">
<source>Show pulley menu when the book is open</source>
@@ -301,6 +296,26 @@
<extracomment>Text switch description</extracomment>
<translation>Чтобы закрыть книгу в отсутствие вытягиваемого меню, её надо будет сдвинуть вверх больше, чем на пол-экрана.</translation>
</message>
+ <message id="harbour-books-settings-page-colors-section_header">
+ <source>Colors</source>
+ <extracomment>Section header for colors</extracomment>
+ <translation>Цвета</translation>
+ </message>
+ <message id="harbour-books-settings-page-standard_colors">
+ <source>Use standard colors</source>
+ <extracomment>Text switch label</extracomment>
+ <translation>Использовать стандартные цвета</translation>
+ </message>
+ <message id="harbour-books-settings-page-standard_colors-description">
+ <source>Note that colors hardcoded in the book override the color scheme.</source>
+ <extracomment>Text switch description</extracomment>
+ <translation>Имейте в виду, что некоторые или даже все цвета могут быть прописаны в самой книге и в этом случае цветовая схема игнорируется.</translation>
+ </message>
+ <message id="harbour-books-settings-page-removable-section_header">
+ <source>Memory card</source>
+ <extracomment>Section header for memory card settings</extracomment>
+ <translation>Карта памяти</translation>
+ </message>
<message id="harbour-books-settings-page-removable_root-label">
<source>Books folder</source>
<extracomment>Settings field label</extracomment>
@@ -311,5 +326,65 @@
<extracomment>Settings field description</extracomment>
<translation>Если оставить имя папки пустым, то можно будет найти книгу в любой папке на карте памяти. Особого смысла в этой настройке нет, просто так исторически сложилось, что по умолчанию книги искались только в папке Books, а теперь можно вообще где угодно.</translation>
</message>
+ <message id="harbour-books-color-page_background">
+ <source>Page background</source>
+ <extracomment>List item label (description of a color scheme element)</extracomment>
+ <translation>Фон страницы</translation>
+ </message>
+ <message id="harbour-books-color-text">
+ <source>Regular text</source>
+ <extracomment>List item label (description of a color scheme element)</extracomment>
+ <translation>Обычный текст</translation>
+ </message>
+ <message id="harbour-books-color-selection_background">
+ <source>Selection background</source>
+ <extracomment>List item label (description of a color scheme element)</extracomment>
+ <translation>Выделенный фон</translation>
+ </message>
+ <message id="harbour-books-color-highlighted_text">
+ <source>Highlighted text</source>
+ <extracomment>List item label (description of a color scheme element)</extracomment>
+ <translation>Выделенный текст</translation>
+ </message>
+ <message id="harbour-books-color-internal_hyperlink">
+ <source>Internal hyperlink</source>
+ <extracomment>List item label (description of a color scheme element)</extracomment>
+ <translation>Внутренняя ссылка</translation>
+ </message>
+ <message id="harbour-books-color-external_hyperlink">
+ <source>External hyperlink</source>
+ <extracomment>List item label (description of a color scheme element)</extracomment>
+ <translation>Внешняя ссылка</translation>
+ </message>
+ <message id="harbour-books-color_picker-menu-reset_colors">
+ <source>Reset colors</source>
+ <extracomment>Pulley menu item</extracomment>
+ <translation>Сбросить цвета</translation>
+ </message>
+ <message id="harbour-books-color_picker-action-select_color">
+ <source>Select color</source>
+ <extracomment>Dialog title label</extracomment>
+ <translation>Выбрать цвет</translation>
+ </message>
+ <message id="harbour-books-color_picker-action-add_color">
+ <source>Add color</source>
+ <extracomment>Dialog title label</extracomment>
+ <translation>Добавить цвет</translation>
+ </message>
+ <message id="harbour-books-color_picker-slider-hue">
+ <source>Color</source>
+ <extracomment>Hue slider label</extracomment>
+ <translation>Цвет</translation>
+ </message>
+ <message id="harbour-books-color_picker-slider-brightness">
+ <source>Brightness</source>
+ <extracomment>Brightness slider label</extracomment>
+ <translation>Яркость</translation>
+ </message>
+ <message id="harbour-books-color_picker-text-hex_notation">
+ <source>Hex notation</source>
+ <extracomment>Text field description</extracomment>
+ <translation>Текстовый формат</translation>
+ </message>
</context>
</TS>
|
[-]
[+]
|
Changed |
_service:tar_git:openrepos-books-1.1.0.tar.gz/app/translations/harbour-books-sv.ts
^
|
@@ -132,7 +132,7 @@
<message id="harbour-books-settings-version">
<source>Version %1</source>
<extracomment>Settings page header description (app version)</extracomment>
- <translation type="unfinished">Version %1</translation>
+ <translation>Version %1</translation>
</message>
<message id="harbour-books-settings-page-display-section_header">
<source>Display</source>
@@ -152,12 +152,12 @@
<message id="harbour-books-settings-page-night_mode_example">
<source>Night mode</source>
<extracomment>Night mode example label</extracomment>
- <translation type="unfinished">Nattläge</translation>
+ <translation>Nattläge</translation>
</message>
<message id="harbour-books-settings-page-night_mode_brightness_label">
<source>Brightness in night mode</source>
<extracomment>Slider label</extracomment>
- <translation type="unfinished">Ljusstyrka i nattläge</translation>
+ <translation>Ljusstyrka i nattläge</translation>
</message>
<message id="harbour-books-settings-page-orientation_label">
<source>Orientation</source>
@@ -237,7 +237,7 @@
<message id="harbour-books-settings-page-keep_display_on">
<source>Keep display on while reading</source>
<extracomment>Text switch label</extracomment>
- <translation>Håll skärmen på vid läsning</translation>
+ <translation>Håll skärmen tänd vid läsning</translation>
</message>
<message id="harbour-books-settings-page-keep_display_on_description">
<source>Prevent the display from blanking while reading the book.</source>
@@ -287,12 +287,27 @@
<message id="harbour-books-settings-page-book_pulldown_menu">
<source>Show pulley menu when the book is open</source>
<extracomment>Text switch label</extracomment>
- <translation type="unfinished">Visa rullgardinsmeny när boken är öppen</translation>
+ <translation>Visa toppmeny när boken är öppen</translation>
</message>
<message id="harbour-books-settings-page-book_pulldown_menu-description">
<source>Without the pulley menu, the book has to be closed by swiping it up.</source>
<extracomment>Text switch description</extracomment>
- <translation type="unfinished">Utan rullgardinsmeny måste boken stängas genom att svepa uppåt.</translation>
+ <translation>Utan toppmeny måste boken stängas genom att svepa uppåt.</translation>
+ </message>
+ <message id="harbour-books-settings-page-colors-section_header">
+ <source>Colors</source>
+ <extracomment>Section header for colors</extracomment>
+ <translation type="unfinished">Färger</translation>
+ </message>
+ <message id="harbour-books-settings-page-standard_colors">
+ <source>Use standard colors</source>
+ <extracomment>Text switch label</extracomment>
+ <translation type="unfinished">Använd standardfärger</translation>
+ </message>
+ <message id="harbour-books-settings-page-standard_colors-description">
+ <source>Note that colors hardcoded in the book override the color scheme.</source>
+ <extracomment>Text switch description</extracomment>
+ <translation type="unfinished">Notera att färger som definieras av boken åsidosätter standardfärgerna.</translation>
</message>
<message id="harbour-books-settings-page-removable-section_header">
<source>Memory card</source>
@@ -309,5 +324,65 @@
<extracomment>Settings field description</extracomment>
<translation>Lämna mappnamnet tomt för att söka igenom hela minneskortet efter böcker.</translation>
</message>
+ <message id="harbour-books-color-page_background">
+ <source>Page background</source>
+ <extracomment>List item label (description of a color scheme element)</extracomment>
+ <translation type="unfinished">Sidans bakgrund</translation>
+ </message>
+ <message id="harbour-books-color-text">
+ <source>Regular text</source>
+ <extracomment>List item label (description of a color scheme element)</extracomment>
+ <translation type="unfinished">Vanlig text</translation>
+ </message>
+ <message id="harbour-books-color-selection_background">
+ <source>Selection background</source>
+ <extracomment>List item label (description of a color scheme element)</extracomment>
+ <translation type="unfinished">Urval bakgrund</translation>
+ </message>
+ <message id="harbour-books-color-highlighted_text">
+ <source>Highlighted text</source>
+ <extracomment>List item label (description of a color scheme element)</extracomment>
+ <translation type="unfinished">Markerad text</translation>
+ </message>
+ <message id="harbour-books-color-internal_hyperlink">
+ <source>Internal hyperlink</source>
+ <extracomment>List item label (description of a color scheme element)</extracomment>
+ <translation type="unfinished">Intern länk</translation>
+ </message>
+ <message id="harbour-books-color-external_hyperlink">
+ <source>External hyperlink</source>
+ <extracomment>List item label (description of a color scheme element)</extracomment>
+ <translation type="unfinished">Extern länk</translation>
+ </message>
+ <message id="harbour-books-color_picker-menu-reset_colors">
+ <source>Reset colors</source>
+ <extracomment>Pulley menu item</extracomment>
+ <translation type="unfinished">Återställ färger</translation>
+ </message>
+ <message id="harbour-books-color_picker-action-select_color">
+ <source>Select color</source>
+ <extracomment>Dialog title label</extracomment>
+ <translation type="unfinished">Välj färg</translation>
+ </message>
+ <message id="harbour-books-color_picker-action-add_color">
+ <source>Add color</source>
+ <extracomment>Dialog title label</extracomment>
+ <translation type="unfinished">Lägg till färg</translation>
+ </message>
+ <message id="harbour-books-color_picker-slider-hue">
+ <source>Color</source>
+ <extracomment>Hue slider label</extracomment>
+ <translation type="unfinished">Färg</translation>
+ </message>
+ <message id="harbour-books-color_picker-slider-brightness">
+ <source>Brightness</source>
+ <extracomment>Brightness slider label</extracomment>
+ <translation type="unfinished">Ljusstyrka</translation>
+ </message>
+ <message id="harbour-books-color_picker-text-hex_notation">
+ <source>Hex notation</source>
+ <extracomment>Text field description</extracomment>
+ <translation type="unfinished">Hex notation</translation>
+ </message>
</context>
</TS>
|
[-]
[+]
|
Changed |
_service:tar_git:openrepos-books-1.1.0.tar.gz/app/translations/harbour-books-zh_CN.ts
^
|
@@ -293,6 +293,21 @@
<extracomment>Text switch description</extracomment>
<translation type="unfinished"></translation>
</message>
+ <message id="harbour-books-settings-page-colors-section_header">
+ <source>Colors</source>
+ <extracomment>Section header for colors</extracomment>
+ <translation type="unfinished">颜色</translation>
+ </message>
+ <message id="harbour-books-settings-page-standard_colors">
+ <source>Use standard colors</source>
+ <extracomment>Text switch label</extracomment>
+ <translation type="unfinished">使用标准颜色</translation>
+ </message>
+ <message id="harbour-books-settings-page-standard_colors-description">
+ <source>Note that colors hardcoded in the book override the color scheme.</source>
+ <extracomment>Text switch description</extracomment>
+ <translation type="unfinished">请注意,书籍定义的颜色会覆盖标准颜色。</translation>
+ </message>
<message id="harbour-books-settings-page-removable-section_header">
<source>Memory card</source>
<extracomment>Section header for memory card settings</extracomment>
@@ -308,5 +323,65 @@
<extracomment>Settings field description</extracomment>
<translation>不填写文件夹名称以扫描SD卡中的全部书籍</translation>
</message>
+ <message id="harbour-books-color-page_background">
+ <source>Page background</source>
+ <extracomment>List item label (description of a color scheme element)</extracomment>
+ <translation type="unfinished">页面背景</translation>
+ </message>
+ <message id="harbour-books-color-text">
+ <source>Regular text</source>
+ <extracomment>List item label (description of a color scheme element)</extracomment>
+ <translation type="unfinished">常规文本</translation>
+ </message>
+ <message id="harbour-books-color-selection_background">
+ <source>Selection background</source>
+ <extracomment>List item label (description of a color scheme element)</extracomment>
+ <translation type="unfinished">选拔背景</translation>
+ </message>
+ <message id="harbour-books-color-highlighted_text">
+ <source>Highlighted text</source>
+ <extracomment>List item label (description of a color scheme element)</extracomment>
+ <translation type="unfinished">突出显示的文本</translation>
+ </message>
+ <message id="harbour-books-color-internal_hyperlink">
+ <source>Internal hyperlink</source>
+ <extracomment>List item label (description of a color scheme element)</extracomment>
+ <translation type="unfinished">内部链接</translation>
+ </message>
+ <message id="harbour-books-color-external_hyperlink">
+ <source>External hyperlink</source>
+ <extracomment>List item label (description of a color scheme element)</extracomment>
+ <translation type="unfinished">外部链接</translation>
+ </message>
+ <message id="harbour-books-color_picker-menu-reset_colors">
+ <source>Reset colors</source>
+ <extracomment>Pulley menu item</extracomment>
+ <translation type="unfinished">重置颜色</translation>
+ </message>
+ <message id="harbour-books-color_picker-action-select_color">
+ <source>Select color</source>
+ <extracomment>Dialog title label</extracomment>
+ <translation type="unfinished">选择颜色</translation>
+ </message>
+ <message id="harbour-books-color_picker-action-add_color">
+ <source>Add color</source>
+ <extracomment>Dialog title label</extracomment>
+ <translation type="unfinished">添加颜色</translation>
+ </message>
+ <message id="harbour-books-color_picker-slider-hue">
+ <source>Color</source>
+ <extracomment>Hue slider label</extracomment>
+ <translation type="unfinished">颜色</translation>
+ </message>
+ <message id="harbour-books-color_picker-slider-brightness">
+ <source>Brightness</source>
+ <extracomment>Brightness slider label</extracomment>
+ <translation type="unfinished">亮度</translation>
+ </message>
+ <message id="harbour-books-color_picker-text-hex_notation">
+ <source>Hex notation</source>
+ <extracomment>Text field description</extracomment>
+ <translation type="unfinished">十六进制表示法</translation>
+ </message>
</context>
</TS>
|
[-]
[+]
|
Changed |
_service:tar_git:openrepos-books-1.1.0.tar.gz/app/translations/harbour-books.ts
^
|
@@ -294,6 +294,21 @@
<extracomment>Text switch description</extracomment>
<translation>Without the pulley menu, the book has to be closed by swiping it up.</translation>
</message>
+ <message id="harbour-books-settings-page-colors-section_header">
+ <source>Colors</source>
+ <extracomment>Section header for colors</extracomment>
+ <translation>Colors</translation>
+ </message>
+ <message id="harbour-books-settings-page-standard_colors">
+ <source>Use standard colors</source>
+ <extracomment>Text switch label</extracomment>
+ <translation>Use standard colors</translation>
+ </message>
+ <message id="harbour-books-settings-page-standard_colors-description">
+ <source>Note that colors hardcoded in the book override the color scheme.</source>
+ <extracomment>Text switch description</extracomment>
+ <translation>Note that colors hardcoded in the book override the color scheme.</translation>
+ </message>
<message id="harbour-books-settings-page-removable-section_header">
<source>Memory card</source>
<extracomment>Section header for memory card settings</extracomment>
@@ -309,5 +324,65 @@
<extracomment>Settings field description</extracomment>
<translation>Leave the folder name empty to scan the entire memory card for books.</translation>
</message>
+ <message id="harbour-books-color-page_background">
+ <source>Page background</source>
+ <extracomment>List item label (description of a color scheme element)</extracomment>
+ <translation>Page background</translation>
+ </message>
+ <message id="harbour-books-color-text">
+ <source>Regular text</source>
+ <extracomment>List item label (description of a color scheme element)</extracomment>
+ <translation>Regular text</translation>
+ </message>
+ <message id="harbour-books-color-selection_background">
+ <source>Selection background</source>
+ <extracomment>List item label (description of a color scheme element)</extracomment>
+ <translation>Selection background</translation>
+ </message>
+ <message id="harbour-books-color-highlighted_text">
+ <source>Highlighted text</source>
+ <extracomment>List item label (description of a color scheme element)</extracomment>
+ <translation>Highlighted text</translation>
+ </message>
+ <message id="harbour-books-color-internal_hyperlink">
+ <source>Internal hyperlink</source>
+ <extracomment>List item label (description of a color scheme element)</extracomment>
+ <translation>Internal hyperlink</translation>
+ </message>
+ <message id="harbour-books-color-external_hyperlink">
+ <source>External hyperlink</source>
+ <extracomment>List item label (description of a color scheme element)</extracomment>
+ <translation>External hyperlink</translation>
+ </message>
+ <message id="harbour-books-color_picker-menu-reset_colors">
+ <source>Reset colors</source>
+ <extracomment>Pulley menu item</extracomment>
+ <translation>Reset colors</translation>
+ </message>
+ <message id="harbour-books-color_picker-action-select_color">
+ <source>Select color</source>
+ <extracomment>Dialog title label</extracomment>
+ <translation>Select color</translation>
+ </message>
+ <message id="harbour-books-color_picker-action-add_color">
+ <source>Add color</source>
+ <extracomment>Dialog title label</extracomment>
+ <translation>Add color</translation>
+ </message>
+ <message id="harbour-books-color_picker-slider-hue">
+ <source>Color</source>
+ <extracomment>Hue slider label</extracomment>
+ <translation>Color</translation>
+ </message>
+ <message id="harbour-books-color_picker-slider-brightness">
+ <source>Brightness</source>
+ <extracomment>Brightness slider label</extracomment>
+ <translation>Brightness</translation>
+ </message>
+ <message id="harbour-books-color_picker-text-hex_notation">
+ <source>Hex notation</source>
+ <extracomment>Text field description</extracomment>
+ <translation>Hex notation</translation>
+ </message>
</context>
</TS>
|
[-]
[+]
|
Changed |
_service:tar_git:openrepos-books-1.1.0.tar.gz/harbour-books.pro
^
|
@@ -1,7 +1,12 @@
TEMPLATE = subdirs
-CONFIG += ordered
+CONFIG += ordered app_settings
SUBDIRS = fribidi linebreak fbreader app
+app_settings {
+ SUBDIRS += settings
+ settings.file = app/settings/settings.pro
+}
+
OTHER_FILES += \
README.md \
rpm/*.spec
|
[-]
[+]
|
Changed |
_service:tar_git:openrepos-books-1.1.0.tar.gz/harbour-lib/harbour-lib.pro
^
|
@@ -36,6 +36,7 @@
src/HarbourOrganizeListModel.cpp \
src/HarbourPolicyPlugin.cpp \
src/HarbourProcessState.cpp \
+ src/HarbourProtoBuf.cpp \
src/HarbourSelectionListModel.cpp \
src/HarbourSigChildHandler.cpp \
src/HarbourSingleImageProvider.cpp \
@@ -46,7 +47,8 @@
src/HarbourTask.cpp \
src/HarbourTemporaryFile.cpp \
src/HarbourTransferMethodInfo.cpp \
- src/HarbourTransferMethodsModel.cpp
+ src/HarbourTransferMethodsModel.cpp \
+ src/HarbourUtil.cpp
greaterThan(QT_MAJOR_VERSION, 4) {
SOURCES += \
@@ -70,6 +72,7 @@
include/HarbourOrganizeListModel.h \
include/HarbourPolicyPlugin.h \
include/HarbourProcessState.h \
+ include/HarbourProtoBuf.h \
include/HarbourSelectionListModel.h \
include/HarbourSigChildHandler.h \
include/HarbourSingleImageProvider.h \
@@ -80,7 +83,8 @@
include/HarbourTask.h \
include/HarbourTemporaryFile.h \
include/HarbourTransferMethodInfo.h \
- include/HarbourTransferMethodsModel.h
+ include/HarbourTransferMethodsModel.h \
+ include/HarbourUtil.h
greaterThan(QT_MAJOR_VERSION, 4) {
PUBLIC_HEADERS += \
|
[-]
[+]
|
Changed |
_service:tar_git:openrepos-books-1.1.0.tar.gz/harbour-lib/include/HarbourBase32.h
^
|
@@ -1,6 +1,6 @@
/*
- * Copyright (C) 2019-2021 Jolla Ltd.
- * Copyright (C) 2019-2021 Slava Monich <slava.monich@jolla.com>
+ * Copyright (C) 2019-2022 Jolla Ltd.
+ * Copyright (C) 2019-2022 Slava Monich <slava.monich@jolla.com>
*
* You may use this file under the terms of the BSD license as follows:
*
@@ -37,13 +37,15 @@
#include <QString>
#include <QByteArray>
-class HarbourBase32 {
+class HarbourBase32
+{
class Private;
- HarbourBase32();
+ HarbourBase32() Q_DECL_EQ_DELETE;
+
public:
- static QByteArray fromBase32(QString aBase32);
- static QString toBase32(QByteArray aBinary, bool aLowerCase = true);
- static bool isValidBase32(QString aBase32);
+ static bool isValidBase32(const QString);
+ static QString toBase32(const QByteArray, bool aLowerCase = true);
+ static QByteArray fromBase32(const QString);
};
#endif // HARBOUR_BASE32_H
|
[-]
[+]
|
Changed |
_service:tar_git:openrepos-books-1.1.0.tar.gz/harbour-lib/include/HarbourBase45.h
^
|
@@ -1,6 +1,6 @@
/*
- * Copyright (C) 2021 Jolla Ltd.
- * Copyright (C) 2021 Slava Monich <slava.monich@jolla.com>
+ * Copyright (C) 2021-2022 Jolla Ltd.
+ * Copyright (C) 2021-2022 Slava Monich <slava.monich@jolla.com>
*
* You may use this file under the terms of the BSD license as follows:
*
@@ -37,13 +37,15 @@
#include <QString>
#include <QByteArray>
-class HarbourBase45 {
+class HarbourBase45
+{
class Private;
- HarbourBase45();
+ HarbourBase45() Q_DECL_EQ_DELETE;
+
public:
- static bool isValidBase45(QString aBase45);
- static QByteArray fromBase45(QString aBase45);
- static QString toBase45(QByteArray aBinary);
+ static bool isValidBase45(const QString);
+ static QString toBase45(const QByteArray);
+ static QByteArray fromBase45(const QString);
};
#endif // HARBOUR_BASE45_H
|
[-]
[+]
|
Added |
_service:tar_git:openrepos-books-1.1.0.tar.gz/harbour-lib/include/HarbourProtoBuf.h
^
|
@@ -0,0 +1,64 @@
+/*
+ * Copyright (C) 2022 Jolla Ltd.
+ * Copyright (C) 2022 Slava Monich <slava.monich@jolla.com>
+ *
+ * You may use this file under the terms of the 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:
+ *
+ * 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
+ * distribution.
+ * 3. Neither the names of the copyright holders 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
+ * OWNER 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.
+ */
+
+#ifndef HARBOUR_PROTOBUF_H
+#define HARBOUR_PROTOBUF_H
+
+#include <QByteArray>
+
+#include <gutil_types.h>
+
+// https://developers.google.com/protocol-buffers/docs/encoding
+
+class HarbourProtoBuf
+{
+ HarbourProtoBuf() Q_DECL_EQ_DELETE;
+
+public:
+ enum {
+ TYPE_SHIFT = 3,
+ TYPE_MASK = ((1 << TYPE_SHIFT)-1),
+ TYPE_VARINT = 0,
+ TYPE_DELIMITED = 2
+ };
+
+ static QByteArray* appendVarInt(QByteArray*, quint64);
+ static QByteArray* appendVarIntKeyValue(QByteArray*, quint64, quint64);
+ static QByteArray* appendDelimitedValue(QByteArray*, const QByteArray);
+ static QByteArray* appendDelimitedKeyValue(QByteArray*, quint64, const QByteArray);
+
+ static bool parseVarInt(GUtilRange*, quint64*);
+ static bool parseDelimitedValue(GUtilRange*, GUtilData*);
+};
+
+#endif // HARBOUR_PROTOBUF_H
|
[-]
[+]
|
Changed |
_service:tar_git:openrepos-books-1.1.0.tar.gz/harbour-lib/include/HarbourTheme.h
^
|
@@ -1,6 +1,6 @@
/*
- * Copyright (C) 2018-2020 Jolla Ltd.
- * Copyright (C) 2018-2020 Slava Monich <slava@monich.com>
+ * Copyright (C) 2018-2022 Jolla Ltd.
+ * Copyright (C) 2018-2022 Slava Monich <slava@monich.com>
*
* You may use this file under the terms of the BSD license as follows:
*
|
[-]
[+]
|
Added |
_service:tar_git:openrepos-books-1.1.0.tar.gz/harbour-lib/include/HarbourUtil.h
^
|
@@ -0,0 +1,69 @@
+/*
+ * Copyright (C) 2022 Jolla Ltd.
+ * Copyright (C) 2022 Slava Monich <slava.monich@jolla.com>
+ *
+ * You may use this file under the terms of the 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:
+ *
+ * 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
+ * distribution.
+ * 3. Neither the names of the copyright holders 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
+ * OWNER 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.
+ */
+
+#ifndef HARBOUR_UTIL_H
+#define HARBOUR_UTIL_H
+
+#include <QByteArray>
+#include <QColor>
+#include <QObject>
+#include <QRgb>
+#include <QString>
+
+class QQmlEngine;
+class QJSEngine;
+
+class HarbourUtil :
+ public QObject
+{
+ Q_OBJECT
+ class Private;
+
+public:
+ explicit HarbourUtil(QObject* aParent = Q_NULLPTR);
+
+ // Callback for qmlRegisterSingletonType<HarbourUtil>
+ static QObject* createSingleton(QQmlEngine*, QJSEngine*);
+
+ // QML (and possibly native) utilities
+ Q_INVOKABLE static QColor invertedColor(const QColor&);
+
+ // Static utilities
+ static QRgb invertedRgb(QRgb);
+ static QByteArray toHexBytes(const void*, size_t);
+ static QString toHex(const void*, size_t);
+ static inline QString toHex(const QByteArray& aData)
+ { return toHex(aData.constData(), aData.size()); }
+};
+
+#endif // HARBOUR_UTIL_H
|
[-]
[+]
|
Changed |
_service:tar_git:openrepos-books-1.1.0.tar.gz/harbour-lib/qml/HarbourBadge.qml
^
|
@@ -1,6 +1,6 @@
/*
- * Copyright (C) 2018-2019 Jolla Ltd.
- * Copyright (C) 2018-2019 Slava Monich <slava@monich.com>
+ * Copyright (C) 2018-2022 Jolla Ltd.
+ * Copyright (C) 2018-2022 Slava Monich <slava@monich.com>
*
* You may use this file under the terms of 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
@@ -39,6 +39,9 @@
property real maxWidth: parent.width
property alias text: label.text
+ property alias backgroundColor: background.color
+ property alias textColor: label.color
+
readonly property real radius: height/2
width: Math.max(label.implicitWidth + radius, height)
|
[-]
[+]
|
Changed |
_service:tar_git:openrepos-books-1.1.0.tar.gz/harbour-lib/src/HarbourBase32.cpp
^
|
@@ -1,6 +1,6 @@
/*
- * Copyright (C) 2019 Jolla Ltd.
- * Copyright (C) 2019 Slava Monich <slava.monich@jolla.com>
+ * Copyright (C) 2019-2022 Jolla Ltd.
+ * Copyright (C) 2019-2022 Slava Monich <slava.monich@jolla.com>
*
* You may use this file under the terms of the BSD license as follows:
*
@@ -46,25 +46,33 @@
// HarbourBase32::Private
// ==========================================================================
-class HarbourBase32::Private {
+class HarbourBase32::Private
+{
public:
- static char nibbleToBase32(int nibble, char a);
- static int base32ToNibble(char a);
+ static char nibbleToBase32(int, char);
+ static int base32ToNibble(char);
};
-inline char HarbourBase32::Private::nibbleToBase32(int nibble, char a)
+inline
+char
+HarbourBase32::Private::nibbleToBase32(
+ int aNibble,
+ char aBaseChar)
{
- return (nibble < 26) ? (a + nibble) : ('2' + (nibble - 26));
+ return (aNibble < 26) ? (aBaseChar + aNibble) : ('2' + (aNibble - 26));
}
-inline int HarbourBase32::Private::base32ToNibble(char c)
+inline
+int
+HarbourBase32::Private::base32ToNibble(
+ char aChar)
{
- if (c >= 'a' && c <= 'z') {
- return c - 'a';
- } else if (c >= 'A' && c <= 'Z') {
- return c - 'A';
- } else if (c >= '2' && c <= '7') {
- return 26 + (c - '2');
+ if (aChar >= 'a' && aChar <= 'z') {
+ return aChar - 'a';
+ } else if (aChar >= 'A' && aChar <= 'Z') {
+ return aChar - 'A';
+ } else if (aChar >= '2' && aChar <= '7') {
+ return 26 + (aChar - '2');
} else {
return -1;
}
@@ -74,7 +82,9 @@
// HarbourBase32
// ==========================================================================
-bool HarbourBase32::isValidBase32(QString aBase32)
+bool
+HarbourBase32::isValidBase32(
+ QString aBase32)
{
const int n = aBase32.length();
const QChar* chars = aBase32.constData();
@@ -133,7 +143,9 @@
return !empty;
}
-QByteArray HarbourBase32::fromBase32(QString aBase32)
+QByteArray
+HarbourBase32::fromBase32(
+ const QString aBase32)
{
QByteArray out;
@@ -205,7 +217,10 @@
return out;
}
-QString HarbourBase32::toBase32(QByteArray aBinary, bool aLowerCase)
+QString
+HarbourBase32::toBase32(
+ const QByteArray aBinary,
+ bool aLowerCase)
{
QString str;
const int n = aBinary.size();
|
[-]
[+]
|
Changed |
_service:tar_git:openrepos-books-1.1.0.tar.gz/harbour-lib/src/HarbourBase45.cpp
^
|
@@ -1,6 +1,6 @@
/*
- * Copyright (C) 2021 Jolla Ltd.
- * Copyright (C) 2021 Slava Monich <slava.monich@jolla.com>
+ * Copyright (C) 2021-2022 Jolla Ltd.
+ * Copyright (C) 2021-2022 Slava Monich <slava.monich@jolla.com>
*
* You may use this file under the terms of the BSD license as follows:
*
@@ -39,7 +39,8 @@
// HarbourBase45::Private
// ==========================================================================
-class HarbourBase45::Private {
+class HarbourBase45::Private
+{
public:
enum {
BASE = 45,
@@ -48,7 +49,7 @@
};
static const char mapBase45[BASE];
static const int reverseMapBase45[REVERSE_MAP_SIZE];
- static bool isValidChar(uint x);
+ static bool isValidChar(uint);
};
const char HarbourBase45::Private::mapBase45[HarbourBase45::Private::BASE] = {
@@ -75,16 +76,22 @@
33, 34, 35
};
-inline bool HarbourBase45::Private::isValidChar(uint x)
+inline
+bool
+HarbourBase45::Private::isValidChar(
+ uint aChar)
{
- return (x < Private::REVERSE_MAP_SIZE) && Private::reverseMapBase45[x] >= 0;
+ return (aChar < Private::REVERSE_MAP_SIZE) &&
+ Private::reverseMapBase45[aChar] >= 0;
}
// ==========================================================================
// HarbourBase45::Private
// ==========================================================================
-bool HarbourBase45::isValidBase45(QString aBase45)
+bool
+HarbourBase45::isValidBase45(
+ const QString aBase45)
{
const int len = aBase45.length();
@@ -123,7 +130,9 @@
return false;
}
-QByteArray HarbourBase45::fromBase45(QString aBase45)
+QByteArray
+HarbourBase45::fromBase45(
+ const QString aBase45)
{
QByteArray out;
const int len = aBase45.length();
@@ -175,7 +184,9 @@
return out;
}
-QString HarbourBase45::toBase45(QByteArray aBinary)
+QString
+HarbourBase45::toBase45(
+ const QByteArray aBinary)
{
const uchar* ptr = (uchar*)aBinary.constData();
const int n = aBinary.size();
|
[-]
[+]
|
Added |
_service:tar_git:openrepos-books-1.1.0.tar.gz/harbour-lib/src/HarbourProtoBuf.cpp
^
|
@@ -0,0 +1,144 @@
+/*
+ * Copyright (C) 2022 Jolla Ltd.
+ * Copyright (C) 2022 Slava Monich <slava.monich@jolla.com>
+ *
+ * You may use this file under the terms of the 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:
+ *
+ * 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
+ * distribution.
+ * 3. Neither the names of the copyright holders 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
+ * OWNER 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.
+ */
+
+#include "HarbourDebug.h"
+#include "HarbourProtoBuf.h"
+
+// https://developers.google.com/protocol-buffers/docs/encoding
+
+QByteArray*
+HarbourProtoBuf::appendVarInt(
+ QByteArray* aOutput,
+ quint64 aValue)
+{
+ if (aOutput) {
+ uchar out[10];
+ quint64 value = aValue;
+ int i = sizeof(out) - 1;
+
+ out[i] = value & 0x7f;
+ value >>= 7;
+ while (value) {
+ out[--i] = 0x80 | (uchar)value;
+ value >>= 7;
+ }
+
+ const int n = sizeof(out) - i;
+
+ aOutput->reserve(aOutput->size() + n);
+ aOutput->append((char*)(out + i), n);
+ }
+ return aOutput;
+}
+
+QByteArray*
+HarbourProtoBuf::appendVarIntKeyValue(
+ QByteArray* aOutput,
+ quint64 aKey,
+ quint64 aValue)
+{
+ HASSERT((aKey & TYPE_MASK) == TYPE_VARINT);
+ return appendVarInt(appendVarInt(aOutput, aKey), aValue);
+}
+
+QByteArray*
+HarbourProtoBuf::appendDelimitedValue(
+ QByteArray* aOutput,
+ const QByteArray aValue)
+{
+ if (aOutput) {
+ appendVarInt(aOutput, aValue.size())->append(aValue);
+ }
+ return aOutput;
+}
+
+QByteArray*
+HarbourProtoBuf::appendDelimitedKeyValue(
+ QByteArray* aOutput,
+ quint64 aKey,
+ const QByteArray aValue)
+{
+ HASSERT((aKey & TYPE_MASK) == TYPE_DELIMITED);
+ return appendDelimitedValue(appendVarInt(aOutput, aKey), aValue);
+}
+
+bool
+HarbourProtoBuf::parseVarInt(
+ GUtilRange* aPos,
+ quint64* aResult)
+{
+ if (aPos) {
+ quint64 value = 0;
+ const guint8* ptr = aPos->ptr;
+
+ for (int i = 0; i < 10 && ptr < aPos->end; i++, ptr++) {
+ value = (value << 7) | (*ptr & 0x7f);
+ if (!(*ptr & 0x80)) {
+ aPos->ptr = ptr + 1;
+ if (aResult) {
+ *aResult = value;
+ }
+ return true;
+ }
+ }
+
+ // Premature end of stream or too many bytes
+ if (aResult) {
+ *aResult = 0;
+ }
+ }
+ return false;
+}
+
+// A delimited value is stored as a size, encoded as a varint, followed
+// by the payload of type (message | string | bytes | packed)
+bool
+HarbourProtoBuf::parseDelimitedValue(
+ GUtilRange* aPos,
+ GUtilData* aPayload)
+{
+ if (aPos) {
+ GUtilRange pos = *aPos;
+ quint64 size;
+
+ if (parseVarInt(&pos, &size) && (pos.ptr + size) <= pos.end) {
+ if (aPayload) {
+ aPayload->bytes = pos.ptr;
+ aPayload->size = size;
+ }
+ aPos->ptr = pos.ptr + size;
+ return true;
+ }
+ }
+ return false;
+}
|
[-]
[+]
|
Changed |
_service:tar_git:openrepos-books-1.1.0.tar.gz/harbour-lib/src/HarbourTheme.cpp
^
|
@@ -1,6 +1,6 @@
/*
- * Copyright (C) 2018-2020 Jolla Ltd.
- * Copyright (C) 2018-2020 Slava Monich <slava@monich.com>
+ * Copyright (C) 2018-2022 Jolla Ltd.
+ * Copyright (C) 2018-2022 Slava Monich <slava@monich.com>
*
* You may use this file under the terms of the BSD license as follows:
*
@@ -31,9 +31,10 @@
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
-#include "HarbourTheme.h"
-#include "HarbourSystem.h"
#include "HarbourDebug.h"
+#include "HarbourSystem.h"
+#include "HarbourTheme.h"
+#include "HarbourUtil.h"
#include <QQmlEngine>
@@ -212,17 +213,12 @@
QColor HarbourTheme::invertedPrimaryColor() const
{
- return invertedColor(Private::primaryColor());
+ return HarbourUtil::invertedColor(Private::primaryColor());
}
QColor HarbourTheme::invertedColor(const QColor& aColor)
{
- if (aColor.isValid()) {
- const QRgb rgba = aColor.rgba();
- return QColor(((~(rgba & RGB_MASK)) & RGB_MASK) | (rgba & (~RGB_MASK)));
- } else {
- return aColor;
- }
+ return HarbourUtil::invertedColor(aColor);
}
qreal HarbourTheme::colorDifference(const QColor& aColor1, const QColor& aColor2)
|
[-]
[+]
|
Added |
_service:tar_git:openrepos-books-1.1.0.tar.gz/harbour-lib/src/HarbourUtil.cpp
^
|
@@ -0,0 +1,116 @@
+/*
+ * Copyright (C) 2022 Jolla Ltd.
+ * Copyright (C) 2022 Slava Monich <slava.monich@jolla.com>
+ *
+ * You may use this file under the terms of the 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:
+ *
+ * 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
+ * distribution.
+ * 3. Neither the names of the copyright holders 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
+ * OWNER 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.
+ */
+
+#include "HarbourUtil.h"
+
+// ==========================================================================
+// HarbourUtil::Private
+// ==========================================================================
+
+class HarbourUtil::Private
+{
+public:
+ static const char hex[];
+};
+
+const char HarbourUtil::Private::hex[] = "0123456789abcdef";
+
+// ==========================================================================
+// HarbourUtil
+// ==========================================================================
+
+HarbourUtil::HarbourUtil(
+ QObject* aParent) :
+ QObject(aParent)
+{
+}
+
+// Callback for qmlRegisterSingletonType<HarbourUtil>
+QObject*
+HarbourUtil::createSingleton(
+ QQmlEngine*,
+ QJSEngine*)
+{
+ return new HarbourUtil();
+}
+
+QColor
+HarbourUtil::invertedColor(
+ const QColor& aColor)
+{
+ if (aColor.isValid()) {
+ const QRgb inv = invertedRgb(aColor.rgba());
+
+ return QColor(qRed(inv), qGreen(inv), qBlue(inv), qAlpha(inv));
+ } else {
+ return aColor;
+ }
+}
+
+QRgb
+HarbourUtil::invertedRgb(
+ QRgb aRgb)
+{
+ return ((~(aRgb & RGB_MASK)) & RGB_MASK) | (aRgb & (~RGB_MASK));
+}
+
+QString
+HarbourUtil::toHex(
+ const void* aData,
+ size_t aSize)
+{
+ QString hex;
+
+ if (aSize > 0) {
+ const uchar* bytes = (const uchar*)aData;
+
+ hex.reserve(2 * aSize);
+ for (size_t i = 0; i < aSize; i++) {
+ const uchar b = bytes[i];
+
+ hex.append(QChar(Private::hex[(b & 0xf0) >> 4]));
+ hex.append(QChar(Private::hex[b & 0x0f]));
+ }
+ }
+ return hex;
+}
+
+QByteArray
+HarbourUtil::toHexBytes(
+ const void* aData,
+ size_t aSize)
+{
+ return aSize ?
+ QByteArray::fromRawData((const char*) aData, (int) aSize).toHex() :
+ QByteArray();
+}
|
[-]
[+]
|
Added |
_service:tar_git:openrepos-books-1.1.0.tar.gz/harbour-lib/src/libcrypto.c
^
|
@@ -0,0 +1,262 @@
+/*
+ * Copyright (C) 2021 Jolla Ltd.
+ * Copyright (C) 2021 Slava Monich <slava.monich@jolla.com>
+ *
+ * You may use this file under the terms of the 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:
+ *
+ * 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
+ * distribution.
+ * 3. Neither the names of the copyright holders 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
+ * OWNER 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.
+ */
+
+#include "gutil_log.h"
+
+#include <dlfcn.h>
+#include <stdint.h>
+
+#include <openssl/aes.h>
+#include <openssl/des.h>
+#include <openssl/md5.h>
+#include <openssl/rsa.h>
+#include <openssl/sha.h>
+
+/*
+ * What is this code?
+ *
+ * Sailfish OS comes in 3 flavors wrt openssl versions:
+ *
+ * 1. Sailfish OS up to 3.4 had openssl 1.0
+ * 2. Sailfish 4.0..4.2 had both openssl 1.0 and openssl 1.1 libraries
+ * 3. Sailfish 4.3 dropped openssl 1.0 libraries and only has openssl 1.1
+ *
+ * Which means that explicitly linking with any version of openssl
+ * makes your app incompatible with either Sailfish OS <= 3.4 or
+ * Sailfish OS >= 4.3 (nice symmetry).
+ *
+ * If you want to build an app which runs on both Sailfish OS <= 3.4
+ * and Sailfish OS >= 4.3 you have two options:
+ *
+ * 1. Link openssl statically
+ * 2. Load libcrypts.so dynamically with dlopen/dlsym
+ *
+ * This module allows you to implement the second strategy. It works
+ * because openssl 1.0 and 1.1 (luckily!) appear to be binary compatible.
+ * It doesn't load all libcrypto functions, only those referenced by my
+ * apps but the list can be easily expanded.
+ */
+
+#ifndef LIBDIR
+# ifdef __aarch64__
+# define LIBDIR "/usr/lib64"
+# else
+# define LIBDIR "/usr/lib"
+# endif
+#endif
+
+/*
+ * OpenSSL 1.0 headers define ERR_load_crypto_strings as a function:
+ *
+ * void ERR_load_crypto_strings(void);
+ *
+ * and OpenSSL 1.1 as a macro:
+ *
+ * #if OPENSSL_API_COMPAT < 0x10100000L
+ * # define ERR_load_crypto_strings() \
+ * OPENSSL_init_crypto(OPENSSL_INIT_LOAD_CRYPTO_STRINGS, NULL)
+ * # define ERR_free_strings() while(0) continue
+ * #endif
+ *
+ * We want to try loading both ERR_load_crypto_strings and
+ * OPENSSL_init_crypto, one of which will probably fail.
+ */
+
+#if OPENSSL_VERSION_NUMBER >= 0x10100000L
+# undef ERR_load_crypto_strings
+#else
+# define OPENSSL_INIT_SETTINGS void
+#endif
+
+/* f(name,params,args) */
+#define LIBCRYPTO_FUNCTIONS1(f) \
+ f(AES_cbc_encrypt, \
+ (const unsigned char* in, unsigned char* out, size_t length, \
+ const AES_KEY* key, unsigned char* ivec, const int enc), \
+ (in, out, length, key, ivec, enc)) \
+ f(AES_cfb128_encrypt, \
+ (const unsigned char* in, unsigned char* out, size_t length, \
+ const AES_KEY* key,unsigned char* ivec, int* num, const int enc), \
+ (in, out, length, key, ivec, num, enc)) \
+ f(AES_ecb_encrypt, \
+ (const unsigned char* in, unsigned char* out, const AES_KEY* key, \
+ const int enc), \
+ (in, out, key, enc)) \
+ f(BN_free, (BIGNUM *a), (a)) \
+ f(DES_ede3_cbc_encrypt, \
+ (const unsigned char* input, unsigned char* output, long length, \
+ DES_key_schedule* ks1, DES_key_schedule* ks2, DES_key_schedule* ks3, \
+ DES_cblock* ivec, int enc), \
+ (input, output, length, ks1, ks2, ks3, ivec, enc)) \
+ f(ERR_load_crypto_strings, (void), ()) \
+ f(RSA_free, (RSA* r), (r))
+
+/* f(ret,name,params,args,def) */
+#define LIBCRYPTO_FUNCTIONS2(f) \
+ f(int, AES_set_decrypt_key, \
+ (const unsigned char* userKey, const int bits, AES_KEY* key), \
+ (userKey, bits, key), -1) \
+ f(int, AES_set_encrypt_key, \
+ (const unsigned char* userKey, const int bits, AES_KEY* key), \
+ (userKey, bits, key), -1) \
+ f(BIGNUM*, BN_bin2bn, \
+ (const unsigned char* s, int len, BIGNUM* ret), (s, len, ret), NULL) \
+ f(int, BN_bn2bin, \
+ (const BIGNUM* a, unsigned char* to), (a, to), 0) \
+ f(BIGNUM*, BN_new, (void), (), NULL) \
+ f(int, BN_num_bits, (const BIGNUM *a), (a), 0) \
+ f(int, BN_set_word, (BIGNUM* a, BN_ULONG w), (a, w), 0) \
+ f(int, DES_check_key_parity, (const_DES_cblock* key), (key), 0) \
+ f(int, DES_is_weak_key, (const_DES_cblock* key), (key), 0) \
+ f(int, DES_set_key, \
+ (const_DES_cblock* key, DES_key_schedule* schedule), \
+ (key, schedule), -1) \
+ f(char*, ERR_error_string, (unsigned long e, char* buf), (e, buf), NULL) \
+ f(unsigned long, ERR_get_error, (void), (), 0) \
+ f(unsigned char*, MD5, \
+ (const unsigned char* d, size_t n, unsigned char* md), (d, n, md), NULL) \
+ f(int, MD5_Final, (unsigned char* md, MD5_CTX* c), (md, c), 0) \
+ f(int, MD5_Init, (MD5_CTX* c), (c), 0) \
+ f(int, MD5_Update, (MD5_CTX* c, const void* data, size_t len), \
+ (c, data, len), 0) \
+ f(int, OPENSSL_init_crypto, \
+ (uint64_t opts, const OPENSSL_INIT_SETTINGS* settings), \
+ (opts, settings), 0) \
+ f(int, RAND_bytes, (unsigned char* buf, int num), (buf, num), 0) \
+ f(int, RAND_poll, (void), (), 0) \
+ f(RSA*, RSAPrivateKey_dup, (RSA* rsa), (rsa), NULL) \
+ f(RSA*, RSAPublicKey_dup, (RSA* rsa), (rsa), NULL) \
+ f(int, RSA_generate_key_ex, \
+ (RSA* rsa, int bits, BIGNUM* e, BN_GENCB* cb), \
+ (rsa, bits, e, cb), 0) \
+ f(RSA*, RSA_new, (void), (), NULL) \
+ f(int, RSA_private_decrypt, \
+ (int flen, const unsigned char* from, unsigned char* to, RSA* rsa, \
+ int padding), (flen, from, to, rsa, padding), 0) \
+ f(int, RSA_private_encrypt, \
+ (int flen, const unsigned char* from, unsigned char* to, RSA* rsa, \
+ int padding), (flen, from, to, rsa, padding), 0) \
+ f(int, RSA_public_decrypt, \
+ (int flen, const unsigned char* from, unsigned char* to, RSA* rsa, \
+ int padding), (flen, from, to, rsa, padding), 0) \
+ f(int, RSA_public_encrypt, \
+ (int flen, const unsigned char* from, unsigned char* to, RSA* rsa, \
+ int padding), (flen, from, to, rsa, padding), 0) \
+ f(int, RSA_size, (const RSA* rsa), (rsa), 0) \
+ f(unsigned char*, SHA1, (const unsigned char* d, size_t n, \
+ unsigned char* md), (d, n, md), NULL) \
+ f(int, SHA1_Final, (unsigned char* md, SHA_CTX* c), (md, c), 0) \
+ f(int, SHA1_Init, (SHA_CTX* c), (c), 0) \
+ f(int, SHA1_Update, (SHA_CTX* c, const void* data, size_t len), \
+ (c, data, len), 0) \
+ f(unsigned char*, SHA256, (const unsigned char* d, size_t n, \
+ unsigned char* md), (d, n, md), NULL) \
+ f(int, SHA256_Final, (unsigned char* md, SHA256_CTX* c), (md, c), 0) \
+ f(int, SHA256_Init, (SHA256_CTX* c), (c), 0) \
+ f(int, SHA256_Update, (SHA256_CTX* c, const void* data, size_t len), \
+ (c, data, len), 0) \
+ f(unsigned char*, SHA512, (const unsigned char* d, size_t n, \
+ unsigned char* md), (d, n, md), NULL) \
+ f(int, SHA512_Final, (unsigned char* md, SHA512_CTX* c), (md, c), 0) \
+ f(int, SHA512_Init, (SHA512_CTX* c), (c), 0) \
+ f(int, SHA512_Update, (SHA512_CTX* c, const void* data, size_t len), \
+ (c, data, len), 0)
+
+static const char* libcrypto_so_path[] = {
+ LIBDIR "/libcrypto.so.1.1",
+ "/lib/libcrypto.so.10"
+};
+
|
[-]
[+]
|
Changed |
_service:tar_git:openrepos-books-1.1.0.tar.gz/harbour-lib/test/Makefile
^
|
@@ -4,3 +4,5 @@
%:
@$(MAKE) -C TestHarbourBase32 $*
@$(MAKE) -C TestHarbourBase45 $*
+ @$(MAKE) -C TestHarbourProtoBuf $*
+ @$(MAKE) -C TestHarbourUtil $*
|
[-]
[+]
|
Changed |
_service:tar_git:openrepos-books-1.1.0.tar.gz/harbour-lib/test/Makefile.common
^
|
@@ -31,6 +31,8 @@
SRC_DIR = .
TOP_DIR = ../..
HARBOUR_DIR = $(TOP_DIR)
+HARBOUR_INCLUDE_DIR = $(HARBOUR_DIR)/include
+HARBOUR_SRC_DIR = $(HARBOUR_DIR)/src
BUILD_DIR = build
DEBUG_BUILD_DIR = $(BUILD_DIR)/debug
RELEASE_BUILD_DIR = $(BUILD_DIR)/release
@@ -44,7 +46,7 @@
LD = $(CC)
MOC = qtchooser -run-tool=moc -qt=5
WARNINGS = -Wall
-INCLUDES = -I$(BUILD_DIR) -I$(HARBOUR_DIR)/include
+INCLUDES = -I$(BUILD_DIR) -I$(HARBOUR_INCLUDE_DIR)
BASE_FLAGS = -fPIC
BASE_LDFLAGS = $(BASE_FLAGS) $(LDFLAGS)
BASE_CFLAGS = $(BASE_FLAGS) $(CFLAGS)
@@ -84,6 +86,9 @@
$(MOC_CPP:%.cpp=$(COVERAGE_BUILD_DIR)/moc_cpp_%.o) \
$(SRC:%.cpp=$(COVERAGE_BUILD_DIR)/%.o) \
$(HARBOUR_SRC:%.cpp=$(COVERAGE_BUILD_DIR)/harbour_%.o)
+GEN_FILES = \
+ $(MOC_H:%.h=$(BUILD_DIR)/moc_%.cpp) \
+ $(MOC_CPP:%.cpp=$(BUILD_DIR)/%.moc)
#
# Dependencies
@@ -96,6 +101,7 @@
endif
endif
+$(GEN_FILES): | $(BUILD_DIR)
$(DEBUG_OBJS): | $(DEBUG_BUILD_DIR)
$(RELEASE_OBJS): | $(RELEASE_BUILD_DIR)
$(COVERAGE_OBJS): | $(COVERAGE_BUILD_DIR)
@@ -139,10 +145,10 @@
$(COVERAGE_BUILD_DIR):
mkdir -p $@
-$(BUILD_DIR)/moc_%.cpp : $(APP_DIR)/%.h
+$(BUILD_DIR)/moc_%.cpp : $(HARBOUR_INCLUDE_DIR)/%.h
$(MOC) $< -o $@
-$(BUILD_DIR)/%.moc : $(APP_DIR)/%.cpp
+$(BUILD_DIR)/%.moc : $(HARBOUR_SRC_DIR)/%.cpp
$(MOC) $< -o $@
$(DEBUG_BUILD_DIR)/%.o : $(SRC_DIR)/%.cpp
@@ -163,31 +169,22 @@
$(COVERAGE_BUILD_DIR)/moc_h_%.o : $(BUILD_DIR)/moc_%.cpp $(BUILD_DIR)
$(CC) -c $(COVERAGE_CFLAGS) -MT"$@" -MF"$(@:%.o=%.d)" $< -o $@
-$(DEBUG_BUILD_DIR)/moc_cpp_%.o : $(HARBOUR_DIR)/%.cpp $(BUILD_DIR)/%.moc
+$(DEBUG_BUILD_DIR)/moc_cpp_%.o : $(HARBOUR_SRC_DIR)/%.cpp $(BUILD_DIR)/%.moc
$(CC) -c $(DEBUG_CFLAGS) -MT"$@" -MF"$(@:%.o=%.d)" $< -o $@
-$(RELEASE_BUILD_DIR)/moc_cpp_%.o : $(HARBOUR_DIR)/%.cpp $(BUILD_DIR)/%.moc
+$(RELEASE_BUILD_DIR)/moc_cpp_%.o : $(HARBOUR_SRC_DIR)/%.cpp $(BUILD_DIR)/%.moc
$(CC) -c $(RELEASE_CFLAGS) -MT"$@" -MF"$(@:%.o=%.d)" $< -o $@
-$(COVERAGE_BUILD_DIR)/moc_cpp_%.o : $(HARBOUR_DIR)/%.cpp $(BUILD_DIR)/%.moc
+$(COVERAGE_BUILD_DIR)/moc_cpp_%.o : $(HARBOUR_SRC_DIR)/%.cpp $(BUILD_DIR)/%.moc
$(CC) -c $(COVERAGE_CFLAGS) -MT"$@" -MF"$(@:%.o=%.d)" $< -o $@
-$(DEBUG_BUILD_DIR)/app_%.o : $(APP_DIR)/%.cpp
+$(DEBUG_BUILD_DIR)/harbour_%.o : $(HARBOUR_SRC_DIR)/%.cpp
$(CC) -c $(DEBUG_CFLAGS) -MT"$@" -MF"$(@:%.o=%.d)" $< -o $@
-$(RELEASE_BUILD_DIR)/app_%.o : $(APP_DIR)/%.cpp
+$(RELEASE_BUILD_DIR)/harbour_%.o : $(HARBOUR_SRC_DIR)/%.cpp
$(CC) -c $(RELEASE_CFLAGS) -MT"$@" -MF"$(@:%.o=%.d)" $< -o $@
-$(COVERAGE_BUILD_DIR)/app_%.o : $(APP_DIR)/%.cpp
- $(CC) -c $(COVERAGE_CFLAGS) -MT"$@" -MF"$(@:%.o=%.d)" $< -o $@
-
-$(DEBUG_BUILD_DIR)/harbour_%.o : $(HARBOUR_DIR)/src/%.cpp
- $(CC) -c $(DEBUG_CFLAGS) -MT"$@" -MF"$(@:%.o=%.d)" $< -o $@
-
-$(RELEASE_BUILD_DIR)/harbour_%.o : $(HARBOUR_DIR)/src/%.cpp
- $(CC) -c $(RELEASE_CFLAGS) -MT"$@" -MF"$(@:%.o=%.d)" $< -o $@
-
-$(COVERAGE_BUILD_DIR)/harbour_%.o : $(HARBOUR_DIR)/src/%.cpp
+$(COVERAGE_BUILD_DIR)/harbour_%.o : $(HARBOUR_SRC_DIR)/%.cpp
$(CC) -c $(COVERAGE_CFLAGS) -MT"$@" -MF"$(@:%.o=%.d)" $< -o $@
$(DEBUG_EXE): $(DEBUG_OBJS)
|
[-]
[+]
|
Added |
_service:tar_git:openrepos-books-1.1.0.tar.gz/harbour-lib/test/TestHarbourProtoBuf/Makefile
^
|
@@ -0,0 +1,7 @@
+# -*- Mode: makefile-gmake -*-
+
+PKGS = libglibutil
+EXE = TestHarbourProtoBuf
+HARBOUR_SRC = HarbourProtoBuf.cpp
+
+include ../Makefile.common
|
[-]
[+]
|
Added |
_service:tar_git:openrepos-books-1.1.0.tar.gz/harbour-lib/test/TestHarbourProtoBuf/TestHarbourProtoBuf.cpp
^
|
@@ -0,0 +1,168 @@
+/*
+ * Copyright (C) 2022 Jolla Ltd.
+ * Copyright (C) 2022 Slava Monich <slava.monich@jolla.com>
+ *
+ * You may use this file under the terms of the 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:
+ *
+ * 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
+ * distribution.
+ * 3. Neither the names of the copyright holders 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
+ * OWNER 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.
+ */
+
+#include "HarbourProtoBuf.h"
+
+#include <glib.h>
+
+/*==========================================================================*
+ * null
+ *==========================================================================*/
+
+static
+void
+test_null(
+ void)
+{
+ g_assert(!HarbourProtoBuf::appendVarInt(NULL, 0));
+ g_assert(!HarbourProtoBuf::appendVarIntKeyValue(NULL, 0, 0));
+ g_assert(!HarbourProtoBuf::appendDelimitedValue(NULL, QByteArray()));
+ g_assert(!HarbourProtoBuf::appendDelimitedKeyValue(NULL,
+ HarbourProtoBuf::TYPE_DELIMITED, QByteArray()));
+ g_assert(!HarbourProtoBuf::parseVarInt(NULL, NULL));
+ g_assert(!HarbourProtoBuf::parseDelimitedValue(NULL, NULL));
+}
+
+/*==========================================================================*
+ * int
+ *==========================================================================*/
+
+static
+void
+test_int(
+ void)
+{
+ QByteArray buf;
+ GUtilRange range;
+ quint64 res;
+
+ static const guint8 enc0[] = { 0 };
+
+ g_assert(HarbourProtoBuf::appendVarInt(&buf, 0) == &buf);
+ g_assert(buf == QByteArray::fromRawData((char*)enc0, sizeof(enc0)));
+
+ range.end = (range.ptr = enc0);
+ g_assert(!HarbourProtoBuf::parseVarInt(&range, NULL));
+ range.end = (range.ptr = enc0);
+
+ res = 42;
+ g_assert(!HarbourProtoBuf::parseVarInt(&range, &res));
+ g_assert_cmpuint(res, == ,0);
+
+ range.end = (range.ptr = enc0) + sizeof(enc0);
+ g_assert(HarbourProtoBuf::parseVarInt(&range, NULL));
+ g_assert(range.ptr == range.end);
+
+ res = 42;
+ range.end = (range.ptr = enc0) + sizeof(enc0);
+ g_assert(HarbourProtoBuf::parseVarInt(&range, &res));
+ g_assert_cmpuint(res, == ,0);
+
+ static const guint8 enc257[] = { 0x82, 0x01 };
+
+ buf.clear();
+ g_assert(HarbourProtoBuf::appendVarInt(&buf, 257) == &buf);
+ g_assert(buf == QByteArray::fromRawData((char*)enc257, sizeof(enc257)));
+
+ res = 42;
+ range.end = (range.ptr = enc257) + 1;
+ g_assert(!HarbourProtoBuf::parseVarInt(&range, &res));
+ g_assert_cmpuint(res, == ,0);
+
+ res = 42;
+ range.end = (range.ptr = enc257) + sizeof(enc257);
+ g_assert(HarbourProtoBuf::parseVarInt(&range, &res));
+ g_assert(range.ptr == range.end);
+ g_assert_cmpuint(res, == ,257);
+}
+
+/*==========================================================================*
+ * delimited
+ *==========================================================================*/
+
+static
+void
+test_delimited(
+ void)
+{
+ QByteArray buf;
+ GUtilRange range;
+ GUtilData payload;
+ static const guint8 value[] = { 0x01, 0x02 };
+ static const guint8 encodedValue[] = { 0x02, 0x01, 0x02 };
+
+ g_assert(HarbourProtoBuf::appendDelimitedValue(&buf,
+ QByteArray::fromRawData((char*)value, sizeof(value))) == &buf);
+ g_assert(buf == QByteArray::fromRawData((char*)encodedValue,
+ sizeof(encodedValue)));
+
+ range.end = (range.ptr = encodedValue);
+ g_assert(!HarbourProtoBuf::parseDelimitedValue(&range, NULL));
+ g_assert(range.ptr == encodedValue);
+
+ range.end = (range.ptr = encodedValue) + sizeof(encodedValue) - 1;
+ g_assert(!HarbourProtoBuf::parseDelimitedValue(&range, NULL));
+ g_assert(range.ptr == encodedValue);
+
+ range.end = (range.ptr = encodedValue) + sizeof(encodedValue);
+ g_assert(HarbourProtoBuf::parseDelimitedValue(&range, NULL));
+
+ memset(&payload, 0, sizeof(payload));
+ range.end = (range.ptr = encodedValue) + sizeof(encodedValue);
+ g_assert(HarbourProtoBuf::parseDelimitedValue(&range, &payload));
+ g_assert_cmpuint(payload.size, == ,sizeof(value));
+ g_assert(!memcmp(payload.bytes, value, sizeof(value)));
+}
+
+/*==========================================================================*
+ * Common
+ *==========================================================================*/
+
+#define TEST_(name) "/HarbourProtoBuf/" name
+
+int main(int argc, char* argv[])
+{
+ g_test_init(&argc, &argv, NULL);
+ g_test_add_func(TEST_("null"), test_null);
+ g_test_add_func(TEST_("int"), test_int);
+ g_test_add_func(TEST_("delimited"), test_delimited);
+ return g_test_run();
+}
+
+/*
+ * Local Variables:
+ * mode: C++
+ * c-basic-offset: 4
+ * indent-tabs-mode: nil
+ * End:
+ */
|
[-]
[+]
|
Added |
_service:tar_git:openrepos-books-1.1.0.tar.gz/harbour-lib/test/TestHarbourUtil/Makefile
^
|
@@ -0,0 +1,8 @@
+# -*- Mode: makefile-gmake -*-
+
+PKGS = Qt5Gui
+EXE = TestHarbourUtil
+MOC_H = HarbourUtil.h
+HARBOUR_SRC = HarbourUtil.cpp
+
+include ../Makefile.common
|
[-]
[+]
|
Added |
_service:tar_git:openrepos-books-1.1.0.tar.gz/harbour-lib/test/TestHarbourUtil/TestHarbourUtil.cpp
^
|
@@ -0,0 +1,115 @@
+/*
+ * Copyright (C) 2022 Jolla Ltd.
+ * Copyright (C) 2022 Slava Monich <slava.monich@jolla.com>
+ *
+ * You may use this file under the terms of the 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:
+ *
+ * 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
+ * distribution.
+ * 3. Neither the names of the copyright holders 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
+ * OWNER 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.
+ */
+
+#include "HarbourUtil.h"
+
+#include <glib.h>
+
+/*==========================================================================*
+ * object
+ *==========================================================================*/
+
+static
+void
+test_object(
+ void)
+{
+ QObject* obj = HarbourUtil::createSingleton(Q_NULLPTR, Q_NULLPTR);
+
+ g_assert(qobject_cast<HarbourUtil*>(obj));
+ delete obj;
+}
+
+/*==========================================================================*
+ * invertColor
+ *==========================================================================*/
+
+static
+void
+test_invertColor(
+ void)
+{
+ g_assert_cmpuint(HarbourUtil::invertedRgb(0x12345678), == ,0x12cba987);
+ const QColor original(0xcb,0xa9,0x87,0x12);
+ const QColor inverted(0x34,0x56,0x78,0x12);
+ g_assert(HarbourUtil::invertedColor(original) == inverted);
+ g_assert(!HarbourUtil::invertedColor(QColor()).isValid());
+}
+
+/*==========================================================================*
+ * toHex
+ *==========================================================================*/
+
+static
+void
+test_toHex(
+ void)
+{
+ static const char data[] = {
+ 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0A,
+ 0x0B, 0x0C, 0x0D, 0x0E, 0x0F, 0x10, 0x11, 0x12, 0x13, 0x14
+ };
+
+ // Lower case is assumed
+ const QByteArray hex("0102030405060708090a0b0c0d0e0f1011121314");
+
+ g_assert(HarbourUtil::toHex(QByteArray()).isEmpty());
+ g_assert(HarbourUtil::toHex(Q_NULLPTR, 0).isEmpty());
+ g_assert(HarbourUtil::toHexBytes(Q_NULLPTR, 0).isEmpty());
+ g_assert(HarbourUtil::toHex(data, sizeof(data)) == QString::fromLatin1(hex));
+ const QByteArray out(HarbourUtil::toHexBytes(data, sizeof(data)));
+ g_assert_cmpstr(out.constData(), == ,hex.constData());
+}
+
+/*==========================================================================*
+ * Common
+ *==========================================================================*/
+
+#define TEST_(name) "/HarbourUtil/" name
+
+int main(int argc, char* argv[])
+{
+ g_test_init(&argc, &argv, NULL);
+ g_test_add_func(TEST_("object"), test_object);
+ g_test_add_func(TEST_("invertColor"), test_invertColor);
+ g_test_add_func(TEST_("toHex"), test_toHex);
+ return g_test_run();
+}
+
+/*
+ * Local Variables:
+ * mode: C++
+ * c-basic-offset: 4
+ * indent-tabs-mode: nil
+ * End:
+ */
|
[-]
[+]
|
Changed |
_service:tar_git:openrepos-books-1.1.0.tar.gz/harbour-lib/test/coverage/run
^
|
@@ -5,7 +5,9 @@
TESTS="\
TestHarbourBase32 \
-TestHarbourBase45"
+TestHarbourBase45 \
+TestHarbourProtoBuf \
+TestHarbourUtil"
function err() {
echo "*** ERROR!" $1
|