mirror of
https://github.com/Quill-OS/quill.git
synced 2024-12-27 16:17:21 -08:00
full scanning networks, turning on
This commit is contained in:
parent
ec81f72d2d
commit
2cf679a303
10 changed files with 224 additions and 13 deletions
|
@ -86,5 +86,7 @@
|
||||||
<file>resources/view-highlights.png</file>
|
<file>resources/view-highlights.png</file>
|
||||||
<file>resources/stop.png</file>
|
<file>resources/stop.png</file>
|
||||||
<file>resources/refresh.png</file>
|
<file>resources/refresh.png</file>
|
||||||
|
<file>resources/lock-fill.png</file>
|
||||||
|
<file>resources/lock-unlock-fill.png</file>
|
||||||
</qresource>
|
</qresource>
|
||||||
</RCC>
|
</RCC>
|
||||||
|
|
|
@ -1072,6 +1072,7 @@ namespace {
|
||||||
global::wifi::WifiState checkWifiState() {
|
global::wifi::WifiState checkWifiState() {
|
||||||
QProcess *wifiStateProcess = new QProcess();
|
QProcess *wifiStateProcess = new QProcess();
|
||||||
// Important to remember thats its in chroot...
|
// Important to remember thats its in chroot...
|
||||||
|
// What can be run in the chroot, should be run here. ibxd is a bit a mess
|
||||||
QString path = "/external_root/usr/local/bin/wifi/wifi_status.sh";
|
QString path = "/external_root/usr/local/bin/wifi/wifi_status.sh";
|
||||||
QStringList args;
|
QStringList args;
|
||||||
wifiStateProcess->start(path, args);
|
wifiStateProcess->start(path, args);
|
||||||
|
|
BIN
src/resources/lock-fill.png
Normal file
BIN
src/resources/lock-fill.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 315 B |
BIN
src/resources/lock-unlock-fill.png
Normal file
BIN
src/resources/lock-unlock-fill.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 291 B |
|
@ -6,9 +6,49 @@ network::network(QWidget *parent) :
|
||||||
ui(new Ui::network)
|
ui(new Ui::network)
|
||||||
{
|
{
|
||||||
ui->setupUi(this);
|
ui->setupUi(this);
|
||||||
|
|
||||||
|
// Stylesheet, style & misc.
|
||||||
|
QFile stylesheetFile("/mnt/onboard/.adds/inkbox/eink.qss");
|
||||||
|
stylesheetFile.open(QFile::ReadOnly);
|
||||||
|
this->setStyleSheet(stylesheetFile.readAll());
|
||||||
|
stylesheetFile.close();
|
||||||
|
|
||||||
|
// Buttons
|
||||||
|
ui->encryptionIcon->setProperty("type", "borderless");
|
||||||
|
ui->encryptionIcon->setStyleSheet("QPushButton[type='borderless']:pressed { background: white; color: white; border: none; }");
|
||||||
|
|
||||||
|
ui->enterButton->setProperty("type", "borderless");
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
network::~network()
|
network::~network()
|
||||||
{
|
{
|
||||||
delete ui;
|
delete ui;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void network::applyVariables() {
|
||||||
|
ui->signalStrengthLabel->setText(QString::number(mainData.signal) + "%");
|
||||||
|
|
||||||
|
// limit name size, maybe device specific
|
||||||
|
QString cuttedSingleData = mainData.name;
|
||||||
|
if(cuttedSingleData.count() > 27)
|
||||||
|
{
|
||||||
|
cuttedSingleData = cuttedSingleData.remove(24, cuttedSingleData.count() - 24);
|
||||||
|
cuttedSingleData.append("...");
|
||||||
|
}
|
||||||
|
ui->nameLabel->setText(cuttedSingleData);
|
||||||
|
|
||||||
|
if(mainData.encryption == true) {
|
||||||
|
ui->encryptionIcon->setIcon(QIcon("://resources/lock-fill.png"));
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
ui->encryptionIcon->setIcon(QIcon("://resources/lock-unlock-fill.png"));
|
||||||
|
}
|
||||||
|
|
||||||
|
if(currentlyConnectedNetwork == mainData.name) {
|
||||||
|
ui->frame->setStyleSheet(".QFrame{background-color: grey; border: 3px solid black; border-radius: 10px;}");
|
||||||
|
} else {
|
||||||
|
ui->frame->setStyleSheet(".QFrame{background-color: white; border: 3px solid black; border-radius: 10px;}");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
@ -19,6 +19,9 @@ public:
|
||||||
global::wifi::wifiNetworkData mainData;
|
global::wifi::wifiNetworkData mainData;
|
||||||
QString currentlyConnectedNetwork;
|
QString currentlyConnectedNetwork;
|
||||||
|
|
||||||
|
public slots:
|
||||||
|
void applyVariables();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Ui::network *ui;
|
Ui::network *ui;
|
||||||
};
|
};
|
||||||
|
|
|
@ -20,6 +20,18 @@
|
||||||
<string>Form</string>
|
<string>Form</string>
|
||||||
</property>
|
</property>
|
||||||
<layout class="QHBoxLayout" name="horizontalLayout">
|
<layout class="QHBoxLayout" name="horizontalLayout">
|
||||||
|
<property name="leftMargin">
|
||||||
|
<number>17</number>
|
||||||
|
</property>
|
||||||
|
<property name="topMargin">
|
||||||
|
<number>4</number>
|
||||||
|
</property>
|
||||||
|
<property name="rightMargin">
|
||||||
|
<number>17</number>
|
||||||
|
</property>
|
||||||
|
<property name="bottomMargin">
|
||||||
|
<number>4</number>
|
||||||
|
</property>
|
||||||
<item>
|
<item>
|
||||||
<widget class="QFrame" name="frame">
|
<widget class="QFrame" name="frame">
|
||||||
<property name="sizePolicy">
|
<property name="sizePolicy">
|
||||||
|
@ -32,9 +44,24 @@
|
||||||
<enum>QFrame::StyledPanel</enum>
|
<enum>QFrame::StyledPanel</enum>
|
||||||
</property>
|
</property>
|
||||||
<property name="frameShadow">
|
<property name="frameShadow">
|
||||||
<enum>QFrame::Raised</enum>
|
<enum>QFrame::Plain</enum>
|
||||||
|
</property>
|
||||||
|
<property name="lineWidth">
|
||||||
|
<number>3</number>
|
||||||
</property>
|
</property>
|
||||||
<layout class="QHBoxLayout" name="horizontalLayout_2">
|
<layout class="QHBoxLayout" name="horizontalLayout_2">
|
||||||
|
<property name="leftMargin">
|
||||||
|
<number>3</number>
|
||||||
|
</property>
|
||||||
|
<property name="topMargin">
|
||||||
|
<number>3</number>
|
||||||
|
</property>
|
||||||
|
<property name="rightMargin">
|
||||||
|
<number>3</number>
|
||||||
|
</property>
|
||||||
|
<property name="bottomMargin">
|
||||||
|
<number>3</number>
|
||||||
|
</property>
|
||||||
<item>
|
<item>
|
||||||
<widget class="QLabel" name="signalStrengthLabel">
|
<widget class="QLabel" name="signalStrengthLabel">
|
||||||
<property name="text">
|
<property name="text">
|
||||||
|
@ -42,6 +69,19 @@
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="Line" name="line">
|
||||||
|
<property name="frameShadow">
|
||||||
|
<enum>QFrame::Plain</enum>
|
||||||
|
</property>
|
||||||
|
<property name="lineWidth">
|
||||||
|
<number>3</number>
|
||||||
|
</property>
|
||||||
|
<property name="orientation">
|
||||||
|
<enum>Qt::Vertical</enum>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
<item>
|
<item>
|
||||||
<widget class="QLabel" name="nameLabel">
|
<widget class="QLabel" name="nameLabel">
|
||||||
<property name="text">
|
<property name="text">
|
||||||
|
|
|
@ -3,6 +3,7 @@
|
||||||
#include <QScreen>
|
#include <QScreen>
|
||||||
#include <QDesktopWidget>
|
#include <QDesktopWidget>
|
||||||
#include <QMessageBox>
|
#include <QMessageBox>
|
||||||
|
#include <QScrollBar>
|
||||||
|
|
||||||
#include "wifidialog.h"
|
#include "wifidialog.h"
|
||||||
#include "ui_wifidialog.h"
|
#include "ui_wifidialog.h"
|
||||||
|
@ -29,6 +30,12 @@ wifiDialog::wifiDialog(QWidget *parent) :
|
||||||
|
|
||||||
ui->Wificheckbox->setStyleSheet("QCheckBox::indicator { width:50px; height: 50px; }");
|
ui->Wificheckbox->setStyleSheet("QCheckBox::indicator { width:50px; height: 50px; }");
|
||||||
|
|
||||||
|
ui->returnBtn->setProperty("type", "borderless");
|
||||||
|
|
||||||
|
// Scroll bar
|
||||||
|
// Needed for the nia.
|
||||||
|
ui->scrollArea->verticalScrollBar()->setStyleSheet("QScrollBar:vertical { width: 50px; }");
|
||||||
|
|
||||||
// Size
|
// Size
|
||||||
QRect screenGeometry = QGuiApplication::screens()[0]->geometry();
|
QRect screenGeometry = QGuiApplication::screens()[0]->geometry();
|
||||||
this->setFixedWidth(screenGeometry.width());
|
this->setFixedWidth(screenGeometry.width());
|
||||||
|
@ -49,7 +56,13 @@ wifiDialog::wifiDialog(QWidget *parent) :
|
||||||
ui->logBtn->setFixedHeight(ui->logBtn->height() + heighIncrease);
|
ui->logBtn->setFixedHeight(ui->logBtn->height() + heighIncrease);
|
||||||
ui->refreshBtn->setFixedHeight(ui->refreshBtn->height() + heighIncrease);
|
ui->refreshBtn->setFixedHeight(ui->refreshBtn->height() + heighIncrease);
|
||||||
|
|
||||||
//ui->cancelBtn->setProperty("type", "borderless");
|
// And set wifi checkbox state. also ignore this first call
|
||||||
|
global::wifi::WifiState currentWifiState = checkWifiState();
|
||||||
|
if(currentWifiState != global::wifi::WifiState::Disabled and currentWifiState != global::wifi::WifiState::Unknown) {
|
||||||
|
ui->Wificheckbox->setChecked(true);
|
||||||
|
} else {
|
||||||
|
wifiButtonEnabled = true;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -161,13 +174,11 @@ void wifiDialog::on_refreshBtn_clicked()
|
||||||
log("To scan, turn on wi-fi first", className);
|
log("To scan, turn on wi-fi first", className);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
if(launchRefresh() == true) {
|
QTimer::singleShot(0, this, SLOT(launchRefresh()));
|
||||||
refreshNetworksList();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool wifiDialog::launchRefresh() {
|
void wifiDialog::launchRefresh() {
|
||||||
QFile fullList = QFile("/external_root/run/wifi_list_full");
|
QFile fullList = QFile("/external_root/run/wifi_list_full");
|
||||||
QFile formattedList = QFile("/external_root/run/wifi_list_format");
|
QFile formattedList = QFile("/external_root/run/wifi_list_format");
|
||||||
fullList.remove();
|
fullList.remove();
|
||||||
|
@ -186,10 +197,9 @@ bool wifiDialog::launchRefresh() {
|
||||||
if(fullList.exists() == false or formattedList.exists() == false) {
|
if(fullList.exists() == false or formattedList.exists() == false) {
|
||||||
emit showToast("Failed to get network list");
|
emit showToast("Failed to get network list");
|
||||||
log("Failed to get network list", className);
|
log("Failed to get network list", className);
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
log("Happily got network list", className);
|
log("Happily got network list", className);
|
||||||
return true;
|
refreshNetworksList();
|
||||||
}
|
}
|
||||||
|
|
||||||
void wifiDialog::refreshNetworksList() {
|
void wifiDialog::refreshNetworksList() {
|
||||||
|
@ -229,7 +239,10 @@ void wifiDialog::refreshNetworksList() {
|
||||||
}
|
}
|
||||||
count = count + 1;
|
count = count + 1;
|
||||||
}
|
}
|
||||||
pureNetworkList.append(singleNetwork);
|
// Really filter out empty networks
|
||||||
|
if(singleNetwork.name.isEmpty() == false) {
|
||||||
|
pureNetworkList.append(singleNetwork);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
log("found valid networks: " + QString::number(pureNetworkList.count()));
|
log("found valid networks: " + QString::number(pureNetworkList.count()));
|
||||||
QFile currentWifiNameFile = QFile("/external_root/run/current_wifi_name");
|
QFile currentWifiNameFile = QFile("/external_root/run/current_wifi_name");
|
||||||
|
@ -245,7 +258,7 @@ void wifiDialog::refreshNetworksList() {
|
||||||
int countVec = 0;
|
int countVec = 0;
|
||||||
int vectorNetworkLocation = 9999;
|
int vectorNetworkLocation = 9999;
|
||||||
for(global::wifi::wifiNetworkData wifiNetwork: pureNetworkList) {
|
for(global::wifi::wifiNetworkData wifiNetwork: pureNetworkList) {
|
||||||
if(wifiNetwork.name.contains(currentWifiNetwork) == true) {
|
if(currentWifiNetwork.isEmpty() == false and wifiNetwork.name.contains(currentWifiNetwork) == true) {
|
||||||
log("Found current network in vector", className);
|
log("Found current network in vector", className);
|
||||||
vectorNetworkLocation = countVec;
|
vectorNetworkLocation = countVec;
|
||||||
currentNetwork = wifiNetwork.name;
|
currentNetwork = wifiNetwork.name;
|
||||||
|
@ -254,11 +267,68 @@ void wifiDialog::refreshNetworksList() {
|
||||||
connectedNetwork->currentlyConnectedNetwork = currentNetwork;
|
connectedNetwork->currentlyConnectedNetwork = currentNetwork;
|
||||||
// this doesnt work so a layout is needed
|
// this doesnt work so a layout is needed
|
||||||
// ui->scrollArea->addScrollBarWidget(connectedNetwork, Qt::AlignTop);
|
// ui->scrollArea->addScrollBarWidget(connectedNetwork, Qt::AlignTop);
|
||||||
|
connectedNetwork->applyVariables();
|
||||||
ui->scrollBarLayout->addWidget(connectedNetwork, Qt::AlignTop);
|
ui->scrollBarLayout->addWidget(connectedNetwork, Qt::AlignTop);
|
||||||
}
|
}
|
||||||
countVec = countVec + 1;
|
countVec = countVec + 1;
|
||||||
}
|
}
|
||||||
|
if(vectorNetworkLocation != 9999) {
|
||||||
|
pureNetworkList.removeAt(vectorNetworkLocation);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// Sort based on signal strength
|
||||||
|
QVector<global::wifi::wifiNetworkData> sortedPureNetworkList;
|
||||||
|
sortedPureNetworkList.append(pureNetworkList.first());
|
||||||
|
pureNetworkList.removeFirst();
|
||||||
|
for(global::wifi::wifiNetworkData wifiNetwork: pureNetworkList) {
|
||||||
|
bool stopIterating = false;
|
||||||
|
int counter = 0;
|
||||||
|
for(global::wifi::wifiNetworkData wifiNetworkToSort: sortedPureNetworkList) {
|
||||||
|
if(stopIterating == false) {
|
||||||
|
if(wifiNetwork.signal > wifiNetworkToSort.signal) {
|
||||||
|
sortedPureNetworkList.insert(counter, wifiNetwork);
|
||||||
|
stopIterating = true;
|
||||||
|
}
|
||||||
|
counter = counter + 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// And now rest of the networks
|
||||||
|
for(global::wifi::wifiNetworkData wifiNetwork: sortedPureNetworkList) {
|
||||||
|
network* connectedNetwork = new network;
|
||||||
|
connectedNetwork->mainData = wifiNetwork;
|
||||||
|
connectedNetwork->currentlyConnectedNetwork = currentNetwork;
|
||||||
|
connectedNetwork->applyVariables();
|
||||||
|
connect(this, SIGNAL(killNetworkWidgets()), connectedNetwork, SLOT(close()));
|
||||||
|
ui->scrollBarLayout->addWidget(connectedNetwork, Qt::AlignTop);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void wifiDialog::on_Wificheckbox_stateChanged(int arg1)
|
||||||
|
{
|
||||||
|
log("wifi dialog clicked: " + QString::number(arg1), className);
|
||||||
|
if(wifiButtonEnabled == true) {
|
||||||
|
if(arg1 == 2) {
|
||||||
|
log("turning wifi on", className);
|
||||||
|
QTimer::singleShot(0, this, SLOT(turnOnWifi()));
|
||||||
|
} else {
|
||||||
|
log("turning wifi off", className);
|
||||||
|
QTimer::singleShot(0, this, SLOT(turnOffWifi()));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if(wifiButtonEnabled == false){
|
||||||
|
wifiButtonEnabled = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void wifiDialog::turnOnWifi() {
|
||||||
|
string_writeconfig("/opt/ibxd", "toggle_wifi_on\n");
|
||||||
|
}
|
||||||
|
|
||||||
|
void wifiDialog::turnOffWifi() {
|
||||||
|
string_writeconfig("/opt/ibxd", "toggle_wifi_off\n");
|
||||||
|
}
|
||||||
|
|
|
@ -21,9 +21,10 @@ public:
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Ui::wifiDialog *ui;
|
Ui::wifiDialog *ui;
|
||||||
|
bool wifiButtonEnabled = false;
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
bool launchRefresh();
|
void launchRefresh();
|
||||||
void refreshNetworksList();
|
void refreshNetworksList();
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
|
@ -35,6 +36,9 @@ signals:
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
void on_refreshBtn_clicked();
|
void on_refreshBtn_clicked();
|
||||||
|
void on_Wificheckbox_stateChanged(int arg1);
|
||||||
|
void turnOnWifi();
|
||||||
|
void turnOffWifi();
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // WIFIDIALOG_H
|
#endif // WIFIDIALOG_H
|
||||||
|
|
|
@ -31,6 +31,9 @@
|
||||||
</property>
|
</property>
|
||||||
<item>
|
<item>
|
||||||
<layout class="QHBoxLayout" name="horizontalLayout_4">
|
<layout class="QHBoxLayout" name="horizontalLayout_4">
|
||||||
|
<property name="spacing">
|
||||||
|
<number>10</number>
|
||||||
|
</property>
|
||||||
<item>
|
<item>
|
||||||
<widget class="QPushButton" name="logBtn">
|
<widget class="QPushButton" name="logBtn">
|
||||||
<property name="sizePolicy">
|
<property name="sizePolicy">
|
||||||
|
@ -139,6 +142,9 @@
|
||||||
<property name="lineWidth">
|
<property name="lineWidth">
|
||||||
<number>0</number>
|
<number>0</number>
|
||||||
</property>
|
</property>
|
||||||
|
<property name="verticalScrollBarPolicy">
|
||||||
|
<enum>Qt::ScrollBarAsNeeded</enum>
|
||||||
|
</property>
|
||||||
<property name="horizontalScrollBarPolicy">
|
<property name="horizontalScrollBarPolicy">
|
||||||
<enum>Qt::ScrollBarAlwaysOff</enum>
|
<enum>Qt::ScrollBarAlwaysOff</enum>
|
||||||
</property>
|
</property>
|
||||||
|
@ -151,17 +157,62 @@
|
||||||
<x>0</x>
|
<x>0</x>
|
||||||
<y>0</y>
|
<y>0</y>
|
||||||
<width>765</width>
|
<width>765</width>
|
||||||
<height>576</height>
|
<height>567</height>
|
||||||
</rect>
|
</rect>
|
||||||
</property>
|
</property>
|
||||||
<layout class="QVBoxLayout" name="verticalLayout_2">
|
<layout class="QVBoxLayout" name="verticalLayout_2">
|
||||||
|
<property name="spacing">
|
||||||
|
<number>0</number>
|
||||||
|
</property>
|
||||||
|
<property name="rightMargin">
|
||||||
|
<number>9</number>
|
||||||
|
</property>
|
||||||
|
<property name="bottomMargin">
|
||||||
|
<number>0</number>
|
||||||
|
</property>
|
||||||
<item>
|
<item>
|
||||||
<layout class="QVBoxLayout" name="scrollBarLayout"/>
|
<layout class="QVBoxLayout" name="scrollBarLayoutParent">
|
||||||
|
<property name="spacing">
|
||||||
|
<number>0</number>
|
||||||
|
</property>
|
||||||
|
<property name="rightMargin">
|
||||||
|
<number>0</number>
|
||||||
|
</property>
|
||||||
|
<item>
|
||||||
|
<layout class="QVBoxLayout" name="scrollBarLayout"/>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<spacer name="verticalSpacer_2">
|
||||||
|
<property name="orientation">
|
||||||
|
<enum>Qt::Vertical</enum>
|
||||||
|
</property>
|
||||||
|
<property name="sizeHint" stdset="0">
|
||||||
|
<size>
|
||||||
|
<width>20</width>
|
||||||
|
<height>40</height>
|
||||||
|
</size>
|
||||||
|
</property>
|
||||||
|
</spacer>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
</item>
|
</item>
|
||||||
</layout>
|
</layout>
|
||||||
</widget>
|
</widget>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="Line" name="line">
|
||||||
|
<property name="frameShadow">
|
||||||
|
<enum>QFrame::Plain</enum>
|
||||||
|
</property>
|
||||||
|
<property name="lineWidth">
|
||||||
|
<number>3</number>
|
||||||
|
</property>
|
||||||
|
<property name="orientation">
|
||||||
|
<enum>Qt::Horizontal</enum>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
<item>
|
<item>
|
||||||
<widget class="QPushButton" name="returnBtn">
|
<widget class="QPushButton" name="returnBtn">
|
||||||
<property name="sizePolicy">
|
<property name="sizePolicy">
|
||||||
|
|
Loading…
Reference in a new issue