WifiPanel: Improved look and functionalities
This commit is contained in:
parent
54c39ab8a3
commit
5f00266df7
2 changed files with 62 additions and 34 deletions
|
|
@ -13,6 +13,7 @@ Singleton {
|
||||||
*/
|
*/
|
||||||
|
|
||||||
// Font size
|
// Font size
|
||||||
|
property real fontSizeXXS: 8
|
||||||
property real fontSizeXS: 9
|
property real fontSizeXS: 9
|
||||||
property real fontSizeS: 10
|
property real fontSizeS: 10
|
||||||
property real fontSizeM: 11
|
property real fontSizeM: 11
|
||||||
|
|
|
||||||
|
|
@ -46,6 +46,7 @@ NPanel {
|
||||||
font.weight: Style.fontWeightBold
|
font.weight: Style.fontWeightBold
|
||||||
color: Color.mOnSurface
|
color: Color.mOnSurface
|
||||||
Layout.fillWidth: true
|
Layout.fillWidth: true
|
||||||
|
Layout.leftMargin: Style.marginS * scaling
|
||||||
}
|
}
|
||||||
|
|
||||||
NIconButton {
|
NIconButton {
|
||||||
|
|
@ -72,6 +73,16 @@ NPanel {
|
||||||
Layout.fillWidth: true
|
Layout.fillWidth: true
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Show errors at the very top
|
||||||
|
NText {
|
||||||
|
visible: NetworkService.connectStatus === "error" && NetworkService.connectError.length > 0
|
||||||
|
text: NetworkService.connectError
|
||||||
|
color: Color.mError
|
||||||
|
font.pointSize: Style.fontSizeXS * scaling
|
||||||
|
wrapMode: Text.Wrap
|
||||||
|
Layout.fillWidth: true
|
||||||
|
}
|
||||||
|
|
||||||
Item {
|
Item {
|
||||||
Layout.fillWidth: true
|
Layout.fillWidth: true
|
||||||
Layout.fillHeight: true
|
Layout.fillHeight: true
|
||||||
|
|
@ -127,69 +138,65 @@ NPanel {
|
||||||
|
|
||||||
// Network list
|
// Network list
|
||||||
ListView {
|
ListView {
|
||||||
id: networkList
|
|
||||||
anchors.fill: parent
|
anchors.fill: parent
|
||||||
visible: Settings.data.network.wifiEnabled && !NetworkService.isLoading
|
visible: Settings.data.network.wifiEnabled && !NetworkService.isLoading
|
||||||
model: Object.values(NetworkService.networks)
|
model: Object.values(NetworkService.networks)
|
||||||
spacing: Style.marginM * scaling
|
spacing: Style.marginS * scaling
|
||||||
clip: true
|
clip: true
|
||||||
|
|
||||||
delegate: Item {
|
delegate: Item {
|
||||||
width: parent ? parent.width : 0
|
width: parent ? parent.width : 0
|
||||||
height: modelData.ssid === passwordPromptSsid
|
height: modelData.ssid === passwordPromptSsid
|
||||||
&& showPasswordPrompt ? 108 * scaling : Style.baseWidgetSize * 1.5 * scaling
|
&& showPasswordPrompt ? 130 * scaling : Style.baseWidgetSize * 1.75 * scaling
|
||||||
|
|
||||||
ColumnLayout {
|
ColumnLayout {
|
||||||
anchors.fill: parent
|
anchors.fill: parent
|
||||||
spacing: 0
|
spacing: 0
|
||||||
|
|
||||||
Rectangle {
|
Rectangle {
|
||||||
|
id: rect
|
||||||
Layout.fillWidth: true
|
Layout.fillWidth: true
|
||||||
Layout.preferredHeight: Style.baseWidgetSize * 1.5 * scaling
|
Layout.fillHeight: true
|
||||||
radius: Style.radiusS * scaling
|
radius: Style.radiusS * scaling
|
||||||
color: modelData.connected ? Color.mPrimary : (networkMouseArea.containsMouse ? Color.mTertiary : Color.transparent)
|
color: networkMouseArea.containsMouse ? Color.mTertiary : Color.transparent
|
||||||
|
border.color: modelData.connected ? Color.mPrimary : Color.transparent
|
||||||
|
border.width: Math.max(1, Style.borderM * scaling)
|
||||||
|
|
||||||
RowLayout {
|
RowLayout {
|
||||||
anchors.fill: parent
|
anchors {
|
||||||
anchors.margins: Style.marginS * scaling
|
fill: parent
|
||||||
|
leftMargin: Style.marginL * scaling
|
||||||
|
rightMargin: Style.marginL * scaling
|
||||||
|
}
|
||||||
spacing: Style.marginS * scaling
|
spacing: Style.marginS * scaling
|
||||||
|
|
||||||
NIcon {
|
NIcon {
|
||||||
text: NetworkService.signalIcon(modelData.signal)
|
text: NetworkService.signalIcon(modelData.signal)
|
||||||
font.pointSize: Style.fontSizeXXL * scaling
|
font.pointSize: Style.fontSizeXXL * scaling
|
||||||
color: modelData.connected ? Color.mSurface : (networkMouseArea.containsMouse ? Color.mSurface : Color.mOnSurface)
|
color: networkMouseArea.containsMouse ? Color.mSurface : Color.mOnSurface
|
||||||
}
|
}
|
||||||
|
|
||||||
ColumnLayout {
|
ColumnLayout {
|
||||||
Layout.fillWidth: true
|
Layout.fillWidth: true
|
||||||
spacing: Style.marginXS * scaling
|
Layout.alignment: Qt.AlignVCenter
|
||||||
|
spacing: 0
|
||||||
|
|
||||||
// SSID
|
// SSID
|
||||||
NText {
|
NText {
|
||||||
|
Layout.fillWidth: true
|
||||||
text: modelData.ssid || "Unknown Network"
|
text: modelData.ssid || "Unknown Network"
|
||||||
font.pointSize: Style.fontSizeNormal * scaling
|
font.pointSize: Style.fontSizeNormal * scaling
|
||||||
elide: Text.ElideRight
|
elide: Text.ElideRight
|
||||||
Layout.fillWidth: true
|
color: networkMouseArea.containsMouse ? Color.mSurface : Color.mOnSurface
|
||||||
color: modelData.connected ? Color.mSurface : (networkMouseArea.containsMouse ? Color.mSurface : Color.mOnSurface)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Security Protocol
|
// Security Protocol
|
||||||
NText {
|
NText {
|
||||||
text: modelData.security && modelData.security !== "--" ? modelData.security : "Open"
|
text: modelData.security && modelData.security !== "--" ? modelData.security : "Open"
|
||||||
font.pointSize: Style.fontSizeXS * scaling
|
font.pointSize: Style.fontSizeXXS * scaling
|
||||||
elide: Text.ElideRight
|
|
||||||
Layout.fillWidth: true
|
|
||||||
color: modelData.connected ? Color.mSurface : (networkMouseArea.containsMouse ? Color.mSurface : Color.mOnSurface)
|
|
||||||
}
|
|
||||||
|
|
||||||
NText {
|
|
||||||
visible: NetworkService.connectStatusSsid === modelData.ssid
|
|
||||||
&& NetworkService.connectStatus === "error" && NetworkService.connectError.length > 0
|
|
||||||
text: NetworkService.connectError
|
|
||||||
color: Color.mError
|
|
||||||
font.pointSize: Style.fontSizeXS * scaling
|
|
||||||
elide: Text.ElideRight
|
elide: Text.ElideRight
|
||||||
Layout.fillWidth: true
|
Layout.fillWidth: true
|
||||||
|
color: networkMouseArea.containsMouse ? Color.mSurface : Color.mOnSurface
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -203,17 +210,25 @@ NPanel {
|
||||||
NBusyIndicator {
|
NBusyIndicator {
|
||||||
visible: NetworkService.connectingSsid === modelData.ssid
|
visible: NetworkService.connectingSsid === modelData.ssid
|
||||||
running: NetworkService.connectingSsid === modelData.ssid
|
running: NetworkService.connectingSsid === modelData.ssid
|
||||||
color: Color.mPrimary
|
color: networkMouseArea.containsMouse ? Color.mSurface : Color.mOnSurface
|
||||||
anchors.centerIn: parent
|
anchors.centerIn: parent
|
||||||
size: Style.baseWidgetSize * 0.7 * scaling
|
size: Style.baseWidgetSize * 0.7 * scaling
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
NText {
|
RowLayout {
|
||||||
visible: modelData.connected
|
visible: modelData.connected
|
||||||
text: "connected"
|
NText {
|
||||||
font.pointSize: Style.fontSizeXS * scaling
|
text: "Connected"
|
||||||
color: modelData.connected ? Color.mSurface : (networkMouseArea.containsMouse ? Color.mSurface : Color.mOnSurface)
|
font.pointSize: Style.fontSizeXS * scaling
|
||||||
|
color: networkMouseArea.containsMouse ? Color.mSurface : Color.mOnSurface
|
||||||
|
Layout.alignment: Qt.AlignVCenter
|
||||||
|
}
|
||||||
|
NIcon {
|
||||||
|
text: "check"
|
||||||
|
font.pointSize: Style.fontSizeXXL * scaling
|
||||||
|
color: networkMouseArea.containsMouse ? Color.mSurface : Color.mOnSurface
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -224,6 +239,7 @@ NPanel {
|
||||||
onClicked: {
|
onClicked: {
|
||||||
if (modelData.connected) {
|
if (modelData.connected) {
|
||||||
NetworkService.disconnectNetwork(modelData.ssid)
|
NetworkService.disconnectNetwork(modelData.ssid)
|
||||||
|
showPasswordPrompt = false
|
||||||
} else if (NetworkService.isSecured(modelData.security) && !modelData.existing) {
|
} else if (NetworkService.isSecured(modelData.security) && !modelData.existing) {
|
||||||
passwordPromptSsid = modelData.ssid
|
passwordPromptSsid = modelData.ssid
|
||||||
showPasswordPrompt = true
|
showPasswordPrompt = true
|
||||||
|
|
@ -240,11 +256,11 @@ NPanel {
|
||||||
|
|
||||||
// Password prompt section
|
// Password prompt section
|
||||||
Rectangle {
|
Rectangle {
|
||||||
id: passwordPromptSection
|
visible: modelData.ssid === passwordPromptSsid && showPasswordPrompt
|
||||||
Layout.fillWidth: true
|
Layout.fillWidth: true
|
||||||
Layout.preferredHeight: modelData.ssid === passwordPromptSsid && showPasswordPrompt ? 60 : 0
|
Layout.preferredHeight: modelData.ssid === passwordPromptSsid && showPasswordPrompt ? 60 : 0
|
||||||
Layout.margins: Style.marginS * scaling
|
Layout.margins: Style.marginS * scaling
|
||||||
visible: modelData.ssid === passwordPromptSsid && showPasswordPrompt
|
|
||||||
color: Color.mSurfaceVariant
|
color: Color.mSurfaceVariant
|
||||||
radius: Style.radiusS * scaling
|
radius: Style.radiusS * scaling
|
||||||
|
|
||||||
|
|
@ -280,8 +296,10 @@ NPanel {
|
||||||
echoMode: TextInput.Password
|
echoMode: TextInput.Password
|
||||||
onTextChanged: passwordInput = text
|
onTextChanged: passwordInput = text
|
||||||
onAccepted: {
|
onAccepted: {
|
||||||
NetworkService.submitPassword(passwordPromptSsid, passwordInput)
|
if (passwordInput !== "") {
|
||||||
showPasswordPrompt = false
|
NetworkService.submitPassword(passwordPromptSsid, passwordInput)
|
||||||
|
showPasswordPrompt = false
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
MouseArea {
|
MouseArea {
|
||||||
|
|
@ -315,8 +333,10 @@ NPanel {
|
||||||
MouseArea {
|
MouseArea {
|
||||||
anchors.fill: parent
|
anchors.fill: parent
|
||||||
onClicked: {
|
onClicked: {
|
||||||
NetworkService.submitPassword(passwordPromptSsid, passwordInput)
|
if (passwordInput !== "") {
|
||||||
showPasswordPrompt = false
|
NetworkService.submitPassword(passwordPromptSsid, passwordInput)
|
||||||
|
showPasswordPrompt = false
|
||||||
|
}
|
||||||
}
|
}
|
||||||
cursorShape: Qt.PointingHandCursor
|
cursorShape: Qt.PointingHandCursor
|
||||||
hoverEnabled: true
|
hoverEnabled: true
|
||||||
|
|
@ -324,6 +344,13 @@ NPanel {
|
||||||
onExited: parent.color = Color.mPrimary
|
onExited: parent.color = Color.mPrimary
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
NIconButton {
|
||||||
|
icon: "close"
|
||||||
|
onClicked: {
|
||||||
|
showPasswordPrompt = false
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue