wpa_gui-qt4: Improve scan results signal display

Display signal strength in dBm with visual indicator in the form of a
bar for scan results displayed by wpa_gui-qt4. Any signal > -35dBm is
treated as full signal bar, signals between range of -95<->-35dBm are
displayed linearly. Convert WEXT signal level value to scale that
nl80211 typically reports in dBm. The condition which differentiates
8-bit WEXT dBm and regular dBm is probably fragile, but there is
currently no way to know what the driver is going to report for signal
strength.

Signed-off-by: Kel Modderman <kel@otaku42.de>
This commit is contained in:
Kel Modderman 2011-11-19 20:10:37 +02:00 committed by Jouni Malinen
parent 88df0ef74f
commit ef992bbd3b
4 changed files with 103 additions and 1 deletions

View file

@ -15,6 +15,7 @@
#include <cstdio>
#include "scanresults.h"
#include "signalbar.h"
#include "wpagui.h"
#include "networkconfig.h"
@ -33,6 +34,7 @@ ScanResults::ScanResults(QWidget *parent, const char *, bool, Qt::WFlags)
wpagui = NULL;
scanResultsWidget->setItemsExpandable(FALSE);
scanResultsWidget->setRootIsDecorated(FALSE);
scanResultsWidget->setItemDelegate(new SignalBar(scanResultsWidget));
}
@ -91,7 +93,7 @@ void ScanResults::updateResults()
bssid = (*it).mid(pos);
else if ((*it).startsWith("freq="))
freq = (*it).mid(pos);
else if ((*it).startsWith("qual="))
else if ((*it).startsWith("level="))
signal = (*it).mid(pos);
else if ((*it).startsWith("flags="))
flags = (*it).mid(pos);

View file

@ -0,0 +1,64 @@
/*
* wpa_gui - SignalBar class
* Copyright (c) 2011, Kel Modderman <kel@otaku42.de>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 as
* published by the Free Software Foundation.
*
* Alternatively, this software may be distributed under the terms of BSD
* license.
*
* See README and COPYING for more details.
*/
#include <cstdio>
#include <qapplication.h>
#include "signalbar.h"
SignalBar::SignalBar(QObject *parent)
: QStyledItemDelegate(parent)
{
}
SignalBar::~SignalBar()
{
}
void SignalBar::paint(QPainter *painter,
const QStyleOptionViewItem &option,
const QModelIndex &index) const
{
QStyleOptionProgressBar opts;
int signal;
if (index.column() != 3) {
QStyledItemDelegate::paint(painter, option, index);
return;
}
if (index.data().toInt() > 0)
signal = 0 - (256 - index.data().toInt());
else
signal = index.data().toInt();
opts.minimum = -95;
opts.maximum = -35;
if (signal < opts.minimum)
opts.progress = opts.minimum;
else if (signal > opts.maximum)
opts.progress = opts.maximum;
else
opts.progress = signal;
opts.text = QString::number(signal) + " dBm";
opts.textVisible = true;
opts.rect = option.rect;
QApplication::style()->drawControl(QStyle::CE_ProgressBar,
&opts, painter);
}

View file

@ -0,0 +1,34 @@
/*
* wpa_gui - SignalBar class
* Copyright (c) 2011, Kel Modderman <kel@otaku42.de>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 as
* published by the Free Software Foundation.
*
* Alternatively, this software may be distributed under the terms of BSD
* license.
*
* See README and COPYING for more details.
*/
#ifndef SIGNALBAR_H
#define SIGNALBAR_H
#include <QObject>
#include <QStyledItemDelegate>
class SignalBar : public QStyledItemDelegate
{
Q_OBJECT
public:
SignalBar(QObject *parent = 0);
~SignalBar();
virtual void paint(QPainter *painter,
const QStyleOptionViewItem &option,
const QModelIndex &index) const ;
};
#endif /* SIGNALBAR_H */

View file

@ -34,6 +34,7 @@ HEADERS += wpamsg.h \
wpagui.h \
eventhistory.h \
scanresults.h \
signalbar.h \
userdatarequest.h \
networkconfig.h \
addinterface.h \
@ -44,6 +45,7 @@ SOURCES += main.cpp \
wpagui.cpp \
eventhistory.cpp \
scanresults.cpp \
signalbar.cpp \
userdatarequest.cpp \
networkconfig.cpp \
addinterface.cpp \