Files

67 lines
1.5 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
function loadEmail(id) {
emailId = id
// Fetch the HTML content from the EmailManager
webView.html = emailManager.getEmailHtmlById(id)
}
// 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
}
}