added simple login page and about page, not functional yet, since i have to code the javascript
This commit is contained in:
parent
7a0b160c89
commit
039b3024cb
6 changed files with 630 additions and 29 deletions
123
qml/ttrss/About.qml
Normal file
123
qml/ttrss/About.qml
Normal file
|
|
@ -0,0 +1,123 @@
|
|||
//Copyright Hauke Schade, 2012
|
||||
//
|
||||
//This file is part of TTRss.
|
||||
//
|
||||
//TTRss is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the
|
||||
//Free Software Foundation, either version 2 of the License, or (at your option) any later version.
|
||||
//TTRss is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
//MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
|
||||
//You should have received a copy of the GNU General Public License along with TTRss (on a Maemo/Meego system there is a copy
|
||||
//in /usr/share/common-licenses. If not, see http://www.gnu.org/licenses/.
|
||||
|
||||
import QtQuick 1.1
|
||||
import com.nokia.meego 1.0
|
||||
import QtWebKit 1.0
|
||||
|
||||
Page {
|
||||
tools: aboutTools
|
||||
|
||||
state: (screen.currentOrientation === Screen.Portrait) ? "portrait" : "landscape"
|
||||
|
||||
states: [
|
||||
State {
|
||||
name: "landscape"
|
||||
PropertyChanges {
|
||||
target: logo
|
||||
anchors.leftMargin: 50
|
||||
anchors.topMargin: 50
|
||||
}
|
||||
AnchorChanges {
|
||||
target: logo
|
||||
anchors {
|
||||
horizontalCenter: undefined
|
||||
|
||||
left: parent.left
|
||||
top: parent.top
|
||||
}
|
||||
}
|
||||
AnchorChanges {
|
||||
target: aboutInfoContainer
|
||||
anchors {
|
||||
horizontalCenter: undefined
|
||||
|
||||
left: logo.right
|
||||
top: logo.top
|
||||
}
|
||||
}
|
||||
PropertyChanges {
|
||||
target: aboutInfoContainer
|
||||
anchors.leftMargin: 50
|
||||
}
|
||||
},
|
||||
State {
|
||||
name: "portrait"
|
||||
AnchorChanges {
|
||||
target: logo
|
||||
anchors {
|
||||
left: undefined
|
||||
|
||||
top: parent.top
|
||||
horizontalCenter: parent.horizontalCenter
|
||||
}
|
||||
}
|
||||
AnchorChanges {
|
||||
target: aboutInfoContainer
|
||||
anchors {
|
||||
left: undefined
|
||||
|
||||
top: logo.bottom
|
||||
horizontalCenter: parent.horizontalCenter
|
||||
}
|
||||
}
|
||||
PropertyChanges {
|
||||
target: aboutInfoContainer
|
||||
anchors.topMargin: 50
|
||||
}
|
||||
}
|
||||
]
|
||||
|
||||
transitions: Transition {
|
||||
AnchorAnimation { duration: 500 }
|
||||
}
|
||||
|
||||
|
||||
Column {
|
||||
id: logo
|
||||
anchors {
|
||||
top: parent.top
|
||||
topMargin: 30
|
||||
}
|
||||
|
||||
Image {
|
||||
width: 398
|
||||
height: 225
|
||||
source: "resources/ttrsslogo.png"
|
||||
}
|
||||
}
|
||||
|
||||
Column {
|
||||
id: aboutInfoContainer
|
||||
|
||||
|
||||
Label {
|
||||
id: aboutInfo
|
||||
width: 350
|
||||
text: qsTr("Version")+": 0.0.1<br/>"
|
||||
+qsTr("Copyright")+": Hauke Schade 2012<br/>"
|
||||
+'<a href="http://github.com/cnlpete/ttrss">'+qsTr('TTRss Privacy Policy')+'</a><br/>';
|
||||
onLinkActivated: {
|
||||
Qt.openUrlExternally(link)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
ToolBarLayout {
|
||||
id: aboutTools
|
||||
|
||||
ToolIcon {
|
||||
iconId: "toolbar-back";
|
||||
onClicked: { pageStack.pop(); }
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -1,23 +1,248 @@
|
|||
//Copyright Hauke Schade, 2012
|
||||
//
|
||||
//This file is part of TTRss.
|
||||
//
|
||||
//TTRss is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the
|
||||
//Free Software Foundation, either version 2 of the License, or (at your option) any later version.
|
||||
//TTRss is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
//MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
|
||||
//You should have received a copy of the GNU General Public License along with TTRss (on a Maemo/Meego system there is a copy
|
||||
//in /usr/share/common-licenses. If not, see http://www.gnu.org/licenses/.
|
||||
|
||||
import QtQuick 1.1
|
||||
import com.nokia.meego 1.0
|
||||
|
||||
Page {
|
||||
function openFile(file) {
|
||||
var component = Qt.createComponent(file)
|
||||
if (component.status === Component.Ready)
|
||||
pageStack.push(component);
|
||||
else
|
||||
console.log("Error loading component:", component.errorString());
|
||||
}
|
||||
|
||||
property bool loading: false
|
||||
|
||||
tools: commonTools
|
||||
|
||||
Label {
|
||||
id: label
|
||||
anchors.centerIn: parent
|
||||
text: qsTr("Hello world!")
|
||||
visible: false
|
||||
state: (screen.currentOrientation === Screen.Portrait) ? "portrait" : "landscape"
|
||||
|
||||
states: [
|
||||
State {
|
||||
name: "landscape"
|
||||
PropertyChanges {
|
||||
target: logo
|
||||
anchors.leftMargin: 50
|
||||
anchors.topMargin: 50
|
||||
}
|
||||
AnchorChanges {
|
||||
target: logo
|
||||
anchors {
|
||||
horizontalCenter: undefined
|
||||
|
||||
left: parent.left
|
||||
top: parent.top
|
||||
}
|
||||
}
|
||||
AnchorChanges {
|
||||
target: loginBox
|
||||
anchors {
|
||||
horizontalCenter: undefined
|
||||
|
||||
left: logo.right
|
||||
top: logo.top
|
||||
}
|
||||
}
|
||||
PropertyChanges {
|
||||
target: loginBox
|
||||
anchors.leftMargin: 50
|
||||
}
|
||||
},
|
||||
State {
|
||||
name: "portrait"
|
||||
AnchorChanges {
|
||||
target: logo
|
||||
anchors {
|
||||
left: undefined
|
||||
|
||||
top: parent.top
|
||||
horizontalCenter: parent.horizontalCenter
|
||||
}
|
||||
}
|
||||
AnchorChanges {
|
||||
target: loginBox
|
||||
anchors {
|
||||
left: undefined
|
||||
|
||||
top: logo.bottom
|
||||
horizontalCenter: parent.horizontalCenter
|
||||
}
|
||||
}
|
||||
PropertyChanges {
|
||||
target: loginBox
|
||||
anchors.topMargin: 50
|
||||
}
|
||||
}
|
||||
]
|
||||
|
||||
transitions: Transition {
|
||||
AnchorAnimation { duration: 500 }
|
||||
}
|
||||
|
||||
Button{
|
||||
Column {
|
||||
id: logo
|
||||
anchors {
|
||||
top: parent.top
|
||||
topMargin: 30
|
||||
}
|
||||
|
||||
Image {
|
||||
width: 398
|
||||
height: 225
|
||||
source: "resources/ttrsslogo.png"
|
||||
}
|
||||
}
|
||||
|
||||
Column {
|
||||
id: loginBox
|
||||
|
||||
Label {
|
||||
id: serverLabel
|
||||
text: qsTr("Server:")
|
||||
}
|
||||
TextField {
|
||||
id: server
|
||||
text: ""
|
||||
width: 300
|
||||
enabled: !loading
|
||||
}
|
||||
Label {
|
||||
id: usernameLabel
|
||||
text: qsTr("Username:")
|
||||
}
|
||||
TextField {
|
||||
id: username
|
||||
text: ""
|
||||
width: 300
|
||||
enabled: !loading
|
||||
}
|
||||
Label {
|
||||
id: passwordLabel
|
||||
text: qsTr("Password:")
|
||||
}
|
||||
TextField {
|
||||
id: password
|
||||
echoMode: TextInput.PasswordEchoOnEdit
|
||||
width: 300
|
||||
enabled: !loading
|
||||
}
|
||||
}
|
||||
BusyIndicator {
|
||||
id: busyindicator1
|
||||
visible: loading
|
||||
running: loading
|
||||
anchors {
|
||||
horizontalCenter: parent.horizontalCenter
|
||||
top: label.bottom
|
||||
topMargin: 10
|
||||
verticalCenter: parent.verticalCenter
|
||||
}
|
||||
platformStyle: BusyIndicatorStyle { size: 'large' }
|
||||
}
|
||||
|
||||
ToolBarLayout {
|
||||
id: commonTools
|
||||
visible: true
|
||||
ToolButton {
|
||||
id: loginButton
|
||||
text: qsTr("Login")
|
||||
anchors.right: menuButton.left
|
||||
onClicked: {
|
||||
var settings = rootWindow.settingsObject();
|
||||
settings.set("server", server.text);
|
||||
settings.set("username", username.text);
|
||||
settings.set("password", password.text);
|
||||
|
||||
startLogin();
|
||||
}
|
||||
enabled: !loading
|
||||
}
|
||||
ToolIcon {
|
||||
id: menuButton
|
||||
platformIconId: "toolbar-view-menu"
|
||||
anchors.right: (parent === undefined) ? undefined : parent.right
|
||||
onClicked: (myMenu.status === DialogStatus.Closed) ? myMenu.open() : myMenu.close()
|
||||
enabled: !loading
|
||||
}
|
||||
}
|
||||
|
||||
Menu {
|
||||
id: myMenu
|
||||
visualParent: pageStack
|
||||
MenuLayout {
|
||||
MenuItem {
|
||||
text: qsTr("About")
|
||||
onClicked: {
|
||||
openFile("About.qml");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function enableLoginBox(focus) {
|
||||
if(focus) {
|
||||
password.forceActiveFocus();
|
||||
}
|
||||
}
|
||||
|
||||
function startLogin() {
|
||||
// close the menu
|
||||
if (myMenu.status !== DialogStatus.Closed)
|
||||
myMenu.close()
|
||||
|
||||
//Start the loading anim
|
||||
loading = true;
|
||||
|
||||
}
|
||||
|
||||
//Dialog for login errors
|
||||
Dialog {
|
||||
id: loginErrorDialog
|
||||
title: Rectangle {
|
||||
id: titleField
|
||||
height: 2
|
||||
width: parent.width
|
||||
color: "red"
|
||||
}
|
||||
|
||||
content:Item {
|
||||
id: loginErrorDialogContents
|
||||
height: 50
|
||||
width: parent.width
|
||||
Text {
|
||||
id: loginErrorDialogText
|
||||
font.pixelSize: 22
|
||||
anchors.centerIn: parent
|
||||
color: "white"
|
||||
text: "Hello Dialog"
|
||||
}
|
||||
}
|
||||
|
||||
buttons: ButtonRow {
|
||||
style: ButtonStyle { }
|
||||
anchors.horizontalCenter: parent.horizontalCenter
|
||||
Button { text: "OK"; onClicked: loginErrorDialog.accept() }
|
||||
}
|
||||
}
|
||||
|
||||
Component.onCompleted: {
|
||||
var settings = rootWindow.settingsObject();
|
||||
settings.initialize();
|
||||
server.text = settings.get("server", "http://");
|
||||
username.text = settings.get("username", "");
|
||||
password.text = settings.get("password", "");
|
||||
var dologin = settings.get("dologin", "false");
|
||||
|
||||
if(dologin === "true") {
|
||||
startLogin();
|
||||
}
|
||||
text: qsTr("Click here!")
|
||||
onClicked: label.visible = true
|
||||
}
|
||||
}
|
||||
|
|
|
|||
35
qml/ttrss/dump.js
Normal file
35
qml/ttrss/dump.js
Normal file
|
|
@ -0,0 +1,35 @@
|
|||
/**
|
||||
* Function : dump()
|
||||
* Arguments: The data - array,hash(associative array),object
|
||||
* The level - OPTIONAL
|
||||
* Returns : The textual representation of the array.
|
||||
* This function was inspired by the print_r function of PHP.
|
||||
* This will accept some data as the argument and return a
|
||||
* text that will be a more readable version of the
|
||||
* array/hash/object that is given.
|
||||
* Docs: http://www.openjs.com/scripts/others/dump_function_php_print_r.php
|
||||
*/
|
||||
function dump(arr,level) {
|
||||
var dumped_text = "";
|
||||
if(!level) level = 0;
|
||||
|
||||
//The padding given at the beginning of the line.
|
||||
var level_padding = "";
|
||||
for(var j=0;j<level+1;j++) level_padding += " ";
|
||||
|
||||
if(typeof(arr) == 'object') { //Array/Hashes/Objects
|
||||
for(var item in arr) {
|
||||
var value = arr[item];
|
||||
|
||||
if(typeof(value) == 'object') { //If it is an array,
|
||||
dumped_text += level_padding + "'" + item + "' ...\n";
|
||||
dumped_text += dump(value,level+1);
|
||||
} else {
|
||||
dumped_text += level_padding + "'" + item + "' => \"" + value + "\"\n";
|
||||
}
|
||||
}
|
||||
} else { //Stings/Chars/Numbers etc.
|
||||
dumped_text = "===>"+arr+"<===("+typeof(arr)+")";
|
||||
}
|
||||
return dumped_text;
|
||||
}
|
||||
171
qml/ttrss/htmlentities.js
Normal file
171
qml/ttrss/htmlentities.js
Normal file
|
|
@ -0,0 +1,171 @@
|
|||
|
||||
function get_html_translation_table (table, quote_style) {
|
||||
// Returns the internal translation table used by htmlspecialchars and htmlentities
|
||||
//
|
||||
// version: 1109.2015
|
||||
// discuss at: http://phpjs.org/functions/get_html_translation_table // + original by: Philip Peterson
|
||||
// + revised by: Kevin van Zonneveld (http://kevin.vanzonneveld.net)
|
||||
// + bugfixed by: noname
|
||||
// + bugfixed by: Alex
|
||||
// + bugfixed by: Marco // + bugfixed by: madipta
|
||||
// + improved by: KELAN
|
||||
// + improved by: Brett Zamir (http://brett-zamir.me)
|
||||
// + bugfixed by: Brett Zamir (http://brett-zamir.me)
|
||||
// + input by: Frank Forte // + bugfixed by: T.Wild
|
||||
// + input by: Ratheous
|
||||
// % note: It has been decided that we're not going to add global
|
||||
// % note: dependencies to php.js, meaning the constants are not
|
||||
// % note: real constants, but strings instead. Integers are also supported if someone // % note: chooses to create the constants themselves.
|
||||
// * example 1: get_html_translation_table('HTML_SPECIALCHARS');
|
||||
// * returns 1: {'"': '"', '&': '&', '<': '<', '>': '>'}
|
||||
var entities = {},
|
||||
hash_map = {}, decimal;
|
||||
var constMappingTable = {},
|
||||
constMappingQuoteStyle = {};
|
||||
var useTable = {},
|
||||
useQuoteStyle = {};
|
||||
// Translate arguments
|
||||
constMappingTable[0] = 'HTML_SPECIALCHARS';
|
||||
constMappingTable[1] = 'HTML_ENTITIES';
|
||||
constMappingQuoteStyle[0] = 'ENT_NOQUOTES'; constMappingQuoteStyle[2] = 'ENT_COMPAT';
|
||||
constMappingQuoteStyle[3] = 'ENT_QUOTES';
|
||||
|
||||
useTable = !isNaN(table) ? constMappingTable[table] : table ? table.toUpperCase() : 'HTML_SPECIALCHARS';
|
||||
useQuoteStyle = !isNaN(quote_style) ? constMappingQuoteStyle[quote_style] : quote_style ? quote_style.toUpperCase() : 'ENT_COMPAT';
|
||||
if (useTable !== 'HTML_SPECIALCHARS' && useTable !== 'HTML_ENTITIES') {
|
||||
throw new Error("Table: " + useTable + ' not supported');
|
||||
// return false;
|
||||
}
|
||||
entities['38'] = '&';
|
||||
if (useTable === 'HTML_ENTITIES') {
|
||||
entities['160'] = ' ';
|
||||
entities['161'] = '¡'; entities['162'] = '¢';
|
||||
entities['163'] = '£';
|
||||
entities['164'] = '¤';
|
||||
entities['165'] = '¥';
|
||||
entities['166'] = '¦'; entities['167'] = '§';
|
||||
entities['168'] = '¨';
|
||||
entities['169'] = '©';
|
||||
entities['170'] = 'ª';
|
||||
entities['171'] = '«'; entities['172'] = '¬';
|
||||
entities['173'] = '­';
|
||||
entities['174'] = '®';
|
||||
entities['175'] = '¯';
|
||||
entities['176'] = '°'; entities['177'] = '±';
|
||||
entities['178'] = '²';
|
||||
entities['179'] = '³';
|
||||
entities['180'] = '´';
|
||||
entities['181'] = 'µ'; entities['182'] = '¶';
|
||||
entities['183'] = '·';
|
||||
entities['184'] = '¸';
|
||||
entities['185'] = '¹';
|
||||
entities['186'] = 'º'; entities['187'] = '»';
|
||||
entities['188'] = '¼';
|
||||
entities['189'] = '½';
|
||||
entities['190'] = '¾';
|
||||
entities['191'] = '¿'; entities['192'] = 'À';
|
||||
entities['193'] = 'Á';
|
||||
entities['194'] = 'Â';
|
||||
entities['195'] = 'Ã';
|
||||
entities['196'] = 'Ä'; entities['197'] = 'Å';
|
||||
entities['198'] = 'Æ';
|
||||
entities['199'] = 'Ç';
|
||||
entities['200'] = 'È';
|
||||
entities['201'] = 'É'; entities['202'] = 'Ê';
|
||||
entities['203'] = 'Ë';
|
||||
entities['204'] = 'Ì';
|
||||
entities['205'] = 'Í';
|
||||
entities['206'] = 'Î'; entities['207'] = 'Ï';
|
||||
entities['208'] = 'Ð';
|
||||
entities['209'] = 'Ñ';
|
||||
entities['210'] = 'Ò';
|
||||
entities['211'] = 'Ó'; entities['212'] = 'Ô';
|
||||
entities['213'] = 'Õ';
|
||||
entities['214'] = 'Ö';
|
||||
entities['215'] = '×';
|
||||
entities['216'] = 'Ø'; entities['217'] = 'Ù';
|
||||
entities['218'] = 'Ú';
|
||||
entities['219'] = 'Û';
|
||||
entities['220'] = 'Ü';
|
||||
entities['221'] = 'Ý'; entities['222'] = 'Þ';
|
||||
entities['223'] = 'ß';
|
||||
entities['224'] = 'à';
|
||||
entities['225'] = 'á';
|
||||
entities['226'] = 'â'; entities['227'] = 'ã';
|
||||
entities['228'] = 'ä';
|
||||
entities['229'] = 'å';
|
||||
entities['230'] = 'æ';
|
||||
entities['231'] = 'ç'; entities['232'] = 'è';
|
||||
entities['233'] = 'é';
|
||||
entities['234'] = 'ê';
|
||||
entities['235'] = 'ë';
|
||||
entities['236'] = 'ì'; entities['237'] = 'í';
|
||||
entities['238'] = 'î';
|
||||
entities['239'] = 'ï';
|
||||
entities['240'] = 'ð';
|
||||
entities['241'] = 'ñ'; entities['242'] = 'ò';
|
||||
entities['243'] = 'ó';
|
||||
entities['244'] = 'ô';
|
||||
entities['245'] = 'õ';
|
||||
entities['246'] = 'ö'; entities['247'] = '÷';
|
||||
entities['248'] = 'ø';
|
||||
entities['249'] = 'ù';
|
||||
entities['250'] = 'ú';
|
||||
entities['251'] = 'û'; entities['252'] = 'ü';
|
||||
entities['253'] = 'ý';
|
||||
entities['254'] = 'þ';
|
||||
entities['255'] = 'ÿ';
|
||||
}
|
||||
if (useQuoteStyle !== 'ENT_NOQUOTES') {
|
||||
entities['34'] = '"';
|
||||
}
|
||||
if (useQuoteStyle === 'ENT_QUOTES') { entities['39'] = ''';
|
||||
}
|
||||
entities['60'] = '<';
|
||||
entities['62'] = '>';
|
||||
|
||||
// ascii decimals to real symbols
|
||||
for (decimal in entities) {
|
||||
if (entities.hasOwnProperty(decimal)) {
|
||||
hash_map[String.fromCharCode(decimal)] = entities[decimal]; }
|
||||
}
|
||||
|
||||
return hash_map;
|
||||
}
|
||||
|
||||
function html_entity_decode (string, quote_style) {
|
||||
// Convert all HTML entities to their applicable characters
|
||||
//
|
||||
// version: 1109.2015
|
||||
// discuss at: http://phpjs.org/functions/html_entity_decode // + original by: john (http://www.jd-tech.net)
|
||||
// + input by: ger
|
||||
// + improved by: Kevin van Zonneveld (http://kevin.vanzonneveld.net)
|
||||
// + revised by: Kevin van Zonneveld (http://kevin.vanzonneveld.net)
|
||||
// + bugfixed by: Onno Marsman // + improved by: marc andreu
|
||||
// + revised by: Kevin van Zonneveld (http://kevin.vanzonneveld.net)
|
||||
// + input by: Ratheous
|
||||
// + bugfixed by: Brett Zamir (http://brett-zamir.me)
|
||||
// + input by: Nick Kolosov (http://sammy.ru) // + bugfixed by: Fox
|
||||
// - depends on: get_html_translation_table
|
||||
// * example 1: html_entity_decode('Kevin & van Zonneveld');
|
||||
// * returns 1: 'Kevin & van Zonneveld'
|
||||
// * example 2: html_entity_decode('&lt;'); // * returns 2: '<'
|
||||
var hash_map = {},
|
||||
symbol = '',
|
||||
tmp_str = '',
|
||||
entity = ''; tmp_str = string.toString();
|
||||
|
||||
if (false === (hash_map = this.get_html_translation_table('HTML_ENTITIES', quote_style))) {
|
||||
return false;
|
||||
}
|
||||
// fix & problem
|
||||
// http://phpjs.org/functions/get_html_translation_table:416#comment_97660
|
||||
delete(hash_map['&']);
|
||||
hash_map['&'] = '&';
|
||||
for (symbol in hash_map) {
|
||||
entity = hash_map[symbol];
|
||||
tmp_str = tmp_str.split(entity).join(symbol);
|
||||
} tmp_str = tmp_str.split(''').join("'");
|
||||
|
||||
return tmp_str;
|
||||
}
|
||||
|
|
@ -1,30 +1,28 @@
|
|||
//Copyright Hauke Schade, 2012
|
||||
//
|
||||
//This file is part of TTRss.
|
||||
//
|
||||
//TTRss is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the
|
||||
//Free Software Foundation, either version 2 of the License, or (at your option) any later version.
|
||||
//TTRss is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
//MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
|
||||
//You should have received a copy of the GNU General Public License along with TTRss (on a Maemo/Meego system there is a copy
|
||||
//in /usr/share/common-licenses. If not, see http://www.gnu.org/licenses/.
|
||||
|
||||
import QtQuick 1.1
|
||||
import com.nokia.meego 1.0
|
||||
import "settings.js" as Settings
|
||||
|
||||
PageStackWindow {
|
||||
id: appWindow
|
||||
id: rootWindow
|
||||
|
||||
function settingsObject() {
|
||||
return Settings;
|
||||
}
|
||||
|
||||
initialPage: mainPage
|
||||
|
||||
MainPage {
|
||||
id: mainPage
|
||||
}
|
||||
|
||||
ToolBarLayout {
|
||||
id: commonTools
|
||||
visible: true
|
||||
ToolIcon {
|
||||
platformIconId: "toolbar-view-menu"
|
||||
anchors.right: (parent === undefined) ? undefined : parent.right
|
||||
onClicked: (myMenu.status === DialogStatus.Closed) ? myMenu.open() : myMenu.close()
|
||||
}
|
||||
}
|
||||
|
||||
Menu {
|
||||
id: myMenu
|
||||
visualParent: pageStack
|
||||
MenuLayout {
|
||||
MenuItem { text: qsTr("Sample menu item") }
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
49
qml/ttrss/settings.js
Normal file
49
qml/ttrss/settings.js
Normal file
|
|
@ -0,0 +1,49 @@
|
|||
//Based on the example code at:
|
||||
//http://www.developer.nokia.com/Community/Wiki/How-to_create_a_persistent_settings_database_in_Qt_Quick_%28QML%29
|
||||
|
||||
function getDatabase() {
|
||||
return openDatabaseSync("TTRssGo", "1.0", "Saved state for TTRssGo", 1000);
|
||||
}
|
||||
|
||||
// At the start of the application, we can initialize the tables we need if they haven't been created yet
|
||||
function initialize() {
|
||||
var db = getDatabase();
|
||||
db.transaction(
|
||||
function(tx) {
|
||||
// Create the settings table if it doesn't already exist
|
||||
// If the table exists, this is skipped
|
||||
tx.executeSql('CREATE TABLE IF NOT EXISTS settings(setting TEXT UNIQUE, value TEXT)');
|
||||
});
|
||||
}
|
||||
|
||||
// This function is used to write a setting into the database
|
||||
function set(setting, value) {
|
||||
// setting: string representing the setting name (eg: “username”)
|
||||
// value: string representing the value of the setting (eg: “myUsername”)
|
||||
var db = getDatabase();
|
||||
var success = false;
|
||||
|
||||
db.transaction(function(tx) {
|
||||
var rs = tx.executeSql('INSERT OR REPLACE INTO settings VALUES (?,?);', [setting,value]);
|
||||
//console.log(rs.rowsAffected)
|
||||
if (rs.rowsAffected > 0) {
|
||||
success = true;
|
||||
}
|
||||
});
|
||||
// The function returns true if it was successful, or false if it wasn't
|
||||
return success;
|
||||
}
|
||||
// This function is used to retrieve a setting from the database
|
||||
function get(setting, defaultValue) {
|
||||
var db = getDatabase();
|
||||
var result = defaultValue;
|
||||
|
||||
db.transaction(function(tx) {
|
||||
var rs = tx.executeSql('SELECT value FROM settings WHERE setting=?;', [setting]);
|
||||
if (rs.rows.length > 0) {
|
||||
result = rs.rows.item(0).value;
|
||||
}});
|
||||
|
||||
// The function returns defaultValue if no setting is found
|
||||
return result;
|
||||
}
|
||||
Loading…
Add table
Reference in a new issue