|
|
|
@ -55,6 +55,7 @@ WifiUI::WifiUI(QWidget *parent) : QWidget(parent) { |
|
|
|
|
|
|
|
|
|
// Scan on startup
|
|
|
|
|
wifi->request_scan(); |
|
|
|
|
page = 0; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
void WifiUI::refresh() { |
|
|
|
@ -74,6 +75,7 @@ void WifiUI::refresh() { |
|
|
|
|
for (Network &network : wifi->seen_networks){ |
|
|
|
|
QHBoxLayout *hlayout = new QHBoxLayout; |
|
|
|
|
|
|
|
|
|
if(page * networks_per_page <= i && i < (page + 1) * networks_per_page){ |
|
|
|
|
// SSID
|
|
|
|
|
hlayout->addSpacing(50); |
|
|
|
|
hlayout->addWidget(new QLabel(QString::fromUtf8(network.ssid))); |
|
|
|
@ -94,7 +96,7 @@ void WifiUI::refresh() { |
|
|
|
|
hlayout->addWidget(btn); |
|
|
|
|
hlayout->addSpacing(20); |
|
|
|
|
|
|
|
|
|
connectButtons->addButton(btn, i++); |
|
|
|
|
connectButtons->addButton(btn, i); |
|
|
|
|
|
|
|
|
|
QWidget * w = new QWidget; |
|
|
|
|
w->setLayout(hlayout); |
|
|
|
@ -113,10 +115,41 @@ void WifiUI::refresh() { |
|
|
|
|
background-color: #114265; |
|
|
|
|
} |
|
|
|
|
)"); |
|
|
|
|
if(i > 10){ |
|
|
|
|
return; |
|
|
|
|
} |
|
|
|
|
i+=1; |
|
|
|
|
} |
|
|
|
|
QHBoxLayout *prev_next_buttons = new QHBoxLayout; |
|
|
|
|
QPushButton* prev = new QPushButton("Previous"); |
|
|
|
|
prev->setEnabled(page); |
|
|
|
|
prev->setFixedHeight(100); |
|
|
|
|
|
|
|
|
|
QPushButton* next = new QPushButton("Next"); |
|
|
|
|
next->setFixedHeight(100); |
|
|
|
|
//If there are more visible networks then we can show, enable going to next page
|
|
|
|
|
if(wifi->seen_networks.size() > (page + 1) * networks_per_page){ |
|
|
|
|
next->setEnabled(true); |
|
|
|
|
}else{ |
|
|
|
|
next->setDisabled(true); |
|
|
|
|
} |
|
|
|
|
QObject::connect(prev, SIGNAL(released()), this, SLOT(prevPage())); |
|
|
|
|
QObject::connect(next, SIGNAL(released()), this, SLOT(nextPage())); |
|
|
|
|
prev_next_buttons->addWidget(prev); |
|
|
|
|
prev_next_buttons->addWidget(next); |
|
|
|
|
|
|
|
|
|
QWidget * w = new QWidget; |
|
|
|
|
w->setLayout(prev_next_buttons); |
|
|
|
|
w->setStyleSheet(R"( |
|
|
|
|
QPushButton:enabled { |
|
|
|
|
background-color: #114265; |
|
|
|
|
} |
|
|
|
|
QPushButton:disabled { |
|
|
|
|
background-color: #323C43; |
|
|
|
|
} |
|
|
|
|
* { |
|
|
|
|
background-color: #114265; |
|
|
|
|
} |
|
|
|
|
)"); |
|
|
|
|
vlayout->addWidget(w); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
void WifiUI::handleButton(QAbstractButton* button) { |
|
|
|
@ -130,7 +163,6 @@ void WifiUI::handleButton(QAbstractButton* button) { |
|
|
|
|
wifi->connect(n); |
|
|
|
|
} else if (n.security_type == SecurityType::WPA){ |
|
|
|
|
QString password = getStringFromUser(); |
|
|
|
|
|
|
|
|
|
if(password.size()){ |
|
|
|
|
wifi->connect(n, password); |
|
|
|
|
} |
|
|
|
@ -150,3 +182,11 @@ void WifiUI::receiveText(QString t) { |
|
|
|
|
loop.quit(); |
|
|
|
|
text = t; |
|
|
|
|
} |
|
|
|
|
void WifiUI::prevPage() { |
|
|
|
|
page--; |
|
|
|
|
refresh(); |
|
|
|
|
} |
|
|
|
|
void WifiUI::nextPage() { |
|
|
|
|
page++; |
|
|
|
|
refresh(); |
|
|
|
|
} |
|
|
|
|