mirror of
https://github.com/dragonpilot/dragonpilot.git
synced 2026-06-25 07:52:03 +08:00
UI: make wifi network sorting more stable (#29376)
* stable sort * fix typo,rename to strengthLevel
This commit is contained in:
@@ -295,7 +295,7 @@ void WifiUI::refresh() {
|
||||
status_icon = lock;
|
||||
}
|
||||
bool show_forget_btn = wifi->isKnownConnection(network.ssid) && !is_tethering_enabled;
|
||||
QPixmap strength = strengths[std::clamp((int)round(network.strength / 33.), 0, 3)];
|
||||
QPixmap strength = strengths[strengthLevel(network.strength)];
|
||||
|
||||
auto item = getItem(n++);
|
||||
item->setItem(network, status_icon, show_forget_btn, strength);
|
||||
|
||||
@@ -8,11 +8,8 @@
|
||||
#include "selfdrive/ui/qt/util.h"
|
||||
|
||||
bool compare_by_strength(const Network &a, const Network &b) {
|
||||
if (a.connected == ConnectedType::CONNECTED) return true;
|
||||
if (b.connected == ConnectedType::CONNECTED) return false;
|
||||
if (a.connected == ConnectedType::CONNECTING) return true;
|
||||
if (b.connected == ConnectedType::CONNECTING) return false;
|
||||
return a.strength > b.strength;
|
||||
return std::tuple(a.connected, strengthLevel(a.strength), b.ssid) >
|
||||
std::tuple(b.connected, strengthLevel(b.strength), a.ssid);
|
||||
}
|
||||
|
||||
template <typename T = QDBusMessage, typename... Args>
|
||||
|
||||
@@ -33,6 +33,7 @@ struct Network {
|
||||
SecurityType security_type;
|
||||
};
|
||||
bool compare_by_strength(const Network &a, const Network &b);
|
||||
inline int strengthLevel(unsigned int strength) { return std::clamp((int)round(strength / 33.), 0, 3); }
|
||||
|
||||
class WifiManager : public QObject {
|
||||
Q_OBJECT
|
||||
|
||||
Reference in New Issue
Block a user