Commit ce9eba85 authored by Martin Straka's avatar Martin Straka

Page header bar as component

parent 456c977c
/*
* Copyright (C) 2014-2017 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
Rectangle {
property string title
id: root
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"
}
Text {
anchors.verticalCenter: parent.verticalCenter
anchors.left: backElement.right
anchors.leftMargin: defaultMargin
font.bold: true
color: datovkaPalette.text
text: title
}
}
......@@ -23,6 +23,7 @@
import QtQuick 2.7
import QtQuick.Controls 2.0
import cz.nic.mobileDatovka 1.0
Component {
id: aboutApp
......@@ -34,43 +35,24 @@ Component {
property var statusBar
property int myWidht: aboutLayout.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 {
PageHeader {
id: headerBar
title: qsTr("About Datovka")
Item {
anchors.left: parent.left
width: parent.width * 0.5
height: parent.height
color: "transparent"
MouseArea {
anchors.fill: parent
onClicked: {
pageView.pop(StackView.Immediate)
pageView.pop(StackView.Immediate)
}
}
}
Text {
text: qsTr("About Datovka")
anchors.verticalCenter: parent.verticalCenter
anchors.left: backElement.right
anchors.leftMargin: defaultMargin
font.bold: true
color: datovkaPalette.text
}
}
Rectangle {
anchors.top: header.bottom
anchors.top: headerBar.bottom
anchors.bottom: parent.bottom
width: parent.width
color: "transparent"
......
......@@ -23,6 +23,7 @@
import QtQuick 2.7
import QtQuick.Controls 2.0
import cz.nic.mobileDatovka 1.0
Component {
id: pageAccountDetail
......@@ -38,47 +39,20 @@ Component {
Component.onCompleted: {
accounts.fillAccountInfo(userName)
}
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 {
PageHeader {
id: headerBar
title: acntName + " (" + userName + ")" + "\n" + qsTr("Account info")
Item {
anchors.left: parent.left
width: parent.width * 0.5
height: parent.height
color: "transparent"
MouseArea {
anchors.fill: parent
onClicked: {
pageView.pop(StackView.Immediate)
pageView.pop(StackView.Immediate)
}
}
}
Column {
anchors.verticalCenter: parent.verticalCenter
anchors.left: backElement.right
anchors.leftMargin: defaultMargin
Text {
text: acntName + " (" + userName + ")"
font.bold: true
color: datovkaPalette.text
}
Text {
text: qsTr("Account info")
font.bold: true
color: datovkaPalette.text
}
}
Row {
anchors.verticalCenter: parent.verticalCenter
spacing: defaultMargin
......@@ -108,7 +82,7 @@ Component {
}
Rectangle {
id: accountDetail
anchors.top: header.bottom
anchors.top: headerBar.bottom
width: parent.width
height: parent.height
visible: false
......
......@@ -27,6 +27,7 @@ import QtQuick.Window 2.1
import QtQuick.Layouts 1.2
import QtQuick.Dialogs 1.2
import QtGraphicalEffects 1.0
import cz.nic.mobileDatovka 1.0
Component {
id: menuAccount
......@@ -40,25 +41,14 @@ Component {
property string userName
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 {
PageHeader {
id: headerBar
title: acntName + " (" + userName + ")" + "\n" + qsTr("Account properties")
Item {
anchors.left: parent.left
width: parent.width * 0.5
height: parent.height
color: "transparent"
MouseArea {
anchors.fill: parent
onClicked: {
......@@ -66,24 +56,9 @@ Component {
}
}
}
Column {
anchors.verticalCenter: parent.verticalCenter
anchors.left: backElement.right
anchors.leftMargin: defaultMargin
Text {
text: acntName + " (" + userName + ")"
font.bold: true
color: datovkaPalette.text
}
Text {
text: qsTr("Account properties")
font.bold: true
color: datovkaPalette.text
}
}
}
Rectangle {
anchors.top: header.bottom
anchors.top: headerBar.bottom
anchors.bottom: parent.bottom
width: parent.width
color: "transparent"
......
......@@ -27,6 +27,7 @@ import QtQuick.Window 2.1
import QtQuick.Layouts 1.2
import QtQuick.Dialogs 1.2
import QtGraphicalEffects 1.0
import cz.nic.mobileDatovka 1.0
Component {
id: menuDatovkamainSettings
......@@ -38,25 +39,14 @@ Component {
property var statusBar
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 {
PageHeader {
id: headerBar
title: qsTr("Datovka settings")
Item {
anchors.left: parent.left
width: parent.width * 0.5
height: parent.height
color: "transparent"
MouseArea {
anchors.fill: parent
onClicked: {
......@@ -64,17 +54,9 @@ Component {
}
}
}
Text {
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.top: headerBar.bottom
anchors.bottom: parent.bottom
width: parent.width
color: "transparent"
......
......@@ -27,6 +27,7 @@ import QtQuick.Window 2.1
import QtQuick.Layouts 1.2
import QtQuick.Dialogs 1.2
import QtGraphicalEffects 1.0
import cz.nic.mobileDatovka 1.0
import cz.nic.mobileDatovka.messages 1.0
Component {
......@@ -47,25 +48,22 @@ Component {
Component.onCompleted: {
messageMenuListModel.setProperty(3, "showIt", canDeleteMsg)
}
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"
function setHeaderTitleText() {
var str = qsTr("Sent message");
if (msgType == MessageType.TYPE_RECEIVED) {
str = qsTr("Received message")
}
Rectangle {
return str + " " + msgId + "\n" + qsTr("Message operations")
}
PageHeader {
id: headerBar
title: setHeaderTitleText()
Item {
anchors.left: parent.left
width: parent.width * 0.5
height: parent.height
color: "transparent"
MouseArea {
anchors.fill: parent
onClicked: {
......@@ -73,30 +71,9 @@ Component {
}
}
}
Column {
anchors.verticalCenter: parent.verticalCenter
anchors.left: backElement.right
anchors.leftMargin: defaultMargin
Text {
text: {
if (msgType == MessageType.TYPE_RECEIVED) {
qsTr("Received message") + " " + msgId
} else {
qsTr("Sent message") + " " + msgId
}
}
font.bold: true
color: datovkaPalette.text
}
Text {
text: qsTr("Message operations")
font.bold: true
color: datovkaPalette.text
}
}
}
Rectangle {
anchors.top: header.bottom
anchors.top: headerBar.bottom
anchors.bottom: parent.bottom
width: parent.width
color: "transparent"
......
......@@ -27,6 +27,7 @@ import QtQuick.Window 2.1
import QtQuick.Layouts 1.2
import QtQuick.Dialogs 1.2
import QtGraphicalEffects 1.0
import cz.nic.mobileDatovka 1.0
import cz.nic.mobileDatovka.messages 1.0
Component {
......@@ -44,25 +45,22 @@ Component {
property var attachmentModel: null /* The QVariant holds actually a pointer to the model. */
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"
function setHeaderTitleText() {
var str = qsTr("Sent message");
if (msgType == MessageType.TYPE_RECEIVED) {
str = qsTr("Received message")
}
Rectangle {
return str + " " + msgId + "\n" + qsTr("Attachment operations")
}
PageHeader {
id: headerBar
title: setHeaderTitleText()
Item {
anchors.left: parent.left
width: parent.width * 0.5
height: parent.height
color: "transparent"
MouseArea {
anchors.fill: parent
onClicked: {
......@@ -70,30 +68,9 @@ Component {
}
}
}
Column {
anchors.verticalCenter: parent.verticalCenter
anchors.left: backElement.right
anchors.leftMargin: defaultMargin
Text {
text: {
if (msgType == MessageType.TYPE_RECEIVED) {
qsTr("Received message") + " " + msgId
} else {
qsTr("Sent message") + " " + msgId
}
}
font.bold: true
color: datovkaPalette.text
}
Text {
text: qsTr("Attachment operations")
font.bold: true
color: datovkaPalette.text
}
}
}
Rectangle {
anchors.top: header.bottom
anchors.top: headerBar.bottom
anchors.bottom: parent.bottom
width: parent.width
color: "transparent"
......
......@@ -27,6 +27,7 @@ import QtQuick.Window 2.1
import QtQuick.Layouts 1.2
import QtQuick.Dialogs 1.2
import QtGraphicalEffects 1.0
import cz.nic.mobileDatovka 1.0
import cz.nic.mobileDatovka.messages 1.0
Component {
......@@ -42,25 +43,22 @@ Component {
property int msgType
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"
function setHeaderTitleText() {
var str = qsTr("Sent message");
if (msgType == MessageType.TYPE_RECEIVED) {
str = qsTr("Received message")
}
Rectangle {
return str + "\n" + qsTr("Message operations")
}
PageHeader {
id: headerBar
title: setHeaderTitleText()
Item {
anchors.left: parent.left
width: parent.width * 0.5
height: parent.height
color: "transparent"
MouseArea {
anchors.fill: parent
onClicked: {
......@@ -68,30 +66,9 @@ Component {
}
}
}
Column {
anchors.verticalCenter: parent.verticalCenter
anchors.left: backElement.right
anchors.leftMargin: defaultMargin
Text {
text: {
if (msgType == MessageType.TYPE_RECEIVED) {
qsTr("Received messages")
} else {
qsTr("Sent messages")
}
}
font.bold: true
color: datovkaPalette.text
}
Text {
text: qsTr("Message operations")
font.bold: true
color: datovkaPalette.text
}
}
}
Rectangle {
anchors.top: header.bottom
anchors.top: headerBar.bottom
anchors.bottom: parent.bottom
width: parent.width
color: "transparent"
......
......@@ -25,6 +25,7 @@ import QtQuick 2.7
import QtQuick.Controls 2.0
import QtQuick.Window 2.1
import QtGraphicalEffects 1.0
import cz.nic.mobileDatovka 1.0
import cz.nic.mobileDatovka.messages 1.0
import cz.nic.mobileDatovka.models 1.0
import cz.nic.mobileDatovka.msgInfo 1.0
......@@ -100,6 +101,33 @@ Component {
setTopButtonVisibility()
}
function setHeaderTitleText() {
var str1 = "";
var str2 = "";
if (fromLocalDb) {
str1 += acntName + " (" + userName + ")"
} else if (zfoType == MsgInfo.TYPE_MESSAGE) {
str1 += qsTr("Message from ZFO")
} else if (zfoType == MsgInfo.TYPE_DELIVERY_INFO) {
str1 += qsTr("Delivery info from ZFO")
} else {
str1 += qsTr("Unknown ZFO content")
}
if (fromLocalDb && (msgType == MessageType.TYPE_RECEIVED)) {
str2 += qsTr("Received message") + " " + zfoId
} else if (fromLocalDb && (msgType == MessageType.TYPE_SENT)) {
str2 += qsTr("Sent message") + " " + zfoId
} else if (zfoType != MsgInfo.TYPE_UNKNOWN) {
str2 += qsTr("Message ID") + " " + zfoId
} else {
str2 += "" /* Empty string. */
}
if (str2 === "") {
return str1
}
return str1 + "\n" + str2
}
onRawZfoContentChanged: {
fillContentFromDb()
}
......@@ -119,25 +147,13 @@ Component {
}
}
Rectangle {
id: header
anchors.top: parent.top
width: parent.width
height: headerHeight
color: datovkaPalette.highlight
Image {
id: backElement3
anchors.verticalCenter: parent.verticalCenter
anchors.left: parent.left
anchors.leftMargin: defaultMargin
sourceSize.height: navImgHeight
source: "qrc:/ui/back.svg"
}
Rectangle {
PageHeader {
id: headerBar
title: setHeaderTitleText()
Item {
anchors.left: parent.left
width: parent.width * 0.5
height: parent.height
color: "transparent"
MouseArea {
anchors.fill: parent
onClicked: {
......@@ -148,39 +164,6 @@ Component {
}
}
}
Column {
anchors.verticalCenter: parent.verticalCenter
anchors.left: backElement3.right
anchors.leftMargin: defaultMargin
Text {
text: if (fromLocalDb) {
acntName + " (" + userName + ")"
} else if (zfoType == MsgInfo.TYPE_MESSAGE) {
qsTr("Message from ZFO")
} else if (zfoType == MsgInfo.TYPE_DELIVERY_INFO) {
qsTr("Delivery info from ZFO")
} else {
qsTr("Unknown ZFO content")
}
font.bold: true
color: datovkaPalette.text
}
Text {
text: {
if (fromLocalDb && (msgType == MessageType.TYPE_RECEIVED)) {
qsTr("Received message") + " " + zfoId
} else if (fromLocalDb && (msgType == MessageType.TYPE_SENT)) {
qsTr("Sent message") + " " + zfoId
} else if (zfoType != MsgInfo.TYPE_UNKNOWN) {
qsTr("Message ID") + " " + zfoId
} else {
"" /* Empty string. */
}
}
font.bold: true
color: datovkaPalette.text
}
}
Row {
anchors.verticalCenter: parent.verticalCenter
spacing: defaultMargin
......@@ -226,7 +209,6 @@ Component {
isds.downloadMessage(userName, msgType, zfoId)
msgDescrHtml = messages.getMessageDetail(userName, zfoId)
attachmentModel.setFromDb(userName, zfoId)
emptyList.visible = (attachmentList.count == 0)
setTopButtonVisibility()
}
......@@ -259,7 +241,7 @@ Component {
}
Rectangle {
id: messageDetail
anchors.top: header.bottom
anchors.top: headerBar.bottom
width: parent.width
height: (zfoType == MsgInfo.TYPE_MESSAGE) ? parent.height * 0.5 : parent.height - headerHeight
color: datovkaPalette.base
......
......@@ -46,6 +46,14 @@ Component {
property string userName
property int msgType
function setHeaderTitleText() {
var str = qsTr("Sent message");
if (msgType == MessageType.TYPE_RECEIVED) {
str = qsTr("Received message")
}
return acntName + " (" + userName + ")" + "\n" + str
}
Component.onCompleted: {
messages.fillMessageList(userName, msgType)
if (messageList.count == 0) {
......@@ -66,33 +74,9 @@ Component {
MessageListModel.ROLE_ANNOTATION])
}
}
Rectangle {
PageHeader {
id: headerBar
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"
}
Text {
anchors.verticalCenter: parent.verticalCenter
anchors.left: backElement.right
anchors.leftMargin: defaultMargin
font.bold: true
color: datovkaPalette.text
text: if (msgType == MessageType.TYPE_RECEIVED) {
acntName + " (" + userName + ")" + "\n" + qsTr("Received messages")
} else {
acntName + " (" + userName + ")" + "\n" + qsTr("Sent messages")
}
}
title: setHeaderTitleText()
Item {
anchors.left: parent.left
width: parent.width * 0.5
......@@ -118,12 +102,6 @@ Component {
width: headerBar.width * 0.3
height: inputItemHeight
inputMethodHints: Qt.ImhNoPredictiveText
background: Rectangle {
color: (filterPhraseText.text.length == 0) ? "#ffffff" :
(messageList.count > 0) ? "#afffaf" : "#ffafaf"
border.color: filterPhraseText.activeFocus ? "#0066ff" :
"#bdbebf"
}
onTextChanged: {
proxyMessageModel.setFilterRegExpStr(filterPhraseText.text)
}
......
......@@ -23,8 +23,6 @@
import QtQuick 2.7
import QtQuick.Controls 2.1
import QtQuick.Window 2.1
import QtQuick.Dialogs 1.2
import cz.nic.mobileDatovka 1.0
import cz.nic.mobileDatovka.messages 1.0
import cz.nic.mobileDatovka.models 1.0
......@@ -54,28 +52,9 @@ Component {
Component.onCompleted: {
}