diff --git a/libnymea-app/models/wirelessaccesspointsproxy.cpp b/libnymea-app/models/wirelessaccesspointsproxy.cpp index 6e373d98..534e1467 100644 --- a/libnymea-app/models/wirelessaccesspointsproxy.cpp +++ b/libnymea-app/models/wirelessaccesspointsproxy.cpp @@ -49,13 +49,57 @@ void WirelessAccessPointsProxy::setAccessPoints(WirelessAccessPoints *accessPoin { m_accessPoints = accessPoints; emit accessPointsChanged(); + setSourceModel(m_accessPoints); - connect(accessPoints, &WirelessAccessPoints::countChanged, this, &WirelessAccessPointsProxy::countChanged); + connect(accessPoints, &WirelessAccessPoints::countChanged, this, [this](){ + sort(0, Qt::DescendingOrder); + invalidateFilter(); + emit countChanged(); + }); + setSortRole(WirelessAccessPoints::WirelessAccesspointRoleSignalStrength); sort(0, Qt::DescendingOrder); + + invalidateFilter(); + + emit countChanged(); } WirelessAccessPoint *WirelessAccessPointsProxy::get(int index) const { return m_accessPoints->get(mapToSource(this->index(index, 0)).row()); } + +bool WirelessAccessPointsProxy::showDuplicates() const +{ + return m_showDuplicates; +} + +void WirelessAccessPointsProxy::setShowDuplicates(bool showDuplicates) +{ + m_showDuplicates = showDuplicates; + emit showDuplicatesChanged(); + + sort(0, Qt::DescendingOrder); + invalidateFilter(); + + emit countChanged(); +} + +bool WirelessAccessPointsProxy::filterAcceptsRow(int source_row, const QModelIndex &source_parent) const +{ + Q_UNUSED(source_parent) + + if (m_showDuplicates) + return true; + + WirelessAccessPoint *accessPoint = m_accessPoints->get(source_row); + // Check if this is the best signal strenght, otherwise filter out... + foreach (WirelessAccessPoint *ap, m_accessPoints->wirelessAccessPoints()) { + if (ap->ssid() == accessPoint->ssid() && ap->signalStrength() > accessPoint->signalStrength()) { + return false; + } + } + + return true; +} diff --git a/libnymea-app/models/wirelessaccesspointsproxy.h b/libnymea-app/models/wirelessaccesspointsproxy.h index 6237e050..f6c1fe52 100644 --- a/libnymea-app/models/wirelessaccesspointsproxy.h +++ b/libnymea-app/models/wirelessaccesspointsproxy.h @@ -42,6 +42,8 @@ class WirelessAccessPointsProxy : public QSortFilterProxyModel Q_OBJECT Q_PROPERTY(int count READ rowCount NOTIFY countChanged) Q_PROPERTY(WirelessAccessPoints* accessPoints READ accessPoints WRITE setAccessPoints) + Q_PROPERTY(bool showDuplicates READ showDuplicates WRITE setShowDuplicates NOTIFY showDuplicatesChanged FINAL) + public: explicit WirelessAccessPointsProxy(QObject *parent = nullptr); @@ -50,12 +52,20 @@ public: Q_INVOKABLE WirelessAccessPoint* get(int index) const; + bool showDuplicates() const; + void setShowDuplicates(bool showDuplicates); + signals: void countChanged(); void accessPointsChanged(); + void showDuplicatesChanged(); + +protected: + bool filterAcceptsRow(int source_row, const QModelIndex &source_parent) const override; private: WirelessAccessPoints *m_accessPoints = nullptr; + bool m_showDuplicates = false; }; diff --git a/nymea-app/resources.qrc b/nymea-app/resources.qrc index a31fc172..fc7cc0ec 100644 --- a/nymea-app/resources.qrc +++ b/nymea-app/resources.qrc @@ -319,5 +319,6 @@ ui/devicepages/ThingStatusPage.qml ui/customviews/MultiStateChart.qml ui/devicepages/DeviceDetailsPage.qml + ui/system/WirelessNetworksFilterSettingsPage.qml diff --git a/nymea-app/translations/nymea-app.cs.ts b/nymea-app/translations/nymea-app.cs.ts index 1cc9366e..cb4b2b58 100644 --- a/nymea-app/translations/nymea-app.cs.ts +++ b/nymea-app/translations/nymea-app.cs.ts @@ -7524,6 +7524,21 @@ Toto prosím používejte pouze v případě, že jste si jisti tím co děláte Přidat + + WirelessNetworksFilterSettingsPage + + WiFi list options + + + + Show all networks + + + + Multiple networks with the same name get filterd out + + + WizardPageBase diff --git a/nymea-app/translations/nymea-app.de.ts b/nymea-app/translations/nymea-app.de.ts index 1395023c..a64f4a46 100644 --- a/nymea-app/translations/nymea-app.de.ts +++ b/nymea-app/translations/nymea-app.de.ts @@ -4499,7 +4499,7 @@ Bitte versuche es erneut. Maybe the hardware is already in use. Verbindung zum Modbus RTU Master kann nicht hergestellt werden. -Wird das Gerät bereits benutzt? +Eventuell wird das Gerät bereits benutzt. Are you sure you want to remove this Modbus RTU master? @@ -7504,6 +7504,21 @@ Bitte benutze diese Funktion nur wenn Du sicher bist, dass es das ist was Du mö Hinzufügen + + WirelessNetworksFilterSettingsPage + + WiFi list options + WiFi Listen Optionen + + + Show all networks + Zeige alle Netzwerke + + + Multiple networks with the same name get filterd out + Mehrere Netzwerke mit gleichem Namen werden gefiltert + + WizardPageBase diff --git a/nymea-app/translations/nymea-app.en.ts b/nymea-app/translations/nymea-app.en.ts index 1de9724e..b3901655 100644 --- a/nymea-app/translations/nymea-app.en.ts +++ b/nymea-app/translations/nymea-app.en.ts @@ -7488,6 +7488,21 @@ Please only use this if you are sure you want this and consider reporting the is + + WirelessNetworksFilterSettingsPage + + WiFi list options + + + + Show all networks + + + + Multiple networks with the same name get filterd out + + + WizardPageBase diff --git a/nymea-app/translations/nymea-app.en_US.ts b/nymea-app/translations/nymea-app.en_US.ts index f6aa7ec3..1dfff990 100644 --- a/nymea-app/translations/nymea-app.en_US.ts +++ b/nymea-app/translations/nymea-app.en_US.ts @@ -7488,6 +7488,21 @@ Please only use this if you are sure you want this and consider reporting the is + + WirelessNetworksFilterSettingsPage + + WiFi list options + + + + Show all networks + + + + Multiple networks with the same name get filterd out + + + WizardPageBase diff --git a/nymea-app/translations/nymea-app.it.ts b/nymea-app/translations/nymea-app.it.ts index 657b0151..94c34b7c 100644 --- a/nymea-app/translations/nymea-app.it.ts +++ b/nymea-app/translations/nymea-app.it.ts @@ -7488,6 +7488,21 @@ Please only use this if you are sure you want this and consider reporting the is Aggiungi + + WirelessNetworksFilterSettingsPage + + WiFi list options + + + + Show all networks + + + + Multiple networks with the same name get filterd out + + + WizardPageBase diff --git a/nymea-app/translations/nymea-app.ko.ts b/nymea-app/translations/nymea-app.ko.ts index 8d22ee5a..4c840ef3 100644 --- a/nymea-app/translations/nymea-app.ko.ts +++ b/nymea-app/translations/nymea-app.ko.ts @@ -7474,6 +7474,21 @@ Please only use this if you are sure you want this and consider reporting the is 추가 + + WirelessNetworksFilterSettingsPage + + WiFi list options + + + + Show all networks + + + + Multiple networks with the same name get filterd out + + + WizardPageBase diff --git a/nymea-app/translations/nymea-app.nl.ts b/nymea-app/translations/nymea-app.nl.ts index 333542cf..2966354a 100644 --- a/nymea-app/translations/nymea-app.nl.ts +++ b/nymea-app/translations/nymea-app.nl.ts @@ -7510,6 +7510,21 @@ Als je fouten in de niet-officiële software vindt, geef deze dan door aan de on Toevoegen + + WirelessNetworksFilterSettingsPage + + WiFi list options + + + + Show all networks + + + + Multiple networks with the same name get filterd out + + + WizardPageBase diff --git a/nymea-app/translations/nymea-app.tr.ts b/nymea-app/translations/nymea-app.tr.ts index 71060ef5..a21e4d15 100644 --- a/nymea-app/translations/nymea-app.tr.ts +++ b/nymea-app/translations/nymea-app.tr.ts @@ -7475,6 +7475,21 @@ Lütfen bunu istediğinizden eminseniz kullanın ve yayınlanmamış kanalları Ekle + + WirelessNetworksFilterSettingsPage + + WiFi list options + + + + Show all networks + + + + Multiple networks with the same name get filterd out + + + WizardPageBase diff --git a/nymea-app/translations/nymea-app.vi.ts b/nymea-app/translations/nymea-app.vi.ts index af7e6849..a7f62d87 100644 --- a/nymea-app/translations/nymea-app.vi.ts +++ b/nymea-app/translations/nymea-app.vi.ts @@ -7469,6 +7469,21 @@ Please only use this if you are sure you want this and consider reporting the is + + WirelessNetworksFilterSettingsPage + + WiFi list options + + + + Show all networks + + + + Multiple networks with the same name get filterd out + + + WizardPageBase diff --git a/nymea-app/ui/appsettings/LookAndFeelSettingsPage.qml b/nymea-app/ui/appsettings/LookAndFeelSettingsPage.qml index 8bb1f5e0..ab2caa3a 100644 --- a/nymea-app/ui/appsettings/LookAndFeelSettingsPage.qml +++ b/nymea-app/ui/appsettings/LookAndFeelSettingsPage.qml @@ -197,7 +197,6 @@ SettingsPageBase { } } - Component { id: styleChangedDialog Dialog { diff --git a/nymea-app/ui/components/WizardPageBase.qml b/nymea-app/ui/components/WizardPageBase.qml index d4fddfbe..0da95906 100644 --- a/nymea-app/ui/components/WizardPageBase.qml +++ b/nymea-app/ui/components/WizardPageBase.qml @@ -23,6 +23,8 @@ Page { readonly property int visibleContentHeight: contentFlickable.height - contentContainer.y + property var headerButtons: [] + ColumnLayout { anchors.fill: parent spacing: Style.margins @@ -46,6 +48,22 @@ Page { Layout.preferredHeight: Style.iconSize + Style.smallMargins * 2 Layout.preferredWidth: Style.iconSize + Style.smallMargins * 2 } + + Row { + id: additionalIcons + anchors { right: parent.right; top: parent.top } + visible: !d.configOverlay + width: visible ? implicitWidth : 0 + Repeater { + model: headerButtons + delegate: HeaderButton { + imageSource: root.headerButtons[index].iconSource + onClicked: root.headerButtons[index].trigger() + visible: root.headerButtons[index].visible + color: root.headerButtons[index].color + } + } + } } Flickable { diff --git a/nymea-app/ui/connection/ConnectionWizard.qml b/nymea-app/ui/connection/ConnectionWizard.qml index c3b76e6a..0139bc69 100644 --- a/nymea-app/ui/connection/ConnectionWizard.qml +++ b/nymea-app/ui/connection/ConnectionWizard.qml @@ -1,6 +1,8 @@ import QtQuick 2.3 import QtQuick.Controls 2.2 import QtQuick.Layouts 1.2 +import Qt.labs.settings 1.1 + import "../components" import Nymea 1.0 @@ -503,6 +505,29 @@ WizardPageBase { showNextButton: false onBack: pageStack.pop() + headerButtons: [ + { + iconSource: "/ui/images/filters.svg", + color: Style.iconColor, + trigger: function() { + pageStack.push(Qt.createComponent("/ui/system/WirelessNetworksFilterSettingsPage.qml"), + { wirelessAccessPointsProxy: wirelessAccessPointsModel }); + }, + visible: true + } + ] + + Settings { + id: settings + property bool wirelessShowDuplicates: false + } + + WirelessAccessPointsProxy { + id: wirelessAccessPointsModel + showDuplicates: settings.wirelessShowDuplicates + accessPoints: wifiSetup.accessPoints + } + property var wifiSetup: null Component.onCompleted: { @@ -519,15 +544,14 @@ WizardPageBase { Layout.fillWidth: true Layout.fillHeight: true - model: wifiSetup.accessPoints + model: wirelessAccessPointsModel clip: true delegate: NymeaItemDelegate { width: parent.width - text: model.ssid !== "" ? model.ssid : qsTr("Hidden Network") - subText: model.hostAddress - + subText: model.macAddress + (model.hostAddress === "" ? "" : (" (" + model.hostAddress + ")")) + prominentSubText: false iconColor: model.selectedNetwork ? Style.accentColor : "#808080" iconName: { if (model.protected) { @@ -577,7 +601,6 @@ WizardPageBase { visible: wifiSetup.wirelessServiceVersion >= 2 onClicked: { pageStack.push(hiddenWifiComponent, {wifiSetup: wifiSetup}) - } } } diff --git a/nymea-app/ui/system/NetworkSettingsPage.qml b/nymea-app/ui/system/NetworkSettingsPage.qml index 59fe8d7b..411a6c1f 100644 --- a/nymea-app/ui/system/NetworkSettingsPage.qml +++ b/nymea-app/ui/system/NetworkSettingsPage.qml @@ -32,8 +32,10 @@ import QtQuick 2.9 import QtQuick.Controls 2.1 import QtQuick.Controls.Material 2.1 import QtQuick.Layouts 1.1 +import Qt.labs.settings 1.1 + import Nymea 1.0 -import "../components" +import "qrc:/ui/components" SettingsPageBase { id: root @@ -398,11 +400,6 @@ SettingsPageBase { property WirelessNetworkDevice wirelessNetworkDevice: null - WirelessAccessPointsProxy { - id: apProxy - accessPoints: wirelessAccessPointsPage.wirelessNetworkDevice.accessPoints - } - SettingsPageSectionHeader { text: qsTr("Access Point") } @@ -442,8 +439,31 @@ SettingsPageBase { } } - SettingsPageSectionHeader { - text: qsTr("Connect to wireless network") + Settings { + id: settings + property bool wirelessShowDuplicates: false + } + + WirelessAccessPointsProxy { + id: apProxy + accessPoints: wirelessAccessPointsPage.wirelessNetworkDevice ? wirelessAccessPointsPage.wirelessNetworkDevice.accessPoints : null + showDuplicates: settings.wirelessShowDuplicates + } + + RowLayout { + Layout.fillWidth: true + SettingsPageSectionHeader { + Layout.fillWidth: true + text: qsTr("Connect to wireless network") + } + + HeaderButton { + id: filterButton + imageSource: "/ui/images/filters.svg" + color: Style.iconColor + onClicked: pageStack.push(Qt.createComponent("/ui/system/WirelessNetworksFilterSettingsPage.qml"), + { wirelessAccessPointsProxy: apProxy }); + } } Repeater { @@ -544,7 +564,7 @@ SettingsPageBase { horizontalAlignment: Text.AlignRight validator: RegExpValidator { regExp: /^((?:[0-1]?[0-9]?[0-9]|2[0-4][0-9]|25[0-5])\.){0,3}(?:[0-1]?[0-9]?[0-9]|2[0-4][0-9]|25[0-5])$/ - } + } } Label { @@ -571,7 +591,7 @@ SettingsPageBase { Layout.fillWidth: true validator: RegExpValidator { regExp: /^((?:[0-1]?[0-9]?[0-9]|2[0-4][0-9]|25[0-5])\.){0,3}(?:[0-1]?[0-9]?[0-9]|2[0-4][0-9]|25[0-5])$/ - } + } } Label { @@ -584,7 +604,7 @@ SettingsPageBase { Layout.fillWidth: true validator: RegExpValidator { regExp: /^((?:[0-1]?[0-9]?[0-9]|2[0-4][0-9]|25[0-5])\.){0,3}(?:[0-1]?[0-9]?[0-9]|2[0-4][0-9]|25[0-5])$/ - } + } } } diff --git a/nymea-app/ui/system/WirelessNetworksFilterSettingsPage.qml b/nymea-app/ui/system/WirelessNetworksFilterSettingsPage.qml new file mode 100644 index 00000000..5d6ac686 --- /dev/null +++ b/nymea-app/ui/system/WirelessNetworksFilterSettingsPage.qml @@ -0,0 +1,68 @@ +import QtQuick 2.9 +import QtQuick.Controls 2.9 +import QtQuick.Layouts 1.2 +import Qt.labs.settings 1.1 + +import "qrc:/ui/components" +import Nymea 1.0 + +Page { + id: root + + title: qsTr("WiFi list options") + + property WirelessAccessPointsProxy wirelessAccessPointsProxy: null + + header: Item { + + height: 28 + 2 * Style.margins + + RowLayout { + anchors.fill: parent + spacing: app.margins + + HeaderButton { + id: backButton + objectName: "backButton" + imageSource: "../images/back.svg" + onClicked: pageStack.pop(); + } + + Label { + Layout.fillWidth: true + id: titleLabel + wrapMode: Text.WrapAtWordBoundaryOrAnywhere + text: root.title + font.pixelSize: app.largeFont + } + } + } + + Settings { + id: settings + property bool wirelessShowDuplicates: false + } + + ColumnLayout { + anchors.left: parent.left + anchors.right: parent.right + anchors.margins: app.margins + + + NymeaItemDelegate { + Layout.fillWidth: true + text: qsTr("Show all networks") + subText: qsTr("Multiple networks with the same name get filterd out") + prominentSubText: false + progressive: false + additionalItem: Switch { + anchors.verticalCenter: parent.verticalCenter + checked: settings.wirelessShowDuplicates + onCheckedChanged: { + settings.wirelessShowDuplicates = checked + wirelessAccessPointsProxy.showDuplicates = checked + } + } + } + } +}