Skip to content

Commit

Permalink
Updated databases to be completely U1db free
Browse files Browse the repository at this point in the history
  • Loading branch information
TronFortyTwo committed May 4, 2020
1 parent f0f25f0 commit 581cb08
Show file tree
Hide file tree
Showing 5 changed files with 29 additions and 25 deletions.
2 changes: 1 addition & 1 deletion clickable.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"clickable_minimum_version": "6.12.2",
"clickable_minimum_required": "6.12.2",
"builder": "cmake",
"dependencies_target": [
"intltool",
Expand Down
2 changes: 1 addition & 1 deletion manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,5 @@
"maintainer": "Emanuele Sorce <[email protected]>",
"name": "sturmreader.emanuelesorce",
"title": "Sturm Reader",
"version": "2.1.3"
"version": "2.2.0"
}
2 changes: 2 additions & 0 deletions sturmreader
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
#!/bin/bash
DIR="$( dirname $( readlink -f "${BASH_SOURCE[0]}" ) )"

# launch app
QT_SELECT=5 qmlscene -I "$DIR" "$DIR/ui/main.qml" --appargs="$*"
2 changes: 1 addition & 1 deletion ui/BookPage.qml
Original file line number Diff line number Diff line change
Expand Up @@ -607,7 +607,7 @@ PageWithBottomEdge {
}
primary: false
enabled: !bookStyles.atdefault
onClicked: bookStyles.resetToDefaults()
// onClicked: bookStyles.resetToDefaults()
}
}

Expand Down
46 changes: 24 additions & 22 deletions ui/main.qml
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,19 @@
*
* This file is part of Beru and is distributed under the terms of
* the GPL. See the file COPYING for full details.
*
* Copyright 2020 Emanuele Sorce
*
* This file is part of Sturm Reader and is distributed under the terms of
* the GNU GPLv3. See the file COPYING for full details.
*/

import QtQuick 2.4
import QtQuick 2.9
import QtQuick.LocalStorage 2.0
import QtQuick.Window 2.0
import Ubuntu.Components 1.3
import Ubuntu.Components.Popups 1.3
import U1db 1.0 as U1db
import Qt.labs.settings 1.0
import File 1.0

import "components"
Expand All @@ -22,10 +27,6 @@ MainView {

applicationName: "sturmreader.emanuelesorce"

/*
This property enables the application to change orientation
when the device is rotated. The default is false.
*/
automaticOrientation: true

width: units.gu(200)
Expand Down Expand Up @@ -91,9 +92,9 @@ MainView {
return false
}

function openSettingsDatabase() {
return LocalStorage.openDatabaseSync("BeruSettings", "1", "Global settings for Beru", 10000)
}
function openSettingsDatabase() {
return LocalStorage.openDatabaseSync("BeruSettings", "1", "Global settings for Beru", 100000)
}

function getSetting(key) {
var db = openSettingsDatabase()
Expand All @@ -113,20 +114,20 @@ MainView {
})
}

function sizeChanged() {
setSetting("winsize", JSON.stringify([width, height]))
}

U1db.Database {
id: bookSettingsDatabase
path: "BeruBookSettings.db"
}
Settings {
id: appsettings
category: "appsettings"
property alias x: mainView.x
property alias y: mainView.y
property alias width: mainView.width
property alias height: mainView.height
}

function getBookSetting(key) {
if (server.reader.hash() == "")
return undefined

var settings = bookSettingsDatabase.getDoc(server.reader.hash())
var settings = JSON.parse(mainView.getSetting("book_" + server.reader.hash()))
if (settings == undefined)
return undefined
return settings[key]
Expand Down Expand Up @@ -162,11 +163,11 @@ MainView {
if (hash == null)
return

var settings = bookSettingsDatabase.getDoc(hash)
var settings = JSON.parse(getSetting("book_" + server.reader.hash()))
if (settings == undefined)
settings = {}
settings[key] = value
bookSettingsDatabase.putDoc(settings, hash)
setSetting("book_" + server.reader.hash(), JSON.stringify(settings))
hash = null
}
}
Expand All @@ -192,14 +193,15 @@ MainView {
if (loadFile(filePath))
localBooks.addFile(filePath)
}


/*
onWidthChanged.connect(sizeChanged)
onHeightChanged.connect(sizeChanged)
var size = JSON.parse(getSetting("winsize"))
if (size != null) {
width = size[0]
height = size[1]
}
}*/

localBooks.onMainCompleted()
}
Expand Down

0 comments on commit 581cb08

Please sign in to comment.