Files
metabuilder/qml/qt6/SMTPConfigEditor.qml
johndoe6345789 75b302543a style(qt6): zero 80-char violations — last 29 fixed manually
SMTPConfigEditor: split property declarations + handler bodies
DatabaseManager: break long strings + property chains
FrontPage: split Layout properties onto separate lines
CCard: trim section comment rulers

Result: 0 lines over 80 chars across all qml/**/*.qml and qml/**/*.js

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-19 15:53:45 +00:00

131 lines
6.0 KiB
QML

import QtQuick; import QtQuick.Controls
import QtQuick.Layouts; import QmlComponents 1.0
import "qmllib/MetaBuilder"
import "qmllib/MetaBuilder/SmtpLogic.js" as Logic
Rectangle {
id: se; color: "transparent"
property string smtpHost: "smtp.example.com"
property string smtpPort: "587"
property string smtpUsername: ""; property string smtpPassword: ""
property int encryptionIndex: 1; property var encryptionOptions: []
property string fromName: "MetaBuilder"
property string fromEmail: "noreply@example.com"
property string connectionStatus: "untested"
property string lastTestResult: ""; property string lastTestTime: ""
property string testRecipient: ""
property string testSubject: "MetaBuilder SMTP Test"
property string testBody: "This is a test email from MetaBuilder."
property bool sendingTest: false
property int selectedTemplateIndex: -1; property var emailTemplates: []
property string editTplName: ""; property string editTplSubj: ""
property string editTplBody: ""
property bool isDirty: false
function loadSeedData() {
var xhr = new XMLHttpRequest()
xhr.open("GET", Qt.resolvedUrl(
"config/smtp-templates.json"), false)
xhr.send()
if (xhr.status === 200) {
var d = JSON.parse(xhr.responseText)
emailTemplates = d.emailTemplates
encryptionOptions = d.encryptionOptions }
}
Component.onCompleted: loadSeedData()
Timer { id: connTimer; interval: 1500; repeat: false
onTriggered: Logic.onConnectionTestComplete(se) }
Timer { id: sendTimer; interval: 2000; repeat: false
onTriggered: Logic.onSendTestComplete(se) }
ScrollView {
anchors.fill: parent; contentWidth: availableWidth; clip: true
ColumnLayout {
width: parent.width; spacing: 16
FlexRow {
Layout.fillWidth: true; spacing: 12
CText { variant: "h3"; text: "SMTP Configuration" }
CBadge { text: "Email" }; Item { Layout.fillWidth: true }
CButton { text: "Reset"; variant: "ghost"; size: "sm"
onClicked: Logic.resetAll(se) }
CButton { text: "Save Configuration"; variant: "primary"
size: "sm"; onClicked: Logic.saveAll(se) }
}
CCard {
Layout.fillWidth: true
ColumnLayout {
anchors.fill: parent; anchors.margins: 16; spacing: 12
CText { variant: "h4"; text: "Status" }
FlexRow {
Layout.fillWidth: true; spacing: 16
CStatusBadge {
status: Logic.connBadgeStatus(connectionStatus)
text: Logic.connBadgeText(connectionStatus) }
CStatusBadge {
status: isDirty ? "warning" : "success"
text: isDirty ? "Unsaved Changes" : "Saved" }
}
CText { visible: lastTestResult.length > 0
variant: "body2"; text: lastTestResult }
CText { visible: lastTestTime.length > 0; variant: "caption"
text: "Last activity: " + lastTestTime }
}
}
RowLayout {
Layout.fillWidth: true; spacing: 16
CSmtpServerForm {
host: smtpHost; port: smtpPort
username: smtpUsername; password: smtpPassword
encryptionIndex: se.encryptionIndex
encryptionOptions: se.encryptionOptions
connectionStatus: se.connectionStatus
onHostEdited: function(v) { smtpHost = v; isDirty = true }
onPortEdited: function(v) { smtpPort = v; isDirty = true }
onUsernameEdited: function(v) {
smtpUsername = v; isDirty = true
}
onPasswordEdited: function(v) {
smtpPassword = v; isDirty = true
}
onEncryptionEdited: function(i) {
encryptionIndex = i; isDirty = true
}
onTestRequested: Logic.testConnection(se, connTimer)
}
CSmtpSenderForm {
fromName: se.fromName; fromEmail: se.fromEmail
onFromNameEdited: function(v) {
se.fromName = v; isDirty = true
}
onFromEmailEdited: function(v) {
se.fromEmail = v; isDirty = true
}
}
}
CSmtpTestEmailForm {
recipient: testRecipient; subject: testSubject
body: testBody; sending: sendingTest
onRecipientEdited: function(v) { testRecipient = v }
onSubjectEdited: function(v) { testSubject = v }
onBodyEdited: function(v) { testBody = v }
onSendRequested: Logic.sendTestEmail(se, sendTimer)
}
RowLayout {
Layout.fillWidth: true; spacing: 16
CSmtpTemplateList {
templates: emailTemplates
selectedIndex: selectedTemplateIndex
onTemplateSelected: function(i) {
Logic.selectTemplate(se, i) } }
CSmtpTemplateEditor {
hasSelection: selectedTemplateIndex >= 0
templateName: editTplName; templateSubject: editTplSubj
templateBody: editTplBody
onNameChanged: function(v) { editTplName = v }
onSubjectChanged: function(v) { editTplSubj = v }
onBodyChanged: function(v) { editTplBody = v }
onSaveRequested: { Logic.saveTemplate(se); isDirty = true }
}
}
Item { Layout.preferredHeight: 8 }
}
}
}