mirror of
https://github.com/vanhoefm/fragattacks.git
synced 2024-11-25 08:48:31 -05:00
ef992bbd3b
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>
65 lines
1.3 KiB
C++
65 lines
1.3 KiB
C++
/*
|
|
* 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);
|
|
}
|