mirror of
https://github.com/Quill-OS/quill.git
synced 2024-10-31 21:33:22 -07:00
Wi-Fi fixes
This commit is contained in:
parent
95fb6af4c2
commit
4bb87485e0
5 changed files with 79 additions and 32 deletions
|
@ -34,10 +34,21 @@ connectiondialog::connectiondialog(QWidget *parent) :
|
|||
|
||||
// Size
|
||||
QRect screenGeometry = QGuiApplication::screens()[0]->geometry();
|
||||
this->setFixedWidth(screenGeometry.width() / 1.5);
|
||||
if(global::deviceID == "n705\n") {
|
||||
this->setFixedWidth(screenGeometry.width() / 1.2);
|
||||
}
|
||||
else {
|
||||
this->setFixedWidth(screenGeometry.width() / 1.5);
|
||||
}
|
||||
|
||||
int halfOfHalfHeight = ((screenGeometry.height() / 2) / 2) / 2;
|
||||
int finalHeight = screenGeometry.height() - halfOfHalfHeight * 6.3;
|
||||
int finalHeight;
|
||||
if(global::deviceID == "n705\n") {
|
||||
finalHeight = screenGeometry.height() - halfOfHalfHeight * 5.9;
|
||||
}
|
||||
else {
|
||||
finalHeight = screenGeometry.height() - halfOfHalfHeight * 6.3;
|
||||
}
|
||||
|
||||
this->setFixedHeight(finalHeight);
|
||||
|
||||
|
@ -53,8 +64,21 @@ connectiondialog::~connectiondialog()
|
|||
}
|
||||
|
||||
void connectiondialog::applyVariables() {
|
||||
// Here, for some devices it will be propably needed to limit the size
|
||||
ui->nameLabel->setText(connectedNetworkData.name);
|
||||
// Limit name size
|
||||
int truncateThreshold;
|
||||
if(global::deviceID == "n705\n") {
|
||||
truncateThreshold = 20;
|
||||
}
|
||||
else {
|
||||
truncateThreshold = 30;
|
||||
}
|
||||
int nameLength = connectedNetworkData.name.length();
|
||||
QString name = connectedNetworkData.name;
|
||||
if(nameLength > truncateThreshold) {
|
||||
name.chop(nameLength - truncateThreshold);
|
||||
name.append("...");
|
||||
}
|
||||
ui->nameLabel->setText(name);
|
||||
ui->macLabel->setText(connectedNetworkData.mac);
|
||||
ui->signalLabel->setText(QString::number(connectedNetworkData.signal) + "%");
|
||||
|
||||
|
@ -272,11 +296,22 @@ void connectiondialog::on_showPassphraseBtn_clicked()
|
|||
ui->showPassphraseBtn->setIcon(QIcon(":/resources/show.png"));
|
||||
|
||||
int passphraseLength = searchDatabase(connectedNetworkData.name).length();
|
||||
QString hiddenPassphrase;
|
||||
for(int i = 0; i < passphraseLength; i++) {
|
||||
hiddenPassphrase.append("•");
|
||||
if(passphraseLength != 0) {
|
||||
QString hiddenPassphrase;
|
||||
for(int i = 0; i < passphraseLength; i++) {
|
||||
hiddenPassphrase.append("•");
|
||||
}
|
||||
ui->passphraseTextEdit->setText(hiddenPassphrase);
|
||||
}
|
||||
else {
|
||||
// This is executed if the user asks to hide the passphrase but it isn't saved yet (upon first connection to a network)
|
||||
QString hiddenPassphrase;
|
||||
int passphraseLength = ui->passphraseTextEdit->text().length();
|
||||
for(int i = 0; i < passphraseLength; i++) {
|
||||
hiddenPassphrase.append("•");
|
||||
}
|
||||
ui->passphraseTextEdit->setText(hiddenPassphrase);
|
||||
}
|
||||
ui->passphraseTextEdit->setText(hiddenPassphrase);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -40,10 +40,17 @@ void network::applyVariables() {
|
|||
ui->signalStrengthLabel->setText(QString::number(mainData.signal) + percent);
|
||||
|
||||
// Limit name size
|
||||
int truncateThreshold;
|
||||
if(global::deviceID == "n705\n") {
|
||||
truncateThreshold = 12;
|
||||
}
|
||||
else {
|
||||
truncateThreshold = 20;
|
||||
}
|
||||
int nameLength = mainData.name.length();
|
||||
QString name = mainData.name;
|
||||
if(nameLength > 20) {
|
||||
name.chop(nameLength - 20);
|
||||
if(nameLength > truncateThreshold) {
|
||||
name.chop(nameLength - truncateThreshold);
|
||||
name.append("...");
|
||||
}
|
||||
ui->nameLabel->setText(name);
|
||||
|
|
|
@ -54,14 +54,16 @@ wifiDialog::wifiDialog(QWidget *parent) :
|
|||
this->move(x, y);
|
||||
|
||||
// Button sizes
|
||||
ui->stopBtn->setFixedWidth(screenGeometry.width() / 9);
|
||||
ui->logBtn->setFixedWidth(screenGeometry.width() / 9);
|
||||
ui->refreshBtn->setFixedWidth(screenGeometry.width() / 9);
|
||||
|
||||
int heightIncrease = 20;
|
||||
ui->stopBtn->setFixedHeight(ui->stopBtn->height() + heightIncrease);
|
||||
ui->logBtn->setFixedHeight(ui->logBtn->height() + heightIncrease);
|
||||
ui->refreshBtn->setFixedHeight(ui->refreshBtn->height() + heightIncrease);
|
||||
if(global::deviceID == "n705\n") {
|
||||
ui->refreshBtn->setStyleSheet("padding: 20px;");
|
||||
ui->stopBtn->setStyleSheet("padding: 20px;");
|
||||
ui->logBtn->setStyleSheet("padding: 20px;");
|
||||
}
|
||||
else {
|
||||
ui->refreshBtn->setStyleSheet("padding: 25px;");
|
||||
ui->stopBtn->setStyleSheet("padding: 25px;");
|
||||
ui->logBtn->setStyleSheet("padding: 25px;");
|
||||
}
|
||||
|
||||
// Set Wi-Fi checkbox state. Ignore the first call.
|
||||
global::wifi::wifiState currentWifiState = checkWifiState();
|
||||
|
@ -72,12 +74,12 @@ wifiDialog::wifiDialog(QWidget *parent) :
|
|||
ui->refreshBtn->click();
|
||||
} else {
|
||||
wifiButtonEnabled = true;
|
||||
ui->stopBtn->setStyleSheet("background-color: lightGray;");
|
||||
ui->stopBtn->setStyleSheet(ui->stopBtn->styleSheet() + "background-color: lightGray;");
|
||||
ui->stopBtn->setEnabled(false);
|
||||
}
|
||||
|
||||
// To avoid confusion with reconnecting
|
||||
QTimer::singleShot(2000, this, SLOT(watcher()));
|
||||
QTimer::singleShot(0, this, SLOT(watcher()));
|
||||
}
|
||||
|
||||
wifiDialog::~wifiDialog()
|
||||
|
@ -104,7 +106,7 @@ void wifiDialog::launchRefresh() {
|
|||
// Order is important
|
||||
if(scanInProgress == false) {
|
||||
scanInProgress = true;
|
||||
ui->refreshBtn->setStyleSheet("background-color: lightGray;");
|
||||
ui->refreshBtn->setStyleSheet(ui->refreshBtn->styleSheet() + "background-color: lightGray;");
|
||||
ui->refreshBtn->setEnabled(false);
|
||||
|
||||
elapsedSeconds = 0;
|
||||
|
@ -122,7 +124,7 @@ void wifiDialog::refreshWait() {
|
|||
if(fullList.exists() == false and formattedList.exists() == false) {
|
||||
if(elapsedSeconds == 6) {
|
||||
emit showToast("Failed to get networks list");
|
||||
ui->refreshBtn->setStyleSheet("background-color:white;");
|
||||
ui->refreshBtn->setStyleSheet(ui->refreshBtn->styleSheet() + "background-color: white;");
|
||||
ui->refreshBtn->setEnabled(true);
|
||||
scanInProgress = false;
|
||||
}
|
||||
|
@ -199,7 +201,7 @@ void wifiDialog::refreshNetworksList() {
|
|||
log("No networks found, skipping", className);
|
||||
showToastSlot("No networks found");
|
||||
ui->refreshBtn->setEnabled(true);
|
||||
ui->refreshBtn->setStyleSheet("background-color: white;");
|
||||
ui->refreshBtn->setStyleSheet(ui->refreshBtn->styleSheet() + "background-color: white;");
|
||||
scanInProgress = false;
|
||||
return void();
|
||||
}
|
||||
|
@ -286,7 +288,7 @@ void wifiDialog::refreshNetworksList() {
|
|||
}
|
||||
scannedAtLeastOnce = true;
|
||||
ui->refreshBtn->setEnabled(true);
|
||||
ui->refreshBtn->setStyleSheet("background-color: white;");
|
||||
ui->refreshBtn->setStyleSheet(ui->refreshBtn->styleSheet() + "background-color: white;");
|
||||
scanInProgress = false;
|
||||
secondScanTry = false;
|
||||
}
|
||||
|
@ -302,14 +304,14 @@ void wifiDialog::on_wifiCheckBox_stateChanged(int arg1)
|
|||
log("Turning Wi-Fi on", className);
|
||||
// The watcher will scan Wi-Fi
|
||||
QTimer::singleShot(0, this, SLOT(turnOnWifi()));
|
||||
ui->stopBtn->setStyleSheet("background-color: white;");
|
||||
ui->stopBtn->setStyleSheet(ui->stopBtn->styleSheet() + "background-color: white;");
|
||||
ui->stopBtn->setEnabled(true);
|
||||
} else {
|
||||
log("Turning Wi-Fi off", className);
|
||||
QTimer::singleShot(0, this, SLOT(turnOffWifi()));
|
||||
// To inform the Wi-Fi icon updater to not show the connected/failed to connect message
|
||||
string_writeconfig("/mnt/onboard/.adds/inkbox/.config/17-wifi_connection_information/stopped", "true");
|
||||
ui->stopBtn->setStyleSheet("background-color: lightGray;");
|
||||
ui->stopBtn->setStyleSheet(ui->stopBtn->styleSheet() + "background-color: lightGray;");
|
||||
ui->stopBtn->setEnabled(false);
|
||||
}
|
||||
emit killNetworkWidgets();
|
||||
|
|
|
@ -170,7 +170,7 @@
|
|||
<string notr="true">padding-left: 10px; font-family: u001</string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Wi-Fi status</string>
|
||||
<string/>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
|
@ -209,8 +209,8 @@
|
|||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>585</width>
|
||||
<height>538</height>
|
||||
<width>591</width>
|
||||
<height>526</height>
|
||||
</rect>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout_2">
|
||||
|
|
|
@ -7,7 +7,7 @@
|
|||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>476</width>
|
||||
<height>273</height>
|
||||
<height>317</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="sizePolicy">
|
||||
|
@ -30,8 +30,8 @@
|
|||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>442</width>
|
||||
<height>208</height>
|
||||
<width>460</width>
|
||||
<height>210</height>
|
||||
</rect>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout">
|
||||
|
@ -366,6 +366,9 @@
|
|||
<property name="alignment">
|
||||
<set>Qt::AlignCenter</set>
|
||||
</property>
|
||||
<property name="wordWrap">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
|
|
Loading…
Reference in a new issue