Use new fancy stars also on Status page
This commit is contained in:
parent
19cfcfe9b6
commit
5928dc3da6
5 changed files with 168 additions and 172 deletions
37
src/helper.cpp
Normal file
37
src/helper.cpp
Normal file
|
|
@ -0,0 +1,37 @@
|
|||
/*
|
||||
* wpaCute - A graphical wpa_supplicant front end
|
||||
* Copyright (C) 2018, 2022, 2024 loh.tar@googlemail.com
|
||||
*
|
||||
* Collection of Helper Functions
|
||||
* Copyright (C) 2024 loh.tar@googlemail.com
|
||||
*
|
||||
* This software may be distributed under the terms of the BSD license.
|
||||
* See COPYING for more details.
|
||||
*/
|
||||
|
||||
#include "helper.h"
|
||||
|
||||
QString Helper::signalToHumanText(const QString& signal) {
|
||||
|
||||
const int s = signal.toInt();
|
||||
if (s < -87) {
|
||||
return signal + "dBm ☆☆☆☆☆";
|
||||
} else if (s < -80) {
|
||||
return signal + "dBm ★☆☆☆☆";
|
||||
} else if (s < -73) {
|
||||
return signal + "dBm ★★☆☆☆";
|
||||
} else if (s < -65) {
|
||||
return signal + "dBm ★★★☆☆";
|
||||
} else if (s < -58) {
|
||||
return signal + "dBm ★★★★☆";
|
||||
} else {
|
||||
return signal + "dBm ★★★★★";
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
QString Helper::signalToHumanText(int signal) {
|
||||
|
||||
return signalToHumanText(QString::number(signal));
|
||||
}
|
||||
|
||||
24
src/helper.h
24
src/helper.h
|
|
@ -9,24 +9,16 @@
|
|||
* See COPYING for more details.
|
||||
*/
|
||||
|
||||
#ifndef HELPER_H
|
||||
#define HELPER_H
|
||||
|
||||
#include <QString>
|
||||
|
||||
namespace Helper {
|
||||
|
||||
QString signalToHumanText(const QString& signal) {
|
||||
const int s = signal.toInt();
|
||||
if (s < -87) {
|
||||
return signal + "dBm ☆☆☆☆☆";
|
||||
} else if (s < -80) {
|
||||
return signal + "dBm ★☆☆☆☆";
|
||||
} else if (s < -73) {
|
||||
return signal + "dBm ★★☆☆☆";
|
||||
} else if (s < -65) {
|
||||
return signal + "dBm ★★★☆☆";
|
||||
} else if (s < -58) {
|
||||
return signal + "dBm ★★★★☆";
|
||||
} else {
|
||||
return signal + "dBm ★★★★★";
|
||||
}
|
||||
};
|
||||
QString signalToHumanText(const QString& signal);
|
||||
QString signalToHumanText(int signal);
|
||||
|
||||
}
|
||||
|
||||
#endif /* HELPER_H */
|
||||
|
|
|
|||
|
|
@ -61,6 +61,7 @@ SOURCES += main.cpp \
|
|||
addinterface.cpp \
|
||||
peers.cpp \
|
||||
stringquery.cpp \
|
||||
helper.cpp \
|
||||
about.cpp \
|
||||
../wpa_supplicant/src/common/wpa_ctrl.c
|
||||
|
||||
|
|
|
|||
|
|
@ -31,6 +31,7 @@
|
|||
|
||||
#include "about.h"
|
||||
#include "eventhistory.h"
|
||||
#include "helper.h"
|
||||
#include "networkconfig.h"
|
||||
#include "peers.h"
|
||||
#include "scanresults.h"
|
||||
|
|
@ -760,7 +761,7 @@ void WpaGui::setState(const WpaStateType state) {
|
|||
networkMenu->setEnabled(false);
|
||||
wpaguiTab->setTabEnabled(wpaguiTab->indexOf(networksTab), false);
|
||||
wpaguiTab->setCurrentWidget(eventTab);
|
||||
rssiBar->hide();
|
||||
textRssi->hide();
|
||||
letTheDogOut();
|
||||
break;
|
||||
case WpaUnknown: // TC
|
||||
|
|
@ -768,7 +769,7 @@ void WpaGui::setState(const WpaStateType state) {
|
|||
// icon = ;
|
||||
stateText = tr("Unknown");
|
||||
tally.insert(NetworkNeedsUpdate);
|
||||
rssiBar->hide();
|
||||
textRssi->hide();
|
||||
break;
|
||||
case WpaObscure: // TC
|
||||
wpaState = WpaObscure;
|
||||
|
|
@ -803,7 +804,7 @@ void WpaGui::setState(const WpaStateType state) {
|
|||
closeDialog(peersWindow);
|
||||
tally.insert(NetworkNeedsUpdate);
|
||||
if (ctrl_conn) { wpa_ctrl_close(ctrl_conn); ctrl_conn = NULL; }
|
||||
rssiBar->hide();
|
||||
textRssi->hide();
|
||||
// Now, polling is mandatory
|
||||
letTheDogOut();
|
||||
break;
|
||||
|
|
@ -832,7 +833,7 @@ void WpaGui::setState(const WpaStateType state) {
|
|||
scanAction->setEnabled(false);
|
||||
peersAction->setEnabled(false);
|
||||
tally.insert(NetworkNeedsUpdate);
|
||||
rssiBar->hide();
|
||||
textRssi->hide();
|
||||
// Now, polling is mandatory
|
||||
letTheDogOut();
|
||||
break;
|
||||
|
|
@ -873,7 +874,7 @@ void WpaGui::setState(const WpaStateType state) {
|
|||
disconReconAction->setStatusTip(StpWpsActTTTxt);
|
||||
disconReconAction->setEnabled(true);
|
||||
tally.insert(WpsRunning);
|
||||
rssiBar->hide();
|
||||
textRssi->hide();
|
||||
break;
|
||||
case WpaInactive: // FR
|
||||
wpaState = WpaInactive;
|
||||
|
|
@ -883,7 +884,7 @@ void WpaGui::setState(const WpaStateType state) {
|
|||
disconReconAction->setStatusTip(DiscActTTTxt);
|
||||
disconReconAction->setEnabled(true);
|
||||
tally.insert(NetworkNeedsUpdate);
|
||||
rssiBar->hide();
|
||||
textRssi->hide();
|
||||
// The wpa_supplicant doesn't report the change
|
||||
// inactive -> disconnected, so we need a work around,
|
||||
letTheDogOut();
|
||||
|
|
@ -898,7 +899,7 @@ void WpaGui::setState(const WpaStateType state) {
|
|||
wpsAction->setEnabled(tally.contains(WpsIsSupported));
|
||||
scanAction->setEnabled(true);
|
||||
peersAction->setEnabled(true);
|
||||
rssiBar->hide();
|
||||
textRssi->hide();
|
||||
// The wpa_supplicant doesn't report the change
|
||||
// scanning -> disconnected, so we need a work around
|
||||
letTheDogOut(BorderCollie); // No PomDog, the scan need some time
|
||||
|
|
@ -911,7 +912,7 @@ void WpaGui::setState(const WpaStateType state) {
|
|||
disconReconAction->setStatusTip(RecActTTTxt);
|
||||
disconReconAction->setEnabled(true);
|
||||
tally.insert(NetworkNeedsUpdate);
|
||||
rssiBar->hide();
|
||||
textRssi->hide();
|
||||
// The wpa_supplicant doesn't report the change
|
||||
// disconnected -> inactive, so we need a work around because that
|
||||
// happens when you disable your connected network with no alternatives left
|
||||
|
|
@ -925,7 +926,7 @@ void WpaGui::setState(const WpaStateType state) {
|
|||
wpaState = WpaLostSignal;
|
||||
icon = TrayIconSignalNone;
|
||||
stateText = tr("Lost signal");
|
||||
rssiBar->hide();
|
||||
textRssi->hide();
|
||||
trayMessage(stateText
|
||||
+ tr(" from %1 - %2").arg(textSsid->text()).arg(textBssid->text())
|
||||
, LogThis, QSystemTrayIcon::Warning);
|
||||
|
|
@ -938,7 +939,7 @@ void WpaGui::setState(const WpaStateType state) {
|
|||
disconReconAction->setStatusTip(DiscActTTTxt);
|
||||
disconReconAction->setEnabled(true);
|
||||
tally.insert(NetworkNeedsUpdate);
|
||||
rssiBar->show();
|
||||
textRssi->show();
|
||||
trayMessage(stateText
|
||||
+ tr(" to %1 - %2").arg(textSsid->text()).arg(textBssid->text())
|
||||
, LogThis);
|
||||
|
|
@ -1439,7 +1440,7 @@ void WpaGui::updateSignalMeter() {
|
|||
}
|
||||
|
||||
debug("RSSI value: %d", rssi_value);
|
||||
rssiBar->setValue(rssi_value);
|
||||
textRssi->setText(Helper::signalToHumanText(rssi_value));
|
||||
|
||||
/*
|
||||
* NOTE: The code below assumes, that the unit of the value returned
|
||||
|
|
@ -2199,7 +2200,7 @@ void WpaGui::showTrayStatus() {
|
|||
msg.append(mask.arg(ssidLabel->text(), lw)
|
||||
.arg(textSsid->text(), tw));
|
||||
msg.append(mask.arg(rssiLabel->text(), lw)
|
||||
.arg(rssiBar->text(), tw));
|
||||
.arg(textRssi->text(), tw));
|
||||
msg.append(mask.arg(bssidLabel->text(), lw)
|
||||
.arg(textBssid->text(), tw));
|
||||
msg.append(mask.arg(authenticationLabel->text(), lw)
|
||||
|
|
|
|||
163
src/wpagui.ui
163
src/wpagui.ui
|
|
@ -145,156 +145,121 @@
|
|||
<property name="frameShadow">
|
||||
<enum>QFrame::Plain</enum>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="gridLayout_3">
|
||||
<item row="0" column="1" rowspan="7">
|
||||
<spacer name="horizontalSpacer_5">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeType">
|
||||
<enum>QSizePolicy::Fixed</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>9</width>
|
||||
<height>218</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item row="0" column="0">
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_3">
|
||||
<item>
|
||||
<layout class="QVBoxLayout" name="verticalLayout_5">
|
||||
<item>
|
||||
<widget class="QLabel" name="statusLabel">
|
||||
<property name="text">
|
||||
<string>Status:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="2">
|
||||
<widget class="QProgressBar" name="rssiBar">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
|
||||
<horstretch>1</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="layoutDirection">
|
||||
<enum>Qt::RightToLeft</enum>
|
||||
</property>
|
||||
<property name="minimum">
|
||||
<number>-95</number>
|
||||
</property>
|
||||
<property name="maximum">
|
||||
<number>-35</number>
|
||||
</property>
|
||||
<property name="value">
|
||||
<number>-68</number>
|
||||
</property>
|
||||
<property name="invertedAppearance">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="textDirection">
|
||||
<enum>QProgressBar::TopToBottom</enum>
|
||||
</property>
|
||||
<property name="format">
|
||||
<string>%vdBm</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="3" column="0">
|
||||
<widget class="QLabel" name="bssidLabel">
|
||||
<property name="text">
|
||||
<string>BSSID:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="3" column="2">
|
||||
<widget class="QLabel" name="textBssid">
|
||||
<property name="text">
|
||||
<string><bssid></string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="0">
|
||||
<item>
|
||||
<widget class="QLabel" name="ssidLabel">
|
||||
<property name="text">
|
||||
<string>SSID:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="0">
|
||||
<item>
|
||||
<widget class="QLabel" name="rssiLabel">
|
||||
<property name="text">
|
||||
<string>Signal:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="4" column="0">
|
||||
<item>
|
||||
<widget class="QLabel" name="bssidLabel">
|
||||
<property name="text">
|
||||
<string>BSSID:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLabel" name="authenticationLabel">
|
||||
<property name="text">
|
||||
<string>Authentication:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="4" column="2">
|
||||
<widget class="QLabel" name="textAuthentication">
|
||||
<property name="text">
|
||||
<string><auth></string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="5" column="0">
|
||||
<item>
|
||||
<widget class="QLabel" name="encryptionLabel">
|
||||
<property name="text">
|
||||
<string>Encryption:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="2">
|
||||
<widget class="QLabel" name="textStatus">
|
||||
<property name="text">
|
||||
<string><status></string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="5" column="2">
|
||||
<widget class="QLabel" name="textEncryption">
|
||||
<property name="text">
|
||||
<string><encryp></string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="6" column="0">
|
||||
<item>
|
||||
<widget class="QLabel" name="ipAddressLabel">
|
||||
<property name="text">
|
||||
<string>IP address:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="6" column="2">
|
||||
<widget class="QLabel" name="textIpAddress">
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QVBoxLayout" name="verticalLayout_6">
|
||||
<item>
|
||||
<widget class="QLabel" name="textStatus">
|
||||
<property name="text">
|
||||
<string><ip-addr></string>
|
||||
<string><status></string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="2">
|
||||
<item>
|
||||
<widget class="QLabel" name="textSsid">
|
||||
<property name="text">
|
||||
<string><ssid></string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="3">
|
||||
<spacer name="horizontalSpacer_6">
|
||||
<item>
|
||||
<widget class="QLabel" name="textRssi">
|
||||
<property name="text">
|
||||
<string><rssi></string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLabel" name="textBssid">
|
||||
<property name="text">
|
||||
<string><bssid></string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLabel" name="textAuthentication">
|
||||
<property name="text">
|
||||
<string><auth></string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLabel" name="textEncryption">
|
||||
<property name="text">
|
||||
<string><encryp></string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLabel" name="textIpAddress">
|
||||
<property name="text">
|
||||
<string><ip-addr></string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<spacer name="horizontalSpacer_5">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeType">
|
||||
<enum>QSizePolicy::Expanding</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>2</width>
|
||||
<width>282</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue