fix: display current active mailserver

Fixes #3505
This commit is contained in:
Richard Ramos 2021-09-16 14:07:43 -04:00 committed by Iuri Matias
parent 12eecd3195
commit dc8294b6bd
3 changed files with 39 additions and 11 deletions

View File

@ -25,7 +25,7 @@ QtObject:
method rowCount(self: MailServersList, index: QModelIndex = nil): int = method rowCount(self: MailServersList, index: QModelIndex = nil): int =
return self.mailservers.len return self.mailservers.len
proc getMailserverName*(self: MailServersList, enode: string): string = proc getMailserverName*(self: MailServersList, enode: string): string {.slot.} =
for mailserver in self.mailservers: for mailserver in self.mailservers:
if mailserver.endpoint == enode: if mailserver.endpoint == enode:
return mailserver.name return mailserver.name

View File

@ -69,6 +69,37 @@ Item {
} }
} }
RowLayout {
Layout.fillWidth: true
StyledText {
color: Style.current.lightBlueText
text: qsTr("Active Mailserver")
Layout.rightMargin: Style.current.padding
Layout.leftMargin: Style.current.padding
Layout.fillWidth: true
font.weight: Font.Medium
font.pixelSize: 20
}
StyledText {
id: activeMailserverTxt
color: Style.current.textColor
text: "..."
Layout.rightMargin: Style.current.padding
Layout.leftMargin: Style.current.padding
Layout.fillWidth: true
wrapMode: Text.Wrap
font.weight: Font.Medium
font.pixelSize: 14
}
}
Connections {
target: profileModel.mailservers
onActiveMailserverChanged: (activeMailserver) => {
activeMailserverTxt.text = profileModel.mailservers.list.getMailserverName(activeMailserver) + "\n" + activeMailserver
}
}
ColumnLayout { ColumnLayout {
id: logContainer id: logContainer
height: 300 height: 300

View File

@ -14,21 +14,22 @@ Item {
Connections { Connections {
target: profileModel.mailservers target: profileModel.mailservers
onActiveMailserverChanged: (activeMailserver) => { onActiveMailserverChanged: (activeMailserver) => {
syncContainer.activeMailserver = activeMailserver syncContainer.activeMailserver = profileModel.mailservers.list.getMailserverName(activeMailserver)
} }
} }
Item { Item {
width: profileContainer.profileContentWidth width: profileContainer.profileContentWidth
anchors.top: parent.top
anchors.bottom: parent.bottom
anchors.horizontalCenter: parent.horizontalCenter anchors.horizontalCenter: parent.horizontalCenter
Component { Component {
id: mailserversList id: mailserversList
StatusRadioButton { StatusRadioButton {
id: rbSetMailsever id: rbSetMailsever
text: name text: name
checked: name === activeMailserver.activeMailserver checked: name === activeMailserver
onClicked: { onClicked: {
if (checked) { if (checked) {
profileModel.mailservers.setMailserver(name); profileModel.mailservers.setMailserver(name);
@ -166,7 +167,7 @@ Item {
StyledText { StyledText {
//% "..." //% "..."
text: profileModel.mailservers.activeMailserver || qsTrId("---") text: qsTr("Active mailserver: %1").arg(activeMailserver) || qsTrId("---")
anchors.left: parent.left anchors.left: parent.left
anchors.leftMargin: 24 anchors.leftMargin: 24
anchors.top: switchLbl.bottom anchors.top: switchLbl.bottom
@ -176,16 +177,12 @@ Item {
ListView { ListView {
id: mailServersListView id: mailServersListView
anchors.topMargin: 200 anchors.topMargin: 20
anchors.top: automaticSelectionSwitch.bottom anchors.top: automaticSelectionSwitch.bottom
anchors.fill: parent anchors.bottom: parent.bottom
model: profileModel.mailservers.list model: profileModel.mailservers.list
delegate: mailserversList delegate: mailserversList
visible: !automaticSelectionSwitch.checked visible: !automaticSelectionSwitch.checked
Component.onCompleted: {
profileModel.mailservers.getActiveMailserver()
}
} }
} }
} }