Commit 09254bd0 authored by Martin Straka's avatar Martin Straka
Browse files

Added new style of settings page - without menu (issue #32)

parent d22fc5d4
......@@ -51,8 +51,11 @@ ApplicationWindow {
property Component messageDetailPage: MessageDetailPage {}
property Component accountDetailPage: AccountDetailPage {}
property Component accountSettingsPage: AccountSettingsPage {}
property Component settingsPage: SettingsPage {}
property Component aboutPage: AboutPage {}
property Component settingsMainPage: SettingsMainPage {}
property Component settingsGeneralPage: SettingsGeneralPage {}
property Component settingsSyncPage: SettingsSyncPage {}
property Component settingsStoragePage: SettingsStoragePage {}
property Component pinPage: PinPage {}
......@@ -69,7 +72,7 @@ ApplicationWindow {
property int listItemHeight: headerHeight * 1.5
property int defaultMargin: Math.round(Screen.pixelDensity)
property int acntListSpacing: defaultMargin * 2
property int formItemVerticalSpacing: defaultMargin * 2
property int formItemVerticalSpacing: defaultMargin * 3
property int formButtonHorizontalSpacing: defaultMargin * 5
// message type = must correspond with common.h
property int receivedMESSAGE: 1
......
......@@ -70,7 +70,7 @@ Component {
}
Label {
id: pageLabel
text: qsTr("Create a new account")
text: qsTr("Add a new account")
anchors.verticalCenter: parent.verticalCenter
anchors.left: backElement.right
anchors.leftMargin: defaultMargin
......
......@@ -85,47 +85,10 @@ Component {
anchors.verticalCenter: parent.verticalCenter
sourceSize.height: imgHeight
source: "qrc:/ui/settings.svg"
Menu {
id: mainContextMenu
implicitWidth: 800 // Chosen to be large enough
MenuItem {
text: qsTr("Add account")
onTriggered: {
gUserName = ""
pageView.push(accountSettingsPage, StackView.Immediate)
}
}
MenuItem {
id: vacuumAllMenu
text: qsTr("Clean up databases")
onTriggered: {
statusBarText.text = ""
files.vacuumFileDbs()
}
}
MenuItem {
text: qsTr("Settings")
onTriggered: {
gUserName = ""
pageView.push(settingsPage, StackView.Immediate)
}
}
MenuItem {
text: qsTr("PIN")
onTriggered: {
gUserName = ""
pageView.push(pinPage, StackView.Immediate)
}
}
}
MouseArea {
anchors.fill: parent
onClicked: {
mainContextMenu.implicitWidth = computeMenuWidth(mainContextMenu)
// Located in right top corner.
mainContextMenu.x = mouse.x - mainContextMenu.width
mainContextMenu.y = mouse.y
mainContextMenu.open()
pageView.push(settingsMainPage, StackView.Immediate)
}
}
}
......
/*
* Copyright (C) 2014-2016 CZ.NIC
*
* This program 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 3 of the License, or
* (at your option) any later version.
*
* This program 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 this program. If not, see <http://www.gnu.org/licenses/>.
*
* In addition, as a special exception, the copyright holders give
* permission to link the code of portions of this program with the
* OpenSSL library under certain conditions as described in each
* individual source file, and distribute linked combinations including
* the two.
*/
import QtQuick 2.7
import QtQuick.Controls 2.0
Component {
id: settingsDialog
Item {
id: mainLayout
property string sectionName: "general"
Component.onCompleted: {
settings.loadSettings(sectionName)
}
property string sLang: "cs"
property int myWidht: mainLayout.width - 2 * defaultMargin
Rectangle {
id: header
anchors.top: parent.top
width: parent.width
height: headerHeight
color: datovkaPalette.highlight
Image {
id: backElement
anchors.verticalCenter: parent.verticalCenter
anchors.left: parent.left
anchors.leftMargin: defaultMargin
sourceSize.height: navImgHeight
source: "qrc:/ui/back.svg"
}
Rectangle {
anchors.left: parent.left
width: parent.width * 0.5
height: parent.height
color: "transparent"
MouseArea {
anchors.fill: parent
onClicked: {
pageView.pop(StackView.Immediate)
}
}
}
Label {
text: qsTr("General settings")
anchors.verticalCenter: parent.verticalCenter
anchors.left: backElement.right
anchors.leftMargin: defaultMargin
font.bold: true
color: datovkaPalette.text
}
Row {
anchors.verticalCenter: parent.verticalCenter
spacing: defaultMargin
anchors.right: parent.right
anchors.rightMargin: defaultMargin
Image {
id: actionButton
anchors.verticalCenter: parent.verticalCenter
sourceSize.height: imgHeight
source: "qrc:/ui/checkbox-marked-circle.svg"
MouseArea {
anchors.fill: parent
onClicked: {
/* TODO - Must be replaced via better solution in the future. */
settings.saveSettingsRequest(sectionName)
}
}
}
}
}
Rectangle {
anchors.top: header.bottom
anchors.bottom: parent.bottom
width: parent.width
color: "transparent"
Component {
id: settingsComponent
Column {
spacing: formItemVerticalSpacing
Column {
spacing: 4
Label {
color: datovkaPalette.text
text: qsTr("Language")
}
ComboBox {
id: languageComboBoxId
currentIndex: 0
width: myWidht
textRole: "key"
model: ListModel {
id: langMethodModel
// Don't change position of list elements, keys and values.
ListElement { key: qsTr("System"); value: "system" }
ListElement { key: qsTr("Czech"); value: "cs" }
ListElement { key: qsTr("English"); value: "en" }
}
onCurrentIndexChanged: sLang = langMethodModel.get(currentIndex).value
}
Text {
color: datovkaPalette.mid
width: myWidht
text: qsTr("Note: Language will be changed after application restart.")
wrapMode: Text.Wrap
}
}
Column {
spacing: 1
Label {
id: fontSizeLabel
color: datovkaPalette.text
width: myWidht
text: qsTr("Font size and application scale")
}
SpinBox {
/* Actually holds font pixel size. */
id: fontSizeSpinBox
property int dflt: 16
from: 10
to: 20
stepSize: 1
function val() {
return value
}
function setVal(v) {
if (v < from) {
value = from
} else if (v > to) {
value = to
} else {
value = v
}
}
}
Text {
color: datovkaPalette.mid
width: myWidht
text: qsTr("Note: Font size will be changed after application restart. Default is %1.").arg(fontSizeSpinBox.dflt)
wrapMode: Text.Wrap
}
}
Connections {
target: settings
onSendSettingsGeneralData: {
languageComboBoxId.currentIndex = langIndex
fontSizeSpinBox.setVal(fontSize)
}
}
Connections {
target: settings
/* TODO - Must be replaced via better solution in the future. */
onSaveSettingsGeneralResponse: {
settings.updateSettingsGeneral(sLang,
fontSizeSpinBox.val().toString())
pageView.pop(StackView.Immediate)
}
}
}
}
ListModel {
id: settingsModel
ListElement {
text: ""
}
}
ListView {
id: settingsList
anchors.fill: parent
anchors.margins: defaultMargin
clip: true
spacing: 0
opacity: 1
visible: true
interactive: true
model: settingsModel
delegate: settingsComponent
}
}
}
}
/*
* Copyright (C) 2014-2016 CZ.NIC
*
* This program 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 3 of the License, or
* (at your option) any later version.
*
* This program 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 this program. If not, see <http://www.gnu.org/licenses/>.
*
* In addition, as a special exception, the copyright holders give
* permission to link the code of portions of this program with the
* OpenSSL library under certain conditions as described in each
* individual source file, and distribute linked combinations including
* the two.
*/
import QtQuick 2.7
import QtQuick.Controls 2.0
import QtQuick.Window 2.1
import QtQuick.Layouts 1.2
import QtQuick.Dialogs 1.2
import QtGraphicalEffects 1.0
Component {
id: mainSettingsDialog
Item {
id: mainLayout
property int myWidht: mainLayout.width - 2 * defaultMargin
Rectangle {
id: header
anchors.top: parent.top
width: parent.width
height: headerHeight
color: datovkaPalette.highlight
Image {
id: backElement
anchors.verticalCenter: parent.verticalCenter
anchors.left: parent.left
anchors.leftMargin: defaultMargin
sourceSize.height: navImgHeight
source: "qrc:/ui/back.svg"
}
Rectangle {
anchors.left: parent.left
width: parent.width * 0.5
height: parent.height
color: "transparent"
MouseArea {
anchors.fill: parent
onClicked: {
pageView.pop(StackView.Immediate)
}
}
}
Label {
text: qsTr("Datovka settings")
anchors.verticalCenter: parent.verticalCenter
anchors.left: backElement.right
anchors.leftMargin: defaultMargin
font.bold: true
color: datovkaPalette.text
}
}
Rectangle {
anchors.top: header.bottom
anchors.bottom: parent.bottom
width: parent.width
color: "transparent"
ListModel {
id: settingsListModel
ListElement {
// id: addAccountItem
index: 1
name: qsTr("Add account")
image: "qrc:/ui/account-plus.svg"
}
ListElement {
// id:generalItem
index: 2
name: qsTr("General")
image: "qrc:/ui/settings.svg"
}
ListElement {
// id: syncItem
index: 3
name: qsTr("Synchronization")
image: "qrc:/ui/sync-all.svg"
}
ListElement {
// id: storageItem
index: 4
name: qsTr("Storage")
image: "qrc:/ui/database.svg"
}
ListElement {
// id: securityItem
index: 5
name: qsTr("Security and PIN")
image: "qrc:/ui/key-variant.svg"
}
}
Component {
id: settingsComponent
Rectangle {
color: datovkaPalette.base
height: headerHeight
width: parent.width
Image {
id: msgSentImage
anchors.verticalCenter: parent.verticalCenter
anchors.left: parent.left
anchors.leftMargin: defaultMargin
sourceSize.height: imgHeight * 0.7
source: image
}
ColorOverlay {
anchors.fill: msgSentImage
source: msgSentImage
color: datovkaPalette.text
}
Text {
anchors.verticalCenter: parent.verticalCenter
anchors.left: msgSentImage.right
anchors.leftMargin: defaultMargin
color: datovkaPalette.text
text: name
}
Rectangle {
id: next2
anchors.verticalCenter: parent.verticalCenter
anchors.right: parent.right
height: parent.height
width: parent.width * 0.07
color: parent.color
Image {
id: nextImage2
anchors.verticalCenter: parent.verticalCenter
anchors.right: parent.right
anchors.rightMargin: defaultMargin
sourceSize.height: navImgHeight
source: "qrc:/ui/next.svg"
}
ColorOverlay {
anchors.fill: nextImage2
source: nextImage2
color: datovkaPalette.text
}
}
MouseArea {
anchors.fill: parent
onClicked: {
if (index == 1) {
pageView.push(accountSettingsPage, StackView.Immediate)
} else if (index == 2) {
pageView.push(settingsGeneralPage, StackView.Immediate)
} else if (index == 3) {
pageView.push(settingsSyncPage, StackView.Immediate)
} else if (index == 4) {
pageView.push(settingsStoragePage, StackView.Immediate)
} else if (index == 5) {
pageView.push(pinPage, StackView.Immediate)
} else {
pageView.pop(StackView.Immediate)
}
}
}
}
}
ListView {
id: settingsList
anchors.fill: parent
clip: true
spacing: 1
opacity: 1
visible: true
width: parent.width
interactive: true
model: settingsListModel
delegate: settingsComponent
}
}
}
}
......@@ -29,10 +29,10 @@ Component {
id: settingsDialog
Item {
id: mainLayout
property string sectionName: "storage"
Component.onCompleted: {
settings.loadSettings()
settings.loadSettings(sectionName)
}
property string sLang: "cs"
property int myWidht: mainLayout.width - 2 * defaultMargin
Rectangle {
id: header
......@@ -61,7 +61,7 @@ Component {
}
}
Label {
text: qsTr("Datovka settings")
text: qsTr("Storage settings")
anchors.verticalCenter: parent.verticalCenter
anchors.left: backElement.right
anchors.leftMargin: defaultMargin
......@@ -82,7 +82,7 @@ Component {
anchors.fill: parent
onClicked: {
/* TODO - Must be replaced via better solution in the future. */
settings.saveSettingsRequest()
settings.saveSettingsRequest(sectionName)
}
}
}
......@@ -97,111 +97,6 @@ Component {
id: settingsComponent
Column {
spacing: formItemVerticalSpacing
Text {
id: sectionLabelGeneral
font.bold: true
color: datovkaPalette.text
text: qsTr("General")
}
Column {
spacing: 4
Label {
color: datovkaPalette.text
text: qsTr("Language")
}
ComboBox {
id: languageComboBoxId
currentIndex: 0
width: myWidht
textRole: "key"
model: ListModel {
id: langMethodModel
// Don't change position of list elements, keys and values.
ListElement { key: qsTr("System"); value: "system" }
ListElement { key: qsTr("Czech"); value: "cs" }
ListElement { key: qsTr("English"); value: "en" }
}
onCurrentIndexChanged: sLang = langMethodModel.get(currentIndex).value
}
Text {
color: datovkaPalette.mid
width: myWidht
text: qsTr("Note: Language will be changed after application restart.")
wrapMode: Text.Wrap
}
}
Column {
spacing: 1
Label {
id: fontSizeLabel
color: datovkaPalette.text
width: myWidht
text: qsTr("Font size and application scale")
}
SpinBox {
/* Actually holds font pixel size. */
id: fontSizeSpinBox
property int dflt: 16
from: 10
to: 20
stepSize: 1
function val() {
return value
}
function setVal(v) {
if (v < from) {
value = from
} else if (v > to) {
value = to
} else {
value = v
}
}
}
Text {
color: datovkaPalette.mid
width: myWidht
text: qsTr("Note: Font size will be changed after application restart. Default is %1.").arg(fontSizeSpinBox.dflt)
wrapMode: Text.Wrap
}
}
Text {
id: sectionLabelMessages
font.bold: true
color: datovkaPalette.text
text: qsTr("Messages")
}
Column {
spacing: 1
CheckBox {
id: idownloadOnlyNewMsgs
text: qsTr("Download only newer messages")
checked: true
}
Text {
color: datovkaPalette.mid
width: myWidht
text: qsTr("Datovka will synchronize only messages which are not older than 90 days.")
wrapMode: Text.Wrap
}
}
Column {
spacing: 1
CheckBox {
id: idownloadCompleteMsgs
text: qsTr("Download complete messages")
}
Text {
color: datovkaPalette.mid
width: myWidht