mirror of
https://github.com/Quill-OS/quill.git
synced 2024-10-31 21:33:22 -07: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/stop.png</file>
|
||||
<file>resources/refresh.png</file>
|
||||
<file>resources/lock-fill.png</file>
|
||||
<file>resources/lock-unlock-fill.png</file>
|
||||
</qresource>
|
||||
</RCC>
|
||||
|
|
|
@ -1072,6 +1072,7 @@ namespace {
|
|||
global::wifi::WifiState checkWifiState() {
|
||||
QProcess *wifiStateProcess = new QProcess();
|
||||
// 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";
|
||||
QStringList 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->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()
|
||||
{
|
||||
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;
|
||||
QString currentlyConnectedNetwork;
|
||||
|
||||
public slots:
|
||||
void applyVariables();
|
||||
|
||||
private:
|
||||
Ui::network *ui;
|
||||
};
|
||||
|
|
|
@ -20,6 +20,18 @@
|
|||
<string>Form</string>
|
||||
</property>
|
||||
<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>
|
||||
<widget class="QFrame" name="frame">
|
||||
<property name="sizePolicy">
|
||||
|
@ -32,9 +44,24 @@
|
|||
<enum>QFrame::StyledPanel</enum>
|
||||
</property>
|
||||
<property name="frameShadow">
|
||||
<enum>QFrame::Raised</enum>
|
||||
<enum>QFrame::Plain</enum>
|
||||
</property>
|
||||
<property name="lineWidth">
|
||||
<number>3</number>
|
||||
</property>
|
||||
<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>
|
||||
<widget class="QLabel" name="signalStrengthLabel">
|
||||
<property name="text">
|
||||
|
@ -42,6 +69,19 @@
|
|||
</property>
|
||||
</widget>
|
||||
</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>
|
||||
<widget class="QLabel" name="nameLabel">
|
||||
<property name="text">
|
||||
|
|
|
@ -3,6 +3,7 @@
|
|||
#include <QScreen>
|
||||
#include <QDesktopWidget>
|
||||
#include <QMessageBox>
|
||||
#include <QScrollBar>
|
||||
|
||||
#include "wifidialog.h"
|
||||
#include "ui_wifidialog.h"
|
||||
|
@ -29,6 +30,12 @@ wifiDialog::wifiDialog(QWidget *parent) :
|
|||
|
||||
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
|
||||
QRect screenGeometry = QGuiApplication::screens()[0]->geometry();
|
||||
this->setFixedWidth(screenGeometry.width());
|
||||
|
@ -49,7 +56,13 @@ wifiDialog::wifiDialog(QWidget *parent) :
|
|||
ui->logBtn->setFixedHeight(ui->logBtn->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);
|
||||
}
|
||||
else {
|
||||
if(launchRefresh() == true) {
|
||||
refreshNetworksList();
|
||||
}
|
||||
QTimer::singleShot(0, this, SLOT(launchRefresh()));
|
||||
}
|
||||
}
|
||||
|
||||
bool wifiDialog::launchRefresh() {
|
||||
void wifiDialog::launchRefresh() {
|
||||
QFile fullList = QFile("/external_root/run/wifi_list_full");
|
||||
QFile formattedList = QFile("/external_root/run/wifi_list_format");
|
||||
fullList.remove();
|
||||
|
@ -186,10 +197,9 @@ bool wifiDialog::launchRefresh() {
|
|||
if(fullList.exists() == false or formattedList.exists() == false) {
|
||||
emit showToast("Failed to get network list");
|
||||
log("Failed to get network list", className);
|
||||
return false;
|
||||
}
|
||||
log("Happily got network list", className);
|
||||
return true;
|
||||
refreshNetworksList();
|
||||
}
|
||||
|
||||
void wifiDialog::refreshNetworksList() {
|
||||
|
@ -229,8 +239,11 @@ void wifiDialog::refreshNetworksList() {
|
|||
}
|
||||
count = count + 1;
|
||||
}
|
||||
// Really filter out empty networks
|
||||
if(singleNetwork.name.isEmpty() == false) {
|
||||
pureNetworkList.append(singleNetwork);
|
||||
}
|
||||
}
|
||||
log("found valid networks: " + QString::number(pureNetworkList.count()));
|
||||
QFile currentWifiNameFile = QFile("/external_root/run/current_wifi_name");
|
||||
currentWifiNameFile.remove();
|
||||
|
@ -245,7 +258,7 @@ void wifiDialog::refreshNetworksList() {
|
|||
int countVec = 0;
|
||||
int vectorNetworkLocation = 9999;
|
||||
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);
|
||||
vectorNetworkLocation = countVec;
|
||||
currentNetwork = wifiNetwork.name;
|
||||
|
@ -254,11 +267,68 @@ void wifiDialog::refreshNetworksList() {
|
|||
connectedNetwork->currentlyConnectedNetwork = currentNetwork;
|
||||
// this doesnt work so a layout is needed
|
||||
// ui->scrollArea->addScrollBarWidget(connectedNetwork, Qt::AlignTop);
|
||||
connectedNetwork->applyVariables();
|
||||
ui->scrollBarLayout->addWidget(connectedNetwork, Qt::AlignTop);
|
||||
}
|
||||
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:
|
||||
Ui::wifiDialog *ui;
|
||||
bool wifiButtonEnabled = false;
|
||||
|
||||
public slots:
|
||||
bool launchRefresh();
|
||||
void launchRefresh();
|
||||
void refreshNetworksList();
|
||||
|
||||
signals:
|
||||
|
@ -35,6 +36,9 @@ signals:
|
|||
|
||||
private slots:
|
||||
void on_refreshBtn_clicked();
|
||||
void on_Wificheckbox_stateChanged(int arg1);
|
||||
void turnOnWifi();
|
||||
void turnOffWifi();
|
||||
};
|
||||
|
||||
#endif // WIFIDIALOG_H
|
||||
|
|
|
@ -31,6 +31,9 @@
|
|||
</property>
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_4">
|
||||
<property name="spacing">
|
||||
<number>10</number>
|
||||
</property>
|
||||
<item>
|
||||
<widget class="QPushButton" name="logBtn">
|
||||
<property name="sizePolicy">
|
||||
|
@ -139,6 +142,9 @@
|
|||
<property name="lineWidth">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="verticalScrollBarPolicy">
|
||||
<enum>Qt::ScrollBarAsNeeded</enum>
|
||||
</property>
|
||||
<property name="horizontalScrollBarPolicy">
|
||||
<enum>Qt::ScrollBarAlwaysOff</enum>
|
||||
</property>
|
||||
|
@ -151,17 +157,62 @@
|
|||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>765</width>
|
||||
<height>576</height>
|
||||
<height>567</height>
|
||||
</rect>
|
||||
</property>
|
||||
<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>
|
||||
<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>
|
||||
</layout>
|
||||
</widget>
|
||||
</widget>
|
||||
</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>
|
||||
<widget class="QPushButton" name="returnBtn">
|
||||
<property name="sizePolicy">
|
||||
|
|
Loading…
Reference in a new issue