Compare commits

..

1 commit

Author SHA1 Message Date
Ansraer
fbf460775e
Merge 91517f65e4 into cc2af329d0 2024-07-07 12:06:26 -07:00
4 changed files with 95 additions and 64 deletions

View file

@ -83,8 +83,29 @@ QString Device::readFile(QString path) {
}
QString Device::getPowerSupplyPath() {
// Since every or almost every device we support uses this path, we will keep things simple for now
return "/sys/class/power_supply/mc13892_bat/";
// get the path to the battery so we can check the charge latter
QString result;
QDirIterator supplies("/sys/class/power_supply", QDirIterator::NoIteratorFlags);
while(supplies.hasNext()) {
QString supply = supplies.filePath();
// Badly-classified device by some ntx kernels, ignore
if (supplies.fileName() == "mc13892_charger") {
continue;
}
if(QFile::exists(supply + "/type")) {
QString content = readFile(supply + "/type");
if(content == "Battery"){
result = supply;
break;
}
}
supplies.next();
}
return result;
}

View file

@ -11,6 +11,7 @@ DeviceKindleTouch::DeviceKindleTouch()
int DeviceKindleTouch::getBatteryLevel() {
if(QFile::exists("/sys/devices/system/yoshi_battery/yoshi_battery0/battery_capacity")) {
return readFile("/sys/devices/system/yoshi_battery/yoshi_battery0/battery_capacity").toInt();
}
return 100;
}

View file

