mirror of
https://github.com/Quill-OS/quill.git
synced 2024-10-31 21:33:22 -07:00
First steps to control brightness from MainWindow and show battery
level/status
This commit is contained in:
parent
ccf67053df
commit
d3362890be
5 changed files with 179 additions and 129 deletions
1
eink.qrc
1
eink.qrc
|
@ -30,5 +30,6 @@
|
||||||
<file>resources/battery_charging.png</file>
|
<file>resources/battery_charging.png</file>
|
||||||
<file>resources/alert.png</file>
|
<file>resources/alert.png</file>
|
||||||
<file>resources/eink_dark.qss</file>
|
<file>resources/eink_dark.qss</file>
|
||||||
|
<file>resources/frontlight.png</file>
|
||||||
</qresource>
|
</qresource>
|
||||||
</RCC>
|
</RCC>
|
||||||
|
|
|
@ -30,12 +30,14 @@ MainWindow::MainWindow(QWidget *parent)
|
||||||
ui->quitBtn->setProperty("type", "borderless");
|
ui->quitBtn->setProperty("type", "borderless");
|
||||||
ui->searchBtn->setProperty("type", "borderless");
|
ui->searchBtn->setProperty("type", "borderless");
|
||||||
ui->pushButton->setProperty("type", "borderless");
|
ui->pushButton->setProperty("type", "borderless");
|
||||||
|
ui->brightnessBtn->setProperty("type", "borderless");
|
||||||
|
|
||||||
ui->settingsBtn->setText("");
|
ui->settingsBtn->setText("");
|
||||||
ui->appsBtn->setText("");
|
ui->appsBtn->setText("");
|
||||||
ui->pushButton->setText("");
|
ui->pushButton->setText("");
|
||||||
ui->quitBtn->setText("");
|
ui->quitBtn->setText("");
|
||||||
ui->searchBtn->setText("");
|
ui->searchBtn->setText("");
|
||||||
|
ui->brightnessBtn->setText("");
|
||||||
|
|
||||||
// Getting the screen's size
|
// Getting the screen's size
|
||||||
float sW = QGuiApplication::screens()[0]->size().width();
|
float sW = QGuiApplication::screens()[0]->size().width();
|
||||||
|
@ -44,15 +46,21 @@ MainWindow::MainWindow(QWidget *parent)
|
||||||
|
|
||||||
float stdIconWidth;
|
float stdIconWidth;
|
||||||
float stdIconHeight;
|
float stdIconHeight;
|
||||||
|
float brightnessIconWidth;
|
||||||
|
float brightnessIconHeight;
|
||||||
|
|
||||||
string_checkconfig("/opt/inkbox_device");
|
string_checkconfig("/opt/inkbox_device");
|
||||||
if(checkconfig_str_val == "n705\n") {
|
if(checkconfig_str_val == "n705\n") {
|
||||||
stdIconWidth = sW / 12;
|
stdIconWidth = sW / 12;
|
||||||
stdIconHeight = sH / 12;
|
stdIconHeight = sH / 12;
|
||||||
|
brightnessIconWidth = sW / 30;
|
||||||
|
brightnessIconHeight = sH / 30;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
stdIconWidth = sW / 14;
|
stdIconWidth = sW / 14;
|
||||||
stdIconHeight = sH / 14;
|
stdIconHeight = sH / 14;
|
||||||
|
brightnessIconWidth = sW / 28;
|
||||||
|
brightnessIconHeight = sH / 28;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Setting icons up
|
// Setting icons up
|
||||||
|
@ -67,11 +75,18 @@ MainWindow::MainWindow(QWidget *parent)
|
||||||
ui->quitBtn->setIcon(QIcon(":/resources/power.png"));
|
ui->quitBtn->setIcon(QIcon(":/resources/power.png"));
|
||||||
ui->quitBtn->setIconSize(QSize(stdIconWidth, stdIconHeight));
|
ui->quitBtn->setIconSize(QSize(stdIconWidth, stdIconHeight));
|
||||||
|
|
||||||
|
ui->brightnessBtn->setIcon(QIcon(":/resources/frontlight.png"));
|
||||||
|
ui->brightnessBtn->setIconSize(QSize(brightnessIconWidth, brightnessIconHeight));
|
||||||
|
|
||||||
ui->book1Btn->setStyleSheet("font-size: 11pt; padding: 25px");
|
ui->book1Btn->setStyleSheet("font-size: 11pt; padding: 25px");
|
||||||
ui->book2Btn->setStyleSheet("font-size: 11pt; padding: 25px");
|
ui->book2Btn->setStyleSheet("font-size: 11pt; padding: 25px");
|
||||||
ui->book3Btn->setStyleSheet("font-size: 11pt; padding: 25px");
|
ui->book3Btn->setStyleSheet("font-size: 11pt; padding: 25px");
|
||||||
ui->book4Btn->setStyleSheet("font-size: 11pt; padding: 25px");
|
ui->book4Btn->setStyleSheet("font-size: 11pt; padding: 25px");
|
||||||
|
|
||||||
|
ui->brightnessBtn->setStyleSheet("font-size: 9pt; padding-bottom: 5px; padding-top: 5px; padding-left: 10px; padding-right: 10px;");
|
||||||
|
ui->batteryIcon->setStyleSheet("font-size: 5pt");
|
||||||
|
ui->batteryIcon->setText("");
|
||||||
|
|
||||||
ui->book1Btn->hide();
|
ui->book1Btn->hide();
|
||||||
ui->book2Btn->hide();
|
ui->book2Btn->hide();
|
||||||
ui->book3Btn->hide();
|
ui->book3Btn->hide();
|
||||||
|
@ -167,10 +182,10 @@ MainWindow::MainWindow(QWidget *parent)
|
||||||
QTimer *t = new QTimer(this);
|
QTimer *t = new QTimer(this);
|
||||||
t->setInterval(500);
|
t->setInterval(500);
|
||||||
connect(t, &QTimer::timeout, [&]() {
|
connect(t, &QTimer::timeout, [&]() {
|
||||||
QString date = QDateTime::currentDateTime().toString("yyyy-MM-dd");
|
|
||||||
QString time = QTime::currentTime().toString("hh:mm:ss");
|
QString time = QTime::currentTime().toString("hh:mm:ss");
|
||||||
|
get_battery_level();
|
||||||
ui->timeLabel->setText(time);
|
ui->timeLabel->setText(time);
|
||||||
ui->dateLabel->setText(date);
|
ui->batteryLabel->setText(batt_level);
|
||||||
} );
|
} );
|
||||||
t->start();
|
t->start();
|
||||||
}
|
}
|
||||||
|
@ -178,10 +193,10 @@ MainWindow::MainWindow(QWidget *parent)
|
||||||
QTimer *t = new QTimer(this);
|
QTimer *t = new QTimer(this);
|
||||||
t->setInterval(500);
|
t->setInterval(500);
|
||||||
connect(t, &QTimer::timeout, [&]() {
|
connect(t, &QTimer::timeout, [&]() {
|
||||||
QString date = QDateTime::currentDateTime().toString("yyyy-MM-dd");
|
|
||||||
QString time = QTime::currentTime().toString("hh:mm");
|
QString time = QTime::currentTime().toString("hh:mm");
|
||||||
|
get_battery_level();
|
||||||
ui->timeLabel->setText(time);
|
ui->timeLabel->setText(time);
|
||||||
ui->dateLabel->setText(date);
|
ui->batteryLabel->setText(batt_level);
|
||||||
} );
|
} );
|
||||||
t->start();
|
t->start();
|
||||||
}
|
}
|
||||||
|
|
11
mainwindow.h
11
mainwindow.h
|
@ -26,8 +26,10 @@ public:
|
||||||
bool checked_box = false;
|
bool checked_box = false;
|
||||||
bool existing_recent_books = false;
|
bool existing_recent_books = false;
|
||||||
bool reboot_after_update = false;
|
bool reboot_after_update = false;
|
||||||
|
int batt_level_int;
|
||||||
QString checkconfig_str_val;
|
QString checkconfig_str_val;
|
||||||
QString relative_path;
|
QString relative_path;
|
||||||
|
QString batt_level;
|
||||||
bool checkconfig(QString file) {
|
bool checkconfig(QString file) {
|
||||||
QFile config(file);
|
QFile config(file);
|
||||||
config.open(QIODevice::ReadOnly);
|
config.open(QIODevice::ReadOnly);
|
||||||
|
@ -48,6 +50,15 @@ public:
|
||||||
fhandler << config << boolalpha << checked_box << endl;
|
fhandler << config << boolalpha << checked_box << endl;
|
||||||
fhandler.close();
|
fhandler.close();
|
||||||
}
|
}
|
||||||
|
void get_battery_level() {
|
||||||
|
QFile batt_level_file("/sys/devices/platform/pmic_battery.1/power_supply/mc13892_bat/capacity");
|
||||||
|
batt_level_file.open(QIODevice::ReadOnly);
|
||||||
|
batt_level = batt_level_file.readAll();
|
||||||
|
batt_level = batt_level.trimmed();
|
||||||
|
batt_level_int = batt_level.toInt();
|
||||||
|
batt_level = batt_level.append("%");
|
||||||
|
batt_level_file.close();
|
||||||
|
}
|
||||||
int brightness_checkconfig(QString file) {
|
int brightness_checkconfig(QString file) {
|
||||||
QFile config(file);
|
QFile config(file);
|
||||||
config.open(QIODevice::ReadWrite);
|
config.open(QIODevice::ReadWrite);
|
||||||
|
|
273
mainwindow.ui
273
mainwindow.ui
|
@ -17,34 +17,50 @@
|
||||||
<layout class="QVBoxLayout" name="verticalLayout">
|
<layout class="QVBoxLayout" name="verticalLayout">
|
||||||
<item>
|
<item>
|
||||||
<layout class="QGridLayout" name="gridLayout_2">
|
<layout class="QGridLayout" name="gridLayout_2">
|
||||||
<item row="0" column="1">
|
<item row="0" column="6">
|
||||||
<spacer name="horizontalSpacer">
|
<widget class="QPushButton" name="brightnessBtn">
|
||||||
<property name="orientation">
|
<property name="text">
|
||||||
<enum>Qt::Horizontal</enum>
|
<string>Brightness</string>
|
||||||
</property>
|
</property>
|
||||||
<property name="sizeHint" stdset="0">
|
</widget>
|
||||||
<size>
|
|
||||||
<width>40</width>
|
|
||||||
<height>20</height>
|
|
||||||
</size>
|
|
||||||
</property>
|
|
||||||
</spacer>
|
|
||||||
</item>
|
</item>
|
||||||
<item row="0" column="5">
|
<item row="0" column="3">
|
||||||
<spacer name="horizontalSpacer_2">
|
<widget class="QLabel" name="inkboxLabel">
|
||||||
<property name="orientation">
|
<property name="font">
|
||||||
<enum>Qt::Horizontal</enum>
|
<font>
|
||||||
|
<pointsize>11</pointsize>
|
||||||
|
</font>
|
||||||
</property>
|
</property>
|
||||||
<property name="sizeHint" stdset="0">
|
<property name="text">
|
||||||
<size>
|
<string>Welcome to InkBox</string>
|
||||||
<width>40</width>
|
|
||||||
<height>20</height>
|
|
||||||
</size>
|
|
||||||
</property>
|
</property>
|
||||||
</spacer>
|
<property name="alignment">
|
||||||
|
<set>Qt::AlignCenter</set>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item row="0" column="4">
|
<item row="0" column="9">
|
||||||
<widget class="QLabel" name="label_2">
|
<widget class="QLabel" name="batteryLabel">
|
||||||
|
<property name="font">
|
||||||
|
<font>
|
||||||
|
<weight>75</weight>
|
||||||
|
<bold>true</bold>
|
||||||
|
</font>
|
||||||
|
</property>
|
||||||
|
<property name="text">
|
||||||
|
<string>batteryLevel</string>
|
||||||
|
</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">
|
<property name="text">
|
||||||
<string>―</string>
|
<string>―</string>
|
||||||
</property>
|
</property>
|
||||||
|
@ -67,39 +83,46 @@
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item row="0" column="3">
|
<item row="0" column="1">
|
||||||
<widget class="QLabel" name="inkboxLabel">
|
<spacer name="horizontalSpacer">
|
||||||
<property name="font">
|
<property name="orientation">
|
||||||
<font>
|
<enum>Qt::Horizontal</enum>
|
||||||
<pointsize>11</pointsize>
|
|
||||||
</font>
|
|
||||||
</property>
|
</property>
|
||||||
<property name="text">
|
<property name="sizeHint" stdset="0">
|
||||||
<string>Welcome to InkBox</string>
|
<size>
|
||||||
|
<width>40</width>
|
||||||
|
<height>20</height>
|
||||||
|
</size>
|
||||||
</property>
|
</property>
|
||||||
<property name="alignment">
|
</spacer>
|
||||||
<set>Qt::AlignCenter</set>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
</item>
|
||||||
<item row="0" column="2">
|
<item row="0" column="4">
|
||||||
<widget class="QLabel" name="label">
|
<widget class="QLabel" name="label_2">
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>―</string>
|
<string>―</string>
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item row="0" column="6">
|
<item row="0" column="5">
|
||||||
<widget class="QLabel" name="dateLabel">
|
<spacer name="horizontalSpacer_2">
|
||||||
<property name="font">
|
<property name="orientation">
|
||||||
<font>
|
<enum>Qt::Horizontal</enum>
|
||||||
<pointsize>11</pointsize>
|
|
||||||
<weight>75</weight>
|
|
||||||
<bold>true</bold>
|
|
||||||
</font>
|
|
||||||
</property>
|
</property>
|
||||||
<property name="text">
|
<property name="sizeHint" stdset="0">
|
||||||
<string>date</string>
|
<size>
|
||||||
|
<width>40</width>
|
||||||
|
<height>20</height>
|
||||||
|
</size>
|
||||||
|
</property>
|
||||||
|
</spacer>
|
||||||
|
</item>
|
||||||
|
<item row="0" column="7">
|
||||||
|
<widget class="Line" name="line_7">
|
||||||
|
<property name="frameShadow">
|
||||||
|
<enum>QFrame::Plain</enum>
|
||||||
|
</property>
|
||||||
|
<property name="orientation">
|
||||||
|
<enum>Qt::Vertical</enum>
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
|
@ -140,22 +163,6 @@
|
||||||
<layout class="QVBoxLayout" name="verticalLayout_2">
|
<layout class="QVBoxLayout" name="verticalLayout_2">
|
||||||
<item>
|
<item>
|
||||||
<layout class="QGridLayout" name="gridLayout_3">
|
<layout class="QGridLayout" name="gridLayout_3">
|
||||||
<item row="3" column="0">
|
|
||||||
<widget class="QLabel" name="recentBooksLabel">
|
|
||||||
<property name="font">
|
|
||||||
<font>
|
|
||||||
<family>Chivo</family>
|
|
||||||
<italic>true</italic>
|
|
||||||
</font>
|
|
||||||
</property>
|
|
||||||
<property name="text">
|
|
||||||
<string>Recently read books will appear here.</string>
|
|
||||||
</property>
|
|
||||||
<property name="alignment">
|
|
||||||
<set>Qt::AlignCenter</set>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item row="2" column="0">
|
<item row="2" column="0">
|
||||||
<spacer name="verticalSpacer_5">
|
<spacer name="verticalSpacer_5">
|
||||||
<property name="orientation">
|
<property name="orientation">
|
||||||
|
@ -185,6 +192,84 @@
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
|
<item row="3" column="0">
|
||||||
|
<widget class="QLabel" name="recentBooksLabel">
|
||||||
|
<property name="font">
|
||||||
|
<font>
|
||||||
|
<family>Chivo</family>
|
||||||
|
<italic>true</italic>
|
||||||
|
</font>
|
||||||
|
</property>
|
||||||
|
<property name="text">
|
||||||
|
<string>Recently read books will appear here.</string>
|
||||||
|
</property>
|
||||||
|
<property name="alignment">
|
||||||
|
<set>Qt::AlignCenter</set>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="0" column="0">
|
||||||
|
<spacer name="verticalSpacer_4">
|
||||||
|
<property name="orientation">
|
||||||
|
<enum>Qt::Vertical</enum>
|
||||||
|
</property>
|
||||||
|
<property name="sizeHint" stdset="0">
|
||||||
|
<size>
|
||||||
|
<width>20</width>
|
||||||
|
<height>40</height>
|
||||||
|
</size>
|
||||||
|
</property>
|
||||||
|
</spacer>
|
||||||
|
</item>
|
||||||
|
<item row="4" column="0">
|
||||||
|
<layout class="QGridLayout" name="gridLayout">
|
||||||
|
<property name="bottomMargin">
|
||||||
|
<number>0</number>
|
||||||
|
</property>
|
||||||
|
<item row="0" column="0">
|
||||||
|
<layout class="QGridLayout" name="gridLayout_6">
|
||||||
|
<property name="bottomMargin">
|
||||||
|
<number>0</number>
|
||||||
|
</property>
|
||||||
|
<item row="0" column="0">
|
||||||
|
<widget class="QPushButton" name="book1Btn">
|
||||||
|
<property name="text">
|
||||||
|
<string>Book 1</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="0" column="1">
|
||||||
|
<widget class="QPushButton" name="book2Btn">
|
||||||
|
<property name="text">
|
||||||
|
<string>Book 2</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
|
</item>
|
||||||
|
<item row="1" column="0">
|
||||||
|
<layout class="QGridLayout" name="gridLayout_8">
|
||||||
|
<property name="bottomMargin">
|
||||||
|
<number>0</number>
|
||||||
|
</property>
|
||||||
|
<item row="0" column="0">
|
||||||
|
<widget class="QPushButton" name="book3Btn">
|
||||||
|
<property name="text">
|
||||||
|
<string>Book 3</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="0" column="1">
|
||||||
|
<widget class="QPushButton" name="book4Btn">
|
||||||
|
<property name="text">
|
||||||
|
<string>Book 4</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
|
</item>
|
||||||
<item row="5" column="0">
|
<item row="5" column="0">
|
||||||
<layout class="QGridLayout" name="gridLayout_4">
|
<layout class="QGridLayout" name="gridLayout_4">
|
||||||
<property name="bottomMargin">
|
<property name="bottomMargin">
|
||||||
|
@ -277,68 +362,6 @@
|
||||||
</item>
|
</item>
|
||||||
</layout>
|
</layout>
|
||||||
</item>
|
</item>
|
||||||
<item row="4" column="0">
|
|
||||||
<layout class="QGridLayout" name="gridLayout">
|
|
||||||
<property name="bottomMargin">
|
|
||||||
<number>0</number>
|
|
||||||
</property>
|
|
||||||
<item row="0" column="0">
|
|
||||||
<layout class="QGridLayout" name="gridLayout_6">
|
|
||||||
<property name="bottomMargin">
|
|
||||||
<number>0</number>
|
|
||||||
</property>
|
|
||||||
<item row="0" column="0">
|
|
||||||
<widget class="QPushButton" name="book1Btn">
|
|
||||||
<property name="text">
|
|
||||||
<string>Book 1</string>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item row="0" column="1">
|
|
||||||
<widget class="QPushButton" name="book2Btn">
|
|
||||||
<property name="text">
|
|
||||||
<string>Book 2</string>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
</layout>
|
|
||||||
</item>
|
|
||||||
<item row="1" column="0">
|
|
||||||
<layout class="QGridLayout" name="gridLayout_8">
|
|
||||||
<property name="bottomMargin">
|
|
||||||
<number>0</number>
|
|
||||||
</property>
|
|
||||||
<item row="0" column="0">
|
|
||||||
<widget class="QPushButton" name="book3Btn">
|
|
||||||
<property name="text">
|
|
||||||
<string>Book 3</string>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item row="0" column="1">
|
|
||||||
<widget class="QPushButton" name="book4Btn">
|
|
||||||
<property name="text">
|
|
||||||
<string>Book 4</string>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
</layout>
|
|
||||||
</item>
|
|
||||||
</layout>
|
|
||||||
</item>
|
|
||||||
<item row="0" column="0">
|
|
||||||
<spacer name="verticalSpacer_4">
|
|
||||||
<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>
|
</layout>
|
||||||
</item>
|
</item>
|
||||||
</layout>
|
</layout>
|
||||||
|
|
BIN
resources/frontlight.png
Normal file
BIN
resources/frontlight.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 5.3 KiB |
Loading…
Reference in a new issue