mirror of
https://github.com/Quill-OS/quill.git
synced 2024-12-26 07:37:21 -08:00
Wi-Fi button/icon in MainWindow
Dialog's coming soon, hopefully ...
This commit is contained in:
parent
d8dee343a4
commit
a532d00f48
5 changed files with 188 additions and 78 deletions
3
eink.qrc
3
eink.qrc
|
@ -57,5 +57,8 @@
|
|||
<file>resources/fonts/IbarraRealNova-Medium.ttf</file>
|
||||
<file>resources/fonts/IbarraRealNova-BoldItalic.ttf</file>
|
||||
<file>resources/fonts/IbarraRealNova-Bold.ttf</file>
|
||||
<file>resources/wifi-connected.png</file>
|
||||
<file>resources/wifi-off.png</file>
|
||||
<file>resources/wifi-standby.png</file>
|
||||
</qresource>
|
||||
</RCC>
|
||||
|
|
|
@ -36,6 +36,7 @@ MainWindow::MainWindow(QWidget *parent)
|
|||
ui->pushButton->setProperty("type", "borderless");
|
||||
ui->brightnessBtn->setProperty("type", "borderless");
|
||||
ui->homeBtn->setProperty("type", "borderless");
|
||||
ui->wifiBtn->setProperty("type", "borderless");
|
||||
|
||||
ui->settingsBtn->setText("");
|
||||
ui->appsBtn->setText("");
|
||||
|
@ -45,6 +46,7 @@ MainWindow::MainWindow(QWidget *parent)
|
|||
ui->brightnessBtn->setText("");
|
||||
ui->homeBtn->setText("");
|
||||
ui->quoteLabel->setText("");
|
||||
ui->wifiBtn->setText("");
|
||||
|
||||
ui->quotePictureLabel->setText("");
|
||||
|
||||
|
@ -72,6 +74,8 @@ MainWindow::MainWindow(QWidget *parent)
|
|||
brightnessIconHeight = sH / 24;
|
||||
homeIconWidth = sW / 18;
|
||||
homeIconHeight = sW / 18;
|
||||
wifiIconWidth = sW / 20;
|
||||
wifiIconHeight = sH / 20;
|
||||
}
|
||||
else if(checkconfig_str_val == "n905\n") {
|
||||
stdIconWidth = sW / 14;
|
||||
|
@ -80,6 +84,8 @@ MainWindow::MainWindow(QWidget *parent)
|
|||
brightnessIconHeight = sH / 26;
|
||||
homeIconWidth = sW / 20;
|
||||
homeIconHeight = sW / 20;
|
||||
wifiIconWidth = sW / 22;
|
||||
wifiIconHeight = sH / 22;
|
||||
}
|
||||
else if(checkconfig_str_val == "n613\n") {
|
||||
stdIconWidth = sW / 12.5;
|
||||
|
@ -88,6 +94,8 @@ MainWindow::MainWindow(QWidget *parent)
|
|||
brightnessIconHeight = sH / 24.5;
|
||||
homeIconWidth = sW / 18.5;
|
||||
homeIconHeight = sW / 18.5;
|
||||
wifiIconWidth = sW / 20.5;
|
||||
wifiIconHeight = sH / 20.5;
|
||||
}
|
||||
else {
|
||||
stdIconWidth = sW / 14;
|
||||
|
@ -96,6 +104,8 @@ MainWindow::MainWindow(QWidget *parent)
|
|||
brightnessIconHeight = sH / 26;
|
||||
homeIconWidth = sW / 20;
|
||||
homeIconHeight = sW / 20;
|
||||
wifiIconWidth = sW / 22;
|
||||
wifiIconHeight = sH / 22;
|
||||
}
|
||||
|
||||
// Setting icons up
|
||||
|
@ -116,6 +126,8 @@ MainWindow::MainWindow(QWidget *parent)
|
|||
ui->brightnessBtn->setIcon(QIcon(":/resources/frontlight.png"));
|
||||
ui->brightnessBtn->setIconSize(QSize(brightnessIconWidth, brightnessIconHeight));
|
||||
|
||||
setWifiIcon();
|
||||
updateWifiIcon(0);
|
||||
setBatteryIcon();
|
||||
|
||||
int id = QFontDatabase::addApplicationFont(":/resources/fonts/CrimsonPro-Regular.ttf");
|
||||
|
@ -132,6 +144,7 @@ MainWindow::MainWindow(QWidget *parent)
|
|||
ui->book4Btn->setStyleSheet("font-size: 11pt; padding: 25px");
|
||||
|
||||
ui->brightnessBtn->setStyleSheet("font-size: 9pt; padding-bottom: 5px; padding-top: 5px; padding-left: 8px; padding-right: 8px;");
|
||||
ui->wifiBtn->setStyleSheet("font-size: 9pt; padding-bottom: 0px; padding-top: 0px; padding-left: 8px; padding-right: 8px");
|
||||
|
||||
// Checking if we have a Mini or Touch there
|
||||
string_checkconfig_ro("/opt/inkbox_device");
|
||||
|
@ -141,6 +154,9 @@ MainWindow::MainWindow(QWidget *parent)
|
|||
else if(checkconfig_str_val == "n613\n") {
|
||||
ui->batteryIcon->setStyleSheet("font-size: 5pt; padding-bottom: 0px; padding-top: 0px; padding-left: 0px; padding-right: 0px;");
|
||||
}
|
||||
else if(checkconfig_str_val == "n873\n") {
|
||||
ui->batteryIcon->setStyleSheet("font-size: 5pt; padding-bottom: 0px; padding-top: 0px; padding-left: 0px; padding-right: 0px;");
|
||||
}
|
||||
else {
|
||||
ui->batteryIcon->setStyleSheet("font-size: 5pt; padding-bottom: 0px; padding-top: 0px; padding-left: 8px; padding-right: 8px;");
|
||||
}
|
||||
|
@ -823,3 +839,71 @@ void MainWindow::setupSearchDialog() {
|
|||
;
|
||||
}
|
||||
}
|
||||
|
||||
int MainWindow::testPing() {
|
||||
QString pingProg = "ping";
|
||||
QStringList pingArgs;
|
||||
pingArgs << "-c" << "1" << "1.1.1.1";
|
||||
QProcess *pingProcess = new QProcess();
|
||||
pingProcess->start(pingProg, pingArgs);
|
||||
pingProcess->waitForFinished();
|
||||
return pingProcess->exitCode();
|
||||
}
|
||||
|
||||
void MainWindow::updateWifiIcon(int mode) {
|
||||
/* Usage:
|
||||
* mode 0: auto
|
||||
* mode 1: off
|
||||
* mode 2: standby
|
||||
* mode 3: connected
|
||||
*/
|
||||
if(mode == 0) {
|
||||
QTimer *wifiIconTimer = new QTimer(this);
|
||||
wifiIconTimer->setInterval(60000);
|
||||
connect(wifiIconTimer, SIGNAL(timeout()), this, SLOT(setWifiIcon()));
|
||||
wifiIconTimer->start();
|
||||
}
|
||||
if(mode == 1) {
|
||||
ui->wifiBtn->setIcon(QIcon(":/resources/wifi-off.png"));
|
||||
ui->wifiBtn->setIconSize(QSize(wifiIconWidth, wifiIconHeight));
|
||||
}
|
||||
if(mode == 2) {
|
||||
ui->wifiBtn->setIcon(QIcon(":/resources/wifi-standby.png"));
|
||||
ui->wifiBtn->setIconSize(QSize(wifiIconWidth, wifiIconHeight));
|
||||
}
|
||||
if(mode == 3) {
|
||||
ui->wifiBtn->setIcon(QIcon(":/resources/wifi-connected.png"));
|
||||
ui->wifiBtn->setIconSize(QSize(wifiIconWidth, wifiIconHeight));
|
||||
}
|
||||
}
|
||||
|
||||
bool MainWindow::checkWifiState() {
|
||||
/* Return value:
|
||||
* true: interface UP
|
||||
* false: interface DOWN
|
||||
*/
|
||||
string_checkconfig_ro("/sys/class/net/eth0/operstate");
|
||||
if(checkconfig_str_val == "up\n") {
|
||||
return true;
|
||||
}
|
||||
else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
void MainWindow::setWifiIcon() {
|
||||
if(checkWifiState() == true) {
|
||||
if(testPing() == 0) {
|
||||
ui->wifiBtn->setIcon(QIcon(":/resources/wifi-connected.png"));
|
||||
ui->wifiBtn->setIconSize(QSize(wifiIconWidth, wifiIconHeight));
|
||||
}
|
||||
else {
|
||||
ui->wifiBtn->setIcon(QIcon(":/resources/wifi-standby.png"));
|
||||
ui->wifiBtn->setIconSize(QSize(wifiIconWidth, wifiIconHeight));
|
||||
}
|
||||
}
|
||||
else {
|
||||
ui->wifiBtn->setIcon(QIcon(":/resources/wifi-off.png"));
|
||||
ui->wifiBtn->setIconSize(QSize(wifiIconWidth, wifiIconHeight));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -36,6 +36,8 @@ public:
|
|||
float brightnessIconHeight;
|
||||
float homeIconWidth;
|
||||
float homeIconHeight;
|
||||
float wifiIconWidth;
|
||||
float wifiIconHeight;
|
||||
float sW;
|
||||
float sH;
|
||||
|
||||
|
@ -51,6 +53,9 @@ public:
|
|||
void resetWindow(bool resetStackedWidget);
|
||||
void resetIcons();
|
||||
void setBatteryIcon();
|
||||
void updateWifiIcon(int mode);
|
||||
int testPing();
|
||||
bool checkWifiState();
|
||||
|
||||
public slots:
|
||||
|
||||
|
@ -70,6 +75,7 @@ private slots:
|
|||
void on_homeBtn_clicked();
|
||||
void refreshScreen();
|
||||
void setupSearchDialog();
|
||||
void setWifiIcon();
|
||||
|
||||
private:
|
||||
Ui::MainWindow *ui;
|
||||
|
|
173
mainwindow.ui
173
mainwindow.ui
|
@ -17,60 +17,20 @@
|
|||
<layout class="QVBoxLayout" name="verticalLayout">
|
||||
<item>
|
||||
<layout class="QGridLayout" name="gridLayout_2">
|
||||
<item row="0" column="5">
|
||||
<spacer name="horizontalSpacer_2">
|
||||
<item row="0" column="14">
|
||||
<widget class="Line" name="line_8">
|
||||
<property name="frameShadow">
|
||||
<enum>QFrame::Plain</enum>
|
||||
</property>
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>40</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item row="0" column="6">
|
||||
<widget class="QPushButton" name="brightnessBtn">
|
||||
<property name="text">
|
||||
<string>Brightness</string>
|
||||
<enum>Qt::Vertical</enum>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="9">
|
||||
<widget class="QLabel" name="batteryLabel">
|
||||
<property name="font">
|
||||
<font>
|
||||
<weight>75</weight>
|
||||
<bold>true</bold>
|
||||
</font>
|
||||
</property>
|
||||
<item row="0" column="0">
|
||||
<widget class="QPushButton" name="homeBtn">
|
||||
<property name="text">
|
||||
<string>batt</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="4">
|
||||
<widget class="QLabel" name="label_2">
|
||||
<property name="text">
|
||||
<string>―</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="11">
|
||||
<widget class="QLabel" name="timeLabel">
|
||||
<property name="font">
|
||||
<font>
|
||||
<pointsize>11</pointsize>
|
||||
<weight>75</weight>
|
||||
<bold>true</bold>
|
||||
</font>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>time</string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignCenter</set>
|
||||
<string>Home</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
|
@ -89,13 +49,6 @@
|
|||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="8">
|
||||
<widget class="QLabel" name="batteryIcon">
|
||||
<property name="text">
|
||||
<string>batteryIcon</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="2">
|
||||
<widget class="QLabel" name="label">
|
||||
<property name="text">
|
||||
|
@ -103,6 +56,57 @@
|
|||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="4">
|
||||
<widget class="QLabel" name="label_2">
|
||||
<property name="text">
|
||||
<string>―</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="10">
|
||||
<widget class="QPushButton" name="wifiBtn">
|
||||
<property name="text">
|
||||
<string>Wi-Fi</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="8">
|
||||
<widget class="QPushButton" name="brightnessBtn">
|
||||
<property name="text">
|
||||
<string>Brightness</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="11">
|
||||
<widget class="Line" name="line_7">
|
||||
<property name="frameShadow">
|
||||
<enum>QFrame::Plain</enum>
|
||||
</property>
|
||||
<property name="orientation">
|
||||
<enum>Qt::Vertical</enum>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="12">
|
||||
<widget class="QLabel" name="batteryIcon">
|
||||
<property name="text">
|
||||
<string>batteryIcon</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="5">
|
||||
<spacer name="horizontalSpacer_2">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>40</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item row="0" column="1">
|
||||
<spacer name="horizontalSpacer">
|
||||
<property name="orientation">
|
||||
|
@ -116,30 +120,43 @@
|
|||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item row="0" column="7">
|
||||
<widget class="Line" name="line_7">
|
||||
<property name="frameShadow">
|
||||
<enum>QFrame::Plain</enum>
|
||||
<item row="0" column="13">
|
||||
<widget class="QLabel" name="batteryLabel">
|
||||
<property name="font">
|
||||
<font>
|
||||
<weight>75</weight>
|
||||
<bold>true</bold>
|
||||
</font>
|
||||
</property>
|
||||
<property name="orientation">
|
||||
<enum>Qt::Vertical</enum>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="10">
|
||||
<widget class="Line" name="line_8">
|
||||
<property name="frameShadow">
|
||||
<enum>QFrame::Plain</enum>
|
||||
</property>
|
||||
<property name="orientation">
|
||||
<enum>Qt::Vertical</enum>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="0">
|
||||
<widget class="QPushButton" name="homeBtn">
|
||||
<property name="text">
|
||||
<string>Home</string>
|
||||
<string>batt</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="15">
|
||||
<widget class="QLabel" name="timeLabel">
|
||||
<property name="font">
|
||||
<font>
|
||||
<pointsize>11</pointsize>
|
||||
<weight>75</weight>
|
||||
<bold>true</bold>
|
||||
</font>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>time</string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignCenter</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="9">
|
||||
<widget class="Line" name="line_9">
|
||||
<property name="frameShadow">
|
||||
<enum>QFrame::Plain</enum>
|
||||
</property>
|
||||
<property name="orientation">
|
||||
<enum>Qt::Vertical</enum>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
|
|
Binary file not shown.
Before Width: | Height: | Size: 3.5 KiB After Width: | Height: | Size: 3.5 KiB |
Loading…
Reference in a new issue