From dc8294b6bd7dbec33246ee4304d157705a5ac9cd Mon Sep 17 00:00:00 2001 From: Richard Ramos Date: Thu, 16 Sep 2021 14:07:43 -0400 Subject: [PATCH] fix: display current active mailserver Fixes #3505 --- src/app/profile/views/mailservers_list.nim | 2 +- ui/app/AppLayouts/Node/NodeLayout.qml | 31 +++++++++++++++++++ .../Profile/Sections/SyncContainer.qml | 17 +++++----- 3 files changed, 39 insertions(+), 11 deletions(-) diff --git a/src/app/profile/views/mailservers_list.nim b/src/app/profile/views/mailservers_list.nim index 402eb14077..e5df418f01 100644 --- a/src/app/profile/views/mailservers_list.nim +++ b/src/app/profile/views/mailservers_list.nim @@ -25,7 +25,7 @@ QtObject: method rowCount(self: MailServersList, index: QModelIndex = nil): int = return self.mailservers.len - proc getMailserverName*(self: MailServersList, enode: string): string = + proc getMailserverName*(self: MailServersList, enode: string): string {.slot.} = for mailserver in self.mailservers: if mailserver.endpoint == enode: return mailserver.name diff --git a/ui/app/AppLayouts/Node/NodeLayout.qml b/ui/app/AppLayouts/Node/NodeLayout.qml index 5dad81b7a2..185ad69d99 100644 --- a/ui/app/AppLayouts/Node/NodeLayout.qml +++ b/ui/app/AppLayouts/Node/NodeLayout.qml @@ -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 { id: logContainer height: 300 diff --git a/ui/app/AppLayouts/Profile/Sections/SyncContainer.qml b/ui/app/AppLayouts/Profile/Sections/SyncContainer.qml index 5da9d5a5a6..d76a9c31a1 100644 --- a/ui/app/AppLayouts/Profile/Sections/SyncContainer.qml +++ b/ui/app/AppLayouts/Profile/Sections/SyncContainer.qml @@ -14,21 +14,22 @@ Item { Connections { target: profileModel.mailservers onActiveMailserverChanged: (activeMailserver) => { - syncContainer.activeMailserver = activeMailserver + syncContainer.activeMailserver = profileModel.mailservers.list.getMailserverName(activeMailserver) } } Item { width: profileContainer.profileContentWidth + anchors.top: parent.top + anchors.bottom: parent.bottom anchors.horizontalCenter: parent.horizontalCenter - Component { id: mailserversList StatusRadioButton { id: rbSetMailsever text: name - checked: name === activeMailserver.activeMailserver + checked: name === activeMailserver onClicked: { if (checked) { profileModel.mailservers.setMailserver(name); @@ -166,7 +167,7 @@ Item { StyledText { //% "..." - text: profileModel.mailservers.activeMailserver || qsTrId("---") + text: qsTr("Active mailserver: %1").arg(activeMailserver) || qsTrId("---") anchors.left: parent.left anchors.leftMargin: 24 anchors.top: switchLbl.bottom @@ -176,16 +177,12 @@ Item { ListView { id: mailServersListView - anchors.topMargin: 200 + anchors.topMargin: 20 anchors.top: automaticSelectionSwitch.bottom - anchors.fill: parent + anchors.bottom: parent.bottom model: profileModel.mailservers.list delegate: mailserversList visible: !automaticSelectionSwitch.checked - - Component.onCompleted: { - profileModel.mailservers.getActiveMailserver() - } } } }