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

75 lines
2.2 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
// Called when the page is activated
Component.onCompleted: {
if (emailId !== -1) {
loadEmail(emailId)
}
}
// Function to load email by ID (placeholder implementation)
function loadEmail(id) {
emailId = id
// Placeholder: show a fixed email. In the future, we will fetch the actual email from the database
// and convert the .eml file to HTML.
webView.html = "<html><body style='font-family: sans-serif;'>" +
"<h2>Test Email Subject</h2>" +
"<p><strong>From:</strong> sender@example.com</p>" +
"<p><strong>To:</strong> recipient@example.com</p>" +
"<p><strong>Date:</strong> May 17, 2026</p>" +
"<hr/>" +
"<p>This is a placeholder for the email body. In a real implementation, we would load the email content from the .eml file and convert it 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
}
}