@ -19,13 +19,13 @@
<item row="28" column="0">
<widget class="Line" name="line_5">
<property name="frameShadow">
<enum>QFrame::Shadow::Plain</enum>
<enum>QFrame::Plain</enum>
</property>
<property name="lineWidth">
<number>2</number>
</property>
<property name="orientation">
<enum>Qt::Orientation::Horizontal</enum>
<enum>Qt::Horizontal</enum>
</property>
</widget>
</item>
@ -37,7 +37,7 @@
<item row="0" column="0">
<spacer name="horizontalSpacer_3">
<property name="orientation">
<enum>Qt::Orientation::Horizontal</enum>
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
@ -50,7 +50,7 @@
<item row="0" column="2">
<spacer name="horizontalSpacer_4">
<property name="orientation">
<enum>Qt::Orientation::Horizontal</enum>
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
@ -64,6 +64,7 @@
<widget class="QLabel" name="label">
<property name="font">
<font>
<weight>75</weight>
<bold>true</bold>
</font>
</property>
@ -71,7 +72,7 @@
<string>InkBox settings</string>
</property>
<property name="alignment">
<set>Qt::AlignmentFlag::AlignCenter</set>
<set>Qt::AlignCenter</set>
</property>
</widget>
</item>
@ -94,13 +95,10 @@
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="currentIndex">
<number>0</number>
</property>
<widget class="QWidget" name="page">
<layout class="QVBoxLayout" name="verticalLayout_4">
<property name="sizeConstraint">
<enum>QLayout::SizeConstraint::SetDefaultConstraint</enum>
<enum>QLayout::SetDefaultConstraint</enum>
</property>
<property name="leftMargin">
<number>0</number>
@ -117,7 +115,7 @@
<item>
<layout class="QHBoxLayout" name="horizontalLayout">
<property name="sizeConstraint">
<enum>QLayout::SizeConstraint::SetDefaultConstraint</enum>
<enum>QLayout::SetDefaultConstraint</enum>
</property>
<property name="bottomMargin">
<number>0</number>
@ -132,7 +130,7 @@
<item>
<spacer name="horizontalSpacer_19">
<property name="orientation">
<enum>Qt::Orientation::Horizontal</enum>
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
@ -154,13 +152,13 @@
<item>
<widget class="Line" name="line_12">
<property name="frameShadow">
<enum>QFrame::Shadow::Plain</enum>
<enum>QFrame::Plain</enum>
</property>
<property name="lineWidth">
<number>2</number>
</property>
<property name="orientation">
<enum>Qt::Orientation::Horizontal</enum>
<enum>Qt::Horizontal</enum>
</property>
</widget>
</item>
@ -172,7 +170,7 @@
<item>
<widget class="QStackedWidget" name="settingsStackedWidget">
<property name="currentIndex">
<number>0</number>
<number>5</number>
</property>
<widget class="QWidget" name="General">
<layout class="QVBoxLayout" name="verticalLayout_7">
@ -193,7 +191,7 @@
<item>
<widget class="QScrollArea" name="scrollArea">
<property name="frameShape">
<enum>QFrame::Shape::NoFrame</enum>
<enum>QFrame::NoFrame</enum>
</property>
<property name="widgetResizable">
<bool>true</bool>
@ -203,8 +201,8 @@
<rect>
<x>0</x>
<y>0</y>
<width>463</width>
<height>587</height>
<width>457</width>
<height>622</height>
</rect>
</property>
<layout class="QVBoxLayout" name="verticalLayout_2">
@ -230,10 +228,10 @@
<item>
<widget class="Line" name="line_13">
<property name="frameShadow">
<enum>QFrame::Shadow::Plain</enum>
<enum>QFrame::Plain</enum>
</property>
<property name="orientation">
<enum>Qt::Orientation::Horizontal</enum>
<enum>Qt::Horizontal</enum>
</property>
</widget>
</item>
@ -247,10 +245,10 @@
<item>
<widget class="Line" name="line_14">
<property name="frameShadow">
<enum>QFrame::Shadow::Plain</enum>
<enum>QFrame::Plain</enum>
</property>
<property name="orientation">
<enum>Qt::Orientation::Horizontal</enum>
<enum>Qt::Horizontal</enum>
</property>
</widget>
</item>
@ -264,10 +262,10 @@
<item>
<widget class="Line" name="line_15">
<property name="frameShadow">
<enum>QFrame::Shadow::Plain</enum>
<enum>QFrame::Plain</enum>
</property>
<property name="orientation">
<enum>Qt::Orientation::Horizontal</enum>
<enum>Qt::Horizontal</enum>
</property>
</widget>
</item>
@ -281,10 +279,10 @@
<item>
<widget class="Line" name="line_16">
<property name="frameShadow">
<enum>QFrame::Shadow::Plain</enum>
<enum>QFrame::Plain</enum>
</property>
<property name="orientation">
<enum>Qt::Orientation::Horizontal</enum>
<enum>Qt::Horizontal</enum>
</property>
</widget>
</item>
@ -298,10 +296,10 @@
<item>
<widget class="Line" name="line_17">
<property name="frameShadow">
<enum>QFrame::Shadow::Plain</enum>
<enum>QFrame::Plain</enum>
</property>
<property name="orientation">
<enum>Qt::Orientation::Horizontal</enum>
<enum>Qt::Horizontal</enum>
</property>
</widget>
</item>
@ -315,7 +313,7 @@
<item>
<spacer name="verticalSpacer_3">
<property name="orientation">
<enum>Qt::Orientation::Vertical</enum>
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
@ -332,13 +330,13 @@
<item>
<widget class="Line" name="line_18">
<property name="frameShadow">
<enum>QFrame::Shadow::Plain</enum>
<enum>QFrame::Plain</enum>
</property>
<property name="lineWidth">
<number>2</number>
</property>
<property name="orientation">
<enum>Qt::Orientation::Horizontal</enum>
<enum>Qt::Horizontal</enum>
</property>
</widget>
</item>
@ -352,13 +350,13 @@
<item>
<widget class="Line" name="line_2">
<property name="frameShadow">
<enum>QFrame::Shadow::Plain</enum>
<enum>QFrame::Plain</enum>
</property>
<property name="lineWidth">
<number>2</number>
</property>
<property name="orientation">
<enum>Qt::Orientation::Horizontal</enum>
<enum>Qt::Horizontal</enum>
</property>
</widget>
</item>
@ -366,6 +364,7 @@
<widget class="QPushButton" name="okBtn">
<property name="font">
<font>
<weight>75</weight>
<bold>true</bold>
</font>
</property>
@ -397,10 +396,10 @@ Save &amp;&amp; Quit
<item>
<widget class="QScrollArea" name="scrollArea_2">
<property name="frameShape">
<enum>QFrame::Shape::NoFrame</enum>
<enum>QFrame::NoFrame</enum>
</property>
<property name="frameShadow">
<enum>QFrame::Shadow::Sunken</enum>
<enum>QFrame::Sunken</enum>
</property>
<property name="widgetResizable">
<bool>true</bool>
@ -410,8 +409,8 @@ Save &amp;&amp; Quit
<rect>
<x>0</x>
<y>0</y>
<width>425</width>
<height>723</height>
<width>235</width>
<height>258</height>
</rect>
</property>
<layout class="QVBoxLayout" name="verticalLayout_3">
@ -457,7 +456,7 @@ Save &amp;&amp; Quit
<item row="1" column="1">
<spacer name="horizontalSpacer_5">
<property name="orientation">
<enum>Qt::Orientation::Horizontal</enum>
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
@ -535,7 +534,7 @@ Save &amp;&amp; Quit
<item row="1" column="0">
<spacer name="horizontalSpacer_11">
<property name="orientation">
<enum>Qt::Orientation::Horizontal</enum>
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
@ -580,7 +579,7 @@ Save &amp;&amp; Quit
<item row="1" column="6">
<spacer name="horizontalSpacer_17">
<property name="orientation">
<enum>Qt::Orientation::Horizontal</enum>
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
@ -607,7 +606,7 @@ Save &amp;&amp; Quit
<item row="0" column="1">
<spacer name="horizontalSpacer_7">
<property name="orientation">
<enum>Qt::Orientation::Horizontal</enum>
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
@ -693,6 +692,7 @@ Save &amp;&amp; Quit
<widget class="QPushButton" name="exportHighlightsBtn">
<property name="font">
<font>
<weight>75</weight>
<bold>true</bold>
</font>
</property>
@ -704,7 +704,7 @@ Save &amp;&amp; Quit
<item row="0" column="1">
<spacer name="horizontalSpacer_12">
<property name="orientation">
<enum>Qt::Orientation::Horizontal</enum>
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
@ -726,7 +726,7 @@ Save &amp;&amp; Quit
<item>
<spacer name="verticalSpacer_4">
<property name="orientation">
<enum>Qt::Orientation::Vertical</enum>
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
@ -782,7 +782,7 @@ Save &amp;&amp; Quit
<item row="5" column="0">
<spacer name="verticalSpacer_5">
<property name="orientation">
<enum>Qt::Orientation::Vertical</enum>
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
@ -822,7 +822,7 @@ Save &amp;&amp; Quit
<item>
<spacer name="verticalSpacer_6">
<property name="orientation">
<enum>Qt::Orientation::Vertical</enum>
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
@ -871,6 +871,7 @@ Save &amp;&amp; Quit
<widget class="QPushButton" name="usbmsBtn">
<property name="font">
<font>
<weight>75</weight>
<bold>true</bold>
</font>
</property>
@ -882,7 +883,7 @@ Save &amp;&amp; Quit
<item row="1" column="1">
<spacer name="horizontalSpacer_2">
<property name="orientation">
<enum>Qt::Orientation::Horizontal</enum>
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
@ -904,7 +905,7 @@ Save &amp;&amp; Quit
<item row="2" column="0">
<spacer name="verticalSpacer_7">
<property name="orientation">
<enum>Qt::Orientation::Vertical</enum>
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
@ -958,7 +959,7 @@ Save &amp;&amp; Quit
<item row="0" column="1">
<spacer name="horizontalSpacer_6">
<property name="orientation">
<enum>Qt::Orientation::Horizontal</enum>
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
@ -972,6 +973,7 @@ Save &amp;&amp; Quit
<widget class="QPushButton" name="showSystemInfoBtn">
<property name="font">
<font>
<weight>75</weight>
<bold>true</bold>
</font>
</property>
@ -991,6 +993,7 @@ Save &amp;&amp; Quit
<widget class="QPushButton" name="generateSystemReportBtn">
<property name="font">
<font>
<weight>75</weight>
<bold>true</bold>
</font>
</property>
@ -1002,7 +1005,7 @@ Save &amp;&amp; Quit
<item row="0" column="1">
<spacer name="horizontalSpacer_15">
<property name="orientation">
<enum>Qt::Orientation::Horizontal</enum>
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
@ -1037,6 +1040,7 @@ Save &amp;&amp; Quit
<widget class="QPushButton" name="checkOtaUpdateBtn">
<property name="font">
<font>
<weight>75</weight>
<bold>true</bold>
</font>
</property>
@ -1048,7 +1052,7 @@ Save &amp;&amp; Quit
<item row="1" column="1">
<spacer name="horizontalSpacer_13">
<property name="orientation">
<enum>Qt::Orientation::Horizontal</enum>
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
@ -1076,6 +1080,7 @@ Save &amp;&amp; Quit
<widget class="QPushButton" name="updateBtn">
<property name="font">
<font>
<weight>75</weight>
<bold>true</bold>
</font>
</property>
@ -1087,7 +1092,7 @@ Save &amp;&amp; Quit
<item row="0" column="1">
<spacer name="horizontalSpacer_10">
<property name="orientation">
<enum>Qt::Orientation::Horizontal</enum>
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
@ -1103,7 +1108,7 @@ Save &amp;&amp; Quit
<string>Update InkBox</string>
</property>
<property name="alignment">
<set>Qt::AlignmentFlag::AlignLeading|Qt::AlignmentFlag::AlignLeft|Qt::AlignmentFlag::AlignVCenter</set>
<set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter</set>
</property>
</widget>
</item>
@ -1117,7 +1122,7 @@ Save &amp;&amp; Quit
<item row="0" column="1">
<spacer name="horizontalSpacer_16">
<property name="orientation">
<enum>Qt::Orientation::Horizontal</enum>
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
@ -1142,7 +1147,7 @@ Save &amp;&amp; Quit
<item row="10" column="0">
<spacer name="verticalSpacer_8">
<property name="orientation">
<enum>Qt::Orientation::Vertical</enum>
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
@ -1160,7 +1165,7 @@ Save &amp;&amp; Quit
<item row="2" column="1">
<spacer name="horizontalSpacer">
<property name="orientation">
<enum>Qt::Orientation::Horizontal</enum>
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
@ -1181,6 +1186,7 @@ Save &amp;&amp; Quit
<widget class="QPushButton" name="requestLeaseBtn">
<property name="font">
<font>
<weight>75</weight>
<bold>true</bold>
</font>
</property>
@ -1220,6 +1226,7 @@ Save &amp;&amp; Quit
<widget class="QPushButton" name="resetBtn">
<property name="font">
<font>
<weight>75</weight>
<bold>true</bold>
</font>
</property>
@ -1231,7 +1238,7 @@ Save &amp;&amp; Quit
<item row="0" column="1">
<spacer name="horizontalSpacer_8">
<property name="orientation">
<enum>Qt::Orientation::Horizontal</enum>
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
@ -1281,7 +1288,7 @@ Save &amp;&amp; Quit
<item row="0" column="1">
<spacer name="horizontalSpacer_14">
<property name="orientation">
<enum>Qt::Orientation::Horizontal</enum>
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
@ -1302,6 +1309,7 @@ Save &amp;&amp; Quit
<widget class="QPushButton" name="repackBtn">
<property name="font">
<font>
<weight>75</weight>
<bold>true</bold>
</font>
</property>
@ -1320,7 +1328,7 @@ Save &amp;&amp; Quit
<item row="0" column="1">
<spacer name="horizontalSpacer_18">
<property name="orientation">
<enum>Qt::Orientation::Horizontal</enum>
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
@ -1388,10 +1396,10 @@ Save &amp;&amp; Quit
<item row="5" column="0">
<widget class="Line" name="line_10">
<property name="frameShadow">
<enum>QFrame::Shadow::Plain</enum>
<enum>QFrame::Plain</enum>
</property>
<property name="orientation">
<enum>Qt::Orientation::Horizontal</enum>
<enum>Qt::Horizontal</enum>
</property>
</widget>
</item>
@ -1403,7 +1411,7 @@ Save &amp;&amp; Quit
<item row="1" column="2">
<spacer name="horizontalSpacer_9">
<property name="orientation">
<enum>Qt::Orientation::Horizontal</enum>
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
@ -1424,6 +1432,7 @@ Save &amp;&amp; Quit
<widget class="QPushButton" name="setPasscodeBtn">
<property name="font">
<font>
<weight>75</weight>
<bold>true</bold>
</font>
</property>
@ -1437,7 +1446,7 @@ Save &amp;&amp; Quit
<item row="8" column="0">
<spacer name="verticalSpacer_9">
<property name="orientation">
<enum>Qt::Orientation::Vertical</enum>
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>

View file

@ -12,7 +12,7 @@ void UI::applyStyle(QWidget &widget, QString styleName) {
styleName = Device::getSingleton()->getStyleSheetPath() + styleName;
}
if(!styleName.endsWith(".qss")) {
styleName = styleName + ".qss";
styleName = styleName + "qss";
}
QFile stylesheetFile(styleName);