Files
wino-mail-dtkqt/resources/qml/ReaderPage.qml
T

74 lines
2.1 KiB
QML

import QtQuick 2.15
import QtQuick.Controls 2.15
import QtQuick.Layouts 1.15
import QtWebEngine 1.15
Item {
id: readerPage
anchors.fill: parent
// Property to hold the email ID to display
property int emailId: -1
property var email: null // Will hold MailItem object
// Called when the page is activated
Component.onCompleted: {
if (emailId !== -1) {
loadEmail(emailId)
}
}
// Function to load email by ID (simplified - in reality would fetch from DB and load .eml)
function loadEmail(id) {
emailId = id
// For demo, we'll just show a placeholder
// In real implementation, we would:
// 1. Get MailItem from MailItemDao by id
// 2. Get fileId from MailItem
// 3. Load .eml file from storage
// 4. Convert MIME to HTML (using gmime or similar)
// 5. Load HTML into webView
webView.html = "<html><body><h1>Email Reader</h1><p>Loading email with ID: " + id + "</p><p>This is a placeholder. Real implementation would load the email content from .eml file and convert to HTML.</p></body></html>"
}
// Back button
Rectangle {
anchors {
top: parent.top
left: parent.left
margins: 10
}
width: 40
height: 40
color: "#e0e0e0"
radius: 5
MouseArea {
anchors.fill: parent
onClicked: {
StackView.view.pop()
}
}
Text {
text: "←"
anchors.centerIn: parent
font.pointSize: 20
color: "#333"
}
}
// Main content: WebEngineView to display email
WebEngineView {
id: webView
anchors {
top: backButton.bottom
bottom: parent.bottom
left: parent.left
right: parent.right
margins: 0
}
// Settings to enable local content loading
settings.javascriptEnabled: true
settings.localContentCanAccessRemoteUrls: true
settings.localContentCanAccessFileUrls: true
}
}