Commit d7090d0d authored by Martin Straka's avatar Martin Straka
Browse files

Listview menu instead of popup in the messages page (issue #38)

parent d59aaf4f
......@@ -48,6 +48,8 @@ ApplicationWindow {
// define all pages for stackview
property Component accountsPage: AccountsPage {}
property Component messagesPage: MessagesPage {}
property Component messagesMenuPage: MessagesMenuPage {}
property Component messageMenuPage: MessageMenuPage {}
property Component messageDetailPage: MessageDetailPage {}
property Component messageDetailMenuPage: MessageDetailMenuPage {}
property Component accountDetailPage: AccountDetailPage {}
......@@ -83,6 +85,7 @@ ApplicationWindow {
property string gAcntName
property int gMsgType
property string gMsgId
property bool gCanDeleteMsg: false
/* compare message delivery date with current date-90days */
property int deleteAfterDays: 90
......
/*
* 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: messageMenuPage
Item {
id: mainLayout
property int myWidht: mainLayout.width - 2 * defaultMargin
property bool canDeleteMsg: gCanDeleteMsg
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"
}
Rectangle {
anchors.left: parent.left
width: parent.width * 0.5
height: parent.height
color: "transparent"
MouseArea {
anchors.fill: parent
onClicked: {
pageView.pop(StackView.Immediate)
}
}
}
Column {
anchors.verticalCenter: parent.verticalCenter
anchors.left: backElement.right
anchors.leftMargin: defaultMargin
Label {
text: {
if (gMsgType == sentMESSAGE) {
qsTr("Sent message") + " " + gMsgId
} else {
qsTr("Received message") + " " + gMsgId
}
}
font.bold: true
color: datovkaPalette.text
}
Label {
text: qsTr("Message operations")
font.bold: true
color: datovkaPalette.text
}
}
}
Rectangle {
anchors.top: header.bottom
anchors.bottom: parent.bottom
width: parent.width
color: "transparent"
ListModel {
id: messageMenuListModel
ListElement {
index: 0
showIt: true
name: qsTr("Download attachments")
image: "qrc:/ui/datovka-email-download.svg"
showNext: false
}
ListElement {
index: 1
showIt: true
name: qsTr("Mark as read")
image: "qrc:/ui/email-open-outline.svg"
showNext: false
}
ListElement {
index: 2
showIt: true
name: qsTr("Mark as unread")
image: "qrc:/ui/email-outline.svg"
showNext: false
}
ListElement {
index: 3
showIt: true
name: qsTr("Delete message")
image: "qrc:/ui/delete.svg"
showNext: false
}
}
Component {
id: messageMenuComponent
Rectangle {
visible: showIt
color: datovkaPalette.base
height: headerHeight
width: parent.width
Image {
id: menuImage
anchors.verticalCenter: parent.verticalCenter
anchors.left: parent.left
anchors.leftMargin: defaultMargin
sourceSize.height: imgHeight * 0.7
source: image
}
ColorOverlay {
anchors.fill: menuImage
source: menuImage
color: datovkaPalette.text
}
Text {
anchors.verticalCenter: parent.verticalCenter
anchors.left: menuImage.right
anchors.leftMargin: defaultMargin
color: datovkaPalette.text
text: name
}
Rectangle {
id: next2
visible: showNext
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 == 0) {
isds.downloadMessage(gUserName, gMsgType, gMsgId)
} else if (index == 1) {
messages.markMessageAsLocallyRead(gUserName, gMsgId, true)
} else if (index == 2) {
messages.markMessageAsLocallyRead(gUserName, gMsgId, false)
} else if (index == 3) {
messages.deleteMessageFromDbs(gUserName, gMsgId)
}
pageView.pop(StackView.Immediate)
}
}
}
}
ListView {
id: messageMenuList
anchors.fill: parent
clip: true
spacing: 1
opacity: 1
visible: true
width: parent.width
interactive: true
model: messageMenuListModel
delegate: messageMenuComponent
}
}
}
}
/*
* 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: messagesMenuPage
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)
}
}
}
Column {
anchors.verticalCenter: parent.verticalCenter
anchors.left: backElement.right
anchors.leftMargin: defaultMargin
Label {
text: {
if (gMsgType == sentMESSAGE) {
qsTr("Sent messages")
} else {
qsTr("Received messages")
}
}
font.bold: true
color: datovkaPalette.text
}
Label {
text: qsTr("Messages operations")
font.bold: true
color: datovkaPalette.text
}
}
}
Rectangle {
anchors.top: header.bottom
anchors.bottom: parent.bottom
width: parent.width
color: "transparent"
ListModel {
id: messagesMenuListModel
ListElement {
index: 0
name: qsTr("Mark all messages as read")
image: "qrc:/ui/email-open-outline.svg"
showNext: false
}
ListElement {
index: 1
name: qsTr("Mark all messages as unread")
image: "qrc:/ui/email-outline.svg"
showNext: false
}
}
Component {
id: messagesMenuComponent
Rectangle {
color: datovkaPalette.base
height: headerHeight
width: parent.width
Image {
id: menuImage
anchors.verticalCenter: parent.verticalCenter
anchors.left: parent.left
anchors.leftMargin: defaultMargin
sourceSize.height: imgHeight * 0.7
source: image
}
ColorOverlay {
anchors.fill: menuImage
source: menuImage
color: datovkaPalette.text
}
Text {
anchors.verticalCenter: parent.verticalCenter
anchors.left: menuImage.right
anchors.leftMargin: defaultMargin
color: datovkaPalette.text
text: name
}
Rectangle {
id: next2
visible: showNext
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 == 0) {
messages.markMessagesAsLocallyRead(gUserName, true)
} else if (index == 1) {
messages.markMessagesAsLocallyRead(gUserName, false)
}
pageView.pop(StackView.Immediate)
}
}
}
}
ListView {
id: messagesMenuList
anchors.fill: parent
clip: true
spacing: 1
opacity: 1
visible: true
width: parent.width
interactive: true
model: messagesMenuListModel
delegate: messagesMenuComponent
}
}
}
}
......@@ -39,7 +39,6 @@ Component {
settingsButton.visible = false
}
}
property bool canDeleteMsg: false
Rectangle {
id: header2
anchors.top: parent.top
......@@ -100,35 +99,11 @@ Component {
anchors.verticalCenter: parent.verticalCenter
sourceSize.height: imgHeight
source: "qrc:/ui/settings.svg"
Menu {
id: mainContextMenu2
implicitWidth: 800 // Chosen to be large enough
MenuItem {
id: markAllAsRead
text: qsTr("Mark all as read")
//iconSource: "qrc:/ui/email-open-outline.svg"
onTriggered: {
messages.markMessagesAsLocallyRead(gUserName, true)
}
}
MenuItem {
id: markAllAsUnRead
text: qsTr("Mark all as unread")
//iconSource: "qrc:/ui/email-outline.svg"
onTriggered: {
messages.markMessagesAsLocallyRead(gUserName, false)
}
}
}
MouseArea {
anchors.fill: parent
onClicked: {
statusBar.visible = false
mainContextMenu2.implicitWidth = computeMenuWidth(mainContextMenu2)
// Located in right top corner.
mainContextMenu2.x = mouse.x - mainContextMenu2.width
mainContextMenu2.y = mouse.y
mainContextMenu2.open()
statusBar.visible = false
pageView.push(messagesMenuPage, StackView.Immediate)
}
}
}
......@@ -277,35 +252,6 @@ Component {
color: datovkaPalette.text
}
}
Menu {
id: messageContextMenu
implicitWidth: 800 // Chosen to be large enough
MenuItem {
text: qsTr("Mark as read")
onTriggered: {
messages.markMessageAsLocallyRead(gUserName, gMsgId, true)
}
}
MenuItem {
text: qsTr("Mark as unread")
onTriggered: {
messages.markMessageAsLocallyRead(gUserName, gMsgId, false)
}
}
MenuItem {
text: qsTr("Download attachments")
onTriggered: {
isds.downloadMessage(gUserName, gMsgType, gMsgId)
}
}
MenuItem {
text: qsTr("Delete message")
enabled: canDeleteMsg
onTriggered: {
messages.deleteMessageFromDbs(gUserName, gMsgId)
}
}
}
MouseArea {
anchors.fill: parent
onClicked: {
......@@ -318,13 +264,9 @@ Component {
}
onPressAndHold: {
gMsgId = rMsgId
canDeleteMsg = compareMsgDate(rDelivTime)
gCanDeleteMsg = compareMsgDate(rDelivTime)
statusBar.visible = false
messageContextMenu.implicitWidth = computeMenuWidth(messageContextMenu)
// Located in left top corner.
messageContextMenu.x = mouse.x
messageContextMenu.y = mouse.y
messageContextMenu.open()
pageView.push(messageMenuPage, StackView.Immediate)
}
}
Rectangle {
......
......@@ -108,5 +108,7 @@
<file>../qml/pages/SettingsStoragePage.qml</file>
<file>../qml/pages/AccountMenuPage.qml</file>
<file>../qml/pages/MessageDetailMenuPage.qml</file>
<file>../qml/pages/MessageMenuPage.qml</file>
<file>../qml/pages/MessagesMenuPage.qml</file>
</qresource>
</RCC>
......@@ -53,6 +53,8 @@ static const struct {
} qmldir_pages [] = {
{ "AccountsPage", 1, 0 },
{ "MessagesPage", 1, 0 },
{ "MessageMenuPage", 1, 0 },
{ "MessagesMenuPage", 1, 0 },
{ "MessageDetailPage", 1, 0 },
{ "MessageDetailMenuPage", 1, 0 },
{ "AccountDetailPage", 1, 0 },
......@@ -66,7 +68,6 @@ static const struct {
{ "SettingsStoragePage", 1, 0 },
};
int main(int argc, char *argv[])
{
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment